input-kanban 0.0.7 → 0.0.9

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhang3xing1
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PROJECT_GUIDE.md CHANGED
@@ -51,9 +51,9 @@ The npm CLI entry is:
51
51
  bin/input-kanban.js
52
52
  ```
53
53
 
54
- It parses CLI options, sets environment variables before importing backend modules, and starts the HTTP server.
54
+ It parses CLI options and sets environment variables before importing backend modules. Without a subcommand, or with `serve`, it starts the HTTP server. With `submit`, it creates a run directly in the shared runs directory and can optionally run an auto loop.
55
55
 
56
- Supported options:
56
+ Supported serve options:
57
57
 
58
58
  ```text
59
59
  --host <host>
@@ -61,10 +61,75 @@ Supported options:
61
61
  --repo <path>
62
62
  --runs-dir <path>
63
63
  --codex-bin <path>
64
+ --runner <headless|tmux>
64
65
  --open
65
66
  --no-open
66
67
  ```
67
68
 
69
+ Supported status options:
70
+
71
+ ```text
72
+ [runId]
73
+ --runs-dir <path>
74
+ --watch
75
+ --poll-ms <ms>
76
+ ```
77
+
78
+ `input-kanban status` refreshes and prints a run summary. If no `runId` is provided, it uses the latest run from the shared runs directory. `--watch` keeps polling until the run reaches a terminal state.
79
+
80
+ Supported result options:
81
+
82
+ ```text
83
+ [runId]
84
+ --runs-dir <path>
85
+ --copy
86
+ ```
87
+
88
+ `input-kanban result [runId]` prints the final judge result. It prefers `judge/verdict.json` and falls back to `judge/last_message.md`. If no `runId` is provided, it uses the latest run. `--copy` sends the result to the system clipboard.
89
+
90
+ Supported retry options:
91
+
92
+ ```text
93
+ <runId>
94
+ [taskId]
95
+ --runs-dir <path>
96
+ --reason <text>
97
+ --max-retries <n>
98
+ --json
99
+ ```
100
+
101
+ `input-kanban retry <runId> [taskId]` retries failed or unknown worker tasks. If `taskId` is omitted, it retries failed/unknown tasks in the current blocked batch. Before retrying, the worker output directory is moved under `worker_attempts/<taskId>/attempt-XX/` so failed logs, stderr, exit code, and last message remain available for audit. Retry resets the task to `pending`, records retry history, then reuses the existing scheduler.
102
+
103
+ Supported stop options:
104
+
105
+ ```text
106
+ <runId>
107
+ --runs-dir <path>
108
+ --reason <text>
109
+ ```
110
+
111
+ `input-kanban stop <runId>` calls the same orchestrator stop path as the Web dashboard. Stop requires an explicit run id. The backend first asks the active runner to stop known processes and then falls back to killing live stored PIDs, so Web and CLI processes can stop each other's headless workers.
112
+
113
+ Supported submit options:
114
+
115
+ ```text
116
+ --repo <path>
117
+ --label <label>
118
+ --task <text>
119
+ --task-file <path|->
120
+ --max-parallel <n>
121
+ --worker-sandbox <read-only|workspace-write|danger-full-access>
122
+ --runner <headless|tmux>
123
+ --runs-dir <path>
124
+ --auto
125
+ --no-auto
126
+ --detach / -d
127
+ --watch
128
+ --poll-ms <ms>
129
+ ```
130
+
131
+ `input-kanban submit` creates a run and starts the planner. Task content can come from `--task <text>` or `--task-file <path|->`; omitting `--repo` uses the current working directory as the target Git work tree. Omitting `--label` derives the run label from the first non-empty task line. Auto mode is the default for submit: it keeps polling the run, dispatches batches when the plan is ready, and starts the final judge once all batches complete. `--no-auto` keeps submit to create + plan only. `-d` / `--detach` starts a background supervisor process for the auto loop and lets the submitting terminal return immediately. The submit output includes `input-kanban status <runId> --watch` for terminal-side observation. Because it writes to the same runs directory as the Web server, CLI-created runs are visible in the 8787 dashboard when both processes use the same `--runs-dir`.
132
+
68
133
  Default behavior:
69
134
 
70
135
  - default repo: current working directory when `input-kanban` is launched; run creation validates that the selected repo is inside a Git work tree;
@@ -73,6 +138,38 @@ Default behavior:
73
138
  - default runs directory: `~/.input-kanban/runs`;
74
139
  - default Codex binary: `codex`.
75
140
 
141
+ ## Agent Workflow
142
+
143
+ This project already exposes an agent-friendly CLI path. Use `--json` for machine-readable output and `runs --active` to discover current work before asking for per-run details.
144
+
145
+ Discovery / lookup pattern:
146
+
147
+ ```text
148
+ input-kanban --json runs --active
149
+ input-kanban --json status <runId>
150
+ input-kanban --json result <runId>
151
+ input-kanban --json stop <runId>
152
+ ```
153
+
154
+ Key points:
155
+
156
+ - `runs` lists visible batches from the shared runs directory; `--active` filters to runs that have not reached a terminal state or still have running tasks.
157
+ - `status` resolves a single run by id and defaults to the latest run when the id is omitted.
158
+ - `result` prefers `judge/verdict.json` and falls back to `judge/last_message.md`; `--copy` copies the result to the clipboard.
159
+ - `stop` requires an explicit `runId` and uses the same stop path as the Web dashboard.
160
+ - `retry` retries failed/unknown workers while preserving the failed attempt directory.
161
+ - `submit` defaults to auto mode: planner -> dispatch -> final judge, with one automatic retry for `batch_blocked` by default. `--no-auto` keeps create + plan only, and `-d/--detach` moves the auto loop to a background supervisor.
162
+ - The Web dashboard now follows the same default auto behavior while the page is open: after planning it auto-dispatches planned runs and auto-starts the final judge once all batches complete.
163
+
164
+ Example agent loop:
165
+
166
+ ```text
167
+ 1. input-kanban --json runs --active
168
+ 2. input-kanban --json status <runId>
169
+ 3. input-kanban --json result <runId>
170
+ 4. input-kanban --json stop <runId> # only when necessary
171
+ ```
172
+
76
173
  ## Data Model
77
174
 
78
175
  ### Run
@@ -138,18 +235,81 @@ If the planner returns valid JSON with zero tasks, the run is marked `plan_empty
138
235
 
