agjan 0.0.11 → 0.0.13

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 (114) hide show
  1. package/README.md +2 -2
  2. package/bin/agjan.mjs +9 -2
  3. package/dist/adapters/claude-code.js +136 -0
  4. package/dist/adapters/copilot.js +110 -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 +170 -0
  9. package/dist/commands/branch.js +71 -0
  10. package/dist/commands/check.js +424 -0
  11. package/dist/commands/fix.js +122 -0
  12. package/dist/commands/gates.js +475 -0
  13. package/dist/commands/lint.js +76 -0
  14. package/dist/commands/log.js +74 -0
  15. package/dist/commands/map.js +47 -0
  16. package/dist/commands/models.js +90 -0
  17. package/dist/commands/new.js +65 -0
  18. package/dist/commands/pr-summary.js +176 -0
  19. package/dist/commands/progress.js +42 -0
  20. package/dist/commands/report.js +105 -0
  21. package/dist/commands/review.js +149 -0
  22. package/dist/commands/setup.js +393 -0
  23. package/dist/commands/status.js +323 -0
  24. package/dist/commands/ui-test.js +39 -0
  25. package/dist/config.js +114 -0
  26. package/dist/context.js +56 -0
  27. package/dist/copilot-mcp.js +56 -0
  28. package/dist/documents.js +207 -0
  29. package/dist/errors.js +15 -0
  30. package/dist/feature.js +221 -0
  31. package/dist/fix.js +117 -0
  32. package/dist/git.js +88 -0
  33. package/{src/hash.mjs → dist/hash.js} +11 -14
  34. package/dist/hook.js +47 -0
  35. package/dist/json-file.js +26 -0
  36. package/dist/log.js +50 -0
  37. package/dist/managed.js +182 -0
  38. package/dist/mcp-config.js +76 -0
  39. package/dist/mcp.js +187 -0
  40. package/dist/plan.js +40 -0
  41. package/dist/progress-view.js +494 -0
  42. package/dist/progress.js +106 -0
  43. package/dist/qa.js +77 -0
  44. package/dist/review-policy.js +84 -0
  45. package/dist/review.js +534 -0
  46. package/dist/scope.js +34 -0
  47. package/dist/terminal.js +127 -0
  48. package/dist/test-results.js +101 -0
  49. package/dist/tests-map.js +29 -0
  50. package/dist/types.js +5 -0
  51. package/dist/ui.js +136 -0
  52. package/dist/usage.js +116 -0
  53. package/dist/validate.js +46 -0
  54. package/docs/guide.md +80 -40
  55. package/kit/hooks/guard.mjs +48 -119
  56. package/kit/skills/agjan-build/SKILL.md +6 -2
  57. package/kit/skills/agjan-design/SKILL.md +9 -2
  58. package/kit/skills/agjan-fix/SKILL.md +8 -16
  59. package/kit/skills/agjan-map/SKILL.md +8 -16
  60. package/kit/skills/agjan-spec/SKILL.md +24 -17
  61. package/kit/skills/agjan-verify/SKILL.md +50 -16
  62. package/kit/skills/qa-tester/SKILL.md +74 -0
  63. package/kit/templates/agents-block.md +3 -3
  64. package/package.json +11 -3
  65. package/schemas/approvals.schema.json +23 -2
  66. package/schemas/config.schema.json +3 -7
  67. package/schemas/log.schema.json +1 -1
  68. package/schemas/reviews.schema.json +3 -1
  69. package/src/adapters/claude-code.mjs +0 -121
  70. package/src/adapters/copilot.mjs +0 -89
  71. package/src/baseline.mjs +0 -66
  72. package/src/browser.mjs +0 -49
  73. package/src/cli.mjs +0 -165
  74. package/src/commands/branch.mjs +0 -95
  75. package/src/commands/check.mjs +0 -376
  76. package/src/commands/fix.mjs +0 -116
  77. package/src/commands/gates.mjs +0 -267
  78. package/src/commands/lint.mjs +0 -74
  79. package/src/commands/log.mjs +0 -60
  80. package/src/commands/map.mjs +0 -47
  81. package/src/commands/new.mjs +0 -53
  82. package/src/commands/pr-summary.mjs +0 -137
  83. package/src/commands/progress.mjs +0 -40
  84. package/src/commands/report.mjs +0 -115
  85. package/src/commands/review.mjs +0 -141
  86. package/src/commands/setup.mjs +0 -393
  87. package/src/commands/status.mjs +0 -250
  88. package/src/commands/ui-test.mjs +0 -38
  89. package/src/config.mjs +0 -122
  90. package/src/context.mjs +0 -67
  91. package/src/copilot-mcp.mjs +0 -56
  92. package/src/documents.mjs +0 -188
  93. package/src/errors.mjs +0 -16
  94. package/src/feature.mjs +0 -225
  95. package/src/fix.mjs +0 -108
  96. package/src/git.mjs +0 -83
  97. package/src/hook.mjs +0 -48
  98. package/src/json-file.mjs +0 -24
  99. package/src/log.mjs +0 -51
  100. package/src/managed.mjs +0 -178
  101. package/src/mcp-config.mjs +0 -83
  102. package/src/mcp.mjs +0 -147
  103. package/src/plan.mjs +0 -45
  104. package/src/progress-view.mjs +0 -466
  105. package/src/progress.mjs +0 -85
  106. package/src/review-policy.mjs +0 -91
  107. package/src/review.mjs +0 -416
  108. package/src/scope.mjs +0 -30
  109. package/src/terminal.mjs +0 -118
  110. package/src/test-results.mjs +0 -111
  111. package/src/tests-map.mjs +0 -29
  112. package/src/ui.mjs +0 -136
  113. package/src/usage.mjs +0 -118
  114. package/src/validate.mjs +0 -41
