devlog-tracker 0.25.0 → 0.27.0

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.
Files changed (117) hide show
  1. package/README.md +43 -71
  2. package/claude/hooks.json +75 -0
  3. package/cli/agents-md.js +18 -12
  4. package/cli/agents-md.test.js +37 -9
  5. package/cli/init.js +6 -4
  6. package/cli/init.test.js +5 -4
  7. package/cli/merge-hooks.js +5 -2
  8. package/cli/merge-hooks.test.js +52 -0
  9. package/cli/platforms/claude.js +55 -0
  10. package/cli/platforms/claude.test.js +178 -0
  11. package/cli/platforms/codex.js +21 -14
  12. package/cli/skills-from-commands.js +32 -0
  13. package/cli/skills-from-commands.test.js +51 -0
  14. package/cli/vendor.js +8 -1
  15. package/cli/vendor.test.js +24 -5
  16. package/codex/hooks/on-pre-tool.sh +3 -3
  17. package/codex/hooks/on-session-end.sh +2 -2
  18. package/codex/hooks/on-session-start.sh +2 -2
  19. package/codex/hooks/on-stop.sh +3 -3
  20. package/codex/hooks/on-user-prompt-submit.sh +2 -2
  21. package/codex/hooks/test-adapters.sh +2 -2
  22. package/commands/checkpoint.md +2 -2
  23. package/commands/clean.md +3 -3
  24. package/commands/compact.md +3 -3
  25. package/commands/continue.md +4 -4
  26. package/commands/keep.md +3 -3
  27. package/commands/lessons-drift.md +2 -2
  28. package/commands/lessons-off.md +3 -3
  29. package/commands/lessons-on.md +3 -3
  30. package/commands/lessons.md +3 -3
  31. package/commands/overview.md +3 -3
  32. package/commands/pause.md +3 -3
  33. package/commands/resume.md +3 -3
  34. package/commands/segment-watch.md +3 -3
  35. package/commands/span.md +2 -2
  36. package/commands/start.md +3 -3
  37. package/commands/status.md +3 -3
  38. package/{hooks → core}/scripts/await-open.sh +1 -1
  39. package/{hooks → core}/scripts/checkpoint-set.sh +1 -1
  40. package/{hooks → core}/scripts/clean-devlog.sh +1 -1
  41. package/{hooks → core}/scripts/close-open-round.sh +1 -1
  42. package/{hooks → core}/scripts/compact-devlog.sh +1 -1
  43. package/{hooks → core}/scripts/enforce-devlog.sh +1 -1
  44. package/{hooks → core}/scripts/keep-move.sh +1 -1
  45. package/{hooks → core}/scripts/kept-list.sh +1 -1
  46. package/{hooks → core}/scripts/lessons-append.sh +2 -2
  47. package/{hooks → core}/scripts/lessons-drift-set.sh +1 -1
  48. package/{hooks → core}/scripts/lessons-off.sh +1 -1
  49. package/{hooks → core}/scripts/lessons-on.sh +1 -1
  50. package/{hooks → core}/scripts/lessons-read.sh +1 -1
  51. package/{hooks → core}/scripts/on-tool-failure.sh +1 -1
  52. package/{hooks → core}/scripts/pause-devlog.sh +1 -1
  53. package/core/scripts/project-dir.sh +19 -0
  54. package/{hooks → core}/scripts/resume-devlog.sh +1 -1
  55. package/{hooks → core}/scripts/round-start.sh +1 -1
  56. package/{hooks → core}/scripts/run-tests.sh +1 -1
  57. package/{hooks → core}/scripts/segment-watch-set.sh +1 -1
  58. package/{hooks → core}/scripts/segment-watch.sh +1 -1
  59. package/{hooks → core}/scripts/session-start-devlog.sh +1 -1
  60. package/{hooks → core}/scripts/span-close.sh +1 -1
  61. package/{hooks → core}/scripts/span-open.sh +1 -1
  62. package/{hooks → core}/scripts/start-devlog.sh +1 -1
  63. package/{hooks → core}/scripts/status-devlog.sh +1 -1
  64. package/core/scripts/tests/test-cli-init-e2e.sh +68 -0
  65. package/core/scripts/tests/test-project-dir.sh +30 -0
  66. package/{hooks → core}/scripts/tests/test-session-start-devlog.sh +2 -2
  67. package/{hooks → core}/scripts/workspace-snapshot.sh +2 -2
  68. package/cursor/hooks/on-pre-tool.sh +2 -2
  69. package/cursor/hooks/on-session-end.sh +2 -2
  70. package/cursor/hooks/on-session-start.sh +2 -2
  71. package/cursor/hooks/on-stop.sh +2 -2
  72. package/cursor/hooks/on-submit-prompt.sh +2 -2
  73. package/cursor/hooks/on-tool-failure.sh +2 -2
  74. package/package.json +4 -3
  75. package/skills/devlog-tracker/SKILL.md +9 -9
  76. package/skills/devlog-tracker/references/lessons-mode.md +1 -1
  77. package/skills/devlog-tracker/references/reply-fold.md +1 -1
  78. package/hooks/scripts/tests/test-cli-init-e2e.sh +0 -38
  79. /package/{hooks → core}/scripts/detect-pending-question.sh +0 -0
  80. /package/{hooks → core}/scripts/devlog-lock.sh +0 -0
  81. /package/{hooks → core}/scripts/devlog-md.sh +0 -0
  82. /package/{hooks → core}/scripts/devlog-path.sh +0 -0
  83. /package/{hooks → core}/scripts/files-snapshot.sh +0 -0
  84. /package/{hooks → core}/scripts/json-field.sh +0 -0
  85. /package/{hooks → core}/scripts/on-session-end.sh +0 -0
  86. /package/{hooks → core}/scripts/on-stop-failure.sh +0 -0
  87. /package/{hooks → core}/scripts/redact-prompt.sh +0 -0
  88. /package/{hooks → core}/scripts/tests/test-await-open.sh +0 -0
  89. /package/{hooks → core}/scripts/tests/test-branch-scoped-integration.sh +0 -0
  90. /package/{hooks → core}/scripts/tests/test-checkpoint-set.sh +0 -0
  91. /package/{hooks → core}/scripts/tests/test-clean-devlog.sh +0 -0
  92. /package/{hooks → core}/scripts/tests/test-close-open-round.sh +0 -0
  93. /package/{hooks → core}/scripts/tests/test-compact-devlog.sh +0 -0
  94. /package/{hooks → core}/scripts/tests/test-devlog-lock.sh +0 -0
  95. /package/{hooks → core}/scripts/tests/test-devlog-md.sh +0 -0
  96. /package/{hooks → core}/scripts/tests/test-devlog-path.sh +0 -0
  97. /package/{hooks → core}/scripts/tests/test-enforce-devlog-files.sh +0 -0
  98. /package/{hooks → core}/scripts/tests/test-enforce-devlog-handoff-order.sh +0 -0
  99. /package/{hooks → core}/scripts/tests/test-enforce-devlog-workspace.sh +0 -0
  100. /package/{hooks → core}/scripts/tests/test-enforce-devlog.sh +0 -0
  101. /package/{hooks → core}/scripts/tests/test-files-snapshot.sh +0 -0
  102. /package/{hooks → core}/scripts/tests/test-json-field.sh +0 -0
  103. /package/{hooks → core}/scripts/tests/test-keep-move.sh +0 -0
  104. /package/{hooks → core}/scripts/tests/test-kept-list.sh +0 -0
  105. /package/{hooks → core}/scripts/tests/test-lessons-append.sh +0 -0
  106. /package/{hooks → core}/scripts/tests/test-lessons-drift-set.sh +0 -0
  107. /package/{hooks → core}/scripts/tests/test-lessons-on-off.sh +0 -0
  108. /package/{hooks → core}/scripts/tests/test-lessons-read.sh +0 -0
  109. /package/{hooks → core}/scripts/tests/test-on-interrupt.sh +0 -0
  110. /package/{hooks → core}/scripts/tests/test-redact-prompt.sh +0 -0
  111. /package/{hooks → core}/scripts/tests/test-resume-devlog.sh +0 -0
  112. /package/{hooks → core}/scripts/tests/test-round-start.sh +0 -0
  113. /package/{hooks → core}/scripts/tests/test-segment-watch-set.sh +0 -0
  114. /package/{hooks → core}/scripts/tests/test-segment-watch.sh +0 -0
  115. /package/{hooks → core}/scripts/tests/test-start-pause-devlog.sh +0 -0
  116. /package/{hooks → core}/scripts/tests/test-status-span.sh +0 -0
  117. /package/{hooks → core}/scripts/tests/test-workspace-snapshot.sh +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # devlog-tracker