139
236
  ## Worker Failure Policy
140
237
 
141
- Workers are not automatically retried.
238
+ Failed or unknown workers can be retried explicitly with `input-kanban retry <runId> [taskId]` or via Web/API retry. CLI/Web auto mode may retry a blocked batch once by default.
142
239
 
143
- Reason: a worker may have already changed files in the target repository. Retrying could duplicate edits, overwrite partial work, or create conflicts.
240
+ Retry rules:
144
241
 
145
- Recovery options:
242
+ - Retry is an orchestrator-level state transition, not a runner auto-restart.
243
+ - Retry refuses stopped or archived runs.
244
+ - Retry refuses tasks that still have a live process.
245
+ - Retry preserves failed output under `worker_attempts/<taskId>/attempt-XX/` before resetting the task.
246
+ - Retry resets failed/unknown tasks to `pending`, records retry history, and reuses the existing scheduler.
146
247
 
147
- - Inspect `events.pretty`, `stderr.log`, `last_message.md`, and artifacts.
248
+ Recovery options after retries are exhausted:
249
+
250
+ - Inspect `events.pretty`, `stderr.log`, `last_message.md`, archived worker attempts, and artifacts.
148
251
  - Manually mark `failed` or `unknown` workers as completed if the user confirms the work is actually done.
149
252
  - Manual completion writes `workers/<taskId>/manual_completion.json`.
150
253
  - If the user pastes a manual success result, it is saved as `workers/<taskId>/manual_result.md` and included in final judge input.
151
254
  - The UI preserves the original failed or unknown status while also showing the manual completion marker.
152
255
 
