@ai-content-space/loopx 0.2.3 → 0.2.7

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 (56) hide show
  1. package/README.md +106 -10
  2. package/README.zh-CN.md +106 -10
  3. package/docs/loopx/design/finish/345/255/246/344/271/240/345/256/241/350/256/241/351/234/200/346/261/202/350/256/276/350/256/241/346/226/207/346/241/243.md +707 -0
  4. package/docs/loopx/memory/2026-06-09-stale-archive-hook-guidance.md +15 -0
  5. package/docs/loopx/memory/README.md +25 -0
  6. package/docs/loopx/plans/2026-06-08-finish-audit-change-window.md +933 -0
  7. package/docs/loopx/plans/2026-06-08-finish-learning-audit.md +410 -0
  8. package/docs/loopx/plans/2026-06-09-cli-onboarding-install-surface.md +1277 -0
  9. package/docs/loopx/specs/installation.md +33 -0
  10. package/package.json +18 -2
  11. package/plugins/loopx/.codex-plugin/plugin.json +1 -1
  12. package/plugins/loopx/skills/clarify/SKILL.md +1 -1
  13. package/plugins/loopx/skills/debug/SKILL.md +1 -1
  14. package/plugins/loopx/skills/doc-readability/SKILL.md +222 -0
  15. package/plugins/loopx/skills/doc-readability/references/prd.md +269 -0
  16. package/plugins/loopx/skills/exec/SKILL.md +11 -1
  17. package/plugins/loopx/skills/final-review/SKILL.md +1 -1
  18. package/plugins/loopx/skills/finish/SKILL.md +39 -7
  19. package/plugins/loopx/skills/fix-review/SKILL.md +1 -1
  20. package/plugins/loopx/skills/go-style/SKILL.md +1 -1
  21. package/plugins/loopx/skills/kratos/SKILL.md +1 -1
  22. package/plugins/loopx/skills/plan/SKILL.md +1 -1
  23. package/plugins/loopx/skills/refactor-plan/SKILL.md +1 -1
  24. package/plugins/loopx/skills/review/SKILL.md +1 -1
  25. package/plugins/loopx/skills/spec/SKILL.md +1 -1
  26. package/plugins/loopx/skills/subagent-exec/SKILL.md +13 -1
  27. package/plugins/loopx/skills/tdd/SKILL.md +1 -1
  28. package/plugins/loopx/skills/verify/SKILL.md +1 -1
  29. package/scripts/claude-workflow-hook.mjs +50 -1
  30. package/scripts/codex-workflow-hook.mjs +33 -12
  31. package/scripts/install-skills.mjs +58 -3
  32. package/scripts/verify-skills.mjs +83 -7
  33. package/skills/RESOLVER.md +3 -1
  34. package/skills/clarify/SKILL.md +1 -1
  35. package/skills/debug/SKILL.md +1 -1
  36. package/skills/doc-readability/SKILL.md +222 -0
  37. package/skills/doc-readability/references/prd.md +269 -0
  38. package/skills/exec/SKILL.md +11 -1
  39. package/skills/final-review/SKILL.md +1 -1
  40. package/skills/finish/SKILL.md +39 -7
  41. package/skills/fix-review/SKILL.md +1 -1
  42. package/skills/go-style/SKILL.md +1 -1
  43. package/skills/kratos/SKILL.md +1 -1
  44. package/skills/plan/SKILL.md +1 -1
  45. package/skills/refactor-plan/SKILL.md +1 -1
  46. package/skills/review/SKILL.md +1 -1
  47. package/skills/spec/SKILL.md +1 -1
  48. package/skills/subagent-exec/SKILL.md +13 -1
  49. package/skills/tdd/SKILL.md +1 -1
  50. package/skills/verify/SKILL.md +1 -1
  51. package/src/cli.mjs +473 -86
  52. package/src/finish-runtime.mjs +1184 -0
  53. package/src/install-discovery.mjs +38 -0
  54. package/src/next-skill.mjs +8 -10
  55. package/src/workflow.mjs +19 -26
  56. package/skills/deepsearch/SKILL.md +0 -38
@@ -3,7 +3,7 @@ name: finish
3
3
  description: "Finishes completed loopx development work after tests pass by presenting merge, PR, keep, or discard options. Not for unfinished work or failing verification."
4
4
  when_to_use: "implementation complete, tests pass, finish branch, create pull request, merge locally, keep branch, discard work"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Finish
@@ -66,18 +66,33 @@ git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
66
66
 
