agjan 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +2 -2
  2. package/bin/agjan.mjs +9 -2
  3. package/dist/adapters/claude-code.js +105 -0
  4. package/dist/adapters/copilot.js +80 -0
  5. package/dist/auto.js +24 -0
  6. package/dist/baseline.js +66 -0
  7. package/dist/browser.js +46 -0
  8. package/dist/cli.js +164 -0
  9. package/dist/commands/branch.js +71 -0
  10. package/dist/commands/check.js +420 -0
  11. package/dist/commands/fix.js +122 -0
  12. package/dist/commands/gates.js +462 -0
  13. package/dist/commands/lint.js +76 -0
  14. package/dist/commands/log.js +72 -0
  15. package/dist/commands/map.js +47 -0
  16. package/dist/commands/new.js +65 -0
  17. package/dist/commands/pr-summary.js +168 -0
  18. package/dist/commands/progress.js +42 -0
  19. package/dist/commands/report.js +105 -0
  20. package/dist/commands/review.js +146 -0
  21. package/dist/commands/setup.js +393 -0
  22. package/dist/commands/status.js +303 -0
  23. package/dist/commands/ui-test.js +39 -0
  24. package/dist/config.js +110 -0
  25. package/dist/context.js +56 -0
  26. package/dist/copilot-mcp.js +56 -0
  27. package/dist/documents.js +207 -0
  28. package/dist/errors.js +15 -0
  29. package/dist/feature.js +221 -0
  30. package/dist/fix.js +117 -0
  31. package/dist/git.js +88 -0
  32. package/{src/hash.mjs → dist/hash.js} +11 -14
  33. package/dist/hook.js +47 -0
  34. package/dist/json-file.js +26 -0
  35. package/dist/log.js +50 -0
  36. package/dist/managed.js +182 -0
  37. package/dist/mcp-config.js +76 -0
  38. package/dist/mcp.js +142 -0
  39. package/dist/plan.js +40 -0
  40. package/dist/progress-view.js +494 -0
  41. package/dist/progress.js +106 -0
  42. package/{src/review-policy.mjs → dist/review-policy.js} +39 -47
  43. package/dist/review.js +435 -0
  44. package/dist/scope.js +30 -0
  45. package/dist/terminal.js +127 -0
  46. package/dist/test-results.js +101 -0
  47. package/dist/tests-map.js +29 -0
  48. package/dist/types.js +5 -0
  49. package/dist/ui.js +136 -0
  50. package/dist/usage.js +116 -0
  51. package/dist/validate.js +46 -0
  52. package/docs/guide.md +98 -37
  53. package/kit/domains/btp/domain.json +4 -4
  54. package/kit/hooks/guard.mjs +48 -119
  55. package/kit/skills/agjan-build/SKILL.md +14 -8
  56. package/kit/skills/agjan-design/SKILL.md +42 -6
  57. package/kit/skills/agjan-fix/SKILL.md +9 -10
  58. package/kit/skills/agjan-map/SKILL.md +9 -10
  59. package/kit/skills/agjan-spec/SKILL.md +22 -11
  60. package/kit/skills/agjan-verify/SKILL.md +46 -19
  61. package/kit/skills/cap-developer/SKILL.md +10 -2
  62. package/kit/skills/cap-developer/references/handlers.md +11 -9
  63. package/kit/skills/cap-developer/references/project-setup.md +21 -8
  64. package/kit/skills/cap-developer/references/testing.md +38 -14
  65. package/kit/skills/cap-developer/references/typescript.md +143 -0
  66. package/kit/skills/cap-developer/references/validation-security.md +26 -8
  67. package/kit/skills/fiori-developer/SKILL.md +20 -5
  68. package/kit/skills/fiori-developer/references/app-setup.md +91 -16
  69. package/kit/skills/fiori-developer/references/elements.md +19 -5
  70. package/kit/skills/fiori-developer/references/freestyle-ts.md +5 -1
  71. package/kit/skills/fiori-developer/references/testing.md +109 -15
  72. package/kit/templates/agents-block.md +7 -3
  73. package/package.json +11 -3
  74. package/schemas/approvals.schema.json +23 -2
  75. package/schemas/config.schema.json +0 -5
  76. package/schemas/log.schema.json +1 -1
  77. package/src/adapters/claude-code.mjs +0 -121
  78. package/src/adapters/copilot.mjs +0 -89
  79. package/src/baseline.mjs +0 -66
  80. package/src/cli.mjs +0 -155
  81. package/src/commands/branch.mjs +0 -60
  82. package/src/commands/check.mjs +0 -365
  83. package/src/commands/fix.mjs +0 -116
  84. package/src/commands/gates.mjs +0 -264
  85. package/src/commands/lint.mjs +0 -74
  86. package/src/commands/log.mjs +0 -60
  87. package/src/commands/map.mjs +0 -47
  88. package/src/commands/new.mjs +0 -53
  89. package/src/commands/pr-summary.mjs +0 -137
  90. package/src/commands/progress.mjs +0 -40
  91. package/src/commands/report.mjs +0 -115
  92. package/src/commands/review.mjs +0 -76
  93. package/src/commands/setup.mjs +0 -383
  94. package/src/commands/status.mjs +0 -248
  95. package/src/config.mjs +0 -122
  96. package/src/context.mjs +0 -67
  97. package/src/copilot-mcp.mjs +0 -56
  98. package/src/documents.mjs +0 -188
  99. package/src/errors.mjs +0 -16
  100. package/src/feature.mjs +0 -225
  101. package/src/fix.mjs +0 -108
  102. package/src/git.mjs +0 -83
  103. package/src/hook.mjs +0 -48
  104. package/src/json-file.mjs +0 -24
  105. package/src/log.mjs +0 -51
  106. package/src/managed.mjs +0 -178
  107. package/src/mcp-config.mjs +0 -83
  108. package/src/mcp.mjs +0 -147
  109. package/src/plan.mjs +0 -45
  110. package/src/progress-view.mjs +0 -466
  111. package/src/progress.mjs +0 -85
  112. package/src/review.mjs +0 -413
  113. package/src/scope.mjs +0 -30
  114. package/src/terminal.mjs +0 -118
  115. package/src/test-results.mjs +0 -111
  116. package/src/tests-map.mjs +0 -29
  117. package/src/ui.mjs +0 -136
  118. package/src/usage.mjs +0 -118
  119. package/src/validate.mjs +0 -41
