AgentSkillsCN

ink-steps

使用 ProcedureStep 和 useProgram 构建 Ink 的 CLI 步骤。当您使用 Ink、ProcedureStep、ProcedureStepError、ProcedureStepLoading、ProcedureStepSuccess、ProcedureNextStep 等组件构建基于步骤的 CLI 界面时,或者在选择 useProgram 键时,请使用此方法。

SKILL.md
--- frontmatter
name: ink-steps
description: Build CLI steps with Ink using ProcedureStep and useProgram. Use when building step-based CLI UIs with Ink, ProcedureStep, ProcedureStepError, ProcedureStepLoading, ProcedureStepSuccess, ProcedureNextStep, or when choosing useProgram keys.

Step components (ProcedureStep, useProgram)

When building CLI steps with Ink, use ProcedureStep and useProgram as below.

ProcedureStep: no conditional rendering

Do not branch on status and return different JSX. Render a single <ProcedureStep status={status}> and put the step pieces inside it. ProcedureStep (and its children: ProcedureStepError, ProcedureStepLoading, ProcedureStepSuccess, ProcedureNextStep) decide what to show from status. One return, one ProcedureStep.

tsx
// Good: one ProcedureStep, status drives what's shown
return (
  <ProcedureStep status={status}>
    <ProcedureStepError error={error} />
    <ProcedureStepLoading message="..." />
    <ProcedureStepSuccess><Text>...</Text></ProcedureStepSuccess>
    <ProcedureNextStep>{data && children(data)}</ProcedureNextStep>
  </ProcedureStep>
);

// Bad: branching and multiple returns
if (status === 'loading') return <ProcedureStep status="loading">...</ProcedureStep>;
if (status === 'error') return ...;
return <>{children(data)}</>;

useProgram key: one stable key

The key for useProgram should be a single, stable identifier for that step (e.g. the component or step name). It does not need to encode repoPath, slug, or other fetcher arguments. Use something like 'GetLocalSkills', not getLocalSkills-${repoPath}-${slug}.