256
+ ## Run State Concurrency and Retry Implementation Notes
257
+
258
+ ### Failure Retry
259
+
260
+ Retry is implemented as an explicit orchestrator state transition.
261
+
262
+ Implemented behavior:
263
+
264
+ - `input-kanban retry <runId> [taskId]` retries either one failed/unknown task or, when `taskId` is omitted, failed/unknown tasks in the current blocked batch.
265
+ - CLI/Web auto mode retries a `batch_blocked` run once by default via the same retry path.
266
+ - Retry reuses the existing scheduler and does not trigger replanning.
267
+ - Planner retry remains separate and only applies before any worker or judge starts.
268
+
269
+ Safety requirements enforced by implementation:
270
+
271
+ 1. Refuse retry when the run is `stopped` or `archived`.
272
+ 2. Refuse retry if the target task still has a live process.
273
+ 3. Preserve the failed attempt directory under `worker_attempts/<taskId>/attempt-XX/` before resetting the task to `pending`.
274
+ 4. Reset the run back to `running` when there is pending retry work, then let the existing scheduler start workers naturally.
275
+ 5. Keep retry counters and history on the task so agents can tell transient noise from deterministic task failure.
276
+
277
+ Why this shape was favored:
278
+
279
+ - Runner-level auto-restart hides intent from the state machine and would have to be duplicated for headless/tmux.
280
+ - Auto-replan is too heavy for a single failed worker and would throw away useful per-task evidence.
281
+ - The retry decision belongs to orchestration, where agents and humans can see it explicitly.
282
+
283
+ ### `run_state.json` Concurrency Safety
284
+
285
+ The backend now uses a per-run lock file to protect state writes. Atomic writes prevent partial files; the lock prevents common lost-update races between detach supervisors, CLI commands, and Web API actions.
286
+
287
+ Implemented shape:
288
+
289
+ - The lock file is `run_state.lock` inside the run directory.
290
+ - Lock acquisition uses exclusive file creation and stores `pid`, `runId`, and timestamp in the lock file.
291
+ - Stale locks can be recovered when the owning PID is gone and the lock is older than the stale threshold.
292
+ - Lock granularity is one run, so different runs do not block each other.
293
+ - State transition paths re-read the run inside the lock before mutating it.
294
+
295
+ Write paths under lock include:
296
+
297
+ - planner start and completion callback;
298
+ - dispatch;
299
+ - retry;
300
+ - stop;
301
+ - archive;
302
+ - rename;
303
+ - manual task completion;
304
+ - judge start and completion callback;
305
+ - refresh/recovery state materialization.
306
+
307
+ Risk notes:
308
+
309
+ - A stale-lock timeout that is too short can accidentally steal a lock from a slow or paused process; too long slows recovery.
310
+ - `child.onExit` callbacks must continue to take the write lock.
311
+ - If the repository ever moves to shared network storage, the current single-machine exclusive-file assumptions should be re-evaluated.
312
+
153
313
  ## Stop and Archive
154
314
 
155
315
  ### Stop
@@ -255,6 +415,7 @@ runs/<runId>/plan.json
255
415
  runs/<runId>/planner/
256
416
  runs/<runId>/planner_attempts/attempt-XX/
257
417
  runs/<runId>/workers/<taskId>/
418
+ runs/<runId>/worker_attempts/<taskId>/attempt-XX/
258
419
  runs/<runId>/judge/judge_input.json
259
420
  runs/<runId>/workers/<taskId>/events_timed.jsonl
260
421
  runs/<runId>/workers/<taskId>/manual_result.md
@@ -272,6 +433,7 @@ runs/<runId>/judge/verdict.json
272
433
  - `POST /api/runs/:runId/plan`
273
434
  - `POST /api/runs/:runId/dispatch`
274
435
  - `POST /api/runs/:runId/judge`
436
+ - `POST /api/runs/:runId/retry`
275
437
  - `POST /api/runs/:runId/stop`
276
438
  - `POST /api/runs/:runId/archive`
277
439
  - `PATCH /api/runs/:runId/label`
package/README.en.md CHANGED
@@ -43,6 +43,52 @@ If you do not want to `cd` into the target repository first, pass it explicitly:
43
43
  input-kanban --repo /path/to/your/repo
