@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.
Files changed (40) hide show
  1. package/README.md +42 -18
  2. package/assets/config/config.yaml +1 -1
  3. package/assets/policy/policy.yaml +6 -0
  4. package/assets/schema/schema.yaml +168 -168
  5. package/assets/skills/asdlc-approve/SKILL.md +1 -1
  6. package/assets/skills/asdlc-archive/SKILL.md +17 -13
  7. package/assets/skills/asdlc-doctor/SKILL.md +8 -8
  8. package/assets/skills/asdlc-impl-review/SKILL.md +2 -14
  9. package/assets/skills/asdlc-init/SKILL.md +11 -18
  10. package/assets/skills/asdlc-pr/SKILL.md +13 -8
  11. package/assets/skills/asdlc-review/SKILL.md +7 -7
  12. package/assets/skills/asdlc-spec-review/SKILL.md +2 -14
  13. package/package.json +2 -1
  14. package/src/assess/ai_judge.js +36 -3
  15. package/src/assess/rules/builtin.js +2 -2
  16. package/src/assess/vectors/v2_security.js +24 -1
  17. package/src/assess/vectors/v3_topology.js +29 -11
  18. package/src/commands/apply.js +1 -1
  19. package/src/commands/approve.js +2 -3
  20. package/src/commands/archive.js +116 -64
  21. package/src/commands/doctor.js +24 -21
  22. package/src/commands/init.js +24 -50
  23. package/src/commands/pr.js +106 -25
  24. package/src/commands/test.js +90 -21
  25. package/src/commands/update.js +1 -11
  26. package/src/commands/upgrade.js +47 -25
  27. package/src/commands/verify.js +94 -14
  28. package/src/lib/agents.js +2 -2
  29. package/src/lib/cliutil.js +57 -7
  30. package/src/lib/git.js +10 -4
  31. package/src/lib/graphify.js +22 -11
  32. package/src/lib/level.js +63 -9
  33. package/src/lib/openspec.js +61 -31
  34. package/src/lib/paths.js +0 -2
  35. package/src/lib/policy.js +4 -0
  36. package/src/lib/schema.js +32 -11
  37. package/src/lib/tdd.js +29 -9
  38. package/assets/ci/asdlc-ai-review.yml +0 -65
  39. package/assets/githooks/post-merge +0 -22
  40. package/assets/githooks/pre-push +0 -17
@@ -14,29 +14,40 @@ const GRAPH_REL = 'graphify-out/graph.json';
14
14
  const REF_REL = 'graphify-out/.asdlc_ref';
15
15
  export const GITIGNORE_LINE = 'graphify-out/';
16
16
 
17
- function which(name) {
17
+ function which(name, env = process.env) {
18
18
  const finder = process.platform === 'win32' ? 'where' : 'which';
19
- const r = spawnSync(finder, [name], { encoding: 'utf8' });
19
+ const r = spawnSync(finder, [name], { encoding: 'utf8', env });
20
20
  if (r.status !== 0) return null;
21
21
  return r.stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean)[0] ?? null;
22
22
  }
23
23
 
