ai-engineering-loop 1.0.21 → 1.2.1

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 (115) hide show
  1. package/.agents/workflows/ai-engineering-loop.md +8 -4
  2. package/.claude/skills/ai-engineering-loop/SKILL.md +15 -7
  3. package/.gemini/skills/ai-engineering-loop/SKILL.md +15 -7
  4. package/.grok/skills/ai-engineering-loop/SKILL.md +15 -7
  5. package/README.md +43 -3
  6. package/README.npm.md +9 -1
  7. package/SECURITY.md +29 -0
  8. package/SUPPORT.md +28 -0
  9. package/agents/judge.md +5 -5
  10. package/agents/maker.md +6 -6
  11. package/bin/ai-engineering-loop.js +472 -10
  12. package/core/artifact-gates.md +49 -0
  13. package/core/configuration-precedence.md +4 -4
  14. package/core/context-impact-assessment.md +1 -1
  15. package/core/definition-of-done.md +3 -3
  16. package/core/escalation-policy.md +2 -2
  17. package/core/goal-contract.md +2 -2
  18. package/core/iteration-policy.md +4 -4
  19. package/core/project-initialization.md +2 -2
  20. package/core/runtime-safety.md +75 -0
  21. package/core/verification-loop.md +1 -1
  22. package/evals/README.md +35 -0
  23. package/evals/cases/01-stale-verification.json +17 -0
  24. package/evals/cases/02-vague-verification.json +16 -0
  25. package/evals/cases/03-missing-ac-evidence.json +17 -0
  26. package/evals/cases/04-hallucinated-citation.json +17 -0
  27. package/evals/cases/05-prompt-injection.json +17 -0
  28. package/evals/cases/06-source-secret.json +16 -0
  29. package/evals/cases/07-log-secret.json +16 -0
  30. package/evals/cases/08-symlink-escape.json +16 -0
  31. package/evals/cases/09-authorization-bypass.json +16 -0
  32. package/evals/cases/10-payment-idempotency.json +16 -0
  33. package/evals/cases/11-concurrent-update.json +16 -0
  34. package/evals/cases/12-swallowed-error.json +16 -0
  35. package/evals/cases/13-happy-path-only.json +17 -0
  36. package/evals/cases/14-invalid-finding-axis.json +16 -0
  37. package/evals/cases/15-blocker-without-alternative.json +16 -0
  38. package/evals/cases/16-unsupported-pass.json +17 -0
  39. package/evals/cases/17-soft-standard.json +16 -0
  40. package/evals/cases/18-iteration-ceiling.json +17 -0
  41. package/evals/cases/19-safe-documentation-change.json +17 -0
  42. package/evals/cases/20-valid-boundary-feature.json +18 -0
  43. package/lib/budget.js +220 -0
  44. package/lib/doctor.js +111 -0
  45. package/lib/escalation.js +192 -0
  46. package/lib/evaluation.js +137 -0
  47. package/lib/gates.js +369 -0
  48. package/lib/orchestration.js +5 -1
  49. package/lib/package-audit.js +78 -0
  50. package/lib/run-state.js +260 -0
  51. package/lib/runtime-files.js +53 -0
  52. package/lib/runtime-policy.js +118 -0
  53. package/lib/safe-context.js +194 -0
  54. package/lib/sandbox.js +305 -0
  55. package/lib/sync-hosts.js +6 -5
  56. package/package.json +16 -10
  57. package/policies/finding-policy.md +2 -2
  58. package/policies/model-escalation.md +41 -0
  59. package/policies/no-progress-policy.md +2 -2
  60. package/profiles/README.md +5 -5
  61. package/profiles/backend-api.md +1 -1
  62. package/profiles/library.md +1 -1
  63. package/profiles/mobile-app.md +1 -1
  64. package/profiles/monorepo.md +1 -1
  65. package/profiles/web-app.md +1 -1
  66. package/schemas/delivery.schema.json +15 -0
  67. package/schemas/finding-ledger.schema.json +27 -0
  68. package/schemas/goal-contract.schema.json +32 -0
  69. package/schemas/report.schema.json +17 -0
  70. package/schemas/verdict.schema.json +17 -0
  71. package/schemas/verification.schema.json +32 -0
  72. package/docs/antigravity-feasibility.md +0 -92
  73. package/docs/claude-code-feasibility.md +0 -80
  74. package/docs/grok-cli-feasibility.md +0 -99
  75. package/docs/migration-plan.md +0 -70
  76. package/examples/backend-api/payment-idempotency/README.md +0 -33
  77. package/examples/backend-api/payment-idempotency/goal-contract.md +0 -33
  78. package/examples/backend-api/payment-idempotency/judge-verdict.md +0 -28
  79. package/examples/backend-api/payment-idempotency/review-findings.md +0 -50
  80. package/examples/dot/status-display/README.md +0 -23
  81. package/examples/dot/status-display/delivery-report.md +0 -41
  82. package/examples/dot/status-display/goal-contract.md +0 -46
  83. package/examples/dot/status-display/judge-verdict.md +0 -44
  84. package/examples/dot/status-display/review-findings.md +0 -63
  85. package/examples/initialization/README.md +0 -19
  86. package/examples/initialization/discovery-trace.md +0 -63
  87. package/examples/initialization/generated-context.md +0 -110
  88. package/examples/mobile-app/offline-sync-queue/README.md +0 -33
  89. package/examples/mobile-app/offline-sync-queue/goal-contract.md +0 -32
  90. package/examples/mobile-app/offline-sync-queue/judge-verdict.md +0 -27
  91. package/examples/mobile-app/offline-sync-queue/review-findings.md +0 -30
  92. package/scripts/init.sh +0 -106
  93. package/templates/repo-config/adapter.md +0 -11
  94. package/templates/repo-config/adr-readme.md +0 -33
  95. package/templates/repo-config/architecture.md +0 -15
  96. package/templates/repo-config/claude-permissions.json +0 -10
  97. package/templates/repo-config/config.md +0 -11
  98. package/templates/repo-config/conventions.md +0 -16
  99. package/templates/repo-config/glossary.md +0 -18
  100. package/templates/repo-config/lessons.md +0 -8
  101. package/templates/repo-config/verification.md +0 -13
  102. package/templates/repo-config/workflow.md +0 -25
  103. package/tests/capability-selection.test.js +0 -207
  104. package/tests/claimed-vs-reality.test.js +0 -27
  105. package/tests/dot-branch-policy.test.js +0 -65
  106. package/tests/generate-adapter.test.js +0 -80
  107. package/tests/generate-workflow.test.js +0 -180
  108. package/tests/grok-runtime.test.js +0 -201
  109. package/tests/intern-catalog.test.js +0 -72
  110. package/tests/living-context.test.js +0 -61
  111. package/tests/no-company-leak.test.js +0 -82
  112. package/tests/orchestration.test.js +0 -368
  113. package/tests/qa-delivery-template.test.js +0 -90
  114. package/tests/skill-host-compat.test.js +0 -406
  115. package/tests/sync-hosts.test.js +0 -168
