agjan 0.0.22 → 0.0.25
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 +6 -4
- package/dist/adapters/claude-code.js +3 -3
- package/dist/baseline.js +2 -2
- package/dist/browser.js +25 -8
- package/dist/cli.js +22 -4
- package/dist/commands/check.js +91 -7
- package/dist/commands/discover.js +54 -0
- package/dist/commands/fix.js +8 -3
- package/dist/commands/gates.js +48 -28
- package/dist/commands/import.js +73 -0
- package/dist/commands/log.js +3 -2
- package/dist/commands/map.js +6 -1
- package/dist/commands/new.js +7 -3
- package/dist/commands/pr-summary.js +20 -5
- package/dist/commands/progress.js +1 -1
- package/dist/commands/report.js +1 -1
- package/dist/commands/review.js +21 -9
- package/dist/commands/setup.js +51 -1
- package/dist/commands/status.js +118 -20
- package/dist/commands/summary.js +2 -1
- package/dist/commands/team.js +45 -0
- package/dist/commands/test.js +37 -0
- package/dist/config.js +9 -1
- package/dist/defaults-file.js +33 -0
- package/dist/discovery.js +42 -0
- package/dist/feature.js +14 -7
- package/dist/imports.js +197 -0
- package/dist/plan.js +1 -1
- package/dist/progress-view.js +46 -11
- package/dist/qa.js +27 -3
- package/dist/readiness.js +33 -0
- package/dist/review-policy.js +2 -1
- package/dist/review.js +68 -17
- package/dist/schema.js +4 -0
- package/dist/story.js +15 -8
- package/dist/teams.js +127 -0
- package/dist/test-run.js +101 -0
- package/dist/types.js +0 -4
- package/dist/workflow.js +83 -0
- package/docs/guide.md +166 -24
- package/kit/domains/btp/domain.json +1 -0
- package/kit/hooks/guard.mjs +134 -6
- package/kit/skills/agjan-ask/SKILL.md +20 -9
- package/kit/skills/agjan-build/SKILL.md +6 -5
- package/kit/skills/agjan-design/SKILL.md +2 -2
- package/kit/skills/agjan-discover/SKILL.md +87 -0
- package/kit/skills/agjan-fix/SKILL.md +10 -6
- package/kit/skills/agjan-map/SKILL.md +12 -8
- package/kit/skills/agjan-spec/SKILL.md +14 -7
- package/kit/skills/agjan-verify/SKILL.md +27 -17
- package/kit/skills/btp-architect/SKILL.md +1 -1
- package/kit/skills/btp-architect/references/security.md +1 -1
- package/kit/skills/cap-developer/SKILL.md +1 -1
- package/kit/skills/cap-developer/references/project-setup.md +1 -1
- package/kit/skills/cap-developer/references/validation-security.md +1 -1
- package/kit/skills/fiori-developer/SKILL.md +1 -1
- package/kit/skills/qa-tester/SKILL.md +4 -2
- package/kit/templates/agents-block.md +13 -6
- package/kit/templates/progress.html +2 -2
- package/kit/templates/proposal.md +22 -0
- package/package.json +1 -1
- package/schemas/approvals.schema.json +9 -1
- package/schemas/config.defaults.json +66 -0
- package/schemas/config.schema.json +33 -1
- package/schemas/log.schema.json +1 -1
- package/schemas/reviews.schema.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { loadFeature, selectFeature } from '../feature.js';
|
|
3
|
+
import { AgjanError, UsageError } from '../errors.js';
|
|
4
|
+
import { UI_SCRIPT } from '../browser.js';
|
|
5
|
+
import { TEST_RUN_FILE, runTests } from '../test-run.js';
|
|
6
|
+
/**
|
|
7
|
+
* agjan test [--feature <slug>]: runs the feature's test commands (`verify.<area>.test`,
|
|
8
|
+
* else `npm test`) and its UI tests where a browser can start, and records the run with
|
|
9
|
+
* the change it ran on in the feature's tests.json (decision 88). Exit code 1 when a test
|
|
10
|
+
* command or the UI tests fail. Output stays short: a line per command, the end of the
|
|
11
|
+
* output of what failed.
|
|
12
|
+
*/
|
|
13
|
+
export function run(ctx, argv) {
|
|
14
|
+
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { feature: { type: 'string' } } });
|
|
15
|
+
if (positionals.length)
|
|
16
|
+
throw new UsageError('usage: agjan test [--feature <slug>]');
|
|
17
|
+
const feature = loadFeature(ctx.root, selectFeature(ctx.root, ctx.config, values.feature));
|
|
18
|
+
if (feature.kind !== 'feature' || feature.stage !== 'build')
|
|
19
|
+
throw new AgjanError(`${feature.slug} is not in Build: agjan test records the tests of a built feature`);
|
|
20
|
+
const s = ctx.style;
|
|
21
|
+
const result = runTests(ctx.root, ctx.config, feature, ctx.now, (line) => ctx.out(s.gray(line)));
|
|
22
|
+
for (const r of result.runs) {
|
|
23
|
+
const verdict = r.exit === 0 ? s.green('passed') : s.red(r.exit === null ? 'stopped' : `failed (exit code ${r.exit})`);
|
|
24
|
+
ctx.out(`${s.bold(r.command)}: ${verdict} ${s.gray(`(${(r.ms / 1000).toFixed(1)} s)`)}`);
|
|
25
|
+
}
|
|
26
|
+
const ui = result.ui;
|
|
27
|
+
if (ui.state === 'skipped')
|
|
28
|
+
ctx.out(`${s.bold(`npm run ${UI_SCRIPT}`)}: ${s.yellow('skipped')}: ${ui.reason} (npx agjan ui-test says how to enable it; name the UI ACs to the user)`);
|
|
29
|
+
else if (ui.state !== 'none')
|
|
30
|
+
ctx.out(`${s.bold(`npm run ${UI_SCRIPT}`)}: ${ui.state === 'passed' ? s.green('passed') : s.red('failed')}`);
|
|
31
|
+
const failedAcs = Object.entries(result.results ?? {}).filter(([, c]) => c.failed).map(([id]) => id);
|
|
32
|
+
if (result.results)
|
|
33
|
+
ctx.out(`ACs in the results: ${Object.keys(result.results).length}${failedAcs.length ? `, failing: ${s.red(failedAcs.join(', '))}` : ''}`);
|
|
34
|
+
const passed = result.runs.every((r) => r.exit === 0) && ui.state !== 'failed';
|
|
35
|
+
ctx.out(`${passed ? s.green('recorded') : s.red('recorded, failed')}: ${feature.slug}/${TEST_RUN_FILE} for this change${passed ? '' : '; fix the code, then run npx agjan test again'}`);
|
|
36
|
+
return passed ? 0 : 1;
|
|
37
|
+
}
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { readJson } from './json-file.js';
|
|
3
|
+
import { importedTeams } from './imports.js';
|
|
3
4
|
import { AgjanError } from './errors.js';
|
|
4
5
|
import { git } from './git.js';
|
|
5
6
|
import { loadSchema, validate } from './schema.js';
|
|
@@ -22,13 +23,14 @@ export function agentModel(config, host, tier) {
|
|
|
22
23
|
return value && value !== SESSION_MODEL ? value : undefined;
|
|
23
24
|
}
|
|
24
25
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
|
25
|
-
const DEFAULTS = {
|
|
26
|
+
export const DEFAULTS = {
|
|
26
27
|
domains: ['btp'],
|
|
27
28
|
hosts: ['claude-code'],
|
|
28
29
|
language: 'en',
|
|
29
30
|
git: { base: null },
|
|
30
31
|
scope: { implicit: {} },
|
|
31
32
|
risk_paths: [],
|
|
33
|
+
application: [],
|
|
32
34
|
tests: {},
|
|
33
35
|
fix: {
|
|
34
36
|
max_total: 80,
|
|
@@ -40,6 +42,7 @@ const DEFAULTS = {
|
|
|
40
42
|
lint: {},
|
|
41
43
|
build: { fix_attempts: 3 },
|
|
42
44
|
review: { build: 'area', rounds: 3 },
|
|
45
|
+
test_evidence: 'run',
|
|
43
46
|
ci: { policy_changes: 'warn', untracked_changes: 'fail' },
|
|
44
47
|
limits: { spec_kb: 12, design_kb: 20 },
|
|
45
48
|
};
|
|
@@ -101,6 +104,7 @@ export function loadConfig(root) {
|
|
|
101
104
|
verify,
|
|
102
105
|
lint,
|
|
103
106
|
risk_paths: [...config.risk_paths, ...(domain.risk_paths ?? [])],
|
|
107
|
+
application: [...config.application, ...(domain.application ?? [])],
|
|
104
108
|
fix: { protected: [...config.fix.protected, ...(domain.protected ?? [])] },
|
|
105
109
|
watched: [...(config.watched ?? []), ...(domain.watched ?? [])],
|
|
106
110
|
});
|
|
@@ -111,6 +115,10 @@ export function loadConfig(root) {
|
|
|
111
115
|
areas[area.name] = area;
|
|
112
116
|
}
|
|
113
117
|
config = merge(config, project);
|
|
118
|
+
// Imported teams (decision 93) sit under the project's own: a project team of the same name wins.
|
|
119
|
+
const imported = importedTeams(root);
|
|
120
|
+
if (Object.keys(imported).length)
|
|
121
|
+
config.teams = { ...imported, ...(config.teams ?? {}) };
|
|
114
122
|
config.domains = domainIds;
|
|
115
123
|
config.areas = areas;
|
|
116
124
|
return config;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DEFAULTS, merge } from './config.js';
|
|
2
|
+
import { DEFAULT_TIERS } from './review-policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* agjan's default settings as data: schemas/config.defaults.json, shipped in the package next
|
|
5
|
+
* to config.schema.json, so tools that do not run agjan (agjan Studio) can show what a setting
|
|
6
|
+
* is when agjan.config.json leaves it out. test/unit/defaults-file.test.ts keeps the file in
|
|
7
|
+
* step with the code; scripts/defaults.ts writes it.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULTS_FILE = 'schemas/config.defaults.json';
|
|
10
|
+
/**
|
|
11
|
+
* Defaults that are not in DEFAULTS because the code reads them where they apply:
|
|
12
|
+
* git.branches (status, branch), review.qa (qa.ts: on unless "off"), agent.script_edits
|
|
13
|
+
* (the guard hook: deny unless "allow").
|
|
14
|
+
*/
|
|
15
|
+
export const IMPLICIT_DEFAULTS = {
|
|
16
|
+
git: { branches: 'new' },
|
|
17
|
+
review: { qa: 'on' },
|
|
18
|
+
agent: { script_edits: 'deny' },
|
|
19
|
+
};
|
|
20
|
+
/** The tier of each review step; `qa` is the QA agent's own tier, not a review.tiers value. */
|
|
21
|
+
function reviewTiers() {
|
|
22
|
+
return Object.fromEntries(Object.entries(DEFAULT_TIERS).filter(([, tier]) => ['fast', 'balanced', 'deep'].includes(tier)));
|
|
23
|
+
}
|
|
24
|
+
export function defaultsDocument() {
|
|
25
|
+
return {
|
|
26
|
+
description: "agjan's defaults for agjan.config.json. Domains add their own on top (kit/domains/<id>/domain.json: per area implicit, tests, verify, lint; application, risk_paths and protected are appended), and the project's file overrides both. Objects merge, arrays replace. Review steps without a tier use balanced.",
|
|
27
|
+
format: 1,
|
|
28
|
+
defaults: merge(merge(DEFAULTS, IMPLICIT_DEFAULTS), { review: { tiers: reviewTiers() } }),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function defaultsFileText() {
|
|
32
|
+
return `${JSON.stringify(defaultsDocument(), null, 2)}\n`;
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { latestReview, stillBlocked } from './feature.js';
|
|
2
|
+
/**
|
|
3
|
+
* Discoveries (decision 91): a question that ends in a recommendation a person approves,
|
|
4
|
+
* and no code. The proposal (proposal.md) is reviewed (step `proposal`) and approved
|
|
5
|
+
* (`agjan approve proposal`); the branch changes nothing outside the discovery's folder.
|
|
6
|
+
*/
|
|
7
|
+
/** A section's text: the lines under `## name` up to the next `## `. */
|
|
8
|
+
function section(text, name) {
|
|
9
|
+
const match = new RegExp(`^## ${name}\\s*$([\\s\\S]*?)(?=^## |(?![\\s\\S]))`, 'm').exec(text);
|
|
10
|
+
return match ? match[1].trim() : '';
|
|
11
|
+
}
|
|
12
|
+
/** What the proposal lacks before its review and its approval. */
|
|
13
|
+
export function proposalProblems(feature) {
|
|
14
|
+
const text = feature.proposal?.text;
|
|
15
|
+
if (!text)
|
|
16
|
+
return ['proposal.md does not exist'];
|
|
17
|
+
const problems = [];
|
|
18
|
+
for (const name of ['Question', 'Context', 'Options', 'Recommendation', 'Sources']) {
|
|
19
|
+
if (!section(text, name))
|
|
20
|
+
problems.push(`proposal.md: the section "${name}" is empty`);
|
|
21
|
+
}
|
|
22
|
+
const options = [...section(text, 'Options').matchAll(/^### (.*)$/gm)].map((m) => m[1].replace(/^Option \d+:?\s*/, '').trim());
|
|
23
|
+
if (!options.length || options.some((o) => !o))
|
|
24
|
+
problems.push('proposal.md: name each option in its heading ("### Option 1: <name>")');
|
|
25
|
+
return problems;
|
|
26
|
+
}
|
|
27
|
+
/** The proposal's review: the latest `proposal` record, and why it does not allow the gate. */
|
|
28
|
+
export function proposalReview(feature) {
|
|
29
|
+
const record = latestReview(feature.reviews, ['proposal']);
|
|
30
|
+
const problems = [];
|
|
31
|
+
if (!record)
|
|
32
|
+
problems.push('no proposal review recorded');
|
|
33
|
+
else {
|
|
34
|
+
if (record.documents?.proposal !== feature.proposal?.hash)
|
|
35
|
+
problems.push(`the latest proposal review (${record.id}) did not review the current proposal.md`);
|
|
36
|
+
if (stillBlocked(feature, record))
|
|
37
|
+
problems.push(`the latest proposal review (${record.id}) is blocked`);
|
|
38
|
+
}
|
|
39
|
+
for (const f of feature.findings.filter((x) => x.status === 'open' && x.severity === 'blocker' && x.step === 'proposal'))
|
|
40
|
+
problems.push(`open blocker ${f.id}: ${f.issue}`);
|
|
41
|
+
return { record, problems };
|
|
42
|
+
}
|
package/dist/feature.js
CHANGED
|
@@ -5,17 +5,20 @@ import { readJson } from './json-file.js';
|
|
|
5
5
|
import { parseSpec, parseDesign, parseTasks } from './documents.js';
|
|
6
6
|
import { changedFiles, resolveBase } from './git.js';
|
|
7
7
|
import { AgjanError, UsageError } from './errors.js';
|
|
8
|
-
|
|
8
|
+
import { CONTAINERS, WORKFLOWS } from './workflow.js';
|
|
9
|
+
export const FEATURES_DIR = 'agjan-docs';
|
|
9
10
|
export const APPROVALS_FILE = 'approvals.json';
|
|
10
11
|
export const REVIEWS_FILE = 'reviews.json';
|
|
12
|
+
export const PROPOSAL_FILE = 'proposal.md';
|
|
11
13
|
/**
|
|
12
|
-
* Record folders under docs
|
|
13
|
-
* docs
|
|
14
|
+
* Record folders under agjan-docs (decision 57). A unit's id is its path below
|
|
15
|
+
* agjan-docs: a feature `order-filter`, a fix `fixes/2026-10-17-order-label`, a map run
|
|
14
16
|
* `maps/2026-10-17`. All have approvals.json (key, accepted findings), reviews.json and
|
|
15
17
|
* log.jsonl; only features have spec, design and tasks.
|
|
16
18
|
*/
|
|
17
|
-
export
|
|
19
|
+
export { CONTAINERS } from './workflow.js';
|
|
18
20
|
const RESERVED = new Set(Object.keys(CONTAINERS));
|
|
21
|
+
const NON_FEATURE_KINDS = Object.keys(WORKFLOWS).filter((k) => k !== 'feature');
|
|
19
22
|
export const SLUG = /^[a-z0-9][a-z0-9-]{0,47}$/;
|
|
20
23
|
export const KEY = /^[A-Z][A-Z0-9]{1,5}$/;
|
|
21
24
|
/** Review steps whose passing record allows each gate (design 7.3). */
|
|
@@ -38,7 +41,7 @@ export function listFeatures(root) {
|
|
|
38
41
|
const others = Object.keys(CONTAINERS).flatMap((c) => unitFolders(join(dir, c)).map((e) => `${c}/${e.name}`).sort());
|
|
39
42
|
return [...features, ...others];
|
|
40
43
|
}
|
|
41
|
-
/** The unit id a repository path belongs to, or null (docs/
|
|
44
|
+
/** The unit id a repository path belongs to, or null (agjan-docs/project.md, ...). */
|
|
42
45
|
export function unitOf(file) {
|
|
43
46
|
const prefix = `${FEATURES_DIR}/`;
|
|
44
47
|
if (!file.startsWith(prefix))
|
|
@@ -97,7 +100,7 @@ function validateApprovals(data, slug) {
|
|
|
97
100
|
}
|
|
98
101
|
if (!KEY.test(data.feature.key ?? ''))
|
|
99
102
|
throw new AgjanError(`${FEATURES_DIR}/${slug}/${APPROVALS_FILE}: invalid feature key`);
|
|
100
|
-
if (data.feature.kind !== undefined && !
|
|
103
|
+
if (data.feature.kind !== undefined && !NON_FEATURE_KINDS.includes(data.feature.kind)) {
|
|
101
104
|
throw new AgjanError(`${FEATURES_DIR}/${slug}/${APPROVALS_FILE}: unknown kind '${data.feature.kind}'`);
|
|
102
105
|
}
|
|
103
106
|
for (const list of ['amendments', 'accepted', 'rejections']) {
|
|
@@ -165,6 +168,9 @@ export function loadFeature(root, slug) {
|
|
|
165
168
|
const design = read('design.md', parseDesign);
|
|
166
169
|
const tasks = read('tasks.md', parseTasks);
|
|
167
170
|
const designHash = design && tasks ? hashParts([['design.md', design.text], ['tasks.md', tasks.text]]) : null;
|
|
171
|
+
// A discovery's one document: its proposal (decision 91).
|
|
172
|
+
const proposal = kind === 'discovery' ? readDoc(dir, PROPOSAL_FILE) : null;
|
|
173
|
+
const proposalState = kind === 'discovery' ? docState(proposal, approvals.approvals.proposal, proposal?.hash) : 'missing';
|
|
168
174
|
const specApproval = approvals.approvals.spec;
|
|
169
175
|
const designApproval = approvals.approvals.design;
|
|
170
176
|
const specState = docState(spec, specApproval, spec?.hash);
|
|
@@ -187,7 +193,8 @@ export function loadFeature(root, slug) {
|
|
|
187
193
|
design,
|
|
188
194
|
tasks,
|
|
189
195
|
designHash,
|
|
190
|
-
|
|
196
|
+
proposal,
|
|
197
|
+
state: { spec: specState, design: designState, proposal: proposalState },
|
|
191
198
|
stage,
|
|
192
199
|
amendments,
|
|
193
200
|
findings: findingStatus(reviews, approvals),
|
package/dist/imports.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { dirname, join, relative } from 'node:path';
|
|
6
|
+
import { readJson, writeJson } from './json-file.js';
|
|
7
|
+
import { AgjanError } from './errors.js';
|
|
8
|
+
import { loadSchema, validate } from './schema.js';
|
|
9
|
+
/**
|
|
10
|
+
* Imports (decision 93): skills and teams from another repository, at an exact commit.
|
|
11
|
+
*
|
|
12
|
+
* The source declares what it offers in `agjan-package.json` (name, version, license,
|
|
13
|
+
* skill folders, teams) and nothing else: no hooks, agents, MCP servers or settings, so an
|
|
14
|
+
* import cannot grant itself any permission. Its skills land in `.claude/skills/<package>-<skill>/`
|
|
15
|
+
* and its teams as `<package>/<team>`. `agjan.imports.json` records the source, the commit,
|
|
16
|
+
* the license and a hash of every imported file; `check` reports a file changed by hand.
|
|
17
|
+
* Nothing in the source runs. A person confirms every import in a terminal: imported skills
|
|
18
|
+
* become instructions to the agents.
|
|
19
|
+
*/
|
|
20
|
+
export const IMPORTS_FILE = 'agjan.imports.json';
|
|
21
|
+
export const MANIFEST = 'agjan-package.json';
|
|
22
|
+
const NAME = /^[a-z][a-z0-9-]{1,30}$/;
|
|
23
|
+
const COMMIT = /^[0-9a-f]{40}$/;
|
|
24
|
+
const MAX_FILE = 1024 * 1024;
|
|
25
|
+
const MAX_TOTAL = 5 * 1024 * 1024;
|
|
26
|
+
export function readImports(root) {
|
|
27
|
+
return readJson(join(root, IMPORTS_FILE)) ?? { schema: 1, imports: {} };
|
|
28
|
+
}
|
|
29
|
+
/** The imported teams, by their namespaced names. */
|
|
30
|
+
export function importedTeams(root) {
|
|
31
|
+
return Object.assign({}, ...Object.values(readImports(root).imports).map((i) => i.teams ?? {}));
|
|
32
|
+
}
|
|
33
|
+
const sha = (content) => `sha256:${createHash('sha256').update(content).digest('hex')}`;
|
|
34
|
+
function manifestProblems(data) {
|
|
35
|
+
if (!data || typeof data !== 'object')
|
|
36
|
+
return [`${MANIFEST} is missing or not JSON`];
|
|
37
|
+
const problems = [];
|
|
38
|
+
const allowed = new Set(['name', 'version', 'license', 'description', 'skills', 'teams']);
|
|
39
|
+
for (const key of Object.keys(data))
|
|
40
|
+
if (!allowed.has(key))
|
|
41
|
+
problems.push(`${MANIFEST}: '${key}' is not allowed (a package offers skills and teams only)`);
|
|
42
|
+
if (!NAME.test(data.name ?? ''))
|
|
43
|
+
problems.push(`${MANIFEST}: name must be 2 to 31 lowercase letters, digits or '-'`);
|
|
44
|
+
if (typeof data.version !== 'string' || !data.version)
|
|
45
|
+
problems.push(`${MANIFEST}: version is missing`);
|
|
46
|
+
if (typeof data.license !== 'string' || !data.license)
|
|
47
|
+
problems.push(`${MANIFEST}: license is missing`);
|
|
48
|
+
if (data.skills !== undefined && (!Array.isArray(data.skills) || data.skills.some((s) => typeof s !== 'string')))
|
|
49
|
+
problems.push(`${MANIFEST}: skills must be a list of folders`);
|
|
50
|
+
if (data.teams !== undefined) {
|
|
51
|
+
for (const p of validate(loadSchema('config'), { teams: data.teams }))
|
|
52
|
+
problems.push(`${MANIFEST}: ${p}`);
|
|
53
|
+
}
|
|
54
|
+
return problems;
|
|
55
|
+
}
|
|
56
|
+
/** Every regular file under `dir`; links and oversized files are refused. */
|
|
57
|
+
function filesUnder(dir, base = dir) {
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
60
|
+
const path = join(dir, entry.name);
|
|
61
|
+
if (lstatSync(path).isSymbolicLink())
|
|
62
|
+
throw new AgjanError(`${relative(base, path)} is a symbolic link; packages contain plain files only`);
|
|
63
|
+
if (entry.isDirectory())
|
|
64
|
+
out.push(...filesUnder(path, base));
|
|
65
|
+
else if (entry.isFile())
|
|
66
|
+
out.push(path);
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fetches the source at `commit` into a temporary folder and builds the plan: nothing in
|
|
72
|
+
* the source runs (a clone and a checkout, no hooks: `core.hooksPath` points nowhere).
|
|
73
|
+
*/
|
|
74
|
+
export function planImport(source, commit) {
|
|
75
|
+
if (!COMMIT.test(commit))
|
|
76
|
+
throw new AgjanError(`--commit must be a full 40-character commit id, not a branch or tag: '${commit}'`);
|
|
77
|
+
const dir = mkdtempSync(join(tmpdir(), 'agjan-import-'));
|
|
78
|
+
try {
|
|
79
|
+
const git = (args, cwd) => execFileSync('git', ['-c', 'core.hooksPath=/dev/null', '-c', 'protocol.ext.allow=never', ...args], { cwd, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' });
|
|
80
|
+
try {
|
|
81
|
+
git(['clone', '--quiet', '--no-checkout', source, join(dir, 'src')]);
|
|
82
|
+
git(['checkout', '--quiet', commit], join(dir, 'src'));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw new AgjanError(`could not fetch ${source} at ${commit}: ${String(error.stderr ?? error).trim().split('\n').at(-1)}`);
|
|
86
|
+
}
|
|
87
|
+
const root = join(dir, 'src');
|
|
88
|
+
let manifest;
|
|
89
|
+
try {
|
|
90
|
+
manifest = JSON.parse(readFileSync(join(root, MANIFEST), 'utf8'));
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
manifest = null;
|
|
94
|
+
}
|
|
95
|
+
const problems = manifestProblems(manifest);
|
|
96
|
+
if (problems.length)
|
|
97
|
+
throw new AgjanError(`${source} at ${commit.slice(0, 12)} is not an agjan package:\n${problems.map((p) => ` - ${p}`).join('\n')}`);
|
|
98
|
+
const files = new Map();
|
|
99
|
+
const skillNames = new Map();
|
|
100
|
+
let total = 0;
|
|
101
|
+
for (const folder of manifest.skills ?? []) {
|
|
102
|
+
const abs = join(root, folder);
|
|
103
|
+
if (relative(root, abs).startsWith('..') || !existsSync(join(abs, 'SKILL.md')))
|
|
104
|
+
throw new AgjanError(`${MANIFEST}: skill folder '${folder}' has no SKILL.md`);
|
|
105
|
+
const local = `${manifest.name}-${folder.replace(/\/+$/, '').split('/').at(-1)}`;
|
|
106
|
+
skillNames.set(folder.replace(/\/+$/, '').split('/').at(-1), local);
|
|
107
|
+
for (const file of filesUnder(abs)) {
|
|
108
|
+
let content = readFileSync(file);
|
|
109
|
+
if (content.length > MAX_FILE)
|
|
110
|
+
throw new AgjanError(`${relative(root, file)} is larger than 1 MiB`);
|
|
111
|
+
total += content.length;
|
|
112
|
+
if (relative(abs, file) === 'SKILL.md') {
|
|
113
|
+
// The skill's name is its namespaced folder, so it cannot pose as another skill.
|
|
114
|
+
content = Buffer.from(content.toString('utf8').replace(/^(---\n[\s\S]*?^name:\s*).*$/m, `$1${local}`));
|
|
115
|
+
}
|
|
116
|
+
files.set(`.claude/skills/${local}/${relative(abs, file).split('\\').join('/')}`, content);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (total > MAX_TOTAL)
|
|
120
|
+
throw new AgjanError('the package is larger than 5 MiB');
|
|
121
|
+
const teams = {};
|
|
122
|
+
for (const [name, team] of Object.entries(manifest.teams ?? {})) {
|
|
123
|
+
const personas = Object.fromEntries(Object.entries(team.personas).map(([role, p]) => [role, { ...p, skills: p.skills.map((s) => skillNames.get(s) ?? s) }]));
|
|
124
|
+
teams[`${manifest.name}/${name}`] = { ...team, personas };
|
|
125
|
+
}
|
|
126
|
+
return { manifest, source, commit, files, teams };
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
rmSync(dir, { recursive: true, force: true });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** What applying a plan changes, against what the project has from this package now. */
|
|
133
|
+
export function planChanges(root, plan) {
|
|
134
|
+
const current = readImports(root).imports[plan.manifest.name];
|
|
135
|
+
const before = current?.files ?? {};
|
|
136
|
+
const added = [...plan.files.keys()].filter((f) => !(f in before));
|
|
137
|
+
const changed = [...plan.files.keys()].filter((f) => f in before && before[f] !== sha(plan.files.get(f)));
|
|
138
|
+
const removed = Object.keys(before).filter((f) => !plan.files.has(f));
|
|
139
|
+
const oldTeams = current?.teams ?? {};
|
|
140
|
+
return {
|
|
141
|
+
added,
|
|
142
|
+
changed,
|
|
143
|
+
removed,
|
|
144
|
+
teams: {
|
|
145
|
+
added: Object.keys(plan.teams).filter((t) => !(t in oldTeams)),
|
|
146
|
+
changed: Object.keys(plan.teams).filter((t) => t in oldTeams && JSON.stringify(oldTeams[t]) !== JSON.stringify(plan.teams[t])),
|
|
147
|
+
removed: Object.keys(oldTeams).filter((t) => !(t in plan.teams)),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Skill folders the package would take over from someone else: the project's own, or another package's. */
|
|
152
|
+
export function collisions(root, plan) {
|
|
153
|
+
const imports = readImports(root).imports;
|
|
154
|
+
const ours = new Set(Object.keys(imports[plan.manifest.name]?.files ?? {}));
|
|
155
|
+
const others = new Set(Object.entries(imports).filter(([n]) => n !== plan.manifest.name).flatMap(([, i]) => Object.keys(i.files)));
|
|
156
|
+
return [...plan.files.keys()].filter((f) => others.has(f) || (!ours.has(f) && existsSync(join(root, f))));
|
|
157
|
+
}
|
|
158
|
+
export function applyImport(root, plan, at, by) {
|
|
159
|
+
const imports = readImports(root);
|
|
160
|
+
for (const file of Object.keys(imports.imports[plan.manifest.name]?.files ?? {}))
|
|
161
|
+
if (!plan.files.has(file))
|
|
162
|
+
rmSync(join(root, file), { force: true });
|
|
163
|
+
const files = {};
|
|
164
|
+
for (const [file, content] of plan.files) {
|
|
165
|
+
mkdirSync(dirname(join(root, file)), { recursive: true });
|
|
166
|
+
writeFileSync(join(root, file), content);
|
|
167
|
+
files[file] = sha(content);
|
|
168
|
+
}
|
|
169
|
+
const { name, version, license, description } = plan.manifest;
|
|
170
|
+
imports.imports[name] = { source: plan.source, commit: plan.commit, version, license, ...(description ? { description } : {}), imported_at_utc: at, by, files, teams: plan.teams };
|
|
171
|
+
writeJson(join(root, IMPORTS_FILE), imports);
|
|
172
|
+
}
|
|
173
|
+
export function removeImport(root, name) {
|
|
174
|
+
const imports = readImports(root);
|
|
175
|
+
const record = imports.imports[name];
|
|
176
|
+
if (!record)
|
|
177
|
+
throw new AgjanError(`no imported package '${name}' (${IMPORTS_FILE})`);
|
|
178
|
+
for (const file of Object.keys(record.files))
|
|
179
|
+
rmSync(join(root, file), { force: true });
|
|
180
|
+
delete imports.imports[name];
|
|
181
|
+
writeJson(join(root, IMPORTS_FILE), imports);
|
|
182
|
+
return Object.keys(record.files);
|
|
183
|
+
}
|
|
184
|
+
/** Imported files that are missing or no longer what was imported. */
|
|
185
|
+
export function importDrift(root) {
|
|
186
|
+
const out = [];
|
|
187
|
+
for (const [name, record] of Object.entries(readImports(root).imports)) {
|
|
188
|
+
for (const [file, hash] of Object.entries(record.files)) {
|
|
189
|
+
const path = join(root, file);
|
|
190
|
+
if (!existsSync(path))
|
|
191
|
+
out.push(`${file} (from ${name}) is missing`);
|
|
192
|
+
else if (sha(readFileSync(path)) !== hash)
|
|
193
|
+
out.push(`${file} (from ${name}) changed after the import`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
package/dist/plan.js
CHANGED
|
@@ -23,7 +23,7 @@ export function buildPlan(config) {
|
|
|
23
23
|
// .claude/skills/ for every host: both read them from there.
|
|
24
24
|
if (hosts.includes(claudeCode.HOST))
|
|
25
25
|
items.push({ kind: 'block', path: 'CLAUDE.md', style: 'md', content: '@AGENTS.md', skip: importsAgents });
|
|
26
|
-
items.push({ kind: 'block', path: '.gitattributes', style: 'hash', content: 'docs
|
|
26
|
+
items.push({ kind: 'block', path: '.gitattributes', style: 'hash', content: 'agjan-docs/** text eol=lf\nagjan.lock.json text eol=lf' },
|
|
27
27
|
// node_modules too: a new project often has no .gitignore of its own (design decision 69).
|
|
28
28
|
{ kind: 'block', path: '.gitignore', style: 'hash', content: '.agjan/\nnode_modules/\n.DS_Store\nThumbs.db' });
|
|
29
29
|
for (const host of hosts) {
|
package/dist/progress-view.js
CHANGED
|
@@ -4,18 +4,21 @@ import { readJson } from './json-file.js';
|
|
|
4
4
|
import { agentModel, loadConfig } from './config.js';
|
|
5
5
|
import { APPROVALS_FILE, FEATURES_DIR, changedFeatures, listFeatures, loadFeature, stillBlocked } from './feature.js';
|
|
6
6
|
import { readLog } from './log.js';
|
|
7
|
-
import {
|
|
7
|
+
import { buildProgress, headHistory, prefetchFiles, repoMemo, verifyState } from './progress.js';
|
|
8
|
+
import { verification } from './readiness.js';
|
|
8
9
|
import { reviewerFor, roundLimit } from './review-policy.js';
|
|
9
10
|
import { acTestFiles } from './tests-map.js';
|
|
10
11
|
import { acResults, loadResults } from './test-results.js';
|
|
11
12
|
import { freshReview } from './fix.js';
|
|
13
|
+
import { workflowOf } from './workflow.js';
|
|
14
|
+
import { proposalReview } from './discovery.js';
|
|
12
15
|
import { spans } from './commands/report.js';
|
|
13
16
|
import { REVIEW_MD, renderReviewMd } from './review.js';
|
|
14
17
|
/**
|
|
15
18
|
* Progress pages (design decision 66): what happened in each unit (feature, fix, map run),
|
|
16
19
|
* who worked on it, how the review loops went, and whose turn it is. agjan regenerates them,
|
|
17
20
|
* and the unit's review.md, after every event it records:
|
|
18
|
-
* - docs
|
|
21
|
+
* - agjan-docs/<unit>/progress.md: committed with the unit, visible in the pull request;
|
|
19
22
|
* - .agjan/progress.md and .agjan/progress.html: the project overview, local (not
|
|
20
23
|
* committed, so parallel branches do not conflict). The HTML is self-contained.
|
|
21
24
|
*/
|
|
@@ -30,7 +33,11 @@ function titleOf(unit) {
|
|
|
30
33
|
return fix.what ?? unit.slug;
|
|
31
34
|
}
|
|
32
35
|
if (unit.kind === 'map')
|
|
33
|
-
return 'Map of the application (docs/
|
|
36
|
+
return 'Map of the application (agjan-docs/project.md)';
|
|
37
|
+
if (unit.kind === 'discovery') {
|
|
38
|
+
const question = /^## Question\s*$\s*^(.+)$/m.exec(unit.proposal?.text ?? '')?.[1].trim() ?? unit.slug;
|
|
39
|
+
return question.length > 110 ? `${question.slice(0, 107)}…` : question;
|
|
40
|
+
}
|
|
34
41
|
const lines = (unit.spec?.text ?? '').split('\n');
|
|
35
42
|
const start = lines.findIndex((l) => l.trim() === '## Summary');
|
|
36
43
|
const text = start === -1 ? '' : lines.slice(start + 1).find((l) => l.trim() && !l.startsWith('#')) ?? '';
|
|
@@ -56,8 +63,10 @@ function unitCommits(root, key, memo) {
|
|
|
56
63
|
/** Stage track and whose turn it is. */
|
|
57
64
|
function stageOf(ctx, unit, onBase, extra) {
|
|
58
65
|
const { review } = extra;
|
|
66
|
+
if (unit.kind === 'discovery')
|
|
67
|
+
return discoveryStage(unit, onBase);
|
|
59
68
|
if (unit.kind !== 'feature') {
|
|
60
|
-
const names = unit.kind
|
|
69
|
+
const names = [...workflowOf(unit.kind).stages, 'Merged'];
|
|
61
70
|
const last = unit.reviews.records.at(-1);
|
|
62
71
|
if (onBase && last && !stillBlocked(unit, last))
|
|
63
72
|
return { names, at: 3, turn: 'merged', now: 'merged' };
|
|
@@ -65,10 +74,10 @@ function stageOf(ctx, unit, onBase, extra) {
|
|
|
65
74
|
return { names, at: 2, turn: 'you', now: 'review and merge the pull request' };
|
|
66
75
|
if (last)
|
|
67
76
|
return { names, at: 1, turn: 'agent', now: review?.problem ?? 'review' };
|
|
68
|
-
return { names, at: 0, turn: 'agent', now: unit.kind === 'fix' ? 'making the change' : 'writing docs/
|
|
77
|
+
return { names, at: 0, turn: 'agent', now: unit.kind === 'fix' ? 'making the change' : 'writing agjan-docs/project.md' };
|
|
69
78
|
}
|
|
70
79
|
const mode = unit.design?.parsed.mode;
|
|
71
|
-
const names = ['
|
|
80
|
+
const names = [...workflowOf(unit.kind).stages.map((s) => (s === 'Design' && mode === 'light' ? 'Design (light)' : s)), onBase ? 'Merged' : 'Done'];
|
|
72
81
|
const events = readLog(unit.dir);
|
|
73
82
|
const lastGate = events.filter((e) => ['gate-requested', 'approved', 'rejected'].includes(e.event)).at(-1);
|
|
74
83
|
const waiting = lastGate?.event === 'gate-requested';
|
|
@@ -95,7 +104,11 @@ function stageOf(ctx, unit, onBase, extra) {
|
|
|
95
104
|
const pending = unit.amendments.filter((a) => a.status === 'pending');
|
|
96
105
|
const verified = progress.complete && progress.due.length === 0 && verify.state === 'current';
|
|
97
106
|
if (verified) {
|
|
98
|
-
|
|
107
|
+
// The final review passed; the same answer as the acceptance gate decides the rest.
|
|
108
|
+
const { problems, accepted } = verification(ctx, unit);
|
|
109
|
+
if (problems.length)
|
|
110
|
+
return { names, at: 3, turn: 'agent', now: `not verified yet: ${problems[0]}` };
|
|
111
|
+
if (accepted)
|
|
99
112
|
return { names, at: 5, turn: 'done', now: 'implemented, verified and accepted' };
|
|
100
113
|
const manual = unit.spec.parsed.acs.filter((ac) => ac.verification === 'manual').map((ac) => ac.id);
|
|
101
114
|
return { names, at: 4, turn: 'you', now: `verified: ${manual.length ? `check ${manual.join(', ')} by hand, then ` : ''}accept it in a terminal (npx agjan approve verify)` };
|
|
@@ -112,6 +125,22 @@ function stageOf(ctx, unit, onBase, extra) {
|
|
|
112
125
|
return unit.approvals.auto ? { names, at: 3, turn: 'agent', now: 'auto mode: the verification is next' } : { names, at: 3, turn: 'you', now: 'start the verification: /agjan-verify' };
|
|
113
126
|
return { names, at: 3, turn: 'agent', now: verify.state === 'none' ? 'verify' : `verify (${verify.state})` };
|
|
114
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* A discovery (decision 91): the agent writes the proposal and has it reviewed; then a
|
|
130
|
+
* person approves the recommendation; after that, building it is new work (/agjan-spec).
|
|
131
|
+
*/
|
|
132
|
+
function discoveryStage(unit, onBase) {
|
|
133
|
+
const names = [...workflowOf('discovery').stages, onBase ? 'Merged' : 'Done'];
|
|
134
|
+
if (unit.state.proposal === 'approved') {
|
|
135
|
+
return onBase ? { names, at: 3, turn: 'merged', now: 'merged' } : { names, at: 3, turn: 'done', now: 'recommendation approved; to build it, start a feature with /agjan-spec' };
|
|
136
|
+
}
|
|
137
|
+
const review = proposalReview(unit);
|
|
138
|
+
if (!review.record)
|
|
139
|
+
return { names, at: 0, turn: 'agent', now: 'writing the proposal' };
|
|
140
|
+
if (review.problems.length)
|
|
141
|
+
return { names, at: 1, turn: 'agent', now: `revising the proposal: ${review.problems[0]}` };
|
|
142
|
+
return { names, at: 2, turn: 'you', now: 'decide on the recommendation: approve it in a terminal (npx agjan approve proposal)' };
|
|
143
|
+
}
|
|
115
144
|
/**
|
|
116
145
|
* While the agent would be working, a `waiting` event after its last step means it stopped
|
|
117
146
|
* for the user (an error it cannot resolve, a decision): their turn, with the reason.
|
|
@@ -128,7 +157,7 @@ function waitingFor(events, stage) {
|
|
|
128
157
|
*/
|
|
129
158
|
export function finalSteps(root, unit, { manual = [], accepted = false } = {}) {
|
|
130
159
|
const project = readFileSyncSafe(join(root, FEATURES_DIR, 'project.md'));
|
|
131
|
-
const tryIt = /^## Run locally\s*$/m.test(project) ? 'try it locally: docs/
|
|
160
|
+
const tryIt = /^## Run locally\s*$/m.test(project) ? 'try it locally: agjan-docs/project.md, section "Run locally" (start command, URL, users)' : 'try it locally';
|
|
132
161
|
const pr = 'open a pull request (ask the agent: "open the PR"), review it, merge it';
|
|
133
162
|
if (accepted)
|
|
134
163
|
return { yours: [], optional: [tryIt, pr] };
|
|
@@ -148,7 +177,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now(), memo =
|
|
|
148
177
|
const isFeature = unit.kind === 'feature';
|
|
149
178
|
const progress = isFeature && unit.tasks ? buildProgress(ctx.root, config, unit, { history: onBase, memo }) : null;
|
|
150
179
|
const verify = isFeature ? verifyState(ctx.root, config, unit, memo) : null;
|
|
151
|
-
const review =
|
|
180
|
+
const review = unit.kind === 'fix' || unit.kind === 'map' ? freshReview(ctx.root, config, unit, unit.kind, memo) : null;
|
|
152
181
|
const stage = waitingFor(events, stageOf(ctx, unit, onBase, { progress, verify, review }));
|
|
153
182
|
const commits = unitCommits(ctx.root, unit.key, memo);
|
|
154
183
|
const times = [...events.map((e) => Date.parse(e.at_utc)), ...commits.map((c) => Date.parse(c.at))].filter(Number.isFinite);
|
|
@@ -161,7 +190,9 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now(), memo =
|
|
|
161
190
|
const steps = list.filter((s) => s.kind === 'step');
|
|
162
191
|
const gates = list.filter((s) => s.kind === 'gate');
|
|
163
192
|
const host = unit.reviews.records.find((r) => r.reviewer?.host)?.reviewer.host ?? events.find((e) => e.host)?.host ?? null;
|
|
164
|
-
|
|
193
|
+
// What a review step looks at: a later round saw a revision only when that changed.
|
|
194
|
+
const seenBy = (r) => r.step === 'spec' ? r.documents?.spec : r.step === 'design' ? r.documents?.design : r.step === 'design:light' ? `${r.documents?.spec} ${r.documents?.design}` : r.tree_hash;
|
|
195
|
+
const reviews = unit.reviews.records.map((r, i, all) => ({
|
|
165
196
|
id: r.id,
|
|
166
197
|
step: r.step,
|
|
167
198
|
round: r.round,
|
|
@@ -172,6 +203,10 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now(), memo =
|
|
|
172
203
|
isolation: r.reviewer?.isolation ?? null,
|
|
173
204
|
findings: (r.findings ?? []).map((f) => f.id),
|
|
174
205
|
resolves: r.resolves ?? [],
|
|
206
|
+
/** Whether what the step looks at changed since its previous round; null for a first round. */
|
|
207
|
+
changed: ((prev) => (prev ? seenBy(prev) !== seenBy(r) : null))(all.slice(0, i).findLast((x) => x.step === r.step)),
|
|
208
|
+
/** The QA tests a QA round left. */
|
|
209
|
+
tests: r.qa_tests?.length ?? null,
|
|
175
210
|
}));
|
|
176
211
|
const resolvedBy = {};
|
|
177
212
|
for (const r of reviews)
|
|
@@ -371,7 +406,7 @@ export function timelineRows(model) {
|
|
|
371
406
|
rows.push([c.at, '🤖 main agent', `commit \`${c.sha}\` ${c.subject}`]);
|
|
372
407
|
return rows.sort((a, b) => a[0].localeCompare(b[0]));
|
|
373
408
|
}
|
|
374
|
-
/** docs
|
|
409
|
+
/** agjan-docs/<unit>/progress.md */
|
|
375
410
|
export function unitMarkdown(model, { generatedAt }) {
|
|
376
411
|
const out = [];
|
|
377
412
|
const md = (s) => String(s).replace(/\|/g, '\\|');
|
package/dist/qa.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { existsSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
4
|
import { contentIds } from './git.js';
|
|
5
|
-
import {
|
|
5
|
+
import { writeJson } from './json-file.js';
|
|
6
|
+
import { FEATURES_DIR, latestReview, stillBlocked } from './feature.js';
|
|
6
7
|
/**
|
|
7
8
|
* The QA step (design decision 81): in Verify, the QA agent (`agjan-qa`, the qa-tester
|
|
8
9
|
* skill) writes and runs tests from the spec alone, without the design, the diff or the
|
|
@@ -14,6 +15,29 @@ export const QA_STEP = 'qa';
|
|
|
14
15
|
export function qaDirs(slug) {
|
|
15
16
|
return [`test/qa/${slug}/`, `test/ui/qa/${slug}/`];
|
|
16
17
|
}
|
|
18
|
+
/** What the QA agent may not read, for the guard (decision 87); written by qa_context. */
|
|
19
|
+
export const QA_GUARD_FILE = '.agjan/qa-guard.json';
|
|
20
|
+
/** The agent name the hosts report for the QA agent's tool calls. */
|
|
21
|
+
export const QA_AGENT = 'agjan-qa';
|
|
22
|
+
/**
|
|
23
|
+
* The QA agent's black box (decision 87): agjan's records, the application code
|
|
24
|
+
* (`application`) and every area's tests are hidden; the spec, the project map and its own
|
|
25
|
+
* QA folders stay visible. Globs; a path is hidden when it matches `hidden` and no `visible`.
|
|
26
|
+
*/
|
|
27
|
+
export function qaGuard(config, slug) {
|
|
28
|
+
const tests = Object.values(config.tests).flat();
|
|
29
|
+
return {
|
|
30
|
+
feature: slug,
|
|
31
|
+
hidden: [...new Set([`${FEATURES_DIR}/**`, ...config.application, ...tests])],
|
|
32
|
+
visible: [`${FEATURES_DIR}/${slug}/spec.md`, `${FEATURES_DIR}/project.md`, ...qaDirs(slug).map((dir) => `${dir}**`)],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Writes the QA guard file for the feature QA is about to test. */
|
|
36
|
+
export function writeQaGuard(root, config, slug) {
|
|
37
|
+
const file = join(root, QA_GUARD_FILE);
|
|
38
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
39
|
+
writeJson(file, qaGuard(config, slug));
|
|
40
|
+
}
|
|
17
41
|
/** QA runs for full-mode features unless the project turns it off (`review.qa: "off"`). */
|
|
18
42
|
export function qaApplies(config, feature) {
|
|
19
43
|
return feature.kind === 'feature' && feature.design?.parsed.mode === 'full' && config.review?.qa !== 'off';
|