input-kanban 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
7
7
  const PACKAGE_VERSION = JSON.parse(await fsp.readFile(new URL('../package.json', import.meta.url), 'utf8')).version;
8
8
  const VALID_RUNNERS = ['headless', 'tmux'];
9
9
  const VALID_SANDBOXES = ['read-only', 'workspace-write', 'danger-full-access'];
10
- const COMMANDS = new Set(['serve', 'submit', 'runs', 'status', 'result', 'retry', 'stop', 'auto']);
10
+ const COMMANDS = new Set(['serve', 'submit', 'runs', 'status', 'result', 'retry', 'stop', 'auto', 'guide', 'install-skill']);
11
11
  const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
12
12
  const STATUS_TEXT = {
13
13
  created: '已创建', planning: '拆分中', plan_failed: '拆分失败', plan_empty: '拆分为空', planned: '已拆分',
@@ -167,6 +167,33 @@ function parseAutoArgs(argv) {
167
167
  return args;
168
168
  }
169
169
 
170
+ function parseGuideArgs(argv) {
171
+ const args = { json: false, help: false };
172
+ for (let i = 0; i < argv.length; i++) {
173
+ const arg = argv[i];
174
+ if (arg === '--help' || arg === '-h') args.help = true;
175
+ else if (arg === '--json' || arg === '-j') args.json = true;
176
+ else throw new Error(`unknown guide argument: ${arg}`);
177
+ }
178
+ return args;
179
+ }
180
+
181
+ function parseInstallSkillArgs(argv) {
182
+ const args = { provider: undefined, targetDir: undefined, force: false, dryRun: false, json: false, help: false };
183
+ for (let i = 0; i < argv.length; i++) {
184
+ const arg = argv[i];
185
+ const next = () => argv[++i];
186
+ if (arg === '--help' || arg === '-h') args.help = true;
187
+ else if (arg === '--json' || arg === '-j') args.json = true;
188
+ else if (arg === '--target-dir') args.targetDir = next();
189
+ else if (arg === '--force') args.force = true;
190
+ else if (arg === '--dry-run') args.dryRun = true;
191
+ else if (!arg.startsWith('-') && !args.provider) args.provider = arg;
192
+ else throw new Error(`unknown install-skill argument: ${arg}`);
193
+ }
194
+ return args;
195
+ }
196
+
170
197
  function parseSubmitArgs(argv) {
171
198
  const args = {
172
199
  host: '127.0.0.1', port: 8787, workspace: undefined, repo: undefined, runsDir: undefined, codexBin: undefined,
@@ -234,6 +261,8 @@ Usage:
234
261
  input-kanban [options]
235
262
  input-kanban serve [options]
236
263
  input-kanban submit [options]
264
+ input-kanban guide [options]
265
+ input-kanban install-skill codex [options]
237
266
  input-kanban --version
238
267
  input-kanban runs [options]
239
268
  input-kanban status [runId] [options]
@@ -241,6 +270,11 @@ Usage:
241
270
  input-kanban retry <runId> [taskId] [options]
242
271
  input-kanban stop <runId> [options]
243
272
 
273
+ Agent guide:
274
+ input-kanban guide Print a friendly agent-oriented control loop and templates
275
+ input-kanban install-skill codex
276
+ Install bundled input-kanban-prepare skill for Codex
277
+
244
278
  Serve options:
245
279
  --host <host> Host to bind, default 127.0.0.1
246
280
  -p, --port <port> Port to bind, default 8787
@@ -283,6 +317,12 @@ Stop options:
283
317
  --reason <text> Stop reason stored in run state
284
318
  -j, --json Emit JSON output instead of human text
285
319
 
320
+ Install skill options:
321
+ --target-dir <path> Codex skills root, default $CODEX_SKILLS_DIR or ~/.codex/skills
322
+ --dry-run Print the planned install target without copying files
323
+ --force Replace an existing installed skill directory
324
+ -j, --json Emit JSON output instead of human text
325
+
286
326
  Submit options:
287
327
  --workspace <path> Target workspace, default current directory
288
328
  -r, --repo <path> Alias for --workspace
@@ -427,6 +467,94 @@ Options:
427
467
  `);
428
468
  }
429
469
 
470
+ function printInstallSkillHelp() {
471
+ console.log(`input-kanban install-skill
472
+
473
+ Usage:
474
+ input-kanban install-skill codex
475
+ input-kanban install-skill codex --target-dir ~/.codex/skills
476
+ input-kanban install-skill codex --dry-run
477
+ input-kanban --json install-skill codex
478
+
479
+ Options:
480
+ --target-dir <path> Codex skills root, default $CODEX_SKILLS_DIR or ~/.codex/skills
481
+ --dry-run Print the planned install target without copying files
482
+ --force Replace an existing installed skill directory
483
+ -j, --json Emit JSON output instead of human text
484
+ `);
485
+ }
486
+
487
+ function printAgentGuide(json = false) {
488
+ const quickStart = [
489
+ 'Use `input-kanban` as the execution tool.',
490
+ 'Treat `submit` as a new task identity.',
491
+ 'Treat `retry` as a new attempt for the same task.',
492
+ 'If the task came from an external chat, prepare a structured `task.md` first.',
493
+ 'Use `status` before any state-dependent action.',
494
+ 'Use `result` for the final outcome.',
495
+ 'Use `stop` only with a known `runId`.'
496
+ ];
497
+ const templates = [
498
+ 'input-kanban submit --task "Implement the new gate workflow" --label "gate-workflow"',
499
+ 'input-kanban submit --task-file task.md',
500
+ 'input-kanban submit --task-file task.md --plan-approval',
501
+ 'input-kanban submit --task-file task.md --detach',
502
+ 'input-kanban status run_1234567890',
503
+ 'input-kanban status run_1234567890 --watch',
504
+ 'input-kanban result run_1234567890',
505
+ 'input-kanban result run_1234567890 --copy',
506
+ 'input-kanban retry run_1234567890',
507
+ 'input-kanban stop run_1234567890'
508
+ ];
509
+ if (json) {
510
+ printJson({
511
+ ok: true,
512
+ command: 'guide',
513
+ title: 'Input Kanban Agent Guide',
514
+ quickStart,
515
+ templates,
516
+ handoffSections: ['Goal', 'Acceptance Criteria', 'Expected Artifacts', 'Context References', 'Risks'],
517
+ skillInstall: 'input-kanban install-skill codex',
518
+ rules: [
519
+ 'submit = new task identity',
520
+ 'retry = same task definition, new attempt',
521
+ 'status = inspect before acting',
522
+ 'result = final confirmation',
523
+ 'stop = only with explicit runId'
524
+ ]
525
+ });
526
+ return;
527
+ }
528
+ console.log(`Input Kanban Agent Guide
529
+
530
+ Quick start:
531
+ ${quickStart.map(item => ` - ${item}`).join('\n')}
532
+
533
+ Core commands:
534
+ submit Create a new run for a new task identity
535
+ retry Re-attempt the same task definition with a new attempt
536
+ status Inspect current progress before acting
537
+ result Read the final outcome
538
+ stop Halt a known run
539
+
540
+ Preparation before submit:
541
+ - Goal
542
+ - Acceptance Criteria
543
+ - Expected Artifacts
544
+ - Context References
545
+ - Risks
546
+
547
+ Install bundled prepare skill:
548
+ input-kanban install-skill codex
549
+
550
+ Example templates:
551
+ ${templates.map((item, index) => ` ${String(index + 1).padStart(2, '0')}. ${item}`).join('\n')}
552
+
553
+ See also:
554
+ input-kanban --help
555
+ `);
556
+ }
557
+
430
558
  function openBrowser(url) {
431
559
  const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
432
560
  const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
@@ -679,6 +807,55 @@ async function copyToClipboard(text) {
679
807
  throw new Error(`无法复制到剪贴板:${lastError?.message || '未找到可用剪贴板命令'}`);
680
808
  }
681
809
 
810
+ function homeDir() {
811
+ if (process.env.HOME) return process.env.HOME;
812
+ if (process.env.USERPROFILE) return process.env.USERPROFILE;
813
+ if (process.env.HOMEDRIVE && process.env.HOMEPATH) return `${process.env.HOMEDRIVE}${process.env.HOMEPATH}`;
814
+ return '';
815
+ }
816
+
817
+ function defaultCodexSkillsDir() {
818
+ if (process.env.CODEX_SKILLS_DIR) return path.resolve(process.env.CODEX_SKILLS_DIR);
819
+ const home = homeDir();
820
+ if (!home) throw new Error('cannot determine home directory; pass --target-dir');
821
+ return path.join(home, '.codex', 'skills');
822
+ }
823
+
824
+ async function pathExists(filePath) {
825
+ try { await fsp.access(filePath); return true; }
826
+ catch { return false; }
827
+ }
828
+
829
+ async function installSkill(args) {
830
+ const provider = String(args.provider || '').toLowerCase();
831
+ if (!provider) throw new Error('install-skill requires a provider, currently: codex');
832
+ if (provider !== 'codex') throw new Error(`unsupported skill provider: ${args.provider}; expected codex`);
833
+ const sourceDir = fileURLToPath(new URL('../skills/input-kanban-prepare', import.meta.url));
834
+ const skillsRoot = args.targetDir ? path.resolve(args.targetDir) : defaultCodexSkillsDir();
835
+ const targetDir = path.join(skillsRoot, 'input-kanban-prepare');
836
+ const exists = await pathExists(targetDir);
837
+ const payload = { ok: true, command: 'install-skill', provider, skill: 'input-kanban-prepare', sourceDir, skillsRoot, targetDir, dryRun: !!args.dryRun, installed: false, replaced: false };
838
+ if (args.dryRun) {
839
+ if (args.json) { printJson(payload); return; }
840
+ console.log(`Skill: input-kanban-prepare`);
841
+ console.log(`Provider: codex`);
842
+ console.log(`Source: ${sourceDir}`);
843
+ console.log(`Target: ${targetDir}`);
844
+ console.log('Dry run: no files copied');
845
+ return;
846
+ }
847
+ if (exists && !args.force) throw new Error(`skill already exists: ${targetDir}; pass --force to replace it`);
848
+ await fsp.mkdir(skillsRoot, { recursive: true });
849
+ if (exists && args.force) await fsp.rm(targetDir, { recursive: true, force: true });
850
+ await fsp.cp(sourceDir, targetDir, { recursive: true });
851
+ payload.installed = true;
852
+ payload.replaced = exists && !!args.force;
853
+ if (args.json) { printJson(payload); return; }
854
+ console.log(`已安装 Codex skill: input-kanban-prepare`);
855
+ console.log(`位置: ${targetDir}`);
856
+ console.log('在 Codex 对话中可尝试使用:use input-kanban-prepare skill');
857
+ }
858
+
682
859
  async function result(args) {
683
860
  applyRuntimeEnv(args);
684
861
  const runId = args.runId || await latestRunId();
@@ -778,6 +955,16 @@ try {
778
955
  args.json = args.json || globals.json;
779
956
  if (args.help) { printSubmitHelp(); process.exit(0); }
780
957
  await submit(args);
958
+ } else if (command === 'guide') {
959
+ const args = parseGuideArgs(rest);
960
+ args.json = args.json || globals.json;
961
+ if (args.help) { printAgentGuide(args.json); process.exit(0); }
962
+ printAgentGuide(args.json);
963
+ } else if (command === 'install-skill') {
964
+ const args = parseInstallSkillArgs(rest);
965
+ args.json = args.json || globals.json;
966
+ if (args.help) { printInstallSkillHelp(); process.exit(0); }
967
+ await installSkill(args);
781
968
  } else if (command === 'runs') {
782
969
  const args = parseRunsArgs(rest);
783
970
  args.json = args.json || globals.json;
@@ -0,0 +1,41 @@
1
+ # Input Kanban CLI Usage
2
+
3
+ This page is only the entry point.
4
+
5
+ Before using `input-kanban` from another project, read:
6
+
7
+ - `docs/input-kanban-cli-skill.md`
8
+ - `docs/input-kanban-prepare.md` when the task comes from an external Agent conversation
9
+
10
+ ## What this is for
11
+
12
+ - Controlled execution through the `input-kanban` CLI
13
+ - Structured handoff from external Agent conversations
14
+ - Status checks, retry handling, result retrieval, and stop control
15
+ - Agent usage in a project that needs stable task execution
16
+
17
+ ## What this is not for
18
+
19
+ - Task decomposition
20
+ - Final acceptance decisions
21
+ - Replacing external gate checks
22
+
23
+ ## Install the bundled prepare skill
24
+
25
+ ```bash
26
+ input-kanban install-skill codex
27
+ ```
28
+
29
+ Use `--target-dir` if your Codex skills root is not `~/.codex/skills`:
30
+
31
+ ```bash
32
+ input-kanban install-skill codex --target-dir /path/to/codex/skills
33
+ ```
34
+
35
+ ## Quick rule
36
+
37
+ - Use `submit` for a new task identity
38
+ - Use `retry` for the same task definition with a new attempt
39
+ - Use `status` before state-dependent actions
40
+ - Use `result` for final confirmation
41
+ - Use `stop` only with an explicit `runId`
@@ -0,0 +1,241 @@
1
+ # Input Kanban CLI Skill Draft
2
+
3
+ ## Purpose
4
+
5
+ Use the `input-kanban` CLI as the execution tool for tasks that have already been decomposed and accepted externally. This skill is for controlled execution, status checks, retry handling, and result retrieval. It is not responsible for task decomposition or final acceptance decisions.
6
+
7
+ ## Core Principles
8
+
9
+ - Treat `input-kanban` as the execution surface, not the source of truth for decomposition or acceptance.
10
+ - Prefer updating or retrying an existing run instead of creating a new run when the task definition is the same.
11
+ - Keep task identity stable and use attempts to represent re-execution.
12
+ - Use `status`, `result`, and `stop` for observation and control.
13
+ - Do not rely on the model alone to declare completion.
14
+
15
+ ## Before `submit`: Prepare the Handoff
16
+
17
+ If the task came from an external Agent conversation, prepare a structured `task.md` first. Prefer these sections:
18
+
19
+ - `Goal`
20
+ - `Acceptance Criteria`
21
+ - `Expected Artifacts`
22
+ - `Context References`
23
+ - `Risks`
24
+
25
+ Use `skills/input-kanban-prepare/SKILL.md` when an Agent needs a stricter preparation workflow.
26
+
27
+ ## When to Use `submit`
28
+
29
+ Use `submit` only when a new task identity is needed.
30
+
31
+ Examples:
32
+
33
+ - The task goal changed.
34
+ - The workspace or scope changed materially.
35
+ - You intentionally want to start a new run with a clean history.
36
+
37
+ Recommended forms:
38
+
39
+ ```bash
40
+ input-kanban submit --task "..."
41
+ input-kanban submit --task-file task.md
42
+ input-kanban submit --task-file task.md --plan-approval
43
+ ```
44
+
45
+ ## When to Use `retry`
46
+
47
+ Use `retry` when the task is the same, but the previous execution did not pass a gate or failed to complete correctly.
48
+
49
+ Examples:
50
+
51
+ - Planner output was invalid.
52
+ - A worker failed or was marked unknown.
53
+ - The final judge needs another attempt after a blocking issue is resolved.
54
+
55
+ Recommended forms:
56
+
57
+ ```bash
58
+ input-kanban retry <runId>
59
+ input-kanban retry <runId> <taskId>
60
+ ```
61
+
62
+ Retry should be treated as a new execution attempt for the same task definition, not as an overwrite of the prior attempt.
63
+
64
+ ## When to Use `status`
65
+
66
+ Use `status` whenever you need to know the current state before acting.
67
+
68
+ Recommended forms:
69
+
70
+ ```bash
71
+ input-kanban status <runId>
72
+ input-kanban status <runId> --watch
73
+ input-kanban --json status <runId>
74
+ ```
75
+
76
+ Use `--json` when another tool or agent needs structured output.
77
+
78
+ ## When to Use `result`
79
+
80
+ Use `result` only after the run reaches a terminal state or when a final outcome is needed for review.
81
+
82
+ Recommended forms:
83
+
84
+ ```bash
85
+ input-kanban result <runId>
86
+ input-kanban --json result <runId>
87
+ input-kanban result <runId> --copy
88
+ ```
89
+
90
+ Prefer the persisted judge result over the model's own summary.
91
+
92
+ ## When to Use `stop`
93
+
94
+ Use `stop` when execution should halt immediately.
95
+
96
+ Recommended form:
97
+
98
+ ```bash
99
+ input-kanban stop <runId>
100
+ ```
101
+
102
+ Only stop an explicitly named run. Never stop by guesswork.
103
+
104
+ ## Suggested Control Loop
105
+
106
+ 1. Discover active work:
107
+
108
+ ```bash
109
+ input-kanban --json runs --active
110
+ ```
111
+
112
+ 2. Inspect a run:
113
+
114
+ ```bash
115
+ input-kanban --json status <runId>
116
+ ```
117
+
118
+ 3. If blocked or failed, decide whether to retry or stop.
119
+ 4. If retry is appropriate, call `retry` on the same run.
120
+ 5. If the task is complete, fetch the final result:
121
+
122
+ ```bash
123
+ input-kanban --json result <runId>
124
+ ```
125
+
126
+ ## Decision Rules
127
+
128
+ - Use `submit` only for a new task identity.
129
+ - Use `retry` for the same task definition with a new execution attempt.
130
+ - Use `status` before any action that depends on current state.
131
+ - Use `result` for final confirmation.
132
+ - Use `stop` only with a known `runId`.
133
+
134
+ ## Safety Rules
135
+
136
+ - Do not create a new run just to recover from a failed attempt if the task definition has not changed.
137
+ - Do not treat a failed execution as a successful result.
138
+ - Do not let the model self-approve completion without external evidence.
139
+ - Prefer preserving history and attempt lineage.
140
+
141
+ ## Practical Guidance
142
+
143
+ - If the task is still the same, keep the task identity stable and create a new attempt.
144
+ - If the task meaning changed, start a new run.
145
+ - If the run is blocked, surface the warning and wait for external intervention or a retry decision.
146
+ - If the run is already terminal, do not mutate it in place.
147
+
148
+ ## Example Patterns
149
+
150
+ ### New task
151
+
152
+ ```bash
153
+ input-kanban submit --task "Refactor the task scheduler to support gates" --label "Scheduler gate refactor"
154
+ ```
155
+
156
+ ### Retry the same task
157
+
158
+ ```bash
159
+ input-kanban retry run_1234567890
160
+ ```
161
+
162
+ ### Check progress
163
+
164
+ ```bash
165
+ input-kanban status run_1234567890 --watch
166
+ ```
167
+
168
+ ### Get final outcome
169
+
170
+ ```bash
171
+ input-kanban result run_1234567890 --copy
172
+ ```
173
+
174
+ ## Example Templates
175
+
176
+ ### 1. Submit a new task from inline text
177
+
178
+ ```bash
179
+ input-kanban submit --task "Implement the new gate workflow" --label "gate-workflow"
180
+ ```
181
+
182
+ ### 2. Submit a task from a file
183
+
184
+ ```bash
185
+ input-kanban submit --task-file task.md
186
+ ```
187
+
188
+ ### 3. Submit with plan approval enabled
189
+
190
+ ```bash
191
+ input-kanban submit --task-file task.md --plan-approval
192
+ ```
193
+
194
+ ### 4. Submit detached for background execution
195
+
196
+ ```bash
197
+ input-kanban submit --task-file task.md --detach
198
+ ```
199
+
200
+ ### 5. Check a run once
201
+
202
+ ```bash
203
+ input-kanban status run_1234567890
204
+ ```
205
+
206
+ ### 6. Watch a run until it changes
207
+
208
+ ```bash
209
+ input-kanban status run_1234567890 --watch
210
+ ```
211
+
212
+ ### 7. Inspect the final result
213
+
214
+ ```bash
215
+ input-kanban result run_1234567890
216
+ ```
217
+
218
+ ### 8. Copy the final result for handoff
219
+
220
+ ```bash
221
+ input-kanban result run_1234567890 --copy
222
+ ```
223
+
224
+ ### 9. Retry the whole run
225
+
226
+ ```bash
227
+ input-kanban retry run_1234567890
228
+ ```
229
+
230
+ ### 10. Stop a known run immediately
231
+
232
+ ```bash
233
+ input-kanban stop run_1234567890
234
+ ```
235
+
236
+ ## Notes for Agent Behavior
237
+
238
+ - Prefer stable task identity over repeated recreation.
239
+ - Prefer attempt lineage over overwriting history.
240
+ - Treat gates as external decisions, not as assumptions.
241
+ - When in doubt, ask for clarification before creating a new run.
@@ -0,0 +1,93 @@
1
+ # Preparing Tasks for Input Kanban
2
+
3
+ Use this guide when a task starts in an external Agent conversation and should be handed off to `input-kanban` for execution.
4
+
5
+ The goal is not to make Input Kanban do all planning from a vague prompt. The goal is to give it a clear execution contract so the planner, workers, and final judge have better inputs.
6
+
7
+ ## Recommended Flow
8
+
9
+ 1. Use the external Agent conversation to clarify the goal, scope, risks, and acceptance criteria.
10
+ 2. Convert the discussion into a structured `task.md`.
11
+ 3. Submit the task with plan approval:
12
+
13
+ ```bash
14
+ input-kanban submit --task-file task.md --plan-approval
15
+ ```
16
+
17
+ 4. Review the generated plan before dispatching workers.
18
+ 5. Use `status`, `result`, `retry`, and `stop` to control execution.
19
+
20
+ ## Minimal `task.md` Structure
21
+
22
+ ```markdown
23
+ # Task
24
+
25
+ ## Goal
26
+
27
+ Describe the desired outcome in one or two concrete paragraphs.
28
+
29
+ ## Non-Goals
30
+
31
+ - List what should not be changed.
32
+
33
+ ## Acceptance Criteria
34
+
35
+ - [ ] Criterion that can be tested, inspected, or verified.
36
+ - [ ] Another criterion.
37
+
38
+ ## Expected Artifacts
39
+
40
+ - Path: `relative/or/absolute/path`
41
+ Verify: command, inspection step, or expected content.
42
+
43
+ ## Context References
44
+
45
+ - `path/to/spec.md`
46
+ - `path/to/relevant/file.ts`
47
+
48
+ ## Execution Hints
49
+
50
+ ### Suggested Batches
51
+
52
+ - Batch: first safe step
53
+ Reason: why this is an execution barrier
54
+ Max parallel: 1
55
+ Tasks:
56
+ - concrete worker instruction
57
+
58
+ ## Risks and Assumptions
59
+
60
+ - Known risk, assumption, or unresolved detail.
61
+ ```
62
+
63
+ ## Good Handoff Checklist
64
+
65
+ - The goal is specific.
66
+ - The scope is bounded.
67
+ - Acceptance criteria are checkable.
68
+ - Expected artifacts include verification methods.
69
+ - Context references point to real material.
70
+ - Batch hints explain dependencies or safety reasons.
71
+ - Risks and assumptions are visible.
72
+
73
+ ## Skill Template
74
+
75
+ A reusable skill draft is available at:
76
+
77
+ ```text
78
+ skills/input-kanban-prepare/SKILL.md
79
+ ```
80
+
81
+ After installing the npm package, you can install the bundled skill for Codex:
82
+
83
+ ```bash
84
+ input-kanban install-skill codex
85
+ ```
86
+
87
+ Use `--target-dir` if your Codex skills root is custom:
88
+
89
+ ```bash
90
+ input-kanban install-skill codex --target-dir /path/to/codex/skills
91
+ ```
92
+
93
+ Use it in external Agent tools when you want the Agent to prepare a better `task.md` before invoking Input Kanban.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "input-kanban",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "input-kanban": "bin/input-kanban.js"
@@ -15,6 +15,8 @@
15
15
  "bin",
16
16
  "src",
17
17
  "public",
18
+ "docs",
19
+ "skills",
18
20
  "README.md",
19
21
  "README.en.md",
20
22
  "RELEASE_NOTES.md",