@ai-content-space/loopx 0.1.1 → 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 (68) 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 +22 -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 +51 -8
  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 +85 -0
  61. package/src/plan-runtime.mjs +100 -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 +1947 -118
  66. package/src/workspace-context.mjs +166 -0
  67. package/src/workspace-memory.mjs +69 -0
  68. package/templates/plan.md +6 -0
@@ -33,38 +33,36 @@ 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);
64
+ const executionInputs = bulletsFromSection(extractSection(sourceText, 'Execution Inputs'), []);
65
+ const executionInputsResolved = executionInputs.length > 0 && executionInputs.every((item) => !/\b(TBD|待定|unknown|later)\b/i.test(item));
68
66
  const preMortem = deliberateMode
69
67
  ? [
70
68
  '如果运行时没有独立的规划适配层,真实编排与测试替身会相互污染。',
@@ -88,159 +86,121 @@ function plannerDraftFromSource({ slug, sourceText, deliberateMode }) {
88
86
  ],
89
87
  options: [
90
88
  {
91
- name: 'Embed orchestration in plan runtime',
92
- pros: ['runtime truth and product contract stay aligned', 'one state machine owns gating and artifacts'],
93
- cons: ['requires new adapter seam for deterministic testing'],
89
+ name: ' plan runtime 内嵌编排',
90
+ pros: ['runtime 真相与产品契约保持一致', '由同一个状态机管理 gate 与工件'],
91
+ cons: ['需要额外的 adapter 边界来支撑确定性测试'],
94
92
  },
95
93
  {
96
- name: 'Wrapper consensus around lightweight plan',
97
- pros: ['smaller immediate diff'],
98
- cons: ['preserves split truth between wrapper and runtime', 'status/debugging remains fragmented'],
94
+ name: '在轻量 plan 外包一层共识流程',
95
+ pros: ['短期 diff 更小'],
96
+ cons: ['wrapper runtime 的事实仍然分裂', 'status 与调试信息继续碎片化'],
99
97
  },
100
98
  ],
101
99
  planText: [
102
- `# loopx Plan: ${slug}`,
100
+ `# loopx 计划: ${slug}`,
103
101
  '',
104
- '## Requirements Summary',
102
+ '## 需求摘要',
105
103
  '',
106
104
  `- ${summary.intent}`,
107
105
  `- ${summary.outcome}`,
108
106
  '',
109
- '## Deliverables',
107
+ '## 交付物',
110
108
  '',
111
109
  ...summary.acceptance.map((item, index) => `${index + 1}. ${item}`),
112
110
  '',
113
- '## Implementation Steps',
111
+ '## 实施步骤',
112
+ '',
113
+ '1. 为 planner、architect、critic 增加 plan orchestration adapter。',
114
+ '2. 在 workflow state 中记录 plan iteration、review verdict 和 execution-input blockers。',
115
+ '3. 从已批准的 planning source 生成中文主规划工件与 canonical plan artifacts。',
116
+ '4. 在 CLI status 中暴露 plan 阶段进度。',
117
+ '5. 为 happy path、iterate path 和 execution input 未收口路径补 deterministic regression coverage。',
114
118
  '',
115
- '1. Add a plan orchestration adapter for planner, architect, and critic.',
116
- '2. Record plan iteration, review verdicts, and docs blockers in workflow state.',
117
- '3. Generate canonical plan artifacts and Chinese docs outputs from the approved planning source.',
118
- '4. Expose plan-stage progress in CLI status.',
119
- '5. Add deterministic regression coverage for happy path, iterate path, and docs blockers.',
119
+ '## 执行输入',
120
120
  '',
121
- '## Risks',
121
+ ...(executionInputs.length > 0 ? executionInputs.map((item) => `- ${item}`) : ['- TBD: execution inputs not yet mapped to concrete sources.']),
122
+ '',
123
+ '## 风险',
122
124
  '',
123
125
  ...summary.constraints.map((item) => `- ${item}`),
124
126
  '',
125
- '## Verification',
127
+ '## 验证',
126
128
  '',
127
- '- run workflow tests',
128
- '- run CLI status checks',
129
- '- prove docs blocking and iteration paths',
129
+ '- 运行 workflow tests',
130
+ '- 运行 CLI status checks',
131
+ '- 证明 execution input blockers iterate path 生效',
130
132
  ].join('\n'),
131
133
  architectureText: [
132
- `# loopx Architecture: ${slug}`,
134
+ `# 架构文档: ${slug}`,
133
135
  '',
134
- '## Intent',
136
+ '## 目标',
135
137
  '',
136
138
  `- ${summary.intent}`,
137
139
  '',
138
- '## Boundaries',
140
+ '## 边界',
139
141
  '',
140
142
  ...summary.decisions.map((item) => `- ${item}`),
141
143
  '',
142
- '## Chosen Design',
144
+ '## 选定方案',
143
145
  '',
144
- '- plan runtime owns the planner -> architect -> critic loop',
145
- '- a dedicated adapter separates production orchestration from deterministic tests',
146
- '- canonical plan artifacts remain under `.loopx/plans/`',
147
- '- 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>/` 下的主规划工件直接作为中文产物',
148
150
  '',
149
- '## Alternatives Considered',
151
+ '## 备选方案',
150
152
  '',
151
- '- keep plan lightweight and wrap it externally',
152
- '- delay runtime alignment and keep the skill contract aspirational',
153
+ '- 保持 plan 轻量并在外层包一层流程',
154
+ '- 推迟 runtime 对齐,仅把 skill contract 当目标状态',
153
155
  ].join('\n'),
154
156
  developmentPlanText: [
155
- `# loopx Development Plan: ${slug}`,
157
+ `# 开发计划: ${slug}`,
156
158
  '',
157
- '## Execution Breakdown',
159
+ '## 执行拆解',
158
160
  '',
159
- '1. Extend plan state schema and status output.',
160
- '2. Implement planner/architect/critic orchestration with bounded iteration.',
161
- '3. Emit canonical and docs planning artifacts.',
162
- '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',
163
165
  '',
164
- '## Staffing Guidance',
166
+ '## 责任分工',
165
167
  '',
166
168
  '- owner: plan runtime',
167
169
  '- reviewer: architect and critic',
168
- '- downstream execution: explicit later approval only',
170
+ '- downstream execution: 仅在后续显式批准后进入',
169
171
  '',
170
- '## Sequencing',
172
+ '## 时序要求',
171
173
  '',
172
- '- do not run critic before architect completes',
173
- '- do not approve build until plan blockers are gone',
174
- '- do not auto-launch execution from plan',
174
+ '- architect 未完成前不得运行 critic',
175
+ '- plan blockers 清除前不得批准 build',
176
+ '- plan 阶段不得自动启动执行',
175
177
  ].join('\n'),
176
178
  testPlanText: [
177
- `# loopx Test Plan: ${slug}`,
179
+ `# 测试计划: ${slug}`,
178
180
  '',
179
- '## Unit',
181
+ '## 单元测试',
180
182
  '',
181
- '- state initialization for plan consensus mode',
182
- '- docs artifact path and blocking checks',
183
- '- planner/architect/critic review artifact recording',
183
+ '- plan consensus mode state 初始化',
184
+ '- 中文主规划工件的 blocking checks',
185
+ '- planner/architect/critic review artifact 记录',
184
186
  '',
185
- '## Integration',
187
+ '## 集成测试',
186
188
  '',
187
189
  '- clarify -> plan happy path',
188
- '- critic iterate then approve path',
189
- '- docs missing or non-Chinese blocking path',
190
+ '- critic iterate approve 的路径',
191
+ '- 主规划工件缺失或非中文时的 blocking 路径',
192
+ '- execution inputs 缺失或标记 TBD 的 blocking 路径',
190
193
  '',
191
- '## Observability',
194
+ '## 可观测性',
192
195
  '',
193
- '- status exposes iteration, architect review status, critic verdict, and docs blockers',
196
+ '- status 输出 iterationarchitect review statuscritic verdict execution input blockers',
194
197
  ].join('\n'),
195
- docs: {
196
- architecture: [
197
- '# 架构文档',
198
- '',
199
- '## 目标',
200
- '',
201
- '- 将 plan 运行时升级为真实的 Planner / Architect / Critic 规划闭环。',
202
- '- 在 approved plan 产出后停止,不进入执行阶段。',
203
- '',
204
- '## 关键边界',
205
- '',
206
- ...summary.decisions.map((item) => `- ${item}`),
207
- '',
208
- '## 关键约束',
209
- '',
210
- ...summary.constraints.map((item) => `- ${item}`),
211
- ].join('\n'),
212
- design: [
213
- '# 设计文档',
214
- '',
215
- '## 设计要点',
216
- '',
217
- '- 引入 plan orchestration adapter,隔离真实编排与测试替身。',
218
- '- 在 workflow state 中记录 iteration、architect review、critic verdict 和 docs blockers。',
219
- '- 以 `.loopx/plans/` 为 canonical,以 `docs/<slug>/` 为中文规划文档输出。',
220
- '',
221
- '## 非目标',
222
- '',
223
- ...summary.nonGoals.map((item) => `- ${item}`),
224
- ].join('\n'),
225
- testPlan: [
226
- '# 测试计划',
227
- '',
228
- '## 验证范围',
229
- '',
230
- ...summary.acceptance.map((item) => `- ${item}`),
231
- '',
232
- '## 核心回归',
233
- '',
234
- '- happy path: 一轮 approve 完成',
235
- '- iterate path: Critic 先 iterate 后 approve',
236
- '- docs blocker: 缺文件或英文占位内容都不能完成',
237
- ].join('\n'),
238
- },
239
198
  preMortem,
240
199
  principlesResolved: true,
241
200
  optionsReviewed: true,
242
201
  acceptanceCriteriaTestable: true,
243
202
  verificationStepsResolved: true,
203
+ executionInputsResolved,
244
204
  };