@@ -16,7 +16,8 @@
16
16
  "hash": { "$ref": "#/$defs/hash" },
17
17
  "spec_hash": { "$ref": "#/$defs/hash" },
18
18
  "at_utc": { "$ref": "#/$defs/utc" },
19
- "by": { "type": "string" }
19
+ "by": { "type": "string", "description": "The approver's email, or 'auto' for a gate approved in auto mode." },
20
+ "enabled_by": { "type": "string", "description": "With by 'auto': who switched auto mode on." }
20
21
  },
21
22
  "additionalProperties": false
22
23
  }
@@ -39,7 +40,20 @@
39
40
  "type": "object",
40
41
  "properties": {
41
42
  "spec": { "$ref": "#/$defs/stamp" },
42
- "design": { "$ref": "#/$defs/stamp" }
43
+ "design": { "$ref": "#/$defs/stamp" },
44
+ "verify": {
45
+ "description": "The human's acceptance of the verified feature (agjan approve verify): the verify review and the tree hash it saw, and the manual ACs the human confirmed.",
46
+ "type": "object",
47
+ "required": ["review", "tree_hash", "manual", "at_utc", "by"],
48
+ "properties": {
49
+ "review": { "type": "string" },
50
+ "tree_hash": { "$ref": "#/$defs/hash" },
51
+ "manual": { "type": "array", "items": { "type": "string" } },
52
+ "at_utc": { "$ref": "#/$defs/utc" },
53
+ "by": { "type": "string" }
54
+ },
55
+ "additionalProperties": false
56
+ }
43
57
  },
44
58
  "additionalProperties": false
45
59
  },
@@ -75,6 +89,13 @@
75
89
  "additionalProperties": false
76
90
  }
77
91
  },
