@ai-content-space/loopx 0.1.2 → 0.1.4

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 (69) hide show
  1. package/README.md +422 -57
  2. package/README.zh-CN.md +485 -0
  3. package/assets/logo.svg +89 -0
  4. package/package.json +5 -1
  5. package/plugins/loopx/.codex-plugin/plugin.json +1 -1
  6. package/plugins/loopx/scripts/plugin-install.test.mjs +14 -0
  7. package/plugins/loopx/skills/archive/SKILL.md +49 -0
  8. package/plugins/loopx/skills/build/SKILL.md +111 -9
  9. package/plugins/loopx/skills/clarify/SKILL.md +129 -8
  10. package/plugins/loopx/skills/debug/SKILL.md +296 -0
  11. package/plugins/loopx/skills/debug/condition-based-waiting.md +115 -0
  12. package/plugins/loopx/skills/debug/defense-in-depth.md +122 -0
  13. package/plugins/loopx/skills/debug/find-polluter.sh +63 -0
  14. package/plugins/loopx/skills/debug/root-cause-tracing.md +169 -0
  15. package/plugins/loopx/skills/go-style/SKILL.md +71 -0
  16. package/plugins/loopx/skills/kratos/SKILL.md +74 -0
  17. package/plugins/loopx/skills/kratos/references/advanced-features.md +314 -0
  18. package/plugins/loopx/skills/kratos/references/architecture.md +488 -0
  19. package/plugins/loopx/skills/kratos/references/configuration.md +399 -0
  20. package/plugins/loopx/skills/kratos/references/http-customization.md +512 -0
  21. package/plugins/loopx/skills/kratos/references/middleware-logging.md +400 -0
  22. package/plugins/loopx/skills/kratos/references/proto-api-design.md +432 -0
  23. package/plugins/loopx/skills/kratos/references/security-auth.md +411 -0
  24. package/plugins/loopx/skills/kratos/references/troubleshooting.md +385 -0
  25. package/plugins/loopx/skills/plan/SKILL.md +24 -3
  26. package/plugins/loopx/skills/review/SKILL.md +98 -1
  27. package/plugins/loopx/skills/tdd/SKILL.md +371 -0
  28. package/plugins/loopx/skills/tdd/testing-anti-patterns.md +299 -0
  29. package/plugins/loopx/skills/verify/SKILL.md +139 -0
  30. package/scripts/codex-stop-hook.mjs +71 -0
  31. package/scripts/codex-workflow-hook.mjs +248 -0
  32. package/skills/archive/SKILL.md +49 -0
  33. package/skills/build/SKILL.md +111 -9
  34. package/skills/clarify/SKILL.md +129 -8
  35. package/skills/debug/SKILL.md +296 -0
  36. package/skills/debug/condition-based-waiting.md +115 -0
  37. package/skills/debug/defense-in-depth.md +122 -0
  38. package/skills/debug/find-polluter.sh +63 -0
  39. package/skills/debug/root-cause-tracing.md +169 -0
  40. package/skills/go-style/SKILL.md +71 -0
  41. package/skills/kratos/SKILL.md +74 -0
  42. package/skills/kratos/references/advanced-features.md +314 -0
  43. package/skills/kratos/references/architecture.md +488 -0
  44. package/skills/kratos/references/configuration.md +399 -0
  45. package/skills/kratos/references/http-customization.md +512 -0
  46. package/skills/kratos/references/middleware-logging.md +400 -0
  47. package/skills/kratos/references/proto-api-design.md +432 -0
  48. package/skills/kratos/references/security-auth.md +411 -0
  49. package/skills/kratos/references/troubleshooting.md +385 -0
  50. package/skills/plan/SKILL.md +20 -3
  51. package/skills/review/SKILL.md +98 -1
  52. package/skills/tdd/SKILL.md +371 -0
  53. package/skills/tdd/testing-anti-patterns.md +299 -0
  54. package/skills/verify/SKILL.md +139 -0
  55. package/src/build-runtime.mjs +311 -26
  56. package/src/build-stop-gate.mjs +94 -0
  57. package/src/cli.mjs +57 -5
  58. package/src/codex-exec-runtime.mjs +105 -5
  59. package/src/context-manifest.mjs +172 -0
  60. package/src/html-views.mjs +316 -0
  61. package/src/install-discovery.mjs +352 -5
  62. package/src/next-skill.mjs +57 -5
  63. package/src/plan-runtime.mjs +102 -122
  64. package/src/review-runtime.mjs +558 -0
  65. package/src/runtime-maintenance.mjs +429 -14
  66. package/src/template-governance.mjs +223 -0
  67. package/src/workflow.mjs +2341 -120
  68. package/src/workspace-context.mjs +166 -0
  69. package/src/workspace-memory.mjs +69 -0
