@chlrc/aiw 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -22,20 +22,22 @@ The result is a CLI that keeps a personal workflow consistent without turning it
22
22
 
23
23
  ## Quick Start
24
24
 
25
- From this checkout:
25
+ Bootstrap with the published package first. Users do not need to clone this repository to start using AIW:
26
26
 
27
27
  ```bash
28
- node bin/aiw --help
29
- node bin/aiw doctor
30
- node bin/aiw cmux-new --agent codex
28
+ npx @chlrc/aiw init
29
+ aiw doctor
30
+ aiw cmux-new --agent codex
31
31
  ```
32
32
 
33
- Bootstrap with the published package, then use the installed `aiw` binary:
33
+ Using `npx @chlrc/aiw ...` is a good first-run path. For frequent use, install the package or pull a local checkout so command startup and local customization are easier.
34
+
35
+ From a local checkout, mostly for AIW development:
34
36
 
35
37
  ```bash
36
- npx @chlrc/aiw init
37
- aiw doctor
38
- aiw cmux-new --agent codex
38
+ node bin/aiw --help
39
+ node bin/aiw doctor
40
+ node bin/aiw cmux-new --agent codex
39
41
  ```
40
42
 
41
43
  The normal daily loop is:
@@ -47,11 +49,10 @@ aiw doctor
47
49
  # 2. Create or switch to a Worktrunk worktree and open the AIW cmux layout.
48
50
  aiw cmux-new --agent codex
49
51
 
50
- # 3. Work in the four-pane workspace.
52
+ # 3. Work in the three-pane workspace.
51
53
  # Files: yazi
52
54
  # Agent: codex / claude / opencode / gemini / aider
53
- # Git: lazygit with the AIW overlay
54
- # Diff: cmux-git-diff or git diff piped through delta
55
+ # Git: lazygit with the AIW overlay and delta-rendered diffs
55
56
 
56
57
  # 4. Review and stage changes.
57
58
  aiw git
@@ -90,6 +91,29 @@ AIW reads configuration from:
90
91
 
91
92
  This lets the repo provide a usable default while still allowing a personal config directory outside business repositories.
92
93
 
94
+ ## Agent Skills
95
+
96
+ AIW ships agent skills in the npm `skills` CLI-compatible multi-skill layout:
97
+
98
+ - [skills/aiw-init](./skills/aiw-init/SKILL.md): bootstrap and troubleshoot AIW setup.
99
+ - [skills/aiw-reference](./skills/aiw-reference/SKILL.md): operate AIW workspace, Git, commit, done, remove, and GC workflows.
100
+
101
+ The current `skills add` flow consumes Git/GitHub sources, so users can install the AIW skills from this repository without cloning it first:
102
+
103
+ ```bash
104
+ npx --yes skills add KiritoKing/aiw-cli --list -y
105
+ npx --yes skills add KiritoKing/aiw-cli --skill aiw-init -y
106
+ npx --yes skills add KiritoKing/aiw-cli --skill aiw-reference -y
107
+ ```
108
+
109
+ Maintainers can validate the checked-out repository before publishing:
110
+
111
+ ```bash
112
+ npx --yes skills add . --list -y
113
+ ```
114
+
115
+ `aiw init` does not install these skills yet; it only initializes AIW config and cmux integration.
116
+
93
117
  ## Init
94
118
 
95
119
  Use `npx @chlrc/aiw init` on macOS or Linux to bootstrap a machine for AIW.
@@ -122,7 +146,7 @@ AIW is deliberately dependency-light:
122
146
  - Process execution: Node child processes through local helpers.
123
147
  - Workspace orchestration: Worktrunk (`wt`) and cmux.
124
148
  - Git UI: lazygit, with an AIW-specific overlay loaded only by `aiw git`.
125
- - Diff UI: `cmux-git-diff` when installed, otherwise `git diff | delta`.
149
+ - Diff UI: delta through the lazygit overlay by default; standalone `aiw diff` uses `cmux-git-diff` when installed, otherwise `git diff | delta`.
126
150
  - Pickers and search: fzf, rg, fd, bat.
127
151
  - File and edit surfaces: yazi and nvim.
128
152
  - Agents: command adapters defined in [config/agents.toml](./config/agents.toml).
@@ -143,7 +167,7 @@ Think of AIW in three layers:
143
167
  2. `aiw` is the orchestration entrypoint. It resolves the repo, branch/worktree, agent, dependency gates, and layout, then calls the right lower-level command.
