@akjamie/agentic-sdlc 1.2.0 → 1.4.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.
Files changed (48) hide show
  1. package/LICENSE +201 -21
  2. package/README.md +239 -302
  3. package/assets/commands/asdlc-apply.md +24 -0
  4. package/assets/commands/asdlc-approve.md +21 -0
  5. package/assets/commands/asdlc-archive.md +21 -0
  6. package/assets/commands/asdlc-doctor.md +24 -0
  7. package/assets/commands/asdlc-lint.md +30 -0
  8. package/assets/commands/asdlc-new.md +29 -0
  9. package/assets/commands/asdlc-pr.md +25 -0
  10. package/assets/commands/asdlc-status.md +23 -0
  11. package/assets/commands/asdlc-test.md +20 -0
  12. package/assets/commands/asdlc-verify.md +29 -0
  13. package/assets/schema/risk-assessment.schema.json +225 -0
  14. package/assets/skills/asdlc-apply/SKILL.md +43 -18
  15. package/assets/skills/asdlc-new/SKILL.md +15 -1
  16. package/assets/skills/asdlc-verify/SKILL.md +16 -6
  17. package/package.json +2 -2
  18. package/src/assess/ai_judge.js +163 -0
  19. package/src/assess/decide.js +164 -0
  20. package/src/assess/governance.js +53 -0
  21. package/src/assess/index.js +183 -0
  22. package/src/assess/render.js +71 -0
  23. package/src/assess/rules/builtin.js +195 -0
  24. package/src/assess/schema.js +148 -0
  25. package/src/assess/store.js +138 -0
  26. package/src/assess/vectors/v1_intent.js +80 -0
  27. package/src/assess/vectors/v2_security.js +131 -0
  28. package/src/assess/vectors/v3_topology.js +107 -0
  29. package/src/cli.js +91 -89
  30. package/src/commands/apply.js +103 -36
  31. package/src/commands/assess.js +57 -0
  32. package/src/commands/doctor.js +33 -18
  33. package/src/commands/init.js +5 -64
  34. package/src/commands/lint.js +9 -2
  35. package/src/commands/new.js +19 -2
  36. package/src/commands/pr.js +27 -3
  37. package/src/commands/skills.js +7 -19
  38. package/src/commands/status.js +169 -8
  39. package/src/commands/update.js +4 -3
  40. package/src/commands/upgrade.js +1 -1
  41. package/src/commands/verify.js +109 -15
  42. package/src/lib/fs.js +26 -3
  43. package/src/lib/level.js +118 -0
  44. package/src/lib/paths.js +3 -1
  45. package/src/lib/prtype.js +17 -4
  46. package/src/lib/risk.js +50 -0
  47. package/src/lib/schema.js +4 -0
  48. package/src/lib/tools.js +313 -0
@@ -8,30 +8,9 @@ import { git } from '../lib/git.js';
8
8
  import { ensureGraphify, buildGraph, ensureGitignore } from '../lib/graphify.js';
9
9
  import { refreshAgents } from '../lib/agents.js';
10
10
  import { ensureRemoteLabels } from './pr.js';
11
+ import { detectTools, installSkills, installCommands } from '../lib/tools.js';
11
12
 
12
- // Directory -> OpenSpec tool id. We detect what the repo already uses so we can
13
- // wire OpenSpec's own agent commands/skills (we do NOT invent our own).
14
- const TOOL_DIRS = {
15
- '.opencode': 'opencode',
16
- '.claude': 'claude',
17
- '.codex': 'codex',
18
- '.pi': 'pi',
19
- '.dsh': 'dsh',
20
- '.cursor': 'cursor',
21
- '.gemini': 'gemini',
22
- '.qwen': 'qwen',
23
- '.trae': 'trae',
24
- '.zed': 'zed',
25
- '.windsurf': 'windsurf',
26
- '.devin': 'devin',
27
- '.agents': 'agents',
28
- };
29
-
30
- export function detectTools(repoRoot) {
31
- return Object.entries(TOOL_DIRS)
32
- .filter(([dir]) => exists(path.join(repoRoot, dir)))
33
- .map(([, id]) => id);
34
- }
13
+ export { detectTools, installSkills, installCommands };
35
14
 