24
- export function graphifyAvailable() {
25
- return Boolean(which('graphify'));
24
+ export function graphifyAvailable(env = process.env) {
25
+ return Boolean(which('graphify', env));
26
26
  }
27
27
 
28
- // Default-install per the BU standard (uv preferred, else pip). Never throws.
29
- export function ensureGraphify({ autoInstall = true } = {}) {
30
- if (graphifyAvailable()) return { installed: true, action: 'present' };
28
+ // Default-install per the BU standard (uv preferred, else pip), honoring internal mirror
29
+ // env vars (PIP_INDEX_URL, UV_INDEX_URL, ASDLC_PIP_INDEX_URL) and offline air-gapped guards. Never throws.
30
+ export function ensureGraphify({ autoInstall = true, env = process.env } = {}) {
31
+ if (graphifyAvailable(env)) return { installed: true, action: 'present' };
31
32
  if (!autoInstall) return { installed: false, action: 'missing' };
32
- const viaUv = Boolean(which('uv'));
33
- const cmd = viaUv ? ['uv', 'tool', 'install', '--upgrade', 'graphifyy'] : ['pip', 'install', 'graphifyy'];
33
+ if (env.ASDLC_OFFLINE === '1' || env.ASDLC_OFFLINE === 'true') {
34
+ return { installed: false, action: 'offline-skipped' };
35
+ }
36
+
37
+ const mirrorUrl = env.ASDLC_PIP_INDEX_URL || env.PIP_INDEX_URL || env.UV_INDEX_URL || null;
38
+ const viaUv = Boolean(which('uv', env));
39
+ const viaPip = Boolean(which('pip', env));
40
+ if (!viaUv && !viaPip) return { installed: false, action: 'missing-installer' };
41
+
42
+ const cmd = viaUv
43
+ ? ['uv', 'tool', 'install', '--upgrade', '--python', '<3.14', ...(mirrorUrl ? ['--index-url', mirrorUrl] : []), 'graphifyy']
44
+ : ['pip', 'install', ...(mirrorUrl ? ['--index-url', mirrorUrl] : []), 'graphifyy'];
34
45
  try {
35
- execFileSync(cmd[0], cmd.slice(1), { encoding: 'utf8', stdio: 'pipe' });
46
+ execFileSync(cmd[0], cmd.slice(1), { encoding: 'utf8', stdio: 'pipe', env, timeout: 45000 });
36
47
  } catch {
37
48
  /* fall through to the availability check */
38
49
  }
39
- return { installed: graphifyAvailable(), action: viaUv ? 'uv-install' : 'pip-install' };
50
+ return { installed: graphifyAvailable(env), action: viaUv ? 'uv-install' : 'pip-install' };
40
51
  }
41
52
 
42
53
  function run(args, cwd) {
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 { assess, loadMaxHistoryLevel } from '../assess/index.js';
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
- export function readEffectiveLevel(repoRoot, changeId) {
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 cdir = changeDir(repoRoot, changeId);
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
- maxHistory = loadMaxHistoryLevel(repoRoot, changeId);
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 (!declaredLevel && !maxHistory && !chainCorrupt) {
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(maxHistory && declaredLevel && declaredRank < historyRank);
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
  };
@@ -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 { runShell } from './exec.js';
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: CI and dev machines must run the same engine version.
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 exec(file, args, cwd) {
14
- if (isWin) {
15
- return spawnSync(`${quote(file)} ${args.map(quote).join(' ')}`, {
16
- cwd,
17
- encoding: 'utf8',
18
- shell: true,
19
- });
20
- }
21
- return spawnSync(file, args, { cwd, encoding: 'utf8' });
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 = exec(found.file, args, cwd);
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
- // Install OpenSpec as a repo devDependency (pinned) when the CLI is absent.
70
- // Works for any repo - creates a package.json first when needed - so
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
- if (openspecVersion(repoRoot)) return { installed: true, action: 'present' };
74
-
75
- if (!exists(path.join(repoRoot, 'package.json'))) {
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
- const res = runShell(
79
- `npm install --save-dev @fission-ai/openspec@${OPENSPEC_PINNED} --no-audit --no-fund`,
80
- repoRoot,
81
- );
82
- const installed = Boolean(openspecVersion(repoRoot));
83
- return { installed, action: 'npm-install', status: res.status, stderr: (res.stderr || '').slice(0, 300) };
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
- // The gate check: schema installed centrally, version matches the repo pin,
68
- // and NOT overridden by a committed local copy.
69
- export function checkSchema(repoRoot, { expectedVersion = null, ...opts } = {}) {
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 installed = readInstalledVersion(opts);
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 && installed !== String(expectedVersion)) {
83
- return {
84
- ok: false,
85
- reason: `schema version mismatch: machine has v${installed}, repo pins v${expectedVersion}`,
86
- hint: 'run `asdlc init`',
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: builtinSchemaVersion(), override };
110
+ return { ok: true, installed, builtin, override };
90
111
  }
package/src/lib/tdd.js CHANGED
@@ -52,24 +52,44 @@ export function checkTaskEvidence(tasksText) {
52
52
  if (!tasksText || !tasksText.trim()) {
53
53
  return { ok: false, detail: 'tasks.md is empty' };
54
54
  }
55
- const lines = tasksText.split('\n');
56
- const checked = lines.filter((l) => /^\s*-\s*\[[xX]\]/.test(l));
57
- if (checked.length === 0) {
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) {
58
61
  return { ok: false, detail: 'no completed tasks found' };
59
62
  }
60
63
 
61
- // Each completed task should indicate verification:
62
- // e.g. verify:, test:, (test: ...), (AC...), evidence:, or [TEST]
63
- const missingVerification = checked.filter((l) => {
64
- return !/(?:verify:|test:|\(test:|\(AC\d+\)|evidence:|\[TEST\]|\[IMPL\])/i.test(l);
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;
65
85
  });
66
86
 
67
87
  if (missingVerification.length > 0) {
68
88
  return {
69
89
  ok: false,
70
- 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`,
71
91
  };
72
92
  }
73
93
 
74
- return { ok: true, detail: `${checked.length} completed task(s) verified` };
94
+ return { ok: true, detail: `${checkedIndices.length} completed task(s) verified` };
75
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
@@ -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