@akjamie/agentic-sdlc 1.5.0 → 1.6.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.
- package/README.md +42 -18
- package/assets/config/config.yaml +1 -1
- package/assets/policy/policy.yaml +6 -0
- package/assets/schema/schema.yaml +168 -168
- package/assets/skills/asdlc-approve/SKILL.md +1 -1
- package/assets/skills/asdlc-archive/SKILL.md +17 -13
- package/assets/skills/asdlc-doctor/SKILL.md +8 -8
- package/assets/skills/asdlc-impl-review/SKILL.md +2 -14
- package/assets/skills/asdlc-init/SKILL.md +11 -18
- package/assets/skills/asdlc-pr/SKILL.md +13 -8
- package/assets/skills/asdlc-review/SKILL.md +7 -7
- package/assets/skills/asdlc-spec-review/SKILL.md +2 -14
- package/package.json +2 -1
- package/src/assess/ai_judge.js +36 -3
- package/src/assess/rules/builtin.js +2 -2
- package/src/assess/vectors/v2_security.js +24 -1
- package/src/assess/vectors/v3_topology.js +29 -11
- package/src/commands/apply.js +1 -1
- package/src/commands/approve.js +2 -3
- package/src/commands/archive.js +116 -64
- package/src/commands/doctor.js +24 -21
- package/src/commands/init.js +24 -50
- package/src/commands/pr.js +106 -25
- package/src/commands/test.js +90 -21
- package/src/commands/update.js +1 -11
- package/src/commands/upgrade.js +47 -25
- package/src/commands/verify.js +94 -14
- package/src/lib/agents.js +2 -2
- package/src/lib/cliutil.js +57 -7
- package/src/lib/git.js +10 -4
- package/src/lib/graphify.js +22 -11
- package/src/lib/level.js +63 -9
- package/src/lib/openspec.js +61 -31
- package/src/lib/paths.js +0 -2
- package/src/lib/policy.js +4 -0
- package/src/lib/schema.js +32 -11
- package/src/lib/tdd.js +29 -9
- package/assets/ci/asdlc-ai-review.yml +0 -65
- package/assets/githooks/post-merge +0 -22
- package/assets/githooks/pre-push +0 -17
package/src/commands/test.js
CHANGED
|
@@ -80,7 +80,7 @@ export function runTests(changeId, opts = {}) {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
if (!opts.json) {
|
|
83
|
+
if (!opts.json && !opts.silent) {
|
|
84
84
|
log.info(`=== Running Acceptance Tests for ${slug} ===`);
|
|
85
85
|
log.info(`Mapped ACs: ${allAcs.length} across ${uniqueTestPaths.length} test file(s):`);
|
|
86
86
|
for (const ac of allAcs) {
|
|
@@ -98,26 +98,7 @@ export function runTests(changeId, opts = {}) {
|
|
|
98
98
|
} catch { /* ignore config parse error */ }
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
const
|
|
102
|
-
const allGo = uniqueTestPaths.every((p) => p.endsWith('.go'));
|
|
103
|
-
const allPy = uniqueTestPaths.every((p) => p.endsWith('.py'));
|
|
104
|
-
const allJava = uniqueTestPaths.every((p) => /\.(java|kt)$/i.test(p));
|
|
105
|
-
if (allGo) {
|
|
106
|
-
// In Go, package directory syntax './path/to/pkg' is required so intra-package symbols resolve
|
|
107
|
-
const goPkgs = [...new Set(uniqueTestPaths.map((p) => {
|
|
108
|
-
const dir = path.dirname(p).replace(/\\/g, '/');
|
|
109
|
-
return dir === '.' ? '.' : `./${dir}`;
|
|
110
|
-
}))];
|
|
111
|
-
return `go test ${goPkgs.join(' ')}`;
|
|
112
|
-
}
|
|
113
|
-
if (allPy) return `pytest ${uniqueTestPaths.join(' ')}`;
|
|
114
|
-
if (allJava) return 'mvn test';
|
|
115
|
-
return process.platform === 'win32'
|
|
116
|
-
? `node --test ${uniqueTestPaths.map((p) => `"${p}"`).join(' ')}`
|
|
117
|
-
: `node --test ${uniqueTestPaths.join(' ')}`;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const runnerCmd = opts.runner ?? configuredRunner ?? defaultRunner();
|
|
101
|
+
const runnerCmd = opts.runner ?? configuredRunner ?? detectTestRunner(repoRoot, uniqueTestPaths);
|
|
121
102
|
|
|
122
103
|
const res = runShell(runnerCmd, repoRoot, {
|
|
123
104
|
env: { NODE_TEST_CONTEXT: undefined },
|
|
@@ -125,11 +106,16 @@ export function runTests(changeId, opts = {}) {
|
|
|
125
106
|
});
|
|
126
107
|
const passed = res.status === 0;
|
|
127
108
|
|
|
109
|
+
if (opts.silent) {
|
|
110
|
+
return passed ? 0 : 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
128
113
|
if (opts.json) {
|
|
129
114
|
const output = {
|
|
130
115
|
changeId: slug,
|
|
131
116
|
pass: passed,
|
|
132
117
|
status: passed ? 'pass' : 'fail',
|
|
118
|
+
runner: runnerCmd,
|
|
133
119
|
acCount: allAcs.length,
|
|
134
120
|
testFiles: uniqueTestPaths,
|
|
135
121
|
acs: allAcs,
|
|
@@ -151,6 +137,89 @@ export function runTests(changeId, opts = {}) {
|
|
|
151
137
|
return passed ? 0 : 1;
|
|
152
138
|
}
|
|
153
139
|
|
|
140
|
+
export function detectTestRunner(repoRoot, uniqueTestPaths = []) {
|
|
141
|
+
const quotePath = (p) => (process.platform === 'win32' || /\s/.test(p) ? `"${p}"` : p);
|
|
142
|
+
const quotedPaths = uniqueTestPaths.map(quotePath).join(' ');
|
|
143
|
+
|
|
144
|
+
const allGo = uniqueTestPaths.length > 0 && uniqueTestPaths.every((p) => p.endsWith('.go'));
|
|
145
|
+
const allPy = uniqueTestPaths.length > 0 && uniqueTestPaths.every((p) => p.endsWith('.py'));
|
|
146
|
+
const allRs = uniqueTestPaths.length > 0 && uniqueTestPaths.every((p) => p.endsWith('.rs'));
|
|
147
|
+
const allJvm = uniqueTestPaths.length > 0 && uniqueTestPaths.every((p) => /\.(java|kt|scala)$/i.test(p));
|
|
148
|
+
|
|
149
|
+
if (allGo) {
|
|
150
|
+
const goPkgs = [...new Set(uniqueTestPaths.map((p) => {
|
|
151
|
+
const dir = path.dirname(p).replace(/\\/g, '/');
|
|
152
|
+
return dir === '.' ? '.' : `./${dir}`;
|
|
153
|
+
}))];
|
|
154
|
+
return `go test ${goPkgs.join(' ')}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (allPy) {
|
|
158
|
+
return `pytest ${quotedPaths}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (allRs) {
|
|
162
|
+
return 'cargo test';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (allJvm) {
|
|
166
|
+
const classNames = [...new Set(uniqueTestPaths.map((p) => path.basename(p).replace(/\.(java|kt|scala)$/i, '')))];
|
|
167
|
+
const hasGradle = exists(path.join(repoRoot, 'build.gradle'))
|
|
168
|
+
|| exists(path.join(repoRoot, 'build.gradle.kts'))
|
|
169
|
+
|| exists(path.join(repoRoot, 'gradlew'));
|
|
170
|
+
if (hasGradle) {
|
|
171
|
+
const gradleBin = exists(path.join(repoRoot, 'gradlew'))
|
|
172
|
+
? (process.platform === 'win32' && exists(path.join(repoRoot, 'gradlew.bat')) ? 'gradlew.bat' : './gradlew')
|
|
173
|
+
: 'gradle';
|
|
174
|
+
const testsArgs = classNames.map((c) => `--tests ${c}`).join(' ');
|
|
175
|
+
return `${gradleBin} test ${testsArgs}`.trim();
|
|
176
|
+
}
|
|
177
|
+
const mvnBin = exists(path.join(repoRoot, 'mvnw'))
|
|
178
|
+
? (process.platform === 'win32' && exists(path.join(repoRoot, 'mvnw.cmd')) ? 'mvnw.cmd' : './mvnw')
|
|
179
|
+
: 'mvn';
|
|
180
|
+
return classNames.length > 0
|
|
181
|
+
? `${mvnBin} test -Dtest=${classNames.join(',')}`
|
|
182
|
+
: `${mvnBin} test`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// JS / TS ecosystem inspection via package.json & config files
|
|
186
|
+
const pkgPath = path.join(repoRoot, 'package.json');
|
|
187
|
+
let pkg = {};
|
|
188
|
+
if (exists(pkgPath)) {
|
|
189
|
+
try { pkg = JSON.parse(readText(pkgPath)); } catch { pkg = {}; }
|
|
190
|
+
}
|
|
191
|
+
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
192
|
+
const testScript = String(pkg.scripts?.test || '');
|
|
193
|
+
|
|
194
|
+
const hasVitest = Boolean(
|
|
195
|
+
deps.vitest ||
|
|
196
|
+
/\bvitest\b/.test(testScript) ||
|
|
197
|
+
['vitest.config.ts', 'vitest.config.js', 'vitest.config.mts', 'vitest.config.mjs'].some((f) => exists(path.join(repoRoot, f)))
|
|
198
|
+
);
|
|
199
|
+
if (hasVitest) {
|
|
200
|
+
return `npx vitest run ${quotedPaths}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const hasJest = Boolean(
|
|
204
|
+
deps.jest ||
|
|
205
|
+
/\bjest\b/.test(testScript) ||
|
|
206
|
+
['jest.config.ts', 'jest.config.js', 'jest.config.cjs', 'jest.config.mjs'].some((f) => exists(path.join(repoRoot, f)))
|
|
207
|
+
);
|
|
208
|
+
if (hasJest) {
|
|
209
|
+
return `npx jest ${quotedPaths}`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const hasTsFiles = uniqueTestPaths.some((p) => /\.(ts|tsx|mts|cts)$/i.test(p));
|
|
213
|
+
if (hasTsFiles) {
|
|
214
|
+
if (deps.tsx || /\btsx\b/.test(testScript)) {
|
|
215
|
+
return `npx tsx --test ${quotedPaths}`;
|
|
216
|
+
}
|
|
217
|
+
return `node --experimental-strip-types --test ${quotedPaths}`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return `node --test ${quotedPaths}`;
|
|
221
|
+
}
|
|
222
|
+
|
|
154
223
|
export function register(program) {
|
|
155
224
|
program
|
|
156
225
|
.command('test <changeId>')
|
package/src/commands/update.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { exists } from '../lib/fs.js';
|
|
3
3
|
import { resolveRepoRoot, openspecDir, OPENSPEC_DIR } from '../lib/paths.js';
|
|
4
4
|
import { log } from '../lib/log.js';
|
|
5
|
-
import { detectTools, installSkills, installCommands
|
|
5
|
+
import { detectTools, installSkills, installCommands } from './init.js';
|
|
6
6
|
import { ensureGraphify, buildGraph, ensureGitignore } from '../lib/graphify.js';
|
|
7
7
|
import { refreshAgents } from '../lib/agents.js';
|
|
8
8
|
|
|
@@ -76,15 +76,6 @@ export function updateRepo(opts = {}) {
|
|
|
76
76
|
log.warn(`AGENTS.md refresh failed: ${err.message}`);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
// 4) Git governance hooks
|
|
80
|
-
if (opts.hooks !== false) {
|
|
81
|
-
try {
|
|
82
|
-
installHooks(repoRoot);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
log.warn(`git hooks refresh failed: ${err.message}`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
79
|
log.info('');
|
|
89
80
|
log.ok('Repository SDLC state is fully up to date.');
|
|
90
81
|
return 0;
|
|
@@ -97,7 +88,6 @@ export function register(program) {
|
|
|
97
88
|
.option('--repo-root <path>', 'repository root (default: current repository)')
|
|
98
89
|
.option('--no-skills', 'skip refreshing agent skills')
|
|
99
90
|
.option('--no-graph', 'skip rebuilding codebase knowledge graph')
|
|
100
|
-
.option('--no-hooks', 'skip refreshing git hooks')
|
|
101
91
|
.action((opts) => {
|
|
102
92
|
process.exitCode = updateRepo(opts);
|
|
103
93
|
});
|
package/src/commands/upgrade.js
CHANGED
|
@@ -20,9 +20,12 @@ export function upgradeAsdlc() {
|
|
|
20
20
|
log.step('upgrading asdlc CLI...');
|
|
21
21
|
try {
|
|
22
22
|
const pkgSpec = process.env.ASDLC_PKG_SPEC || '@akjamie/agentic-sdlc@latest';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const res = spawnSync(`npm install -g ${pkgSpec}`, { shell: true, stdio: 'inherit' });
|
|
24
|
+
if (res.status === 0) {
|
|
25
|
+
log.ok('asdlc CLI upgraded to latest');
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
throw new Error(res.error ? res.error.message : `npm exited with status ${res.status}`);
|
|
26
29
|
} catch (err) {
|
|
27
30
|
log.warn(`asdlc upgrade via npm failed: ${err.message}`);
|
|
28
31
|
log.info('💡 [FALLBACK] If automatic upgrade failed, run manually:');
|
|
@@ -47,12 +50,16 @@ export function upgradeSkills(repoRoot) {
|
|
|
47
50
|
export function upgradeOpenspec() {
|
|
48
51
|
log.step('upgrading openspec...');
|
|
49
52
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const res = spawnSync('npm install -g @fission-ai/openspec@latest', { shell: true, stdio: 'inherit' });
|
|
54
|
+
if (res.status === 0) {
|
|
55
|
+
log.ok('openspec upgraded to latest');
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
log.info(`note: global openspec install skipped (exit ${res.status}); asdlc bundles OpenSpec natively`);
|
|
52
59
|
return true;
|
|
53
60
|
} catch (err) {
|
|
54
|
-
log.
|
|
55
|
-
return
|
|
61
|
+
log.info(`note: global openspec install skipped (${err.message}); asdlc bundles OpenSpec natively`);
|
|
62
|
+
return true;
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
65
|
|
|
@@ -64,9 +71,17 @@ export function upgradeGraphify() {
|
|
|
64
71
|
|
|
65
72
|
if (viaUv) {
|
|
66
73
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
// Prefer Python <3.14 to use pre-built wheels for tree-sitter, avoiding source compilation failure on experimental Pythons (e.g. 3.15)
|
|
75
|
+
const res = spawnSync('uv tool install --upgrade --python "<3.14" graphifyy', { shell: true, stdio: 'inherit' });
|
|
76
|
+
if (res.status === 0) {
|
|
77
|
+
log.ok('graphify upgraded via uv');
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
const resFallback = spawnSync('uv tool install --upgrade graphifyy', { shell: true, stdio: 'inherit' });
|
|
81
|
+
if (resFallback.status === 0) {
|
|
82
|
+
log.ok('graphify upgraded via uv');
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
70
85
|
} catch {
|
|
71
86
|
// fallback
|
|
72
87
|
}
|
|
@@ -74,9 +89,11 @@ export function upgradeGraphify() {
|
|
|
74
89
|
|
|
75
90
|
if (viaPipx) {
|
|
76
91
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
const res = spawnSync('pipx install --upgrade graphifyy', { shell: true, stdio: 'inherit' });
|
|
93
|
+
if (res.status === 0) {
|
|
94
|
+
log.ok('graphify upgraded via pipx');
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
80
97
|
} catch {
|
|
81
98
|
// fallback
|
|
82
99
|
}
|
|
@@ -84,19 +101,23 @@ export function upgradeGraphify() {
|
|
|
84
101
|
|
|
85
102
|
if (viaPip) {
|
|
86
103
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
const res = spawnSync('pip install --upgrade graphifyy', { shell: true, stdio: 'inherit' });
|
|
105
|
+
if (res.status === 0) {
|
|
106
|
+
log.ok('graphify upgraded via pip');
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
91
109
|
// PEP 668 on Debian/Ubuntu externally-managed-environment: retry with --break-system-packages
|
|
92
|
-
|
|
93
|
-
|
|
110
|
+
const resBreak = spawnSync('pip install --upgrade graphifyy --break-system-packages', { shell: true, stdio: 'inherit' });
|
|
111
|
+
if (resBreak.status === 0) {
|
|
94
112
|
log.ok('graphify upgraded via pip (--break-system-packages)');
|
|
95
113
|
return true;
|
|
96
|
-
} catch (err2) {
|
|
97
|
-
log.warn(`graphify upgrade via pip failed: ${err2.message}`);
|
|
98
|
-
return false;
|
|
99
114
|
}
|
|
115
|
+
throw new Error(`pip install exited with code ${resBreak.status}`);
|
|
116
|
+
} catch (err2) {
|
|
117
|
+
log.warn(`graphify upgrade via pip failed: ${err2.message}`);
|
|
118
|
+
log.info('💡 [HINT] If wheel build fails for tree-sitter on Python >=3.14, install with uv using Python 3.12:');
|
|
119
|
+
log.info(' uv tool install --python 3.12 graphifyy');
|
|
120
|
+
return false;
|
|
100
121
|
}
|
|
101
122
|
}
|
|
102
123
|
|
|
@@ -127,6 +148,7 @@ export function runUpgrade(opts = {}) {
|
|
|
127
148
|
log.info('');
|
|
128
149
|
|
|
129
150
|
const repoRoot = opts.global ? null : resolveRepoRoot(opts);
|
|
151
|
+
const isGit = repoRoot ? exists(path.join(repoRoot, '.git')) : false;
|
|
130
152
|
|
|
131
153
|
if (opts.asdlc !== false) upgradeAsdlc();
|
|
132
154
|
if (opts.openspec !== false) upgradeOpenspec();
|
|
@@ -134,9 +156,9 @@ export function runUpgrade(opts = {}) {
|
|
|
134
156
|
if (opts.schema !== false) upgradeSchema();
|
|
135
157
|
|
|
136
158
|
if (opts.skills !== false) {
|
|
137
|
-
if (opts.global) {
|
|
159
|
+
if (opts.global || !isGit) {
|
|
138
160
|
installGlobalSkills(opts);
|
|
139
|
-
} else
|
|
161
|
+
} else {
|
|
140
162
|
if (exists(openspecDir(repoRoot))) {
|
|
141
163
|
updateRepo({ repoRoot, ...opts });
|
|
142
164
|
} else {
|
|
@@ -151,7 +173,7 @@ export function runUpgrade(opts = {}) {
|
|
|
151
173
|
if (opts.doctor !== false) {
|
|
152
174
|
log.info('');
|
|
153
175
|
log.info('=== Post-upgrade Health Check (doctor) ===');
|
|
154
|
-
return doctor(repoRoot ? { repoRoot } : {});
|
|
176
|
+
return doctor(isGit && repoRoot ? { repoRoot } : { global: true });
|
|
155
177
|
}
|
|
156
178
|
|
|
157
179
|
return 0;
|
package/src/commands/verify.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { exists, readText, writeText, walkFiles } from '../lib/fs.js';
|
|
3
3
|
import { readYaml } from '../lib/yaml.js';
|
|
4
4
|
import { openspecDir, changeDir } from '../lib/paths.js';
|
|
5
|
-
import { requireRepo, toChangeSlug, readLintConfig } from '../lib/cliutil.js';
|
|
5
|
+
import { requireRepo, toChangeSlug, readLintConfig, jsonOut } from '../lib/cliutil.js';
|
|
6
6
|
import { validateChange } from '../lib/openspec.js';
|
|
7
7
|
import { runShell } from '../lib/exec.js';
|
|
8
8
|
import { lastCommitTouching, changeOnRef, git } from '../lib/git.js';
|
|
@@ -13,6 +13,7 @@ import { classifyPR } from '../lib/prtype.js';
|
|
|
13
13
|
import { isSinglePrLevel, requiresHumanReview, readChangeLevel, readEffectiveLevel } from '../lib/level.js';
|
|
14
14
|
import { assess, renderCheckSummary, loadRiskHistory } from '../assess/index.js';
|
|
15
15
|
import { checkTestPresence, checkTaskEvidence } from '../lib/tdd.js';
|
|
16
|
+
import { runTests, parseSpecAcceptanceCriteria } from './test.js';
|
|
16
17
|
import { log, dim } from '../lib/log.js';
|
|
17
18
|
|
|
18
19
|
// THE implementation check (v10: gate absorbed verify). Deterministic checks
|
|
@@ -61,13 +62,27 @@ function readExternalChecks(repoRoot) {
|
|
|
61
62
|
return ext.filter((e) => e && typeof e.command === 'string').map((e) => ({ name: e.name ?? e.command, command: e.command }));
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
function finish(results, policy) {
|
|
65
|
+
function finish(results, policy, opts = {}) {
|
|
65
66
|
let failed = 0;
|
|
66
|
-
|
|
67
|
-
for (const r of results) {
|
|
67
|
+
const processed = results.map((r) => {
|
|
68
68
|
const status = r.status === 'fail' && isAdvisory(policy, r.name) ? 'warn' : r.status;
|
|
69
|
-
const badge = { pass: 'PASS', fail: 'FAIL', warn: 'WARN', skip: 'SKIP' }[status];
|
|
70
69
|
if (status === 'fail') failed += 1;
|
|
70
|
+
return { ...r, status };
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (opts.json) {
|
|
74
|
+
jsonOut({
|
|
75
|
+
verdict: failed === 0 ? 'PASS' : 'FAIL',
|
|
76
|
+
pass: failed === 0,
|
|
77
|
+
failed,
|
|
78
|
+
results: processed,
|
|
79
|
+
});
|
|
80
|
+
return failed ? 1 : 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
log.info('');
|
|
84
|
+
for (const r of processed) {
|
|
85
|
+
const badge = { pass: 'PASS', fail: 'FAIL', warn: 'WARN', skip: 'SKIP' }[r.status];
|
|
71
86
|
log.plain(` [${badge}] ${r.name}`);
|
|
72
87
|
if (r.detail) log.plain(` ${dim(r.detail)}`);
|
|
73
88
|
}
|
|
@@ -92,7 +107,43 @@ function intent(cdir) {
|
|
|
92
107
|
return parts.join('\n\n');
|
|
93
108
|
}
|
|
94
109
|
|
|
95
|
-
|
|
110
|
+
export const DEFAULT_MAX_DIFF_CHARS = 32000;
|
|
111
|
+
|
|
112
|
+
export function buildVerifierDiffPayload(diff, { maxChars = DEFAULT_MAX_DIFF_CHARS } = {}) {
|
|
113
|
+
const raw = String(diff || '');
|
|
114
|
+
if (!raw) return '(empty diff)';
|
|
115
|
+
if (raw.length <= maxChars) return raw;
|
|
116
|
+
|
|
117
|
+
// Split unified diff by file and preserve file manifest + bounded per-file hunks
|
|
118
|
+
const sections = raw.split(/(?=^diff --git )/m).filter(Boolean);
|
|
119
|
+
const fileManifest = sections.map((sec) => {
|
|
120
|
+
const header = sec.match(/^diff --git a\/(.+?) b\/(.+?)$/m);
|
|
121
|
+
const file = header ? header[2] : 'unknown';
|
|
122
|
+
const adds = (sec.match(/^\+(?!\+\+)/gm) || []).length;
|
|
123
|
+
const dels = (sec.match(/^-(?!--)/gm) || []).length;
|
|
124
|
+
return ` - ${file} (+${adds} / -${dels})`;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const manifestBlock = `Changed files (${sections.length}):\n${fileManifest.join('\n')}\n\n`;
|
|
128
|
+
const notice = `\n\n[DIFF TRUNCATED: total ${raw.length} chars exceeded ${maxChars}-char stdin budget. Run the \`asdlc-impl-review\` skill in an independent agent session for multi-file deep review.]`;
|
|
129
|
+
const remainingBudget = Math.max(256, maxChars - manifestBlock.length - notice.length);
|
|
130
|
+
const perFileBudget = Math.max(160, Math.floor(remainingBudget / Math.max(1, sections.length)));
|
|
131
|
+
|
|
132
|
+
const excerpts = [];
|
|
133
|
+
let used = 0;
|
|
134
|
+
for (const sec of sections) {
|
|
135
|
+
if (used >= remainingBudget) break;
|
|
136
|
+
const allowance = Math.min(perFileBudget, remainingBudget - used);
|
|
137
|
+
const slice = sec.length > allowance ? `${sec.slice(0, allowance)}\n... (hunk truncated)` : sec;
|
|
138
|
+
excerpts.push(slice);
|
|
139
|
+
used += slice.length + 2;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return `${manifestBlock}${excerpts.join('\n\n')}${notice}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function buildPrompt(changeId, intentText, diff, base, opts = {}) {
|
|
146
|
+
const boundedDiff = buildVerifierDiffPayload(diff, { maxChars: opts.maxDiffChars ?? DEFAULT_MAX_DIFF_CHARS });
|
|
96
147
|
return `You are an INDEPENDENT VERIFIER for change ${changeId}. You did NOT author it.
|
|
97
148
|
Verify the IMPLEMENTATION satisfies the APPROVED INTENT. Be skeptical.
|
|
98
149
|
- Decide PASS/FAIL for every requirement / acceptance criterion and every task.
|
|
@@ -103,7 +154,7 @@ Output ONLY strict JSON: {"verdict":"PASS|FAIL","summary":"...","requirements":[
|
|
|
103
154
|
${intentText}
|
|
104
155
|
|
|
105
156
|
===== IMPLEMENTATION DIFF (base ${base}) =====
|
|
106
|
-
${
|
|
157
|
+
${boundedDiff}
|
|
107
158
|
`;
|
|
108
159
|
}
|
|
109
160
|
|
|
@@ -136,10 +187,10 @@ export function runVerify(changeId, opts = {}) {
|
|
|
136
187
|
const cdir = changeDir(repoRoot, slug);
|
|
137
188
|
if (!exists(cdir)) {
|
|
138
189
|
add('change', 'fail', `change '${slug}' not found`);
|
|
139
|
-
return finish(results, policy);
|
|
190
|
+
return finish(results, policy, opts);
|
|
140
191
|
}
|
|
141
192
|
add('change', 'pass', slug);
|
|
142
|
-
const effLevel = readEffectiveLevel(repoRoot, changeId);
|
|
193
|
+
const effLevel = readEffectiveLevel(repoRoot, changeId, { baseRef: base });
|
|
143
194
|
if (effLevel?.tampered) {
|
|
144
195
|
add('level-integrity', 'fail', `tampered: declared ${effLevel.declaredLevel} < recorded history ${effLevel.maxHistoryLevel}`);
|
|
145
196
|
} else {
|
|
@@ -208,7 +259,7 @@ export function runVerify(changeId, opts = {}) {
|
|
|
208
259
|
|
|
209
260
|
const isCI = opts.ci !== undefined
|
|
210
261
|
? Boolean(opts.ci)
|
|
211
|
-
: (opts.openingPr ? false : Boolean(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI
|
|
262
|
+
: (opts.openingPr ? false : Boolean(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI));
|
|
212
263
|
|
|
213
264
|
const assessment = assess({
|
|
214
265
|
stage: 'impl',
|
|
@@ -303,7 +354,10 @@ export function runVerify(changeId, opts = {}) {
|
|
|
303
354
|
else add('openspec-validate', 'fail', `${res.stdout}${res.stderr}`.trim().slice(0, 600));
|
|
304
355
|
}
|
|
305
356
|
|
|
306
|
-
const schema = checkSchema(repoRoot, {
|
|
357
|
+
const schema = checkSchema(repoRoot, {
|
|
358
|
+
expectedVersion: readYamlConfig(repoRoot)?.schemaVersion ?? null,
|
|
359
|
+
stateless: true,
|
|
360
|
+
});
|
|
307
361
|
add('schema-managed', schema.ok ? 'pass' : 'fail',
|
|
308
362
|
schema.ok ? `managed schema v${schema.installed}` : `${schema.reason}${schema.hint ? ` (${schema.hint})` : ''}`);
|
|
309
363
|
|
|
@@ -311,11 +365,28 @@ export function runVerify(changeId, opts = {}) {
|
|
|
311
365
|
const SECRET = /TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|PRIVATE_?KEY|CREDENTIAL/i;
|
|
312
366
|
const cleanEnv = Object.fromEntries(Object.entries(process.env).filter(([k]) => !SECRET.test(k)));
|
|
313
367
|
const env = { ...cleanEnv, ASDLC_CHANGE_ID: changeId, ASDLC_REPO: opts.repo ?? '', ASDLC_SPEC_SHA: specSha ?? '' };
|
|
314
|
-
|
|
368
|
+
const extChecks = readExternalChecks(repoRoot);
|
|
369
|
+
for (const check of extChecks) {
|
|
315
370
|
const res = runShell(check.command, repoRoot, { env });
|
|
316
371
|
if (res.status === 0) add(check.name, 'pass', '');
|
|
317
372
|
else add(check.name, 'fail', `${res.stdout}${res.stderr}`.trim().slice(0, 600) || `exit ${res.status}`);
|
|
318
373
|
}
|
|
374
|
+
|
|
375
|
+
// Default mapped acceptance-test execution when specs declare AC test mappings
|
|
376
|
+
if (extChecks.length === 0 && specFiles.length > 0 && blockers === 0) {
|
|
377
|
+
const hasMappedAcs = specFiles.some((f) =>
|
|
378
|
+
parseSpecAcceptanceCriteria(readText(path.join(cdir, 'specs', f))).some((ac) => ac.testPath)
|
|
379
|
+
);
|
|
380
|
+
if (hasMappedAcs) {
|
|
381
|
+
try {
|
|
382
|
+
const testExit = runTests(slug, { repoRoot, silent: true });
|
|
383
|
+
add('acceptance-tests', testExit === 0 ? 'pass' : 'fail',
|
|
384
|
+
testExit === 0 ? 'all spec-mapped acceptance tests passed' : 'one or more spec-mapped acceptance tests failed');
|
|
385
|
+
} catch (err) {
|
|
386
|
+
add('acceptance-tests', 'fail', err.message);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
319
390
|
}
|
|
320
391
|
|
|
321
392
|
const vcfg = readYamlConfig(repoRoot).verify ?? {};
|
|
@@ -325,13 +396,17 @@ export function runVerify(changeId, opts = {}) {
|
|
|
325
396
|
add('AI verification', required2 ? 'fail' : 'skip', required2 ? 'no verifier configured (set ASDLC_VERIFY_COMMAND)' : 'no verifier configured');
|
|
326
397
|
} else {
|
|
327
398
|
const diff = git(['diff', `${base}...${head}`], repoRoot, { allowFail: true }) ?? '';
|
|
328
|
-
const
|
|
399
|
+
const maxDiffChars = opts.maxDiffChars ?? vcfg.maxDiffChars ?? DEFAULT_MAX_DIFF_CHARS;
|
|
400
|
+
const res = runShell(command, repoRoot, {
|
|
401
|
+
input: buildPrompt(changeId, intent(cdir), diff, base, { maxDiffChars }),
|
|
402
|
+
timeout: 900000,
|
|
403
|
+
});
|
|
329
404
|
const report = extractJson(res.stdout) ?? { verdict: 'FAIL', summary: 'verifier produced no parseable JSON' };
|
|
330
405
|
const ok = String(report.verdict).toUpperCase() === 'PASS' && res.status === 0;
|
|
331
406
|
add('AI verification', ok ? 'pass' : 'fail', String(report.summary ?? '').slice(0, 300));
|
|
332
407
|
}
|
|
333
408
|
|
|
334
|
-
return finish(results, policy);
|
|
409
|
+
return finish(results, policy, opts);
|
|
335
410
|
}
|
|
336
411
|
|
|
337
412
|
export function register(program) {
|
|
@@ -339,11 +414,16 @@ export function register(program) {
|
|
|
339
414
|
.command('verify <changeId>')
|
|
340
415
|
.description('check the implementation: artifacts + approved SHA + tasks complete + lint + validate + AI verification')
|
|
341
416
|
.option('--repo <name>', 'repository name')
|
|
417
|
+
.option('--repo-root <dir>', 'repository root path')
|
|
342
418
|
.option('--protected-branch <ref>', 'branch the approved spec must be merged into', 'origin/main')
|
|
343
419
|
.option('--base <ref>', 'base ref for the PR diff (default: protected branch)')
|
|
344
420
|
.option('--head <ref>', 'head ref (default: HEAD)')
|
|
421
|
+
.option('--approved', 'flag indicating human lead approval is verified on PR / platform')
|
|
422
|
+
.option('--emergency', 'emergency mode bypassing standard branch checks')
|
|
423
|
+
.option('--required', 'require AI verification gate to pass')
|
|
345
424
|
.option('--skip-openspec', 'skip openspec validation')
|
|
346
425
|
.option('--skip-external', 'skip external checks from config')
|
|
426
|
+
.option('--json', 'print output in structured JSON')
|
|
347
427
|
.action((changeId, opts) => {
|
|
348
428
|
process.exitCode = runVerify(changeId, opts);
|
|
349
429
|
});
|
package/src/lib/agents.js
CHANGED
|
@@ -24,14 +24,14 @@ raw escape hatch: the wrappers ARE the guards (graph refresh, approval, checks).
|
|
|
24
24
|
(or **batch-grill-me** if \`--batch-grill\` was passed) with anti-fatigue guardrails (look facts up yourself,
|
|
25
25
|
focus on material trade-offs, lead with recommendations, early-exit on agreement), and record settled decisions
|
|
26
26
|
in \`clarifications.md\`. (If \`--no-grill\` was passed, self-settle context-inferred assumptions).
|
|
27
|
-
▶ **CRITICAL**: ONLY AFTER \`clarifications.md\` is settled may you author **proposal.md -> specs/**\`. (AI Review is
|
|
27
|
+
▶ **CRITICAL**: ONLY AFTER \`clarifications.md\` is settled may you author **proposal.md -> specs/**\`. (Independent AI Review is executed in an isolated agent session via \`asdlc-spec-review\` / \`asdlc-impl-review\` skills).
|
|
28
28
|
2. **grill** - (embedded in Stage 2) settle all design forks in \`clarifications.md\` BEFORE writing specs.
|
|
29
29
|
3. **lint** - \`asdlc lint <ID>\`: artifacts + BDD/acceptance criteria. Open Spec PR via \`asdlc pr <ID> <targetBranch>\`.
|
|
30
30
|
4. **approve** - human/TL approves (via PR merge, on PR, or in-place); \`asdlc approve <ID>\` records approved SHA + READY_FOR_IMPL.
|
|
31
31
|
5. **apply** - \`asdlc apply <ID>\` (guard: the spec must be approved), then
|
|
32
32
|
\`/opsx-apply\` with task-level TDD + task-level converge.
|
|
33
33
|
6. **verify** - \`asdlc verify <ID>\`: approved SHA, artifacts, tasks complete, tests, AI.
|
|
34
|
-
7. **archive** - \`asdlc archive <ID
|
|
34
|
+
7. **archive** - \`asdlc archive [<ID> | --merged]\`: post-merge compaction syncing specs to openspec/specs/ (updates AGENTS.md only on \`--agents\` or constitutional changes).
|
|
35
35
|
|
|
36
36
|
Need orientation? \`asdlc status <ID>\` (where am I / next command) and \`asdlc doctor\`
|
|
37
37
|
(environment health). A bad spec is never edited: close it and \`asdlc new\` again.`;
|
package/src/lib/cliutil.js
CHANGED
|
@@ -11,16 +11,64 @@ export function toChangeSlug(changeId) {
|
|
|
11
11
|
.replace(/^-+|-+$/g, '');
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Bilingual domain lexicon bridging Chinese engineering requirements to canonical English
|
|
15
|
+
// codebase symbols and readable change slugs (enabling Graphify AST queries on CJK inputs).
|
|
16
|
+
const CJK_DOMAIN_LEXICON = [
|
|
17
|
+
[/重构/, 'refactor'],
|
|
18
|
+
[/修复|排障|缺陷/, 'fix'],
|
|
19
|
+
[/清结算|清算/, 'clearing-settlement'],
|
|
20
|
+
[/支付|打款|收单/, 'payment'],
|
|
21
|
+
[/结算/, 'settlement'],
|
|
22
|
+
[/退款/, 'refund'],
|
|
23
|
+
[/账务|账本|记账|对账/, 'ledger'],
|
|
24
|
+
[/计费|账单/, 'billing'],
|
|
25
|
+
[/钱包|资金/, 'wallet'],
|
|
26
|
+
[/删表|删除.*表|清空.*表|清理历史|物理删除/, 'purge-table'],
|
|
27
|
+
[/鉴权|认证|登录态|单点登录/, 'auth'],
|
|
28
|
+
[/权限|越权|角色/, 'rbac'],
|
|
29
|
+
[/密钥|私钥|令牌|加密|脱敏/, 'secret-crypto'],
|
|
30
|
+
[/接口|出入参|协议/, 'api'],
|
|
31
|
+
[/路由|网关|控制器/, 'router'],
|
|
32
|
+
[/数据库|数据表|表结构|迁移|索引/, 'schema-db'],
|
|
33
|
+
[/订单/, 'order'],
|
|
34
|
+
[/缓存/, 'cache'],
|
|
35
|
+
[/队列|消息/, 'queue'],
|
|
36
|
+
[/配置/, 'config'],
|
|
37
|
+
[/单元测试|集成测试|测试用例/, 'test'],
|
|
38
|
+
[/文档|注释/, 'docs'],
|
|
39
|
+
[/微信/, 'wechat'],
|
|
40
|
+
[/回调|通知/, 'callback'],
|
|
41
|
+
[/状态机/, 'state-machine'],
|
|
42
|
+
[/错别字/, 'typo'],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
function extractCjkMappedTokens(text) {
|
|
46
|
+
const raw = String(text ?? '');
|
|
47
|
+
if (!/[\u4e00-\u9fff]/.test(raw)) return [];
|
|
48
|
+
const tokens = [];
|
|
49
|
+
for (const [pattern, mapped] of CJK_DOMAIN_LEXICON) {
|
|
50
|
+
if (pattern.test(raw)) {
|
|
51
|
+
for (const part of mapped.split('-')) {
|
|
52
|
+
if (!tokens.includes(part)) tokens.push(part);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return tokens;
|
|
57
|
+
}
|
|
58
|
+
|
|
14
59
|
export function extractRequirementTerms(text) {
|
|
15
|
-
const
|
|
60
|
+
const raw = String(text ?? '');
|
|
61
|
+
const s = raw
|
|
16
62
|
.replace(/\b[A-Za-z]{2,10}-\d+\b[:\s-]*/g, '')
|
|
17
63
|
.toLowerCase()
|
|
18
64
|
.replace(/\b(i\s+want\s+to\s+build|i\s+want\s+to\s+add|i\s+want\s+to|we\s+need\s+to|please\s+add|build|create|add|implement)\b/gi, '')
|
|
19
65
|
.replace(/\b(a|an|the|of|for|with|in|on|to|and|by)\b/gi, '')
|
|
20
66
|
.replace(/[^a-z0-9\s]/g, ' ')
|
|
21
67
|
.trim();
|
|
22
|
-
const
|
|
23
|
-
|
|
68
|
+
const asciiWords = s.split(/\s+/).filter(Boolean);
|
|
69
|
+
const cjkWords = extractCjkMappedTokens(raw).filter((w) => !['refactor', 'fix'].includes(w));
|
|
70
|
+
const merged = [...new Set([...asciiWords, ...cjkWords])];
|
|
71
|
+
return merged.slice(0, 6).join(' ');
|
|
24
72
|
}
|
|
25
73
|
|
|
26
74
|
export function deriveChangeSlug(input, opts = {}) {
|
|
@@ -47,11 +95,13 @@ export function deriveChangeSlug(input, opts = {}) {
|
|
|
47
95
|
|
|
48
96
|
if (!cleaned) cleaned = text.toLowerCase();
|
|
49
97
|
|
|
50
|
-
const
|
|
98
|
+
const asciiWords = cleaned
|
|
51
99
|
.replace(/[^a-z0-9\s-]/g, ' ')
|
|
52
100
|
.split(/\s+/)
|
|
53
|
-
.filter(Boolean)
|
|
54
|
-
|
|
101
|
+
.filter(Boolean);
|
|
102
|
+
|
|
103
|
+
const cjkTokens = extractCjkMappedTokens(text);
|
|
104
|
+
const words = [...new Set([...cjkTokens, ...asciiWords])].slice(0, 5);
|
|
55
105
|
|
|
56
106
|
const keywords = words.join('-');
|
|
57
107
|
if (ticket && keywords) return `${ticket}-${keywords}`.slice(0, 40).replace(/-+$/, '');
|
|
@@ -60,7 +110,7 @@ export function deriveChangeSlug(input, opts = {}) {
|
|
|
60
110
|
const fallback = toChangeSlug(text).slice(0, 40);
|
|
61
111
|
if (fallback) return fallback;
|
|
62
112
|
|
|
63
|
-
// Non-ASCII fallback
|
|
113
|
+
// Non-ASCII fallback when no domain terms matched: generate deterministic slug from content hash
|
|
64
114
|
const hash = Math.abs(text.split('').reduce((acc, c) => ((acc << 5) - acc) + c.charCodeAt(0), 0)).toString(36);
|
|
65
115
|
return `change-${hash || Date.now().toString(36)}`;
|
|
66
116
|
}
|
package/src/lib/git.js
CHANGED
|
@@ -23,12 +23,18 @@ export function currentBranch(cwd) {
|
|
|
23
23
|
return git(['rev-parse', '--abbrev-ref', 'HEAD'], cwd, { allowFail: true });
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export function safeCommit(cwd, message) {
|
|
27
|
+
const userName = git(['config', 'user.name'], cwd, { allowFail: true });
|
|
28
|
+
const userEmail = git(['config', 'user.email'], cwd, { allowFail: true });
|
|
29
|
+
const authorArgs = [];
|
|
30
|
+
if (!userName) authorArgs.push('-c', 'user.name=asdlc-bot');
|
|
31
|
+
if (!userEmail) authorArgs.push('-c', 'user.email=asdlc-bot@example.invalid');
|
|
32
|
+
return git([...authorArgs, 'commit', '-m', message], cwd);
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
export function commitAll(cwd, message) {
|
|
27
36
|
git(['add', '-A'], cwd);
|
|
28
|
-
|
|
29
|
-
['-c', 'user.name=asdlc-bot', '-c', 'user.email=asdlc-bot@example.invalid', 'commit', '-m', message],
|
|
30
|
-
cwd,
|
|
31
|
-
);
|
|
37
|
+
safeCommit(cwd, message);
|
|
32
38
|
return headSha(cwd);
|
|
33
39
|
}
|
|
34
40
|
|