67
67
  Or ask: "This branch split from main - is that correct?"
68
68
 
69
- ### Step 4: Learning Extraction
69
+ ### Step 4: Audit-First Learning Extraction
70
70
 
71
- Run learning extraction before presenting merge, PR, keep, or discard options.
71
+ Run `finish-audit` before presenting merge, PR, keep, or discard options.
72
+
73
+ `loopx:exec` and `loopx:subagent-exec` should have run `finish-start` before implementation. `finish-audit` uses that baseline to preserve committed `baseline..HEAD` evidence after the working tree is clean. It may also generate `audit.extraction_candidates` as draft memory/spec review prompts. These drafts are not automatically written to memory or specs.
72
74
 
73
75
  Allowed inputs:
74
- - current git diff
76
+ - `finish-state.json` `audit.change_window`, especially `baseline..HEAD` commits and changed files
77
+ - `finish-state.json` `audit.extraction_candidates`
78
+ - current uncommitted git diff and `git status --short`
75
79
  - executed verification output
76
80
  - plan, spec, and review artifacts used in this task
77
81
  - explicit user decisions in the current conversation
78
82
  - existing `.loopx/memory/MEMORY.md` and `.loopx/memory/index.jsonl`
83
+ - existing `docs/loopx/memory/*.md`
79
84
  - existing `docs/loopx/specs/*.md`
80
85
 
86
+ An empty git diff does not mean there is no learning candidate. When `audit.change_window.commit_count > 0`, inspect the committed range before deciding memory/spec candidates. "Already committed" is not a rejection reason; reject only when the committed change window contains no durable behavior, contract, invariant, pitfall, or user decision worth preserving.
87
+
88
+ Read the audit state from `.loopx/finish/<audit-id>/finish-state.json` before deciding what to record.
89
+ After learning extraction, update `finish-state.json` before any `done` record:
90
+ - set `status` to `"audited"`
91
+ - for every `audit.extraction_candidates[]` item, add either a matching `accepted_candidates` with evidence or a matching `rejected_candidates[]` item with `rejection_reason`
92
+ - when no extraction candidates exist and no candidate is accepted, replace `no_candidates_reason` with a specific reason
93
+
94
+ `finish-record --status done` will reject an audit while generated extraction candidates remain unreviewed.
95
+
81
96
  Learning extraction priority:
82
97
  1. Durable behavior, contracts, or constraints proven by the implementation
83
98
  2. State, file, CLI, API, install, migration, compatibility, or test invariants
@@ -87,11 +102,19 @@ Learning extraction priority:
87
102
 
88
103
  Do not infer durable rules from agent intuition alone. Do not promote unverified implementation details.
89
104
 
105
+ When the audit has no candidates, record `none` with the scanned inputs and a reason in `no_candidates_reason`.
106
+ Keep rejected candidates explicit when draft candidates are not accepted.
107
+ Accepted candidates require evidence from the audit state. Rejected candidates require reasons.
108
+ choice recording must persist the user's completion choice through `finish-record` before presenting the final completion outcome.
109
+
90
110
  #### Memory
91
111
 
92
- Memory is local, agent-queryable project context. It is not repo-tracked by default.
112
+ Memory has two scopes:
113
+
114
+ - local memory: agent-queryable project context for one machine; not repo-tracked
115
+ - shared memory: lightweight project knowledge that should follow a user across machines; repo-tracked
93
116
 
94
- Use:
117
+ Use local memory for machine-local facts, short-lived handoffs, and context that is useful only to the current agent environment:
95
118
 
96
119
  ```text
97
120
  .loopx/memory/MEMORY.md
@@ -104,7 +127,13 @@ Use:
104
127
 
105
128
  `index.jsonl` is a curated active index, not an append-only history. It should point only to active memory cards worth querying.
106
129
 
107
- Use memory only for facts that will help a future agent avoid rework, avoid mistakes, or preserve a decision. Do not record process negatives such as "no spec promotion".
130
+ Use shared memory for concise, evidence-backed notes that are useful across machines but not stable enough for specs:
131
+
132
+ ```text
133
+ docs/loopx/memory/
134
+ ```
135
+
136
+ Use memory only for facts that will help a future agent avoid rework, avoid mistakes, or preserve a decision. Do not record process negatives such as "no spec promotion". Do not store secrets, raw conversation logs, or machine-local paths in shared memory.
108
137
 
109
138
  One finish run may write 0-3 active memory cards. If more learnings appear, consolidate, promote to spec, archive stale cards, or skip low-signal items.
110
139
 
@@ -123,6 +152,8 @@ Allowed memory `type` values:
123
152
 
124
153
  Finish may automatically update `.loopx/memory/MEMORY.md`, `.loopx/memory/index.jsonl`, and active memory cards. The final response must list the memory changes.
125
154
 
155
+ When accepting an `audit.extraction_candidates[]` item with `kind: "memory"` and `scope: "shared"`, write the accepted note under `docs/loopx/memory/` so it is visible in the git diff. Promote shared memory to `docs/loopx/specs/` when it becomes a durable rule that planning or review should depend on.
156
+
126
157
  #### Spec Candidates
127
158
 
128
159
  Spec extraction is conditional. Run the audit every time, but write spec candidates only when the task produced stable, shared, reusable project rules.
@@ -295,6 +326,7 @@ Use this shape:
295
326
  ```text
