@ai-content-space/loopx 0.1.2 → 0.1.3

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 (67) hide show
  1. package/README.md +343 -56
  2. package/README.zh-CN.md +392 -0
  3. package/package.json +4 -1
  4. package/plugins/loopx/.codex-plugin/plugin.json +1 -1
  5. package/plugins/loopx/scripts/plugin-install.test.mjs +1 -0
  6. package/plugins/loopx/skills/archive/SKILL.md +39 -0
  7. package/plugins/loopx/skills/build/SKILL.md +111 -9
  8. package/plugins/loopx/skills/clarify/SKILL.md +121 -1
  9. package/plugins/loopx/skills/debug/SKILL.md +296 -0
  10. package/plugins/loopx/skills/debug/condition-based-waiting.md +115 -0
  11. package/plugins/loopx/skills/debug/defense-in-depth.md +122 -0
  12. package/plugins/loopx/skills/debug/find-polluter.sh +63 -0
  13. package/plugins/loopx/skills/debug/root-cause-tracing.md +169 -0
  14. package/plugins/loopx/skills/go-style/SKILL.md +71 -0
  15. package/plugins/loopx/skills/kratos/SKILL.md +74 -0
  16. package/plugins/loopx/skills/kratos/references/advanced-features.md +314 -0
  17. package/plugins/loopx/skills/kratos/references/architecture.md +488 -0
  18. package/plugins/loopx/skills/kratos/references/configuration.md +399 -0
  19. package/plugins/loopx/skills/kratos/references/http-customization.md +512 -0
  20. package/plugins/loopx/skills/kratos/references/middleware-logging.md +400 -0
  21. package/plugins/loopx/skills/kratos/references/proto-api-design.md +432 -0
  22. package/plugins/loopx/skills/kratos/references/security-auth.md +411 -0
  23. package/plugins/loopx/skills/kratos/references/troubleshooting.md +385 -0
  24. package/plugins/loopx/skills/plan/SKILL.md +22 -2
  25. package/plugins/loopx/skills/review/SKILL.md +98 -1
  26. package/plugins/loopx/skills/tdd/SKILL.md +371 -0
  27. package/plugins/loopx/skills/tdd/testing-anti-patterns.md +299 -0
  28. package/plugins/loopx/skills/verify/SKILL.md +139 -0
  29. package/scripts/codex-stop-hook.mjs +71 -0
  30. package/scripts/codex-workflow-hook.mjs +153 -0
  31. package/skills/archive/SKILL.md +39 -0
  32. package/skills/build/SKILL.md +111 -9
  33. package/skills/clarify/SKILL.md +121 -1
  34. package/skills/debug/SKILL.md +296 -0
  35. package/skills/debug/condition-based-waiting.md +115 -0
  36. package/skills/debug/defense-in-depth.md +122 -0
  37. package/skills/debug/find-polluter.sh +63 -0
  38. package/skills/debug/root-cause-tracing.md +169 -0
  39. package/skills/go-style/SKILL.md +71 -0
  40. package/skills/kratos/SKILL.md +74 -0
  41. package/skills/kratos/references/advanced-features.md +314 -0
  42. package/skills/kratos/references/architecture.md +488 -0
  43. package/skills/kratos/references/configuration.md +399 -0
  44. package/skills/kratos/references/http-customization.md +512 -0
  45. package/skills/kratos/references/middleware-logging.md +400 -0
  46. package/skills/kratos/references/proto-api-design.md +432 -0
  47. package/skills/kratos/references/security-auth.md +411 -0
  48. package/skills/kratos/references/troubleshooting.md +385 -0
  49. package/skills/plan/SKILL.md +18 -2
  50. package/skills/review/SKILL.md +98 -1
  51. package/skills/tdd/SKILL.md +371 -0
  52. package/skills/tdd/testing-anti-patterns.md +299 -0
  53. package/skills/verify/SKILL.md +139 -0
  54. package/src/build-runtime.mjs +303 -26
  55. package/src/build-stop-gate.mjs +94 -0
  56. package/src/cli.mjs +47 -5
  57. package/src/codex-exec-runtime.mjs +105 -5
  58. package/src/context-manifest.mjs +172 -0
  59. package/src/install-discovery.mjs +352 -5
  60. package/src/next-skill.mjs +57 -5
  61. package/src/plan-runtime.mjs +79 -122
  62. package/src/review-runtime.mjs +378 -0
  63. package/src/runtime-maintenance.mjs +428 -14
  64. package/src/template-governance.mjs +223 -0
  65. package/src/workflow.mjs +1941 -117
  66. package/src/workspace-context.mjs +166 -0
  67. package/src/workspace-memory.mjs +69 -0