2
2
 
3
- **版本** 0.25.0
3
+ **版本** 0.27.0
4
4
 
5
5
  在專案中維護一份 `.devlog/devlog.md`,把每一輪對話的請求、決策與結果寫成永久紀錄。對話一 `/clear` 或換 session 就沒了;這份檔案取代那個缺口,讓工作可以中斷再接。沒下過 `/devlog-tracker:start` 時,裝著也不會動任何檔案。
6
6
 
@@ -20,119 +20,91 @@
20
20
 
21
21
  ## 安裝
22
22
 
23
- 作為 Claude Code plugin 安裝(會自動更新):
23
+ 三個平台對等,各自獨立安裝;同一個專案要用哪個或哪幾個都可以,但同一個平台**不要同時**用 plugin marketplace 跟 `npx init` 兩條路線,會讓 hook 觸發兩次。
24
+
25
+ ### Claude Code
26
+
27
+ **方式一:plugin marketplace(會自動更新)**
24
28
 
25
29
  ```
26
30
  /plugin marketplace add gogogohuang/devlog-tracker
27
31
  /plugin install devlog-tracker@devlog-tracker
28
32
  ```
29
33
 
30
- ### npx(Cursor/Codex 用)
34
+ 指令用 `/devlog-tracker:*`(例如 `/devlog-tracker:start`)。
31
35
 
32
- Claude Code 請用上面的 `/plugin marketplace add` 安裝方式;這個 CLI 不會設定 Claude Code。
36
+ **方式二:npx(vendor 進專案,版本可鎖定)**
33
37
 
34
38
  ```bash
35
- npx devlog-tracker init
39
+ npx devlog-tracker init --claude
36
40
  ```
37
41
 
38
- 沒帶 `--codex`/`--cursor` 時會互動式問要裝哪個平台;在沒有 TTY 的環境(例如 CI)且沒帶旗標時,`init` 不會詢問,直接安裝所有支援的平台(codex + cursor)。也可以直接指定:
42
+ 會把 hooks 合併進 `.claude/settings.local.json`(不是 `settings.json`——合併後的指令路徑含這台機器的絕對路徑,不該 commit;`settings.local.json` 是 Claude Code 預設 gitignore 的檔案),並把 `commands/*.md` 轉成 `.claude/skills/devlog-<名稱>/SKILL.md`,用 `/devlog-<名稱>` 執行;同時在 `CLAUDE.md` 加上一段 `<!-- devlog-tracker:begin/end -->` fallback 說明。
43
+
44
+ ### Codex
39
45
 
40
46
  ```bash
41
- npx devlog-tracker init --codex --cursor
47
+ npx devlog-tracker init --codex
42
48
  ```
43
49
 