144
168
  3. Mature CLI tools do the real work: Worktrunk for worktrees, yazi for files, nvim/LazyVim for editing, lazygit for review and staging, delta for diffs, rg/fd/fzf/bat/eza for search and inspection, zoxide in the surrounding shell workflow, and agent CLIs for model interaction.
145
169
 
146
- AIW started from a practical goal: recreate the useful Codex App-style workspace motion without moving the workflow into a closed app. The target experience is not just "four panes on screen." It is a continuous path: open cmux, start AIW, create or switch a worktree, land in the standard workspace, inspect files, talk to an agent, stage hunks, watch the diff, commit, merge, and clean up.
170
+ AIW started from a practical goal: recreate the useful Codex App-style workspace motion without moving the workflow into a closed app. The target experience is not just "panes on screen." It is a continuous path: open cmux, start AIW, create or switch a worktree, land in the standard workspace, inspect files, talk to an agent, stage hunks, review the delta-rendered diff in lazygit, commit, merge, and clean up.
147
171
 
148
172
  The important difference is control. A polished app can be pleasant, but it tends to fix the shape of the workflow. In a terminal stack, you can choose the file manager, editor setup, Git UI, diff renderer, fuzzy finder, navigation tools, shell behavior, keybindings, and agent CLI. Shell rendering also matters: when command output is central to development, native terminal tools are easier to trust, tune, and compose than an embedded shell surface.
149
173
 
@@ -164,7 +188,7 @@ aiw cmux-new
164
188
  -> repository and branch selection
165
189
  -> Worktrunk creates or switches the worktree
166
190
  -> aiw layout builds the cmux workspace
167
- -> cmux opens Files / Agent / Git / Diff panes
191
+ -> cmux opens Files / Agent / Git panes
168
192
  ```
169
193
 
170
194
  The same idea applies to cleanup:
@@ -192,7 +216,7 @@ cmux entry
192
216
  -> dependency gate
193
217
  -> Worktrunk worktree create/switch
194
218
  -> aiw layout
195
- -> cmux workspace with Files / Agent / Git / Diff
219
+ -> cmux workspace with Files / Agent / Git
196
220
  ```
197
221
 
198
222
  The value is the fluid handoff between layers. cmux stays the place you start and look. AIW stays the workflow brain. The lower-level CLIs stay sharp and native.
@@ -253,6 +277,7 @@ aiw workspace open feat/foo --agent codex
253
277
  ```bash
254
278
  aiw doctor
255
279
  aiw cmux-new --agent codex
280
+ aiw new --agent codex
256
281
  aiw cmux-new --pick-repo --agent codex
257
282
  aiw cmux-new --local --agent codex
258
283
  aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --agent codex --dry-run
@@ -288,7 +313,10 @@ Short workspace aliases are kept for daily use:
288
313
 
289
314
  ```bash
290
315
  aiw ws list
316
+ aiw ws ls
291
317
  aiw list
318
+ aiw ls
319
+ aiw als
292
320
  aiw open feat/foo
293
321
  aiw switch feat/foo
294
322
  aiw done
@@ -299,16 +327,19 @@ aiw clean
299
327
 
300
328
  ## Worktree and cmux Workflow
301
329
 
302
- `aiw cmux-new` is the main entrypoint for new work.
330
+ `aiw cmux-new` is the main entrypoint for new work. `aiw new` and `aiw cmux new` are aliases for the same command.
303
331
 
304
332
  Common forms:
305
333
 
306
334
  ```bash
307
335
  aiw cmux-new
336
+ aiw new
308
337
  aiw cmux-new --agent codex
338
+ aiw new --agent codex
309
339
  aiw cmux-new --pick-repo --agent codex
310
340
  aiw cmux-new --repo ~/Code/my-repo --agent codex
311
341
  aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --agent codex
342
+ aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --base main --agent codex
312
343
  aiw cmux-new --local --agent codex
313
344
  ```
314
345
 
@@ -316,8 +347,9 @@ Behavior:
316
347
 
317
348
  - The current Git repository is used automatically when possible.
318
349
  - `--pick-repo` lets you select another repository under `paths.code_root`.
319
- - Without a branch in a TTY, AIW lets you create a new branch from current `HEAD`, open the current checkout, or choose an existing branch.
350
+ - Without a branch in a TTY, AIW lets you create a new branch from current `HEAD`, create a new branch from an existing branch, open the current checkout, or choose an existing branch.
320
351
  - Creating a new branch runs `wt switch --create <branch> --base @ -x "aiw layout --agent <agent>"`.
