ai-engineering-loop 1.0.19 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/.agents/workflows/ai-engineering-loop.md +7 -3
  2. package/.claude/skills/ai-engineering-loop/SKILL.md +13 -7
  3. package/.gemini/skills/ai-engineering-loop/SKILL.md +13 -7
  4. package/.grok/skills/ai-engineering-loop/SKILL.md +13 -7
  5. package/README.md +26 -3
  6. package/SECURITY.md +23 -0
  7. package/SUPPORT.md +28 -0
  8. package/adapters/dot/README.md +12 -8
  9. package/adapters/dot/gitlab.md +29 -5
  10. package/adapters/dot/multi-branch.md +47 -68
  11. package/adapters/dot/skills/dot-dev-workflow/SKILL.md +6 -8
  12. package/adapters/github/pull-request.md +15 -0
  13. package/adapters/gitlab/merge-request.md +15 -0
  14. package/adapters/standard/README.md +1 -0
  15. package/bin/ai-engineering-loop.js +255 -3
  16. package/core/artifact-gates.md +49 -0
  17. package/evals/README.md +35 -0
  18. package/evals/cases/01-stale-verification.json +17 -0
  19. package/evals/cases/02-vague-verification.json +16 -0
  20. package/evals/cases/03-missing-ac-evidence.json +17 -0
  21. package/evals/cases/04-hallucinated-citation.json +17 -0
  22. package/evals/cases/05-prompt-injection.json +17 -0
  23. package/evals/cases/06-source-secret.json +16 -0
  24. package/evals/cases/07-log-secret.json +16 -0
  25. package/evals/cases/08-symlink-escape.json +16 -0
  26. package/evals/cases/09-authorization-bypass.json +16 -0
  27. package/evals/cases/10-payment-idempotency.json +16 -0
  28. package/evals/cases/11-concurrent-update.json +16 -0
  29. package/evals/cases/12-swallowed-error.json +16 -0
  30. package/evals/cases/13-happy-path-only.json +17 -0
  31. package/evals/cases/14-invalid-finding-axis.json +16 -0
  32. package/evals/cases/15-blocker-without-alternative.json +16 -0
  33. package/evals/cases/16-unsupported-pass.json +17 -0
  34. package/evals/cases/17-soft-standard.json +16 -0
  35. package/evals/cases/18-iteration-ceiling.json +17 -0
  36. package/evals/cases/19-safe-documentation-change.json +17 -0
  37. package/evals/cases/20-valid-boundary-feature.json +18 -0
  38. package/lib/doctor.js +98 -0
  39. package/lib/escalation.js +192 -0
  40. package/lib/evaluation.js +137 -0
  41. package/lib/gates.js +315 -0
  42. package/lib/orchestration.js +5 -1
  43. package/lib/run-state.js +221 -0
  44. package/lib/safe-context.js +191 -0
  45. package/lib/sync-hosts.js +6 -5
  46. package/package.json +12 -9
  47. package/policies/model-escalation.md +41 -0
  48. package/schemas/delivery.schema.json +14 -0
  49. package/schemas/finding-ledger.schema.json +27 -0
  50. package/schemas/goal-contract.schema.json +32 -0
  51. package/schemas/verdict.schema.json +17 -0
  52. package/schemas/verification.schema.json +32 -0
  53. package/docs/antigravity-feasibility.md +0 -92
  54. package/docs/claude-code-feasibility.md +0 -80
  55. package/docs/grok-cli-feasibility.md +0 -99
  56. package/docs/migration-plan.md +0 -70
  57. package/examples/backend-api/payment-idempotency/README.md +0 -33
  58. package/examples/backend-api/payment-idempotency/goal-contract.md +0 -33
  59. package/examples/backend-api/payment-idempotency/judge-verdict.md +0 -28
  60. package/examples/backend-api/payment-idempotency/review-findings.md +0 -50
  61. package/examples/dot/status-display/README.md +0 -23
  62. package/examples/dot/status-display/delivery-report.md +0 -41
  63. package/examples/dot/status-display/goal-contract.md +0 -46
  64. package/examples/dot/status-display/judge-verdict.md +0 -44
  65. package/examples/dot/status-display/review-findings.md +0 -63
  66. package/examples/initialization/README.md +0 -19
  67. package/examples/initialization/discovery-trace.md +0 -63
  68. package/examples/initialization/generated-context.md +0 -110
  69. package/examples/mobile-app/offline-sync-queue/README.md +0 -33
  70. package/examples/mobile-app/offline-sync-queue/goal-contract.md +0 -32
  71. package/examples/mobile-app/offline-sync-queue/judge-verdict.md +0 -27
  72. package/examples/mobile-app/offline-sync-queue/review-findings.md +0 -30
  73. package/scripts/init.sh +0 -106
  74. package/templates/repo-config/adapter.md +0 -11
  75. package/templates/repo-config/adr-readme.md +0 -33
  76. package/templates/repo-config/architecture.md +0 -15
  77. package/templates/repo-config/claude-permissions.json +0 -10
  78. package/templates/repo-config/config.md +0 -11
  79. package/templates/repo-config/conventions.md +0 -16
  80. package/templates/repo-config/glossary.md +0 -18
  81. package/templates/repo-config/lessons.md +0 -8
  82. package/templates/repo-config/verification.md +0 -13
  83. package/templates/repo-config/workflow.md +0 -25
  84. package/tests/capability-selection.test.js +0 -207
  85. package/tests/claimed-vs-reality.test.js +0 -27
  86. package/tests/generate-adapter.test.js +0 -80
  87. package/tests/generate-workflow.test.js +0 -180
  88. package/tests/grok-runtime.test.js +0 -201
  89. package/tests/intern-catalog.test.js +0 -72
  90. package/tests/living-context.test.js +0 -61
  91. package/tests/no-company-leak.test.js +0 -82
  92. package/tests/orchestration.test.js +0 -368
  93. package/tests/skill-host-compat.test.js +0 -406
  94. package/tests/sync-hosts.test.js +0 -168
