@akjamie/agentic-sdlc 1.3.0 → 1.5.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 +48 -24
- package/assets/commands/asdlc-apply.md +24 -0
- package/assets/commands/asdlc-approve.md +21 -0
- package/assets/commands/asdlc-archive.md +21 -0
- package/assets/commands/asdlc-doctor.md +24 -0
- package/assets/commands/asdlc-lint.md +30 -0
- package/assets/commands/asdlc-new.md +29 -0
- package/assets/commands/asdlc-pr.md +25 -0
- package/assets/commands/asdlc-status.md +23 -0
- package/assets/commands/asdlc-test.md +20 -0
- package/assets/commands/asdlc-verify.md +29 -0
- package/assets/schema/risk-assessment.schema.json +2 -1
- package/assets/skills/asdlc-apply/SKILL.md +1 -1
- package/assets/skills/asdlc-approve/SKILL.md +1 -1
- package/assets/skills/asdlc-impl-review/SKILL.md +13 -11
- package/assets/skills/asdlc-new/SKILL.md +20 -3
- package/assets/skills/asdlc-spec-review/SKILL.md +8 -6
- package/package.json +1 -1
- package/src/assess/ai_judge.js +70 -33
- package/src/assess/decide.js +8 -6
- package/src/assess/index.js +13 -3
- package/src/assess/rules/builtin.js +6 -1
- package/src/assess/schema.js +6 -1
- package/src/assess/vectors/v1_intent.js +53 -8
- package/src/assess/vectors/v3_topology.js +97 -3
- package/src/cli.js +1 -1
- package/src/commands/apply.js +32 -3
- package/src/commands/doctor.js +32 -4
- package/src/commands/init.js +5 -55
- package/src/commands/lint.js +41 -4
- package/src/commands/new.js +23 -22
- package/src/commands/skills.js +7 -19
- package/src/commands/status.js +170 -9
- package/src/commands/test.js +31 -4
- package/src/commands/update.js +4 -3
- package/src/commands/verify.js +47 -20
- package/src/lib/graphify.js +67 -3
- package/src/lib/paths.js +1 -0
- package/src/lib/speclint.js +5 -3
- package/src/lib/tdd.js +6 -2
- package/src/lib/tools.js +313 -0
package/src/commands/doctor.js
CHANGED
|
@@ -8,6 +8,7 @@ import { refreshAgents } from '../lib/agents.js';
|
|
|
8
8
|
import { readYaml } from '../lib/yaml.js';
|
|
9
9
|
import { git } from '../lib/git.js';
|
|
10
10
|
import { log, dim } from '../lib/log.js';
|
|
11
|
+
import { detectTools, checkToolHealth, installSkills, installCommands } from '../lib/tools.js';
|
|
11
12
|
|
|
12
13
|
// Environment + setup health. Exit non-zero only on a critical failure
|
|
13
14
|
// (no OpenSpec project, or the managed schema is not installed / is overridden).
|
|
@@ -34,6 +35,12 @@ export function doctor(opts = {}) {
|
|
|
34
35
|
const schemaV = readInstalledVersion();
|
|
35
36
|
add('managed schema', schemaV ? 'pass' : 'fail', schemaV ? `v${schemaV} (bundled v${builtinSchemaVersion()})` : 'not installed (run `asdlc init` or `asdlc upgrade`)');
|
|
36
37
|
|
|
38
|
+
let gi = null;
|
|
39
|
+
let ignored = false;
|
|
40
|
+
let hooksPath = null;
|
|
41
|
+
let hasRouting = false;
|
|
42
|
+
let detectedTools = [];
|
|
43
|
+
|
|
37
44
|
// If in global mode or not in a repository workspace, check global skills and skip repo-specific checks
|
|
38
45
|
if (isGlobal || (!isRepo && !hasProject)) {
|
|
39
46
|
const globalSkills = path.join(process.env.HOME || process.env.USERPROFILE || '', '.agents', 'skills');
|
|
@@ -52,20 +59,32 @@ export function doctor(opts = {}) {
|
|
|
52
59
|
if (exists(cfgPath)) { try { cfgSchema = (readYaml(cfgPath) ?? {}).schema ?? null; } catch { /* ignore */ } }
|
|
53
60
|
add('repo config schema', cfgSchema === 'agentic-repo-change' ? 'pass' : 'warn', cfgSchema ?? 'unset');
|
|
54
61
|
|
|
55
|
-
let hooksPath = null;
|
|
56
62
|
try { hooksPath = git(['config', '--get', 'core.hooksPath'], repoRoot, { allowFail: true }); } catch { /* ignore */ }
|
|
57
63
|
add('.githooks', hooksPath === '.githooks' ? 'pass' : 'warn', hooksPath === '.githooks' ? 'core.hooksPath=.githooks' : `core.hooksPath=${hooksPath ?? 'unset'}`);
|
|
58
64
|
|
|
59
65
|
const agents = path.join(repoRoot, 'AGENTS.md');
|
|
60
|
-
|
|
66
|
+
hasRouting = exists(agents) && readText(agents).includes('<!-- asdlc:routing -->');
|
|
61
67
|
add('AGENTS.md routing', hasRouting ? 'pass' : 'warn', hasRouting ? '' : 'missing (run `asdlc init`)');
|
|
62
68
|
|
|
63
69
|
const gstatus = graphStatus(repoRoot);
|
|
64
70
|
add('knowledge graph', gstatus === 'fresh' ? 'pass' : 'warn', gstatus);
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
gi = path.join(repoRoot, '.gitignore');
|
|
73
|
+
ignored = exists(gi) && readText(gi).split(/\r?\n/).some((l) => l.trim() === GITIGNORE_LINE);
|
|
68
74
|
add('graphify-out ignored', ignored ? 'pass' : 'warn', ignored ? '' : `add ${GITIGNORE_LINE} to .gitignore`);
|
|
75
|
+
|
|
76
|
+
// 3) Agent Tools & Slash-Command Parity Checks
|
|
77
|
+
detectedTools = detectTools(repoRoot);
|
|
78
|
+
if (detectedTools.length === 0) {
|
|
79
|
+
add('agent tools', 'pass', 'none detected (.agents used as default)');
|
|
80
|
+
} else {
|
|
81
|
+
for (const toolId of detectedTools) {
|
|
82
|
+
const health = checkToolHealth(repoRoot, toolId);
|
|
83
|
+
if (health) {
|
|
84
|
+
add(`tool: ${health.name}`, health.status, health.detail);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
69
88
|
}
|
|
70
89
|
|
|
71
90
|
let failed = 0;
|
|
@@ -121,6 +140,15 @@ export function doctor(opts = {}) {
|
|
|
121
140
|
if (g.installed) log.ok('fixed: installed graphify CLI');
|
|
122
141
|
} catch (e) { log.warn(`fix failed for graphify: ${e.message}`); }
|
|
123
142
|
}
|
|
143
|
+
|
|
144
|
+
// 7. Tool skills & slash commands remediation
|
|
145
|
+
if (detectedTools && detectedTools.length > 0) {
|
|
146
|
+
try {
|
|
147
|
+
installSkills(repoRoot, detectedTools);
|
|
148
|
+
installCommands(repoRoot, detectedTools);
|
|
149
|
+
log.ok('fixed: synchronized skills and commands for detected tools');
|
|
150
|
+
} catch (e) { log.warn(`fix failed for tool parity: ${e.message}`); }
|
|
151
|
+
}
|
|
124
152
|
log.info('');
|
|
125
153
|
}
|
|
126
154
|
|
package/src/commands/init.js
CHANGED
|
@@ -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
|
-
|
|
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());
|
|
@@ -115,11 +94,12 @@ export function initRepo(opts = {}) {
|
|
|
115
94
|
}
|
|
116
95
|
}
|
|
117
96
|
|
|
118
|
-
// 4.5) Bundled Agent Skills: install out-of-the-box skills
|
|
119
|
-
// into
|
|
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.)
|
|
120
99
|
const explicitTools = opts.tools ? opts.tools.split(',').map((s) => s.trim().toLowerCase()) : [];
|
|
121
100
|
const allTools = [...new Set([...detectTools(repoRoot), ...explicitTools])];
|
|
122
101
|
installSkills(repoRoot, allTools);
|
|
102
|
+
installCommands(repoRoot, allTools);
|
|
123
103
|
|
|
124
104
|
// 5) AGENTS.md: the routing layer the agentic IDE reads (workflow + system
|
|
125
105
|
// status derived from the graph). Written after the graph so status has nodes.
|
|
@@ -135,36 +115,6 @@ export function initRepo(opts = {}) {
|
|
|
135
115
|
return repoRoot;
|
|
136
116
|
}
|
|
137
117
|
|
|
138
|
-
// All supported tools and their skills directory name (tools that use a 'skills/' subdir convention)
|
|
139
|
-
const TOOL_SKILLS_DIRS = {
|
|
140
|
-
claude: '.claude',
|
|
141
|
-
opencode: '.opencode',
|
|
142
|
-
pi: '.pi',
|
|
143
|
-
dsh: '.dsh',
|
|
144
|
-
cursor: '.cursor',
|
|
145
|
-
gemini: '.gemini',
|
|
146
|
-
windsurf: '.windsurf',
|
|
147
|
-
trae: '.trae',
|
|
148
|
-
codex: '.codex',
|
|
149
|
-
zed: '.zed',
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export function installSkills(repoRoot, tools = []) {
|
|
153
|
-
if (!exists(skillsAssetDir)) return;
|
|
154
|
-
const targetDirs = ['.agents'];
|
|
155
|
-
for (const t of tools) {
|
|
156
|
-
const key = String(t).toLowerCase().replace(/^\./, '');
|
|
157
|
-
if (TOOL_SKILLS_DIRS[key]) targetDirs.push(TOOL_SKILLS_DIRS[key]);
|
|
158
|
-
else if (key) targetDirs.push(`.${key}`);
|
|
159
|
-
}
|
|
160
|
-
const count = listDir(skillsAssetDir).filter((d) => d.isDirectory()).length;
|
|
161
|
-
for (const dir of new Set(targetDirs)) {
|
|
162
|
-
const dest = path.join(repoRoot, dir, 'skills');
|
|
163
|
-
copyTree(skillsAssetDir, dest);
|
|
164
|
-
log.ok(`installed bundled skills (${count} skills) -> ${dir}/skills/`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
118
|
export function installHooks(repoRoot) {
|
|
169
119
|
if (!exists(githooksAssetDir)) return;
|
|
170
120
|
const dest = path.join(repoRoot, '.githooks');
|
package/src/commands/lint.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { exists, readText, walkFiles } from '../lib/fs.js';
|
|
2
|
+
import { exists, readText, writeText, walkFiles } from '../lib/fs.js';
|
|
3
3
|
import { changeDir } from '../lib/paths.js';
|
|
4
4
|
import { requireRepo, toChangeSlug, readLintConfig, jsonOut } from '../lib/cliutil.js';
|
|
5
5
|
import { lintSpecText, countBlockers } from '../lib/speclint.js';
|
|
6
|
+
import { assess } from '../assess/index.js';
|
|
6
7
|
import { log, dim } from '../lib/log.js';
|
|
7
8
|
|
|
8
9
|
// THE spec check (v10: lint absorbed review). Deterministic:
|
|
@@ -90,7 +91,7 @@ export function runLint(changeId, opts = {}) {
|
|
|
90
91
|
|
|
91
92
|
const reviewPath = path.join(cdir, 'review.md');
|
|
92
93
|
if (!exists(reviewPath)) {
|
|
93
|
-
add('review.md', 'pass', 'delegated to
|
|
94
|
+
add('review.md', 'pass', 'delegated to independent review agent (review comments & summary posted on PR)');
|
|
94
95
|
add('review verdict', 'pass', 'pending human PR review on GitHub/GitLab');
|
|
95
96
|
} else {
|
|
96
97
|
const text = readText(reviewPath);
|
|
@@ -100,6 +101,35 @@ export function runLint(changeId, opts = {}) {
|
|
|
100
101
|
add('blocking findings', hasBlockingFindings(text) ? 'fail' : 'pass', hasBlockingFindings(text) ? 'blocking findings present' : '');
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
// Spec-stage risk assessment: ground in artifacts and sync level/workflow mode
|
|
105
|
+
const metaPath = path.join(cdir, '.openspec.yaml');
|
|
106
|
+
let currLvl = null;
|
|
107
|
+
if (exists(metaPath)) {
|
|
108
|
+
const lvlMatch = readText(metaPath).match(/^\s*level:\s*['"]?([^\s'"]+)['"]?\s*$/m);
|
|
109
|
+
currLvl = lvlMatch ? lvlMatch[1].toUpperCase() : null;
|
|
110
|
+
}
|
|
111
|
+
const agentAssessPath = path.join(cdir, '.agent-assess.json');
|
|
112
|
+
if (currLvl || exists(agentAssessPath) || exists(path.join(cdir, 'risk-history.jsonl'))) {
|
|
113
|
+
const assessment = assess({
|
|
114
|
+
stage: 'spec',
|
|
115
|
+
changeId: slug,
|
|
116
|
+
repoRoot,
|
|
117
|
+
persist: true
|
|
118
|
+
});
|
|
119
|
+
const effectiveLevel = assessment.risk.level;
|
|
120
|
+
if (exists(metaPath) && currLvl !== effectiveLevel) {
|
|
121
|
+
let metaText = readText(metaPath);
|
|
122
|
+
const upsertKey = (text, key, val) => {
|
|
123
|
+
const re = new RegExp(`^\\s*${key}:\\s*.*$`, 'm');
|
|
124
|
+
return re.test(text) ? text.replace(re, `${key}: "${val}"`) : `${text.trimEnd()}\n${key}: "${val}"\n`;
|
|
125
|
+
};
|
|
126
|
+
metaText = upsertKey(metaText, 'level', effectiveLevel);
|
|
127
|
+
metaText = upsertKey(metaText, 'workflowMode', assessment.governance.workflow_mode);
|
|
128
|
+
writeText(metaPath, metaText);
|
|
129
|
+
}
|
|
130
|
+
add('governance level', 'pass', `${effectiveLevel} (${assessment.governance.workflow_mode})`);
|
|
131
|
+
}
|
|
132
|
+
|
|
103
133
|
const { rules } = readLintConfig(repoRoot);
|
|
104
134
|
const findings = [];
|
|
105
135
|
for (const file of specFiles) {
|
|
@@ -109,8 +139,15 @@ export function runLint(changeId, opts = {}) {
|
|
|
109
139
|
for (const fnd of lintSpecText(readText(path.join(cdir, 'specs', file)), { rules })) findings.push({ ...fnd, file });
|
|
110
140
|
}
|
|
111
141
|
const blockers = countBlockers(findings);
|
|
112
|
-
|
|
113
|
-
|
|
142
|
+
let bddDetail = blockers === 0 ? `${findings.length} advisory finding(s)` : `${blockers} blocker(s)`;
|
|
143
|
+
if (blockers > 0) {
|
|
144
|
+
const list = findings
|
|
145
|
+
.map((f) => `${f.code}: ${f.message}${f.location ? ` (${f.location})` : ''}`)
|
|
146
|
+
.slice(0, 5);
|
|
147
|
+
const overflow = findings.length > 5 ? ` (+${findings.length - 5} more)` : '';
|
|
148
|
+
bddDetail = `${blockers} blocker(s) [${list.join('; ')}${overflow}] (see docs/spec-format.md)`;
|
|
149
|
+
}
|
|
150
|
+
add('BDD + acceptance criteria', blockers === 0 ? 'pass' : 'fail', bddDetail);
|
|
114
151
|
|
|
115
152
|
return finish(results, { json: opts.json, changeId });
|
|
116
153
|
}
|
package/src/commands/new.js
CHANGED
|
@@ -34,28 +34,8 @@ export function newChange(requirement, opts = {}) {
|
|
|
34
34
|
// Determine grill mode: 'none' (--no-grill), 'batch' (--batch-grill), or 'interactive' (default grill-me)
|
|
35
35
|
const grillMode = opts.grill === false ? 'none' : (opts.batchGrill ? 'batch' : 'interactive');
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
const
|
|
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)
|
|
46
|
-
const metaPath = path.join(cdir, '.openspec.yaml');
|
|
47
|
-
if (exists(metaPath)) {
|
|
48
|
-
const existing = readText(metaPath).trimEnd();
|
|
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]`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const g = ensureGraphify();
|
|
37
|
+
// Grounding in knowledge graph (explore.md) before assessing initial risk level
|
|
38
|
+
const g = ensureGraphify({ autoInstall: false });
|
|
59
39
|
if (!g.installed) {
|
|
60
40
|
log.warn('[WARN] explore.md generated without graph context (Graphify not installed). Run `asdlc init --graph` to enable architectural AST index.');
|
|
61
41
|
const fallbackMd = `# Explore: ${slug}
|
|
@@ -116,6 +96,27 @@ _(unavailable - graph query error)_
|
|
|
116
96
|
}
|
|
117
97
|
}
|
|
118
98
|
|
|
99
|
+
// Infer governance level (L0, L1, L2, L3) via unified assessment engine (grounded in explore.md)
|
|
100
|
+
const { level, changeType, workflowMode, reason: levelReason } = inferInitialLevel({
|
|
101
|
+
requirement,
|
|
102
|
+
explicitLevel: opts.level,
|
|
103
|
+
repoRoot,
|
|
104
|
+
changeId: slug
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Record requirement, grill mode, and governance level in change metadata (.openspec.yaml)
|
|
108
|
+
const metaPath = path.join(cdir, '.openspec.yaml');
|
|
109
|
+
if (exists(metaPath)) {
|
|
110
|
+
const existing = readText(metaPath).trimEnd();
|
|
111
|
+
writeText(metaPath, `${existing}\nrequirement: ${JSON.stringify(requirement)}\ngrillMode: "${grillMode}"\nchangeType: "${changeType}"\nworkflowMode: "${workflowMode}"\nlevel: "${level}"\nlevelReason: ${JSON.stringify(levelReason)}\n`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (workflowMode === 'single-pr') {
|
|
115
|
+
log.ok(`assigned governance level: ${level} [Type: ${changeType}] (${levelReason}) - [Single PR mode: code & specs in one PR]`);
|
|
116
|
+
} else {
|
|
117
|
+
log.ok(`assigned governance level: ${level} [Type: ${changeType}] (${levelReason}) - [Spec-first mode: Spec PR required before implementation]`);
|
|
118
|
+
}
|
|
119
|
+
|
|
119
120
|
// Seed the grilling interview / clarification record.
|
|
120
121
|
const clar = path.join(cdir, 'clarifications.md');
|
|
121
122
|
if (!exists(clar)) {
|
package/src/commands/skills.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
75
|
+
Object.values(TOOL_REGISTRY).forEach((t) => targets.add(t.detectDir));
|
|
88
76
|
} else {
|
|
89
|
-
const
|
|
90
|
-
targets.add(
|
|
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
|
|
97
|
-
if (exists(path.join(home,
|
|
98
|
-
targets.add(
|
|
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
|
}
|
package/src/commands/status.js
CHANGED
|
@@ -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
|
-
else if (!approvedSha) next = `run: asdlc lint ${changeId} && asdlc pr ${changeId} (
|
|
59
|
+
else if (!approvedSha) next = `run: asdlc lint ${changeId} && asdlc pr ${changeId} (after independent spec review & merge, 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
|
|
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
|
+
|
package/src/commands/test.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { exists, readText, walkFiles } from '../lib/fs.js';
|
|
3
|
-
import { changeDir } from '../lib/paths.js';
|
|
3
|
+
import { changeDir, openspecDir } from '../lib/paths.js';
|
|
4
4
|
import { requireRepo, toChangeSlug } from '../lib/cliutil.js';
|
|
5
5
|
import { runShell } from '../lib/exec.js';
|
|
6
6
|
import { fail } from '../lib/errors.js';
|
|
7
7
|
import { log } from '../lib/log.js';
|
|
8
|
+
import { readYaml } from '../lib/yaml.js';
|
|
8
9
|
|
|
9
10
|
export function parseSpecAcceptanceCriteria(specText) {
|
|
10
11
|
const acs = [];
|
|
@@ -88,9 +89,35 @@ export function runTests(changeId, opts = {}) {
|
|
|
88
89
|
log.info('');
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const testCfg = path.join(openspecDir(repoRoot), 'config.yaml');
|
|
93
|
+
let configuredRunner = null;
|
|
94
|
+
if (exists(testCfg)) {
|
|
95
|
+
try {
|
|
96
|
+
const parsed = readYaml(testCfg);
|
|
97
|
+
configuredRunner = parsed?.test?.runner || parsed?.testing?.runner || null;
|
|
98
|
+
} catch { /* ignore config parse error */ }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const defaultRunner = () => {
|
|
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();
|
|
94
121
|
|
|
95
122
|
const res = runShell(runnerCmd, repoRoot, {
|
|
96
123
|
env: { NODE_TEST_CONTEXT: undefined },
|
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, 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)
|