352
+ - Creating a new branch from an existing branch runs `wt switch --create <branch> --base <base> -x "aiw layout --agent <agent>"`; pass `--base <branch>` or `--from <branch>` with `--branch <new-branch>` to do this non-interactively.
321
353
  - Selecting an existing branch runs `wt switch <branch> -x "aiw layout --agent <agent>"`.
322
354
  - `--local` opens the standard layout in the current checkout without creating a Worktrunk worktree.
323
355
  - `--dry-run` prints the command that would be run.
@@ -329,9 +361,9 @@ The standard cmux layout is:
329
361
  | Files | Agent |
330
362
  | aiw files | codex/claude/etc. |
331
363
  +----------------------+----------------------+
332
- | Git | Diff |
333
- | aiw git | aiw diff --watch |
334
- +----------------------+----------------------+
364
+ | Git |
365
+ | aiw git |
366
+ +--------------------------------------------+
335
367
  ```
336
368
 
337
369
  `aiw layout --print-json` prints the cmux layout JSON without opening cmux.
@@ -378,11 +410,14 @@ In a TTY, `workspace open` without a target opens a searchable picker over exist
378
410
  ```bash
379
411
  aiw workspace done
380
412
  aiw workspace done dev
413
+ aiw workspace done dev --agent codex
414
+ aiw workspace done dev --retries 3
415
+ aiw workspace done dev --agent codex --retries 3
381
416
  aiw workspace done dev --no-close-cmux
382
417
  aiw done dev
383
418
  ```
384
419
 
385
- `done` is only allowed from a feature worktree. It refuses to run from the main workspace. It also refuses to proceed when the current worktree is dirty.
420
+ `done` is only allowed from a feature worktree. It refuses to run from the main workspace. It also refuses to proceed when the current worktree is dirty, or when the selected target branch is checked out in another dirty worktree.
386
421
 
387
422
  When it proceeds, AIW delegates the merge and cleanup to Worktrunk:
388
423
 
@@ -390,7 +425,15 @@ When it proceeds, AIW delegates the merge and cleanup to Worktrunk:
390
425
  wt merge <target>
391
426
  ```
392
427
 
393
- If AIW recorded a target when the worktree was created, bare `aiw done` can use that target. In a TTY it opens a target picker when needed. After a successful merge, AIW closes the matching cmux workspace unless `--no-close-cmux` is passed.
428
+ Worktrunk squashes by default. If Worktrunk does not already have a `[commit.generation] command` or `WORKTRUNK_COMMIT__GENERATION__COMMAND`, AIW injects its own commit-message bridge for the merge:
429
+
430
+ ```bash
431
+ WORKTRUNK_COMMIT__GENERATION__COMMAND="<aiw> commit-message --agent <agent>" wt merge <target>
432
+ ```
433
+
434
+ This avoids Worktrunk's plain fallback squash subject, which can fail Conventional Commit hooks in business repositories. Pass `--agent <name>` to choose the AIW commit agent for the squash message. Existing Worktrunk commit-generation config and explicit Worktrunk environment variables are respected.
435
+
436
+ If AIW recorded a target when the worktree was created, bare `aiw done` can use that target. In a TTY it opens a target picker when needed. `done` retries failed `wt merge` attempts up to `commit.retries` times, defaulting to 3, and restores the source worktree, target branch, and Worktrunk backup ref after each failed attempt. After a successful merge, AIW closes the matching cmux workspace unless `--no-close-cmux` is passed.
394
437
 
395
438
  ### Remove and GC
396
439
 
@@ -481,6 +524,7 @@ aiw commit --prompt "Use scope aiw"
481
524
  aiw commit --prompt-file ~/commit-style.md
482
525
  aiw commit --print-prompt
483
526
  aiw commit --dry-run