245
205
  }
246
206
 
@@ -257,7 +217,7 @@ function reviewArtifact(kind, iteration, verdict, findings, extras = {}) {
257
217
  function defaultArchitectReview({ plannerDraft, iteration }) {
258
218
  const findings = [
259
219
  'Real planning orchestration needs an adapter seam so production runtime and deterministic tests can share one state machine.',
260
- '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.',
261
221
  ];
262
222
  return reviewArtifact('architect', iteration, 'approve', findings, {
263
223
  status: 'complete',
@@ -267,7 +227,13 @@ function defaultArchitectReview({ plannerDraft, iteration }) {
267
227
  }
268
228
 
269
229
  function containsChinese(text) {
270
- 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);
271
237
  }
272
238
 
273
239
  function defaultCriticReview({ plannerDraft, iteration }) {
@@ -284,12 +250,16 @@ function defaultCriticReview({ plannerDraft, iteration }) {
284
250
  if (!plannerDraft.verificationStepsResolved) {
285
251
  findings.push('Verification steps are not concrete.');
286
252
  }
287
- if (!containsChinese(plannerDraft.docs.architecture) || !containsChinese(plannerDraft.docs.design) || !containsChinese(plannerDraft.docs.testPlan)) {
288
- findings.push('Required docs outputs are not Chinese.');
253
+ if (!plannerDraft.executionInputsResolved) {
254
+ findings.push('Execution inputs are not fully mapped to concrete sources.');
255
+ }
256
+ if (!containsChinese(plannerDraft.planText) || !containsChinese(plannerDraft.architectureText) || !containsChinese(plannerDraft.developmentPlanText) || !containsChinese(plannerDraft.testPlanText)) {
257
+ findings.push('Required workflow planning artifacts are not Chinese.');
289
258
  }
290
259
  return reviewArtifact('critic', iteration, findings.length > 0 ? 'iterate' : 'approve', findings, {
291
260
  acceptanceCriteriaTestable: plannerDraft.acceptanceCriteriaTestable,
292
261
  verificationStepsResolved: plannerDraft.verificationStepsResolved,
262
+ executionInputsResolved: plannerDraft.executionInputsResolved,
293
263
  });
294
264
  }
295
265
 
@@ -302,6 +272,9 @@ function scriptedVerdict(script, index, fallback) {
302
272
  }
303
273
 
304
274
  function scriptedCriticReview({ plannerDraft, iteration }, script, index) {
275
+ if (!Array.isArray(script) || script.length === 0) {
276
+ return defaultCriticReview({ plannerDraft, iteration });
277
+ }
305
278
  const verdict = scriptedVerdict(script, index, 'approve');
306
279
  const findings = verdict === 'approve'
307
280
  ? ['Structured planning outputs satisfy the scripted approval path.']
@@ -309,6 +282,7 @@ function scriptedCriticReview({ plannerDraft, iteration }, script, index) {
309
282
  return reviewArtifact('critic', iteration, verdict, findings, {
310
283
  acceptanceCriteriaTestable: plannerDraft.acceptanceCriteriaTestable,
311
284
  verificationStepsResolved: plannerDraft.verificationStepsResolved,
285
+ executionInputsResolved: plannerDraft.executionInputsResolved,
312
286
  });
313
287
  }
314
288
 
@@ -321,6 +295,9 @@ export function createScriptedPlanAdapter(script = {}) {
321
295
  },
322
296
  async architect(context) {
323
297
  const base = defaultArchitectReview(context);
298
+ if (!Array.isArray(script.architect) || script.architect.length === 0) {
299
+ return base;
300
+ }
324
301
  const mode = scriptedVerdict(script.architect, architectIndex, 'approve');
325
302
  architectIndex += 1;
326
303
  return {
@@ -359,15 +336,15 @@ export function createRealPlanAdapter({ model } = {}) {
359
336
  ' "architectureText": string,',
360
337
  ' "developmentPlanText": string,',
361
338
  ' "testPlanText": string,',
362
- ' "docs": {"architecture": string, "design": string, "testPlan": string},',
363
339
  ' "principlesResolved": boolean,',
364
340
  ' "optionsReviewed": boolean,',
365
341
  ' "acceptanceCriteriaTestable": boolean,',
366
- ' "verificationStepsResolved": boolean',
342
+ ' "verificationStepsResolved": boolean,',
343
+ ' "executionInputsResolved": boolean',
367
344
  '}',
368
345
  `Deliberate mode: ${Boolean(context.deliberateMode)}`,
369
346
  '',
370
- 'Use Chinese for docs.architecture / docs.design / docs.testPlan.',
347
+ 'Use Chinese for planText / architectureText / developmentPlanText / testPlanText.',
371
348
  'Do not ask questions. Do not wrap JSON in markdown.',
372
349
  '',
373
350
  'Source requirements:',
@@ -433,7 +410,8 @@ export function createRealPlanAdapter({ model } = {}) {
433
410
  ' "verdict": "approve" | "iterate" | "reject",',
434
411
  ' "findings": string[],',
435
412
  ' "acceptanceCriteriaTestable": boolean,',
436
- ' "verificationStepsResolved": boolean',
413
+ ' "verificationStepsResolved": boolean,',
414
+ ' "executionInputsResolved": boolean',
437
415
  '}',
438
416
  'Do not ask questions. Do not wrap JSON in markdown.',
439
417
  '',