44
44
  ```
45
45
 
46
+ ## CLI Auto Execution
47
+
48
+ To submit a task from the terminal and let it advance automatically, use `submit`. Task content supports two input modes:
49
+
50
+ ```bash
51
+ input-kanban submit --task-file task.md --label "Fix login issue"
52
+ input-kanban submit --task "Fix the login issue and add regression tests" --label "Fix login issue"
53
+ ```
54
+
55
+ `submit` creates a run, starts planning, dispatches all batches, and starts the final judge after all workers finish by default. The default repo is the current directory. If `--label` is omitted, the run label is generated from the task text. It uses the same runs directory, so CLI-created runs are visible in the Web dashboard on port 8787 as long as the dashboard uses the same `--runs-dir`.
56
+
57
+ To return immediately and let a background supervisor continue the auto loop, pass `-d` / `--detach`:
58
+
59
+ ```bash
60
+ input-kanban submit --task-file task.md -d
61
+ ```
62
+
63
+ To create the run and start planning without dispatching or judging, pass `--no-auto`.
64
+
65
+ Common examples:
66
+
67
+ ```bash
68
+ input-kanban submit --task "Fix login issue"
69
+ input-kanban submit --task-file task.md --max-parallel 2 --worker-sandbox workspace-write
70
+ input-kanban submit --runs-dir ~/.input-kanban/runs --runner tmux -d
71
+ ```
72
+
73
+ Check and stop:
74
+
75
+ ```bash
76
+ input-kanban runs
77
+ input-kanban --json runs --active
78
+ input-kanban status
79
+ input-kanban status --watch
80
+ input-kanban status <runId> --watch
81
+ input-kanban --json status <runId>
82
+ input-kanban result
83
+ input-kanban result <runId> --copy
84
+ input-kanban --json result <runId>
85
+ input-kanban retry <runId> [taskId]
86
+ input-kanban --json retry <runId> [taskId]
87
+ input-kanban stop <runId>
88
+ ```
89
+
90
+ Use `runs` to discover visible run batches first; `runs --active` shows only runs that have not reached a terminal state or still have running tasks, which lets an agent find `runId` values before calling `status <runId>`. Without a `runId`, `status` and `result` use the latest run by default. `result --copy` copies the final judge result. `retry` preserves the failed attempt and retries failed/unknown tasks. `--json` is handy for agents/scripts that need structured output. Stopping requires an explicit `runId` to avoid stopping the wrong run.
91
+
46
92
  ## Common Startup Options
47
93
 
48
94
  ```bash
@@ -76,11 +122,11 @@ After run-level tmux metadata is available, the dashboard shows `Copy tmux attac
76
122
  1. Click `New Run`.
77
123
  2. Enter a label, target repository, worker sandbox, and task description.
78
124
  3. Click `Create Run`.
79
- 4. Click `Plan` to let the Codex planner generate batches and workers.
80
- 5. Click `Dispatch` to run workers by batch barrier and concurrency limits.
81
- 6. Inspect execution logs, final messages, error logs, and artifacts.
82
- 7. After all batches complete, click `Final Judge`.
83
- 8. Stop or archive a run when needed, or manually mark a confirmed failed/unknown worker as completed.
125
+ 4. The dashboard automatically starts `Plan` so the Codex planner can generate batches and workers.
126
+ 5. After planning completes, Web auto mode dispatches workers by batch barrier and concurrency limits by default.
127
+ 6. After all batches complete, Web auto mode starts the final judge by default.
128
+ 7. Inspect execution logs, final messages, error logs, and artifacts.
129
+ 8. Stop or archive a run when needed, or manually click buttons to retry/advance, or manually mark a confirmed failed/unknown worker as completed.
84
130
 
85
131
  ## What It Is For
86
132
 
package/README.md CHANGED
@@ -43,6 +43,52 @@ http://127.0.0.1:8787
43
43
  input-kanban --repo /path/to/your/repo
44
44
  ```
45
45
 