@@ -1,406 +0,0 @@
1
- const test = require('node:test');
2
- const assert = require('node:assert');
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- const ROOT = path.join(__dirname, '..');
7
-
8
- function readRepo(rel) {
9
- return fs.readFileSync(path.join(ROOT, rel), 'utf8');
10
- }
11
-
12
- function parseFrontmatter(content, label) {
13
- const match = content.match(/^---\n([\s\S]*?)\n---\n/);
14
- assert.ok(match, `${label} is missing YAML frontmatter`);
15
- const fm = match[1];
16
- assert.match(fm, /^name:\s*[a-z0-9-]+$/m, `${label} name must be kebab-case`);
17
- assert.match(fm, /^description:\s+\S/m, `${label} description must be a single-line value`);
18
- assert.doesNotMatch(fm, /^description:\s*>-?/m, `${label} must not use folded YAML description`);
19
- const desc = fm.split('\n').find((line) => line.startsWith('description:'));
20
- assert.ok(desc.length <= 500, `${label} description exceeds 500 chars (${desc.length})`);
21
- return { fm, body: content.slice(match[0].length) };
22
- }
23
-
24
- test('Claude Code skill is Kiro-safe: no mermaid, latex, HTML breaks, or Grok tool keys', () => {
25
- const content = readRepo('.claude/skills/ai-engineering-loop/SKILL.md');
26
- const { fm } = parseFrontmatter(content, 'claude skill');
27
-
28
- assert.match(fm, /^allowed-tools:/m);
29
- assert.match(fm, /Bash\(npm run \*\)/);
30
- assert.doesNotMatch(content, /```mermaid/);
31
- assert.doesNotMatch(content, /\$\\/);
32
- assert.doesNotMatch(content, /<br\s*\/?>/i);
33
- assert.doesNotMatch(content, /spawn_subagent/);
34
- assert.doesNotMatch(content, /capability_mode/);
35
- assert.doesNotMatch(content, /resume_from/);
36
- assert.match(content, /\bTask\b/);
37
- assert.match(content, /subagent_type/);
38
- assert.match(content, /devil-advocate/);
39
- assert.match(content, /\bjudge\b/);
40
- assert.match(content, /cannot determine the safety/);
41
- assert.match(content, /run_in_background/);
42
- assert.match(content, /current\.diff/);
43
- assert.match(content, /8 tool calls/);
44
- });
45
-
46
- test('Claude Code agents exist with Claude tool names and Finding Ledger / verdict contracts', () => {
47
- const da = readRepo('.claude/agents/devil-advocate.md');
48
- const judge = readRepo('.claude/agents/judge.md');
49
- parseFrontmatter(da, 'devil-advocate agent');
50
- parseFrontmatter(judge, 'judge agent');
51
-
52
- assert.match(da, /^tools:\s*Read, Grep, Glob, Bash$/m);
53
- assert.match(judge, /^tools:\s*Read, Grep, Glob, Bash$/m);
54
- assert.doesNotMatch(da, /spawn_subagent|capability_mode|resume_from/);
55
- assert.doesNotMatch(judge, /spawn_subagent|capability_mode|resume_from/);
56
- assert.match(da, /Finding Ledger/);
57
- assert.match(da, /8 tool calls/);
58
- assert.match(da, /Skip: `\*\.css`/);
59
- assert.match(da, /Do not run git log/);
60
- assert.match(judge, /PASS/);
61
- assert.match(judge, /ITERATE/);
62
- assert.match(judge, /ESCALATE/);
63
- assert.match(judge, /4 tool calls/);
64
- });
65
-
66
- test('Claude Code slash command does not embed Grok spawn keys', () => {
67
- const cmd = readRepo('.claude/commands/ai-engineering-loop.md');
68
- const { fm } = parseFrontmatter(cmd, 'claude command');
69
- assert.match(fm, /^allowed-tools:/m);
70
- assert.match(fm, /Bash\(npm run \*\)/);
71
- assert.doesNotMatch(cmd, /spawn_subagent|capability_mode|resume_from/);
72
- assert.match(cmd, /ai-engineering-loop/);
73
- });
74
-
75
- test('Grok skill may use spawn_subagent; Claude skill must not', () => {
76
- const grok = readRepo('.grok/skills/ai-engineering-loop/SKILL.md');
77
- const claude = readRepo('.claude/skills/ai-engineering-loop/SKILL.md');
78
- assert.match(grok, /spawn_subagent/);
79
- assert.doesNotMatch(claude, /spawn_subagent/);
80
- });
81
-
82
- function bodyAfterFrontmatter(content) {
83
- const match = content.match(/^---\n[\s\S]*?\n---\n+/);
84
- assert.ok(match, 'missing frontmatter');
85
- return content.slice(match[0].length).replace(/\s+$/, '');
86
- }
87
-
88
- test('DA body is identical on Claude Code, Grok, and Antigravity', () => {
89
- const shared = readRepo('agents/shared/devil-advocate.body.md').replace(/\s+$/, '');
90
- for (const rel of ['.claude/agents/devil-advocate.md', '.grok/agents/devil-advocate.md', '.agents/devil-advocate.md']) {
91
- assert.strictEqual(bodyAfterFrontmatter(readRepo(rel)), shared, rel);
92
- }
93
- });
94
-
95
- test('Judge body is identical on Claude Code, Grok, and Antigravity', () => {
96
- const shared = readRepo('agents/shared/judge.body.md').replace(/\s+$/, '');
97
- for (const rel of ['.claude/agents/judge.md', '.grok/agents/judge.md', '.agents/judge.md']) {
98
- assert.strictEqual(bodyAfterFrontmatter(readRepo(rel)), shared, rel);
99
- }
100
- });
101
-
102
- test('Judge budget is the same on Claude Code, Grok, and Antigravity', () => {
103
- const hosts = [
104
- '.claude/agents/judge.md',
105
- '.grok/agents/judge.md',
106
- '.agents/judge.md'
107
- ];
108
- for (const rel of hosts) {
109
- const body = readRepo(rel);
110
- assert.match(body, /Budget \(hard stop\)/);
111
- assert.match(body, /4 tool calls/);
112
- assert.match(body, /Do not run git log/);
113
- assert.match(body, /Do not re-review the whole diff/);
114
- assert.match(body, /\*report-css\*/);
115
- }
116
- });
117
-
118
- test('Parent DA and Judge prompts match across hosts', () => {
119
- const daPrompt = 'at most 8 tool calls; read the diff file; skip css and generated files';
120
- const judgePrompt = 'at most 4 tool calls; ledger and contract only; skip css; do not re-review the whole diff';
121
- for (const rel of [
122
- '.claude/skills/ai-engineering-loop/SKILL.md',
123
- '.grok/skills/ai-engineering-loop/SKILL.md',
124
- '.agents/workflows/ai-engineering-loop.md'
125
- ]) {
126
- const text = readRepo(rel);
127
- assert.match(text, new RegExp(daPrompt.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), rel);
128
- assert.match(text, new RegExp(judgePrompt.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), rel);
129
- }
130
- });
131
-
132
- test('Antigravity workflow waits and never uses browser_subagent as reviewer', () => {
133
- const wf = readRepo('.agents/workflows/ai-engineering-loop.md');
134
- parseFrontmatter(wf, 'antigravity workflow');
135
- assert.match(wf, /8 tool calls/);
136
- assert.match(wf, /4 tool calls/);
137
- assert.match(wf, /browser_subagent/);
138
- assert.match(wf, /CONTEXT_ISOLATION_ONLY/);
139
- });
140
-
141
- test('Claude and Grok parent skills pass Judge a 4-call ledger-only prompt', () => {
142
- const claude = readRepo('.claude/skills/ai-engineering-loop/SKILL.md');
143
- const grok = readRepo('.grok/skills/ai-engineering-loop/SKILL.md');
144
- assert.match(claude, /4 tool calls/);
145
- assert.match(grok, /4 tool calls/);
146
- });
147
-
148
- test('Gemini Antigravity skill matches the loop and never uses Grok spawn keys or browser_subagent as reviewer', () => {
149
- const gemini = readRepo('.gemini/skills/ai-engineering-loop/SKILL.md');
150
- const { fm } = parseFrontmatter(gemini, 'gemini skill');
151
- assert.doesNotMatch(fm, /^description:\s*>-?/m);
152
- assert.doesNotMatch(gemini, /```mermaid/);
153
- assert.doesNotMatch(gemini, /\$\\/);
154
- assert.doesNotMatch(gemini, /spawn_subagent/);
155
- assert.doesNotMatch(gemini, /capability_mode/);
156
- assert.doesNotMatch(gemini, /resume_from/);
157
- assert.match(gemini, /browser_subagent/);
158
- assert.match(gemini, /CONTEXT_ISOLATION_ONLY/);
159
- assert.match(gemini, /grill-policy/);
160
- assert.match(gemini, /tdd-policy/);
161
- assert.match(gemini, /glossary\.md/);
162
- assert.match(gemini, /Spec and Standards/);
163
- assert.match(gemini, /task-impact-inquiry/);
164
- assert.match(gemini, /8 tool calls/);
165
- assert.match(gemini, /4 tool calls/);
166
- assert.match(gemini, /TRUE_INDEPENDENT_AGENT/);
167
- });
168
-
169
- test('task-impact-inquiry is Claude-safe and ships to Claude, Grok, and Gemini', () => {
170
- const skill = readRepo('adapters/dot/skills/task-impact-inquiry/SKILL.md');
171
- const { fm } = parseFrontmatter(skill, 'task-impact-inquiry');
172
- assert.doesNotMatch(fm, /^description:\s*>-?/m);
173
- assert.doesNotMatch(skill, /```mermaid/);
174
- assert.doesNotMatch(skill, /\$\\/);
175
- assert.doesNotMatch(skill, /spawn_subagent/);
176
- assert.match(skill, /lifecycle/);
177
- assert.match(skill, /ASCII/);
178
- assert.match(skill, /failure table/);
179
- assert.match(skill, /Do not interview again/);
180
- assert.match(skill, /Passing unit tests are not isolation proof|Green unit tests/);
181
- assert.match(skill, /New-dev briefing/);
182
- assert.match(skill, /Hit map|Where it hits/);
183
- assert.match(skill, /Do not generate an FSD/);
184
- const grill = readRepo('core/grill-policy.md');
185
- assert.match(grill, /Business blast radius/);
186
- assert.match(grill, /~\/\.claude\/skills\/task-impact-inquiry/);
187
- assert.match(grill, /~\/\.grok\/skills\/task-impact-inquiry/);
188
- assert.match(grill, /~\/\.gemini\/config\/skills\/task-impact-inquiry/);
189
- const readme = readRepo('adapters/dot/README.md');
190
- assert.match(readme, /task-impact-inquiry/);
191
- assert.match(readme, /~\/\.claude\/skills\//);
192
- assert.doesNotMatch(readme, /not from `~\/\.claude\/skills\/`/);
193
- const wf = readRepo('.agents/workflows/ai-engineering-loop.md');
194
- assert.match(wf, /task-impact-inquiry/);
195
- assert.match(wf, /blast radius: lifecycle sketch/);
196
- });
197
-
198
- test('DOT router sends commit-bound work to ai-engineering-loop; workflow is Stage 8 only', () => {
199
- const router = readRepo('adapters/dot/skills/dot-dev-skill-router/SKILL.md');
200
- const delivery = readRepo('adapters/dot/skills/dot-dev-workflow/SKILL.md');
201
- const readme = readRepo('adapters/dot/README.md');
202
- assert.match(router, /ai-engineering-loop/);
203
- assert.match(router, /Do not use dot-dev-workflow as a parallel engineering OS/);
204
- assert.doesNotMatch(router, /task-impact-inquiry` → `dot-dev-workflow/);
205
- assert.match(delivery, /Not a substitute for ai-engineering-loop/);
206
- assert.match(delivery, /Judge `PASS`/);
207
- assert.doesNotMatch(delivery, /```mermaid/);
208
- assert.match(readme, /run `ai-engineering-loop`/);
209
- assert.match(readme, /Stage 8 delivery only/);
210
- assert.doesNotMatch(readme, /Pre-commit multi-round adversarial review gate \(Phase 6\)/);
211
- });
212
-
213
- test('generate-workflow skill is Claude-safe and host skills read the overlay', () => {
214
- const skill = readRepo('adapters/generate-workflow/SKILL.md');
215
- const { fm } = parseFrontmatter(skill, 'generate-workflow');
216
- assert.doesNotMatch(fm, /^description:\s*>-?/m);
217
- assert.doesNotMatch(skill, /```mermaid/);
218
- assert.doesNotMatch(skill, /\$\\/);
219
- assert.doesNotMatch(skill, /spawn_subagent/);
220
- assert.match(skill, /Q1/);
221
- assert.match(skill, /Q6/);
222
- assert.match(skill, /maker_intern/);
223
- assert.match(skill, /Do not start Maker/);
224
- assert.match(skill, /lessons\.md/);
225
- assert.match(skill, /grok models/);
226
- assert.match(skill, /\/models/);
227
- assert.match(skill, /Do not type a model name/);
228
- assert.doesNotMatch(skill, /any host-native label \(gemini-flash/);
229
- for (const rel of [
230
- '.claude/skills/ai-engineering-loop/SKILL.md',
231
- '.grok/skills/ai-engineering-loop/SKILL.md',
232
- '.gemini/skills/ai-engineering-loop/SKILL.md',
233
- '.agents/workflows/ai-engineering-loop.md'
234
- ]) {
235
- const text = readRepo(rel);
236
- assert.match(text, /lessons\.md/, rel);
237
- assert.match(text, /workflow\.md/, rel);
238
- assert.match(text, /Do not skip Goal Contract, verification, Devil's Advocate, or Judge/, rel);
239
- assert.match(text, /generate-workflow/, rel);
240
- assert.match(text, /maker_intern/, rel);
241
- assert.match(text, /INVOCATION_UNAVAILABLE/, rel);
242
- assert.match(text, /Do not type a model name/, rel);
243
- }
244
- });
245
-
246
- test('generate-adapter skill is Claude-safe and shipped adapters stay generic', () => {
247
- const skill = readRepo('adapters/generate-adapter/SKILL.md');
248
- const { fm } = parseFrontmatter(skill, 'generate-adapter');
249
- assert.doesNotMatch(fm, /^description:\s*>-?/m);
250
- assert.doesNotMatch(skill, /```mermaid/);
251
- assert.doesNotMatch(skill, /\$\\/);
252
- assert.doesNotMatch(skill, /spawn_subagent/);
253
- assert.match(skill, /Q1/);
254
- assert.match(skill, /Do not start Maker/);
255
- const catalog = readRepo('adapters/README.md');
256
- assert.match(catalog, /standard/);
257
- assert.match(catalog, /github/);
258
- assert.match(catalog, /gitlab/);
259
- const gitlab = readRepo('adapters/gitlab/README.md');
260
- assert.match(gitlab, /not the DOT adapter/);
261
- assert.doesNotMatch(gitlab, /Coreview/);
262
- assert.doesNotMatch(gitlab, /Mattermost/);
263
- const standard = readRepo('adapters/standard/README.md');
264
- assert.match(standard, /Judge `PASS`/);
265
- });
266
-
267
- test('Host compact map names four buckets and keeps 8-stage numbers', () => {
268
- const readme = readRepo('README.md');
269
- assert.match(readme, /Specify \(stages 0-1\)/);
270
- assert.match(readme, /Make \(stages 2-4\)/);
271
- assert.match(readme, /Review \(stages 5-7\)/);
272
- assert.match(readme, /Deliver \(stage 8\)/);
273
- assert.doesNotMatch(readme, /Later phase \(not this change\): host compact pipeline/);
274
- const grill = readRepo('core/grill-policy.md');
275
- assert.doesNotMatch(grill, /Later phase \(not this loop\): host compact pipeline/);
276
- for (const rel of [
277
- '.claude/skills/ai-engineering-loop/SKILL.md',
278
- '.grok/skills/ai-engineering-loop/SKILL.md',
279
- '.gemini/skills/ai-engineering-loop/SKILL.md',
280
- '.agents/workflows/ai-engineering-loop.md'
281
- ]) {
282
- const text = readRepo(rel);
283
- assert.match(text, /Specify \(stages 0-1\)/, rel);
284
- assert.match(text, /Make \(stages 2-4\)/, rel);
285
- assert.match(text, /Review \(stages 5-7\)/, rel);
286
- assert.match(text, /Deliver \(stage 8\)/, rel);
287
- assert.match(text, /8-stage/, rel);
288
- assert.match(text, /not a second OS/, rel);
289
- assert.match(text, /Do not skip Goal Contract, verification, Devil's Advocate, or Judge/, rel);
290
- }
291
- });
292
-
293
- test('Host skills Stage 0 runs sync-hosts before status', () => {
294
- for (const rel of [
295
- '.claude/skills/ai-engineering-loop/SKILL.md',
296
- '.grok/skills/ai-engineering-loop/SKILL.md',
297
- '.gemini/skills/ai-engineering-loop/SKILL.md',
298
- '.agents/workflows/ai-engineering-loop.md'
299
- ]) {
300
- const text = readRepo(rel);
301
- assert.match(text, /sync-hosts/, rel);
302
- }
303
- });
304
-
305
- test('Sloppy prompt drafts a Goal Contract; claimed-vs-reality gates DA', () => {
306
- const grill = readRepo('core/grill-policy.md');
307
- assert.match(grill, /Sloppy \/ underspecified prompts/);
308
- assert.match(grill, /Do not start Maker/);
309
- assert.match(grill, /Do not invent a second draft/);
310
- const verif = readRepo('core/verification-loop.md');
311
- assert.match(verif, /claimed-vs-reality\.md/);
312
- assert.match(verif, /seems green/);
313
- const judge = readRepo('agents/shared/judge.body.md');
314
- assert.match(judge, /claimed-vs-reality\.md/);
315
- for (const rel of [
316
- '.claude/skills/ai-engineering-loop/SKILL.md',
317
- '.grok/skills/ai-engineering-loop/SKILL.md',
318
- '.gemini/skills/ai-engineering-loop/SKILL.md',
319
- '.agents/workflows/ai-engineering-loop.md'
320
- ]) {
321
- const text = readRepo(rel);
322
- assert.match(text, /If the user prompt has no numbered AC/, rel);
323
- assert.match(text, /claimed-vs-reality\.md/, rel);
324
- assert.match(text, /Do not spawn Devil's Advocate if the file is missing/, rel);
325
- }
326
- });
327
-
328
- test('Grill freeze gate and idea menu are in the loop, not a parallel product', () => {
329
- const grill = readRepo('core/grill-policy.md');
330
- assert.match(grill, /Idea and menu requests/);
331
- assert.match(grill, /Do not implement/);
332
- assert.match(grill, /is \*\*not\*\* a freeze/);
333
- assert.match(grill, /numbered AC/);
334
- const contract = readRepo('core/goal-contract.md');
335
- assert.match(contract, /Chat is not the contract/);
336
- assert.match(contract, /The Chat Contract/);
337
- assert.match(contract, /The Wrong Artifact/);
338
- const judge = readRepo('agents/shared/judge.body.md');
339
- assert.match(judge, /Goal Contract \*\*file\*\* only/);
340
- assert.match(judge, /source grep/);
341
- const tdd = readRepo('policies/tdd-policy.md');
342
- assert.match(tdd, /Source grep/);
343
- for (const rel of [
344
- '.claude/skills/ai-engineering-loop/SKILL.md',
345
- '.grok/skills/ai-engineering-loop/SKILL.md',
346
- '.gemini/skills/ai-engineering-loop/SKILL.md',
347
- '.agents/workflows/ai-engineering-loop.md'
348
- ]) {
349
- const text = readRepo(rel);
350
- assert.match(text, /list a short menu and wait/, rel);
351
- assert.match(text, /Chat agreement is not freeze/, rel);
352
- }
353
- });
354
-
355
- test('Failure table is required to freeze, TDD, verify, and Judge', () => {
356
- const grill = readRepo('core/grill-policy.md');
357
- assert.match(grill, /failure table/);
358
- assert.match(grill, /sunny path is not frozen/);
359
- const contract = readRepo('core/goal-contract.md');
360
- assert.match(contract, /The Happy-Path Contract/);
361
- assert.match(contract, /Empty \/ omitted field/);
362
- const tdd = readRepo('policies/tdd-policy.md');
363
- assert.match(tdd, /Coverage as a map, not a score/);
364
- assert.match(tdd, /Happy-path only/);
365
- assert.match(tdd, /Coverage theater/);
366
- const verif = readRepo('core/verification-loop.md');
367
- assert.match(verif, /non-happy-path AC/);
368
- const judge = readRepo('agents/shared/judge.body.md');
369
- assert.match(judge, /happy-path-only/);
370
- const da = readRepo('agents/shared/devil-advocate.body.md');
371
- assert.match(da, /happy-path-only suite vs written failure table/);
372
- for (const rel of [
373
- '.claude/skills/ai-engineering-loop/SKILL.md',
374
- '.grok/skills/ai-engineering-loop/SKILL.md',
375
- '.gemini/skills/ai-engineering-loop/SKILL.md',
376
- '.agents/workflows/ai-engineering-loop.md'
377
- ]) {
378
- const text = readRepo(rel);
379
- assert.match(text, /failure table/, rel);
380
- assert.match(text, /One red test per AC row/, rel);
381
- assert.match(text, /Do not freeze sunny-path-only/, rel);
382
- assert.match(text, /blast radius: lifecycle sketch/, rel);
383
- }
384
- });
385
-
386
- test('Host skills absorb grill, TDD, glossary, and two-axis review without splitting the loop', () => {
387
- for (const rel of [
388
- '.claude/skills/ai-engineering-loop/SKILL.md',
389
- '.grok/skills/ai-engineering-loop/SKILL.md',
390
- '.agents/workflows/ai-engineering-loop.md'
391
- ]) {
392
- const text = readRepo(rel);
393
- assert.match(text, /grill-policy/, rel);
394
- assert.match(text, /tdd-policy/, rel);
395
- assert.match(text, /glossary\.md/, rel);
396
- assert.match(text, /Spec and Standards/, rel);
397
- assert.match(text, /adapter_type: dot/, rel);
398
- }
399
- const da = readRepo('agents/shared/devil-advocate.body.md');
400
- assert.match(da, /"axis": "spec"/);
401
- assert.match(da, /hardConvention/);
402
- assert.match(da, /standards/);
403
- const judge = readRepo('agents/shared/judge.body.md');
404
- assert.match(judge, /hardConvention is true/);
405
- assert.match(judge, /Do not merge Spec and Standards/);
406
- });
@@ -1,168 +0,0 @@
1
- const test = require('node:test');
2
- const assert = require('node:assert');
3
- const fs = require('fs');
4
- const os = require('os');
5
- const path = require('path');
6
- const { execFileSync } = require('child_process');
7
-
8
- const {
9
- applyGrokSkillOverlay,
10
- planHostSync,
11
- applyHostSync,
12
- summarizeHostSync
13
- } = require('../lib/sync-hosts.js');
14
-
15
- const ROOT = path.join(__dirname, '..');
16
- const CLI = path.join(ROOT, 'bin', 'ai-engineering-loop.js');
17
-
18
- function tmpHome() {
19
- return fs.mkdtempSync(path.join(os.tmpdir(), 'ael-home-'));
20
- }
21
-
22
- test('applyGrokSkillOverlay inserts user-invocable once', () => {
23
- const raw = '---\nname: demo\ndescription: x\n---\n\n# Body\n';
24
- const once = applyGrokSkillOverlay(raw);
25
- assert.match(once, /user-invocable: true/);
26
- const twice = applyGrokSkillOverlay(once);
27
- assert.strictEqual(twice, once);
28
- });
29
-
30
- test('planHostSync skips everything when no host roots exist', () => {
31
- const home = tmpHome();
32
- const plan = planHostSync({ packageRoot: ROOT, home });
33
- assert.ok(plan.length > 0);
34
- assert.ok(plan.every((item) => item.action === 'skip'));
35
- const reasons = new Set(plan.map((item) => item.reason));
36
- assert.ok(reasons.has('host-missing'));
37
- });
38
-
39
- test('sync upserts Claude AEL files but does not invent DOT skills', () => {
40
- const home = tmpHome();
41
- fs.mkdirSync(path.join(home, '.claude'));
42
- const results = applyHostSync({ packageRoot: ROOT, home });
43
- const claude = results.filter((item) => item.id === 'claude');
44
- assert.ok(claude.every((item) => item.action === 'copy'));
45
- assert.ok(fs.existsSync(path.join(home, '.claude/skills/ai-engineering-loop/SKILL.md')));
46
- assert.ok(fs.existsSync(path.join(home, '.claude/agents/devil-advocate.md')));
47
- assert.ok(fs.existsSync(path.join(home, '.claude/agents/judge.md')));
48
- assert.ok(fs.existsSync(path.join(home, '.claude/commands/ai-engineering-loop.md')));
49
- assert.ok(!fs.existsSync(path.join(home, '.claude/skills/dot-dev-workflow/SKILL.md')));
50
- assert.ok(fs.existsSync(path.join(home, '.claude/skills/task-impact-inquiry/SKILL.md')));
51
- assert.ok(!fs.existsSync(path.join(home, '.claude/settings.local.json')));
52
- });
53
-
54
- test('sync upserts task-impact-inquiry onto Claude, Grok, and Gemini', () => {
55
- const home = tmpHome();
56
- fs.mkdirSync(path.join(home, '.claude'));
57
- fs.mkdirSync(path.join(home, '.grok'));
58
- fs.mkdirSync(path.join(home, '.gemini'));
59
- applyHostSync({ packageRoot: ROOT, home });
60
- const claude = fs.readFileSync(path.join(home, '.claude/skills/task-impact-inquiry/SKILL.md'), 'utf8');
61
- const grok = fs.readFileSync(path.join(home, '.grok/skills/task-impact-inquiry/SKILL.md'), 'utf8');
62
- const gemini = fs.readFileSync(path.join(home, '.gemini/config/skills/task-impact-inquiry/SKILL.md'), 'utf8');
63
- assert.match(claude, /name: task-impact-inquiry/);
64
- assert.doesNotMatch(claude, /```mermaid/);
65
- assert.match(claude, /New-dev briefing/);
66
- assert.match(grok, /^user-invocable: true$/m);
67
- assert.match(grok, /Where it hits/);
68
- assert.match(gemini, /Business blast radius|blast radius/);
69
- });
70
-
71
- test('DOT skills update only when already installed', () => {
72
- const home = tmpHome();
73
- const dest = path.join(home, '.claude/skills/dot-dev-workflow/SKILL.md');
74
- fs.mkdirSync(path.dirname(dest), { recursive: true });
75
- fs.writeFileSync(dest, 'stale\n');
76
- const results = applyHostSync({ packageRoot: ROOT, home });
77
- const dotWf = results.find((item) => item.dest === dest);
78
- assert.strictEqual(dotWf.action, 'copy');
79
- assert.match(fs.readFileSync(dest, 'utf8'), /Not a substitute for ai-engineering-loop/);
80
- });
81
-
82
- test('Grok skill overlay keeps user-invocable', () => {
83
- const home = tmpHome();
84
- fs.mkdirSync(path.join(home, '.grok'));
85
- const dot = path.join(home, '.grok/skills/dot-dev-workflow/SKILL.md');
86
- fs.mkdirSync(path.dirname(dot), { recursive: true });
87
- fs.writeFileSync(dot, '---\nname: dot-dev-workflow\ndescription: old\n---\n\nold\n');
88
- applyHostSync({ packageRoot: ROOT, home });
89
- const skill = fs.readFileSync(path.join(home, '.grok/skills/ai-engineering-loop/SKILL.md'), 'utf8');
90
- const wf = fs.readFileSync(dot, 'utf8');
91
- assert.match(skill, /^user-invocable: true$/m);
92
- assert.match(wf, /^user-invocable: true$/m);
93
- });
94
-
95
- test('dry-run does not write; second apply is current', () => {
96
- const home = tmpHome();
97
- fs.mkdirSync(path.join(home, '.gemini'));
98
- const dry = applyHostSync({ packageRoot: ROOT, home, dryRun: true });
99
- const gemini = dry.find((item) => item.id === 'gemini');
100
- assert.strictEqual(gemini.action, 'copy');
101
- assert.ok(gemini.dryRun);
102
- assert.ok(!fs.existsSync(path.join(home, '.gemini/config/skills/ai-engineering-loop/SKILL.md')));
103
- applyHostSync({ packageRoot: ROOT, home });
104
- const again = applyHostSync({ packageRoot: ROOT, home });
105
- assert.strictEqual(summarizeHostSync(again.filter((item) => item.id === 'gemini')).current, 4);
106
- assert.strictEqual(summarizeHostSync(again.filter((item) => item.id === 'gemini')).copy, 0);
107
- });
108
-
109
- test('symlink destinations are left alone', () => {
110
- const home = tmpHome();
111
- const skillDir = path.join(home, '.claude/skills/ai-engineering-loop');
112
- fs.mkdirSync(skillDir, { recursive: true });
113
- const target = path.join(home, 'outside.md');
114
- fs.writeFileSync(target, 'keep me\n');
115
- fs.symlinkSync(target, path.join(skillDir, 'SKILL.md'));
116
- applyHostSync({ packageRoot: ROOT, home });
117
- assert.strictEqual(fs.readFileSync(target, 'utf8'), 'keep me\n');
118
- assert.ok(fs.lstatSync(path.join(skillDir, 'SKILL.md')).isSymbolicLink());
119
- });
120
-
121
- test('CLI sync-hosts --dry-run respects AEL_HOME', () => {
122
- const home = tmpHome();
123
- fs.mkdirSync(path.join(home, '.agents'));
124
- const out = execFileSync('node', [CLI, 'sync-hosts', '--dry-run'], {
125
- cwd: ROOT,
126
- encoding: 'utf8',
127
- env: { ...process.env, AEL_HOME: home }
128
- });
129
- assert.match(out, /dry-run/);
130
- assert.match(out, /would-copy|copy:/);
131
- assert.ok(!fs.existsSync(path.join(home, '.agents/judge.md')));
132
- });
133
-
134
- test('CLI help lists sync-hosts', () => {
135
- const out = execFileSync('node', [CLI, '--help'], { encoding: 'utf8' });
136
- assert.match(out, /sync-hosts/);
137
- assert.match(out, /generate-adapter/);
138
- assert.match(out, /generate-workflow/);
139
- });
140
-
141
- test('sync upserts generate-adapter onto Claude, Grok, and Gemini', () => {
142
- const home = tmpHome();
143
- fs.mkdirSync(path.join(home, '.claude'));
144
- fs.mkdirSync(path.join(home, '.grok'));
145
- fs.mkdirSync(path.join(home, '.gemini'));
146
- applyHostSync({ packageRoot: ROOT, home });
147
- const claude = fs.readFileSync(path.join(home, '.claude/skills/generate-adapter/SKILL.md'), 'utf8');
148
- const grok = fs.readFileSync(path.join(home, '.grok/skills/generate-adapter/SKILL.md'), 'utf8');
149
- assert.match(claude, /name: generate-adapter/);
150
- assert.doesNotMatch(claude, /```mermaid/);
151
- assert.match(grok, /^user-invocable: true$/m);
152
- });
153
-
154
- test('sync upserts generate-workflow onto Claude, Grok, and Gemini', () => {
155
- const home = tmpHome();
156
- fs.mkdirSync(path.join(home, '.claude'));
157
- fs.mkdirSync(path.join(home, '.grok'));
158
- fs.mkdirSync(path.join(home, '.gemini'));
159
- applyHostSync({ packageRoot: ROOT, home });
160
- const claude = fs.readFileSync(path.join(home, '.claude/skills/generate-workflow/SKILL.md'), 'utf8');
161
- const grok = fs.readFileSync(path.join(home, '.grok/skills/generate-workflow/SKILL.md'), 'utf8');
162
- const gemini = fs.readFileSync(path.join(home, '.gemini/config/skills/generate-workflow/SKILL.md'), 'utf8');
163
- assert.match(claude, /name: generate-workflow/);
164
- assert.doesNotMatch(claude, /```mermaid/);
165
- assert.match(claude, /lessons\.md/);
166
- assert.match(grok, /^user-invocable: true$/m);
167
- assert.match(gemini, /Do not start Maker/);
168
- });