Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 35 additions & 85 deletions src/components/SkillInstallCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import type { ClawdisSkillMetadata } from 'clawhub-schema'
import { formatInstallCommand, formatInstallLabel } from './skillDetailUtils'

const CAPABILITY_DISPLAY: Record<string, { icon: string; label: string }> = {
shell: { icon: '>_', label: 'Shell commands' },
filesystem: { icon: '\uD83D\uDCC2', label: 'File access' },
network: { icon: '\uD83C\uDF10', label: 'Web search/fetch' },
browser: { icon: '\uD83D\uDD0D', label: 'Browser control' },
sessions: { icon: '\u26A1', label: 'Session orchestration' },
messaging: { icon: '\u2709\uFE0F', label: 'Message sending' },
scheduling: { icon: '\u23F0', label: 'Scheduling/cron' },
}

type SkillInstallCardProps = {
clawdis: ClawdisSkillMetadata | undefined
osLabels: string[]
Expand All @@ -9,28 +19,44 @@ type SkillInstallCardProps = {
export function SkillInstallCard({ clawdis, osLabels }: SkillInstallCardProps) {
const requirements = clawdis?.requires
const installSpecs = clawdis?.install ?? []
const envVars = clawdis?.envVars ?? []
const dependencies = clawdis?.dependencies ?? []
const links = clawdis?.links
const hasRuntimeRequirements = Boolean(
clawdis?.emoji ||
osLabels.length ||
requirements?.bins?.length ||
requirements?.anyBins?.length ||
requirements?.env?.length ||
requirements?.config?.length ||
clawdis?.primaryEnv ||
envVars.length,
clawdis?.primaryEnv,
)
const hasInstallSpecs = installSpecs.length > 0
const hasDependencies = dependencies.length > 0
const hasLinks = Boolean(links?.homepage || links?.repository || links?.documentation)

if (!hasRuntimeRequirements && !hasInstallSpecs && !hasDependencies && !hasLinks) return null
const hasCapabilities = Boolean(clawdis?.capabilities?.length)

return (
<div className="skill-hero-content">
<div className="skill-hero-panels">
{hasCapabilities ? (
<div className="skill-panel">
<h3 className="section-title" style={{ fontSize: '1rem', margin: 0 }}>
Capabilities
</h3>
<div className="skill-panel-body">
{clawdis!.capabilities!.map((cap) => (
<div key={cap} className="stat">
<span>{CAPABILITY_DISPLAY[cap]?.icon ?? cap}</span>
<span>{CAPABILITY_DISPLAY[cap]?.label ?? cap}</span>
</div>
))}
</div>
</div>
) : (
<div className="skill-panel">
<div className="skill-panel-body">
<div className="stat" style={{ color: 'var(--ink-soft)' }}>
<span>No capabilities declared</span>
</div>
</div>
</div>
)}
{hasRuntimeRequirements ? (
<div className="skill-panel">
<h3 className="section-title" style={{ fontSize: '1rem', margin: 0 }}>
Expand Down Expand Up @@ -74,55 +100,6 @@ export function SkillInstallCard({ clawdis, osLabels }: SkillInstallCardProps) {
<span>{clawdis.primaryEnv}</span>
</div>
) : null}
{envVars.length > 0 ? (
<div className="stat">
<strong>Environment variables</strong>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.25rem', marginTop: '0.25rem' }}>
{envVars.map((env, index) => (
<div key={`${env.name}-${index}`} style={{ display: 'flex', alignItems: 'baseline', gap: '0.5rem' }}>
<code style={{ fontSize: '0.85rem' }}>{env.name}</code>
{env.required === false ? (
<span style={{ color: 'var(--ink-soft)', fontSize: '0.75rem' }}>optional</span>
) : env.required === true ? (
<span style={{ color: 'var(--ink-accent)', fontSize: '0.75rem' }}>required</span>
) : null}
{env.description ? (
<span style={{ color: 'var(--ink-soft)', fontSize: '0.8rem' }}>— {env.description}</span>
) : null}
</div>
))}
</div>
</div>
) : null}
</div>
</div>
) : null}
{hasDependencies ? (
<div className="skill-panel">
<h3 className="section-title" style={{ fontSize: '1rem', margin: 0 }}>
Dependencies
</h3>
<div className="skill-panel-body">
{dependencies.map((dep, index) => (
<div key={`${dep.name}-${index}`} className="stat">
<div>
<strong>{dep.name}</strong>
<span style={{ color: 'var(--ink-soft)', fontSize: '0.85rem', marginLeft: '0.5rem' }}>
{dep.type}{dep.version ? ` ${dep.version}` : ''}
</span>
{dep.url ? (
<div style={{ fontSize: '0.8rem' }}>
<a href={dep.url} target="_blank" rel="noopener noreferrer">{dep.url}</a>
</div>
) : null}
{dep.repository && dep.repository !== dep.url ? (
<div style={{ fontSize: '0.8rem' }}>
<a href={dep.repository} target="_blank" rel="noopener noreferrer">Source</a>
</div>
) : null}
</div>
</div>
))}
</div>
</div>
) : null}
Expand Down Expand Up @@ -151,33 +128,6 @@ export function SkillInstallCard({ clawdis, osLabels }: SkillInstallCardProps) {
</div>
</div>
) : null}
{hasLinks ? (
<div className="skill-panel">
<h3 className="section-title" style={{ fontSize: '1rem', margin: 0 }}>
Links
</h3>
<div className="skill-panel-body">
{links?.homepage ? (
<div className="stat">
<strong>Homepage</strong>
<a href={links.homepage} target="_blank" rel="noopener noreferrer">{links.homepage}</a>
</div>
) : null}
{links?.repository ? (
<div className="stat">
<strong>Repository</strong>
<a href={links.repository} target="_blank" rel="noopener noreferrer">{links.repository}</a>
</div>
) : null}
{links?.documentation ? (
<div className="stat">
<strong>Docs</strong>
<a href={links.documentation} target="_blank" rel="noopener noreferrer">{links.documentation}</a>
</div>
) : null}
</div>
</div>
) : null}
</div>
</div>
)
Expand Down
Loading