agjan 0.0.0-stage → 0.0.2
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/LICENSE +201 -0
- package/NOTICE +11 -0
- package/README.md +105 -2
- package/bin/agjan.mjs +12 -0
- package/docs/brand/agjan-icon.svg +14 -0
- package/docs/brand/agjan-logo-dark.svg +17 -0
- package/docs/brand/agjan-logo-light.svg +17 -0
- package/docs/guide.md +232 -0
- package/kit/domains/btp/domain.json +27 -0
- package/kit/hooks/guard.mjs +61 -0
- package/kit/mcp/servers.json +5 -0
- package/kit/skills/agjan-build/SKILL.md +61 -0
- package/kit/skills/agjan-design/SKILL.md +95 -0
- package/kit/skills/agjan-fix/SKILL.md +55 -0
- package/kit/skills/agjan-map/SKILL.md +51 -0
- package/kit/skills/agjan-spec/SKILL.md +111 -0
- package/kit/skills/agjan-verify/SKILL.md +60 -0
- package/kit/skills/btp-architect/SKILL.md +51 -0
- package/kit/skills/btp-architect/references/deployment.md +72 -0
- package/kit/skills/btp-architect/references/security.md +54 -0
- package/kit/skills/cap-developer/SKILL.md +49 -0
- package/kit/skills/cap-developer/references/handlers.md +47 -0
- package/kit/skills/cap-developer/references/modeling.md +52 -0
- package/kit/skills/cap-developer/references/services.md +53 -0
- package/kit/skills/cap-developer/references/testing.md +39 -0
- package/kit/skills/cap-developer/references/validation-security.md +49 -0
- package/kit/skills/fiori-developer/SKILL.md +64 -0
- package/kit/skills/fiori-developer/references/elements.md +77 -0
- package/kit/skills/fiori-developer/references/freestyle-ts.md +45 -0
- package/kit/skills/fiori-developer/references/testing.md +32 -0
- package/kit/skills/fiori-developer/references/ui5-basics.md +52 -0
- package/kit/skills/solution-reviewer/SKILL.md +51 -0
- package/kit/templates/agents-block.md +20 -0
- package/kit/templates/agjan-ci.yml +40 -0
- package/kit/templates/design.md +17 -0
- package/kit/templates/project.md +28 -0
- package/kit/templates/spec.md +33 -0
- package/kit/templates/tasks.md +13 -0
- package/package.json +50 -4
- package/schemas/approvals.schema.json +93 -0
- package/schemas/config.schema.json +79 -0
- package/schemas/log.schema.json +30 -0
- package/schemas/reviews.schema.json +68 -0
- package/schemas/tasks.schema.json +26 -0
- package/src/adapters/claude-code.mjs +115 -0
- package/src/adapters/copilot.mjs +88 -0
- package/src/baseline.mjs +66 -0
- package/src/cli.mjs +133 -0
- package/src/commands/check.mjs +363 -0
- package/src/commands/fix.mjs +116 -0
- package/src/commands/gates.mjs +264 -0
- package/src/commands/log.mjs +53 -0
- package/src/commands/map.mjs +47 -0
- package/src/commands/new.mjs +53 -0
- package/src/commands/pr-summary.mjs +134 -0
- package/src/commands/report.mjs +110 -0
- package/src/commands/review.mjs +49 -0
- package/src/commands/setup.mjs +269 -0
- package/src/commands/status.mjs +176 -0
- package/src/config.mjs +98 -0
- package/src/context.mjs +58 -0
- package/src/documents.mjs +188 -0
- package/src/errors.mjs +16 -0
- package/src/feature.mjs +214 -0
- package/src/fix.mjs +108 -0
- package/src/git.mjs +66 -0
- package/src/hash.mjs +33 -0
- package/src/hook.mjs +48 -0
- package/src/json-file.mjs +24 -0
- package/src/log.mjs +37 -0
- package/src/managed.mjs +178 -0
- package/src/mcp-config.mjs +83 -0
- package/src/mcp.mjs +142 -0
- package/src/plan.mjs +41 -0
- package/src/progress.mjs +85 -0
- package/src/review-policy.mjs +49 -0
- package/src/review.mjs +336 -0
- package/src/scope.mjs +30 -0
- package/src/terminal.mjs +98 -0
- package/src/test-results.mjs +111 -0
- package/src/tests-map.mjs +29 -0
- package/src/ui.mjs +110 -0
- package/src/usage.mjs +118 -0
- package/src/validate.mjs +41 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { stringify as toYaml } from 'yaml';
|
|
2
|
+
import { skillBody } from '../managed.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Claude Code adapter (design 13): the generated reviewer agents and the deny rules for
|
|
6
|
+
* the human-only commands. Results of the host experiments shape both
|
|
7
|
+
* (docs/host-experiments.md, items 1, 1b and 5).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const HOST = 'claude-code';
|
|
11
|
+
export const DEFAULT_MODELS = { fast: 'haiku', balanced: 'sonnet', deep: 'opus' };
|
|
12
|
+
|
|
13
|
+
/** One agent per reviewer tier; workflow skills pick the tier per step (design 7.3). */
|
|
14
|
+
const REVIEWERS = [
|
|
15
|
+
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
16
|
+
{ name: 'agjan-reviewer-deep', tier: 'deep' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const HUMAN_ONLY = ['approve', 'accept', 'reject'];
|
|
20
|
+
/** Every way an agent's shell might start agjan. Indirect forms are stopped by the terminal check. */
|
|
21
|
+
const LAUNCHERS = ['agjan', 'npx agjan', 'npx --no-install agjan', 'npx -y agjan', 'npm exec agjan', 'npm exec -- agjan'];
|
|
22
|
+
|
|
23
|
+
export const DENY_RULES = HUMAN_ONLY.flatMap((cmd) => LAUNCHERS.map((l) => `Bash(${l} ${cmd}:*)`));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The guard as a PreToolUse hook. It also catches wrapped forms the prefix deny rules miss
|
|
27
|
+
* (`sh -c "agjan approve …"`). If it cannot start (agjan not installed), Claude Code
|
|
28
|
+
* treats the error as non-blocking.
|
|
29
|
+
*
|
|
30
|
+
* Shell form, as in Claude Code's documentation (it runs hooks with bash, on Windows
|
|
31
|
+
* through Git Bash). Not the exec form (`command` + `args`): the GitHub Copilot CLI also
|
|
32
|
+
* runs the hooks of `.claude/settings.json`, ignores `args`, and denies every tool call
|
|
33
|
+
* when a hook fails (host experiments, GitHub Copilot CLI, 5b).
|
|
34
|
+
*/
|
|
35
|
+
export const GUARD_HOOK = {
|
|
36
|
+
type: 'command',
|
|
37
|
+
command: 'node "$CLAUDE_PROJECT_DIR/node_modules/agjan/kit/hooks/guard.mjs"',
|
|
38
|
+
timeout: 10,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const GUARD_PATH = 'node_modules/agjan/kit/hooks/guard.mjs';
|
|
42
|
+
|
|
43
|
+
/** A guard entry written by an earlier agjan version (for example the exec form). */
|
|
44
|
+
function isOutdatedGuard(hook) {
|
|
45
|
+
const text = JSON.stringify(hook);
|
|
46
|
+
return text.includes(GUARD_PATH) && text !== JSON.stringify(GUARD_HOOK);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function hasGuard(data) {
|
|
50
|
+
const hooks = (data.hooks?.PreToolUse ?? []).flatMap((group) => group.hooks ?? []);
|
|
51
|
+
return hooks.some((h) => JSON.stringify(h) === JSON.stringify(GUARD_HOOK)) && !hooks.some(isOutdatedGuard);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** PreToolUse without outdated guard entries; a group left empty is dropped. */
|
|
55
|
+
function withoutOutdatedGuards(groups) {
|
|
56
|
+
return groups
|
|
57
|
+
.map((group) => (group.hooks?.some(isOutdatedGuard) ? { ...group, hooks: group.hooks.filter((h) => !isOutdatedGuard(h)) } : group))
|
|
58
|
+
.filter((group) => !Array.isArray(group.hooks) || group.hooks.length > 0);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function reviewerAgent(name, tier, model, skill) {
|
|
62
|
+
const frontmatter = {
|
|
63
|
+
name,
|
|
64
|
+
description:
|
|
65
|
+
`agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
|
|
66
|
+
'review of a step; it records its result itself.',
|
|
67
|
+
tools: 'Read, Grep, Glob, mcp__agjan__review_context, mcp__agjan__review_record',
|
|
68
|
+
model,
|
|
69
|
+
// Scoped to this agent only: the writer session must not have review_record.
|
|
70
|
+
mcpServers: [
|
|
71
|
+
{
|
|
72
|
+
agjan: {
|
|
73
|
+
type: 'stdio',
|
|
74
|
+
command: 'npx',
|
|
75
|
+
args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
return [
|
|
81
|
+
'---',
|
|
82
|
+
toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
|
|
83
|
+
'---',
|
|
84
|
+
'<!-- Generated by agjan sync from the solution-reviewer skill. Do not edit; run agjan sync. -->',
|
|
85
|
+
'',
|
|
86
|
+
skillBody(skill),
|
|
87
|
+
].join('\n');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The plan items this adapter contributes. */
|
|
91
|
+
export function plan(config, skills) {
|
|
92
|
+
const models = { ...DEFAULT_MODELS, ...(config.models?.[HOST] ?? {}) };
|
|
93
|
+
const skill = skills['solution-reviewer/SKILL.md'];
|
|
94
|
+
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
95
|
+
kind: 'file',
|
|
96
|
+
path: `.claude/agents/${name}.md`,
|
|
97
|
+
content: reviewerAgent(name, tier, models[tier], skill),
|
|
98
|
+
}));
|
|
99
|
+
items.push({
|
|
100
|
+
kind: 'json',
|
|
101
|
+
path: '.claude/settings.json',
|
|
102
|
+
present: (data) => DENY_RULES.every((rule) => data.permissions?.deny?.includes(rule)) && hasGuard(data),
|
|
103
|
+
merge: (data) => {
|
|
104
|
+
const deny = [...new Set([...(data.permissions?.deny ?? []), ...DENY_RULES])];
|
|
105
|
+
let hooks = data.hooks ?? {};
|
|
106
|
+
if (!hasGuard(data)) {
|
|
107
|
+
const groups = withoutOutdatedGuards(hooks.PreToolUse ?? []);
|
|
108
|
+
const current = groups.some((g) => (g.hooks ?? []).some((h) => JSON.stringify(h) === JSON.stringify(GUARD_HOOK)));
|
|
109
|
+
hooks = { ...hooks, PreToolUse: current ? groups : [...groups, { matcher: 'Bash', hooks: [GUARD_HOOK] }] };
|
|
110
|
+
}
|
|
111
|
+
return { ...data, permissions: { ...(data.permissions ?? {}), deny }, hooks };
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
return items;
|
|
115
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { stringify as toYaml } from 'yaml';
|
|
2
|
+
import { skillBody } from '../managed.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GitHub Copilot adapter (design 13), verified with the Copilot CLI
|
|
6
|
+
* (docs/host-experiments.md): reviewer agents in `.github/agents/` with the agjan MCP
|
|
7
|
+
* server inline, and a `preToolUse` guard hook in `.github/hooks/`, because the
|
|
8
|
+
* Copilot CLI has no persistent deny setting. Skills need nothing: Copilot reads
|
|
9
|
+
* `.claude/skills/`.
|
|
10
|
+
*
|
|
11
|
+
* VS Code ignores `mcp-servers` in agent files and does not run hooks; see the open
|
|
12
|
+
* item in design section 19.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const HOST = 'copilot';
|
|
16
|
+
export const HOOK_FILE = '.github/hooks/agjan-guard.json';
|
|
17
|
+
export const GUARD = 'node_modules/agjan/kit/hooks/guard.mjs';
|
|
18
|
+
|
|
19
|
+
/** Copilot model names differ from Claude Code's; unset means the session's model. */
|
|
20
|
+
export const DEFAULT_MODELS = {};
|
|
21
|
+
|
|
22
|
+
const REVIEWERS = [
|
|
23
|
+
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
24
|
+
{ name: 'agjan-reviewer-deep', tier: 'deep' },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function reviewerAgent(name, tier, model, skill) {
|
|
28
|
+
const frontmatter = {
|
|
29
|
+
name,
|
|
30
|
+
description:
|
|
31
|
+
`agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
|
|
32
|
+
'review of a step; it records its result itself.',
|
|
33
|
+
tools: ['read', 'search', 'agjan/review_context', 'agjan/review_record'],
|
|
34
|
+
...(model ? { model } : {}),
|
|
35
|
+
// Scoped to this agent only: the writer session must not have review_record.
|
|
36
|
+
'mcp-servers': {
|
|
37
|
+
agjan: {
|
|
38
|
+
type: 'local',
|
|
39
|
+
command: 'npx',
|
|
40
|
+
args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent'],
|
|
41
|
+
tools: ['*'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
return [
|
|
46
|
+
'---',
|
|
47
|
+
toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
|
|
48
|
+
'---',
|
|
49
|
+
'<!-- Generated by agjan sync from the solution-reviewer skill. Do not edit; run agjan sync. -->',
|
|
50
|
+
'',
|
|
51
|
+
skillBody(skill),
|
|
52
|
+
].join('\n');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The guard hook. If agjan is not installed the guard cannot start; the hook then
|
|
57
|
+
* allows (`|| true`, `exit 0`) instead of failing closed and blocking every tool call.
|
|
58
|
+
*/
|
|
59
|
+
export function hookConfig() {
|
|
60
|
+
const hook = {
|
|
61
|
+
version: 1,
|
|
62
|
+
hooks: {
|
|
63
|
+
preToolUse: [
|
|
64
|
+
{
|
|
65
|
+
type: 'command',
|
|
66
|
+
bash: `node ${GUARD} || true`,
|
|
67
|
+
powershell: `node ${GUARD}; exit 0`,
|
|
68
|
+
cwd: '.',
|
|
69
|
+
timeoutSec: 10,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
return `${JSON.stringify(hook, null, 2)}\n`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The plan items this adapter contributes. */
|
|
78
|
+
export function plan(config, skills) {
|
|
79
|
+
const models = { ...DEFAULT_MODELS, ...(config.models?.[HOST] ?? {}) };
|
|
80
|
+
const skill = skills['solution-reviewer/SKILL.md'];
|
|
81
|
+
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
82
|
+
kind: 'file',
|
|
83
|
+
path: `.github/agents/${name}.agent.md`,
|
|
84
|
+
content: reviewerAgent(name, tier, models[tier], skill),
|
|
85
|
+
}));
|
|
86
|
+
items.push({ kind: 'file', path: HOOK_FILE, content: hookConfig() });
|
|
87
|
+
return items;
|
|
88
|
+
}
|
package/src/baseline.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { git } from './git.mjs';
|
|
5
|
+
import { readJson, writeJson } from './json-file.mjs';
|
|
6
|
+
import { headings } from './documents.mjs';
|
|
7
|
+
import { matcher } from './scope.mjs';
|
|
8
|
+
import { repoFiles } from './tests-map.mjs';
|
|
9
|
+
import { FEATURES_DIR } from './feature.mjs';
|
|
10
|
+
import { PROJECT_MD } from './fix.mjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The baseline (design 8.6): docs/agjan/project.md, written by people and agents, and
|
|
14
|
+
* docs/agjan/baseline.json, written by `agjan baseline refresh`, with the hashes of the
|
|
15
|
+
* domains' watched files (models, services, app manifests, mta.yaml).
|
|
16
|
+
*/
|
|
17
|
+
export const BASELINE_FILE = `${FEATURES_DIR}/baseline.json`;
|
|
18
|
+
|
|
19
|
+
/** Required `##` headings of project.md: general ones plus the BTP domain's areas. */
|
|
20
|
+
export function projectHeadings(config) {
|
|
21
|
+
const general = ['Overview', 'Conventions', 'Do-not-touch list'];
|
|
22
|
+
return config.domains.includes('btp') ? ['Overview', 'CAP', 'Fiori', 'BTP', 'Conventions', 'Do-not-touch list'] : general;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function projectProblems(root, config) {
|
|
26
|
+
const file = join(root, PROJECT_MD);
|
|
27
|
+
if (!existsSync(file)) return [`${PROJECT_MD} does not exist`];
|
|
28
|
+
const present = new Set(headings(readFileSync(file, 'utf8')));
|
|
29
|
+
return projectHeadings(config).filter((h) => !present.has(h)).map((h) => `${PROJECT_MD}: missing heading '## ${h}'`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function fileHash(root, file) {
|
|
33
|
+
return `sha256:${createHash('sha256').update(readFileSync(join(root, file))).digest('hex')}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function watchedHashes(root, config) {
|
|
37
|
+
const isWatched = matcher(config.watched ?? []);
|
|
38
|
+
const out = {};
|
|
39
|
+
for (const file of repoFiles(root).filter(isWatched).sort()) {
|
|
40
|
+
if (existsSync(join(root, file))) out[file] = fileHash(root, file);
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** agjan baseline refresh: records the current state of the watched files. */
|
|
46
|
+
export function refreshBaseline(root, config, now) {
|
|
47
|
+
const head = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true })?.trim() ?? null;
|
|
48
|
+
const data = { schema: 1, refreshed_at_utc: now, based_on_commit: head, watched: watchedHashes(root, config) };
|
|
49
|
+
mkdirSync(dirname(join(root, BASELINE_FILE)), { recursive: true });
|
|
50
|
+
writeJson(join(root, BASELINE_FILE), data);
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Watched files that differ from the baseline: changed, added or removed since the refresh. */
|
|
55
|
+
export function baselineDrift(root, config) {
|
|
56
|
+
const baseline = readJson(join(root, BASELINE_FILE));
|
|
57
|
+
if (!baseline?.watched) return null;
|
|
58
|
+
const current = watchedHashes(root, config);
|
|
59
|
+
const drift = [];
|
|
60
|
+
for (const [file, hash] of Object.entries(current)) {
|
|
61
|
+
if (baseline.watched[file] === undefined) drift.push(`${file} (new)`);
|
|
62
|
+
else if (baseline.watched[file] !== hash) drift.push(file);
|
|
63
|
+
}
|
|
64
|
+
for (const file of Object.keys(baseline.watched)) if (current[file] === undefined) drift.push(`${file} (removed)`);
|
|
65
|
+
return drift;
|
|
66
|
+
}
|
package/src/cli.mjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createContext, pkg } from './context.mjs';
|
|
2
|
+
import { AgjanError } from './errors.mjs';
|
|
3
|
+
import { banner, createStyle } from './ui.mjs';
|
|
4
|
+
import * as newCommand from './commands/new.mjs';
|
|
5
|
+
import * as gates from './commands/gates.mjs';
|
|
6
|
+
import * as check from './commands/check.mjs';
|
|
7
|
+
import * as status from './commands/status.mjs';
|
|
8
|
+
import * as review from './commands/review.mjs';
|
|
9
|
+
import * as log from './commands/log.mjs';
|
|
10
|
+
import * as prSummary from './commands/pr-summary.mjs';
|
|
11
|
+
import * as setup from './commands/setup.mjs';
|
|
12
|
+
import * as report from './commands/report.mjs';
|
|
13
|
+
import * as fix from './commands/fix.mjs';
|
|
14
|
+
import * as mapCommand from './commands/map.mjs';
|
|
15
|
+
|
|
16
|
+
const COMMANDS = {
|
|
17
|
+
init: setup.init,
|
|
18
|
+
sync: setup.sync,
|
|
19
|
+
doctor: setup.doctor,
|
|
20
|
+
hook: setup.hook,
|
|
21
|
+
new: newCommand.run,
|
|
22
|
+
scaffold: newCommand.scaffold,
|
|
23
|
+
status: status.run,
|
|
24
|
+
check: check.run,
|
|
25
|
+
amend: gates.amend,
|
|
26
|
+
approve: gates.approve,
|
|
27
|
+
accept: gates.accept,
|
|
28
|
+
reject: gates.reject,
|
|
29
|
+
review: review.show,
|
|
30
|
+
log: log.run,
|
|
31
|
+
'pr-summary': prSummary.run,
|
|
32
|
+
report: report.run,
|
|
33
|
+
fix: fix.run,
|
|
34
|
+
map: mapCommand.map,
|
|
35
|
+
baseline: mapCommand.baseline,
|
|
36
|
+
mcp: review.mcp,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const HELP = `agjan ${pkg.version}
|
|
40
|
+
|
|
41
|
+
Spec-driven workflow kit for AI coding agents, with human approval gates
|
|
42
|
+
and a read-only reviewer at every step. Closed beta (0.x); the user guide is\nin this package: docs/guide.md
|
|
43
|
+
|
|
44
|
+
Usage: agjan <command> [options]
|
|
45
|
+
|
|
46
|
+
Setup (human):
|
|
47
|
+
init [--domains btp] [--hosts claude-code,copilot] [--base <ref>]
|
|
48
|
+
[--no-hook] [--no-ci] [--prepare]
|
|
49
|
+
set up agjan in this repository
|
|
50
|
+
sync [--force] regenerate managed files (skills, agents, blocks, settings)
|
|
51
|
+
hook install install the pre-commit hook
|
|
52
|
+
doctor check the environment and the project setup
|
|
53
|
+
|
|
54
|
+
Agent and human:
|
|
55
|
+
new <slug> --key <KEY> create a feature folder with approvals.json and spec.md
|
|
56
|
+
scaffold design create design.md and tasks.md from the templates
|
|
57
|
+
status [--feature <s> | --all]
|
|
58
|
+
show the state of the changed (or every) feature
|
|
59
|
+
check [--staged | --ci] [--base <ref>]
|
|
60
|
+
enforce the workflow rules
|
|
61
|
+
amend --task <id> --paths <p,...> --reason "<why>"
|
|
62
|
+
propose a scope amendment during Build
|
|
63
|
+
fix start <slug> --key <KEY> --what "<text>" | fix check | fix record [--verify "…"]
|
|
64
|
+
fast path for small changes (record folder under fixes/)
|
|
65
|
+
map start start mapping an existing application (project.md)
|
|
66
|
+
baseline refresh record the watched files in baseline.json
|
|
67
|
+
review show [--step <step>] list review records, or print a step's review context
|
|
68
|
+
log --stage <stage> [--role r] [--task T1] [--skill s]
|
|
69
|
+
log --gate-requested <gate> [--message "<commit message>"]
|
|
70
|
+
record a step start or a gate handed to the human
|
|
71
|
+
pr-summary print the PR description (Markdown), with check --ci results
|
|
72
|
+
report write report.md: durations, gate waits, models and tokens
|
|
73
|
+
|
|
74
|
+
Reviewer agent (through the host's MCP configuration):
|
|
75
|
+
mcp [--host <h>] [--isolation agent|shared|fork|none]
|
|
76
|
+
agjan MCP server on stdio: review_context, review_record
|
|
77
|
+
|
|
78
|
+
Human only, in a terminal:
|
|
79
|
+
approve spec | design | spec design | amendment <id>
|
|
80
|
+
accept <finding-id> --reason "<why>"
|
|
81
|
+
reject spec|design --reason "<why>"
|
|
82
|
+
each records the decision, then commits the feature
|
|
83
|
+
folder with a message you can edit (--no-commit skips)
|
|
84
|
+
|
|
85
|
+
Other:
|
|
86
|
+
--version, --help
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Runs the CLI and returns the process exit code.
|
|
91
|
+
* `options` (streams, clock, confirmation) are passed to the command context for tests.
|
|
92
|
+
*/
|
|
93
|
+
export async function main(args, options = {}) {
|
|
94
|
+
const stdout = options.stdout ?? process.stdout;
|
|
95
|
+
const stderr = options.stderr ?? process.stderr;
|
|
96
|
+
const [command, ...rest] = args;
|
|
97
|
+
|
|
98
|
+
if (command === undefined || command === '--help' || command === '-h' || command === 'help') {
|
|
99
|
+
const s = createStyle(stdout);
|
|
100
|
+
if (!s.enabled) {
|
|
101
|
+
stdout.write(HELP);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
// On a terminal: the logo instead of the first line, and bold section headings.
|
|
105
|
+
const body = HELP.split('\n').slice(1).map((l) => (/^\S.*:$/.test(l) ? s.bold(l) : l));
|
|
106
|
+
stdout.write(`${[...banner(s, pkg.version), ...body.slice(1)].join('\n')}`);
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
if (command === '--version' || command === '-v' || command === 'version') {
|
|
110
|
+
stdout.write(`${pkg.version}\n`);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const handler = COMMANDS[command];
|
|
115
|
+
if (!handler) {
|
|
116
|
+
stderr.write(`agjan: unknown command '${command}'. Run 'agjan --help'.\n`);
|
|
117
|
+
return 2;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return await handler(createContext({ ...options, stdout, stderr }), rest);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error instanceof AgjanError) {
|
|
123
|
+
const s = createStyle(stderr);
|
|
124
|
+
stderr.write(`${s.bold(s.red(`agjan ${command}:`))} ${error.message}\n`);
|
|
125
|
+
return error.exitCode;
|
|
126
|
+
}
|
|
127
|
+
if (error?.code?.startsWith?.('ERR_PARSE_ARGS')) {
|
|
128
|
+
stderr.write(`agjan ${command}: ${error.message}\n`);
|
|
129
|
+
return 2;
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|