44
- 會把 `hooks/scripts/`、`codex/hooks/`、`cursor/hooks/`、`skills/`、`commands/`
45
- 複製進專案的 `.devlog-tracker/`,並把對應平台的 `hooks.json` 合併進專案(不覆蓋
46
- 其他工具已設定的 hook)。重新執行 `npx devlog-tracker init` 可以升級到套件目前的
47
- 版本;`npx devlog-tracker status` 可以查目前裝的版本是否落後。
50
+ 會把 `codex/hooks.json` 的 `hooks` 合併進專案 `.codex/hooks.json`,並從 `commands/*.md` 產生 `.agents/skills/devlog-<名稱>/SKILL.md`,用 `$devlog-<名稱>`(或 `/skills` 選)執行;同時在 `AGENTS.md` 加上同一種 fallback 說明區塊。舊版(0.25.0)寫到 `.codex/prompts/` 的檔案會在重跑 `init` 時清掉——Codex 不讀專案層級的 custom prompts。
48
51
 
49
- 裝 Codex 時,`init` 會從 `.devlog-tracker/commands/*.md` 產生對應的專案指令到
50
- `.codex/prompts/`,例如以 `/prompts:devlog-start` 啟動追蹤。也會在專案根目錄的
51
- `AGENTS.md` 加上(或更新)一段以 `<!-- devlog-tracker:begin/end -->` 包住的 fallback
52
- 說明。區塊外的內容不會動,重跑 `init` 只會換掉區塊本身;區塊裡只有相對路徑,可以 commit。
52
+ **hook 需要審核才會執行。** Codex 對新增或有變動的 hook 要求先審核;沒核准的 hook 會被直接略過,而且**沒有任何警告**,看起來就像 devlog 沒在記錄。這跟專案有沒有設成 `trust_level = "trusted"` 是兩回事,專案信任不會讓 hook 生效。
53
53
 
54
- 裝完 Codex 之後,第一次還要在 Codex 裡核准這些 hook,否則不會記錄(見下方〈Codex(選用)〉的「hook 需要審核」)。
54
+ - 互動模式:第一次開啟時 Codex 會提示有 hook 需要審核,核准後才會執行。之後 hook 的設定有變動(例如重跑 `init` 讓路徑或指令改變)也可能要再核准一次。
55
+ - 非互動的 `codex exec`(CI、腳本):未審核的 hook 會被靜默略過。`--dangerously-bypass-hook-trust` 可以讓它們跑起來,但那個旗標會略過所有 hook 的信任檢查,只適合已經自己確認過 hook 來源的自動化環境。
56
+ - 想確認有沒有生效:`start` 之後送一則訊息,看 `.devlog/.round-current.md` 有沒有出現這一輪的 User Input skeleton;沒有就代表 hook 沒被執行。
55
57
 
56
- `init` 會把這台機器專屬的絕對路徑寫進 `.codex/hooks.json`、`.cursor/hooks.json` 與
57
- `.devlog-tracker/env.sh`。如果你把這些檔案 commit 進 git,每位隊友都要在自己的機器上
58
- 跑一次 `npx devlog-tracker init`(路徑每台機器不同);或者改成把 `.devlog-tracker/` 與
59
- 產生出來的 hooks.json 加進 `.gitignore`。
58
+ Codex 目前沒有對應「使用者中斷」(Claude Code 的 `PostToolUseFailure`/`is_interrupt`)與「這輪異常結束」(`StopFailure`)的事件,這兩種細節狀態在 Codex 上不會被標記成 `INTERRUPTED`;核心強制記錄機制(`Stop` 事件擋住未寫完的輪次)不受影響。
60
59
 
61
- ### Cursor(選用)
60
+ ### Cursor
62
61
 
63
- Claude Code 仍是主要安裝方式。若要在 Cursor workspace 使用,先設定
64
- `DEVLOG_TRACKER_ROOT` 為本 plugin 的絕對路徑,再把 `cursor/hooks.json` 的
65
- `hooks` 合併進專案 `.cursor/hooks.json`。也可以把整個 `cursor/hooks/` 與
66
- `hooks/scripts/` vendoring 到專案,並調整 command 路徑;兩者的相對目錄必須維持可用。
62
+ ```bash
63
+ npx devlog-tracker init --cursor
64
+ ```
67
65
 