296
327
  Memory:
297
328
  - updated: .loopx/memory/MEMORY.md
329
+ - shared: docs/loopx/memory/<file>.md
298
330
  - entries: <N> added, <N> archived
299
331
  - summary:
300
332
  - <high-signal memory change>
@@ -3,7 +3,7 @@ name: fix-review
3
3
  description: "Handles received code review feedback with verification, technical evaluation, pushback, and one-item-at-a-time fixes. Not for requesting a new review or implementing unrelated changes."
4
4
  when_to_use: "fix-review, received code review feedback, review comments, reviewer suggestions, requested changes, 处理评审意见"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Fix Review
@@ -3,7 +3,7 @@ name: go-style
3
3
  description: "Applies loopx Go coding style for .go edits, tests, errors, context, naming, and interface boundaries. Not for non-Go code or Kratos-specific architecture by itself."
4
4
  when_to_use: "go-style, Go, golang, .go files, go tests, gofmt, idiomatic Go, Go style, Go 代码"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Go Style
@@ -3,7 +3,7 @@ name: kratos
3
3
  description: "Supports Go-Kratos microservices, proto/buf APIs, service/biz/data layers, middleware, auth, config, and troubleshooting. Not for generic Go style alone."
4
4
  when_to_use: "kratos, Go-Kratos, proto, buf, service layer, biz layer, data layer, middleware, auth, config, Kratos 微服务"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Kratos
@@ -3,7 +3,7 @@ name: plan
3
3
  description: "Creates bite-sized implementation plans from approved requirements, clarify output, or design specs with exact files, tests, commands, expected output, and execution handoff. Not for unresolved requirements, design decisions, PRD generation, or code changes."
4
4
  when_to_use: "plan, implementation plan, execution plan, task breakdown, approved requirements, approved design spec, docs/loopx/design, 实施计划, 执行计划, 任务拆分"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  argument-hint: "<design spec path or feature name>"
8
8
  ---
9
9
 
@@ -3,7 +3,7 @@ name: refactor-plan
3
3
  description: "Creates a behavior-preserving refactor plan with user interview, repo evidence, tiny commits, scope boundaries, and testing decisions. Not for feature changes or immediate implementation."
4
4
  when_to_use: "refactor-plan, refactor request, refactoring RFC, tiny commits, behavior-preserving cleanup, architecture cleanup, 重构计划"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  This skill will be invoked when the user wants to create a refactor request. You should go through the steps below. You may skip steps if you don't consider them necessary.
@@ -3,7 +3,7 @@ name: review
3
3
  description: "Dispatches a loopx code reviewer subagent against a concrete git range and requirements. Not for implementation, planning, or unresolved review scope."
4
4
  when_to_use: "request code review, completed task review, major feature review, pre-merge review, subagent code quality check"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Review
@@ -3,7 +3,7 @@ name: spec
3
3
  description: "Writes software design specs from already-clarified requirements, including solution approach, architecture outline, detailed design, tradeoffs, verification design, and handoff context. Not for unresolved requirements, PRD generation, implementation task planning, or code changes."
4
4
  when_to_use: "spec, design spec, technical design, design proposal, detailed design, architecture design, 设计方案, 概要设计, 详细设计, 技术方案"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # loopx Spec
@@ -3,7 +3,7 @@ name: subagent-exec
3
3
  description: "Executes approved loopx implementation plans with fresh subagents per independent task and staged review. Not for planning, unclear requirements, or tightly coupled edits."
4
4
  when_to_use: "approved implementation plan, independent tasks, subagent execution, staged spec review, code quality review, parallel-capable execution"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Subagent Exec
@@ -63,11 +63,13 @@ digraph process {
63
63
  "Mark task complete in update_plan" [shape=box];
64
64
  }