527
+ aiw commit-message --agent codex < prompt.txt
484
528
  ```
485
529
 
486
530
  Flow:
@@ -493,6 +537,8 @@ Flow:
493
537
  6. Run `git commit -F -`.
494
538
  7. If commit hooks fail, include the hook output in the next prompt and retry up to `commit.retries`.
495
539
 
540
+ `aiw commit-message` is the stdin-to-stdout message generator used by `aiw done` when bridging Worktrunk squash commit generation. It does not create a Git commit.
541
+
496
542
  The agent adapter contract is stdin/stdout oriented:
497
543
 
498
544
  - stdin or `{{prompt}}`: full commit prompt and staged diff
@@ -562,8 +608,8 @@ aiw doctor --gate commit --agent codex
562
608
 
563
609
  Gate behavior:
564
610
 
565
- - `cmux-new` requires Git, Worktrunk, cmux, yazi, lazygit, nvim, the selected agent, and either `cmux-git-diff` or delta.
566
- - `layout` requires the layout tools and selected agent, but not Worktrunk.
611
+ - `cmux-new` requires Git, Worktrunk, cmux, yazi, lazygit, nvim, the selected agent, and delta when the lazygit overlay is configured.
612
+ - `layout` requires the layout tools, selected agent, and the same lazygit overlay dependencies, but not Worktrunk.
567
613
  - `init` checks the tools needed to bootstrap the default workflow before writing config.
568
614
  - `workspace` requires Git and Worktrunk.
569
615
  - `git` requires lazygit and delta when the lazygit overlay is configured.
package/README.zh-CN.md CHANGED
@@ -22,19 +22,22 @@ AIW 是一个很薄的编排层。它不替代你已经在用的工具,而是
22
22
 
23
23
  ## 快速上手
24
24
 
25
- 从当前 checkout 运行:
25
+ 优先从已发布的 npm 包启动。用户开始使用 AIW 不需要先 clone 这个仓库:
26
26
 
27
27
  ```bash
28
- node bin/aiw --help
29
- node bin/aiw doctor
30
- node bin/aiw cmux-new --agent codex
28
+ npx @chlrc/aiw init
29
+ aiw doctor
30
+ aiw cmux-new --agent codex
31
31
  ```
32
32
 
33
- 如果 `aiw` 已经安装到 `PATH`:
33
+ 第一次可以直接使用 `npx @chlrc/aiw ...`。后续高频使用时,建议安装包或拉到本地 checkout,方便启动、调试和个性化配置。
34
+
35
+ 从本地 checkout 运行,主要用于开发 AIW 自身:
34
36
 
35
37
  ```bash