@@ -0,0 +1,485 @@
1
+ <p align="center">
2
+ <img src="./assets/logo.svg" alt="loopx fox logo" width="128" height="128">
3
+ </p>
4
+
5
+ <h1 align="center">loopx</h1>
6
+
7
+ <p align="center">
8
+ 面向 Codex 的 skill-first 工作流运行时。
9
+ </p>
10
+
11
+ [English](./README.md)
12
+
13
+ `loopx` 是一个面向 Codex 的 skill-first 工作流工具包。它把需求澄清、共识规划、持久执行、独立评审组织成一条可追踪的本地工作流,并通过 CLI 与 Codex Skill 两种方式暴露同一套运行时。
14
+
15
+ 当前公开流程:
16
+
17
+ ```text
18
+ clarify -> plan -> build -> review -> approve review->done -> archive
19
+ ```
20
+
21
+ `done` 是通过 `loopx approve <slug> --from review --to done` 进入的运行时完成状态,不是单独的 Codex skill。
22
+
23
+ 评审通过并进入 `done` 后,可以执行 archive,把本次被接受的 change delta 合并到长期 specs。
24
+
25
+ 其中 `autopilot` 是端到端编排入口,会在内部复用这套公开阶段,而不是引入另一套流程真相。
26
+
27
+ ## 特性
28
+
29
+ - 安装并公开 11 个 loopx Codex skills:工作流 skills `clarify`、`plan`、`build`、`review`、`archive`、`autopilot`,质量辅助 skills `debug`、`tdd`、`verify`,以及 Go 支持 skills `go-style`、`kratos`。
30
+ - 支持 npm 全局安装和 Codex plugin 安装,两种安装方式共享同一套 install/discovery 逻辑。
31
+ - 自动安装 loopx 管理的 Codex workflow hook,在 Codex 中提示当前 workflow 状态和安全下一步。
32
+ - 所有运行时状态和阶段产物都写入项目本地 `.loopx/`,便于审计、恢复和迁移。
33
+ - clarify 需求快照写入 `.loopx/intake/`,让 `.loopx/specs/` 只承载长期领域规格。
34
+ - `plan` 默认采用 Planner -> Architect -> Critic 的共识规划循环。
35
+ - `plan` 会写入借鉴 OpenSpec 的 change artifacts:proposal、spec delta、design、tasks 和 artifact dependency graph。
36
+ - 提供项目级 agent context:`.loopx/agents/` 和 `.loopx/context/domain.md`,供 build/review 的 context manifest 消费。
37
+ - `build` 默认包含执行记录、验证证据、架构验收、deslop 清理和回归再验证。
38
+ - `review` 作为独立验收面,包含代码审查和内部 architecture-smell lane,并输出中文评审结论和 go/no-go 判断。
39
+ - 支持 `archive`,把已批准的 change delta 同步进长期 `.loopx/specs/` source of truth,并生成 ADR candidate。
40
+
41
+ ## 安装
42
+
43
+ ### npm 全局安装
44
+
45
+ ```bash
46
+ npm install -g @ai-content-space/loopx
47
+ ```
48
+
49
+ 安装后会自动运行:
50
+
51
+ ```bash
52
+ node scripts/install-skills.mjs
53
+ ```
54
+
55
+ 该脚本会把 loopx 管理的 skills 安装到:
56
+
57
+ ```text
58
+ ~/.agents/skills/
59
+ ```
60
+
61
+ 同时也会把 loopx 管理的 Codex workflow hook 安装到:
62
+
63
+ ```text
64
+ ~/.codex/hooks/codex-workflow-hook.mjs
65
+ ```
66
+
67
+ 并更新:
68
+
69
+ ```text
70
+ ~/.agents/.skill-lock.json
71
+ ```
72
+
73
+ ### Codex plugin 安装
74
+
75
+ 插件入口位于:
76
+
77
+ ```text
78
+ plugins/loopx/
79
+ ```
80
+
81
+ 插件安装脚本:
82
+
83
+ ```bash
84
+ node plugins/loopx/scripts/plugin-install.mjs
85
+ ```
86
+
87
+ npm 安装和 plugin 安装会收敛到同一个 `installationIdentity=loopx`,避免 Codex 里出现重复的 loopx skill 集合。
88
+
89
+ ## 快速开始
90
+
91
+ 初始化一个工作流:
92
+
93
+ ```bash
94
+ loopx init --slug my-task
95
+ ```
96
+
97
+ 进入澄清阶段:
98
+
99
+ ```bash
100
+ loopx clarify my-task
101
+ ```
102
+
103
+ 澄清完成后批准进入计划阶段:
104
+
105
+ ```bash
106
+ loopx approve my-task --from clarify --to plan
107
+ loopx plan my-task
108
+ ```
109
+
110
+ 计划完成后批准执行:
111
+
112
+ ```bash
113
+ loopx approve my-task --from plan --to build
114
+ loopx build my-task
115
+ ```
116
+
117
+ 执行完成后进入评审:
118
+
119
+ ```bash
120
+ loopx approve my-task --from build --to review
121
+ loopx review my-task
122
+ ```
123
+
124
+ 评审通过后完成工作流:
125
+
126
+ ```bash
127
+ loopx approve my-task --from review --to done
128
+ ```
129
+
130
+ 把已接受行为归档到长期 specs:
131
+
132
+ ```text
133
+ $archive my-task
134
+ ```
135
+
136
+ 查看状态:
137
+
138
+ ```bash
139
+ loopx status my-task
140
+ loopx status my-task --json
141
+ ```
142
+
143
+ 生成派生 HTML 阅读视图:
144
+
145
+ ```bash
146
+ loopx render my-task
147
+ ```
148
+
149
+ 也可以让 loopx 根据一个现成 spec 直接创建规划工作流:
150
+
151
+ ```bash
152
+ loopx plan --direct ./path/to/spec.md
153
+ ```
154
+
155
+ ## CLI 命令
156
+
157
+ ```bash
158
+ loopx init [--slug <slug>]
159
+ loopx clarify <slug> [--standard|--deep]
160
+ loopx approve <slug> --from <stage> --to <stage>
161
+ loopx plan [slug] [--direct <spec-path>] [--interactive] [--deliberate]
162
+ loopx build <slug> [--no-deslop]
163
+ loopx build --from-review <review-report-path> [--no-deslop]
164
+ loopx review <slug> [--reviewer <name>]
165
+ loopx archive <slug>
166
+ loopx autopilot <slug> [--reviewer <name>]
167
+ loopx render [slug|--all]
168
+ loopx status [slug] [--json]
169
+ loopx setup-context
170
+ loopx doctor
171
+ loopx migrate
172
+ loopx repair-install
173
+ ```
174
+
175
+ CLI 主要用于运行时、调试、状态观察和维护。日常面向 Codex 的主入口是同名 skills,例如 `$clarify`、`$plan`、`$build`、`$review`、`$archive`、`$autopilot`、`$debug`、`$tdd`、`$verify`、`$go-style`、`$kratos`。
176
+
177
+ `loopx status` 仍然是 CLI/runtime 诊断命令,不作为单独 Codex skill 暴露。`loopx render` 会基于现有运行时产物生成给人阅读的 HTML 视图;不传 slug 时会渲染所有非 legacy workflow 和工作区首页。Markdown 和 JSON 仍然是机器可读、可编辑的事实源。
178
+
179
+ ## Skill 说明
180
+
181
+ ### clarify
182
+
183
+ `clarify` 用于把模糊请求转成可执行 spec。它会维护歧义分数、非目标、决策边界和压力测试结果。只有满足门禁后,才建议进入 `plan`。
184
+
185
+ 默认 profile:
186
+
187
+ - `--standard`:目标歧义分数 `<= 0.20`,最多 `15` 轮。
188
+ - `--deep`:目标歧义分数 `<= 0.10`,最多 `25` 轮。
189
+
190
+ ### plan
191
+
192
+ `plan` 把已批准的 clarify spec 或直接输入的 spec 转成计划包。默认包含 Planner、Architect、Critic 三段式评审循环,最多迭代到通过或达到上限。
193
+
194
+ 主要产物:
195
+
196
+ - `.loopx/plans/prd-<slug>.md`
197
+ - `.loopx/plans/test-spec-<slug>.md`
198
+ - `.loopx/changes/active/<change-id>/proposal.md`
199
+ - `.loopx/changes/active/<change-id>/spec-delta.md`
200
+ - `.loopx/changes/active/<change-id>/design.md`
201
+ - `.loopx/changes/active/<change-id>/tasks.md`
202
+ - `.loopx/changes/active/<change-id>/artifact-graph.json`
203
+ - `.loopx/workflows/<slug>/plan.md`
204
+ - `.loopx/workflows/<slug>/architecture.md`
205
+ - `.loopx/workflows/<slug>/development-plan.md`
206
+ - `.loopx/workflows/<slug>/test-plan.md`
207
+
208
+ `spec-delta.md` 使用 requirement delta:`## ADDED Requirements`、`## MODIFIED Requirements`、`## REMOVED Requirements` 和 `## RENAMED Requirements`。ADDED / MODIFIED 必须是完整的 `### Requirement:` 块,包含 SHALL/MUST 约束和 `#### Scenario:` 场景,archive 才能把它们合并进长期 spec 当前状态。
209
+
210
+ ### build
211
+
212
+ `build` 执行已批准的计划,并把执行过程、验证证据和限制记录到 canonical artifact:
213
+
214
+ ```text
215
+ .loopx/workflows/<slug>/execution-record.md
216
+ ```
217
+
218
+ `build` 内部保留结构化 runtime lanes,同时增加 Ralph-like owner loop:单一 owner 持续推进,可并行 delegation,但进入 review handoff 前必须满足 blocking delegation 已 drain,并通过 completion audit。相关运行态证据写入:
219
+
220
+ ```text
221
+ .loopx/workflows/<slug>/build-support/delegation-ledger.json
222
+ .loopx/workflows/<slug>/build-support/completion-audit.json
223
+ ```
224
+
225
+ 这些仍然是 build 支撑证据,不替代 `execution-record.md`。
226
+
227
+ 默认流程包含 deslop 清理;如果确实要跳过,可以使用:
228
+
229
+ ```bash
230
+ loopx build <slug> --no-deslop
231
+ ```
232
+
233
+ 当 review 要求修实现问题时,Codex 侧的正常回路把 review artifact 作为本轮返工合同:
234
+
235
+ ```text
236
+ $build --from-review .loopx/workflows/<slug>/review-report.md
237
+ ```
238
+
239
+ 已批准 PRD、test spec、上次 `execution-record.md` 和 workflow-local plan package 仍会作为支撑上下文加载,但不再让用户把 PRD 当成本轮返工的主参数。
240
+
241
+ ### review
242
+
243
+ `review` 消费 build 输出的 `execution-record.md`,执行独立验收、代码评审和轻量 architecture-smell lane,并生成:
244
+
245
+ ```text
246
+ .loopx/workflows/<slug>/review-report.md
247
+ ```
248
+
249
+ 最终用户可见评审结果要求使用中文。
250
+
251
+ 如果评审通过,仍然需要显式批准 `review -> done`。如果评审要求修实现问题,则运行 `$build --from-review .loopx/workflows/<slug>/review-report.md`。只有当 review 明确指出计划或需求本身错误时,才回到 `$plan <slug>` 或 `$clarify <slug>`。
252
+
253
+ architecture-smell lane 是 review 的一部分,不会增加新阶段。它会把发现记录到 `review-support/architecture-smell.json`,只有当模块边界、可测试性、领域词汇或计划架构假设存在实质性错误时才阻断。
254
+
255
+ ### archive
256
+
257
+ `archive` 消费已完成工作流,并把 `.loopx/changes/active/<change-id>/spec-delta.md` 合并进 `.loopx/specs/` 下的长期领域规格。归档后的 change 目录会移动到:
258
+
259
+ ```text
260
+ .loopx/changes/archive/<change-id>/
261
+ ```
262
+
263
+ Archive 还会在 `.loopx/decisions/adr-candidates/<change-id>.md` 写入建议性 ADR candidate,不会自动提升到 `docs/adr/`。
264
+
265
+ Archive 现在按语义应用 requirement delta,而不是追加每次 change 的历史块。ADDED 新增 requirement,MODIFIED 替换完整 requirement 块,REMOVED 删除 requirement,RENAMED 只修改 requirement 标题并保留正文。
266
+
267
+ ### autopilot
268
+
269
+ `autopilot` 是端到端编排入口,会在内部组织 expansion、planning、execution、qa、validation 等阶段,但 canonical artifact 仍然来自公开的 `clarify -> plan -> build -> review` 流程。
270
+
271
+ 自动编排 ledger 写入:
272
+
273
+ ```text
274
+ .loopx/autopilot/<slug>/run.json
275
+ ```
276
+
277
+ ### debug
278
+
279
+ `debug` 是用于 bug、测试失败、回归和异常行为的质量辅助 skill。它要求先完成根因调查,再进入模式对比、假设验证和修复实现,避免直接猜测式打补丁。
280
+
281
+ ### tdd
282
+
283
+ `tdd` 是用于功能开发和 bug 修复的质量辅助 skill。它要求先写失败测试,确认失败原因正确,再实现最小可通过改动。
284
+
285
+ ### verify
286
+
287
+ `verify` 是用于最终完成声明前的质量辅助 skill。它要求在声称完成、修好、测试通过、可提交或可评审之前,先运行 fresh verification 并读取真实输出。
288
+
289
+ ### go-style
290
+
291
+ `go-style` 是 Go 语言支持 skill。它用于指导 `.go` 文件编辑,强调 idiomatic Go、保留项目本地风格、清晰错误处理、小接口、表驱动测试,以及 `gofmt` 和 Go 验证。
292
+
293
+ ### kratos
294
+
295
+ `kratos` 是 Go-Kratos 框架支持 skill。当项目出现 `buf.yaml`、proto API、`internal/service`、`internal/biz`、`internal/data` 或 `github.com/go-kratos/kratos/v2` 等信号时使用,并提供 proto 设计、分层架构、配置、中间件、认证、HTTP 定制和排错参考。
296
+
297
+ ## 运行时目录
298
+
299
+ loopx 在当前项目下写入 `.loopx/`:
300
+
301
+ ```text
302
+ .loopx/
303
+ README.md
304
+ config.json
305
+ intake/
306
+ clarify-<slug>-<timestamp>.md
307
+ views/
308
+ index.html
309
+ specs/
310
+ <domain>/
311
+ spec.md
312
+ changes/
313
+ active/
314
+ <change-id>/
315
+ proposal.md
316
+ spec-delta.md
317
+ design.md
318
+ tasks.md
319
+ slices.json
320
+ artifact-graph.json
321
+ archive/
322
+ <change-id>/
323
+ decisions/
324
+ adr-candidates/
325
+ plans/
326
+ agents/
327
+ issue-tracker.md
328
+ domain.md
329
+ triage-labels.md
330
+ context/
331
+ domain.md
332
+ workflows/
333
+ <slug>/
334
+ state.json
335
+ spec.md
336
+ plan.md
337
+ architecture.md
338
+ development-plan.md
339
+ test-plan.md
340
+ execution-record.md
341
+ review-report.md
342
+ view/
343
+ index.html
344
+ intake.html
345
+ plan.html
346
+ build.html
347
+ review.html
348
+ plan-reviews/
349
+ build-support/
350
+ autopilot/
351
+ <slug>/
352
+ run.json
353
+ ```
354
+
355
+ `intake` 保存一次需求的 clarify 快照;`workflows` 保存当前任务的运行时工作副本;`changes` 保存本次需求对长期行为的 change delta;`specs` 只保存 archive 后的长期领域行为契约。
356
+
357
+ `views/` 和 `workflows/<slug>/view/` 是 `loopx render` 生成的派生 HTML 阅读视图,只服务于人的浏览和评审,可以随时重新生成;agent 和工具仍应读取、修改 Markdown 与 JSON 产物。
358
+
359
+ ### 文档关注边界
360
+
361
+ 用户日常需要关注的文档:
362
+
363
+ - `README.md` / `README.zh-CN.md`:产品用法、命令和目录约定。
364
+ - `.loopx/workflows/<slug>/spec.md`:当前需求工作副本。
365
+ - `.loopx/workflows/<slug>/plan.md`、`architecture.md`、`development-plan.md`、`test-plan.md`:当前任务的计划、架构和验证约定。
366
+ - `.loopx/workflows/<slug>/execution-record.md`、`review-report.md`:执行证据和评审结论。
367
+ - `.loopx/views/index.html` 与 `.loopx/workflows/<slug>/view/index.html`:由 `loopx render` 生成的阅读入口。
368
+
369
+ 用户可以阅读和按流程修改的事实源文档:
370
+
371
+ - `.loopx/workflows/<slug>/*.md`:当前 workflow 的可编辑工作副本;修改后仍需通过对应阶段门禁。
372
+ - `.loopx/context/domain.md` 和 `.loopx/agents/*.md`:项目级背景、术语和 agent 协作约定。
373
+ - `.loopx/changes/active/<change-id>/*.md`:plan 生成的 change proposal、design、tasks 和 spec delta;修改后应重新过 plan/build/review。
374
+ - `.loopx/specs/<domain>/spec.md`:archive 后的长期行为规格;通常由 `archive` 同步,人工改动需要保持和后续 change delta 一致。
375
+
376
+ 工具运行依赖或派生的文档/数据:
377
+
378
+ - `.loopx/workflows/<slug>/state.json`、`build-context.jsonl`、`review-context.jsonl`:运行时状态和 context manifest,工具依赖,不建议手改。
379
+ - `.loopx/workflows/<slug>/plan-reviews/`、`build-support/`、`review-support/`:阶段证据和内部审查结果,供诊断和 review 使用。
380
+ - `.loopx/intake/clarify-*.md`:clarify 快照,用于审计和追溯;不要当作长期 specs 修改。
381
+ - `.loopx/changes/active/<change-id>/slices.json`、`artifact-graph.json`:计划结构化数据,build/review/archive 会消费。
382
+ - `.loopx/autopilot/<slug>/run.json`、`.loopx/build-active.json`:编排和 stop-hook 运行态。
383
+ - `.loopx/views/` 和 `.loopx/workflows/<slug>/view/`:HTML 派生视图,可删除后用 `loopx render` 重新生成,不应作为事实源编辑。
384
+
385
+ ## 安装诊断与修复
386
+
387
+ 检查运行时和 skill 安装状态:
388
+
389
+ ```bash
390
+ loopx doctor
391
+ ```
392
+
393
+ 修复 loopx 管理的 skill 安装:
394
+
395
+ ```bash
396
+ loopx repair-install
397
+ ```
398
+
399
+ 只检查当前 skill discovery 状态:
400
+
401
+ ```bash
402
+ node scripts/install-skills.mjs --check
403
+ ```
404
+
405
+ ## Codex Workflow Hook
406
+
407
+ `install-skills.mjs` 和 Codex plugin 安装脚本会自动把 `scripts/codex-workflow-hook.mjs` 安装到:
408
+
409
+ ```text
410
+ ~/.codex/hooks/codex-workflow-hook.mjs
411
+ ```
412
+
413
+ 该 hook 会读取最近的 `.loopx/workflows/<slug>/state.json`,为当前 workflow 输出建议性上下文:当前阶段、blockers、readiness、authorization、evidence 和安全下一步。它只提供提示;真正的运行时门禁仍以 loopx runtime 为准。
414
+
415
+ 设置 `LOOPX_HOOKS=0` 可以关闭 workflow hook 输出。
416
+
417
+ ## Codex Stop Hook
418
+
419
+ loopx 内置一个 Codex stop-hook 辅助脚本,用于防止活跃 build 在达到 review handoff 之前提前停止:
420
+
421
+ ```bash
422
+ node scripts/codex-stop-hook.mjs
423
+ ```
424
+
425
+ `loopx build` 运行期间会写入持久状态:
426
+
427
+ ```text
428
+ .loopx/build-active.json
429
+ ```
430
+
431
+ 如果状态显示 build 仍处于 `starting`、`executing`、`verifying` 或 `fixing`,hook 会返回 `allow: false` 和继续执行提示。只有 build 已经 `review-ready`、被真实 blocker 阻塞、失败、取消或不活跃时,hook 才允许停止。
432
+
433
+ ## 环境变量
434
+
435
+ 安装和 discovery 逻辑支持以下环境变量:
436
+
437
+ - `LOOPX_HOME`:覆盖默认 home 目录。
438
+ - `LOOPX_AGENTS_ROOT`:覆盖 `.agents` 根目录。
439
+ - `LOOPX_SKILLS_ROOT`:覆盖已安装 skills 目录。
440
+ - `LOOPX_SKILL_LOCK_PATH`:覆盖 skill lock 文件路径。
441
+ - `LOOPX_PROJECT_ROOT`:覆盖 loopx 项目根目录。
442
+ - `LOOPX_SKILL_SOURCE_ROOT`:覆盖 skill 源目录。
443
+ - `LOOPX_DISTRIBUTION_CHANNEL`:设置安装渠道,默认 `npm`。
444
+ - `LOOPX_INSTALLATION_IDENTITY`:设置安装身份,默认 `loopx`。
445
+ - `LOOPX_SOURCE_URL`:设置安装来源。
446
+ - `LOOPX_HOOKS`:设置为 `0` 时关闭 workflow hook 输出。
447
+
448
+ ## 开发
449
+
450
+ 安装依赖后运行测试:
451
+
452
+ ```bash
453
+ npm test
454
+ ```
455
+
456
+ 也可以直接执行项目内的验证命令:
457
+
458
+ ```bash
459
+ node --test test/*.test.mjs
460
+ node scripts/install-skills.mjs --check
461
+ node --test plugins/loopx/scripts/plugin-install.test.mjs
462
+ node src/cli.mjs --help
463
+ node src/cli.mjs doctor
464
+ node src/cli.mjs status --json
465
+ ```
466
+
467
+ ## 发布内容
468
+
469
+ `package.json` 的 `files` 字段会发布以下内容:
470
+
471
+ - `README.md`
472
+ - `README.zh-CN.md`
473
+ - `package.json`
474
+ - `scripts/install-skills.mjs`
475
+ - `scripts/codex-stop-hook.mjs`
476
+ - `scripts/codex-workflow-hook.mjs`
477
+ - `assets/logo.svg`
478
+ - `src/`
479
+ - `skills/`,包含公开 loopx skills 以及随包发布的兼容/内部 skill 源文件
480
+ - `templates/`
481
+ - `plugins/loopx/`
482
+
483
+ ## 版本
484
+
485
+ 当前 npm 包版本:`0.1.4`。
@@ -0,0 +1,89 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-labelledby="title desc">
2
+ <title id="title">loopx fox logo</title>
3
+ <desc id="desc">A cute black and white fox mascot in left-facing profile with a curled tail.</desc>
4
+ <g transform="translate(0.000000,256.000000) scale(0.025000,-0.025000)"
5
+ fill="#000000" stroke="none">
6
+ <path d="M5828 9086 c-59 -21 -132 -81 -223 -184 -395 -444 -774 -1140 -908
7
+ -1667 -18 -71 -37 -131 -42 -133 -6 -1 -57 9 -115 22 -103 25 -262 46 -337 46
8
+ l-38 0 76 -74 77 -73 -109 -7 c-119 -7 -305 -36 -384 -60 -27 -8 -50 -14 -52
9
+ -12 -5 5 136 62 212 85 39 12 98 25 133 28 34 3 65 9 67 14 3 4 -28 36 -69 72
10
+ l-74 65 45 6 c117 16 292 5 493 -30 l35 -6 12 54 c7 29 27 97 44 150 l32 97
11
+ -58 73 c-262 326 -572 612 -891 822 -279 182 -403 179 -451 -12 -21 -81 -28
12
+ -399 -14 -563 27 -304 117 -651 222 -861 16 -32 29 -61 29 -65 0 -4 -18 -21
13
+ -40 -36 -22 -16 -40 -31 -40 -35 0 -4 48 -6 107 -5 105 3 107 2 83 -15 -230
14
+ -161 -385 -319 -497 -507 -119 -200 -152 -337 -163 -670 -6 -224 -9 -245 -34
15
+ -320 -54 -161 -155 -291 -319 -413 -168 -125 -284 -186 -394 -207 -92 -18
16
+ -179 -59 -208 -98 -33 -46 -27 -137 14 -214 61 -115 199 -252 270 -270 14 -3
17
+ 46 -25 71 -47 56 -52 126 -100 187 -130 27 -12 68 -42 93 -65 56 -53 197 -122
18
+ 310 -153 74 -20 108 -23 260 -22 158 0 195 4 380 38 326 59 478 59 564 -2 109
19
+ -76 104 -238 -11 -381 -54 -67 -92 -102 -248 -227 -77 -61 -158 -131 -181
20
+ -155 -50 -55 -128 -169 -120 -176 3 -3 33 0 67 6 34 7 100 16 148 19 l87 7
21
+ -69 -79 c-88 -103 -142 -196 -186 -321 -33 -94 -35 -108 -35 -230 -1 -165 23
22
+ -267 99 -420 138 -279 371 -495 708 -655 244 -116 483 -177 722 -186 116 -4
23
+ 137 -2 121 8 -10 7 -57 39 -105 70 -47 31 -102 70 -121 86 l-35 30 160 -6
24
+ c605 -19 1215 178 1665 538 89 72 227 206 219 214 -2 3 -33 -1 -69 -9 -194
25
+ -40 -295 -50 -530 -49 -195 0 -255 4 -350 22 -398 73 -641 226 -704 441 -56
26
+ 190 20 400 217 608 68 71 246 223 262 223 4 0 5 -19 2 -43 -7 -50 3 -187 13
27
+ -187 4 0 44 62 90 138 100 164 159 246 282 387 168 193 181 209 224 276 87
28
+ 133 132 269 141 424 5 93 -2 160 -33 295 -4 20 0 16 21 -15 45 -69 83 -149
29
+ 111 -236 32 -99 35 -96 65 79 24 141 25 341 3 467 -45 261 -171 492 -384 705
30
+ -63 64 -136 131 -162 150 -27 18 -46 35 -44 38 7 7 154 -75 223 -124 153 -109
31
+ 270 -248 354 -418 68 -141 100 -273 108 -451 l6 -140 105 -6 c112 -7 162 -17
32
+ 250 -47 263 -91 456 -295 506 -532 23 -107 14 -345 -15 -454 -82 -297 -270
33
+ -573 -551 -808 -336 -282 -844 -513 -1274 -580 -42 -6 -76 -15 -76 -19 0 -19
34
+ 211 -74 362 -94 932 -123 1887 474 2182 1365 68 206 80 288 80 545 0 212 -2
35
+ 240 -26 356 -99 459 -337 832 -722 1131 -49 38 -170 123 -270 190 -255 172
36
+ -308 211 -271 203 55 -12 129 -36 208 -67 43 -17 80 -28 84 -25 9 10 -63 153
37
+ -118 232 -67 98 -185 209 -288 272 -45 28 -78 53 -74 56 17 11 141 29 238 35
38
+ l100 7 -50 37 c-86 64 -204 130 -340 190 -71 32 -135 58 -141 58 -6 0 -24 -28
39
+ -40 -62 -35 -77 -128 -217 -184 -278 l-40 -45 34 60 c80 141 141 319 183 530
40
+ 25 127 25 501 0 670 -69 465 -238 944 -470 1330 -187 313 -349 454 -469 411z
41
+ m91 -422 c80 -67 234 -356 310 -579 86 -256 129 -488 138 -751 14 -420 -80
42
+ -781 -283 -1087 -64 -96 -66 -100 -56 -136 31 -102 111 -189 316 -343 194
43
+ -146 191 -143 141 -122 -104 43 -606 309 -644 341 -16 12 16 7 92 -17 48 -15
44
+ 87 -24 87 -19 0 11 -119 160 -174 217 -61 65 -169 151 -275 221 -51 33 -90 61
45
+ -87 61 12 0 151 -39 195 -55 24 -8 46 -14 48 -12 2 2 -29 34 -68 72 -130 122
46
+ -334 240 -521 302 -100 32 -98 29 -98 169 0 392 184 908 486 1364 132 200 306
47
+ 400 347 400 9 0 29 -12 46 -26z m-2425 -576 c108 -185 314 -628 291 -628 -2 0
48
+ -32 18 -66 40 -34 22 -64 38 -66 36 -8 -7 62 -149 120 -244 31 -51 57 -95 57
49
+ -97 0 -1 -33 8 -72 20 -40 13 -75 22 -77 19 -6 -6 62 -107 103 -152 21 -23 37
50
+ -44 35 -45 -2 -2 -24 -12 -48 -22 -24 -11 -80 -43 -124 -72 -44 -29 -81 -52
51
+ -81 -50 -58 154 -111 370 -142 577 -34 238 -27 710 11 710 3 0 29 -42 59 -92z
52
+ m528 -2172 c132 -40 244 -122 317 -231 56 -84 92 -176 71 -183 -55 -19 -175
53
+ -90 -222 -131 l-56 -51 -7 39 c-11 64 -61 158 -110 205 -59 58 -122 87 -199
54
+ 93 -133 11 -234 -55 -300 -196 -44 -94 -70 -221 -61 -301 7 -66 32 -157 49
55
+ -185 13 -19 11 -20 -71 -20 l-84 0 6 110 c30 540 154 794 420 862 59 15 178 9
56
+ 247 -11z m-134 -377 c36 -18 74 -46 93 -70 68 -86 90 -219 48 -289 -32 -52
57
+ -88 -118 -120 -140 l-27 -20 25 72 c22 63 25 85 21 173 -3 73 -10 112 -25 146
58
+ -26 57 -88 128 -128 145 l-30 13 41 1 c26 0 63 -11 102 -31z m-224 -78 c49
59
+ -54 15 -163 -53 -169 -49 -5 -71 20 -71 79 0 86 77 142 124 90z m1291 -361
60
+ c50 -6 126 -17 170 -26 86 -17 272 -77 287 -92 6 -6 -23 -10 -74 -11 -119 -2
61
+ -338 -42 -338 -61 0 -4 33 -10 74 -13 207 -18 461 -103 611 -207 78 -54 169
62
+ -146 221 -222 44 -67 113 -215 114 -246 0 -7 -29 3 -77 27 -99 49 -193 78
63
+ -313 96 -99 15 -212 20 -223 9 -4 -4 19 -22 51 -41 69 -41 171 -140 214 -206
64
+ 31 -49 78 -165 78 -193 0 -10 -26 8 -66 44 -75 69 -196 134 -294 157 -116 27
65
+ -118 24 -36 -57 46 -46 86 -97 107 -138 33 -63 34 -68 34 -185 0 -112 -2 -125
66
+ -31 -190 -79 -182 -200 -307 -558 -575 -142 -106 -304 -237 -359 -289 -209
67
+ -201 -328 -391 -399 -636 -19 -67 -23 -103 -23 -225 1 -136 3 -151 32 -239
68
+ l32 -94 -41 39 c-86 84 -159 206 -199 334 -19 62 -24 96 -23 195 0 74 6 144
69
+ 16 183 8 35 12 62 7 60 -5 -2 -29 -30 -54 -63 -46 -62 -95 -168 -95 -207 0
70
+ -16 -3 -19 -11 -11 -21 21 -14 229 10 322 49 187 179 378 356 522 36 29 63 54
71
+ 61 56 -2 2 -86 -6 -186 -17 -100 -12 -184 -20 -186 -17 -8 8 69 71 231 188
72
+ 174 127 300 248 352 339 36 63 63 148 63 197 0 32 4 36 65 64 36 16 86 32 111
73
+ 36 24 3 46 9 49 13 8 12 -138 78 -220 99 -119 31 -205 41 -350 41 -146 0 -233
74
+ -11 -550 -72 -198 -38 -234 -42 -365 -42 -159 1 -254 20 -347 68 l-48 25 86 1
75
+ c285 1 546 111 724 302 105 114 128 178 61 178 -31 0 -41 -10 -71 -69 -77
76
+ -154 -278 -283 -510 -326 -67 -13 -123 -16 -220 -12 -145 5 -230 26 -325 80
77
+ -55 31 -150 112 -150 128 0 4 13 28 30 52 39 58 86 179 95 242 4 34 2 65 -8
78
+ 92 l-14 42 46 10 c94 21 158 23 335 11 313 -21 423 8 776 205 113 63 252 135
79
+ 309 160 319 139 660 198 956 165z m-2567 -537 l57 -28 -87 -6 c-51 -4 -104
80
+ -15 -131 -27 l-45 -20 -26 27 c-24 25 -25 29 -11 41 55 46 162 51 243 13z"/>
81
+ <path d="M5937 8202 c-48 -198 -131 -379 -247 -532 -22 -30 -36 -56 -31 -58
82
+ 16 -5 144 65 189 104 22 19 42 34 45 34 2 0 -2 -35 -10 -77 -32 -169 -114
83
+ -321 -248 -462 -44 -46 -71 -81 -62 -81 28 0 152 42 210 72 67 34 66 37 22
84
+ -75 -39 -98 -86 -167 -181 -265 l-92 -95 65 6 c37 4 99 21 149 40 l85 35 -6
85
+ -32 c-6 -25 -44 -109 -113 -249 -7 -14 65 20 113 53 147 101 249 270 306 507
86
+ 16 69 22 132 26 293 6 236 -6 349 -62 565 -29 115 -112 335 -125 335 -3 0 -18
87
+ -53 -33 -118z"/>
88
+ </g>
89
+ </svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-content-space/loopx",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "Skill-first loopx workflow product for Codex",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,8 +19,12 @@
19
19
  },