@@ -33,36 +33,32 @@ function paragraphFromSection(section, fallback) {
33
33
 
34
34
  function buildSourceSummary(sourceText) {
35
35
  return {
36
- intent: paragraphFromSection(extractSection(sourceText, 'Intent'), 'Translate the approved requirements into a build-ready plan package.'),
37
- outcome: paragraphFromSection(extractSection(sourceText, 'Desired Outcome'), 'Produce an approved plan package and stop before execution.'),
36
+ intent: paragraphFromSection(extractSection(sourceText, 'Intent'), '将已批准的需求整理成可进入 build 的计划包。'),
37
+ outcome: paragraphFromSection(extractSection(sourceText, 'Desired Outcome'), '产出已批准的计划工件,并在执行前停止。'),
38
38
  inScope: bulletsFromSection(extractSection(sourceText, 'In Scope'), [
39
- 'Create the approved planning artifacts.',
40
- 'Keep runtime state machine-checkable.',
41
- 'Preserve explicit execution approval boundaries.',
39
+ '生成已批准的规划工件。',
40
+ '保持 runtime 状态机可检查。',
41
+ '保留显式的执行审批边界。',
42
42
  ]),
43
43
  nonGoals: bulletsFromSection(extractSection(sourceText, 'Out of Scope / Non-goals'), [
44
- 'Do not launch execution from plan.',
45
- 'Do not widen the task beyond approved planning scope.',
44
+ '不要从 plan 直接启动执行。',
45
+ '不要把任务扩展到已批准范围之外。',
46
46
  ]),
47
47
  acceptance: bulletsFromSection(extractSection(sourceText, 'Testable Acceptance Criteria'), [
48
- 'Planning outputs are complete and reviewable.',
49
- 'Verification steps are explicit.',
48
+ '规划输出完整且可审阅。',
49
+ '验证步骤明确可执行。',
50
50
  ]),
51
51
  constraints: bulletsFromSection(extractSection(sourceText, 'Constraints'), [
52
- 'Preserve existing workflow sequencing.',
53
- 'Keep planning outputs deterministic and reviewable.',
52
+ '保留既有 workflow 顺序。',
53
+ '保持规划输出稳定且可审阅。',
54
54
  ]),
55
55
  decisions: bulletsFromSection(extractSection(sourceText, 'Decision Boundaries'), [
56
- 'Plan stops after approved planning artifacts exist.',
57
- 'Execution requires explicit downstream approval.',
56
+ 'plan 在生成已批准规划工件后停止。',
57
+ '执行需要显式下游批准。',
58
58
  ]),
59
59
  };
60
60
  }
61
61
 
62
- function chineseBulletList(items) {
63
- return items.map((item) => `- ${item}`).join('\n');
64
- }
65
-
66
62
  function plannerDraftFromSource({ slug, sourceText, deliberateMode }) {
67
63
  const summary = buildSourceSummary(sourceText);
68
64
  const executionInputs = bulletsFromSection(extractSection(sourceText, 'Execution Inputs'), []);
@@ -90,159 +86,115 @@ function plannerDraftFromSource({ slug, sourceText, deliberateMode }) {
90
86
  ],
91
87
  options: [
92
88
  {
93
- name: 'Embed orchestration in plan runtime',
94
- pros: ['runtime truth and product contract stay aligned', 'one state machine owns gating and artifacts'],
95
- cons: ['requires new adapter seam for deterministic testing'],
89
+ name: ' plan runtime 内嵌编排',
90
+ pros: ['runtime 真相与产品契约保持一致', '由同一个状态机管理 gate 与工件'],
91
+ cons: ['需要额外的 adapter 边界来支撑确定性测试'],
96
92
  },
97
93
  {
98
- name: 'Wrapper consensus around lightweight plan',
99
- pros: ['smaller immediate diff'],
100
- cons: ['preserves split truth between wrapper and runtime', 'status/debugging remains fragmented'],
94
+ name: '在轻量 plan 外包一层共识流程',
95
+ pros: ['短期 diff 更小'],
96
+ cons: ['wrapper runtime 的事实仍然分裂', 'status 与调试信息继续碎片化'],
101
97
  },
102
98
  ],
103
99
  planText: [
104
- `# loopx Plan: ${slug}`,
100
+ `# loopx 计划: ${slug}`,
105
101
  '',
106
- '## Requirements Summary',
102
+ '## 需求摘要',
107
103
  '',
108
104
  `- ${summary.intent}`,
109
105
  `- ${summary.outcome}`,
110
106
  '',
111
- '## Deliverables',
107
+ '## 交付物',
112
108
  '',
113
109
  ...summary.acceptance.map((item, index) => `${index + 1}. ${item}`),
114
110
  '',
115
- '## Implementation Steps',
111
+ '## 实施步骤',
116
112
  '',
117
- '1. Add a plan orchestration adapter for planner, architect, and critic.',
118
- '2. Record plan iteration, review verdicts, execution-input blockers, and docs blockers in workflow state.',
119
- '3. Generate canonical plan artifacts and Chinese docs outputs from the approved planning source.',
120
- '4. Expose plan-stage progress in CLI status.',
121
- '5. Add deterministic regression coverage for happy path, iterate path, docs blockers, and unresolved execution inputs.',
113
+ '1. planner、architect、critic 增加 plan orchestration adapter',
114
+ '2. workflow state 中记录 plan iterationreview verdict execution-input blockers',
115
+ '3. 从已批准的 planning source 生成中文主规划工件与 canonical plan artifacts',
116
+ '4. CLI status 中暴露 plan 阶段进度。',
117
+ '5. happy pathiterate path execution input 未收口路径补 deterministic regression coverage。',
122
118
  '',
123
- '## Execution Inputs',
119
+ '## 执行输入',
124
120
  '',
125
121
  ...(executionInputs.length > 0 ? executionInputs.map((item) => `- ${item}`) : ['- TBD: execution inputs not yet mapped to concrete sources.']),
126
122
  '',
127
- '## Risks',
123
+ '## 风险',
128
124
  '',
129
125
  ...summary.constraints.map((item) => `- ${item}`),
130
126
  '',
131
- '## Verification',
127
+ '## 验证',
132
128
  '',
133
- '- run workflow tests',
134
- '- run CLI status checks',
135
- '- prove docs blocking and iteration paths',
129
+ '- 运行 workflow tests',
130
+ '- 运行 CLI status checks',
131
+ '- 证明 execution input blockers iterate path 生效',
136
132
  ].join('\n'),
137
133
  architectureText: [
138
- `# loopx Architecture: ${slug}`,
134
+ `# 架构文档: ${slug}`,
139
135
  '',
140
- '## Intent',
136
+ '## 目标',
141
137
  '',
142
138
  `- ${summary.intent}`,
143
139
  '',
144
- '## Boundaries',
140
+ '## 边界',
145
141
  '',
146
142
  ...summary.decisions.map((item) => `- ${item}`),
147
143
  '',
148
- '## Chosen Design',
144
+ '## 选定方案',
149
145
  '',
150
- '- plan runtime owns the planner -> architect -> critic loop',
151
- '- a dedicated adapter separates production orchestration from deterministic tests',
152
- '- canonical plan artifacts remain under `.loopx/plans/`',
153
- '- required Chinese docs are emitted under `docs/<slug>/`',
146
+ '- plan runtime 负责 planner -> architect -> critic 闭环',
147
+ '- 通过专用 adapter 隔离生产编排与确定性测试',
148
+ '- canonical plan artifacts 保持写入 `.loopx/plans/`',
149
+ '- `.loopx/workflows/<slug>/` 下的主规划工件直接作为中文产物',
154
150
  '',
155
- '## Alternatives Considered',
151
+ '## 备选方案',
156
152
  '',
157
- '- keep plan lightweight and wrap it externally',
158
- '- delay runtime alignment and keep the skill contract aspirational',
153
+ '- 保持 plan 轻量并在外层包一层流程',
154
+ '- 推迟 runtime 对齐,仅把 skill contract 当目标状态',
159
155
  ].join('\n'),
160
156
  developmentPlanText: [
161
- `# loopx Development Plan: ${slug}`,
157
+ `# 开发计划: ${slug}`,
162
158
  '',
163
- '## Execution Breakdown',
159
+ '## 执行拆解',
164
160
  '',
165
- '1. Extend plan state schema and status output.',
166
- '2. Implement planner/architect/critic orchestration with bounded iteration.',
167
- '3. Emit canonical and docs planning artifacts.',
168
- '4. Add deterministic test seams and regression coverage.',
161
+ '1. 扩展 plan state schema status 输出。',
162
+ '2. 实现带有有界迭代的 planner/architect/critic 编排。',
163
+ '3. 直接输出中文主规划工件与 canonical plan artifacts',
164
+ '4. 增加 deterministic test seams regression coverage',
169
165
  '',
170
- '## Staffing Guidance',
166
+ '## 责任分工',
171
167
  '',
172
168
  '- owner: plan runtime',
173
169
  '- reviewer: architect and critic',
174
- '- downstream execution: explicit later approval only',
170
+ '- downstream execution: 仅在后续显式批准后进入',
175
171
  '',
176
- '## Sequencing',
172
+ '## 时序要求',
177
173
  '',
178
- '- do not run critic before architect completes',
179
- '- do not approve build until plan blockers are gone',
180
- '- do not auto-launch execution from plan',
174
+ '- architect 未完成前不得运行 critic',
175
+ '- plan blockers 清除前不得批准 build',
176
+ '- plan 阶段不得自动启动执行',
181
177
  ].join('\n'),
182
178
  testPlanText: [
183
- `# loopx Test Plan: ${slug}`,
179
+ `# 测试计划: ${slug}`,
184
180
  '',
185
- '## Unit',
181
+ '## 单元测试',
186
182
  '',
187
- '- state initialization for plan consensus mode',
188
- '- docs artifact path and blocking checks',
189
- '- planner/architect/critic review artifact recording',
183
+ '- plan consensus mode state 初始化',
184
+ '- 中文主规划工件的 blocking checks',
185
+ '- planner/architect/critic review artifact 记录',
190
186
  '',
191
- '## Integration',
187
+ '## 集成测试',
192
188
  '',
193
189
  '- clarify -> plan happy path',
194
- '- critic iterate then approve path',
195
- '- docs missing or non-Chinese blocking path',
196
- '- execution inputs missing or marked TBD blocking path',
190
+ '- critic iterate approve 的路径',
191
+ '- 主规划工件缺失或非中文时的 blocking 路径',
192
+ '- execution inputs 缺失或标记 TBD blocking 路径',
197
193
  '',
198
- '## Observability',
194
+ '## 可观测性',
199
195
  '',
200
- '- status exposes iteration, architect review status, critic verdict, execution input blockers, and docs blockers',
196
+ '- status 输出 iterationarchitect review statuscritic verdict execution input blockers',
201
197
  ].join('\n'),
202
- docs: {
203
- architecture: [
204
- '# 架构文档',
205
- '',
206
- '## 目标',
207
- '',
208
- '- 将 plan 运行时升级为真实的 Planner / Architect / Critic 规划闭环。',
209
- '- 在 approved plan 产出后停止,不进入执行阶段。',
210
- '',
211
- '## 关键边界',
212
- '',
213
- ...summary.decisions.map((item) => `- ${item}`),
214
- '',
215
- '## 关键约束',
216
- '',
217
- ...summary.constraints.map((item) => `- ${item}`),
218
- ].join('\n'),
219
- design: [
220
- '# 设计文档',
221
- '',
222
- '## 设计要点',
223
- '',
224
- '- 引入 plan orchestration adapter,隔离真实编排与测试替身。',
225
- '- 在 workflow state 中记录 iteration、architect review、critic verdict 和 docs blockers。',
226
- '- 以 `.loopx/plans/` 为 canonical,以 `docs/<slug>/` 为中文规划文档输出。',
227
- '',
228
- '## 非目标',
229
- '',
230
- ...summary.nonGoals.map((item) => `- ${item}`),
231
- ].join('\n'),
232
- testPlan: [
233
- '# 测试计划',
234
- '',
235
- '## 验证范围',
236
- '',
237
- ...summary.acceptance.map((item) => `- ${item}`),
238
- '',
239
- '## 核心回归',
240
- '',
241
- '- happy path: 一轮 approve 完成',
242
- '- iterate path: Critic 先 iterate 后 approve',
243
- '- docs blocker: 缺文件或英文占位内容都不能完成',
244
- ].join('\n'),
245
- },
246
198
  preMortem,
247
199
  principlesResolved: true,
248
200
  optionsReviewed: true,
@@ -265,7 +217,7 @@ function reviewArtifact(kind, iteration, verdict, findings, extras = {}) {
265
217
  function defaultArchitectReview({ plannerDraft, iteration }) {
266
218
  const findings = [
267
219
  'Real planning orchestration needs an adapter seam so production runtime and deterministic tests can share one state machine.',
268
- 'Plan completion should depend on blocking docs outputs, not only canonical plan artifacts.',
220
+ 'Plan completion should depend on blocking workflow planning artifacts, not only canonical plan artifacts.',
269
221
  ];
270
222
  return reviewArtifact('architect', iteration, 'approve', findings, {
271
223
  status: 'complete',
@@ -275,7 +227,13 @@ function defaultArchitectReview({ plannerDraft, iteration }) {
275
227
  }
276
228
 
277
229
  function containsChinese(text) {
278
- return /[\u3400-\u9fff]/.test(text);
230
+ const chineseChars = text.match(/[\u3400-\u9fff]/g) || [];
231
+ const latinChars = text.match(/[A-Za-z]/g) || [];
232
+ const signalChars = chineseChars.length + latinChars.length;
233
+ if (signalChars === 0) {
234
+ return false;
235
+ }
236
+ return chineseChars.length >= 40 || (chineseChars.length >= 8 && chineseChars.length / signalChars >= 0.2);
279
237
  }
280
238
 
281
239
  function defaultCriticReview({ plannerDraft, iteration }) {
@@ -295,8 +253,8 @@ function defaultCriticReview({ plannerDraft, iteration }) {
295
253
  if (!plannerDraft.executionInputsResolved) {
296
254
  findings.push('Execution inputs are not fully mapped to concrete sources.');
297
255
  }
298
- if (!containsChinese(plannerDraft.docs.architecture) || !containsChinese(plannerDraft.docs.design) || !containsChinese(plannerDraft.docs.testPlan)) {
299
- findings.push('Required docs outputs are not Chinese.');
256
+ if (!containsChinese(plannerDraft.planText) || !containsChinese(plannerDraft.architectureText) || !containsChinese(plannerDraft.developmentPlanText) || !containsChinese(plannerDraft.testPlanText)) {
257
+ findings.push('Required workflow planning artifacts are not Chinese.');
300
258
  }
301
259
  return reviewArtifact('critic', iteration, findings.length > 0 ? 'iterate' : 'approve', findings, {
302
260
  acceptanceCriteriaTestable: plannerDraft.acceptanceCriteriaTestable,
@@ -378,7 +336,6 @@ export function createRealPlanAdapter({ model } = {}) {
378
336
  ' "architectureText": string,',
379
337
  ' "developmentPlanText": string,',
380
338
  ' "testPlanText": string,',
381
- ' "docs": {"architecture": string, "design": string, "testPlan": string},',
382
339
  ' "principlesResolved": boolean,',
383
340
  ' "optionsReviewed": boolean,',
384
341
  ' "acceptanceCriteriaTestable": boolean,',
@@ -387,7 +344,7 @@ export function createRealPlanAdapter({ model } = {}) {
387
344
  '}',
388
345
  `Deliberate mode: ${Boolean(context.deliberateMode)}`,
389
346
  '',
390
- 'Use Chinese for docs.architecture / docs.design / docs.testPlan.',
347
+ 'Use Chinese for planText / architectureText / developmentPlanText / testPlanText.',
391
348
  'Do not ask questions. Do not wrap JSON in markdown.',
392
349
  '',
393
350
  'Source requirements:',