92
+ "auto": {
93
+ "description": "Auto mode of this feature (agjan auto on, a human in a terminal): its spec and design gates are approved automatically once their reviews pass. Absent when off.",
94
+ "type": "object",
95
+ "required": ["by", "at_utc"],
96
+ "properties": { "by": { "type": "string" }, "at_utc": { "$ref": "#/$defs/utc" }, "from": { "enum": ["default"] } },
97
+ "additionalProperties": false
98
+ },
78
99
  "rejections": {
79
100
  "type": "array",
80
101
  "items": {
@@ -97,11 +97,6 @@
97
97
  "agent": {
98
98
  "type": "object",
99
99
  "properties": {
100
- "allow": {
101
- "description": "Shell commands agents may run without a prompt (the agjan guard hook approves a single simple command starting with an entry). agjan approve, accept and reject are always denied.",
102
- "type": "array",
103
- "items": { "type": "string", "minLength": 1 }
104
- },
105
100
  "script_edits": {
106
101
  "description": "Whether agents may edit files with shell or script commands (python/node scripts that write files, sed -i, cat > file, tee). Default 'deny': the agjan guard hook sends them to their file edit tool.",
107
102
  "enum": ["deny", "allow"]
@@ -7,7 +7,7 @@
7
7
  "required": ["at_utc", "event"],
8
8
  "properties": {
9
9
  "at_utc": { "type": "string" },
10
- "event": { "enum": ["step", "gate-requested", "approved", "rejected", "accepted", "amendment-proposed", "review-recorded", "round-granted", "waiting"] },
10
+ "event": { "enum": ["step", "gate-requested", "approved", "rejected", "accepted", "amendment-proposed", "review-recorded", "round-granted", "waiting", "auto-on", "auto-off"] },
11
11
  "stage": { "enum": ["map", "spec", "design", "build", "verify", "fix"] },
12
12
  "role": { "type": "string" },
13
13
  "task": { "type": "string" },
@@ -1,121 +0,0 @@
1
- import { stringify as toYaml } from 'yaml';
2
- import { skillBody } from '../managed.mjs';
3
- import { agentModel } from '../config.mjs';
4
-
5
- /**
6
- * Claude Code adapter (design 13): the generated reviewer agents and the deny rules for
7
- * the human-only commands. Results of the host experiments shape both
8
- * (docs/host-experiments.md, items 1, 1b and 5).
9
- */
10
-
11
- export const HOST = 'claude-code';
12
- /** The models earlier versions used when none were configured; `sync` writes them for such projects. */
13
- export const LEGACY_MODELS = { balanced: 'sonnet', deep: 'opus' };
14
-
15
- /** One agent per reviewer tier; workflow skills pick the tier per step (design 7.3). */
16
- const REVIEWERS = [
17
- { name: 'agjan-reviewer', tier: 'balanced' },
18
- { name: 'agjan-reviewer-deep', tier: 'deep' },
19
- ];
20
-
21
- const HUMAN_ONLY = ['approve', 'accept', 'reject'];
22
- /** Every way an agent's shell might start agjan. Indirect forms are stopped by the terminal check. */
23
- const LAUNCHERS = ['agjan', 'npx agjan', 'npx --no-install agjan', 'npx -y agjan', 'npm exec agjan', 'npm exec -- agjan'];
24
-
25
- export const DENY_RULES = HUMAN_ONLY.flatMap((cmd) => LAUNCHERS.map((l) => `Bash(${l} ${cmd}:*)`));
26
-
27
- /**
28
- * The guard as a PreToolUse hook. It also catches wrapped forms the prefix deny rules miss
29
- * (`sh -c "agjan approve …"`). If it cannot start (agjan not installed), Claude Code
30
- * treats the error as non-blocking.
31
- *
32
- * Shell form, as in Claude Code's documentation (it runs hooks with bash, on Windows
33
- * through Git Bash). Not the exec form (`command` + `args`): the GitHub Copilot CLI also
34
- * runs the hooks of `.claude/settings.json`, ignores `args`, and denies every tool call
35
- * when a hook fails (host experiments, GitHub Copilot CLI, 5b).
36
- */
37
- export const GUARD_HOOK = {
38
- type: 'command',
39
- command: 'node "$CLAUDE_PROJECT_DIR/node_modules/agjan/kit/hooks/guard.mjs"',
40
- timeout: 10,
41
- };
42
-
43
- const GUARD_PATH = 'node_modules/agjan/kit/hooks/guard.mjs';
44
-
45
- /** A guard entry written by an earlier agjan version (for example the exec form). */
46
- /** The tools the guard sees: the shell, and the file edit tools (records, allow_edits). */
47
- export const GUARD_MATCHER = 'Bash|Edit|Write|MultiEdit|NotebookEdit';
48
-
49
- const isGuard = (hook) => JSON.stringify(hook).includes(GUARD_PATH);
50
- const isCurrent = (hook) => JSON.stringify(hook) === JSON.stringify(GUARD_HOOK);
51
-
52
- /** The current guard, in a group with the current matcher, and no other guard entry. */
53
- function hasGuard(data) {
54
- const groups = data.hooks?.PreToolUse ?? [];
55
- const guards = groups.flatMap((group) => (group.hooks ?? []).filter(isGuard).map((hook) => ({ group, hook })));
56
- return guards.length === 1 && isCurrent(guards[0].hook) && guards[0].group.matcher === GUARD_MATCHER;
57
- }
58
-
59
- /**
60
- * PreToolUse without any guard entry (earlier forms, or the current one under an older
61
- * matcher such as 'Bash'); a group left empty is dropped. The caller adds the current one.
62
- */
63
- function withoutGuards(groups) {
64
- return groups
65
- .map((group) => (group.hooks?.some(isGuard) ? { ...group, hooks: group.hooks.filter((h) => !isGuard(h)) } : group))
66
- .filter((group) => !Array.isArray(group.hooks) || group.hooks.length > 0);
67
- }
68
-
69
- function reviewerAgent(name, tier, model, skill) {
70
- const frontmatter = {
71
- name,
72
- description:
73
- `agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
74
- 'review of a step; it records its result itself.',
75
- tools: 'Read, Grep, Glob, mcp__agjan__review_context, mcp__agjan__review_record',
76
- ...(model ? { model } : {}),
77
- // Scoped to this agent only: the writer session must not have review_record.
78
- mcpServers: [
79
- {
80
- agjan: {
81
- type: 'stdio',
82
- command: 'npx',
83
- args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent'],
84
- },
85
- },
86
- ],
87
- };
88
- return [
89
- '---',
90
- toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
91
- '---',
92
- '<!-- Generated by agjan sync from the solution-reviewer skill. Do not edit; run agjan sync. -->',
93
- '',
94
- skillBody(skill),
95
- ].join('\n');
96
- }
97
-
98
- /** The plan items this adapter contributes. */
99
- export function plan(config, skills) {
100
-
101
- const skill = skills['solution-reviewer/SKILL.md'];
102
- const items = REVIEWERS.map(({ name, tier }) => ({
103
- kind: 'file',
104
- path: `.claude/agents/${name}.md`,
105
- content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
106
- }));
107
- items.push({
108
- kind: 'json',
109
- path: '.claude/settings.json',
110
- present: (data) => DENY_RULES.every((rule) => data.permissions?.deny?.includes(rule)) && hasGuard(data),
111
- merge: (data) => {
112
- const deny = [...new Set([...(data.permissions?.deny ?? []), ...DENY_RULES])];
113
- let hooks = data.hooks ?? {};
114
- if (!hasGuard(data)) {
115
- hooks = { ...hooks, PreToolUse: [...withoutGuards(hooks.PreToolUse ?? []), { matcher: GUARD_MATCHER, hooks: [GUARD_HOOK] }] };
116
- }
117
- return { ...data, permissions: { ...(data.permissions ?? {}), deny }, hooks };
118
- },
119
- });
120
- return items;
121
- }
@@ -1,89 +0,0 @@
1
- import { stringify as toYaml } from 'yaml';
2
- import { skillBody } from '../managed.mjs';
3
- import { agentModel } from '../config.mjs';
4
-
5
- /**
6
- * GitHub Copilot adapter (design 13), verified with the Copilot CLI
7
- * (docs/host-experiments.md): reviewer agents in `.github/agents/` with the agjan MCP
8
- * server inline, and a `preToolUse` guard hook in `.github/hooks/`, because the
9
- * Copilot CLI has no persistent deny setting. Skills need nothing: Copilot reads
10
- * `.claude/skills/`.
11
- *
12
- * VS Code ignores `mcp-servers` in agent files and does not run hooks; see the open
13
- * item in design section 19.
14
- */
15
-
16
- export const HOST = 'copilot';
17
- export const HOOK_FILE = '.github/hooks/agjan-guard.json';
18
- export const GUARD = 'node_modules/agjan/kit/hooks/guard.mjs';
19
-
20
- /** The models earlier versions used when none were configured: the session's model. */
21
- export const LEGACY_MODELS = {};
22
-
23
- const REVIEWERS = [
24
- { name: 'agjan-reviewer', tier: 'balanced' },
25
- { name: 'agjan-reviewer-deep', tier: 'deep' },
26
- ];
27
-
28
- function reviewerAgent(name, tier, model, skill) {
29
- const frontmatter = {
30
- name,
31
- description:
32
- `agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
33
- 'review of a step; it records its result itself.',
34
- tools: ['read', 'search', 'agjan/review_context', 'agjan/review_record'],
35
- ...(model ? { model } : {}),
36
- // Scoped to this agent only: the writer session must not have review_record.
37
- 'mcp-servers': {
38
- agjan: {
39
- type: 'local',
40
- command: 'npx',
41
- args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent'],
42
- tools: ['*'],
43
- },
44
- },
45
- };
46
- return [
47
- '---',
48
- toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
49
- '---',
50
- '<!-- Generated by agjan sync from the solution-reviewer skill. Do not edit; run agjan sync. -->',
51
- '',
52
- skillBody(skill),
53
- ].join('\n');
54
- }
55
-
56
- /**
57
- * The guard hook. If agjan is not installed the guard cannot start; the hook then
58
- * allows (`|| true`, `exit 0`) instead of failing closed and blocking every tool call.
59
- */
60
- export function hookConfig() {
61
- const hook = {
62
- version: 1,
63
- hooks: {
64
- preToolUse: [
65
- {
66
- type: 'command',
67
- bash: `node ${GUARD} || true`,
68
- powershell: `node ${GUARD}; exit 0`,
69
- cwd: '.',
70
- timeoutSec: 10,
71
- },
72
- ],
73
- },
74
- };
75
- return `${JSON.stringify(hook, null, 2)}\n`;
76
- }
77
-
78
- /** The plan items this adapter contributes. */
79
- export function plan(config, skills) {
80
-
81
- const skill = skills['solution-reviewer/SKILL.md'];
82
- const items = REVIEWERS.map(({ name, tier }) => ({
83
- kind: 'file',
84
- path: `.github/agents/${name}.agent.md`,
85
- content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
86
- }));
87
- items.push({ kind: 'file', path: HOOK_FILE, content: hookConfig() });
88
- return items;
89
- }
package/src/baseline.mjs DELETED
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,155 +0,0 @@
1
- import { createContext, pkg } from './context.mjs';
2
- import { AgjanError } from './errors.mjs';
3
- import { createStyle, mark } 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
- import * as branch from './commands/branch.mjs';
16
- import * as progress from './commands/progress.mjs';
17
- import * as lint from './commands/lint.mjs';
18
- import { onEvent } from './log.mjs';
19
- import { refreshAfterEvent } from './progress-view.mjs';
20
-
21
- const COMMANDS = {
22
- init: setup.init,
23
- sync: setup.sync,
24
- doctor: setup.doctor,
25
- hook: setup.hook,
26
- branch: branch.run,
27
- progress: progress.run,
28
- new: newCommand.run,
29
- scaffold: newCommand.scaffold,
30
- status: status.run,
31
- check: check.run,
32
- lint: lint.run,
33
- amend: gates.amend,
34
- approve: gates.approve,
35
- accept: gates.accept,
36
- reject: gates.reject,
37
- review: review.run,
38
- log: log.run,
39
- 'pr-summary': prSummary.run,
40
- report: report.run,
41
- fix: fix.run,
42
- map: mapCommand.map,
43
- baseline: mapCommand.baseline,
44
- mcp: review.mcp,
45
- };
46
-
47
- const HELP = `agjan ${pkg.version}
48
-
49
- Spec-driven workflow kit for AI coding agents, with human approval gates
50
- and a read-only reviewer at every step. Closed beta (0.x); the user guide is\nin this package: docs/guide.md
51
-
52
- Usage: agjan <command> [options]
53
-
54
- Setup (human):
55
- init [--domains btp] [--hosts claude-code,copilot] [--base <ref>]
56
- [--no-hook] [--no-ci] [--prepare] [--agent-allow | --no-agent-allow]
57
- [--copilot-mcp | --no-copilot-mcp]
58
- set up agjan in this repository
59
- sync [--force] [--copilot-mcp]
60
- regenerate managed files (skills, agents, blocks, settings);
61
- --copilot-mcp adds missing MCP servers to Copilot
62
- hook install install the pre-commit hook
63
- doctor check the environment and the project setup
64
-
65
- Agent and human:
66
- branch <name> | --list | --use <name>
67
- create the branch for a feature, fix or map run, list
68
- the existing ones, or switch to one (after asking the user)
69
- new <slug> --key <KEY> create a feature folder with approvals.json and spec.md
70
- scaffold design create design.md and tasks.md from the templates
71
- progress [--open] regenerate the progress pages and show the overview
72
- (.agjan/progress.html, docs/agjan/<unit>/progress.md)
73
- status [--feature <s> | --all]
74
- show the state of the changed (or every) feature
75
- check [--staged | --ci] [--base <ref>]
76
- enforce the workflow rules
77
- lint [--all] [--base <ref>] run the area linters (UI5 linter for fiori) on the changed
78
- files of each app, without MCP
79
- amend --task <id> --paths <p,...> --reason "<why>"
80
- propose a scope amendment during Build
81
- fix start <slug> --key <KEY> --what "<text>" | fix check | fix record [--verify "…"]
82
- fast path for small changes (record folder under fixes/)
83
- map start start mapping an existing application (project.md)
84
- baseline refresh record the watched files in baseline.json
85
- review show [--step <step>] list review records, or print a step's review context
86
- review extend <step> one more round for a step still blocked at its round
87
- limit (after the user said yes)
88
- log --stage <stage> [--role r] [--task T1] [--skill s]
89
- log --gate-requested <gate> [--message "<commit message>"]
90
- record a step start or a gate handed to the human
91
- pr-summary print the PR description (Markdown), with check --ci results
92
- report write report.md: durations, gate waits, models and tokens
93
-
94
- Reviewer agent (through the host's MCP configuration):
95
- mcp [--host <h>] [--isolation agent|shared|fork|none]
96
- agjan MCP server on stdio: review_context, review_record
97
-
98
- Human only, in a terminal:
99
- approve spec | design | spec design | amendment <id>
100
- accept <finding-id> --reason "<why>"
101
- reject spec|design --reason "<why>"
102
- each records the decision, then commits the feature
103
- folder with a message you can edit (--no-commit skips)
104
-
105
- Other:
106
- --version, --help
107
- `;
108
-
109
- /**
110
- * Runs the CLI and returns the process exit code.
111
- * `options` (streams, clock, confirmation) are passed to the command context for tests.
112
- */
113
- export async function main(args, options = {}) {
114
- const stdout = options.stdout ?? process.stdout;
115
- const stderr = options.stderr ?? process.stderr;
116
- const [command, ...rest] = args;
117
-
118
- if (command === undefined || command === '--help' || command === '-h' || command === 'help') {
119
- const s = createStyle(stdout);
120
- if (!s.brand) {
121
- stdout.write(HELP);
122
- return 0;
123
- }
124
- // On a terminal: the agjan mark instead of the first line, and bold section headings.
125
- const body = HELP.split('\n').slice(1).map((l) => (/^\S.*:$/.test(l) ? s.bold(l) : l));
126
- stdout.write(`${[...mark(s, pkg.version), ...body.slice(1)].join('\n')}`);
127
- return 0;
128
- }
129
- if (command === '--version' || command === '-v' || command === 'version') {
130
- stdout.write(`${pkg.version}\n`);
131
- return 0;
132
- }
133
-
134
- // Every recorded event regenerates the progress pages (docs/agjan/<unit>/progress.md, .agjan/).
135
- onEvent((unitDir) => refreshAfterEvent(unitDir, pkg.version));
136
- const handler = COMMANDS[command];
137
- if (!handler) {
138
- stderr.write(`agjan: unknown command '${command}'. Run 'agjan --help'.\n`);
139
- return 2;
140
- }
141
- try {
142
- return await handler(createContext({ ...options, stdout, stderr }), rest);
143
- } catch (error) {
144
- if (error instanceof AgjanError) {
145
- const s = createStyle(stderr);
146
- stderr.write(`${s.bold(s.red(`agjan ${command}:`))} ${error.message}\n`);
147
- return error.exitCode;
148
- }
149
- if (error?.code?.startsWith?.('ERR_PARSE_ARGS')) {
150
- stderr.write(`agjan ${command}: ${error.message}\n`);
151
- return 2;
152
- }
153
- throw error;
154
- }
155
- }
@@ -1,60 +0,0 @@
1
- import { parseArgs } from 'node:util';
2
- import { git, currentBranch, resolveBase } from '../git.mjs';
3
- import { AgjanError, UsageError } from '../errors.mjs';
4
-
5
- /** Problems with a proposed branch name: git's rules, existence. */
6
- export function branchProblems(root, config, name) {
7
- const problems = [];
8
- if (git(root, ['check-ref-format', '--branch', name], { allowFail: true }) === null) problems.push(`'${name}' is not a valid branch name`);
9
- if (git(root, ['rev-parse', '--verify', '--quiet', `refs/heads/${name}`], { allowFail: true }) !== null) problems.push(`branch '${name}' already exists`);
10
- return problems;
11
- }
12
-
13
- /** Local branches other than the base branch, most recent commit first. */
14
- export function existingBranches(root, config) {
15
- const base = (resolveBase(root, config.git?.base) ?? '').replace(/^origin\//, '');
16
- const out = git(root, ['for-each-ref', '--sort=-committerdate', '--format=%(refname:short)\t%(committerdate:relative)', 'refs/heads'], { allowFail: true }) ?? '';
17
- return out.split('\n').filter(Boolean).map((line) => {
18
- const [name, when] = line.split('\t');
19
- return { name, when };
20
- }).filter((b) => b.name !== base);
21
- }
22
-
23
- /**
24
- * agjan branch <name> | --list | --use <name>: the branch for a feature, fix or map run.
25
- * The agent asks the user first (create the proposed name, use an existing branch, or
26
- * another name; design decision 62), then runs this: <name> creates the branch and
27
- * switches to it, --list shows the existing ones, --use switches to one of them.
28
- */
29
- export async function run(ctx, argv) {
30
- const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { list: { type: 'boolean' }, use: { type: 'string' } } });
31
- const s = ctx.style;
32
- if (values.list) {
33
- if (positionals.length || values.use) throw new UsageError('usage: agjan branch --list');
34
- const current = currentBranch(ctx.root);
35
- const branches = existingBranches(ctx.root, ctx.config);
36
- if (!branches.length) ctx.out(s.gray('no branches besides the base branch'));
37
- for (const b of branches) ctx.out(`${b.name === current ? s.green('* ') : ' '}${s.bold(b.name)} ${s.gray(`(${b.when})`)}`);
38
- return 0;
39
- }
40
- if (values.use !== undefined) {
41
- if (positionals.length) throw new UsageError('usage: agjan branch --use <name>');
42
- const name = values.use;
43
- if (!existingBranches(ctx.root, ctx.config).some((b) => b.name === name)) {
44
- throw new AgjanError(`'${name}' is not an existing branch other than the base branch (npx agjan branch --list)`);
45
- }
46
- if (currentBranch(ctx.root) !== name) git(ctx.root, ['switch', '-q', name]);
47
- ctx.out(`${s.green('on branch')} ${s.bold(name)}`);
48
- return 0;
49
- }
50
- if (positionals.length !== 1) throw new UsageError('usage: agjan branch <name> | --list | --use <name>');
51
- const name = positionals[0];
52
- const problems = branchProblems(ctx.root, ctx.config, name);
53
- if (problems.length) throw new AgjanError(`cannot create the branch:\n${problems.map((p) => ` - ${p}`).join('\n')}`);
54
- const from = currentBranch(ctx.root);
55
- git(ctx.root, ['switch', '-q', '-c', name]);
56
- ctx.out(`${s.green('created branch')} ${s.bold(name)}${from ? s.gray(` (from ${from})`) : ''}`);
57
- const base = resolveBase(ctx.root, ctx.config.git?.base);
58
- if (from && base && from !== base.replace(/^origin\//, '')) ctx.out(s.yellow(`note: created from ${from}, not from the base branch ${base}`));
59
- return 0;
60
- }