20
20
  "files": [
21
21
  "README.md",
22
+ "README.zh-CN.md",
22
23
  "package.json",
23
24
  "scripts/install-skills.mjs",
25
+ "scripts/codex-stop-hook.mjs",
26
+ "scripts/codex-workflow-hook.mjs",
27
+ "assets/logo.svg",
24
28
  "src/",
25
29
  "skills/",
26
30
  "templates/",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopx",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Skill-first loopx workflow product for Codex",
5
5
  "skills": "./skills/",
6
6
  "interface": {
@@ -23,6 +23,7 @@ const LOOPX_SKILLS = [
23
23
  'plan',
24
24
  'build',
25
25
  'review',
26
+ 'archive',
26
27
  'autopilot',
27
28
  ];
28
29
 
@@ -82,6 +83,19 @@ describe('loopx plugin shell', () => {
82
83
  assert.equal(ralplanSkill.includes('$plan --consensus'), false);
83
84
  });
84
85
 
86
+ it('locks clarify handoff to plan instead of direct implementation', async () => {
87
+ const clarifySkill = await readFile(join(ROOT_SKILLS_DIR, 'clarify', 'SKILL.md'), 'utf8');
88
+ const pluginClarifySkill = await readFile(join(PLUGIN_SKILLS_DIR, 'clarify', 'SKILL.md'), 'utf8');
89
+
90
+ assert.equal(pluginClarifySkill, clarifySkill);
91
+ assert.match(clarifySkill, /Recommended invocation: `\$plan <slug>`/);
92
+ assert.doesNotMatch(clarifySkill, /hand off to `build` only/i);
93
+ assert.doesNotMatch(clarifySkill, /direct execution/i);
94
+ assert.doesNotMatch(clarifySkill, /direct implementation/i);
95
+ assert.doesNotMatch(clarifySkill, /directly to implementation/i);
96
+ assert.doesNotMatch(clarifySkill, /Proceed directly to implementation/i);
97
+ });
98
+
85
99
  it('reuses the shared install core while materializing skills from the plugin shell', async () => {
86
100
  const home = await mkdtemp(join(tmpdir(), 'loopx-plugin-home-'));
87
101
  const env = loopxEnv(home);
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: archive
3
+ description: Sync an approved loopx change delta into long-lived specs after review is done.
4
+ argument-hint: "<workflow slug>"
5
+ ---
6
+
7
+ # loopx Archive
8
+
9
+ ## Purpose
10
+
11
+ Use `archive` after a loopx workflow has reached `done`. It syncs the accepted change delta into long-lived `.loopx/specs/` files, archives the change staging directory, and writes an advisory ADR candidate.
12
+
13
+ The accepted delta is requirement-based, not a changelog block. Archive applies:
14
+
15
+ - `## ADDED Requirements`
16
+ - `## MODIFIED Requirements`
17
+ - `## REMOVED Requirements`
18
+ - `## RENAMED Requirements`
19
+
20
+ into the current long-lived `## Requirements` state for each target domain.
21
+
22
+ ## Inputs
23
+
24
+ - `<workflow slug>` for a completed loopx workflow
25
+
26
+ ## Behavior
27
+
28
+ Run:
29
+
30
+ ```bash
31
+ loopx archive <slug>
32
+ ```
33
+
34
+ Then report in Chinese:
35
+
36
+ - whether the change was archived
37
+ - which long-lived spec files were updated
38
+ - the archived change path
39
+ - the ADR candidate path, if written
40
+ - any blocker if the workflow is not done, the spec delta is incomplete, or the execution record still declares partial scope
41
+
42
+ ## Boundaries
43
+
44
+ - Do not run archive before `review -> done` has been approved.
45
+ - Do not archive malformed requirement deltas. ADDED and MODIFIED entries must use `### Requirement:`, SHALL/MUST language, and at least one `#### Scenario:`.
46
+ - Do not archive when `execution-record.md` declares non-empty `remaining_scope`, `completion_claim` other than `full`, or a mismatch between `planned_scope` and `implemented_scope`; route back to build/plan instead.
47
+ - Do not edit implementation code.
48
+ - Do not promote ADR candidates into `docs/adr/` automatically; report the candidate path for human follow-up.
49
+ - Do not treat `loopx status` as a user-facing skill. Use status only as a runtime diagnostic when needed.