36
15
  export function initRepo(opts = {}) {
37
16
  const repoRoot = path.resolve(opts.repoRoot ?? process.cwd());
@@ -94,15 +73,6 @@ export function initRepo(opts = {}) {
94
73
  }
95
74
  if (opts.hooks !== false) installHooks(repoRoot);
96
75
 
97
- // 3.5) Platform policy (v6 §7.3): committed, CODEOWNERS-protected. Default only.
98
- const policyDest = path.join(repoRoot, '.sdlc', 'policy.yaml');
99
- if (exists(policyDest) && !opts.force) {
100
- log.step('.sdlc/policy.yaml exists (use --force to reset)');
101
- } else {
102
- writeText(policyDest, readText(policyAssetFile));
103
- log.ok('wrote .sdlc/policy.yaml (platform-owned; protect with CODEOWNERS)');
104
- }
105
-
106
76
  // 3.6) Pre-provision remote governance labels if git remote & gh are available
107
77
  try {
108
78
  ensureRemoteLabels(repoRoot);
@@ -124,11 +94,12 @@ export function initRepo(opts = {}) {
124
94
  }
125
95
  }
126
96
 
127
- // 4.5) Bundled Agent Skills: install out-of-the-box skills (grilling, asdlc-apply)
128
- // into the project's agent tools directory (.agents/skills, .claude/skills, etc.)
97
+ // 4.5) Bundled Agent Skills & Slash Commands: install out-of-the-box skills and
98
+ // slash command parity into detected agent tools (.claude, .opencode, .pi, .agents, .github, etc.)
129
99
  const explicitTools = opts.tools ? opts.tools.split(',').map((s) => s.trim().toLowerCase()) : [];
130
100
  const allTools = [...new Set([...detectTools(repoRoot), ...explicitTools])];
131
101
  installSkills(repoRoot, allTools);
102
+ installCommands(repoRoot, allTools);
132
103
 
133
104
  // 5) AGENTS.md: the routing layer the agentic IDE reads (workflow + system
134
105
  // status derived from the graph). Written after the graph so status has nodes.
@@ -144,36 +115,6 @@ export function initRepo(opts = {}) {
144
115
  return repoRoot;
145
116
  }
146
117
 
147
- // All supported tools and their skills directory name (tools that use a 'skills/' subdir convention)
148
- const TOOL_SKILLS_DIRS = {
149
- claude: '.claude',
150
- opencode: '.opencode',
151
- pi: '.pi',
152
- dsh: '.dsh',
153
- cursor: '.cursor',
154
- gemini: '.gemini',
155
- windsurf: '.windsurf',
156
- trae: '.trae',
157
- codex: '.codex',
158
- zed: '.zed',
159
- };
160
-
161
- export function installSkills(repoRoot, tools = []) {
162
- if (!exists(skillsAssetDir)) return;
163
- const targetDirs = ['.agents'];
164
- for (const t of tools) {
165
- const key = String(t).toLowerCase().replace(/^\./, '');
166
- if (TOOL_SKILLS_DIRS[key]) targetDirs.push(TOOL_SKILLS_DIRS[key]);
167
- else if (key) targetDirs.push(`.${key}`);
168
- }
169
- const count = listDir(skillsAssetDir).filter((d) => d.isDirectory()).length;
170
- for (const dir of new Set(targetDirs)) {
171
- const dest = path.join(repoRoot, dir, 'skills');
172
- copyTree(skillsAssetDir, dest);
173
- log.ok(`installed bundled skills (${count} skills) -> ${dir}/skills/`);
174
- }
175
- }
176
-
177
118
  export function installHooks(repoRoot) {
178
119
  if (!exists(githooksAssetDir)) return;
179
120
  const dest = path.join(repoRoot, '.githooks');
@@ -109,8 +109,15 @@ export function runLint(changeId, opts = {}) {
109
109
  for (const fnd of lintSpecText(readText(path.join(cdir, 'specs', file)), { rules })) findings.push({ ...fnd, file });
110
110
  }
111
111
  const blockers = countBlockers(findings);
112
- add('BDD + acceptance criteria', blockers === 0 ? 'pass' : 'fail',
113
- blockers === 0 ? `${findings.length} advisory finding(s)` : `${blockers} blocker(s)`);
112
+ let bddDetail = blockers === 0 ? `${findings.length} advisory finding(s)` : `${blockers} blocker(s)`;
113
+ if (blockers > 0) {
114
+ const list = findings
115
+ .map((f) => `${f.code}: ${f.message}${f.location ? ` (${f.location})` : ''}`)
116
+ .slice(0, 5);
117
+ const overflow = findings.length > 5 ? ` (+${findings.length - 5} more)` : '';
118
+ bddDetail = `${blockers} blocker(s) [${list.join('; ')}${overflow}] (see docs/spec-format.md)`;
119
+ }
120
+ add('BDD + acceptance criteria', blockers === 0 ? 'pass' : 'fail', bddDetail);
114
121
 
115
122
  return finish(results, { json: opts.json, changeId });
116
123
  }
@@ -7,6 +7,8 @@ import { runOpenspec } from '../lib/openspec.js';
7
7
  import { runShell } from '../lib/exec.js';
8
8
  import { fail } from '../lib/errors.js';
9
9
  import { log } from '../lib/log.js';
10
+ import { Option } from 'commander';
11
+ import { inferInitialLevel, isSinglePrLevel } from '../lib/level.js';
10
12
 
11
13
  // STAGE 1 of the spec (v10: explore + propose are ONE step).
12
14
  // 1) scaffold the change through OpenSpec (derives canonical slug from requirement)
@@ -32,11 +34,25 @@ export function newChange(requirement, opts = {}) {
32
34
  // Determine grill mode: 'none' (--no-grill), 'batch' (--batch-grill), or 'interactive' (default grill-me)
33
35
  const grillMode = opts.grill === false ? 'none' : (opts.batchGrill ? 'batch' : 'interactive');
34
36
 
35
- // Record requirement and grill mode in change metadata (.openspec.yaml)
37
+ // Infer governance level (L0, L1, L2, L3) via unified assessment engine
38
+ const { level, changeType, workflowMode, reason: levelReason } = inferInitialLevel({
39
+ requirement,
40
+ explicitLevel: opts.level,
41
+ repoRoot,
42
+ changeId: slug
43
+ });
44
+
45
+ // Record requirement, grill mode, and governance level in change metadata (.openspec.yaml)
36
46
  const metaPath = path.join(cdir, '.openspec.yaml');
37
47
  if (exists(metaPath)) {
38
48
  const existing = readText(metaPath).trimEnd();
39
- writeText(metaPath, `${existing}\nrequirement: ${JSON.stringify(requirement)}\ngrillMode: "${grillMode}"\n`);
49
+ writeText(metaPath, `${existing}\nrequirement: ${JSON.stringify(requirement)}\ngrillMode: "${grillMode}"\nchangeType: "${changeType}"\nworkflowMode: "${workflowMode}"\nlevel: "${level}"\nlevelReason: ${JSON.stringify(levelReason)}\n`);
50
+ }
51
+
52
+ if (workflowMode === 'single-pr') {
53
+ log.ok(`assigned governance level: ${level} [Type: ${changeType}] (${levelReason}) - [Single PR mode: code & specs in one PR]`);
54
+ } else {
55
+ log.ok(`assigned governance level: ${level} [Type: ${changeType}] (${levelReason}) - [Spec-first mode: Spec PR required before implementation]`);
40
56
  }
41
57
 
42
58
  const g = ensureGraphify();
@@ -225,6 +241,7 @@ export function register(program) {
225
241
  .option('--no-design', 'skip generating technical design (design.md)')
226
242
  .option('--batch-grill', 'use batch-grill-me (present entire decision frontier in structured batches)')
227
243
  .option('--no-grill', 'skip interactive grilling interview (self-settle decisions in clarifications.md)')
244
+ .addOption(new Option('--level <level>', 'internal governance level override (hidden)').hideHelp())
228
245
  .option('--repo-root <path>')
229
246
  .action((requirement, opts) => {
230
247
  newChange(requirement, opts);
@@ -8,6 +8,8 @@ import { runLint } from './lint.js';
8
8
  import { runVerify } from './verify.js';
9
9
  import { fail } from '../lib/errors.js';
10
10
  import { log } from '../lib/log.js';
11
+ import { assess, renderLabels, renderPRComment } from '../assess/index.js';
12
+ import { readEffectiveLevel } from '../lib/level.js';
11
13
 
12
14
  export const ASDLC_LABELS = {
13
15
  'asdlc:spec-review': {
@@ -88,6 +90,10 @@ export async function createPR(changeId, targetBranch, opts = {}) {
88
90
  .split(/\r?\n/).filter(Boolean);
89
91
  const hasSourceChanges = diffFiles.some((f) => !f.startsWith(`openspec/changes/${slug}/`));
90
92
 
93
+ const lvlMatch = metaText.match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
94
+ const changeLevel = lvlMatch ? lvlMatch[1].toUpperCase() : null;
95
+ const isSinglePr = changeLevel === 'L0' || changeLevel === 'L1';
96
+
91
97
  let prType;
92
98
  if (opts.type) {
93
99
  prType = opts.type.toLowerCase();
@@ -96,6 +102,7 @@ export async function createPR(changeId, targetBranch, opts = {}) {
96
102
  changeStatus === 'ready_for_impl' ||
97
103
  Boolean(specSha) ||
98
104
  currentBranch.startsWith('impl/') ||
105
+ (isSinglePr && hasSourceChanges) ||
99
106
  (hasSourceChanges && (checkedCount > 0 || uncheckedCount === 0))
100
107
  ) {
101
108
  prType = 'impl';
@@ -122,6 +129,7 @@ export async function createPR(changeId, targetBranch, opts = {}) {
122
129
  repoRoot,
123
130
  base: targetBranch,
124
131
  protectedBranch: targetBranch,
132
+ openingPr: true,
125
133
  ...opts,
126
134
  });
127
135
  if (verifyExit !== 0) {
@@ -200,7 +208,23 @@ ${proposalText}
200
208
  `;
201
209
  }
202
210
 
203
- // 6. Multi-tier PR creation strategy:
211
+ // 6. Assessment Governance & PR Metadata
212
+ const assessment = assess({
213
+ stage: isSpec ? 'spec' : 'impl',
214
+ changeId: slug,
215
+ baseSha: targetBranch,
216
+ headSha: 'HEAD',
217
+ changedFiles: diffFiles,
218
+ repoRoot,
219
+ persist: false
220
+ });
221
+ const assessLabels = renderLabels(assessment);
222
+ const assessComment = renderPRComment(assessment);
223
+ const labelsToApply = Array.from(new Set([labelPrefix, secondaryLabel, ...assessLabels]));
224
+
225
+ body = `${body}\n\n---\n\n${assessComment}\n`;
226
+
227
+ // 7. Multi-tier PR creation strategy:
204
228
  // Tier 1: Platform CLI (gh / glab)
205
229
  // Tier 2: Direct REST API (GITHUB_TOKEN / GITLAB_TOKEN)
206
230
  // Tier 3: 1-click Web compare URL fallback
@@ -213,7 +237,7 @@ ${proposalText}
213
237
 
214
238
  // Pre-provision governance labels on remote before PR creation (so gh pr create doesn't reject unknown labels)
215
239
  if (remoteInfo?.isGitHub) {
216
- ensureRemoteLabels(repoRoot, [labelPrefix, secondaryLabel]);
240
+ ensureRemoteLabels(repoRoot, labelsToApply);
217
241
  }
218
242
 
219
243
  // Attempt Tier 1: CLI (gh)
@@ -224,7 +248,7 @@ ${proposalText}
224
248
  '--body', body,
225
249
  '--base', targetBranch,
226
250
  '--head', currentBranch,
227
- '--label', `${labelPrefix},${secondaryLabel}`,
251
+ '--label', labelsToApply.join(','),
228
252
  ], { cwd: repoRoot, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
229
253
  prCreated = true;
230
254
  prUrl = out.trim();
@@ -7,19 +7,7 @@ import { detectTools, installSkills } from './init.js';
7
7
  import { fail } from '../lib/errors.js';
8
8
  import { log } from '../lib/log.js';
9
9
 
10
- // Standard agent tools and their home/global directories
11
- const GLOBAL_TOOL_DIRS = {
12
- agents: '.agents',
13
- opencode: '.opencode',
14
- pi: '.pi',
15
- dsh: '.dsh',
16
- claude: '.claude',
17
- cursor: '.cursor',
18
- codex: '.codex',
19
- trae: '.trae',
20
- zed: '.zed',
21
- gemini: '.gemini',
22
- };
10
+ import { TOOL_REGISTRY, getToolDefinition } from '../lib/tools.js';
23
11
 
24
12
  /**
25
13
  * Parse YAML frontmatter from a SKILL.md file
@@ -84,18 +72,18 @@ export function installGlobalSkills(opts = {}) {
84
72
  const requested = opts.tools.split(',').map((t) => t.trim().toLowerCase());
85
73
  for (const tool of requested) {
86
74
  if (tool === 'all') {
87
- Object.values(GLOBAL_TOOL_DIRS).forEach((dir) => targets.add(dir));
75
+ Object.values(TOOL_REGISTRY).forEach((t) => targets.add(t.detectDir));
88
76
  } else {
89
- const clean = tool.replace(/^\./, '');
90
- targets.add(GLOBAL_TOOL_DIRS[clean] || `.${clean}`);
77
+ const def = getToolDefinition(tool);
78
+ targets.add(def ? def.detectDir : `.${tool.replace(/^\./, '')}`);
91
79
  }
92
80
  }
93
81
  } else {
94
82
  // If no explicit tools given, always install to .agents (universal)
95
83
  // plus any detected tool directories present in home
96
- for (const [tool, dir] of Object.entries(GLOBAL_TOOL_DIRS)) {
97
- if (exists(path.join(home, dir))) {
98
- targets.add(dir);
84
+ for (const tool of Object.values(TOOL_REGISTRY)) {
85
+ if (exists(path.join(home, tool.detectDir))) {
86
+ targets.add(tool.detectDir);
99
87
  }
100
88
  }
101
89
  }
@@ -1,11 +1,12 @@
1
1
  import path from 'node:path';
2
- import { exists, readText, walkFiles } from '../lib/fs.js';
3
- import { changeDir } from '../lib/paths.js';
2
+ import { exists, readText, walkFiles, listDir } from '../lib/fs.js';
3
+ import { changeDir, openspecDir, CHANGES_DIR } from '../lib/paths.js';
4
4
  import { requireRepo, toChangeSlug } from '../lib/cliutil.js';
5
5
  import { lastCommitTouching } from '../lib/git.js';
6
6
  import { verdictOf } from './lint.js';
7
7
  import { countUncheckedTasks } from './verify.js';
8
8
  import { log } from '../lib/log.js';
9
+ import { isSinglePrLevel } from '../lib/level.js';
9
10
 
10
11
  // "Where am I?" for a change - a read-only view of the 7 stages from the working
11
12
  // tree + git. Useful for humans and for an agent deciding the next command.
@@ -16,6 +17,14 @@ export function statusChange(changeId, opts = {}) {
16
17
  const cdir = changeDir(repoRoot, slug);
17
18
 
18
19
  if (!exists(cdir)) {
20
+ if (opts.json) {
21
+ log.plain(JSON.stringify({
22
+ change: slug,
23
+ exists: false,
24
+ next: `asdlc new ${changeId}`
25
+ }, null, 2));
26
+ return 0;
27
+ }
19
28
  log.plain(`change: ${slug}`);
20
29
  log.plain(' (not created)');
21
30
  log.plain(`next: asdlc new ${changeId}`);
@@ -31,6 +40,11 @@ export function statusChange(changeId, opts = {}) {
31
40
  const approvedSha = lastCommitTouching(repoRoot, branch, locked);
32
41
  const unchecked = has('tasks.md') ? countUncheckedTasks(readText(path.join(cdir, 'tasks.md'))) : null;
33
42
 
43
+ const metaPath = path.join(cdir, '.openspec.yaml');
44
+ let metaText = exists(metaPath) ? readText(metaPath) : '';
45
+ const levelMatch = metaText.match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
46
+ const level = levelMatch ? levelMatch[1].toUpperCase() : 'L1';
47
+
34
48
  const stage = [
35
49
  ['1 explore (draft)', has('explore.md')],
36
50
  ['2 proposal.md', has('proposal.md')],
@@ -39,27 +53,174 @@ export function statusChange(changeId, opts = {}) {
39
53
  ['4 tasks complete', unchecked === 0],
40
54
  ];
41
55
 
42
- log.plain(`change: ${slug}`);
43
- for (const [name, ok] of stage) log.plain(` [${ok ? 'x' : ' '}] ${name}`);
44
-
45
56
  let next;
46
57
  if (!has('explore.md') && !has('proposal.md')) next = `asdlc new ${changeId}`;
47
58
  else if (!has('proposal.md') || specFiles.length === 0) next = 'author proposal.md + specs/**';
48
59
  else if (!approvedSha) next = `run: asdlc lint ${changeId} && asdlc pr ${changeId} (CI handles AI review on PR; once merged run: asdlc approve ${changeId})`;
49
60
  else if (unchecked !== 0) next = `asdlc apply ${changeId}, then complete tasks in tasks.md`;
50
61
  else next = `asdlc verify ${changeId}`;
62
+
63
+ if (opts.json) {
64
+ log.plain(JSON.stringify({
65
+ change: slug,
66
+ exists: true,
67
+ level,
68
+ stage: stage.map(([name, ok]) => ({ name, ok })),
69
+ next
70
+ }, null, 2));
71
+ return 0;
72
+ }
73
+
74
+ log.plain(`change: ${slug}`);
75
+ for (const [name, ok] of stage) log.plain(` [${ok ? 'x' : ' '}] ${name}`);
51
76
  log.plain('');
52
77
  log.plain(`next: ${next}`);
53
78
  return 0;
54
79
  }
55
80
 
81
+ // Portfolio overview across all active (in-flight) changes.
82
+ // Deliberately excludes completed/archived changes to keep output compact and scannable.
83
+ export function statusPortfolio(opts = {}) {
84
+ const repoRoot = requireRepo(opts);
85
+ const branch = opts.protectedBranch ?? 'origin/main';
86
+ const cdirRoot = path.join(openspecDir(repoRoot), CHANGES_DIR);
87
+
88
+ if (!exists(cdirRoot)) {
89
+ if (opts.json) {
90
+ log.plain(JSON.stringify({ total: 0, active: [] }, null, 2));
91
+ return 0;
92
+ }
93
+ log.plain('No active changes in flight.');
94
+ log.plain('Run: asdlc new "<requirement>"');
95
+ return 0;
96
+ }
97
+
98
+ const entries = listDir(cdirRoot).filter((e) => e.isDirectory() && e.name !== 'archive');
99
+ const active = [];
100
+
101
+ for (const entry of entries) {
102
+ const slug = entry.name;
103
+ const cdir = path.join(cdirRoot, slug);
104
+
105
+ // Skip archived changes
106
+ const metaPath = path.join(cdir, '.openspec.yaml');
107
+ let metaText = exists(metaPath) ? readText(metaPath) : '';
108
+ if (/status:\s*['"]?archived['"]?/i.test(metaText)) continue;
109
+
110
+ const has = (f) => exists(path.join(cdir, f));
111
+ const specFiles = exists(path.join(cdir, 'specs'))
112
+ ? walkFiles(path.join(cdir, 'specs')).filter((f) => f.endsWith('spec.md')) : [];
113
+
114
+ const levelMatch = metaText.match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
115
+ const level = levelMatch ? levelMatch[1].toUpperCase() : 'L1';
116
+
117
+ const reqMatch = metaText.match(/^\s*requirement:\s*([^\r\n]+)/m);
118
+ let requirement = reqMatch ? reqMatch[1].trim() : null;
119
+ if (requirement?.startsWith('"') && requirement?.endsWith('"')) {
120
+ try { requirement = JSON.parse(requirement); } catch { /* keep raw */ }
121
+ }
122
+
123
+ const locked = [`openspec/changes/${slug}/proposal.md`, `openspec/changes/${slug}/specs`];
124
+ const approvedSha = lastCommitTouching(repoRoot, branch, locked);
125
+ const unchecked = has('tasks.md') ? countUncheckedTasks(readText(path.join(cdir, 'tasks.md'))) : null;
126
+ const isSinglePr = isSinglePrLevel(level);
127
+ const statusMatch = metaText.match(/^\s*status:\s*['"]?([^\s'"]+)['"]?\s*$/m);
128
+ const recordedStatus = statusMatch ? statusMatch[1].toLowerCase() : null;
129
+
130
+ let stage = '';
131
+ let next = '';
132
+
133
+ if (!has('explore.md') && !has('proposal.md')) {
134
+ stage = 'Draft (Explore)';
135
+ next = `asdlc new ${slug}`;
136
+ } else if (!has('proposal.md') || specFiles.length === 0) {
137
+ stage = 'Drafting Specs';
138
+ next = `author proposal.md + specs/**`;
139
+ } else if (isSinglePr) {
140
+ if (unchecked === null) {
141
+ stage = 'Ready for Impl';
142
+ next = `asdlc apply ${slug}`;
143
+ } else if (unchecked > 0) {
144
+ stage = `Implementing (${unchecked} left)`;
145
+ next = `asdlc apply ${slug}`;
146
+ } else {
147
+ stage = 'Ready to Verify';
148
+ next = `asdlc verify ${slug}`;
149
+ }
150
+ } else {
151
+ // Spec-first mode (L2 / L3)
152
+ if (!approvedSha && recordedStatus !== 'ready_for_impl') {
153
+ stage = 'Spec Review';
154
+ next = `asdlc lint ${slug} && asdlc pr ${slug}`;
155
+ } else if (unchecked === null) {
156
+ stage = 'Spec Approved';
157
+ next = `asdlc apply ${slug}`;
158
+ } else if (unchecked > 0) {
159
+ stage = `Implementing (${unchecked} left)`;
160
+ next = `asdlc apply ${slug}`;
161
+ } else {
162
+ stage = 'Ready to Verify';
163
+ next = `asdlc verify ${slug}`;
164
+ }
165
+ }
166
+
167
+ active.push({
168
+ slug,
169
+ level,
170
+ stage,
171
+ next,
172
+ requirement
173
+ });
174
+ }
175
+
176
+ active.sort((a, b) => a.slug.localeCompare(b.slug));
177
+
178
+ if (active.length === 0) {
179
+ if (opts.json) {
180
+ log.plain(JSON.stringify({ total: 0, active: [] }, null, 2));
181
+ return 0;
182
+ }
183
+ log.plain('No active changes in flight.');
184
+ log.plain('Run: asdlc new "<requirement>"');
185
+ return 0;
186
+ }
187
+
188
+ if (opts.json) {
189
+ log.plain(JSON.stringify({
190
+ total: active.length,
191
+ active
192
+ }, null, 2));
193
+ return 0;
194
+ }
195
+
196
+ // Render clean, compact table
197
+ log.plain(`Active changes (${active.length} in flight):\n`);
198
+
199
+ const colSlug = Math.max(6, ...active.map((a) => a.slug.length));
200
+ const colLevel = 5;
201
+ const colStage = Math.max(5, ...active.map((a) => a.stage.length));
202
+
203
+ const pad = (str, len) => str + ' '.repeat(Math.max(0, len - str.length));
204
+
205
+ log.plain(` ${pad('CHANGE', colSlug)} ${pad('LEVEL', colLevel)} ${pad('STAGE', colStage)} NEXT COMMAND`);
206
+ log.plain(` ${'-'.repeat(colSlug)} ${'-'.repeat(colLevel)} ${'-'.repeat(colStage)} ${'-'.repeat(24)}`);
207
+
208
+ for (const a of active) {
209
+ log.plain(` ${pad(a.slug, colSlug)} ${pad(a.level, colLevel)} ${pad(a.stage, colStage)} ${a.next}`);
210
+ }
211
+ log.plain('');
212
+ return 0;
213
+ }
214
+
56
215
  export function register(program) {
57
216
  program
58
- .command('status <changeId>')
59
- .description('show where a change is in the 7 stages + the next command')
217
+ .command('status [changeId]')
218
+ .description('show where a change is in the 7 stages + the next command (or portfolio overview if omitted)')
60
219
  .option('--protected-branch <ref>', 'branch the approved spec must be merged into', 'origin/main')
61
220
  .option('--repo-root <path>')
221
+ .option('--json', 'output machine-readable JSON')
62
222
  .action((changeId, opts) => {
63
- process.exitCode = statusChange(changeId, opts);
223
+ process.exitCode = changeId ? statusChange(changeId, opts) : statusPortfolio(opts);
64
224
  });
65
225
  }
226
+
@@ -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, installHooks } from './init.js';
5
+ import { detectTools, installSkills, installCommands, installHooks } from './init.js';
6
6
  import { ensureGraphify, buildGraph, ensureGitignore } from '../lib/graphify.js';
7
7
  import { refreshAgents } from '../lib/agents.js';
8
8
 
@@ -38,11 +38,12 @@ export function updateRepo(opts = {}) {
38
38
  log.info(`Repository: ${repoRoot}`);
39
39
  log.info('');
40
40
 
41
- // 1) Skills refresh
41
+ // 1) Skills & slash commands refresh
42
42
  if (opts.skills !== false) {
43
- log.step('refreshing bundled agent skills in repository...');
43
+ log.step('refreshing bundled agent skills and slash commands in repository...');
44
44
  const tools = detectTools(repoRoot);
45
45
  installSkills(repoRoot, tools);
46
+ installCommands(repoRoot, tools);
46
47
  }
47
48
 
48
49
  // 2) Codebase AST knowledge graph (KB / graphify)
@@ -111,7 +111,7 @@ export function upgradeSchema() {
111
111
  log.warn(`schema asset directory missing at ${schemaAssetDir}`);
112
112
  return false;
113
113
  }
114
- const dest = installSchema();
114
+ const dest = installSchema({ force: true });
115
115
  log.ok(`refreshed schema v${builtinSchemaVersion()} -> ${dest}`);
116
116
  return true;
117
117
  } catch (err) {