36
- aiw doctor
37
- aiw cmux-new --agent codex
38
+ node bin/aiw --help
39
+ node bin/aiw doctor
40
+ node bin/aiw cmux-new --agent codex
38
41
  ```
39
42
 
40
43
  日常工作流通常是:
@@ -46,11 +49,10 @@ aiw doctor
46
49
  # 2. 创建或切换 Worktrunk worktree,并打开 AIW cmux layout。
47
50
  aiw cmux-new --agent codex
48
51
 
49
- # 3. 在四分屏 workspace 里工作。
52
+ # 3. 在三 pane workspace 里工作。
50
53
  # Files: yazi
51
54
  # Agent: codex / claude / opencode / gemini / aider
52
- # Git: lazygit + AIW overlay
53
- # Diff: cmux-git-diff,或 git diff 通过 delta 渲染
55
+ # Git: lazygit + AIW overlay,并用 delta 渲染 diff
54
56
 
55
57
  # 4. 审查并 stage 改动。
56
58
  aiw git
@@ -89,6 +91,29 @@ AIW 按以下顺序读取配置:
89
91
 
90
92
  这样仓库可以提供开箱默认值,同时允许个人配置留在业务仓库之外。
91
93
 
94
+ ## Agent Skills
95
+
96
+ AIW 现在按 npm `skills` CLI 可消费的 multi-skill 目录组织 agent skills:
97
+
98
+ - [skills/aiw-init](./skills/aiw-init/SKILL.md):帮助初始化和排查 AIW 环境。
99
+ - [skills/aiw-reference](./skills/aiw-reference/SKILL.md):帮助 agent 直接执行 AIW workspace、Git、commit、done、remove 和 GC 流程。
100
+
101
+ 当前 `skills add` 流程消费 Git/GitHub 源,因此用户不需要 clone repo,也可以直接从这个仓库安装 AIW skills:
102
+
103
+ ```bash
104
+ npx --yes skills add KiritoKing/aiw-cli --list -y
105
+ npx --yes skills add KiritoKing/aiw-cli --skill aiw-init -y
106
+ npx --yes skills add KiritoKing/aiw-cli --skill aiw-reference -y
107
+ ```
108
+
109
+ 维护者发布前可以用本地 checkout 验证 discoverability:
110
+
111
+ ```bash
112
+ npx --yes skills add . --list -y
113
+ ```
114
+
115
+ `aiw init` 暂不安装这些 skills;它只初始化 AIW config 和 cmux 集成。
116
+
92
117
  ## 初始化
93
118
 
94
119
  在 macOS 或 Linux 上,可以用 `npx @chlrc/aiw init` 为一台机器初始化 AIW。
@@ -121,7 +146,7 @@ AIW 有意保持低依赖:
121
146
  - Process execution: 通过本地 helper 调用 Node child process。
122
147
  - Workspace orchestration: Worktrunk (`wt`) 和 cmux。
123
148
  - Git UI: lazygit;仅 `aiw git` 会加载 AIW 专用 overlay。
124
- - Diff UI: 优先 `cmux-git-diff`,否则 `git diff | delta`。
149
+ - Diff UI: 默认通过 lazygit overlay 使用 delta;独立 `aiw diff` 命令仍优先 `cmux-git-diff`,否则 `git diff | delta`。
125
150
  - Picker 和搜索: fzf、rg、fd、bat。
126
151
  - 文件和编辑界面: yazi、nvim。
127
152
  - Agent: 在 [config/agents.toml](./config/agents.toml) 中声明命令适配器。
@@ -142,7 +167,7 @@ npm run check
142
167
  2. `aiw` 是编排入口。它负责解析 repo、branch/worktree、agent、依赖门禁和 layout,然后调用正确的底层命令。
143
168
  3. 成熟 CLI 工具负责真正执行:Worktrunk 管 worktree,yazi 管文件,nvim/LazyVim 管编辑,lazygit 管审查和 stage,delta 管 diff,rg/fd/fzf/bat/eza 管搜索和查看,zoxide 融入外层 shell 导航,agent CLI 负责模型交互。
144
169
 
145
- AIW 最初的目标很实际:在 Codex App 之外复刻它里面有价值的 workspace 动线,但不把 workflow 搬进一个封闭 App。目标不只是“屏幕上有四个 pane”,而是一条连续动作:打开 cmux,启动 AIW,创建或切换 worktree,进入标准 workspace,看文件,和 agent 交流,stage hunk,看实时 diff,commit,merge,清理。
170
+ AIW 最初的目标很实际:在 Codex App 之外复刻它里面有价值的 workspace 动线,但不把 workflow 搬进一个封闭 App。目标不只是“屏幕上有几个 pane”,而是一条连续动作:打开 cmux,启动 AIW,创建或切换 worktree,进入标准 workspace,看文件,和 agent 交流,stage hunk,在 lazygit 里看 delta 渲染的 diff,commit,merge,清理。
146
171
 
147
172
  关键差异是控制权。成熟 App 的体验可以很完整,但它通常也固定了工作流形状。在终端工具栈里,你可以选择文件管理器、编辑器配置、Git UI、diff renderer、fuzzy finder、目录跳转工具、shell 行为、快捷键和 agent CLI。shell 渲染也是体验的一部分:当命令输出是开发过程的核心时,原生终端工具比嵌入式 shell 界面更可信、更可调,也更容易拼装。
148
173
 
@@ -163,7 +188,7 @@ aiw cmux-new
163
188
  -> repository and branch selection
164
189
  -> Worktrunk creates or switches the worktree
165
190
  -> aiw layout builds the cmux workspace
166
- -> cmux opens Files / Agent / Git / Diff panes
191
+ -> cmux opens Files / Agent / Git panes
167
192
  ```
168
193
 
169
194
  清理流程也是同一套思想:
@@ -191,7 +216,7 @@ cmux entry
191
216
  -> dependency gate
192
217
  -> Worktrunk worktree create/switch
193
218
  -> aiw layout
194
- -> cmux workspace with Files / Agent / Git / Diff
219
+ -> cmux workspace with Files / Agent / Git
195
220
  ```
196
221
 
197
222
  价值在于层与层之间的交接很流畅。cmux 继续作为开始工作和承载视图的地方;AIW 作为 workflow brain;底层 CLI 继续保持锋利和原生。
@@ -253,6 +278,7 @@ aiw workspace open feat/foo --agent codex
253
278
  npx @chlrc/aiw init
254
279
  aiw doctor
255
280
  aiw cmux-new --agent codex
281
+ aiw new --agent codex
256
282
  aiw cmux-new --pick-repo --agent codex
257
283
  aiw cmux-new --local --agent codex
258
284
  aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --agent codex --dry-run
@@ -288,7 +314,10 @@ aiw tree 3
288
314
 
289
315
  ```bash
290
316
  aiw ws list
317
+ aiw ws ls
291
318
  aiw list
319
+ aiw ls
320
+ aiw als
292
321
  aiw open feat/foo
293
322
  aiw switch feat/foo
294
323
  aiw done
@@ -299,16 +328,19 @@ aiw clean
299
328
 
300
329
  ## Worktree 和 cmux 工作流
301
330
 