46
+ ## CLI 自动执行
47
+
48
+ 如果希望从终端直接提交任务并自动推进,可以使用 `submit`。任务内容支持两种输入方式:
49
+
50
+ ```bash
51
+ input-kanban submit --task-file task.md --label "修复登录问题"
52
+ input-kanban submit --task "修复登录问题,并补充回归测试" --label "修复登录问题"
53
+ ```
54
+
55
+ `submit` 默认会创建任务批次、发起拆分、自动派发所有批次,并在全部完成后自动发起最终验收。默认 repo 是当前目录;如果不传 `--label`,任务批次名称会从任务内容自动生成。它使用同一个 runs 目录,所以只要 8787 Web 看板也使用相同的 `--runs-dir`,CLI 创建的任务会在 Web 界面里可见。
56
+
57
+ 如果希望提交后立即返回,让任务在后台自动执行,可以加 `-d` / `--detach`:
58
+
59
+ ```bash
60
+ input-kanban submit --task-file task.md -d
61
+ ```
62
+
63
+ 如果只想创建并拆分,不自动派发和验收,可以加 `--no-auto`。
64
+
65
+ 常用参数:
66
+
67
+ ```bash
68
+ input-kanban submit --task "修复登录问题"
69
+ input-kanban submit --task-file task.md --max-parallel 2 --worker-sandbox workspace-write
70
+ input-kanban submit --runs-dir ~/.input-kanban/runs --runner tmux -d
71
+ ```
72
+
73
+ 查看和停止:
74
+
75
+ ```bash
76
+ input-kanban runs
77
+ input-kanban --json runs --active
78
+ input-kanban status
79
+ input-kanban status --watch
80
+ input-kanban status <runId> --watch
81
+ input-kanban --json status <runId>
82
+ input-kanban result
83
+ input-kanban result <runId> --copy
84
+ input-kanban --json result <runId>
85
+ input-kanban retry <runId> [taskId]
86
+ input-kanban --json retry <runId> [taskId]
87
+ input-kanban stop <runId>
88
+ ```
89
+
90
+ `runs` 用来先列出可见任务批次,`runs --active` 只列出未进入终态或仍有子任务运行的批次,便于 agent 先发现 `runId`,再用 `status <runId>` 查详情。不传 `runId` 时,`status` 和 `result` 默认查看最近一次任务批次。`result --copy` 会复制最终验收结果;`retry` 会保留失败现场并重试失败/未知任务;`--json` 适合给 agent/脚本做结构化读取;停止任务请显式传入 `runId`,避免误停。
91
+
46
92
  ## 常用启动参数
47
93
 
48
94
  ```bash
@@ -76,11 +122,11 @@ tmux 模式是可选能力,主要用于在终端里实时查看每个 Codex
76
122
  1. 点击 `新建任务批次`。
77
123
  2. 输入批次名称、目标仓库、Worker 沙箱和任务说明。
78
124
  3. 点击 `创建批次`。
79
- 4. 点击 `拆分任务`,让 Codex planner 生成 batches 和 workers。
80
- 5. 点击 `派发执行`,按 batch barrier 和并发限制运行 workers。
81
- 6. 查看执行日志、最终回复、错误日志和产物。
82
- 7. 所有 batch 完成后,点击 `汇总验收`。
83
- 8. 必要时可以停止或归档 run,也可以手动标记已确认完成的失败/未知 worker。
125
+ 4. 看板会自动发起 `拆分任务`,让 Codex planner 生成 batches 和 workers。
126
+ 5. 拆分完成后,Web 默认自动派发执行,按 batch barrier 和并发限制运行 workers。
127
+ 6. 所有 batch 完成后,Web 默认自动发起 `汇总验收`。
128
+ 7. 查看执行日志、最终回复、错误日志和产物。
129
+ 8. 必要时可以停止或归档 run,也可以手动点击按钮重试、推进,或手动标记已确认完成的失败/未知 worker。
84
130
 
85
131
  ## 它适合做什么
86
132
 
package/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Release Notes
2
2
 
3
+ ## v0.0.8
4
+
5
+ ### Highlights
6
+
7
+ - Add CLI `submit` workflow with two task input modes: `--task-file <markdown>` for Markdown files and `--task <text>` for inline task text.
8
+ - Add CLI auto loop as the default `submit` behavior to create a run, start planning, dispatch batches, and run the final judge while keeping the run visible in the shared Web dashboard.
9
+ - Add CLI `-d` / `--detach` to run the auto loop in a background supervisor, plus `--no-auto` for create-and-plan-only mode.
10
+ - Add CLI `status [runId] [--watch]`, defaulting to the latest run when `runId` is omitted.
11
+ - Add CLI `result [runId] [--copy]` to print or copy the final judge result.
12
+ - Add CLI `retry <runId> [taskId]` and automatic one-shot retry for blocked batches while preserving failed worker attempts.
13
+ - Add per-run `run_state.lock` protection around state writes to reduce CLI/Web/supervisor lost-update races.
14
+ - Add CLI `stop <runId>` and make backend stop robust across CLI/Web processes by falling back to stored live PIDs.
15
+ - Derive the run label from task text when `--label` / form label is omitted.
16
+ - Add dashboard run-card archive confirmation without modal popups and replace the detail refresh text chips with a one-shot circle animation.
17
+
18
+ ### Verification
19
+
20
+ - `npm run check` passed with 58 tests.
21
+
3
22
  ## v0.0.7
4
23
 
5
24
  ### Highlights