package/src/browser.mjs DELETED
@@ -1,49 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { join } from 'node:path';
3
- import { readJson } from './json-file.mjs';
4
-
5
- /**
6
- * UI tests are optional (design decision 75): they run in Playwright's Chromium where it
7
- * can start, and are skipped with the reason where it cannot. On macOS and Windows,
8
- * `npx playwright install chromium` is all it needs; on Linux, Chromium also needs system
9
- * libraries, which only an administrator adds. agjan never installs them.
10
- */
11
-
12
- /** The npm script that runs a project's UI tests. */
13
- export const UI_SCRIPT = 'test:ui';
14
-
15
- // Exit code 3: the project has no Playwright.
16
- const PROBE = `let pw;
17
- try { pw = await import('@playwright/test'); } catch { process.exit(3); }
18
- const browser = await pw.chromium.launch();
19
- await browser.close();`;
20
-
21
- /** Whether the project defines the UI test script. */
22
- export function hasUiTests(root) {
23
- return Boolean(readJson(join(root, 'package.json'))?.scripts?.[UI_SCRIPT]);
24
- }
25
-
26
- /**
27
- * Starts and closes Chromium from the project. Returns { ready: true } or { ready: false,
28
- * reason, enable }. AGJAN_BROWSER_PROBE names a Node script that replaces the probe (tests).
29
- */
30
- export function probeBrowser(root) {
31
- const fake = process.env.AGJAN_BROWSER_PROBE;
32
- const run = spawnSync(process.execPath, fake ? [fake] : ['--input-type=module', '-e', PROBE], { cwd: root, encoding: 'utf8', timeout: 120_000 });
33
- if (run.status === 0) return { ready: true };
34
- if (run.status === 3) return { ready: false, reason: '@playwright/test is not installed', enable: 'npm install' };
35
- const output = `${run.stderr ?? ''}${run.stdout ?? ''}`;
36
- if (/Executable doesn't exist|playwright install/i.test(output) && !/install-deps|missing dependencies/i.test(output)) {
37
- return { ready: false, reason: 'Chromium is not downloaded', enable: 'npx playwright install chromium (no admin rights needed)' };
38
- }
39
- const library = /error while loading shared libraries: (\S+?):/.exec(output)?.[1];
40
- if (library || /missing dependencies|install-deps/i.test(output)) {
41
- return {
42
- ready: false,
43
- reason: `Chromium cannot start: this Linux system lacks its libraries${library ? ` (${library})` : ''}`,
44
- enable: 'whoever maintains the machine or container image adds them once, for example with `npx playwright install-deps chromium` run as root in its Dockerfile',
45
- };
46
- }
47
- const first = output.split('\n').map((l) => l.trim()).find((l) => l && !l.startsWith('at ')) ?? (run.error ? run.error.message : `exit code ${run.status}`);
48
- return { ready: false, reason: `Chromium cannot start: ${first.replace(/^\w*Error: /, '')}`, enable: 'npx playwright install chromium, then npx agjan doctor' };
49
- }
package/src/cli.mjs DELETED
@@ -1,165 +0,0 @@
1
- import { createContext, pkg } from './context.mjs';
2
- import { AgjanError } from './errors.mjs';
3
- import { blink, 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 * as uiTest from './commands/ui-test.mjs';
19
- import { onEvent } from './log.mjs';
20
- import { refreshAfterEvent } from './progress-view.mjs';
21
-
22
- const COMMANDS = {
23
- init: setup.init,
24
- sync: setup.sync,
25
- doctor: setup.doctor,
26
- hook: setup.hook,
27
- branch: branch.run,
28
- progress: progress.run,
29
- new: newCommand.run,
30
- scaffold: newCommand.scaffold,
31
- status: status.run,
32
- check: check.run,
33
- lint: lint.run,
34
- 'ui-test': uiTest.run,
35
- amend: gates.amend,
36
- approve: gates.approve,
37
- accept: gates.accept,
38
- reject: gates.reject,
39
- review: review.run,
40
- log: log.run,
41
- 'pr-summary': prSummary.run,
42
- report: report.run,
43
- fix: fix.run,
44
- map: mapCommand.map,
45
- baseline: mapCommand.baseline,
46
- mcp: review.mcp,
47
- };
48
-
49
- const HELP = `agjan ${pkg.version}
50
-
51
- Spec-driven workflow kit for AI coding agents, with human approval gates
52
- and a read-only reviewer at every step. Closed beta (0.x); the user guide is\nin this package: docs/guide.md
53
-
54
- Usage: agjan <command> [options]
55
-
56
- Setup (human):
57
- init [--domains btp] [--hosts claude-code,copilot] [--base <ref>]
58
- [--no-hook] [--no-ci] [--prepare] [--agent-allow | --no-agent-allow]
59
- [--copilot-mcp | --no-copilot-mcp]
60
- set up agjan in this repository
61
- sync [--force] [--copilot-mcp]
62
- regenerate managed files (skills, agents, blocks, settings);
63
- --copilot-mcp adds missing MCP servers to Copilot
64
- hook install install the pre-commit hook
65
- doctor check the environment and the project setup
66
-
67
- Agent and human:
68
- branch <name> | --list | --use <name> | --edit <proposal>
69
- create the branch for a feature, fix or map run, list
70
- the existing ones, or switch to one (after asking the user);
71
- --edit: the human edits the proposed name in a terminal
72
- new <slug> --key <KEY> create a feature folder with approvals.json and spec.md
73
- scaffold design create design.md and tasks.md from the templates
74
- progress [--open] regenerate the progress pages and show the overview
75
- (.agjan/progress.html, docs/agjan/<unit>/progress.md)
76
- status [--feature <s> | --all]
77
- show the state of the changed (or every) feature
78
- check [--staged | --ci] [--base <ref>]
79
- enforce the workflow rules
80
- lint [--all] [--base <ref>] run the area linters (UI5 linter for fiori) on the changed
81
- files of each app, without MCP
82
- ui-test [--require] run the UI tests (npm run test:ui, Playwright) where
83
- Chromium can start; else say why and skip (--require: exit 1)
84
- amend --task <id> --paths <p,...> --reason "<why>"
85
- propose a scope amendment during Build
86
- fix start <slug> --key <KEY> --what "<text>" | fix check | fix record [--verify "…"]
87
- fast path for small changes (record folder under fixes/)
88
- map start start mapping an existing application (project.md)
89
- baseline refresh record the watched files in baseline.json
90
- review show [--step <step>] list review records, or print a step's review context
91
- review report [--step <step>] the latest review round for the user: verdict, findings,
92
- rounds, what happens next (agents show it after each review)
93
- review extend <step> one more round for a step still blocked at its round
94
- limit (after the user said yes)
95
- log --stage <stage> [--role r] [--task T1] [--skill s]
96
- log --gate-requested <gate> [--message "<commit message>"]
97
- record a step start or a gate handed to the human
98
- pr-summary print the PR description (Markdown), with check --ci results
99
- report write report.md: durations, gate waits, models and tokens
100
-
101
- Reviewer agent (through the host's MCP configuration):
102
- mcp [--host <h>] [--isolation agent|shared|fork|none]
103
- agjan MCP server on stdio: review_context, review_record
104
-
105
- Human only, in a terminal:
106
- approve spec | design | spec design | amendment <id>
107
- accept <finding-id> --reason "<why>"
108
- reject spec|design --reason "<why>"
109
- each records the decision, then commits the feature
110
- folder with a message you can edit (--no-commit skips)
111
-
112
- Other:
113
- --version, --help
114
- `;
115
-
116
- /**
117
- * Runs the CLI and returns the process exit code.
118
- * `options` (streams, clock, confirmation) are passed to the command context for tests.
119
- */
120
- export async function main(args, options = {}) {
121
- const stdout = options.stdout ?? process.stdout;
122
- const stderr = options.stderr ?? process.stderr;
123
- const [command, ...rest] = args;
124
-
125
- if (command === undefined || command === '--help' || command === '-h' || command === 'help') {
126
- const s = createStyle(stdout);
127
- if (!s.brand) {
128
- stdout.write(HELP);
129
- return 0;
130
- }
131
- // On a terminal: the agjan mark instead of the first line, and bold section headings.
132
- const body = HELP.split('\n').slice(1).map((l) => (/^\S.*:$/.test(l) ? s.bold(l) : l));
133
- const logo = mark(s, pkg.version);
134
- stdout.write(`${logo.join('\n')}\n`);
135
- await blink({ isTTY: Boolean(stdout.isTTY), write: (text) => stdout.write(text) }, logo);
136
- stdout.write(body.slice(1).join('\n'));
137
- return 0;
138
- }
139
- if (command === '--version' || command === '-v' || command === 'version') {
140
- stdout.write(`${pkg.version}\n`);
141
- return 0;
142
- }
143
-
144
- // Every recorded event regenerates the progress pages (docs/agjan/<unit>/progress.md, .agjan/).
145
- onEvent((unitDir) => refreshAfterEvent(unitDir, pkg.version));
146
- const handler = COMMANDS[command];
147
- if (!handler) {
148
- stderr.write(`agjan: unknown command '${command}'. Run 'agjan --help'.\n`);
149
- return 2;
150
- }
151
- try {
152
- return await handler(createContext({ ...options, stdout, stderr }), rest);
153
- } catch (error) {
154
- if (error instanceof AgjanError) {
155
- const s = createStyle(stderr);
156
- stderr.write(`${s.bold(s.red(`agjan ${command}:`))} ${error.message}\n`);
157
- return error.exitCode;
158
- }
159
- if (error?.code?.startsWith?.('ERR_PARSE_ARGS')) {
160
- stderr.write(`agjan ${command}: ${error.message}\n`);
161
- return 2;
162
- }
163
- throw error;
164
- }
165
- }
@@ -1,95 +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
- /** Creates the branch `name` from the current one and switches to it. */
24
- function create(ctx, name) {
25
- const s = ctx.style;
26
- const problems = branchProblems(ctx.root, ctx.config, name);
27
- if (problems.length) throw new AgjanError(`cannot create the branch:\n${problems.map((p) => ` - ${p}`).join('\n')}`);
28
- const from = currentBranch(ctx.root);
29
- git(ctx.root, ['switch', '-q', '-c', name]);
30
- ctx.out(`${s.green('created branch')} ${s.bold(name)}${from ? s.gray(` (from ${from})`) : ''}`);
31
- const base = resolveBase(ctx.root, ctx.config.git?.base);
32
- if (from && base && from !== base.replace(/^origin\//, '')) ctx.out(s.yellow(`note: created from ${from}, not from the base branch ${base}`));
33
- return 0;
34
- }
35
-
36
- /**
37
- * --edit <proposal>: the human edits the proposed name in a terminal (it is typed in
38
- * already), then the branch is created. A name git refuses is shown again for editing;
39
- * an empty name cancels. Agents have no terminal: they ask the user to run it.
40
- */
41
- async function edit(ctx, proposal) {
42
- const s = ctx.style;
43
- let name = proposal;
44
- for (;;) {
45
- try {
46
- name = String(await ctx.edit(`${s.bold('Branch name')} (Enter to create, empty to cancel): `, name)).trim();
47
- } catch (error) {
48
- if (error instanceof AgjanError) throw new AgjanError(`npx agjan branch --edit needs a human at a terminal; agents ask the user to run it (${error.message})`);
49
- throw error;
50
- }
51
- if (!name) {
52
- ctx.out(s.yellow('cancelled, no branch created'));
53
- return 1;
54
- }
55
- const problems = branchProblems(ctx.root, ctx.config, name);
56
- if (!problems.length) return create(ctx, name);
57
- ctx.out(s.red(`${problems.join('; ')}; change the name`));
58
- }
59
- }
60
-
61
- /**
62
- * agjan branch <name> | --list | --use <name> | --edit <proposal>: the branch for a
63
- * feature, fix or map run. The agent asks the user first (create the proposed name, use
64
- * an existing branch, or another name; design decision 62), then runs this: <name>
65
- * creates the branch and switches to it, --list shows the existing ones, --use switches
66
- * to one of them. --edit is for the human in a terminal: the proposal, ready to edit.
67
- */
68
- export async function run(ctx, argv) {
69
- const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { list: { type: 'boolean' }, use: { type: 'string' }, edit: { type: 'string' } } });
70
- const s = ctx.style;
71
- if (values.edit !== undefined) {
72
- if (positionals.length || values.use !== undefined || values.list) throw new UsageError('usage: agjan branch --edit <proposal>');
73
- return edit(ctx, values.edit);
74
- }
75
- if (values.list) {
76
- if (positionals.length || values.use) throw new UsageError('usage: agjan branch --list');
77
- const current = currentBranch(ctx.root);
78
- const branches = existingBranches(ctx.root, ctx.config);
79
- if (!branches.length) ctx.out(s.gray('no branches besides the base branch'));
80
- for (const b of branches) ctx.out(`${b.name === current ? s.green('* ') : ' '}${s.bold(b.name)} ${s.gray(`(${b.when})`)}`);
81
- return 0;
82
- }
83
- if (values.use !== undefined) {
84
- if (positionals.length) throw new UsageError('usage: agjan branch --use <name>');
85
- const name = values.use;
86
- if (!existingBranches(ctx.root, ctx.config).some((b) => b.name === name)) {
87
- throw new AgjanError(`'${name}' is not an existing branch other than the base branch (npx agjan branch --list)`);
88
- }
89
- if (currentBranch(ctx.root) !== name) git(ctx.root, ['switch', '-q', name]);
90
- ctx.out(`${s.green('on branch')} ${s.bold(name)}`);
91
- return 0;
92
- }
93
- if (positionals.length !== 1) throw new UsageError('usage: agjan branch <name> | --list | --use <name> | --edit <proposal>');
94
- return create(ctx, positionals[0]);
95
- }