@akjamie/agentic-sdlc 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -29
- package/assets/commands/asdlc-approve.md +2 -2
- package/assets/config/config.yaml +1 -1
- package/assets/policy/policy.yaml +6 -0
- package/assets/schema/risk-assessment.schema.json +2 -1
- package/assets/schema/schema.yaml +168 -168
- package/assets/skills/asdlc-apply/SKILL.md +1 -1
- package/assets/skills/asdlc-approve/SKILL.md +2 -2
- 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 +15 -25
- package/assets/skills/asdlc-init/SKILL.md +11 -18
- package/assets/skills/asdlc-new/SKILL.md +5 -2
- 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 +10 -20
- package/package.json +2 -1
- package/src/assess/ai_judge.js +106 -36
- package/src/assess/decide.js +8 -6
- package/src/assess/index.js +13 -3
- package/src/assess/rules/builtin.js +7 -2
- package/src/assess/schema.js +6 -1
- package/src/assess/vectors/v1_intent.js +53 -8
- package/src/assess/vectors/v2_security.js +24 -1
- package/src/assess/vectors/v3_topology.js +125 -13
- package/src/commands/apply.js +33 -4
- package/src/commands/approve.js +2 -3
- package/src/commands/archive.js +116 -64
- package/src/commands/doctor.js +22 -19
- package/src/commands/init.js +24 -50
- package/src/commands/lint.js +32 -2
- package/src/commands/new.js +23 -22
- package/src/commands/pr.js +106 -25
- package/src/commands/status.js +1 -1
- package/src/commands/test.js +101 -5
- package/src/commands/update.js +1 -11
- package/src/commands/verify.js +141 -34
- 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 +89 -14
- 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/speclint.js +5 -3
- package/src/lib/tdd.js +35 -11
- 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/lib/level.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { exists, readText } from './fs.js';
|
|
3
3
|
import { changeDir } from './paths.js';
|
|
4
|
-
import {
|
|
4
|
+
import { toChangeSlug } from './cliutil.js';
|
|
5
|
+
import { git } from './git.js';
|
|
6
|
+
import { assess, loadMaxHistoryLevel, loadRiskHistory } from '../assess/index.js';
|
|
5
7
|
import { RISK_LEVELS, LEVEL_RANK } from '../assess/rules/builtin.js';
|
|
6
8
|
import { fail } from './errors.js';
|
|
7
9
|
|
|
@@ -74,9 +76,46 @@ export function readChangeLevel(repoRoot, changeId) {
|
|
|
74
76
|
return eff ? eff.effectiveLevel : null;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
function readBaseBranchHistoryInfo(repoRoot, slug, baseRef) {
|
|
80
|
+
if (!repoRoot || !slug || !baseRef) return { maxLevel: null, records: [] };
|
|
81
|
+
const candidates = [baseRef];
|
|
82
|
+
if (baseRef.startsWith('origin/')) candidates.push(baseRef.slice('origin/'.length));
|
|
83
|
+
|
|
84
|
+
for (const ref of candidates) {
|
|
85
|
+
const histOut = git(['show', `${ref}:openspec/changes/${slug}/risk-history.jsonl`], repoRoot, { allowFail: true });
|
|
86
|
+
const metaOut = git(['show', `${ref}:openspec/changes/${slug}/.openspec.yaml`], repoRoot, { allowFail: true });
|
|
87
|
+
if (!histOut && !metaOut) continue;
|
|
88
|
+
|
|
89
|
+
let maxLvl = null;
|
|
90
|
+
const records = [];
|
|
91
|
+
if (histOut) {
|
|
92
|
+
for (const line of histOut.split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) {
|
|
93
|
+
try {
|
|
94
|
+
const rec = JSON.parse(line);
|
|
95
|
+
records.push(rec);
|
|
96
|
+
const lvl = rec.risk?.level;
|
|
97
|
+
if (lvl && (!maxLvl || (LEVEL_RANK[lvl] ?? 0) > (LEVEL_RANK[maxLvl] ?? 0))) {
|
|
98
|
+
maxLvl = lvl;
|
|
99
|
+
}
|
|
100
|
+
} catch { /* ignore */ }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (metaOut) {
|
|
104
|
+
const m = metaOut.match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
|
|
105
|
+
const decl = m ? m[1].toUpperCase() : null;
|
|
106
|
+
if (decl && (!maxLvl || (LEVEL_RANK[decl] ?? 0) > (LEVEL_RANK[maxLvl] ?? 0))) {
|
|
107
|
+
maxLvl = decl;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return { maxLevel: maxLvl, records };
|
|
111
|
+
}
|
|
112
|
+
return { maxLevel: null, records: [] };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function readEffectiveLevel(repoRoot, changeId, opts = {}) {
|
|
78
116
|
if (!repoRoot || !changeId) return null;
|
|
79
|
-
const
|
|
117
|
+
const slug = toChangeSlug(changeId);
|
|
118
|
+
const cdir = changeDir(repoRoot, slug);
|
|
80
119
|
const metaPath = path.join(cdir, '.openspec.yaml');
|
|
81
120
|
let declaredLevel = null;
|
|
82
121
|
if (exists(metaPath)) {
|
|
@@ -86,9 +125,11 @@ export function readEffectiveLevel(repoRoot, changeId) {
|
|
|
86
125
|
}
|
|
87
126
|
|
|
88
127
|
let maxHistory = null;
|
|
128
|
+
let localRecords = [];
|
|
89
129
|
let chainCorrupt = false;
|
|
90
130
|
try {
|
|
91
|
-
|
|
131
|
+
localRecords = loadRiskHistory(repoRoot, slug);
|
|
132
|
+
maxHistory = loadMaxHistoryLevel(repoRoot, slug);
|
|
92
133
|
} catch (err) {
|
|
93
134
|
if (err.code === 'TAMPER_DETECTED' || err.message?.includes('tamper')) {
|
|
94
135
|
chainCorrupt = true;
|
|
@@ -97,20 +138,33 @@ export function readEffectiveLevel(repoRoot, changeId) {
|
|
|
97
138
|
}
|
|
98
139
|
}
|
|
99
140
|
|
|
100
|
-
if (
|
|
141
|
+
// Anchor against target branch history if available (prevents local delete-and-regenerate attack)
|
|
142
|
+
const baseInfo = opts.baseRef ? readBaseBranchHistoryInfo(repoRoot, slug, opts.baseRef) : { maxLevel: null, records: [] };
|
|
143
|
+
if (baseInfo.records.length > 0) {
|
|
144
|
+
if (
|
|
145
|
+
localRecords.length < baseInfo.records.length ||
|
|
146
|
+
localRecords[0]?.hash !== baseInfo.records[0]?.hash
|
|
147
|
+
) {
|
|
148
|
+
chainCorrupt = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!declaredLevel && !maxHistory && !baseInfo.maxLevel && !chainCorrupt) {
|
|
101
153
|
return null;
|
|
102
154
|
}
|
|
103
155
|
|
|
104
156
|
const declaredRank = declaredLevel ? (LEVEL_RANK[declaredLevel] ?? 0) : 0;
|
|
105
157
|
const historyRank = maxHistory ? (LEVEL_RANK[maxHistory] ?? 0) : 0;
|
|
158
|
+
const baseRank = baseInfo.maxLevel ? (LEVEL_RANK[baseInfo.maxLevel] ?? 0) : 0;
|
|
159
|
+
const requiredMinRank = Math.max(historyRank, baseRank);
|
|
106
160
|
|
|
107
|
-
const tampered = chainCorrupt || Boolean(
|
|
108
|
-
const effectiveRank = Math.max(declaredRank, historyRank);
|
|
109
|
-
const effectiveLevel = Object.keys(LEVEL_RANK).find((k) => LEVEL_RANK[k] === effectiveRank) || (declaredLevel || maxHistory || 'L1');
|
|
161
|
+
const tampered = chainCorrupt || Boolean(requiredMinRank > 0 && declaredLevel && declaredRank < requiredMinRank);
|
|
162
|
+
const effectiveRank = Math.max(declaredRank, historyRank, baseRank);
|
|
163
|
+
const effectiveLevel = Object.keys(LEVEL_RANK).find((k) => LEVEL_RANK[k] === effectiveRank) || (declaredLevel || maxHistory || baseInfo.maxLevel || 'L1');
|
|
110
164
|
|
|
111
165
|
return {
|
|
112
166
|
declaredLevel,
|
|
113
|
-
maxHistoryLevel: maxHistory,
|
|
167
|
+
maxHistoryLevel: maxHistory || baseInfo.maxLevel,
|
|
114
168
|
effectiveLevel,
|
|
115
169
|
tampered
|
|
116
170
|
};
|
package/src/lib/openspec.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { exists } from './fs.js';
|
|
4
|
-
import {
|
|
5
|
+
import { packageRoot } from './paths.js';
|
|
6
|
+
import { readInstalledVersion, ensureRuntimeSchemaXdgDir } from './schema.js';
|
|
5
7
|
|
|
6
8
|
const isWin = process.platform === 'win32';
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
7
10
|
|
|
8
|
-
// PINNED:
|
|
11
|
+
// PINNED: bundled directly in @akjamie/agentic-sdlc dependencies so target Go/Java/Python
|
|
12
|
+
// repositories are NEVER polluted with package.json or node_modules.
|
|
9
13
|
export const OPENSPEC_PINNED = '1.13.2';
|
|
10
14
|
|
|
11
15
|
const quote = (value) => (/[\s"]/.test(value) ? `"${String(value).replace(/"/g, '\\"')}"` : String(value));
|
|
12
16
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
function resolveBundledOpenspecJs() {
|
|
18
|
+
try {
|
|
19
|
+
const entry = require.resolve('@fission-ai/openspec');
|
|
20
|
+
const pkgDir = path.resolve(path.dirname(entry), '..');
|
|
21
|
+
const binJs = path.join(pkgDir, 'bin', 'openspec.js');
|
|
22
|
+
if (exists(binJs)) return binJs;
|
|
23
|
+
} catch { /* fallback */ }
|
|
24
|
+
|
|
25
|
+
const fallback = path.join(packageRoot, 'node_modules', '@fission-ai', 'openspec', 'bin', 'openspec.js');
|
|
26
|
+
return exists(fallback) ? fallback : null;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
function localBin(cwd, name) {
|
|
30
|
+
if (!cwd) return null;
|
|
25
31
|
const candidates = [
|
|
26
32
|
path.join(cwd, 'node_modules', '.bin', isWin ? `${name}.cmd` : name),
|
|
27
33
|
path.join(cwd, 'node_modules', '.bin', name),
|
|
@@ -29,9 +35,9 @@ function localBin(cwd, name) {
|
|
|
29
35
|
return candidates.find((p) => exists(p)) ?? null;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
function which(name) {
|
|
38
|
+
function which(name, env = process.env) {
|
|
33
39
|
const finder = isWin ? 'where' : 'which';
|
|
34
|
-
const res = spawnSync(finder, [name], { encoding: 'utf8' });
|
|
40
|
+
const res = spawnSync(finder, [name], { encoding: 'utf8', env });
|
|
35
41
|
if (res.status !== 0) return null;
|
|
36
42
|
const lines = res.stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
|
37
43
|
if (!lines.length) return null;
|
|
@@ -39,20 +45,46 @@ function which(name) {
|
|
|
39
45
|
return lines[0];
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
export function findOpenspec(cwd) {
|
|
48
|
+
export function findOpenspec(cwd, opts = {}) {
|
|
49
|
+
const bundled = resolveBundledOpenspecJs();
|
|
50
|
+
if (bundled) return { file: bundled, kind: 'bundled', isNodeScript: true };
|
|
43
51
|
const local = localBin(cwd, 'openspec');
|
|
44
|
-
if (local) return { file: local, kind: 'local' };
|
|
45
|
-
const global = which('openspec');
|
|
46
|
-
if (global) return { file: global, kind: 'global' };
|
|
52
|
+
if (local) return { file: local, kind: 'local', isNodeScript: false };
|
|
53
|
+
const global = which('openspec', opts.env);
|
|
54
|
+
if (global) return { file: global, kind: 'global', isNodeScript: false };
|
|
47
55
|
return null;
|
|
48
56
|
}
|
|
49
57
|
|
|
58
|
+
function execFound(found, args, cwd, extraEnv = {}) {
|
|
59
|
+
const env = { ...process.env, ...extraEnv };
|
|
60
|
+
// Stateless container fallback: if host ~/.local/share/openspec lacks the managed schema,
|
|
61
|
+
// transparently supply bundled schema via XDG_DATA_HOME.
|
|
62
|
+
if (!env.XDG_DATA_HOME && !readInstalledVersion({ env })) {
|
|
63
|
+
try {
|
|
64
|
+
env.XDG_DATA_HOME = ensureRuntimeSchemaXdgDir();
|
|
65
|
+
} catch { /* non-fatal */ }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (found.isNodeScript) {
|
|
69
|
+
return spawnSync(process.execPath, [found.file, ...args], { cwd, encoding: 'utf8', env });
|
|
70
|
+
}
|
|
71
|
+
if (isWin) {
|
|
72
|
+
return spawnSync(`${quote(found.file)} ${args.map(quote).join(' ')}`, {
|
|
73
|
+
cwd,
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
shell: true,
|
|
76
|
+
env,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return spawnSync(found.file, args, { cwd, encoding: 'utf8', env });
|
|
80
|
+
}
|
|
81
|
+
|
|
50
82
|
export function runOpenspec(args, cwd) {
|
|
51
83
|
const found = findOpenspec(cwd);
|
|
52
84
|
if (!found) {
|
|
53
85
|
return { status: 127, stdout: '', stderr: 'openspec not found', missing: true };
|
|
54
86
|
}
|
|
55
|
-
const res =
|
|
87
|
+
const res = execFound(found, args, cwd);
|
|
56
88
|
return {
|
|
57
89
|
status: res.status ?? 1,
|
|
58
90
|
stdout: res.stdout ?? '',
|
|
@@ -66,21 +98,19 @@ export function openspecVersion(cwd) {
|
|
|
66
98
|
return res.status === 0 ? res.stdout.trim() : null;
|
|
67
99
|
}
|
|
68
100
|
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// `asdlc init` is fully self-contained (req: init includes openspec install).
|
|
101
|
+
// Resolves OpenSpec from asdlc's own bundled runtime without EVER writing package.json
|
|
102
|
+
// or node_modules into the target business repository (safe for Go, Java, Rust, Python repos).
|
|
72
103
|
export function ensureOpenspec(repoRoot) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
runShell('npm init -y', repoRoot);
|
|
104
|
+
const found = findOpenspec(repoRoot);
|
|
105
|
+
if (found) {
|
|
106
|
+
return { installed: true, action: found.kind === 'bundled' ? 'bundled' : 'present' };
|
|
77
107
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
return {
|
|
109
|
+
installed: false,
|
|
110
|
+
action: 'missing',
|
|
111
|
+
status: 127,
|
|
112
|
+
stderr: 'Bundled @fission-ai/openspec engine not found; reinstall @akjamie/agentic-sdlc.',
|
|
113
|
+
};
|
|
84
114
|
}
|
|
85
115
|
|
|
86
116
|
export function validateChange(cwd, { strict = true, all = true } = {}) {
|
package/src/lib/paths.js
CHANGED
|
@@ -7,8 +7,6 @@ const here = path.dirname(fileURLToPath(import.meta.url));
|
|
|
7
7
|
export const packageRoot = path.resolve(here, '..', '..');
|
|
8
8
|
export const assetsDir = path.join(packageRoot, 'assets');
|
|
9
9
|
export const configAssetFile = path.join(assetsDir, 'config', 'config.yaml');
|
|
10
|
-
export const ciAssetDir = path.join(assetsDir, 'ci');
|
|
11
|
-
export const githooksAssetDir = path.join(assetsDir, 'githooks');
|
|
12
10
|
export const policyAssetFile = path.join(assetsDir, 'policy', 'policy.yaml');
|
|
13
11
|
export const skillsAssetDir = path.join(assetsDir, 'skills');
|
|
14
12
|
export const commandsAssetDir = path.join(assetsDir, 'commands');
|
package/src/lib/policy.js
CHANGED
|
@@ -11,6 +11,10 @@ export const DEFAULT_POLICY = {
|
|
|
11
11
|
fast_path: { allow_paths: ['docs/**'], allow_kinds: [] },
|
|
12
12
|
reviewers: { spec: null, design: null },
|
|
13
13
|
ai_review: { trigger: 'on-ready-and-push', debounce_seconds: 120 },
|
|
14
|
+
staging: {
|
|
15
|
+
max_file_size_mb: 50,
|
|
16
|
+
ignore_patterns: [],
|
|
17
|
+
},
|
|
14
18
|
rollout_mode: {},
|
|
15
19
|
web_search: 'allow',
|
|
16
20
|
};
|
package/src/lib/schema.js
CHANGED
|
@@ -64,9 +64,23 @@ export function localOverride(repoRoot) {
|
|
|
64
64
|
return { present, tracked: present ? isPathTracked(repoRoot, rel) : false, path: rel };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
export const SUPPORTED_SCHEMA_VERSIONS = new Set(['1']);
|
|
68
|
+
|
|
69
|
+
// Lazily materializes a stateless XDG_DATA_HOME directory backed by bundled assets
|
|
70
|
+
// so ephemeral containers and clean hosts never fail when ~/.local/share/openspec is absent.
|
|
71
|
+
export function ensureRuntimeSchemaXdgDir() {
|
|
72
|
+
const xdgBase = path.join(os.tmpdir(), `asdlc-schema-v${builtinSchemaVersion() || '1'}`);
|
|
73
|
+
const dest = path.join(xdgBase, 'openspec', 'schemas', SCHEMA_NAME);
|
|
74
|
+
if (!exists(path.join(dest, 'schema.yaml')) && exists(schemaAssetDir)) {
|
|
75
|
+
ensureDir(path.dirname(dest));
|
|
76
|
+
copyTree(schemaAssetDir, dest);
|
|
77
|
+
}
|
|
78
|
+
return xdgBase;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The gate check: schema version matches repo pin (either centrally installed or statelessly
|
|
82
|
+
// bundled when opts.stateless is true), and NOT overridden by a committed local copy.
|
|
83
|
+
export function checkSchema(repoRoot, { expectedVersion = null, stateless = false, ...opts } = {}) {
|
|
70
84
|
const override = localOverride(repoRoot);
|
|
71
85
|
if (override.tracked) {
|
|
72
86
|
return {
|
|
@@ -75,16 +89,23 @@ export function checkSchema(repoRoot, { expectedVersion = null, ...opts } = {})
|
|
|
75
89
|
hint: 'remove openspec/schemas/' + SCHEMA_NAME + ' and run `asdlc init`',
|
|
76
90
|
};
|
|
77
91
|
}
|
|
78
|
-
const
|
|
92
|
+
const builtin = builtinSchemaVersion();
|
|
93
|
+
const installed = readInstalledVersion(opts) ?? (stateless ? builtin : null);
|
|
79
94
|
if (!installed) {
|
|
80
95
|
return { ok: false, reason: 'BU-managed schema not installed on this machine', hint: 'run `asdlc init`' };
|
|
81
96
|
}
|
|
82
|
-
if (expectedVersion
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
if (expectedVersion) {
|
|
98
|
+
const expStr = String(expectedVersion);
|
|
99
|
+
const compatible = stateless
|
|
100
|
+
? (installed === expStr || builtin === expStr || SUPPORTED_SCHEMA_VERSIONS.has(expStr))
|
|
101
|
+
: installed === expStr;
|
|
102
|
+
if (!compatible) {
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
reason: `schema version mismatch: machine has v${installed}, repo pins v${expectedVersion}`,
|
|
106
|
+
hint: 'run `asdlc init` or `asdlc upgrade`',
|
|
107
|
+
};
|
|
108
|
+
}
|
|
88
109
|
}
|
|
89
|
-
return { ok: true, installed, builtin
|
|
110
|
+
return { ok: true, installed, builtin, override };
|
|
90
111
|
}
|
package/src/lib/speclint.js
CHANGED
|
@@ -76,9 +76,10 @@ function scenarios(body) {
|
|
|
76
76
|
function acceptanceCriteria(body) {
|
|
77
77
|
const out = [];
|
|
78
78
|
for (const line of body.split('\n')) {
|
|
79
|
-
const
|
|
79
|
+
const trimmed = line.trimEnd();
|
|
80
|
+
const m = trimmed.match(/^\s*-\s*\[[ xX]\]\s*(AC\d+)\s*:\s*(.+)$/);
|
|
80
81
|
if (!m) continue;
|
|
81
|
-
const t =
|
|
82
|
+
const t = trimmed.match(/\(test:\s*([^)]+?)\s*\)/i);
|
|
82
83
|
out.push({ id: m[1], text: m[2].replace(/\(test:.*$/i, '').trim(), test: t ? t[1].trim() : null });
|
|
83
84
|
}
|
|
84
85
|
return out;
|
|
@@ -109,7 +110,8 @@ const DEFAULT_SEVERITY = {
|
|
|
109
110
|
'R8-removed-reason': 'major',
|
|
110
111
|
};
|
|
111
112
|
|
|
112
|
-
export function lintSpecText(
|
|
113
|
+
export function lintSpecText(rawText, { requireGiven = true, repoRoot = null, rules = {} } = {}) {
|
|
114
|
+
const text = String(rawText || '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
113
115
|
const findings = [];
|
|
114
116
|
const add = (code, rawSeverity, message, location = '') => {
|
|
115
117
|
const configured = rules[code] ?? DEFAULT_SEVERITY[code] ?? rawSeverity;
|
package/src/lib/tdd.js
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
export function isTestFile(file) {
|
|
4
4
|
const normalized = String(file).replace(/\\/g, '/');
|
|
5
5
|
return (
|
|
6
|
-
/(?:^|\/)(?:tests?|__tests__|spec)\//i.test(normalized) ||
|
|
7
|
-
/\.(?:test|spec)\.[a-zA-Z0-9]+$/i.test(normalized)
|
|
6
|
+
/(?:^|\/)(?:tests?|__tests__|testing|spec|fixtures?|mocks?)\//i.test(normalized) ||
|
|
7
|
+
/\.(?:test|spec)\.[a-zA-Z0-9]+$/i.test(normalized) ||
|
|
8
|
+
/_test\.go$/i.test(normalized) ||
|
|
9
|
+
/test_[^/]+\.py$/i.test(normalized) ||
|
|
10
|
+
/[^/]+_test\.py$/i.test(normalized) ||
|
|
11
|
+
/(?:^|\/).*(?:Test|Tests|TestCase|IT)\.(?:java|kt|scala)$/i.test(normalized)
|
|
8
12
|
);
|
|
9
13
|
}
|
|
10
14
|
|
|
@@ -48,24 +52,44 @@ export function checkTaskEvidence(tasksText) {
|
|
|
48
52
|
if (!tasksText || !tasksText.trim()) {
|
|
49
53
|
return { ok: false, detail: 'tasks.md is empty' };
|
|
50
54
|
}
|
|
51
|
-
const lines = tasksText.split(
|
|
52
|
-
const
|
|
53
|
-
|
|
55
|
+
const lines = tasksText.split(/\r?\n/);
|
|
56
|
+
const checkedIndices = [];
|
|
57
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
58
|
+
if (/^\s*-\s*\[[xX]\]/.test(lines[i])) checkedIndices.push(i);
|
|
59
|
+
}
|
|
60
|
+
if (checkedIndices.length === 0) {
|
|
54
61
|
return { ok: false, detail: 'no completed tasks found' };
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
const hasCheckedTestTask = checkedIndices.some((idx) => /\[TEST\]/i.test(lines[idx]));
|
|
65
|
+
|
|
66
|
+
// Each completed task must carry explicit verification / AC / test mapping,
|
|
67
|
+
// OR be an [IMPL] task paired with at least one completed [TEST] task (or nested verify/evidence sub-bullet).
|
|
68
|
+
// Standalone `- [x] 1.1 [IMPL] done` with zero [TEST] tasks and zero verification evidence is rejected.
|
|
69
|
+
const missingVerification = checkedIndices.filter((idx) => {
|
|
70
|
+
const line = lines[idx];
|
|
71
|
+
// Collect any indented sub-bullets immediately under this task
|
|
72
|
+
let block = line;
|
|
73
|
+
for (let j = idx + 1; j < lines.length; j += 1) {
|
|
74
|
+
if (/^\s*-\s*\[[ xX]\]/.test(lines[j]) || /^#+\s/.test(lines[j])) break;
|
|
75
|
+
if (/^\s{2,}[-*]/.test(lines[j])) block += `\n${lines[j]}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (/(?:verify:|test:|\(test:|\(AC\d+\)|evidence:|\[TEST\])/i.test(block)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (/\[IMPL\]/i.test(line) && hasCheckedTestTask) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
61
85
|
});
|
|
62
86
|
|
|
63
87
|
if (missingVerification.length > 0) {
|
|
64
88
|
return {
|
|
65
89
|
ok: false,
|
|
66
|
-
detail: `${missingVerification.length} completed task(s) lack verification statement or test mapping`,
|
|
90
|
+
detail: `${missingVerification.length} completed task(s) lack verification statement, paired [TEST] task, or test mapping`,
|
|
67
91
|
};
|
|
68
92
|
}
|
|
69
93
|
|
|
70
|
-
return { ok: true, detail: `${
|
|
94
|
+
return { ok: true, detail: `${checkedIndices.length} completed task(s) verified` };
|
|
71
95
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
name: ASDLC AI Review
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, synchronize, reopened, labeled]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
pull-requests: write
|
|
10
|
-
statuses: write
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
spec-ai-review:
|
|
14
|
-
name: Spec AI Review
|
|
15
|
-
if: contains(github.event.pull_request.labels.*.name, 'asdlc:spec-review')
|
|
16
|
-
runs-on: ubuntu-latest
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout code
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
with:
|
|
21
|
-
fetch-depth: 0
|
|
22
|
-
|
|
23
|
-
- name: Set up Node.js
|
|
24
|
-
uses: actions/setup-node@v4
|
|
25
|
-
with:
|
|
26
|
-
node-version: '20'
|
|
27
|
-
|
|
28
|
-
- name: Run Spec AI Review
|
|
29
|
-
env:
|
|
30
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
-
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
32
|
-
REPO: ${{ github.repository }}
|
|
33
|
-
run: |
|
|
34
|
-
# Dispatch independent AI spec reviewer (Player != Referee)
|
|
35
|
-
# using asdlc-spec-review skill instructions.
|
|
36
|
-
# The agent evaluates the PR diff, posts findings directly as a PR comment,
|
|
37
|
-
# and sets the commit status check (asdlc/spec-ai-review).
|
|
38
|
-
echo "Spec AI Review triggered for PR #${PR_NUMBER} in ${REPO}"
|
|
39
|
-
|
|
40
|
-
impl-ai-review:
|
|
41
|
-
name: Implementation AI Review
|
|
42
|
-
if: contains(github.event.pull_request.labels.*.name, 'asdlc:impl-review')
|
|
43
|
-
runs-on: ubuntu-latest
|
|
44
|
-
steps:
|
|
45
|
-
- name: Checkout code
|
|
46
|
-
uses: actions/checkout@v4
|
|
47
|
-
with:
|
|
48
|
-
fetch-depth: 0
|
|
49
|
-
|
|
50
|
-
- name: Set up Node.js
|
|
51
|
-
uses: actions/setup-node@v4
|
|
52
|
-
with:
|
|
53
|
-
node-version: '20'
|
|
54
|
-
|
|
55
|
-
- name: Run Implementation AI Review
|
|
56
|
-
env:
|
|
57
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
58
|
-
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
59
|
-
REPO: ${{ github.repository }}
|
|
60
|
-
run: |
|
|
61
|
-
# Dispatch independent AI implementation reviewer (Player != Referee)
|
|
62
|
-
# using asdlc-impl-review skill instructions.
|
|
63
|
-
# The agent evaluates the PR diff against approved specs, posts findings as a PR comment,
|
|
64
|
-
# and sets the commit status check (asdlc/impl-ai-review).
|
|
65
|
-
echo "Implementation AI Review triggered for PR #${PR_NUMBER} in ${REPO}"
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# asdlc post-merge: a merged spec PR IS the human approval (no store needed).
|
|
3
|
-
# Derive the approved SHA from the merge and stamp READY_FOR_IMPL so that task
|
|
4
|
-
# generation / implementation can start automatically.
|
|
5
|
-
#
|
|
6
|
-
# No global `asdlc` install is assumed: we try a local devDependency, then PATH,
|
|
7
|
-
# then an explicit toolkit checkout (ASDLC_TOOLKIT).
|
|
8
|
-
BRANCH="$(git symbolic-ref --quiet --short HEAD 2>/dev/null)"
|
|
9
|
-
case "$BRANCH" in main|master) ;; *) exit 0 ;; esac
|
|
10
|
-
|
|
11
|
-
run() { "$@" approve || echo "[asdlc] approval stamp skipped"; }
|
|
12
|
-
|
|
13
|
-
if [ -x node_modules/.bin/asdlc ]; then
|
|
14
|
-
run node_modules/.bin/asdlc
|
|
15
|
-
elif command -v asdlc >/dev/null 2>&1; then
|
|
16
|
-
run asdlc
|
|
17
|
-
elif [ -n "${ASDLC_TOOLKIT:-}" ] && [ -f "$ASDLC_TOOLKIT/bin/asdlc.js" ]; then
|
|
18
|
-
run node "$ASDLC_TOOLKIT/bin/asdlc.js"
|
|
19
|
-
else
|
|
20
|
-
echo "[asdlc] asdlc not found (local bin / PATH / ASDLC_TOOLKIT); skipping approval stamp"
|
|
21
|
-
fi
|
|
22
|
-
exit 0
|
package/assets/githooks/pre-push
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
# asdlc pre-push: trigger the Jenkins gate for this change. With a real SCM
|
|
3
|
-
# webhook + multibranch pipeline this is optional (demonstration/local use).
|
|
4
|
-
JENKINS_URL="${ASDLC_JENKINS_URL:-http://localhost:8080}"
|
|
5
|
-
BRANCH="$(git symbolic-ref --quiet --short HEAD 2>/dev/null)"
|
|
6
|
-
case "$BRANCH" in main|master) exit 0 ;; esac
|
|
7
|
-
|
|
8
|
-
CHANGE_ID="$(printf '%s' "${BRANCH##*/}" | tr '[:lower:]' '[:upper:]')"
|
|
9
|
-
MODE="lint"
|
|
10
|
-
case "$BRANCH" in *impl*) MODE="gate" ;; esac
|
|
11
|
-
|
|
12
|
-
echo "[asdlc] push: branch=$BRANCH change=$CHANGE_ID mode=$MODE"
|
|
13
|
-
curl -s -o /dev/null -w "[asdlc] jenkins trigger http=%{http_code}\n" -X POST \
|
|
14
|
-
"$JENKINS_URL/job/asdlc-pr/buildWithParameters" \
|
|
15
|
-
--data-urlencode "CHANGE_ID=$CHANGE_ID" \
|
|
16
|
-
--data-urlencode "MODE=$MODE" 2>/dev/null || echo "[asdlc] jenkins unreachable"
|
|
17
|
-
exit 0
|