302
- `aiw cmux-new` 是新任务的主入口。
331
+ `aiw cmux-new` 是新任务的主入口。`aiw new` 和 `aiw cmux new` 是同一个命令的 alias。
303
332
 
304
333
  常见形式:
305
334
 
306
335
  ```bash
307
336
  aiw cmux-new
337
+ aiw new
308
338
  aiw cmux-new --agent codex
339
+ aiw new --agent codex
309
340
  aiw cmux-new --pick-repo --agent codex
310
341
  aiw cmux-new --repo ~/Code/my-repo --agent codex
311
342
  aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --agent codex
343
+ aiw cmux-new --repo ~/Code/my-repo --branch feat/foo --base main --agent codex
312
344
  aiw cmux-new --local --agent codex
313
345
  ```
314
346
 
@@ -316,8 +348,9 @@ aiw cmux-new --local --agent codex
316
348
 
317
349
  - 能识别当前 Git repo 时,默认使用当前 repo。
318
350
  - `--pick-repo` 可以选择 `paths.code_root` 下的其他 repo。
319
- - TTY 中没有传 branch 时,AIW 会让你选择从当前 `HEAD` 创建新分支、打开当前 checkout、或选择已有分支。
351
+ - TTY 中没有传 branch 时,AIW 会让你选择从当前 `HEAD` 创建新分支、从已有 branch 创建新分支、打开当前 checkout、或选择已有分支。
320
352
  - 创建新分支时运行 `wt switch --create <branch> --base @ -x "aiw layout --agent <agent>"`。
353
+ - 从已有 branch 创建新分支时运行 `wt switch --create <branch> --base <base> -x "aiw layout --agent <agent>"`;非交互使用 `--branch <new-branch> --base <branch>` 或 `--from <branch>`。
321
354
  - 选择已有分支时运行 `wt switch <branch> -x "aiw layout --agent <agent>"`。
322
355
  - `--local` 在当前 checkout 打开标准 layout,不创建 Worktrunk worktree。
323
356
  - `--dry-run` 打印将要运行的命令。
@@ -329,9 +362,9 @@ aiw cmux-new --local --agent codex
329
362
  | Files | Agent |
330
363
  | aiw files | codex/claude/etc. |
331
364
  +----------------------+----------------------+
332
- | Git | Diff |
333
- | aiw git | aiw diff --watch |
334
- +----------------------+----------------------+
365
+ | Git |
366
+ | aiw git |
367
+ +--------------------------------------------+
335
368
  ```
336
369
 
337
370
  `aiw layout --print-json` 可以只打印 cmux layout JSON,不打开 cmux。
@@ -378,11 +411,14 @@ TTY 中不传 target 时,`workspace open` 会打开可搜索 picker,列出
378
411
  ```bash
379
412
  aiw workspace done
380
413
  aiw workspace done dev
414
+ aiw workspace done dev --agent codex
415
+ aiw workspace done dev --retries 3
416
+ aiw workspace done dev --agent codex --retries 3
381
417
  aiw workspace done dev --no-close-cmux
382
418
  aiw done dev
383
419
  ```
384
420
 
385
- `done` 只能在 feature worktree 内执行。主 workspace 会被拒绝;当前 worktree dirty 时也会被拒绝。
421
+ `done` 只能在 feature worktree 内执行。主 workspace 会被拒绝;当前 worktree dirty 时也会被拒绝。如果目标分支正被另一个 dirty worktree checkout,也会在进入 merge 前拒绝。
386
422
 
387
423
  通过检查后,AIW 把 merge 和 cleanup 交给 Worktrunk:
388
424
 
@@ -390,7 +426,15 @@ aiw done dev
390
426
  wt merge <target>
391
427
  ```
392
428
 