68
- Cursor cloud agent 不執行 `sessionStart`,因此不會自動注入接手摘要;其他已設定的
69
- hook 仍依 Cursor 支援的事件執行。
66
+ 會把 `cursor/hooks.json` 的 `hooks` 合併進專案 `.cursor/hooks.json`。Cursor 沒有 slash 指令面,hooks 裝好後照 commands/*.md 的步驟手動執行對應腳本。Cursor cloud agent 不執行 `sessionStart`,因此不會自動注入接手摘要;其他已設定的 hook 仍依 Cursor 支援的事件執行。
70
67
 
71
- Cursor 沒有 `/devlog-tracker:*` slash 指令面;hooks 裝好後,請用與 Claude commands
72
- 相同的腳本(`commands/*.md` 會優先讀 `CLAUDE_PLUGIN_ROOT`,否則讀
73
- `DEVLOG_TRACKER_ROOT`):
68
+ ### 三平台共通
74
69
 
75
70
  ```bash
76
- export DEVLOG_TRACKER_ROOT=/absolute/path/to/devlog-tracker
77
- export CLAUDE_PROJECT_DIR="$(pwd)"
78
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/start-devlog.sh"
79
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/status-devlog.sh"
80
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/segment-watch-set.sh" 600
81
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/checkpoint-set.sh" 20
82
- # pause / span-open / span-close / compact / keep-move / clean / resume:見 commands/*.md
71
+ npx devlog-tracker init
83
72
  ```
84
73
 
85
- ### Codex(選用)
74
+ 沒帶 `--claude`/`--codex`/`--cursor` 時會互動式問要裝哪個平台;在沒有 TTY 的環境(例如 CI)且沒帶旗標時,`init` 不會詢問,直接安裝全部三個平台。也可以組合指定,例如 `npx devlog-tracker init --claude --codex`。
86
75
 
87
- Claude Code 仍是主要安裝方式。若要在 Codex CLI 使用,先設定
88
- `DEVLOG_TRACKER_ROOT` 為本 plugin 的絕對路徑,再把 `codex/hooks.json` 的
89
- `hooks` 合併進專案(或 `~/.codex/`)的 `hooks.json`。也可以把整個 `codex/hooks/` 與
90
- `hooks/scripts/` vendoring 到專案,並調整 command 路徑;兩者的相對目錄必須維持可用。
76
+ 會把 `core/scripts/`、`claude/hooks.json`、`codex/hooks/`、`cursor/hooks/`、`skills/`、`commands/` 複製進專案的 `.devlog-tracker/`。重新執行 `npx devlog-tracker init` 可以升級到套件目前的版本;`npx devlog-tracker status` 可以查目前裝的版本是否落後。
91
77
 
92
- **hook 需要審核才會執行。** Codex 對新增或有變動的 hook 要求先審核;沒核准的 hook 會被
93
- 直接略過,而且**沒有任何警告**,看起來就像 devlog 沒在記錄。這跟專案有沒有設成
94
- `trust_level = "trusted"` 是兩回事,專案信任不會讓 hook 生效。
78
+ `init` 會把這台機器專屬的絕對路徑寫進各平台的 hooks 設定檔與 `.devlog-tracker/env.sh`。如果你把這些檔案 commit 進 git,每位隊友都要在自己的機器上跑一次 `npx devlog-tracker init`(路徑每台機器不同);或者改成把 `.devlog-tracker/` 與產生出來的 hooks 設定檔加進 `.gitignore`。
95
79
 
96
- - 互動模式:第一次開啟時 Codex 會提示有 hook 需要審核,核准後才會執行。之後 hook 的設定
97
- 有變動(例如重跑 `init` 讓路徑或指令改變)也可能要再核准一次。
98
- - 非互動的 `codex exec`(CI、腳本):未審核的 hook 會被靜默略過。`--dangerously-bypass-hook-trust`
99
- 可以讓它們跑起來,但那個旗標會略過所有 hook 的信任檢查,只適合已經自己確認過 hook 來源的
100
- 自動化環境。
101
- - 想確認有沒有生效:`start` 之後送一則訊息,看 `.devlog/.round-current.md` 有沒有出現這一輪的
102
- User Input skeleton;沒有就代表 hook 沒被執行。
103
-
104
- Codex 目前沒有對應「使用者中斷」(Claude Code 的 `PostToolUseFailure`/
105
- `is_interrupt`)與「這輪異常結束」(`StopFailure`)的事件,這兩種細節狀態在
106
- Codex 上不會被標記成 `INTERRUPTED`;核心強制記錄機制(`Stop` 事件擋住未寫完的
107
- 輪次)不受影響。
108
-
109
- Codex 使用 `/prompts:devlog-<名稱>`(例如 `/prompts:devlog-start`)執行指令;它們會
110
- 讀與 Claude commands 相同的內容。若使用的 Codex 環境沒有載入 custom prompts,仍可直接
111
- 使用以下腳本(`commands/*.md` 會優先讀 `CLAUDE_PLUGIN_ROOT`,否則讀
112
- `DEVLOG_TRACKER_ROOT`):
80
+ 若要手動裝(不透過 npx),設定 `DEVLOG_TRACKER_ROOT` 為本 plugin 的絕對路徑,把對應平台的 `hooks.json` 的 `hooks` 合併進專案設定;`commands/*.md` 會優先讀 `DEVLOG_TRACKER_ROOT`,否則讀 `CLAUDE_PLUGIN_ROOT`:
113
81
 
114
82
  ```bash
115
83
  export DEVLOG_TRACKER_ROOT=/absolute/path/to/devlog-tracker
116
- export CLAUDE_PROJECT_DIR="$(pwd)"
117
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/start-devlog.sh"
118
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/status-devlog.sh"
119
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/segment-watch-set.sh" 600
120
- bash "$DEVLOG_TRACKER_ROOT/hooks/scripts/checkpoint-set.sh" 20
84
+ export DEVLOG_PROJECT_DIR="$(pwd)"
85
+ bash "$DEVLOG_TRACKER_ROOT/core/scripts/start-devlog.sh"
86
+ bash "$DEVLOG_TRACKER_ROOT/core/scripts/status-devlog.sh"
87
+ bash "$DEVLOG_TRACKER_ROOT/core/scripts/segment-watch-set.sh" 600
88
+ bash "$DEVLOG_TRACKER_ROOT/core/scripts/checkpoint-set.sh" 20
121
89
  # pause / span-open / span-close / compact / keep-move / clean / resume:見 commands/*.md
122
90
  ```
123
91
 
124
92
  ## 快速開始
125
93
 
126
- 在專案裡下一次:
94
+ 在專案裡下一次(依安裝方式擇一):
127
95
 
128
96
  ```
129
- /devlog-tracker:start
97
+ /devlog-tracker:start # Claude Code plugin
98
+ /devlog-start # npx init --claude
99
+ $devlog-start # npx init --codex
130
100
  ```
131
101
 
132
- 之後正常跟 Claude 對話即可,每一輪結束前都會被強制檢查、補上 `.devlog/devlog.md` 的紀錄。`/clear` 之後 context 是空的;要接著做上一題,下 `/devlog-tracker:continue`。暫停、歸檔、具名搬走、狀態與 span 見下方指令表(完整 namespace,plugin 名稱是 `devlog-tracker`)。
102
+ 之後正常對話即可,每一輪結束前都會被強制檢查、補上 `.devlog/devlog.md` 的紀錄。`/clear` 之後 context 是空的;要接著做上一題,下對應的 `continue` 指令。暫停、歸檔、具名搬走、狀態與 span 見下方指令表。
133
103
 
134
104
  ## 指令
135
105
 
106
+ 下表以 plugin 的 `/devlog-tracker:*` namespace 表示;`npx init --claude` 裝的是 `/devlog-<名稱>`,`npx init --codex` 裝的是 `$devlog-<名稱>`,指令內容相同。
107
+
136
108
  | 指令 | 做什麼 |
137
109
  |---|---|
138
110
  | `/devlog-tracker:start` | 跑腳本建立 `.devlog/.enabled`(缺的 state 檔會補上,已有門檻不重置)。讀檔對進度,不自動開工。`.devlog/` 含 prompt,會建議加進 `.gitignore`,要你同意才改。 |
@@ -244,7 +216,7 @@ Claude 用純文字結尾提出問題、下一則訊息才拿到答案時,不
244
216
  ## 測試
245
217
 
246
218
  ```
247
- bash hooks/scripts/run-tests.sh
219
+ bash core/scripts/run-tests.sh
248
220
  ```
249
221
 
250
222
  含 Cursor adapter。
@@ -0,0 +1,75 @@
1
+ {
2
+ "hooks": {
3
+ "SessionStart": [
4
+ {
5
+ "matcher": "startup|resume|clear|compact|fork",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/session-start-devlog.sh\""
10
+ }
11
+ ]
12
+ }
13
+ ],
14
+ "UserPromptSubmit": [
15
+ {
16
+ "hooks": [
17
+ {
18
+ "type": "command",
19
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/round-start.sh\""
20
+ }
21
+ ]
22
+ }
23
+ ],
24
+ "PreToolUse": [
25
+ {
26
+ "hooks": [
27
+ {
28
+ "type": "command",
29
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/segment-watch.sh\""
30
+ }
31
+ ]
32
+ }
33
+ ],
34
+ "PostToolUseFailure": [
35
+ {
36
+ "hooks": [
37
+ {
38
+ "type": "command",
39
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/on-tool-failure.sh\""
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "StopFailure": [
45
+ {
46
+ "hooks": [
47
+ {
48
+ "type": "command",
49
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/on-stop-failure.sh\""
50
+ }
51
+ ]
52
+ }
53
+ ],
54
+ "SessionEnd": [
55
+ {
56
+ "hooks": [
57
+ {
58
+ "type": "command",
59
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/on-session-end.sh\""
60
+ }
61
+ ]
62
+ }
63
+ ],
64
+ "Stop": [
65
+ {
66
+ "hooks": [
67
+ {
68
+ "type": "command",
69
+ "command": "bash \"${CLAUDE_PLUGIN_ROOT}/core/scripts/enforce-devlog.sh\""
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ }
package/cli/agents-md.js CHANGED
@@ -5,19 +5,20 @@ const path = require('path');
5
5
  const BEGIN = '<!-- devlog-tracker:begin -->';
6
6
  const END = '<!-- devlog-tracker:end -->';
7
7
 
8
- const BLOCK = `${BEGIN}
8
+ function codexBlock() {
9
+ return `${BEGIN}
9
10
  ## devlog-tracker
10
11
 
11
- 這個專案用 devlog-tracker 在 \`.devlog/devlog.md\` 維護逐輪紀錄(Claude Code 與 Codex 共用同一份)。Codex 指令在 \`.codex/prompts/\`,以 \`/prompts:devlog-<名稱>\` 執行;若 slash command 不可用,請照下面對照做:
12
+ 這個專案用 devlog-tracker 在 \`.devlog/devlog.md\` 維護逐輪紀錄(Claude Code 與 Codex 共用同一份)。Codex 指令是 \`.agents/skills/devlog-<名稱>/\` 底下的 skill,用 \`/skills\` 選或打 \`$devlog-<名稱>\` 執行;若 skill 不可用,請照下面對照做:
12
13
 
13
14
  1. 先 \`source .devlog-tracker/env.sh\`(設定 \`DEVLOG_TRACKER_ROOT\`)。
14
- 2. 依使用者意圖讀對應的 \`.devlog-tracker/commands/<名稱>.md\`,照裡面的步驟做(腳本在 \`.devlog-tracker/hooks/scripts/\`,執行時 \`CLAUDE_PROJECT_DIR\` 設成專案根目錄)。
15
+ 2. 依使用者意圖讀對應的 \`.devlog-tracker/commands/<名稱>.md\`,照裡面的步驟做(腳本在 \`.devlog-tracker/core/scripts/\`,執行時 \`DEVLOG_PROJECT_DIR\` 設成專案根目錄)。
15
16
 
16
17
  | 使用者說 | 讀這份 |
17
18
  |---|---|
18
- | 開始追蹤 / start | \`/prompts:devlog-start\`;\`commands/start.md\` |
19
- | 暫停 / pause | \`/prompts:devlog-pause\`;\`commands/pause.md\` |
20
- | 狀態 / status | \`/prompts:devlog-status\`;\`commands/status.md\` |
19
+ | 開始追蹤 / start | \`$devlog-start\`;\`commands/start.md\` |
20
+ | 暫停 / pause | \`$devlog-pause\`;\`commands/pause.md\` |
21
+ | 狀態 / status | \`$devlog-status\`;\`commands/status.md\` |
21
22
  | 接續上一題 / continue(換過工具或 \`/clear\` 之後) | \`commands/continue.md\` |
22
23
  | 歸檔 / compact | \`commands/compact.md\` |
23
24
  | 清空重編 / clean(不可復原,先問使用者確認) | \`commands/clean.md\` |
@@ -29,23 +30,28 @@ const BLOCK = `${BEGIN}
29
30
  寫 devlog 的格式與規則見 \`.devlog-tracker/skills/devlog-tracker/SKILL.md\`。每輪結束前必須把當輪寫進 \`.devlog/\`;已 \`start\` 的專案,Stop hook 會擋沒寫完的輪次。
30
31
  ${END}
31
32
  `;
33
+ }
32
34
 
33
- function upsertAgentsMd(targetDir) {
34
- const filePath = path.join(targetDir, 'AGENTS.md');
35
+ function upsertMarkdown(targetDir, { fileName = 'AGENTS.md', block = codexBlock() } = {}) {
36
+ const filePath = path.join(targetDir, fileName);
35
37
  const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
36
38
  const begin = existing.indexOf(BEGIN);
37
39
  const end = existing.indexOf(END);
38
40
 
39
41
  let next;
40
42
  if (begin !== -1 && end > begin) {
41
- next = existing.slice(0, begin) + BLOCK + existing.slice(end + END.length).replace(/^\n/, '');
43
+ next = existing.slice(0, begin) + block + existing.slice(end + END.length).replace(/^\n/, '');
42
44
  } else if (existing.trim() === '') {
43
- next = BLOCK;
45
+ next = block;
44
46
  } else {
45
- next = `${existing.replace(/\n*$/, '\n')}\n${BLOCK}`;
47
+ next = `${existing.replace(/\n*$/, '\n')}\n${block}`;
46
48
  }
47
49
  if (next !== existing) fs.writeFileSync(filePath, next);
48
50
  return filePath;
49
51
  }
50
52
 
51
- module.exports = { upsertAgentsMd, BEGIN, END };
53
+ function upsertAgentsMd(targetDir) {
54
+ return upsertMarkdown(targetDir, { fileName: 'AGENTS.md', block: codexBlock() });
55
+ }
56
+
57
+ module.exports = { upsertAgentsMd, upsertMarkdown, codexBlock, BEGIN, END };
@@ -4,7 +4,7 @@ const assert = require('node:assert/strict');
4
4
  const fs = require('fs');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
- const { upsertAgentsMd, BEGIN, END } = require('./agents-md');
7
+ const { upsertAgentsMd, upsertMarkdown, BEGIN, END } = require('./agents-md');
8
8
  const { run } = require('./init');
9
9
 
10
10
  function tmp() {
@@ -40,29 +40,57 @@ test('is idempotent and replaces the block in place', () => {
40
40
  assert.equal(once.split(BEGIN).length, 2);
41
41
  });
42
42
 
43
- test('block mentions every command doc and Codex prompt naming convention', () => {
43
+ test('block mentions every command doc and Codex skill naming convention', () => {
44
44
  const commandsDir = path.join(__dirname, '..', 'commands');
45
45
  const text = fs.readFileSync(upsertAgentsMd(tmp()), 'utf8');
46
46
  for (const file of fs.readdirSync(commandsDir).filter((f) => f.endsWith('.md'))) {
47
47
  assert.ok(text.includes(`commands/${file}`), `AGENTS.md block is missing commands/${file}`);
48
48
  }
49
- assert.ok(text.includes('/prompts:devlog-start'));
49
+ assert.ok(text.includes('$devlog-start'));
50
50
  });
51
51
 
52
- test('init --codex writes AGENTS.md and custom prompts; --cursor alone does not', async () => {
52
+ test('init --codex writes AGENTS.md and project skills; --cursor alone does not', async () => {
53
53
  const repoRoot = path.join(__dirname, '..');
54
54
  const withCodex = tmp();
55
55
  await run(['--codex'], { repoRoot, targetDir: withCodex, version: '0.0.0' });
56
56
  assert.ok(fs.existsSync(path.join(withCodex, 'AGENTS.md')));
57
57
  for (const file of fs.readdirSync(path.join(repoRoot, 'commands')).filter((file) => file.endsWith('.md'))) {
58
- const prompt = fs.readFileSync(
59
- path.join(withCodex, '.codex', 'prompts', `devlog-${path.basename(file, '.md')}.md`),
60
- 'utf8'
61
- );
62
- assert.match(prompt, /\$ARGUMENTS/);
58
+ const name = `devlog-${path.basename(file, '.md')}`;
59
+ const skill = fs.readFileSync(path.join(withCodex, '.agents', 'skills', name, 'SKILL.md'), 'utf8');
60
+ assert.match(skill, new RegExp(`^---\\nname: ${name}\\ndescription: ".+"\\n---\\n`));
63
61
  }
62
+ assert.ok(!fs.existsSync(path.join(withCodex, '.codex', 'prompts')));
63
+
64
+ const upgraded = tmp();
65
+ const legacy = path.join(upgraded, '.codex', 'prompts');
66
+ fs.mkdirSync(legacy, { recursive: true });
67
+ fs.writeFileSync(path.join(legacy, 'devlog-start.md'), 'old');
68
+ fs.writeFileSync(path.join(legacy, 'mine.md'), 'keep');
69
+ await run(['--codex'], { repoRoot, targetDir: upgraded, version: '0.0.0' });
70
+ assert.ok(!fs.existsSync(path.join(legacy, 'devlog-start.md')));
71
+ assert.ok(fs.existsSync(path.join(legacy, 'mine.md')));
64
72
 
65
73
  const cursorOnly = tmp();
66
74
  await run(['--cursor'], { repoRoot, targetDir: cursorOnly, version: '0.0.0' });
67
75
  assert.ok(!fs.existsSync(path.join(cursorOnly, 'AGENTS.md')));
68
76
  });
77
+
78
+ test('upsertMarkdown writes to a custom file name with a custom block', () => {
79
+ const targetDir = tmp();
80
+
81
+ const filePath = upsertMarkdown(targetDir, {
82
+ fileName: 'CLAUDE.md',
83
+ block: `${BEGIN}\n## custom\n${END}\n`,
84
+ });
85
+
86
+ assert.equal(filePath, path.join(targetDir, 'CLAUDE.md'));
87
+ assert.equal(fs.readFileSync(filePath, 'utf8'), `${BEGIN}\n## custom\n${END}\n`);
88
+ });
89
+
90
+ test('upsertAgentsMd keeps writing AGENTS.md by default (back-compat)', () => {
91
+ const targetDir = tmp();
92
+
93
+ const filePath = upsertAgentsMd(targetDir);
94
+
95
+ assert.equal(filePath, path.join(targetDir, 'AGENTS.md'));
96
+ });
package/cli/init.js CHANGED
@@ -1,18 +1,20 @@
1
1
  'use strict';
2
2
  const readline = require('readline');
3
3
  const { vendor } = require('./vendor');
4
+ const claude = require('./platforms/claude');
4
5
  const codex = require('./platforms/codex');
5
6
  const cursor = require('./platforms/cursor');
6
7
 
7
- const PLATFORMS = { codex, cursor };
8
+ const PLATFORMS = { claude, codex, cursor };
8
9
 
9
10
  function parseArgs(argv) {
10
11
  const platforms = [];
11
12
  for (const arg of argv) {
12
- if (arg === '--codex') platforms.push('codex');
13
+ if (arg === '--claude') platforms.push('claude');
14
+ else if (arg === '--codex') platforms.push('codex');
13
15
  else if (arg === '--cursor') platforms.push('cursor');
14
16
  else if (arg.startsWith('-')) {
15
- throw new Error(`Unknown option: ${arg} (supported: --codex, --cursor)`);
17
+ throw new Error(`Unknown option: ${arg} (supported: --claude, --codex, --cursor)`);
16
18
  }
17
19
  }
18
20
  return { platforms };
@@ -22,7 +24,7 @@ function promptPlatforms() {
22
24
  if (!process.stdin.isTTY) return Promise.resolve(Object.keys(PLATFORMS));
23
25
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
24
26
  return new Promise((resolve) => {
25
- rl.question('要裝哪個平台?(codex/cursor,逗號分隔,留空=全部): ', (answer) => {
27
+ rl.question('要裝哪個平台?(claude/codex/cursor,逗號分隔,留空=全部): ', (answer) => {
26
28
  rl.close();
27
29
  const trimmed = answer.trim();
28
30
  if (!trimmed) return resolve(Object.keys(PLATFORMS));
package/cli/init.test.js CHANGED
@@ -6,16 +6,17 @@ const os = require('os');
6
6
  const path = require('path');
7
7
  const { parseArgs, run } = require('./init');
8
8
 
9
- test('parseArgs accepts --codex and --cursor', () => {
9
+ test('parseArgs accepts --claude, --codex and --cursor', () => {
10
+ assert.deepEqual(parseArgs(['--claude']), { platforms: ['claude'] });
10
11
  assert.deepEqual(parseArgs(['--codex']), { platforms: ['codex'] });
11
- assert.deepEqual(parseArgs(['--codex', '--cursor']), { platforms: ['codex', 'cursor'] });
12
+ assert.deepEqual(parseArgs(['--claude', '--codex', '--cursor']), { platforms: ['claude', 'codex', 'cursor'] });
12
13
  assert.deepEqual(parseArgs([]), { platforms: [] });
13
14
  });
14
15
 
15
16
  test('parseArgs throws a clear error for unknown options', () => {
16
17
  assert.throws(
17
- () => parseArgs(['--claude']),
18
- { message: 'Unknown option: --claude (supported: --codex, --cursor)' }
18
+ () => parseArgs(['--foo']),
19
+ { message: 'Unknown option: --foo (supported: --claude, --codex, --cursor)' }
19
20
  );
20
21
  assert.throws(() => parseArgs(['--codex', '-x']), /Unknown option: -x/);
21
22
  });
@@ -30,9 +30,12 @@ function readExisting(targetPath) {
30
30
  return parsed;
31
31
  }
32
32
 
33
- function mergeHooksTemplate({ templatePath, targetPath, vendorRoot }) {
33
+ function mergeHooksTemplate({ templatePath, targetPath, vendorRoot, placeholders = ['${DEVLOG_TRACKER_ROOT}'] }) {
34
34
  const escapedRoot = JSON.stringify(vendorRoot).slice(1, -1);
35
- const rawTemplate = fs.readFileSync(templatePath, 'utf8').split('${DEVLOG_TRACKER_ROOT}').join(escapedRoot);
35
+ let rawTemplate = fs.readFileSync(templatePath, 'utf8');
36
+ for (const placeholder of placeholders) {
37
+ rawTemplate = rawTemplate.split(placeholder).join(escapedRoot);
38
+ }
36
39
  const template = JSON.parse(rawTemplate);
37
40
 
38
41
  const existing = readExisting(targetPath);
@@ -185,3 +185,55 @@ test('real templates quote the vendor path so project paths with spaces work', (
185
185
  }
186
186
  }
187
187
  });
188
+
189
+ test('placeholders parameter substitutes multiple placeholder strings when provided', () => {
190
+ const dir = tmpdir();
191
+ const templatePath = path.join(dir, 'template.json');
192
+ fs.writeFileSync(
193
+ templatePath,
194
+ JSON.stringify({
195
+ hooks: {
196
+ SessionStart: [{ hooks: [{ type: 'command', command: 'bash "${CLAUDE_PLUGIN_ROOT}/script.sh"' }] }],
197
+ Stop: [{ hooks: [{ type: 'command', command: 'bash "${DEVLOG_TRACKER_ROOT}/other.sh"' }] }],
198
+ },
199
+ })
200
+ );
201
+ const targetPath = path.join(dir, 'hooks.json');
202
+ const vendorRoot = '/proj/.devlog-tracker';
203
+
204
+ mergeHooksTemplate({
205
+ templatePath,
206
+ targetPath,
207
+ vendorRoot,
208
+ placeholders: ['${DEVLOG_TRACKER_ROOT}', '${CLAUDE_PLUGIN_ROOT}'],
209
+ });
210
+
211
+ const written = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
212
+ assert.equal(written.hooks.SessionStart[0].hooks[0].command, `bash "${vendorRoot}/script.sh"`);
213
+ assert.equal(written.hooks.Stop[0].hooks[0].command, `bash "${vendorRoot}/other.sh"`);
214
+ });
215
+
216
+ test('unlisted placeholders remain verbatim when placeholders parameter is provided', () => {
217
+ const dir = tmpdir();
218
+ const templatePath = path.join(dir, 'template.json');
219
+ fs.writeFileSync(
220
+ templatePath,
221
+ JSON.stringify({
222
+ hooks: {
223
+ Stop: [{ hooks: [{ type: 'command', command: 'bash "${UNLISTED_PLACEHOLDER}/script.sh"' }] }],
224
+ },
225
+ })
226
+ );
227
+ const targetPath = path.join(dir, 'hooks.json');
228
+ const vendorRoot = '/proj/.devlog-tracker';
229
+
230
+ mergeHooksTemplate({
231
+ templatePath,
232
+ targetPath,
233
+ vendorRoot,
234
+ placeholders: ['${DEVLOG_TRACKER_ROOT}'],
235
+ });
236
+
237
+ const written = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
238
+ assert.equal(written.hooks.Stop[0].hooks[0].command, 'bash "${UNLISTED_PLACEHOLDER}/script.sh"');
239
+ });
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+ const { mergeHooksTemplate } = require('../merge-hooks');
4
+ const { upsertMarkdown, BEGIN, END } = require('../agents-md');
5
+ const { generateSkillsFromCommands } = require('../skills-from-commands');
6
+
7
+ function claudeBlock() {
8
+ return `${BEGIN}
9
+ ## devlog-tracker
10
+
11
+ 這個專案用 devlog-tracker 在 \`.devlog/devlog.md\` 維護逐輪紀錄。指令是 \`.claude/skills/devlog-<名稱>/\` 底下的 skill,用 \`/devlog-<名稱>\` 執行;若 skill 不可用,請照下面對照做:
12
+
13
+ 1. 先 \`source .devlog-tracker/env.sh\`(設定 \`DEVLOG_TRACKER_ROOT\`)。
14
+ 2. 依使用者意圖讀對應的 \`.devlog-tracker/commands/<名稱>.md\`,照裡面的步驟做(腳本在 \`.devlog-tracker/core/scripts/\`,執行時 \`DEVLOG_PROJECT_DIR\` 設成專案根目錄)。
15
+
16
+ | 使用者說 | 讀這份 |
17
+ |---|---|
18
+ | 開始追蹤 / start | \`/devlog-start\`;\`commands/start.md\` |
19
+ | 暫停 / pause | \`/devlog-pause\`;\`commands/pause.md\` |
20
+ | 狀態 / status | \`/devlog-status\`;\`commands/status.md\` |
21
+ | 接續上一題 / continue(換過工具或 \`/clear\` 之後) | \`commands/continue.md\` |
22
+ | 歸檔 / compact | \`commands/compact.md\` |
23
+ | 清空重編 / clean(不可復原,先問使用者確認) | \`commands/clean.md\` |
24
+ | 保存主題 / keep、接續具名檔 / resume、跨主題總覽 / overview | \`commands/keep.md\`、\`commands/resume.md\`、\`commands/overview.md\` |
25
+ | 長任務定期記錄 / span | \`commands/span.md\` |
26
+ | 調整沉默門檻 / checkpoint、segment-watch | \`commands/checkpoint.md\`、\`commands/segment-watch.md\` |
27
+ | 開發歷程教訓 / lessons、lessons-on、lessons-off、lessons-drift | \`commands/lessons.md\`、\`commands/lessons-on.md\`、\`commands/lessons-off.md\`、\`commands/lessons-drift.md\` |
28
+
29
+ 寫 devlog 的格式與規則見 \`.devlog-tracker/skills/devlog-tracker/SKILL.md\`。每輪結束前必須把當輪寫進 \`.devlog/\`;已 \`start\` 的專案,Stop hook 會擋沒寫完的輪次。
30
+
31
+ 注意:若同時透過 Claude Code plugin marketplace 安裝了 devlog-tracker,這兩條安裝路線的 hook 都會生效,導致同一輪被記錄兩次;二選一即可。
32
+ ${END}
33
+ `;
34
+ }
35
+
36
+ function installSkills({ targetDir, vendorRoot }) {
37
+ generateSkillsFromCommands({
38
+ commandsDir: path.join(vendorRoot, 'commands'),
39
+ targetSkillsDir: path.join(targetDir, '.claude', 'skills'),
40
+ namePrefix: 'devlog',
41
+ });
42
+ }
43
+
44
+ function install({ repoRoot, targetDir, vendorRoot }) {
45
+ mergeHooksTemplate({
46
+ templatePath: path.join(repoRoot, 'claude', 'hooks.json'),
47
+ targetPath: path.join(targetDir, '.claude', 'settings.local.json'),
48
+ vendorRoot,
49
+ placeholders: ['${DEVLOG_TRACKER_ROOT}', '${CLAUDE_PLUGIN_ROOT}'],
50
+ });
51
+ installSkills({ targetDir, vendorRoot });
52
+ upsertMarkdown(targetDir, { fileName: 'CLAUDE.md', block: claudeBlock() });
53
+ }
54
+
55
+ module.exports = { install, installSkills };