65
65
 
66
+ "Record finish baseline with loopx finish-start <slug> --source <plan-path>" [shape=box];
66
67
  "Read plan, extract all tasks with full text, note context, create update_plan" [shape=box];
67
68
  "More tasks remain?" [shape=diamond];
68
69
  "Use loopx:final-review for entire implementation" [shape=box];
69
70
  "Use loopx:finish" [shape=box style=filled fillcolor=lightgreen];
70
71
 
72
+ "Record finish baseline with loopx finish-start <slug> --source <plan-path>" -> "Read plan, extract all tasks with full text, note context, create update_plan";
71
73
  "Read plan, extract all tasks with full text, note context, create update_plan" -> "Dispatch implementer subagent (./implementer-prompt.md)";
72
74
  "Dispatch implementer subagent (./implementer-prompt.md)" -> "Implementer subagent asks questions?";
73
75
  "Implementer subagent asks questions?" -> "Answer questions, provide context" [label="yes"];
@@ -89,6 +91,16 @@ digraph process {
89
91
  }
90
92
  ```
91
93
 
94
+ ### Step 0: Record Finish Baseline
95
+
96
+ Before dispatching the first implementer, run:
97
+
98
+ ```bash
99
+ loopx finish-start <slug> --source <plan-path>
100
+ ```
101
+
102
+ Use the plan filename slug when no workflow slug is available. This preserves the starting `HEAD` so `finish-audit` can inspect `baseline..HEAD` even after implementers commit their work and the current `git diff` is empty.
103
+
92
104
  ## Model Selection
93
105
 
94
106
  Use the least powerful model that can handle each role to conserve cost and increase speed.
@@ -3,7 +3,7 @@ name: tdd
3
3
  description: "Guides feature and bugfix implementation through a failing test before production code and red-green-refactor discipline. Not for generated files or throwaway prototypes."
4
4
  when_to_use: "tdd, failing test first, feature implementation, bugfix, regression test, red green refactor, 测试先行"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Test-Driven Development (TDD)
@@ -3,7 +3,7 @@ name: verify
3
3
  description: "Requires fresh verification evidence before claiming work is complete, fixed, passing, review-ready, or ready to commit. Not for speculative confidence or stale results."
4
4
  when_to_use: "verify, completion claim, fixed claim, tests pass, review-ready, commit, fresh evidence, 验证, 完成前检查"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Verification Before Completion
@@ -52,10 +52,59 @@ function findNearestLoopxRuntimeRoot(startCwd) {
52
52
  }
53
53
  }
54
54
 
55
+ function archiveNextActionReplacement(state) {
56
+ const approvedReviewAction = approvedReviewNextAction(state);
57
+ if (approvedReviewAction) {
58
+ return approvedReviewAction;
59
+ }
60
+ if (state.current_stage === 'done' || state.current_stage === 'archive' || state.completion_confirmed === true) {
61
+ return '$finish';
62
+ }
63
+ return null;
64
+ }
65
+
66
+ function approvedReviewNextAction(state) {
67
+ if (state.current_stage === 'review' && state.review_verdict === 'approve' && state.slug) {
68
+ return `loopx approve ${state.slug} --from review --to done`;
69
+ }
70
+ return null;
71
+ }
72
+
73
+ function persistedNextAction(state) {
74
+ const action = typeof state?.recommended_next_action === 'string'
75
+ ? state.recommended_next_action.trim()
76
+ : '';
77
+ if (!action) {
78
+ return null;
79
+ }
80
+ if (/\bloopx\s+archive\b|\$archive\b/i.test(action)) {
81
+ return archiveNextActionReplacement(state);
82
+ }
83
+ return action;
84
+ }
85
+
86
+ function staleArchiveNextAction(state) {
87
+ const action = typeof state?.recommended_next_action === 'string'
88
+ ? state.recommended_next_action.trim()
89
+ : '';
90
+ if (!action || !/\bloopx\s+archive\b|\$archive\b/i.test(action)) {
91
+ return null;
92
+ }
93
+ return archiveNextActionReplacement(state);
94
+ }
95
+
55
96
  function nextSkill(state) {
56
97
  if (!state?.slug) {
57
98
  return null;
58
99
  }
100
+ const staleArchiveAction = staleArchiveNextAction(state);
101
+ if (staleArchiveAction) {
102
+ return staleArchiveAction;
103
+ }
104
+ const approvedReviewAction = approvedReviewNextAction(state);
105
+ if (approvedReviewAction) {
106
+ return approvedReviewAction;
107
+ }
59
108
  if (state.current_stage === 'clarify') {
60
109
  return 'Use loopx:clarify until material questions are resolved, then route to loopx:spec or loopx:plan.';
61
110
  }
@@ -68,7 +117,7 @@ function nextSkill(state) {
68
117
  if (state.current_stage === 'review') {
69
118
  return 'Legacy runtime review detected. New v1 code review should use loopx:review.';
70
119
  }
71
- return state.recommended_next_action || null;
120
+ return persistedNextAction(state);
72
121
  }
73
122
 
74
123
  try {
@@ -35,16 +35,8 @@ function nextSkill(state) {
35
35
  return `$plan ${state.slug}`;
36
36
  }
37
37
  if (state.current_stage === 'done'
38
- && state.completion_confirmed === true
39
- && state.archive_status !== 'archived') {
40
- return `$archive ${state.slug}`;
41
- }
42
- if (state.current_stage === 'review'
43
- && state.review_verdict === 'approve'
44
- && state.pending_user_decision === 'review->done'
45
- && ['requested', 'approved'].includes(state.approval?.complete)
46
- && state.archive_status !== 'archived') {
47
- return `$archive ${state.slug}`;
38
+ && state.completion_confirmed === true) {
39
+ return '$finish';
48
40
  }
49
41
  if (state.stage_status === 'awaiting-approval'
50
42
  && state.current_stage === 'plan'
@@ -103,6 +95,12 @@ function nextCli(state) {
103
95
  && state.plan_blockers.length === 0) {
104
96
  return `loopx build .loopx/plans/requirements-snapshot-${state.slug}.md`;
105
97
  }
98
+ if (state.current_stage === 'review'
99
+ && state.review_verdict === 'approve'
100
+ && state.pending_user_decision === 'review->done'
101
+ && ['requested', 'approved'].includes(state.approval?.complete)) {
102
+ return `loopx approve ${state.slug} --from review --to done`;
103
+ }
106
104
  if (state.current_stage === 'review'
107
105
  && state.review_verdict === 'request-changes'
108
106
  && state.rollback_target === 'build'
@@ -123,6 +121,29 @@ function nextCli(state) {
123
121
  return null;
124
122
  }
125
123
 
124
+ function archiveNextActionReplacement(state) {
125
+ if (state.current_stage === 'review' && state.review_verdict === 'approve' && state.slug) {
126
+ return `loopx approve ${state.slug} --from review --to done`;
127
+ }
128
+ if (state.current_stage === 'done' || state.current_stage === 'archive' || state.completion_confirmed === true) {
129
+ return '$finish';
130
+ }
131
+ return null;
132
+ }
133
+
134
+ function persistedNextAction(state) {
135
+ const action = typeof state?.recommended_next_action === 'string'
136
+ ? state.recommended_next_action.trim()
137
+ : '';
138
+ if (!action) {
139
+ return null;
140
+ }
141
+ if (/\bloopx\s+archive\b|\$archive\b/i.test(action)) {
142
+ return archiveNextActionReplacement(state);
143
+ }
144
+ return action;
145
+ }
146
+
126
147
  function blockers(state) {
127
148
  const values = [
128
149
  ...(Array.isArray(state.plan_blockers) ? state.plan_blockers : []),
@@ -161,9 +182,9 @@ function nextActionLine(state, workflow) {
161
182
  return `loopx migrate, then $plan ${state.slug || workflow}`;
162
183
  }
163
184
  if (isClarifyReadyForPlan(state) && state.approval?.plan !== 'approved') {
164
- return `approve clarify -> plan, then $plan ${state.slug || workflow}`;
185
+ return `finish clarification, then $plan ${state.slug || workflow}`;
165
186
  }
166
- return nextSkill(state) || nextCli(state) || state.recommended_next_action || 'none';
187
+ return nextSkill(state) || nextCli(state) || persistedNextAction(state) || 'none';
167
188
  }
168
189
 
169
190
  function implementationGateLines(state) {
@@ -2,17 +2,72 @@
2
2
 
3
3
  import { installSkillsForTargets, verifyInstallTargets } from '../src/install-discovery.mjs';
4
4
 
5
+ function shouldSkipPostinstall(env = process.env) {
6
+ return env.LOOPX_SKIP_POSTINSTALL === '1' || env.LOOPX_POSTINSTALL === '0';
7
+ }
8
+
9
+ function skipPostinstallEnv(env = process.env) {
10
+ if (env.LOOPX_SKIP_POSTINSTALL === '1') {
11
+ return 'LOOPX_SKIP_POSTINSTALL';
12
+ }
13
+ if (env.LOOPX_POSTINSTALL === '0') {
14
+ return 'LOOPX_POSTINSTALL';
15
+ }
16
+ return null;
17
+ }
18
+
19
+ function targetNames(result) {
20
+ return Array.isArray(result.targets) && result.targets.length > 0 ? result.targets : Object.keys(result.results || {});
21
+ }
22
+
23
+ function count(result, key) {
24
+ return Object.values(result.results || {})
25
+ .reduce((sum, target) => sum + (Array.isArray(target?.[key]) ? target[key].length : 0), 0);
26
+ }
27
+
28
+ function printSummary(result, { checkOnly = false } = {}) {
29
+ console.log(`loopx ${checkOnly ? 'install check' : 'postinstall'}: ${result.ok === false ? 'attention needed' : 'ok'}`);
30
+ console.log(`targets: ${targetNames(result).join(', ')}`);
31
+ if (!checkOnly) {
32
+ console.log(`installed skills: ${count(result, 'installed')}`);
33
+ }
34
+ console.log(`conflicts: ${count(result, 'conflicts')}`);
35
+ console.log(`skipped user-modified: ${count(result, 'skipped')}`);
36
+ console.log('repair: loopx repair-install');
37
+ console.log('opt out: LOOPX_SKIP_POSTINSTALL=1');
38
+ console.log('disable hooks for one process: LOOPX_HOOKS=0');
39
+ console.log('details: node scripts/install-skills.mjs --json');
40
+ }
41
+
5
42
  async function main() {
43
+ const json = process.argv.includes('--json');
44
+ if (shouldSkipPostinstall()) {
45
+ if (json) {
46
+ console.log(JSON.stringify({
47
+ ok: true,
48
+ skipped: true,
49
+ reason: 'postinstall_disabled',
50
+ env: skipPostinstallEnv(),
51
+ }, null, 2));
52
+ } else {
53
+ console.log('loopx postinstall skipped: LOOPX_SKIP_POSTINSTALL=1 or LOOPX_POSTINSTALL=0');
54
+ }
55
+ return;
56
+ }
57
+
6
58
  const checkOnly = process.argv.includes('--check');
7
59
  const result = checkOnly ? await verifyInstallTargets(process.env) : await installSkillsForTargets(process.env);
8
60
  const ok = checkOnly ? result.ok : result.ok !== false;
9
61
  const payload = checkOnly ? result : { ok, targets: result.targets, results: result.results };
62
+ if (json) {
63
+ const stream = ok ? process.stdout : process.stderr;
64
+ stream.write(`${JSON.stringify(payload, null, 2)}\n`);
65
+ } else {
66
+ printSummary(payload, { checkOnly });
67
+ }
10
68
  if (!ok) {
11
- console.error(JSON.stringify(payload, null, 2));
12
69
  process.exitCode = 1;
13
- return;
14
70
  }
15
- console.log(JSON.stringify(payload, null, 2));
16
71
  }
17
72
 
18
73
  await main();
@@ -103,6 +103,16 @@ function assertContains(text, value, label) {
103
103
  assert.match(text, new RegExp(value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), `${label} missing ${value}`);
104
104
  }
105
105
 
106
+ function publicArchiveCommandLines(text) {
107
+ return text
108
+ .split('\n')
109
+ .filter((line) => /^\s*(?:(?:[-*+]|\d+[.)])\s+)?`?loopx archive(?:\s|`|$)/.test(line));
110
+ }
111
+
112
+ function assertNoPublicArchiveCommandExposure(text, label) {
113
+ assert.deepEqual(publicArchiveCommandLines(text), [], `${label} should not expose archive runtime command`);
114
+ }
115
+
106
116
  async function assertPublicDocsAligned() {
107
117
  const readme = await readFile(join(repoRoot, 'README.md'), 'utf8');
108
118
  const readmeZh = await readFile(join(repoRoot, 'README.zh-CN.md'), 'utf8');
@@ -110,13 +120,10 @@ async function assertPublicDocsAligned() {
110
120
  'loopx install-skills',
111
121
  'loopx init',
112
122
  'loopx clarify',
113
- 'loopx approve',
114
- 'loopx plan',
115
- 'loopx build',
116
- 'loopx review',
117
- 'loopx autopilot',
118
123
  'loopx render',
119
124
  'loopx status',
125
+ 'loopx next',
126
+ 'loopx help advanced',
120
127
  'loopx setup-context',
121
128
  'loopx doctor',
122
129
  'loopx migrate',
@@ -127,8 +134,67 @@ async function assertPublicDocsAligned() {
127
134
  assertContains(readme, command, 'README.md');
128
135
  assertContains(readmeZh, command, 'README.zh-CN.md');
129
136
  }
130
- assert.doesNotMatch(readme, /loopx archive/, 'README.md should not expose archive runtime command');
131
- assert.doesNotMatch(readmeZh, /loopx archive/, 'README.zh-CN.md should not expose archive runtime command');
137
+ assert.deepEqual(
138
+ publicArchiveCommandLines([
139
+ 'loopx archive <slug>',
140
+ '- loopx archive <slug>',
141
+ '- `loopx archive <slug>`',
142
+ '1. loopx archive <slug>',
143
+ 'archive is not part of the public v1 finish flow. Older runtime state may still contain archive fields or a hidden `loopx archive <slug>` compatibility command.',
144
+ ].join('\n')),
145
+ [
146
+ 'loopx archive <slug>',
147
+ '- loopx archive <slug>',
148
+ '- `loopx archive <slug>`',
149
+ '1. loopx archive <slug>',
150
+ ],
151
+ 'archive command exposure guard should catch public command lines without rejecting prose compatibility notes',
152
+ );
153
+ assertNoPublicArchiveCommandExposure(readme, 'README.md');
154
+ assertNoPublicArchiveCommandExposure(readmeZh, 'README.zh-CN.md');
155
+ assertContains(readme, 'local audit ledger', 'README.md');
156
+ assertContains(readme, '.loopx/finish/<audit-id>/', 'README.md');
157
+ assert.match(readme, /`none` means|none means/i, 'README.md missing none means');
158
+ assertContains(readme, 'docs/loopx/specs/', 'README.md');
159
+ assertContains(readme, 'Advanced runtime commands', 'README.md');
160
+ assertContains(readme, 'loopx help advanced', 'README.md');
161
+ assertContains(readme, 'Undo installed files', 'README.md');
162
+ assertContains(readme, 'Golden path', 'README.md');
163
+
164
+ assertContains(readmeZh, '本地 audit ledger', 'README.zh-CN.md');
165
+ assertContains(readmeZh, '.loopx/finish/<audit-id>/', 'README.zh-CN.md');
166
+ assertContains(readmeZh, '`none` 表示', 'README.zh-CN.md');
167
+ assertContains(readmeZh, 'docs/loopx/specs/', 'README.zh-CN.md');
168
+ assertContains(readmeZh, '高级 runtime 命令', 'README.zh-CN.md');
169
+ assertContains(readmeZh, 'loopx help advanced', 'README.zh-CN.md');
170
+ assertContains(readmeZh, '撤销已安装文件', 'README.zh-CN.md');
171
+ assertContains(readmeZh, '黄金路径', 'README.zh-CN.md');
172
+ for (const required of [
173
+ 'Quick start',
174
+ 'Human output is the default',
175
+ 'loopx install-skills --target all --dry-run',
176
+ 'LOOPX_SKIP_POSTINSTALL=1',
177
+ 'LOOPX_POSTINSTALL=0',
178
+ 'LOOPX_HOOKS=0',
179
+ 'Archive compatibility',
180
+ ]) {
181
+ assertContains(readme, required, 'README.md');
182
+ }
183
+ for (const required of [
184
+ '快速开始',
185
+ '默认输出面向人类',
186
+ 'loopx install-skills --target all --dry-run',
187
+ 'LOOPX_SKIP_POSTINSTALL=1',
188
+ 'LOOPX_POSTINSTALL=0',
189
+ 'LOOPX_HOOKS=0',
190
+ 'Archive 兼容性',
191
+ ]) {
192
+ assertContains(readmeZh, required, 'README.zh-CN.md');
193
+ }
194
+ assert.doesNotMatch(readme, /`loopx install-skills --dry-run`/, 'README.md should use explicit dry-run target');
195
+ assert.doesNotMatch(readmeZh, /`loopx install-skills --dry-run`/, 'README.zh-CN.md should use explicit dry-run target');
196
+ assert.doesNotMatch(readme, /Public finish audit commands:/, 'README.md should not promote finish runtime commands as public primary flow');
197
+ assert.doesNotMatch(readmeZh, /公开的 finish audit 命令:/, 'README.zh-CN.md should not promote finish runtime commands as public primary flow');
132
198
 
133
199
  const releaseNotesRoot = join(repoRoot, 'docs', 'release-notes');
134
200
  const releaseNotes = existsSync(releaseNotesRoot)
@@ -179,6 +245,16 @@ async function assertSkill(skillName, resolverText) {
179
245
  assert.equal(pluginManifest.version, packageJson.version, 'plugin manifest version must match package.json');
180
246
  assert.equal(existsSync(resolverPath), true, 'skills/RESOLVER.md missing');
181
247
  assert.equal(packageJson.files.includes('scripts/claude-workflow-hook.mjs'), true, 'npm package must include claude-workflow-hook.mjs');
248
+ assert.equal(packageJson.files.includes('skills/'), false, 'npm package must not include broad skills/ surface');
249
+ assert.equal(packageJson.files.includes('skills/RESOLVER.md'), true, 'npm package must include skills/RESOLVER.md');
250
+ for (const skillName of LOOPX_BUNDLED_SKILLS) {
251
+ assert.equal(packageJson.files.includes(`skills/${skillName}/`), true, `npm package missing bundled skill ${skillName}`);
252
+ }
253
+ assert.deepEqual(
254
+ packageJson.files.filter((path) => path.startsWith('skills/')).sort(),
255
+ ['skills/RESOLVER.md', ...LOOPX_BUNDLED_SKILLS.map((skillName) => `skills/${skillName}/`)].sort(),
256
+ 'npm package skills/ surface must exactly match bundled skills plus resolver',
257
+ );
182
258
 
183
259
  for (const relativePath of markdownPaths) {
184
260
  await assertMarkdownStructure(relativePath);
@@ -26,6 +26,7 @@ Read the selected skill file before acting. If multiple skills match, read every
26
26
  | Feature or bugfix implementation should be covered by a failing test first | `skills/tdd/SKILL.md` |
27
27
  | Bug, test failure, build failure, regression, unexpected behavior, root-cause investigation | `skills/debug/SKILL.md` |
28
28
  | Completion, fixed, passing, review-ready, commit, or handoff claims need fresh evidence | `skills/verify/SKILL.md` |
29
+ | Document readability, PRD assessment, requirements gaps, unclear viewpoint, AI-like prose, or document rewriting | `skills/doc-readability/SKILL.md` |
29
30
  | Editing `.go` files or reviewing Go style | `skills/go-style/SKILL.md` |
30
31
  | Go-Kratos proto, service, biz, data, middleware, auth, config, or troubleshooting | `skills/kratos/SKILL.md` |
31
32
 
@@ -42,7 +43,8 @@ Read the selected skill file before acting. If multiple skills match, read every
42
43
  9. Use `fix-review` only after feedback exists.
43
44
  10. Use `finish` only after implementation, final review, and verification are complete.
44
45
  11. Use `refactor-plan` for behavior-preserving refactor planning. If the refactor changes external behavior or contracts, route to `clarify` or `spec`.
45
- 12. Treat `tdd`, `debug`, `verify`, `go-style`, and `kratos` as support lenses unless the user explicitly invokes them directly.
46
+ 12. Use `doc-readability` for document assessment or rewriting, especially PRDs, requirements docs, specs, meeting notes, and AI-like prose. If the document is a source artifact for implementation, assess or rewrite it first, then route clarified implementation work back through `clarify`, `spec`, or `plan`.
47
+ 13. Treat `tdd`, `debug`, `verify`, `doc-readability`, `go-style`, and `kratos` as support lenses unless the user explicitly invokes them directly.
46
48
 
47
49
  ## Deterministic Guard
48
50
 
@@ -3,7 +3,7 @@ name: clarify
3
3
  description: "Grills ambiguous loopx work until material questions are answered, then routes to spec or plan using a design gate. Not for clear implementation tasks, approved specs, or code changes."
4
4
  when_to_use: "clarify, requirements, ambiguous request, unclear scope, non-goals, decision boundaries, acceptance criteria, 需求澄清, 范围不清"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # loopx Clarify
@@ -3,7 +3,7 @@ name: debug
3
3
  description: "Finds root cause for bugs, failing tests, build failures, regressions, and unexpected behavior before fixes. Not for new feature planning or routine code review."
4
4
  when_to_use: "debug, bug, test failure, build failure, regression, unexpected behavior, root cause, 报错, 失败, 回归, 排查"
5
5
  metadata:
6
- version: "0.2.3"
6
+ version: "0.2.7"
7
7
  ---
8
8
 
9
9
  # Systematic Debugging