ai-engineering-loop 1.0.15 → 1.0.17
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.
- package/.agents/workflows/ai-engineering-loop.md +1 -1
- package/.claude/commands/ai-engineering-loop.md +1 -1
- package/.claude/skills/ai-engineering-loop/SKILL.md +5 -3
- package/.gemini/skills/ai-engineering-loop/SKILL.md +5 -3
- package/.grok/commands/ai-engineering-loop.md +1 -1
- package/.grok/skills/ai-engineering-loop/SKILL.md +4 -4
- package/README.md +23 -10
- package/adapters/README.md +29 -0
- package/adapters/generate-adapter/SKILL.md +123 -0
- package/adapters/generate-workflow/SKILL.md +128 -0
- package/adapters/github/README.md +28 -0
- package/adapters/github/pull-request.md +23 -0
- package/adapters/gitlab/README.md +28 -0
- package/adapters/gitlab/merge-request.md +26 -0
- package/adapters/standard/README.md +44 -0
- package/bin/ai-engineering-loop.js +63 -4
- package/core/context-impact-assessment.md +1 -0
- package/core/repo-config-schema.md +14 -1
- package/lib/generate-adapter.js +118 -0
- package/lib/generate-workflow.js +203 -0
- package/lib/sync-hosts.js +7 -1
- package/package.json +1 -1
- package/templates/repo-config/adapter.md +1 -1
- package/templates/repo-config/lessons.md +8 -0
- package/templates/repo-config/workflow.md +20 -0
- package/tests/generate-adapter.test.js +80 -0
- package/tests/generate-workflow.test.js +109 -0
- package/tests/living-context.test.js +15 -0
- package/tests/skill-host-compat.test.js +45 -0
- package/tests/sync-hosts.test.js +32 -1
|
@@ -20,8 +20,21 @@ const {
|
|
|
20
20
|
planHostSync,
|
|
21
21
|
formatHostSyncReport
|
|
22
22
|
} = require('../lib/sync-hosts.js');
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const {
|
|
24
|
+
detectAdapterHints,
|
|
25
|
+
writeShippedAdapter,
|
|
26
|
+
formatGenerateAdapterReport,
|
|
27
|
+
parseTypeArg
|
|
28
|
+
} = require('../lib/generate-adapter.js');
|
|
29
|
+
const {
|
|
30
|
+
writeWorkflowOverlay,
|
|
31
|
+
formatGenerateWorkflowReport,
|
|
32
|
+
parseWriteArg,
|
|
33
|
+
workflowMarkdown,
|
|
34
|
+
lessonsMarkdown
|
|
35
|
+
} = require('../lib/generate-workflow.js');
|
|
36
|
+
|
|
37
|
+
const VERSION = '1.0.17';
|
|
25
38
|
const CWD = process.cwd();
|
|
26
39
|
const CONTEXT_DIR = path.join(CWD, '.ai-engineering-loop');
|
|
27
40
|
|
|
@@ -275,7 +288,7 @@ function generateContextFiles(rootDir, discovery, trigger = 'init', impact = 'IN
|
|
|
275
288
|
|
|
276
289
|
// 0. metadata.json (Baseline)
|
|
277
290
|
const metadataJson = {
|
|
278
|
-
contextVersion: '1.0.
|
|
291
|
+
contextVersion: '1.0.17',
|
|
279
292
|
generatedAt: new Date().toISOString(),
|
|
280
293
|
repositoryRevision: currentRevision,
|
|
281
294
|
projectProfile: discovery.profile,
|
|
@@ -365,7 +378,7 @@ ${discovery.scripts.e2e ? `- **e2e**: \`${discovery.scripts.e2e}\`` : ''}
|
|
|
365
378
|
const adapterMd = `# Project Delivery Adapter Configuration
|
|
366
379
|
|
|
367
380
|
## Delivery Pipeline
|
|
368
|
-
- **adapter_type**: "${discovery.adapter.type}" #
|
|
381
|
+
- **adapter_type**: "${discovery.adapter.type}" # standard | github | gitlab | dot | custom
|
|
369
382
|
${discovery.adapter.repoSlug ? `- **remote_repository**: "${discovery.adapter.repoSlug}"` : ''}
|
|
370
383
|
- **default_target_branch**: "${discovery.adapter.defaultBranch}"
|
|
371
384
|
- **ci_provider**: "${discovery.adapter.ciProvider}"
|
|
@@ -412,6 +425,9 @@ What becomes easier, harder, or forbidden.
|
|
|
412
425
|
\`\`\`
|
|
413
426
|
`;
|
|
414
427
|
writeContextFile(path.join(targetDir, 'adrs', 'README.md'), adrReadme, { overwrite: false });
|
|
428
|
+
|
|
429
|
+
writeContextFile(path.join(targetDir, 'workflow.md'), workflowMarkdown(), { overwrite: false });
|
|
430
|
+
writeContextFile(path.join(targetDir, 'lessons.md'), lessonsMarkdown(), { overwrite: false });
|
|
415
431
|
}
|
|
416
432
|
|
|
417
433
|
/**
|
|
@@ -654,6 +670,39 @@ function handleSyncHosts() {
|
|
|
654
670
|
console.log(formatHostSyncReport(results, { version: VERSION, dryRun }));
|
|
655
671
|
}
|
|
656
672
|
|
|
673
|
+
function handleGenerateAdapter() {
|
|
674
|
+
log.info('AI Engineering Loop — Generate delivery adapter (generate-adapter)');
|
|
675
|
+
const hints = detectAdapterHints(CWD);
|
|
676
|
+
const type = parseTypeArg(process.argv);
|
|
677
|
+
if (!type) {
|
|
678
|
+
console.log(formatGenerateAdapterReport(hints, { version: VERSION }));
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
try {
|
|
682
|
+
const wrote = writeShippedAdapter(CWD, { type, hints });
|
|
683
|
+
console.log(formatGenerateAdapterReport(hints, { version: VERSION, wrote }));
|
|
684
|
+
} catch (err) {
|
|
685
|
+
log.error(err.message);
|
|
686
|
+
process.exit(1);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function handleGenerateWorkflow() {
|
|
691
|
+
log.info('AI Engineering Loop — Generate loop overlay (generate-workflow)');
|
|
692
|
+
const shouldWrite = parseWriteArg(process.argv);
|
|
693
|
+
if (!shouldWrite) {
|
|
694
|
+
console.log(formatGenerateWorkflowReport({ version: VERSION }));
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
try {
|
|
698
|
+
const wrote = writeWorkflowOverlay(CWD, {});
|
|
699
|
+
console.log(formatGenerateWorkflowReport({ version: VERSION, wrote }));
|
|
700
|
+
} catch (err) {
|
|
701
|
+
log.error(err.message);
|
|
702
|
+
process.exit(1);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
|
|
657
706
|
function detectGrokHost() {
|
|
658
707
|
try {
|
|
659
708
|
const { detectGrokRuntime } = require('../lib/orchestration.js');
|
|
@@ -746,6 +795,10 @@ Commands:
|
|
|
746
795
|
sync-hosts Copy package skills/agents/commands into ~/.claude ~/.grok ~/.gemini ~/.agents
|
|
747
796
|
(only hosts that already exist; DOT skills only if already installed)
|
|
748
797
|
--dry-run print the plan without writing
|
|
798
|
+
generate-adapter Print detected forge and grill protocol for Stage 8
|
|
799
|
+
--type standard|github|gitlab|dot write .ai-engineering-loop/adapter.md (skip grill)
|
|
800
|
+
generate-workflow Print grill protocol for a loop overlay (hooks + lessons.md)
|
|
801
|
+
--write write .ai-engineering-loop/workflow.md and empty lessons.md (skip grill)
|
|
749
802
|
|
|
750
803
|
Options:
|
|
751
804
|
-h, --help Show this help menu
|
|
@@ -776,6 +829,12 @@ switch (command) {
|
|
|
776
829
|
case 'sync-hosts':
|
|
777
830
|
handleSyncHosts();
|
|
778
831
|
break;
|
|
832
|
+
case 'generate-adapter':
|
|
833
|
+
handleGenerateAdapter();
|
|
834
|
+
break;
|
|
835
|
+
case 'generate-workflow':
|
|
836
|
+
handleGenerateWorkflow();
|
|
837
|
+
break;
|
|
779
838
|
case '-v':
|
|
780
839
|
case '--version':
|
|
781
840
|
console.log(`ai-engineering-loop v${VERSION}`);
|
|
@@ -70,6 +70,7 @@ flowchart TD
|
|
|
70
70
|
| New folder in `src/modules/` or `apps/` | `architecture.md` | Add module summary and boundary notes |
|
|
71
71
|
| New global error class or lint rule added | `conventions.md` | Document new pattern or forbidden rule |
|
|
72
72
|
| New or corrected domain term | `glossary.md` | Add or fix one glossary row |
|
|
73
|
+
| Confirmed process / taste lesson (not a term) | `lessons.md` | Append one row; do not dump chat |
|
|
73
74
|
| Load-bearing design choice settled | `adrs/NNN-*.md` | Write an ADR; do not bury it in chat |
|
|
74
75
|
| `.gitlab-ci.yml` / `.github/workflows` edited | `adapter.md` | Update CI/CD workflow references |
|
|
75
76
|
|
|
@@ -14,6 +14,8 @@ The `.ai-engineering-loop/` directory serves as the **Living Project Context** f
|
|
|
14
14
|
├── verification.md # Exact CLI verification commands
|
|
15
15
|
├── adapter.md # Configured delivery pipeline & CI/CD tools
|
|
16
16
|
├── glossary.md # Ubiquitous language (one term per concept)
|
|
17
|
+
├── workflow.md # Optional loop overlay (hooks around the 8-stage OS)
|
|
18
|
+
├── lessons.md # Optional confirmed process lessons (not a chat log)
|
|
17
19
|
├── adrs/ # Architecture Decision Records from Stage 1 grill
|
|
18
20
|
│ └── README.md
|
|
19
21
|
└── tasks/ # Ephemeral: current.diff, handoff.md, verification logs
|
|
@@ -64,7 +66,7 @@ Maintains lightweight state for instant drift detection:
|
|
|
64
66
|
- `e2e`: (Optional) End-to-end / browser test command.
|
|
65
67
|
|
|
66
68
|
### 6. `adapter.md` — Delivery Pipeline Configuration
|
|
67
|
-
- `adapter_type`: Configured adapter (`
|
|
69
|
+
- `adapter_type`: Configured adapter (`standard`, `github`, `gitlab`, `dot`, `custom`). Shipped specs live in `adapters/<type>/`. Generate with `npx ai-engineering-loop generate-adapter` (grill) or `--type`.
|
|
68
70
|
- `remote_repository`: Git remote repository slug.
|
|
69
71
|
- `default_target_branch`: Base target branch.
|
|
70
72
|
- `ci_provider`: Detected CI engine (GitHub Actions, GitLab CI).
|
|
@@ -79,6 +81,17 @@ Maintains lightweight state for instant drift detection:
|
|
|
79
81
|
### 9. `tasks/` — Run artifacts (optional)
|
|
80
82
|
- `current.diff`, verification logs, `handoff.md`. Not required for `init` validity.
|
|
81
83
|
|
|
84
|
+
### 10. `workflow.md` — Loop overlay (optional)
|
|
85
|
+
- Hooks around the 8-stage OS: `before_grill`, `after_freeze`, `after_pass`.
|
|
86
|
+
- Cannot skip Goal Contract, verification, Devil's Advocate, or Judge.
|
|
87
|
+
- Missing file means default 8-stage loop (no extra hooks).
|
|
88
|
+
- Generate with `npx ai-engineering-loop generate-workflow` (grill) or `--write`.
|
|
89
|
+
|
|
90
|
+
### 11. `lessons.md` — Confirmed process lessons (optional)
|
|
91
|
+
- One human-confirmed row per lesson. Not a chat transcript. Not `eval.md`.
|
|
92
|
+
- Terms still go to `glossary.md`. Code bans to `conventions.md`. Design why to `adrs/`.
|
|
93
|
+
- `refresh` / `--write` must not overwrite filled lessons.
|
|
94
|
+
|
|
82
95
|
---
|
|
83
96
|
|
|
84
97
|
## 3. Version Control Recommendation
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const SHIPPED_TYPES = ['standard', 'github', 'gitlab', 'dot'];
|
|
7
|
+
|
|
8
|
+
function readGitRemote(rootDir) {
|
|
9
|
+
const gitConfig = path.join(rootDir, '.git', 'config');
|
|
10
|
+
try {
|
|
11
|
+
const text = fs.readFileSync(gitConfig, 'utf8');
|
|
12
|
+
const match = text.match(/url\s*=\s*(.*)/);
|
|
13
|
+
return match ? match[1].trim() : '';
|
|
14
|
+
} catch {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function detectCi(rootDir) {
|
|
20
|
+
if (fs.existsSync(path.join(rootDir, '.github', 'workflows'))) {
|
|
21
|
+
return 'GitHub Actions';
|
|
22
|
+
}
|
|
23
|
+
if (fs.existsSync(path.join(rootDir, '.gitlab-ci.yml'))) {
|
|
24
|
+
return 'GitLab CI';
|
|
25
|
+
}
|
|
26
|
+
return 'none';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function recommendType(remote) {
|
|
30
|
+
const url = (remote || '').toLowerCase();
|
|
31
|
+
if (url.includes('github.com')) return 'github';
|
|
32
|
+
if (url.includes('gitlab')) return 'gitlab';
|
|
33
|
+
return 'standard';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function detectAdapterHints(rootDir) {
|
|
37
|
+
const remote = readGitRemote(rootDir);
|
|
38
|
+
const ciProvider = detectCi(rootDir);
|
|
39
|
+
const recommended = recommendType(remote);
|
|
40
|
+
let existingType = '';
|
|
41
|
+
const adapterPath = path.join(rootDir, '.ai-engineering-loop', 'adapter.md');
|
|
42
|
+
try {
|
|
43
|
+
const text = fs.readFileSync(adapterPath, 'utf8');
|
|
44
|
+
const match = text.match(/adapter_type\*\*:\s*"?([a-z0-9-]+)/i) || text.match(/adapter_type:\s*"?([a-z0-9-]+)/i);
|
|
45
|
+
if (match) existingType = match[1];
|
|
46
|
+
} catch {
|
|
47
|
+
/* missing */
|
|
48
|
+
}
|
|
49
|
+
return { remote, ciProvider, recommended, existingType };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function adapterMarkdown({ type, remote, ciProvider, defaultBranch = 'main' }) {
|
|
53
|
+
const spec = `adapters/${type}/`;
|
|
54
|
+
const remoteLine = remote ? `- **remote_repository**: "${remote}"\n` : '';
|
|
55
|
+
return `# Project Delivery Adapter Configuration
|
|
56
|
+
|
|
57
|
+
## Delivery Pipeline
|
|
58
|
+
- **adapter_type**: "${type}"
|
|
59
|
+
- **spec**: "${spec}"
|
|
60
|
+
${remoteLine}- **default_target_branch**: "${defaultBranch}"
|
|
61
|
+
- **ci_provider**: "${ciProvider}"
|
|
62
|
+
|
|
63
|
+
## Stage 8
|
|
64
|
+
After Judge PASS, follow \`${spec}\` in the ai-engineering-loop package.
|
|
65
|
+
Do not start Maker. Do not skip Devil's Advocate or Judge.
|
|
66
|
+
Extra branches and chat notifications stay off unless this file names them.
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function writeShippedAdapter(rootDir, { type, hints }) {
|
|
71
|
+
if (!SHIPPED_TYPES.includes(type)) {
|
|
72
|
+
const err = new Error(`Unknown adapter type: ${type}. Use ${SHIPPED_TYPES.join('|')}`);
|
|
73
|
+
err.code = 'UNKNOWN_TYPE';
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
const dir = path.join(rootDir, '.ai-engineering-loop');
|
|
77
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
78
|
+
const dest = path.join(dir, 'adapter.md');
|
|
79
|
+
const body = adapterMarkdown({
|
|
80
|
+
type,
|
|
81
|
+
remote: hints.remote,
|
|
82
|
+
ciProvider: hints.ciProvider
|
|
83
|
+
});
|
|
84
|
+
fs.writeFileSync(dest, body);
|
|
85
|
+
return dest;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function formatGenerateAdapterReport(hints, { version, wrote } = {}) {
|
|
89
|
+
const lines = [
|
|
90
|
+
`Adapter generate (v${version || 'unknown'})`,
|
|
91
|
+
'Detected',
|
|
92
|
+
`- remote: ${hints.remote || '(none)'}`,
|
|
93
|
+
`- ci: ${hints.ciProvider}`,
|
|
94
|
+
`- recommended: ${hints.recommended}`,
|
|
95
|
+
`- existing: ${hints.existingType || '(none)'}`,
|
|
96
|
+
`Shipped: ${SHIPPED_TYPES.join(' | ')}`,
|
|
97
|
+
'Next: load skill generate-adapter. Ask Q1-Q5. Wait.',
|
|
98
|
+
'Headless: npx ai-engineering-loop generate-adapter --type <standard|github|gitlab|dot>'
|
|
99
|
+
];
|
|
100
|
+
if (wrote) lines.push(`Wrote: ${wrote}`);
|
|
101
|
+
return lines.join('\n');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function parseTypeArg(argv) {
|
|
105
|
+
const idx = argv.indexOf('--type');
|
|
106
|
+
if (idx === -1) return null;
|
|
107
|
+
return argv[idx + 1] || null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = {
|
|
111
|
+
SHIPPED_TYPES,
|
|
112
|
+
detectAdapterHints,
|
|
113
|
+
recommendType,
|
|
114
|
+
adapterMarkdown,
|
|
115
|
+
writeShippedAdapter,
|
|
116
|
+
formatGenerateAdapterReport,
|
|
117
|
+
parseTypeArg
|
|
118
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const REQUIRED_STAGES = ['goal_contract', 'verification', 'devil_advocate', 'judge'];
|
|
7
|
+
const ALLOWED_OPTIONAL_SKIPS = ['blast_radius', 'generate_adapter'];
|
|
8
|
+
const DEFAULT_HOOKS = {
|
|
9
|
+
before_grill: 'none',
|
|
10
|
+
after_freeze: 'none',
|
|
11
|
+
after_pass: 'none'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const REQUIRED_ALIASES = {
|
|
15
|
+
goal_contract: 'goal_contract',
|
|
16
|
+
'goal contract': 'goal_contract',
|
|
17
|
+
verification: 'verification',
|
|
18
|
+
devil_advocate: 'devil_advocate',
|
|
19
|
+
"devil's advocate": 'devil_advocate',
|
|
20
|
+
'devils advocate': 'devil_advocate',
|
|
21
|
+
judge: 'judge'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function normalizeSkip(name) {
|
|
25
|
+
return String(name || '')
|
|
26
|
+
.trim()
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.replace(/['"]/g, '')
|
|
29
|
+
.replace(/\s+/g, '_');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function assertNoRequiredSkip(skips) {
|
|
33
|
+
for (const raw of skips || []) {
|
|
34
|
+
const id = REQUIRED_ALIASES[normalizeSkip(raw)] || normalizeSkip(raw);
|
|
35
|
+
if (REQUIRED_STAGES.includes(id)) {
|
|
36
|
+
const err = new Error(`cannot skip required stage: ${id}`);
|
|
37
|
+
err.code = 'REQUIRED_SKIP';
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function routeDurableNote(kind) {
|
|
44
|
+
const map = {
|
|
45
|
+
term: 'glossary.md',
|
|
46
|
+
process: 'lessons.md',
|
|
47
|
+
lesson: 'lessons.md',
|
|
48
|
+
convention: 'conventions.md',
|
|
49
|
+
adr: 'adrs/'
|
|
50
|
+
};
|
|
51
|
+
return map[kind] || 'lessons.md';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function workflowMarkdown({ hooks = DEFAULT_HOOKS, optionalSkips = [] } = {}) {
|
|
55
|
+
const skipLine = optionalSkips.length ? optionalSkips.join(', ') : 'none';
|
|
56
|
+
return `# Loop Overlay
|
|
57
|
+
|
|
58
|
+
This file adds hooks around the AI Engineering Loop. It does not replace the 8-stage OS.
|
|
59
|
+
|
|
60
|
+
## Required (cannot skip)
|
|
61
|
+
- Goal Contract
|
|
62
|
+
- verification
|
|
63
|
+
- Devil's Advocate
|
|
64
|
+
- Judge
|
|
65
|
+
|
|
66
|
+
## Hooks
|
|
67
|
+
- **before_grill**: ${hooks.before_grill || 'none'}
|
|
68
|
+
- **after_freeze**: ${hooks.after_freeze || 'none'}
|
|
69
|
+
- **after_pass**: ${hooks.after_pass || 'none'}
|
|
70
|
+
|
|
71
|
+
## Optional skips
|
|
72
|
+
${skipLine}
|
|
73
|
+
|
|
74
|
+
Allowed optional skips: \`blast_radius\` (when the change is not business logic), \`generate_adapter\` (when adapter.md already exists).
|
|
75
|
+
Do not list Goal Contract, verification, Devil's Advocate, or Judge here.
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function lessonsMarkdown() {
|
|
80
|
+
return `# Lessons
|
|
81
|
+
|
|
82
|
+
Confirmed by a human. One row per lesson. Not a chat transcript. Not a glossary.
|
|
83
|
+
|
|
84
|
+
Route elsewhere when it fits: term → glossary.md, code ban → conventions.md, load-bearing design → adrs/.
|
|
85
|
+
|
|
86
|
+
| Date | Lesson | Do not |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function parseHookLine(text, key) {
|
|
92
|
+
const re = new RegExp(`\\*\\*${key}\\*\\*:\\s*(.+)`, 'i');
|
|
93
|
+
const match = text.match(re);
|
|
94
|
+
if (!match) return 'none';
|
|
95
|
+
return match[1].trim() || 'none';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function parseOptionalSkips(text) {
|
|
99
|
+
const block = text.split(/## Optional skips/i)[1];
|
|
100
|
+
if (!block) return [];
|
|
101
|
+
const line = block.split('\n').find((row) => row.trim() && !row.startsWith('#'));
|
|
102
|
+
if (!line) return [];
|
|
103
|
+
const raw = line.replace(/^-\s*/, '').trim();
|
|
104
|
+
if (!raw || /^none$/i.test(raw)) return [];
|
|
105
|
+
return raw.split(/,|\|/).map((item) => normalizeSkip(item)).filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function parseWorkflowMarkdown(text) {
|
|
109
|
+
return {
|
|
110
|
+
missing: false,
|
|
111
|
+
required: REQUIRED_STAGES.slice(),
|
|
112
|
+
hooks: {
|
|
113
|
+
before_grill: parseHookLine(text, 'before_grill'),
|
|
114
|
+
after_freeze: parseHookLine(text, 'after_freeze'),
|
|
115
|
+
after_pass: parseHookLine(text, 'after_pass')
|
|
116
|
+
},
|
|
117
|
+
optionalSkips: parseOptionalSkips(text)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function parseWorkflowFile(rootDir) {
|
|
122
|
+
const dest = path.join(rootDir, '.ai-engineering-loop', 'workflow.md');
|
|
123
|
+
try {
|
|
124
|
+
const text = fs.readFileSync(dest, 'utf8');
|
|
125
|
+
return parseWorkflowMarkdown(text);
|
|
126
|
+
} catch {
|
|
127
|
+
return {
|
|
128
|
+
missing: true,
|
|
129
|
+
required: REQUIRED_STAGES.slice(),
|
|
130
|
+
hooks: { ...DEFAULT_HOOKS },
|
|
131
|
+
optionalSkips: []
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function lessonsAreFilled(text) {
|
|
137
|
+
if (!text || !text.trim()) return false;
|
|
138
|
+
return /\| 20\d{2}-/.test(text);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function writeWorkflowOverlay(rootDir, { hooks, optionalSkips } = {}) {
|
|
142
|
+
const skips = optionalSkips || [];
|
|
143
|
+
assertNoRequiredSkip(skips);
|
|
144
|
+
for (const skip of skips) {
|
|
145
|
+
const id = normalizeSkip(skip);
|
|
146
|
+
if (!ALLOWED_OPTIONAL_SKIPS.includes(id)) {
|
|
147
|
+
const err = new Error(`Unknown optional skip: ${skip}. Use ${ALLOWED_OPTIONAL_SKIPS.join('|')}`);
|
|
148
|
+
err.code = 'UNKNOWN_SKIP';
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const dir = path.join(rootDir, '.ai-engineering-loop');
|
|
153
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
154
|
+
const workflowPath = path.join(dir, 'workflow.md');
|
|
155
|
+
const lessonsPath = path.join(dir, 'lessons.md');
|
|
156
|
+
fs.writeFileSync(
|
|
157
|
+
workflowPath,
|
|
158
|
+
workflowMarkdown({
|
|
159
|
+
hooks: { ...DEFAULT_HOOKS, ...(hooks || {}) },
|
|
160
|
+
optionalSkips: skips
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
if (!fs.existsSync(lessonsPath) || !lessonsAreFilled(fs.readFileSync(lessonsPath, 'utf8'))) {
|
|
164
|
+
if (!fs.existsSync(lessonsPath)) {
|
|
165
|
+
fs.writeFileSync(lessonsPath, lessonsMarkdown());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { workflow: workflowPath, lessons: lessonsPath };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function formatGenerateWorkflowReport({ version, wrote } = {}) {
|
|
172
|
+
const lines = [
|
|
173
|
+
`Workflow overlay generate (v${version || 'unknown'})`,
|
|
174
|
+
'This is not a second OS. Required: Goal Contract, verification, Devil\'s Advocate, Judge.',
|
|
175
|
+
'Files: .ai-engineering-loop/workflow.md and lessons.md',
|
|
176
|
+
'Next: load skill generate-workflow. Ask Q1-Q5. Wait.',
|
|
177
|
+
'Headless: npx ai-engineering-loop generate-workflow --write'
|
|
178
|
+
];
|
|
179
|
+
if (wrote) {
|
|
180
|
+
lines.push(`Wrote: ${wrote.workflow}`);
|
|
181
|
+
lines.push(`Lessons: ${wrote.lessons}`);
|
|
182
|
+
}
|
|
183
|
+
return lines.join('\n');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function parseWriteArg(argv) {
|
|
187
|
+
return argv.includes('--write');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
module.exports = {
|
|
191
|
+
REQUIRED_STAGES,
|
|
192
|
+
ALLOWED_OPTIONAL_SKIPS,
|
|
193
|
+
DEFAULT_HOOKS,
|
|
194
|
+
assertNoRequiredSkip,
|
|
195
|
+
routeDurableNote,
|
|
196
|
+
workflowMarkdown,
|
|
197
|
+
lessonsMarkdown,
|
|
198
|
+
parseWorkflowMarkdown,
|
|
199
|
+
parseWorkflowFile,
|
|
200
|
+
writeWorkflowOverlay,
|
|
201
|
+
formatGenerateWorkflowReport,
|
|
202
|
+
parseWriteArg
|
|
203
|
+
};
|
package/lib/sync-hosts.js
CHANGED
|
@@ -34,6 +34,8 @@ function hostFileMap(home) {
|
|
|
34
34
|
files: [
|
|
35
35
|
{ src: '.claude/skills/ai-engineering-loop/SKILL.md', dest: path.join(claude, 'skills/ai-engineering-loop/SKILL.md'), mode: 'upsert' },
|
|
36
36
|
{ src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(claude, 'skills/task-impact-inquiry/SKILL.md'), mode: 'upsert' },
|
|
37
|
+
{ src: 'adapters/generate-adapter/SKILL.md', dest: path.join(claude, 'skills/generate-adapter/SKILL.md'), mode: 'upsert' },
|
|
38
|
+
{ src: 'adapters/generate-workflow/SKILL.md', dest: path.join(claude, 'skills/generate-workflow/SKILL.md'), mode: 'upsert' },
|
|
37
39
|
{ src: '.claude/agents/devil-advocate.md', dest: path.join(claude, 'agents/devil-advocate.md'), mode: 'upsert' },
|
|
38
40
|
{ src: '.claude/agents/judge.md', dest: path.join(claude, 'agents/judge.md'), mode: 'upsert' },
|
|
39
41
|
{ src: '.claude/commands/ai-engineering-loop.md', dest: path.join(claude, 'commands/ai-engineering-loop.md'), mode: 'upsert' }
|
|
@@ -45,6 +47,8 @@ function hostFileMap(home) {
|
|
|
45
47
|
files: [
|
|
46
48
|
{ src: '.grok/skills/ai-engineering-loop/SKILL.md', dest: path.join(grok, 'skills/ai-engineering-loop/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
|
|
47
49
|
{ src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(grok, 'skills/task-impact-inquiry/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
|
|
50
|
+
{ src: 'adapters/generate-adapter/SKILL.md', dest: path.join(grok, 'skills/generate-adapter/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
|
|
51
|
+
{ src: 'adapters/generate-workflow/SKILL.md', dest: path.join(grok, 'skills/generate-workflow/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
|
|
48
52
|
{ src: '.grok/agents/devil-advocate.md', dest: path.join(grok, 'agents/devil-advocate.md'), mode: 'upsert' },
|
|
49
53
|
{ src: '.grok/agents/judge.md', dest: path.join(grok, 'agents/judge.md'), mode: 'upsert' },
|
|
50
54
|
{ src: '.grok/commands/ai-engineering-loop.md', dest: path.join(grok, 'commands/ai-engineering-loop.md'), mode: 'upsert' }
|
|
@@ -55,7 +59,9 @@ function hostFileMap(home) {
|
|
|
55
59
|
root: gemini,
|
|
56
60
|
files: [
|
|
57
61
|
{ src: '.gemini/skills/ai-engineering-loop/SKILL.md', dest: path.join(gemini, 'config/skills/ai-engineering-loop/SKILL.md'), mode: 'upsert' },
|
|
58
|
-
{ src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(gemini, 'config/skills/task-impact-inquiry/SKILL.md'), mode: 'upsert' }
|
|
62
|
+
{ src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(gemini, 'config/skills/task-impact-inquiry/SKILL.md'), mode: 'upsert' },
|
|
63
|
+
{ src: 'adapters/generate-adapter/SKILL.md', dest: path.join(gemini, 'config/skills/generate-adapter/SKILL.md'), mode: 'upsert' },
|
|
64
|
+
{ src: 'adapters/generate-workflow/SKILL.md', dest: path.join(gemini, 'config/skills/generate-workflow/SKILL.md'), mode: 'upsert' }
|
|
59
65
|
]
|
|
60
66
|
},
|
|
61
67
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Project Delivery Adapter Configuration
|
|
2
2
|
|
|
3
3
|
## Delivery Settings
|
|
4
|
-
- **adapter_type**: "github" #
|
|
4
|
+
- **adapter_type**: "github" # standard | github | gitlab | dot | custom
|
|
5
5
|
- **repository**: "organization/my-service"
|
|
6
6
|
- **default_target_branch**: "main"
|
|
7
7
|
- **notification_webhook**: "https://hooks.slack.com/services/..." # Optional
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
## Optional skips
|
|
17
|
+
none
|
|
18
|
+
|
|
19
|
+
Allowed optional skips: `blast_radius` (when the change is not business logic), `generate_adapter` (when adapter.md already exists).
|
|
20
|
+
Do not list Goal Contract, verification, Devil's Advocate, or Judge here.
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
});
|