393
- 如果 AIW 在创建 worktree 时记录过 target,裸 `aiw done` 可以使用该 target。TTY 中缺少 target 时会打开目标分支 picker。成功 merge 后,AIW 默认关闭匹配的 cmux workspace;传 `--no-close-cmux` 可保留。
429
+ Worktrunk 默认会 squash。如果 Worktrunk 没有配置 `[commit.generation] command`,也没有显式设置 `WORKTRUNK_COMMIT__GENERATION__COMMAND`,AIW 会为本次 merge 注入自己的 commit message bridge:
430
+
431
+ ```bash
432
+ WORKTRUNK_COMMIT__GENERATION__COMMAND="<aiw> commit-message --agent <agent>" wt merge <target>
433
+ ```
434
+
435
+ 这样可以避免 Worktrunk 的普通 fallback squash subject 触发业务仓库的 Conventional Commit hook 失败。传 `--agent <name>` 可以指定本次 squash message 使用哪个 AIW commit agent;已有 Worktrunk commit-generation 配置和显式环境变量会被保留,不会被 AIW 覆盖。
436
+
437
+ 如果 AIW 在创建 worktree 时记录过 target,裸 `aiw done` 可以使用该 target。TTY 中缺少 target 时会打开目标分支 picker。`done` 会按 `commit.retries` 重试失败的 `wt merge`,默认 3 次;每次失败后会恢复 source worktree、target branch 和 Worktrunk backup ref,避免把中间脏状态留在仓库里。成功 merge 后,AIW 默认关闭匹配的 cmux workspace;传 `--no-close-cmux` 可保留。
394
438
 
395
439
  ### 删除和 GC
396
440
 
@@ -481,6 +525,7 @@ aiw commit --prompt "Use scope aiw"
481
525
  aiw commit --prompt-file ~/commit-style.md
482
526
  aiw commit --print-prompt
483
527
  aiw commit --dry-run