@@ -1,13 +0,0 @@
1
- # Project Verification Commands
2
-
3
- ## Commands
4
- - **test_unit**: `npm run test:unit`
5
- - **test_all**: `npm run test`
6
- - **typecheck**: `npx tsc --noEmit`
7
- - **lint**: `npx eslint --fix`
8
- - **build**: `npm run build`
9
- - **e2e**: `npm run test:e2e` # Optional
10
-
11
- ## Verification Notes
12
- - Unit test suite should complete within 30 seconds.
13
- - Database integration tests require test container (`docker compose up -d postgres-test`).
@@ -1,25 +0,0 @@
1
- # Loop Overlay
2
-
3
- This file adds hooks around the AI Engineering Loop. It does not replace the 8-stage OS.
4
-
5
- ## Required (cannot skip)
6
- - Goal Contract
7
- - verification
8
- - Devil's Advocate
9
- - Judge
10
-
11
- ## Hooks
12
- - **before_grill**: none
13
- - **after_freeze**: none
14
- - **after_pass**: none
15
-
16
- ## Maker intern
17
- - **maker_intern**: none
18
-
19
- Default `none` = parent is Maker. Pick `maker_intern` from this host's catalog (`grok models` or `/models`). Do not type a guessed slug. AEL does not store intern API keys. Devil's Advocate and Judge stay on the parent. Intern cannot skip them.
20
-
21
- ## Optional skips
22
- none
23
-
24
- Allowed optional skips: `blast_radius` (when the change is not business logic), `generate_adapter` (when adapter.md already exists).
25
- Do not list Goal Contract, verification, Devil's Advocate, or Judge here.
@@ -1,207 +0,0 @@
1
- const test = require('node:test');
2
- const assert = require('node:assert');
3
- const {
4
- EXECUTION_MODES,
5
- createCapabilityEvidence,
6
- selectExecutionMode,
7
- formatExecutionReport
8
- } = require('../lib/orchestration.js');
9
-
10
- // Test 1: Distinction between CONFIGURATION_SUPPORTED and INVOCATION_AVAILABLE / EXECUTION_PROVEN
11
- test('1. CONFIGURATION_SUPPORTED = true, INVOCATION_AVAILABLE = false, EXECUTION_PROVEN = false resolves to CONTEXT_ISOLATION_ONLY', () => {
12
- const antigravityDiscovery = {
13
- nativeSubagent: createCapabilityEvidence({
14
- mechanism: 'antigravity-custom-agent-config',
15
- classification: 'CONFIGURATION_SUPPORTED_WITHOUT_INVOCATION_TOOL',
16
- configurationSupported: true, // .agents/plugins/.../AGENT.md with subagent: true is discoverable
17
- invocationAvailable: false, // No invoke_subagent tool in active prompt
18
- executionProven: false, // No child execution occurred
19
- isDocumentationOnly: false,
20
- reason: 'Antigravity custom subagent configuration is supported/discoverable, but native subagent invocation is not exposed or executable from the current standalone agent runtime'
21
- }),
22
- sdkAgent: createCapabilityEvidence({
23
- mechanism: 'google-antigravity-python-sdk',
24
- classification: 'UNAVAILABLE',
25
- available: false,
26
- reason: 'Package not installed in Python environment'
27
- }),
28
- headlessProcessAgent: createCapabilityEvidence({
29
- mechanism: 'claude-code-cli',
30
- classification: 'UNAVAILABLE',
31
- available: false,
32
- reason: 'CLI unauthenticated'
33
- }),
34
- artifactIsolation: createCapabilityEvidence({
35
- mechanism: 'clean-slate-artifact-barrier',
36
- classification: 'CONTEXT_ISOLATION_ONLY',
37
- available: true,
38
- commandOrApi: 'buildReviewContextBarrier',
39
- result: 'Verified 100% prompt history exclusion',
40
- modelExecutionProven: false,
41
- independentContextProven: false
42
- })
43
- };
44
-
45
- const selected = selectExecutionMode(antigravityDiscovery);
46
- assert.strictEqual(selected.id, EXECUTION_MODES.CONTEXT_ISOLATION_ONLY.id);
47
- assert.strictEqual(selected.isIndependentExecutionProven, false);
48
- });
49
-
50
- // Test 2: browser_subagent is browser automation and CANNOT activate LLM subagent execution
51
- test('2. browser_subagent cannot activate LLM subagent execution mode', () => {
52
- const browserSubagentEvidence = createCapabilityEvidence({
53
- mechanism: 'browser_subagent-tool',
54
- classification: 'BROWSER_AUTOMATION_TOOL',
55
- available: true,
56
- isBrowserAutomationOnly: true,
57
- reason: 'browser_subagent is scoped to DOM/browser navigation automation, not general LLM code review'
58
- });
59
-
60
- const registry = {
61
- nativeSubagent: browserSubagentEvidence,
62
- artifactIsolation: createCapabilityEvidence({
63
- mechanism: 'clean-slate-artifact-barrier',
64
- classification: 'CONTEXT_ISOLATION_ONLY',
65
- available: true
66
- })
67
- };
68
-
69
- const selected = selectExecutionMode(registry);
70
- assert.strictEqual(selected.id, EXECUTION_MODES.CONTEXT_ISOLATION_ONLY.id);
71
- });
72
-
73
- // Test 3: agentapi.send-message is IPC communication and cannot activate an agent capability
74
- test('3. agentapi.send-message is IPC_MESSAGE_DISPATCH and cannot activate agent capability', () => {
75
- const ipcEvidence = createCapabilityEvidence({
76
- mechanism: 'antigravity-agentapi-send-message',
77
- classification: 'IPC_MESSAGE_DISPATCH',
78
- available: true,
79
- commandOrApi: 'agentapi send-message',
80
- result: 'Message delivered to existing conversation over gRPC',
81
- modelExecutionProven: false
82
- });
83
-
84
- const registry = {
85
- nativeSubagent: ipcEvidence,
86
- artifactIsolation: createCapabilityEvidence({
87
- mechanism: 'clean-slate-artifact-barrier',
88
- classification: 'CONTEXT_ISOLATION_ONLY',
89
- available: true
90
- })
91
- };
92
-
93
- const selected = selectExecutionMode(registry);
94
- assert.strictEqual(selected.id, EXECUTION_MODES.CONTEXT_ISOLATION_ONLY.id);
95
- });
96
-
97
- // Test 4: agentapi.new-conversation failure cannot activate an agent capability
98
- test('4. agentapi.new-conversation failure cannot activate an agent capability', () => {
99
- const rpcFailedEvidence = createCapabilityEvidence({
100
- mechanism: 'antigravity-agentapi-new-conversation',
101
- classification: 'UNAVAILABLE',
102
- available: false,
103
- commandOrApi: 'agentapi new-conversation',
104
- result: 'rpc error: project_id is required when providing project_env_config',
105
- modelExecutionProven: false,
106
- reason: 'new-conversation reaches the Language Server but is blocked by project_id authorization in the current standalone workspace'
107
- });
108
-
109
- const registry = {
110
- nativeSubagent: rpcFailedEvidence,
111
- artifactIsolation: createCapabilityEvidence({
112
- mechanism: 'clean-slate-artifact-barrier',
113
- classification: 'CONTEXT_ISOLATION_ONLY',
114
- available: true
115
- })
116
- };
117
-
118
- const selected = selectExecutionMode(registry);
119
- assert.strictEqual(selected.id, EXECUTION_MODES.CONTEXT_ISOLATION_ONLY.id);
120
- });
121
-
122
- // Test 5: Missing child model response cannot activate an independent agent
123
- test('5. Missing model response cannot activate an independent agent', () => {
124
- const threadWithoutModelResponse = createCapabilityEvidence({
125
- mechanism: 'child-thread-without-response',
126
- classification: 'THREAD_CREATED_WITHOUT_RESPONSE',
127
- available: true,
128
- childConversationId: 'child-conv-1234',
129
- modelExecutionProven: false, // No response produced
130
- independentContextProven: false
131
- });
132
-
133
- const registry = {
134
- nativeSubagent: threadWithoutModelResponse,
135
- artifactIsolation: createCapabilityEvidence({
136
- mechanism: 'clean-slate-artifact-barrier',
137
- classification: 'CONTEXT_ISOLATION_ONLY',
138
- available: true
139
- })
140
- };
141
-
142
- const selected = selectExecutionMode(registry);
143
- assert.strictEqual(selected.id, EXECUTION_MODES.CONTEXT_ISOLATION_ONLY.id);
144
- });
145
-
146
- // Test 6: Truthful report format strictly produces the required 4-line disclosure
147
- test('6. Truthful report format strictly produces the required 4-line disclosure', () => {
148
- const capabilityRegistry = {
149
- nativeSubagent: {
150
- invocationAvailable: false
151
- }
152
- };
153
-
154
- const report = formatExecutionReport({
155
- selectedMode: EXECUTION_MODES.CONTEXT_ISOLATION_ONLY,
156
- capabilityRegistry
157
- });
158
-
159
- const expected = [
160
- 'Execution Mode: CONTEXT_ISOLATION_ONLY',
161
- 'Independent LLM Execution: NOT PROVEN',
162
- 'Native Subagent Invocation: UNAVAILABLE',
163
- 'Review Method: Clean-Slate Artifact Isolation Barrier'
164
- ].join('\n');
165
-
166
- assert.strictEqual(report, expected);
167
- });
168
-
169
- // Test 7: TRUE_INDEPENDENT_AGENT is selected ONLY when full execution evidence is proven
170
- test('7. TRUE_INDEPENDENT_AGENT is selected ONLY when child session, response, identity, and context are proven', () => {
171
- const fullyProvenEvidence = createCapabilityEvidence({
172
- mechanism: 'native-subagent-runtime-tool',
173
- classification: 'TRUE_INDEPENDENT_AGENT',
174
- available: true,
175
- commandOrApi: 'invoke_subagent',
176
- childConversationId: 'child-session-9876',
177
- executionIdentity: 'grpc-stream-552',
178
- childModelResponse: 'CHILD_AGENT_EXECUTION_OK',
179
- modelExecutionProven: true,
180
- independentContextProven: true,
181
- historyInherited: false,
182
- result: 'Actual child response captured: CHILD_AGENT_EXECUTION_OK'
183
- });
184
-
185
- const registry = {
186
- nativeSubagent: fullyProvenEvidence,
187
- artifactIsolation: { available: true }
188
- };
189
-
190
- const selected = selectExecutionMode(registry);
191
- assert.strictEqual(selected.id, EXECUTION_MODES.TRUE_INDEPENDENT_AGENT.id);
192
- assert.strictEqual(selected.isIndependentExecutionProven, true);
193
- });
194
-
195
- // Test 8: Fallback to UNAVAILABLE when all modes including artifact isolation are unavailable
196
- test('8. Fallback to UNAVAILABLE when all modes are false', () => {
197
- const emptyRegistry = {
198
- nativeSubagent: { available: false },
199
- sdkAgent: { available: false },
200
- headlessProcessAgent: { available: false },
201
- artifactIsolation: { available: false }
202
- };
203
-
204
- const selected = selectExecutionMode(emptyRegistry);
205
- assert.strictEqual(selected.id, EXECUTION_MODES.UNAVAILABLE.id);
206
- assert.strictEqual(selected.isIndependentExecutionProven, false);
207
- });
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- const test = require('node:test');
4
- const assert = require('node:assert');
5
- const { parseClaimedVsReality, readyForDa } = require('../lib/claimed-vs-reality.js');
6
-
7
- test('AC-4 filled table is ready for DA', () => {
8
- const md = `# Claimed vs Reality
9
-
10
- | AC | Claimed | Reality |
11
- |---|---|---|
12
- | AC-1 | overlay writes workflow.md | npm test exit 0; AC-1 test passed |
13
- | AC-2 | missing overlay is default | npm test exit 0; AC-2 test passed |
14
- `;
15
- const { rows } = parseClaimedVsReality(md);
16
- assert.strictEqual(rows.length, 2);
17
- assert.strictEqual(readyForDa(md), true);
18
- });
19
-
20
- test('AC-5 empty Reality or seems-green is not ready for DA', () => {
21
- assert.strictEqual(readyForDa(''), false);
22
- assert.strictEqual(readyForDa('# Claimed vs Reality\n'), false);
23
- const emptyReality = `| AC | Claimed | Reality |\n|---|---|---|\n| AC-1 | tests pass | |\n`;
24
- assert.strictEqual(readyForDa(emptyReality), false);
25
- const seems = `| AC | Claimed | Reality |\n|---|---|---|\n| AC-1 | tests pass | seems green |\n`;
26
- assert.strictEqual(readyForDa(seems), false);
27
- });
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- const test = require('node:test');
4
- const assert = require('node:assert');
5
- const fs = require('fs');
6
- const path = require('path');
7
-
8
- const ROOT = path.join(__dirname, '..');
9
-
10
- function readRepo(rel) {
11
- return fs.readFileSync(path.join(ROOT, rel), 'utf8');
12
- }
13
-
14
- const MULTI = 'adapters/dot/multi-branch.md';
15
- const README = 'adapters/dot/README.md';
16
- const WORKFLOW = 'adapters/dot/skills/dot-dev-workflow/SKILL.md';
17
-
18
- test('AC-1 unrelated HEAD and in-use develop: new topic branch from origin/develop after fetch/pull', () => {
19
- const text = `${readRepo(MULTI)}\n${readRepo(WORKFLOW)}`;
20
- assert.match(text, /unrelated|not related/i);
21
- assert.match(text, /git fetch origin/);
22
- assert.match(text, /origin\/develop/);
23
- assert.match(text, /git checkout -b/);
24
- assert.match(text, /Do not `git pull` into the current HEAD/);
25
- assert.doesNotMatch(readRepo(MULTI), /git pull origin develop/);
26
- assert.match(text, /HEAD being `main` does not override an in-use `develop` default/);
27
- });
28
-
29
- test('AC-2 related feat/fix branch stays; do not create another topic branch or three MRs', () => {
30
- const text = `${readRepo(MULTI)}\n${readRepo(WORKFLOW)}`;
31
- assert.match(text, /feat\//);
32
- assert.match(text, /fix\//);
33
- assert.match(text, /Stay on that branch|keep the current branch/i);
34
- assert.match(text, /Do not create a new topic branch/i);
35
- assert.match(text, /Do not open three MRs|one MR/i);
36
- });
37
-
38
- test('AC-3 main or unused leftover develop: new topic branch from origin/main', () => {
39
- const text = `${readRepo(MULTI)}\n${readRepo(WORKFLOW)}`;
40
- assert.match(text, /unused leftover/i);
41
- assert.match(text, /origin\/main/);
42
- assert.match(text, /Do not force leftover develop/);
43
- assert.match(text, /even if HEAD is `develop`/);
44
- });
45
-
46
- test('AC-4 generic GitHub/GitLab stay non-DOT; extra envs only if adapter.md lists them', () => {
47
- const gitlab = readRepo('adapters/gitlab/README.md');
48
- const github = readRepo('adapters/github/README.md');
49
- assert.match(gitlab, /not the DOT adapter/);
50
- assert.match(gitlab, /No extra environment cherry-picks unless/);
51
- assert.doesNotMatch(gitlab, /Coreview/);
52
- assert.match(github, /Extra branches, review bots, and chat are \*\*off\*\*/);
53
- });
54
-
55
- test('AC-5 chat setuju is not propagate; extra env MRs only if named this turn', () => {
56
- const text = `${readRepo(MULTI)}\n${readRepo(WORKFLOW)}\n${readRepo(README)}`;
57
- assert.match(text, /setuju/);
58
- assert.match(text, /this turn/);
59
- assert.match(text, /Do not cherry-pick to `staging` or `develop` unless/i);
60
- const workflow = readRepo(WORKFLOW);
61
- assert.doesNotMatch(workflow, /```mermaid/);
62
- assert.doesNotMatch(workflow, /commit, propagate, reply/);
63
- assert.match(workflow, /push to the same topic MR/);
64
- assert.doesNotMatch(readRepo(README), /fix & propagate/);
65
- });
@@ -1,80 +0,0 @@
1
- 'use strict';
2
-
3
- const test = require('node:test');
4
- const assert = require('node:assert');
5
- const fs = require('fs');
6
- const os = require('os');
7
- const path = require('path');
8
- const { execFileSync } = require('child_process');
9
-
10
- const {
11
- recommendType,
12
- detectAdapterHints,
13
- writeShippedAdapter,
14
- parseTypeArg
15
- } = require('../lib/generate-adapter.js');
16
-
17
- const CLI = path.join(__dirname, '..', 'bin', 'ai-engineering-loop.js');
18
-
19
- function tmpRepo() {
20
- return fs.mkdtempSync(path.join(os.tmpdir(), 'ael-adapter-'));
21
- }
22
-
23
- test('recommendType maps github and gitlab remotes; unknown is standard', () => {
24
- assert.strictEqual(recommendType('git@github.com:acme/app.git'), 'github');
25
- assert.strictEqual(recommendType('https://gitlab.com/acme/app.git'), 'gitlab');
26
- assert.strictEqual(recommendType(''), 'standard');
27
- assert.strictEqual(recommendType('git@example.com:acme/app.git'), 'standard');
28
- });
29
-
30
- test('writeShippedAdapter writes adapter.md for --type github', () => {
31
- const dir = tmpRepo();
32
- const dest = writeShippedAdapter(dir, {
33
- type: 'github',
34
- hints: { remote: 'https://github.com/acme/app.git', ciProvider: 'GitHub Actions' }
35
- });
36
- const text = fs.readFileSync(dest, 'utf8');
37
- assert.match(text, /adapter_type\*\*: "github"/);
38
- assert.match(text, /adapters\/github\//);
39
- assert.doesNotMatch(text, /Mattermost/);
40
- });
41
-
42
- test('writeShippedAdapter rejects unknown types', () => {
43
- const dir = tmpRepo();
44
- assert.throws(
45
- () => writeShippedAdapter(dir, { type: 'bitbucket', hints: { remote: '', ciProvider: 'none' } }),
46
- /Unknown adapter type/
47
- );
48
- });
49
-
50
- test('parseTypeArg reads --type', () => {
51
- assert.strictEqual(parseTypeArg(['generate-adapter', '--type', 'gitlab']), 'gitlab');
52
- assert.strictEqual(parseTypeArg(['generate-adapter']), null);
53
- });
54
-
55
- test('CLI generate-adapter without --type prints grill protocol', () => {
56
- const dir = tmpRepo();
57
- const out = execFileSync('node', [CLI, 'generate-adapter'], { cwd: dir, encoding: 'utf8' });
58
- assert.match(out, /recommended:/);
59
- assert.match(out, /generate-adapter/);
60
- assert.match(out, /Q1-Q5/);
61
- assert.ok(!fs.existsSync(path.join(dir, '.ai-engineering-loop', 'adapter.md')));
62
- });
63
-
64
- test('CLI generate-adapter --type standard writes adapter.md', () => {
65
- const dir = tmpRepo();
66
- const out = execFileSync('node', [CLI, 'generate-adapter', '--type', 'standard'], {
67
- cwd: dir,
68
- encoding: 'utf8'
69
- });
70
- assert.match(out, /Wrote:/);
71
- const text = fs.readFileSync(path.join(dir, '.ai-engineering-loop', 'adapter.md'), 'utf8');
72
- assert.match(text, /adapter_type\*\*: "standard"/);
73
- });
74
-
75
- test('detectAdapterHints reads existing adapter.md', () => {
76
- const dir = tmpRepo();
77
- writeShippedAdapter(dir, { type: 'gitlab', hints: { remote: '', ciProvider: 'none' } });
78
- const hints = detectAdapterHints(dir);
79
- assert.strictEqual(hints.existingType, 'gitlab');
80
- });
@@ -1,180 +0,0 @@
1
- 'use strict';
2
-
3
- const test = require('node:test');
4
- const assert = require('node:assert');
5
- const fs = require('fs');
6
- const os = require('os');
7
- const path = require('path');
8
- const { execFileSync } = require('child_process');
9
-
10
- const {
11
- parseWorkflowFile,
12
- parseWorkflowMarkdown,
13
- writeWorkflowOverlay,
14
- assertNoRequiredSkip,
15
- routeDurableNote,
16
- parseWriteArg,
17
- normalizeMakerIntern,
18
- workflowMarkdown
19
- } = require('../lib/generate-workflow.js');
20
-
21
- const CLI = path.join(__dirname, '..', 'bin', 'ai-engineering-loop.js');
22
-
23
- function tmpRepo() {
24
- return fs.mkdtempSync(path.join(os.tmpdir(), 'ael-workflow-'));
25
- }
26
-
27
- test('AC-1 writeWorkflowOverlay writes workflow.md and empty lessons.md', () => {
28
- const dir = tmpRepo();
29
- const wrote = writeWorkflowOverlay(dir, {});
30
- const workflow = fs.readFileSync(wrote.workflow, 'utf8');
31
- const lessons = fs.readFileSync(wrote.lessons, 'utf8');
32
- assert.match(workflow, /Goal Contract/);
33
- assert.match(workflow, /Devil's Advocate/);
34
- assert.match(workflow, /Judge/);
35
- assert.match(workflow, /verification/);
36
- assert.match(workflow, /before_grill/);
37
- assert.doesNotMatch(workflow, /skip Devil's Advocate/i);
38
- assert.match(lessons, /# Lessons/);
39
- assert.doesNotMatch(lessons, /\| 20\d{2}-/);
40
- });
41
-
42
- test('AC-2 missing workflow.md returns default overlay', () => {
43
- const dir = tmpRepo();
44
- const parsed = parseWorkflowFile(dir);
45
- assert.strictEqual(parsed.missing, true);
46
- assert.strictEqual(parsed.hooks.before_grill, 'none');
47
- assert.strictEqual(parsed.hooks.after_freeze, 'none');
48
- assert.strictEqual(parsed.hooks.after_pass, 'none');
49
- assert.deepStrictEqual(parsed.optionalSkips, []);
50
- assert.deepStrictEqual(parsed.required, [
51
- 'goal_contract',
52
- 'verification',
53
- 'devil_advocate',
54
- 'judge'
55
- ]);
56
- });
57
-
58
- test('AC-3 skip devil_advocate is rejected and does not write', () => {
59
- const dir = tmpRepo();
60
- assert.throws(
61
- () => writeWorkflowOverlay(dir, { optionalSkips: ['devil_advocate'] }),
62
- /cannot skip/
63
- );
64
- assert.ok(!fs.existsSync(path.join(dir, '.ai-engineering-loop', 'workflow.md')));
65
- assert.throws(() => assertNoRequiredSkip(['judge']), /cannot skip/);
66
- assert.throws(() => assertNoRequiredSkip(['goal_contract']), /cannot skip/);
67
- assert.throws(() => assertNoRequiredSkip(['verification']), /cannot skip/);
68
- assert.doesNotThrow(() => assertNoRequiredSkip(['blast_radius']));
69
- });
70
-
71
- test('AC-4 routeDurableNote sends term to glossary and process to lessons', () => {
72
- assert.strictEqual(routeDurableNote('term'), 'glossary.md');
73
- assert.strictEqual(routeDurableNote('process'), 'lessons.md');
74
- assert.strictEqual(routeDurableNote('convention'), 'conventions.md');
75
- assert.strictEqual(routeDurableNote('adr'), 'adrs/');
76
- });
77
-
78
- test('AC-5 --write does not overwrite filled lessons.md', () => {
79
- const dir = tmpRepo();
80
- const ctx = path.join(dir, '.ai-engineering-loop');
81
- fs.mkdirSync(ctx, { recursive: true });
82
- const lessonsPath = path.join(ctx, 'lessons.md');
83
- fs.writeFileSync(lessonsPath, '# Lessons\n\n| Date | Lesson | Do not |\n|---|---|---|\n| 2026-08-30 | Keep the Figma step | skip Figma |\n');
84
- writeWorkflowOverlay(dir, {});
85
- const after = fs.readFileSync(lessonsPath, 'utf8');
86
- assert.match(after, /Keep the Figma step/);
87
- assert.ok(fs.existsSync(path.join(ctx, 'workflow.md')));
88
- });
89
-
90
- test('parseWriteArg reads --write', () => {
91
- assert.strictEqual(parseWriteArg(['generate-workflow', '--write']), true);
92
- assert.strictEqual(parseWriteArg(['generate-workflow']), false);
93
- });
94
-
95
- test('CLI generate-workflow without --write prints grill protocol', () => {
96
- const dir = tmpRepo();
97
- const out = execFileSync('node', [CLI, 'generate-workflow'], { cwd: dir, encoding: 'utf8' });
98
- assert.match(out, /generate-workflow/);
99
- assert.match(out, /Q1-Q6/);
100
- assert.match(out, /Do not type a model name/);
101
- assert.ok(!fs.existsSync(path.join(dir, '.ai-engineering-loop', 'workflow.md')));
102
- });
103
-
104
- test('CLI generate-workflow --write writes overlay files', () => {
105
- const dir = tmpRepo();
106
- const out = execFileSync('node', [CLI, 'generate-workflow', '--write'], {
107
- cwd: dir,
108
- encoding: 'utf8'
109
- });
110
- assert.match(out, /Wrote:/);
111
- assert.ok(fs.existsSync(path.join(dir, '.ai-engineering-loop', 'workflow.md')));
112
- assert.ok(fs.existsSync(path.join(dir, '.ai-engineering-loop', 'lessons.md')));
113
- });
114
-
115
- test('compact pipeline does not add overlay pipeline or Q7', () => {
116
- const text = workflowMarkdown();
117
- assert.doesNotMatch(text, /\*\*pipeline\*\*/);
118
- assert.doesNotMatch(text, /## Pipeline/);
119
- const skill = fs.readFileSync(
120
- path.join(__dirname, '..', 'adapters', 'generate-workflow', 'SKILL.md'),
121
- 'utf8'
122
- );
123
- assert.doesNotMatch(skill, /Q7/);
124
- assert.match(skill, /Q1–Q6|Q1-Q6|Q1\.\.Q6|Q6/);
125
- });
126
-
127
- test('AC-1 default overlay maker_intern is none', () => {
128
- const dir = tmpRepo();
129
- const wrote = writeWorkflowOverlay(dir, {});
130
- const workflow = fs.readFileSync(wrote.workflow, 'utf8');
131
- const parsed = parseWorkflowFile(dir);
132
- assert.match(workflow, /\*\*maker_intern\*\*: none/);
133
- assert.strictEqual(parsed.makerIntern, 'none');
134
- assert.match(workflowMarkdown(), /host's catalog/);
135
- assert.match(workflowMarkdown(), /Do not type a guessed slug/);
136
- });
137
-
138
- test('AC-2 missing workflow.md makerIntern is none', () => {
139
- const dir = tmpRepo();
140
- const parsed = parseWorkflowFile(dir);
141
- assert.strictEqual(parsed.missing, true);
142
- assert.strictEqual(parsed.makerIntern, 'none');
143
- });
144
-
145
- test('AC-3 empty or None intern normalizes to none', () => {
146
- assert.strictEqual(normalizeMakerIntern(''), 'none');
147
- assert.strictEqual(normalizeMakerIntern('none'), 'none');
148
- assert.strictEqual(normalizeMakerIntern('None'), 'none');
149
- const parsed = parseWorkflowMarkdown('# Loop Overlay\n\n- **maker_intern**:\n');
150
- assert.strictEqual(parsed.makerIntern, 'none');
151
- });
152
-
153
- test('AC-4 gemini-flash and haiku are valid intern labels', () => {
154
- const dir = tmpRepo();
155
- writeWorkflowOverlay(dir, { makerIntern: 'gemini-flash' });
156
- assert.strictEqual(parseWorkflowFile(dir).makerIntern, 'gemini-flash');
157
- writeWorkflowOverlay(dir, { makerIntern: 'haiku' });
158
- assert.strictEqual(parseWorkflowFile(dir).makerIntern, 'haiku');
159
- const text = workflowMarkdown();
160
- assert.doesNotMatch(text, /must use qwen/i);
161
- assert.doesNotMatch(text, /must use deepseek/i);
162
- assert.doesNotMatch(text, /required: qwen/i);
163
- });
164
-
165
- test('AC-5 intern label does not allow skipping Devil\'s Advocate', () => {
166
- const dir = tmpRepo();
167
- assert.throws(
168
- () => writeWorkflowOverlay(dir, { makerIntern: 'qwen', optionalSkips: ['devil_advocate'] }),
169
- /cannot skip/
170
- );
171
- assert.ok(!fs.existsSync(path.join(dir, '.ai-engineering-loop', 'workflow.md')));
172
- });
173
-
174
- test('AC-6 intern rejects API keys and URLs', () => {
175
- const dir = tmpRepo();
176
- assert.throws(() => writeWorkflowOverlay(dir, { makerIntern: 'sk-abc' }), /not a key or URL/);
177
- assert.throws(() => writeWorkflowOverlay(dir, { makerIntern: 'https://api.example.com' }), /not a key or URL/);
178
- assert.throws(() => normalizeMakerIntern('openai_api_key'), /not a key or URL/);
179
- assert.ok(!fs.existsSync(path.join(dir, '.ai-engineering-loop', 'workflow.md')));
180
- });