528
+ aiw commit-message --agent codex < prompt.txt
484
529
  ```
485
530
 
486
531
  流程:
@@ -493,6 +538,8 @@ aiw commit --dry-run
493
538
  6. 运行 `git commit -F -`。
494
539
  7. 如果 commit hook 失败,把 hook 输出注入下一轮 prompt,并按 `commit.retries` 重试。
495
540
 
541
+ `aiw commit-message` 是 `aiw done` 桥接 Worktrunk squash commit generation 时使用的 stdin-to-stdout message generator。它不会创建 Git commit。
542
+
496
543
  Agent adapter 契约是 stdin/stdout 风格:
497
544
 
498
545
  - stdin 或 `{{prompt}}`: 完整 commit prompt 和 staged diff
@@ -562,8 +609,8 @@ aiw doctor --gate commit --agent codex
562
609
 
563
610
  Gate 行为:
564
611
 
565
- - `cmux-new` 需要 Git、Worktrunk、cmux、yazi、lazygit、nvim、选定 agent,以及 `cmux-git-diff` delta 之一。
566
- - `layout` 需要 layout 相关工具和选定 agent,但不需要 Worktrunk。
612
+ - `cmux-new` 需要 Git、Worktrunk、cmux、yazi、lazygit、nvim、选定 agent;配置 lazygit overlay 时还需要 delta
613
+ - `layout` 需要 layout 相关工具、选定 agent,以及同一组 lazygit overlay 依赖,但不需要 Worktrunk。
567
614
  - `init` 在写配置前检查默认工作流初始化所需工具。
568
615
  - `workspace` 需要 Git 和 Worktrunk。
569
616
  - `git` 在配置 lazygit overlay 时需要 lazygit 和 delta。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chlrc/aiw",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Personal AI workflow bridge for cmux, Worktrunk, and CLI agents.",
6
6
  "keywords": [
@@ -25,6 +25,7 @@
25
25
  "bin",
26
26
  "src",
27
27
  "config",
28
+ "skills",
28
29
  "scripts",
29
30
  "README.zh-CN.md"
30
31
  ],
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: aiw-init
3
+ description: Initialize, bootstrap, configure, or troubleshoot the AIW CLI environment for a user. Use when the user asks about installing AIW, running `npx @chlrc/aiw init`, setting up cmux actions, choosing AIW config paths, checking dependency gates, diagnosing setup failures, or answering questions about the AIW initialization flow.
4
+ ---
5
+
6
+ # AIW Init
7
+
8
+ ## Purpose
9
+
10
+ Help users get AIW ready on a machine without turning setup into a blind write operation. AIW is a thin orchestration CLI for cmux, Worktrunk, lazygit, delta, yazi, nvim, and agent CLIs; setup should verify those boundaries and only write personal config when that is intended.
11
+
12
+ ## Operating Rules
13
+
14
+ - Prefer a read-only preflight first. Use `doctor`, `init --dry-run`, or direct `command -v` checks before applying setup changes.
15
+ - Treat `aiw init` as a write operation: it can create `~/.config/aiw`, create code/worktree directories, and merge cmux config. Run it for real only when the user explicitly wants initialization to proceed.
16
+ - Do not use `--force` unless the user explicitly wants existing AIW config files overwritten. `--force` creates backups, but it is still a replacement operation.
17
+ - Do not claim that `aiw init` installs agent skills. Current AIW init prints `[skip] skills initialization`; install skills separately with the npm `skills` CLI.
18
+ - Keep AIW personal workflow config out of business repositories by default. Prefer `--cmux-scope home` unless the user specifically wants project-local cmux registration.
19
+
20
+ ## Resolve the AIW Command
21
+
22
+ Use the package path first. Users do not need to clone the AIW repository just to initialize a machine:
23
+
24
+ ```bash
25
+ npx @chlrc/aiw init --help
26
+ npx @chlrc/aiw init --dry-run --yes
27
+ ```
28
+
29
+ After initialization, prefer the installed `aiw` binary for daily checks:
30
+
31
+ ```bash
32
+ aiw --help
33
+ aiw doctor
34
+ ```
35
+
36
+ For frequent use, local customization, or AIW development, a local checkout is recommended later:
37
+
38
+ ```bash
39
+ node bin/aiw --help
40
+ ```
41
+
42
+ When initializing from the scoped package, store the same launcher in cmux actions unless the user has already installed an `aiw` binary:
43
+
44
+ ```bash
45
+ npx @chlrc/aiw init --launcher "npx @chlrc/aiw" --dry-run --yes
46
+ ```
47
+
48
+ The current CLI default launcher is `npx aiw`; `--launcher` controls the command prefix written into cmux actions such as `aiw-new-worktree`.
49
+
50
+ ## Setup Workflow
51
+
52
+ 1. Identify the user's target paths and cmux scope:
53
+ - Config: `~/.config/aiw`, or `$AIW_CONFIG_DIR` when set.
54
+ - Code root: default `~/Code`.
55
+ - Worktrees root: default `~/worktrees`.
56
+ - cmux scope: `home`, `code`, or `none`.
57
+
58
+ 2. Run dependency and setup preflight:
59
+
60
+ ```bash
61
+ aiw doctor
62
+ aiw doctor --gate init --agent codex
63
+ aiw init --dry-run --yes
64
+ ```
65
+
66
+ For first-time package bootstrap:
67
+
68
+ ```bash
69
+ npx @chlrc/aiw init --launcher "npx @chlrc/aiw" --dry-run --yes
70
+ ```
71
+
72
+ 3. Explain blockers using the preflight output. Blocking setup dependencies include Node/npx, Git, Worktrunk (`wt`), cmux, yazi, lazygit, nvim, the default layout/commit agent, and `delta` when the lazygit overlay is configured. Optional tools such as `fd`, `eza`, and non-default agents should be reported without blocking unrelated setup.
73
+
74
+ 4. Apply only after the user intends it:
75
+
76
+ ```bash
77
+ npx @chlrc/aiw init --launcher "npx @chlrc/aiw" --yes
78
+ ```
79
+
80
+ Useful variants:
81
+
82
+ ```bash
83
+ npx @chlrc/aiw init --cmux-scope home --yes
84
+ npx @chlrc/aiw init --cmux-scope code --code-root ~/Code --worktrees-root ~/worktrees --yes
85
+ npx @chlrc/aiw init --cmux-scope none --dry-run --yes
86
+ npx @chlrc/aiw init --config-dir ~/.config/aiw --no-reload --yes
87
+ ```
88
+
89
+ 5. Verify after setup:
90
+
91
+ ```bash
92
+ aiw doctor
93
+ aiw doctor --gate cmux-new --agent codex
94
+ aiw layout --agent codex --dry-run
95
+ ```
96
+
97
+ When validating cmux registration, check that the AIW actions exist rather than editing cmux config manually:
98
+
99
+ - `aiw-new-worktree` -> `aiw cmux-new`
100
+ - `aiw-pick-directory` -> `aiw cmux-new --pick-repo`
101
+ - `aiw-local-workspace` -> `aiw cmux-new --local`
102
+
103
+ ## Troubleshooting
104
+
105
+ - If setup fails before writing files, install the missing blocking dependency and rerun the dry-run command.
106
+ - If cmux config parsing fails, inspect the target JSON/JSONC file and fix invalid syntax before rerunning init.
107
+ - If an agent command is missing, install that agent CLI or edit `~/.config/aiw/agents.toml` to point at an available command.
108
+ - If `fnm_multishells ... Operation not permitted` appears before command output, treat it as shell startup noise when the actual AIW command succeeds.
109
+ - If the user only wants setup advice, answer from the preflight evidence and do not apply changes.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "AIW Init"
3
+ short_description: "Bootstrap and troubleshoot AIW setup"
4
+ default_prompt: "Use $aiw-init to initialize AIW on this machine and explain any dependency blockers."