agjan 0.0.14 → 0.0.16

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 CHANGED
@@ -7,8 +7,9 @@
7
7
 
8
8
  # agjan
9
9
 
10
- Spec-driven workflow kit for AI coding agents, with human approval gates and a
11
- read-only reviewer at every step.
10
+ An agentic engineering harness. It runs AI coding agents like an engineering team (a
11
+ main agent, an independent reviewer and a QA tester) under your approval gates and
12
+ checks that CI enforces. Spec-driven, starting with SAP BTP: CAP, Fiori elements and UI5.
12
13
 
13
14
  > **Status: closed beta (0.x).** The source repository is not public yet; it will open
14
15
  > soon. Until then, links to the repository and to other documents do not work on npm;
@@ -54,7 +55,7 @@ Linux, macOS or Windows.
54
55
  npm install --global agjan
55
56
  agjan init my-project --hosts claude-code,copilot # or "agjan init ." in an existing folder
56
57
  cd my-project
57
- agjan doctor
58
+ npx agjan doctor
58
59
  ```
59
60
 
60
61
  `agjan init my-project` creates the folder, the git repository (branch `main`) and a
package/dist/cli.js CHANGED
@@ -49,18 +49,21 @@ const COMMANDS = {
49
49
  };
50
50
  const HELP = `agjan ${pkg.version}
51
51
 
52
- Spec-driven workflow kit for AI coding agents, with human approval gates
53
- and a read-only reviewer at every step. Closed beta (0.x); the user guide is\nin this package: docs/guide.md
52
+ Agentic engineering harness for AI coding agents: role agents (main agent,
53
+ reviewer, QA), human approval gates and CI-enforced checks. SAP BTP first.
54
+ Closed beta (0.x); the user guide is in this package: docs/guide.md
54
55
 
55
56
  Usage: agjan <command> [options]
56
57
 
57
58
  Setup (human):
58
59
  init <folder | .> [--hosts claude-code,copilot] [--domains btp] [--base <ref>]
59
60
  [--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
60
- [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
61
+ [--commit | --no-commit] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
61
62
  set up agjan: <folder> is created (git init, package.json,
62
63
  agjan pinned and installed), . is the current folder; without
63
- --hosts it asks which hosts (claude-code, copilot) to set up
64
+ --hosts it asks which hosts (claude-code, copilot) to set up,
65
+ and at the end whether to commit the setup (a new repository:
66
+ on main; else on chore/set-up-agjan)
64
67
  sync [--force] [--copilot-mcp]
65
68
  regenerate managed files (skills, agents, blocks, settings);
66
69
  --copilot-mcp adds missing MCP servers to Copilot
@@ -112,6 +115,8 @@ Human only, in a terminal:
112
115
  approve spec | design | spec design | verify | amendment <id>
113
116
  accept <finding-id> --reason "<why>"
114
117
  reject spec|design --reason "<why>"
118
+ auto status [--feature <s>] show the real auto mode settings: your default for new
119
+ features and every existing feature
115
120
  auto on|off [--default] auto mode for one feature (--default: every new feature in this
116
121
  checkout): spec and design are approved automatically once
117
122
  their reviews pass (approve verify stays yours)
@@ -3,10 +3,10 @@ import { join, relative } from 'node:path';
3
3
  import { parseArgs } from 'node:util';
4
4
  import { writeJson } from '../json-file.js';
5
5
  import { appendLog, readLog } from '../log.js';
6
- import { APPROVALS_FILE, FEATURES_DIR, gateReview, loadFeature, selectFeature } from '../feature.js';
6
+ import { APPROVALS_FILE, FEATURES_DIR, changedFeatures, gateReview, listFeatures, loadFeature, selectFeature } from '../feature.js';
7
7
  import { documentProblems, designProblems } from '../validate.js';
8
8
  import { AgjanError, UsageError } from '../errors.js';
9
- import { blink, mark, tone } from '../ui.js';
9
+ import { blink, mark, markLine, pad, tone } from '../ui.js';
10
10
  import { git } from '../git.js';
11
11
  import { acceptanceState, verifyState } from '../progress.js';
12
12
  import { NOT_ACCEPTED, runChecks } from './check.js';
@@ -315,6 +315,39 @@ export function approve(ctx, argv) {
315
315
  return approveAmendment(ctx, feature, positionals[1], values);
316
316
  throw new UsageError('usage: agjan approve spec | design | spec design | verify | amendment <id> [--feature <slug>] [--no-commit]');
317
317
  }
318
+ /**
319
+ * agjan auto status [--feature <slug>]: the real settings, read-only: your default for new
320
+ * features, and the auto mode of every existing feature (or the named one).
321
+ */
322
+ function autoStatus(ctx, values) {
323
+ for (const line of markLine(ctx.style, ctx.kit, 'auto mode'))
324
+ ctx.out(line);
325
+ printAutoSettings(ctx, values.feature);
326
+ return 0;
327
+ }
328
+ /** The real settings: your default for new features, then the mode of every feature (or one). */
329
+ function printAutoSettings(ctx, only) {
330
+ const s = ctx.style;
331
+ const root = ctx.root;
332
+ const features = listFeatures(root).map((slug) => loadFeature(root, slug)).filter((f) => f.kind === 'feature');
333
+ const shown = only ? features.filter((f) => f.slug === only) : features;
334
+ if (only && shown.length === 0)
335
+ throw new UsageError(`no feature '${only}'`);
336
+ const here = new Set(changedFeatures(root, ctx.config));
337
+ const state = (on) => (on ? s.yellow('on') : s.gray('off'));
338
+ const standing = readAutoDefault(root);
339
+ ctx.out('', s.bold('Default for new features'), ` ${pad(state(Boolean(standing)), standing ? 'on' : 'off', 5)}${s.gray(standing ? `since ${standing.at_utc}, by ${standing.by} (this checkout only)` : 'new features wait at their gates')}`);
340
+ ctx.out('', s.bold('Features'));
341
+ if (shown.length === 0)
342
+ ctx.out(` ${s.gray('none yet')}`);
343
+ const width = Math.max(0, ...shown.map((f) => f.slug.length)) + 2;
344
+ for (const feature of shown) {
345
+ const mode = feature.approvals.auto;
346
+ const detail = mode ? `since ${mode.at_utc}, by ${mode.by}${mode.from === 'default' ? ', from the default' : ''}` : 'waits at its gates';
347
+ const branch = here.has(feature.slug) ? s.teal(' ◂ this branch') : '';
348
+ ctx.out(` ${pad(feature.slug, feature.slug, width)}${pad(state(Boolean(mode)), mode ? 'on' : 'off', 5)}${s.gray(detail)}${branch}`);
349
+ }
350
+ }
318
351
  /**
319
352
  * agjan auto on|off --default: the person's default for this checkout (decision 79). Every
320
353
  * feature created here afterwards starts with auto mode on; existing features keep theirs.
@@ -352,12 +385,13 @@ async function autoDefault(ctx, on) {
352
385
  }
353
386
  if (on) {
354
387
  writeAutoDefault(ctx.root, { by: ctx.email(), at_utc: ctx.now() });
355
- ctx.out(s.green('auto mode on for every new feature in this checkout'));
388
+ ctx.out(s.green('auto mode on for every new feature in this checkout'), s.gray('(features that already exist keep their mode)'));
356
389
  }
357
390
  else {
358
391
  removeAutoDefault(ctx.root);
359
- ctx.out('auto mode default off: new features wait at their gates again');
392
+ ctx.out('auto mode default off: new features wait at their gates again', s.gray('(features that already exist keep their mode)'));
360
393
  }
394
+ printAutoSettings(ctx);
361
395
  return 0;
362
396
  }
363
397
  /**
@@ -370,7 +404,9 @@ async function autoDefault(ctx, on) {
370
404
  export async function auto(ctx, argv) {
371
405
  const { values, positionals } = parseArgs({ args: argv, options: { ...FEATURE_OPTION, default: { type: 'boolean' } }, allowPositionals: true });
372
406
  const [what] = positionals;
373
- const usage = 'usage: agjan auto on|off [--feature <slug>] [--no-commit] | agjan auto on|off --default';
407
+ const usage = 'usage: agjan auto on|off [--feature <slug>] [--no-commit] | agjan auto on|off --default | agjan auto status [--feature <slug>]';
408
+ if (what === 'status' && positionals.length === 1 && !values.default)
409
+ return autoStatus(ctx, values);
374
410
  if (!['on', 'off'].includes(what) || positionals.length !== 1)
375
411
  throw new UsageError(usage);
376
412
  if (values.default) {
@@ -385,10 +421,18 @@ export async function auto(ctx, argv) {
385
421
  catch (error) {
386
422
  if (!(error instanceof UsageError))
387
423
  throw error;
388
- // No single feature to act on: name both ways, the feature and the default.
389
- throw new UsageError(`${error.message.replace(/; pass --feature <slug>$/, '')}.\n` +
390
- ` every new feature in this checkout: npx agjan auto ${what} --default\n` +
391
- ` one feature: npx agjan auto ${what} --feature <slug>, or run it on the feature's branch after /agjan-spec has created it`);
424
+ // No single feature to act on: say why, and name both ways (the default, one feature).
425
+ const s = ctx.style;
426
+ const cmd = (rest) => s.cyan(`npx agjan auto ${what}${rest}`);
427
+ const several = /^several features changed \((.*?)\)/.exec(error.message);
428
+ throw new UsageError(`there is no single feature to switch auto mode ${what} for: ${several ? `this branch changes several (${several[1]})` : 'this branch has none yet'}.\n` +
429
+ 'Auto mode belongs to a feature, so choose:\n\n' +
430
+ ` ${s.bold('For every feature you start from now on')} (this checkout only):\n` +
431
+ ` ${cmd(' --default')}\n\n` +
432
+ ` ${s.bold('For one existing feature:')}\n` +
433
+ ` ${cmd(' --feature <slug>')}\n` +
434
+ ` or switch to the feature's branch and run ${cmd('')}\n` +
435
+ ` ${s.gray('(npx agjan status --all lists the features; /agjan-spec creates a new one)')}`);
392
436
  }
393
437
  const feature = loadFeature(ctx.root, slug);
394
438
  if (feature.kind !== 'feature')
@@ -408,8 +452,9 @@ export async function auto(ctx, argv) {
408
452
  return 1;
409
453
  feature.approvals.auto = { by: ctx.email(), at_utc: ctx.now() };
410
454
  save(ctx, feature, 'auto-on', {});
411
- ctx.out(ctx.style.green(`auto mode on for ${feature.slug}`));
455
+ ctx.out(ctx.style.green(`auto mode on for ${feature.slug}`), ctx.style.gray('(your default for new features is unchanged)'));
412
456
  await commitRecord(ctx, feature, values, `${feature.key}: auto mode on`);
457
+ printAutoSettings(ctx);
413
458
  return 0;
414
459
  }
415
460
  if (!current)
@@ -420,6 +465,7 @@ export async function auto(ctx, argv) {
420
465
  save(ctx, feature, 'auto-off', {});
421
466
  ctx.out(`auto mode off for ${feature.slug}; the gates wait for you again`);
422
467
  await commitRecord(ctx, feature, values, `${feature.key}: auto mode off`);
468
+ printAutoSettings(ctx);
423
469
  return 0;
424
470
  }
425
471
  /** agjan accept <finding-id> --reason "…" [--feature <slug>] [--no-commit] */
@@ -25,8 +25,12 @@ export function copilotModels() {
25
25
  const AGENTS = {
26
26
  balanced: { agent: 'agjan-reviewer', label: 'reviewer' },
27
27
  deep: { agent: 'agjan-reviewer-deep', label: 'deep reviewer' },
28
- qa: { agent: 'agjan-qa', label: 'QA' },
28
+ qa: { agent: 'agjan-qa', label: 'QA agent' },
29
29
  };
30
+ /** Whether the QA agent has no model of its own on `host`, so it runs on the deep tier's (decision 81). */
31
+ function followsDeep(config, host, tier) {
32
+ return tier === 'qa' && !config.models?.[host]?.qa;
33
+ }
30
34
  /** The steps a tier runs, from the step tiers (`review.tiers` over the defaults). */
31
35
  function stepsOf(config, tier) {
32
36
  if (tier === 'qa')
@@ -63,25 +67,31 @@ function show(ctx) {
63
67
  const config = ctx.config;
64
68
  for (const line of markLine(s, ctx.kit, 'models'))
65
69
  ctx.out(line);
70
+ ctx.out('', s.gray('A tier is the model setting of one agent: balanced and deep are the reviewers, qa is the tester.'));
66
71
  for (const host of config.hosts) {
67
72
  ctx.out('', s.bold(host));
73
+ const head = (text, width) => pad(s.gray(text), text, width);
74
+ // As wide as the longest model name here: real names (claude-sonnet-5.5) outgrow a fixed column.
75
+ const modelWidth = Math.max(13, ...AGENT_TIERS.map((t) => (agentModel(config, host, t) ?? '').length)) + 2;
76
+ ctx.out(` ${head('TIER', 10)}${head('AGENT', 21)}${head('MODEL', modelWidth)}${s.gray('RUNS')}`);
68
77
  for (const tier of AGENT_TIERS) {
69
78
  const { agent, label } = AGENTS[tier];
70
79
  const model = agentModel(config, host, tier);
71
80
  const shown = model ? s.cyan(model) : s.gray('session model');
72
81
  const plain = model ?? 'session model';
73
- const follows = tier === 'qa' && !config.models?.[host]?.qa ? s.gray(' (follows the deep reviewer)') : '';
74
- ctx.out(` ${pad(label, label, 15)}${pad(s.gray(agent), agent, 21)}${pad(shown, plain, 19)}${s.gray(stepsOf(config, tier))}${follows}`);
82
+ const follows = followsDeep(config, host, tier) ? s.gray(' (follows the deep tier)') : '';
83
+ ctx.out(` ${pad(s.bold(tier), tier, 10)}${pad(s.gray(agent), agent, 21)}${pad(shown, plain, modelWidth)}${s.gray(stepsOf(config, tier))}${follows}`);
75
84
  }
76
85
  }
77
86
  ctx.out('', s.bold('Change, in your terminal:'));
78
87
  const change = [
79
- ['npx agjan models set deep <model>', 'tip: another model family than the main agent finds other things'],
80
- ['npx agjan models set qa <model>', 'QA gets its own model'],
81
- [`npx agjan models set <tier> ${SESSION_MODEL}`, "back to the session's model"],
88
+ ['npx agjan models set balanced <model>', 'the reviewer: most review steps'],
89
+ ['npx agjan models set deep <model>', 'the deep reviewer; tip: another model family than the main agent'],
90
+ ['npx agjan models set qa <model>', 'QA gets its own model (else it follows the deep reviewer)'],
91
+ [`npx agjan models set <tier> ${SESSION_MODEL}`, `back to the session's model (tiers: ${AGENT_TIERS.join(', ')})`],
82
92
  ];
83
93
  for (const [command, why] of change)
84
- ctx.out(` ${pad(s.cyan(command), command, 38)}${s.gray(why)}`);
94
+ ctx.out(` ${pad(s.cyan(command), command, 40)}${s.gray(why)}`);
85
95
  if (config.hosts.length > 1)
86
96
  ctx.out(s.gray(' add --host <host> for one host only'));
87
97
  if (config.hosts.includes('copilot')) {
@@ -115,9 +125,14 @@ function set(ctx, tier, model, host) {
115
125
  if (models && !models.includes(model))
116
126
  throw new AgjanError(`GitHub Copilot does not offer '${model}'; its models: ${models.join(', ')}`);
117
127
  }
118
- const answer = ctx.ask(`Let the ${tier} reviewer run on ${model === SESSION_MODEL ? "the session's model" : model} (${hosts.join(', ')})?`, { defaultYes: true });
128
+ const { agent, label } = AGENTS[tier];
129
+ const following = tier === 'deep' ? hosts.filter((h) => followsDeep(config, h, 'qa')) : [];
130
+ if (following.length) {
131
+ ctx.out(ctx.style.gray(`The QA agent has no model of its own${config.hosts.length > 1 ? ` (${following.join(', ')})` : ''} and follows the deep tier, so it moves too.`), ctx.style.gray(`Give it one with: npx agjan models set qa <model>`));
132
+ }
133
+ const answer = ctx.ask(`Let the ${label} (tier ${tier}, ${agent}) run on ${model === SESSION_MODEL ? "the session's model" : model} (${hosts.join(', ')})?`, { defaultYes: true });
119
134
  if (answer === null)
120
- throw new AgjanError('choosing the reviewer model needs a human at a terminal; agents must not run it. Run it yourself in a terminal.');
135
+ throw new AgjanError('choosing a model needs a human at a terminal; agents must not run it. Run it yourself in a terminal.');
121
136
  if (!answer) {
122
137
  ctx.out(ctx.style.yellow('cancelled, nothing changed'));
123
138
  return 1;
@@ -1,5 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { basename, dirname, join, relative, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
@@ -16,7 +16,7 @@ import { GUARD } from '../adapters/copilot.js';
16
16
  import { git, mergeBase, resolveBase } from '../git.js';
17
17
  import { AgjanError, UsageError } from '../errors.js';
18
18
  import { blink, mark, pad, tone, verdictColor } from '../ui.js';
19
- import { mcpServers } from '../mcp-config.js';
19
+ import { PINNED, mcpServers } from '../mcp-config.js';
20
20
  import { addCommand, addCopilotServers, copilotServers } from '../copilot-mcp.js';
21
21
  import { UI_SCRIPT, hasUiTests, probeBrowser } from '../browser.js';
22
22
  import { readAutoDefault } from '../auto.js';
@@ -81,14 +81,41 @@ function doSync(ctx, { force }) {
81
81
  function ask(ctx, question, options) {
82
82
  return ctx.ask(question, options);
83
83
  }
84
- /** The next steps after init, for the configured hosts (design decision 69). */
85
- function nextSteps(ctx, hosts, firstCommit) {
84
+ /** The offer to add the documentation servers to Copilot: why, and what, as a short list. */
85
+ function copilotMcpOffer(ctx, servers) {
86
86
  const s = ctx.style;
87
- const steps = [
88
- firstCommit
89
- ? `Commit the setup: ${s.cyan('git add -A && git commit -m "chore: set up agjan"')}`
90
- : `Commit the setup on a branch of its own and merge it with a PR: ${s.cyan('git add -A && git commit -m "chore: set up agjan"')}`,
87
+ const names = Object.keys(servers);
88
+ const width = Math.max(...names.map((n) => n.length));
89
+ const packages = names.map((n) => servers[n].args.at(-1) ?? '');
90
+ const wide = Math.max(...packages.map((p) => p.length));
91
+ return [
92
+ '',
93
+ s.bold('Documentation MCP servers for Copilot'),
94
+ s.gray(" Copilot reads a project's .mcp.json only in folders it remembers as trusted."),
95
+ s.gray(' Added with copilot mcp add, they load in every Copilot session.'),
96
+ '',
97
+ ...names.map((n, i) => ` ${pad(s.bold(s.teal(n)), n, width + 2)}${pad(s.gray(packages[i]), packages[i], wide + 2)}${PINNED[n]?.about ?? ''}`),
98
+ '',
91
99
  ];
100
+ }
101
+ const SETUP_BRANCH = 'chore/set-up-agjan';
102
+ const SETUP_COMMIT = 'chore: set up agjan';
103
+ /** The next steps after init, for the configured hosts (design decision 69). */
104
+ function nextSteps(ctx, hosts, left) {
105
+ const s = ctx.style;
106
+ const steps = [];
107
+ if (left.cd)
108
+ steps.push(`Move into the project: ${s.cyan(`cd ${/\s/.test(left.cd) ? JSON.stringify(left.cd) : left.cd}`)}`);
109
+ if (left.install)
110
+ steps.push(`Install the pinned agjan: ${s.cyan(left.install)}`);
111
+ if (left.committed?.created) {
112
+ steps.push(`The setup is committed on ${s.cyan(left.committed.branch)}: push it and merge it with a PR.`);
113
+ }
114
+ else if (!left.committed) {
115
+ steps.push(left.firstCommit
116
+ ? `Commit the setup: ${s.cyan(`git add -A && git commit -m "${SETUP_COMMIT}"`)}`
117
+ : `Commit the setup on a branch of its own and merge it with a PR: ${s.cyan(`git switch -c ${SETUP_BRANCH} && git add -A && git commit -m "${SETUP_COMMIT}"`)}`);
118
+ }
92
119
  if (hosts.includes('claude-code')) {
93
120
  steps.push("Open this folder once in Claude Code and trust it: the reviewer's agjan tools load only in trusted folders.");
94
121
  }
@@ -98,6 +125,22 @@ function nextSteps(ctx, hosts, firstCommit) {
98
125
  steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
99
126
  return ['', s.bold('Next steps:'), ...steps.map((text, i) => ` ${i + 1}. ${text}`)];
100
127
  }
128
+ /**
129
+ * Commits everything init wrote: on the current branch of a new repository, else on a
130
+ * branch of its own (the base branch changes through a PR). Returns the branch, or why not.
131
+ */
132
+ function commitSetup(root, { firstCommit }) {
133
+ try {
134
+ if (!firstCommit)
135
+ git(root, ['switch', '-q', '-c', SETUP_BRANCH]);
136
+ git(root, ['add', '-A']);
137
+ git(root, ['commit', '-q', '-m', SETUP_COMMIT]);
138
+ return { branch: git(root, ['branch', '--show-current']).trim(), created: !firstCommit };
139
+ }
140
+ catch (error) {
141
+ return { error: error.message };
142
+ }
143
+ }
101
144
  const INIT_USAGE = [
102
145
  'Usage: agjan init <folder | .> --hosts <host,...> [options]',
103
146
  '',
@@ -107,6 +150,7 @@ const INIT_USAGE = [
107
150
  ' --hosts <host,...> claude-code, copilot (asked for on a terminal when left out)',
108
151
  ' --domains btp --language en --base <ref> --no-hook --no-ci --prepare',
109
152
  ' --copilot-mcp | --no-copilot-mcp',
153
+ ' --commit | --no-commit commit the setup (a new repository: on main; else on chore/set-up-agjan) or leave it to you',
110
154
  ' --no-install pin agjan in package.json but do not install it',
111
155
  ` --pm <${PACKAGE_MANAGERS.join('|')}> the package manager to install with (default: from the lockfile, else npm)`,
112
156
  ' --dry-run show what would be done and stop',
@@ -128,7 +172,10 @@ function planScaffold(ctx, target) {
128
172
  if (top && realpathSync(top) !== join(realpathSync(ancestor), relative(ancestor, target))) {
129
173
  throw new AgjanError(`${target} is inside the git repository ${top}; agjan is set up at the root of a repository (run 'agjan init .' there)`);
130
174
  }
131
- return { exists, repo: Boolean(top), packageJson: exists && existsSync(join(target, 'package.json')) };
175
+ // Only a start without other work in it may be committed as a whole: a new folder, an
176
+ // empty one, or a repository whose working tree is clean.
177
+ const clean = !exists || (top ? git(target, ['status', '--porcelain']).trim() === '' : readdirSync(target).length === 0);
178
+ return { exists, repo: Boolean(top), packageJson: exists && existsSync(join(target, 'package.json')), clean };
132
179
  }
133
180
  /** A valid package name for a folder name. */
134
181
  function packageName(folder) {
@@ -174,7 +221,7 @@ function scaffold(ctx, target, found, { install, manager }) {
174
221
  /**
175
222
  * agjan init <folder | .> --hosts claude-code,copilot [--domains btp] [--language en] [--base <ref>]
176
223
  * [--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
177
- * [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
224
+ * [--commit | --no-commit] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
178
225
  */
179
226
  export async function init(ctx, argv) {
180
227
  const { values, positionals } = parseArgs({
@@ -190,6 +237,8 @@ export async function init(ctx, argv) {
190
237
  prepare: { type: 'boolean' },
191
238
  'copilot-mcp': { type: 'boolean' },
192
239
  'no-copilot-mcp': { type: 'boolean' },
240
+ commit: { type: 'boolean' },
241
+ 'no-commit': { type: 'boolean' },
193
242
  'no-install': { type: 'boolean' },
194
243
  pm: { type: 'string' },
195
244
  'dry-run': { type: 'boolean' },
@@ -202,6 +251,8 @@ export async function init(ctx, argv) {
202
251
  if (positionals.length > 1)
203
252
  throw new UsageError(`init takes one folder, got ${positionals.length}: ${positionals.join(' ')}`);
204
253
  const target = resolve(ctx.cwd, positionals[0]);
254
+ if (values.commit && values['no-commit'])
255
+ throw new UsageError('--commit and --no-commit exclude each other');
205
256
  if (values.pm && !PACKAGE_MANAGERS.includes(values.pm))
206
257
  throw new UsageError(`--pm must be one of ${PACKAGE_MANAGERS.join(', ')}`);
207
258
  const found = planScaffold(ctx, target);
@@ -224,9 +275,10 @@ export async function init(ctx, argv) {
224
275
  for (const line of lines)
225
276
  ctx.out(line);
226
277
  await blink(ctx, lines);
227
- const hosts = chosen ?? ctx.select('Which hosts should agjan set up?', supported.map((id) => ({ id, label: id })));
278
+ const hosts = chosen ?? await ctx.select('Which hosts should agjan set up?', supported.map((id) => ({ id, label: id })));
228
279
  if (!hosts)
229
280
  throw new UsageError(`no host chosen and no terminal to ask on; pass --hosts <host,...> (supported: ${supported.join(', ')})`);
281
+ const origin = ctx.cwd;
230
282
  ctx.out('');
231
283
  scaffold(ctx, target, found, { install: !values['no-install'], manager });
232
284
  ctx.chdir(target);
@@ -239,9 +291,9 @@ export async function init(ctx, argv) {
239
291
  const resolved = { id: `${d}:${a}`, domain: d, name: a, role: area.role };
240
292
  return [[a, resolved], [`${d}:${a}`, resolved]];
241
293
  })));
242
- const servers = Object.keys(mcpServers({ areas }).servers);
243
- const copilotMcp = hosts.includes('copilot') && servers.length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
244
- ask(ctx, `Add the documentation MCP servers ${servers.join(', ')} to your Copilot configuration (copilot mcp add)?\n(Copilot loads a project's .mcp.json only in folders it remembers as trusted; these then load in every Copilot session.)`, { defaultYes: true }) ?? false);
294
+ const offered = mcpServers({ areas }).servers;
295
+ const copilotMcp = hosts.includes('copilot') && Object.keys(offered).length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
296
+ (ctx.out(...copilotMcpOffer(ctx, offered)), ask(ctx, 'Add them to your Copilot configuration?', { defaultYes: true })) ?? false);
245
297
  const config = {
246
298
  $schema: './node_modules/agjan/schemas/config.schema.json',
247
299
  kit: ctx.kit,
@@ -274,7 +326,36 @@ export async function init(ctx, argv) {
274
326
  }
275
327
  }
276
328
  const firstCommit = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) === null;
277
- ctx.out(...nextSteps(ctx, hosts, firstCommit));
329
+ // Asked once everything is written. Not when other work is in the folder (git add -A would
330
+ // sweep it in), unless --commit says so.
331
+ let committed = null;
332
+ // The pre-commit hook runs the project's agjan: without the install, committing would hang on it.
333
+ const hookNeedsInstall = values['no-install'] && !values['no-hook'];
334
+ const wanted = values['no-commit'] || hookNeedsInstall ? false : values.commit ? true : !found.clean ? false
335
+ : ask(ctx, firstCommit ? `Commit the setup now (${SETUP_COMMIT})?` : `Commit the setup on a new branch, ${SETUP_BRANCH}?`, { defaultYes: true }) ?? false;
336
+ if (hookNeedsInstall && !values['no-commit']) {
337
+ ctx.out('', s.yellow(`The setup is not committed: the pre-commit hook needs the installed agjan (${manager} install, then commit).`));
338
+ }
339
+ else if (!found.clean && !values.commit && !values['no-commit']) {
340
+ ctx.out('', s.yellow('The folder had other work in it, so the setup is not committed for you; commit what belongs to it yourself.'));
341
+ }
342
+ if (wanted) {
343
+ const result = commitSetup(root, { firstCommit });
344
+ if ('error' in result) {
345
+ ctx.out('', s.yellow(`Could not commit the setup: ${result.error}`));
346
+ }
347
+ else {
348
+ committed = result;
349
+ ctx.out('', ` ${pad(tone(s, 'created'), 'created', 14)} commit "${SETUP_COMMIT}" on ${result.branch}`);
350
+ }
351
+ }
352
+ const cd = relative(origin, target);
353
+ ctx.out(...nextSteps(ctx, hosts, {
354
+ cd: cd && cd !== '.' ? cd : null,
355
+ install: values['no-install'] ? `${manager} install` : null,
356
+ committed,
357
+ firstCommit,
358
+ }));
278
359
  return 0;
279
360
  }
280
361
  function addPrepare(root) {
package/dist/select.js ADDED
@@ -0,0 +1,54 @@
1
+ export function initialSelect(count) {
2
+ return { cursor: 0, picked: Array(count).fill(false), warn: false };
3
+ }
4
+ /** The key a chunk of terminal input stands for: arrows and k/j move, space ticks, `a` ticks all. */
5
+ export function keysOf(chunk) {
6
+ const keys = [];
7
+ for (const token of chunk.match(/\x1b\[[0-9;]*[A-Za-z]|\x1bO[A-Z]|\x1b|[\s\S]/g) ?? []) {
8
+ const key = {
9
+ '\x1b[A': 'up', '\x1bOA': 'up', k: 'up',
10
+ '\x1b[B': 'down', '\x1bOB': 'down', j: 'down',
11
+ ' ': 'toggle', a: 'all',
12
+ '\r': 'enter', '\n': 'enter',
13
+ '\x03': 'cancel', '\x04': 'cancel', '\x1b': 'cancel', q: 'cancel',
14
+ }[token];
15
+ if (key)
16
+ keys.push(key);
17
+ }
18
+ return keys;
19
+ }
20
+ /** The state after a key; `done` when Enter confirmed a choice or the human cancelled. */
21
+ export function reduceSelect(state, key) {
22
+ const count = state.picked.length;
23
+ switch (key) {
24
+ case 'up':
25
+ return { state: { ...state, cursor: (state.cursor + count - 1) % count, warn: false } };
26
+ case 'down':
27
+ return { state: { ...state, cursor: (state.cursor + 1) % count, warn: false } };
28
+ case 'toggle':
29
+ return { state: { ...state, picked: state.picked.map((p, i) => (i === state.cursor ? !p : p)), warn: false } };
30
+ case 'all':
31
+ return { state: { ...state, picked: state.picked.map(() => !state.picked.every(Boolean)), warn: false } };
32
+ case 'enter':
33
+ return state.picked.some(Boolean) ? { state, done: 'confirm' } : { state: { ...state, warn: true } };
34
+ case 'cancel':
35
+ return { state, done: 'cancel' };
36
+ }
37
+ }
38
+ /** The lines of the picker: the question, one line per choice, and a hint (or the refusal). */
39
+ export function renderSelect(s, question, choices, state) {
40
+ const rows = choices.map((choice, i) => {
41
+ const here = i === state.cursor;
42
+ const box = state.picked[i] ? s.green('◉') : s.gray('◯');
43
+ const label = here ? s.bold(s.teal(choice.label)) : state.picked[i] ? s.green(choice.label) : choice.label;
44
+ return `${here ? s.teal('❯') : ' '} ${box} ${label}`;
45
+ });
46
+ const hint = state.warn
47
+ ? s.red('Select at least one host with space, then press enter.')
48
+ : s.gray('↑/↓ move · space select · a all · enter confirm · esc cancel');
49
+ return [`${s.teal('?')} ${s.bold(question)}`, ...rows, ` ${hint}`];
50
+ }
51
+ /** The one line left on the terminal once the human confirmed. */
52
+ export function renderChosen(s, question, chosen) {
53
+ return `${s.green('✔')} ${s.bold(question)} ${s.teal(chosen.join(', '))}`;
54
+ }
package/dist/terminal.js CHANGED
@@ -2,6 +2,8 @@ import { openSync, readSync, writeSync, closeSync } from 'node:fs';
2
2
  import { createInterface } from 'node:readline';
3
3
  import { ReadStream, WriteStream, isatty } from 'node:tty';
4
4
  import { AgjanError } from './errors.js';
5
+ import { initialSelect, keysOf, reduceSelect, renderChosen, renderSelect } from './select.js';
6
+ import { createStyle } from './ui.js';
5
7
  /**
6
8
  * Opens the controlling terminal, bypassing stdin and stdout, so that piped input
7
9
  * cannot answer a confirmation (design 9.4). Returns null when there is none, which is
@@ -82,32 +84,82 @@ export function askOnTerminal(question, { defaultYes = false } = {}) {
82
84
  }
83
85
  }
84
86
  /**
85
- * Lists `choices` on the controlling terminal and asks for one or more of them, by number
86
- * or name, separated by commas. Asks again on input it does not understand; an empty
87
- * answer selects nothing. Returns null when there is no terminal (a script, CI or an
88
- * agent): the caller then needs the choice from a flag.
87
+ * Asks the human to choose among `choices` on the controlling terminal: with the cursor
88
+ * keys, space and Enter where the terminal allows, else by typing numbers or names
89
+ * separated by commas. Returns null when there is no terminal (a script, CI or an
90
+ * agent): the caller then needs the choice from a flag. Cancelling is an error.
89
91
  */
90
- export function selectOnTerminal(question, choices) {
92
+ export async function selectOnTerminal(question, choices) {
91
93
  const tty = openTerminal();
92
94
  if (!tty)
93
95
  return null;
96
+ const style = createStyle({ isTTY: true });
97
+ if (!isatty(tty.input)) {
98
+ try {
99
+ return typeSelection(tty, style, question, choices);
100
+ }
101
+ finally {
102
+ closeSync(tty.input);
103
+ if (tty.output !== tty.input)
104
+ closeSync(tty.output);
105
+ }
106
+ }
107
+ const input = new ReadStream(tty.input);
108
+ const write = (text) => writeSync(tty.output, text);
109
+ let state = initialSelect(choices.length);
110
+ let lines = 0;
111
+ // Draws the picker over its previous drawing.
112
+ const draw = () => {
113
+ const frame = renderSelect(style, question, choices, state);
114
+ write(`${lines ? `\x1b[${lines - 1}A\r` : ''}${frame.map((l) => `\x1b[2K${l}`).join('\n')}`);
115
+ lines = frame.length;
116
+ };
117
+ const leave = (result) => {
118
+ write(`${lines > 1 ? `\x1b[${lines - 1}A` : ''}\r\x1b[J${result}\x1b[?25h`);
119
+ };
94
120
  try {
95
- writeSync(tty.output, `${question}\n${choices.map((c, i) => ` ${i + 1}. ${c.label}`).join('\n')}\n`);
96
- for (;;) {
97
- writeSync(tty.output, 'Choose one or more (numbers or names, separated by commas): ');
98
- const answer = readLine(tty.input).trim();
99
- const picked = answer.split(',').map((a) => a.trim()).filter(Boolean).map((a) => choices[Number(a) - 1]?.id ?? choices.find((c) => c.id === a)?.id);
100
- if (picked.length && picked.every(Boolean))
101
- return [...new Set(picked)];
102
- writeSync(tty.output, `Not understood: ${answer === '' ? '(nothing)' : answer}\n`);
121
+ input.setRawMode(true);
122
+ write('\x1b[?25l');
123
+ draw();
124
+ const done = await new Promise((resolve) => {
125
+ input.on('data', (chunk) => {
126
+ for (const key of keysOf(chunk.toString('utf8'))) {
127
+ const next = reduceSelect(state, key);
128
+ state = next.state;
129
+ if (next.done)
130
+ return resolve(next.done);
131
+ }
132
+ draw();
133
+ });
134
+ input.on('end', () => resolve('cancel'));
135
+ });
136
+ if (done === 'cancel') {
137
+ leave(`${style.red('✖')} ${style.bold(question)} ${style.gray('cancelled')}\n`);
138
+ throw new AgjanError('cancelled; nothing was changed');
103
139
  }
140
+ const chosen = choices.filter((_, i) => state.picked[i]).map((c) => c.id);
141
+ leave(`${renderChosen(style, question, chosen)}\n`);
142
+ return chosen;
104
143
  }
105
144
  finally {
106
- closeSync(tty.input);
145
+ write('\x1b[?25h');
146
+ input.destroy();
107
147
  if (tty.output !== tty.input)
108
148
  closeSync(tty.output);
109
149
  }
110
150
  }
151
+ /** The fallback without key input: a numbered list and a typed answer. */
152
+ function typeSelection(tty, s, question, choices) {
153
+ writeSync(tty.output, `${s.teal('?')} ${s.bold(question)}\n${choices.map((c, i) => ` ${s.teal(`${i + 1}.`)} ${c.label}`).join('\n')}\n`);
154
+ for (;;) {
155
+ writeSync(tty.output, `${s.gray('Choose one or more (numbers or names, separated by commas):')} `);
156
+ const answer = readLine(tty.input).trim();
157
+ const picked = answer.split(',').map((a) => a.trim()).filter(Boolean).map((a) => choices[Number(a) - 1]?.id ?? choices.find((c) => c.id === a)?.id);
158
+ if (picked.length && picked.every(Boolean))
159
+ return [...new Set(picked)];
160
+ writeSync(tty.output, `${s.red('Not understood:')} ${answer === '' ? '(nothing)' : answer}\n`);
161
+ }
162
+ }
111
163
  /**
112
164
  * Asks for one line on the controlling terminal with `initial` already typed, so the human
113
165
  * can edit it in place (cursor keys, backspace) or press Enter to keep it. Without line
package/dist/ui.js CHANGED
@@ -93,7 +93,7 @@ export function highlightMarkdown(style, text) {
93
93
  * The agjan mark (the "ag" of the app icon: the bowl of the a with its teal stem, and the
94
94
  * g with its descender) with two lines of text beside it. Empty when the brand is off.
95
95
  */
96
- export function mark(style, version, line2 = 'spec-driven work with AI agents, gated by you', line3 = '') {
96
+ export function mark(style, version, line2 = 'agentic engineering harness, gated by you', line3 = '') {
97
97
  if (!style.brand)
98
98
  return [];
99
99
  const stem = style.teal('┃');
package/docs/guide.md CHANGED
@@ -3,6 +3,11 @@
3
3
  How to set up agjan in a project and work with it. The reasons behind every rule are
4
4
  in the [design](design.md); this guide is about using it.
5
5
 
6
+ agjan is an agentic engineering harness: it runs your AI coding agents like an engineering
7
+ team (a main agent, an independent reviewer and a QA tester), spec-driven, under approval
8
+ gates you hold and checks that CI enforces. It is not an agent or a model; it is the
9
+ structure around the agents you already use (Claude Code, GitHub Copilot).
10
+
6
11
  - [Concepts](#concepts)
7
12
  - [Set up a project](#set-up-a-project)
8
13
  - [The workflow](#the-workflow)
@@ -34,10 +39,9 @@ Requirements: Node.js 22 or later, git, and Claude Code and/or GitHub Copilot.
34
39
 
35
40
  ```sh
36
41
  npm install --global agjan
37
- agjan init my-project --hosts claude-code,copilot # or one of them; without --hosts, init asks
38
- cd my-project
39
- agjan doctor
40
- git add -A && git commit -m "chore: set up agjan"
42
+ agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), then to commit the setup
43
+ cd my-project # a command cannot move your shell: init prints this as its first next step
44
+ npx agjan doctor # from here on, npx runs the project's pinned agjan
41
45
  ```
42
46
 
43
47
  `agjan init <folder>` creates the folder, runs `git init -b main`, writes a `package.json`
@@ -49,12 +53,23 @@ before changing anything when the folder already has an `agjan.config.json`, whe
49
53
  `package.json` is not valid JSON, or when the folder lies inside another git repository.
50
54
  `--dry-run` shows the plan, `--no-install` only pins the version.
51
55
 
56
+ When everything is written, `init` offers to commit the setup (`chore: set up agjan`): on
57
+ `main` in a new repository, on a branch of its own, `chore/set-up-agjan`, in an existing one
58
+ (the base branch changes through a PR). `--commit` and `--no-commit` answer the question.
59
+ Nothing is committed for you when the folder had other work in it (files in a folder that was
60
+ not a repository, or uncommitted changes), nor when `--no-install` leaves the pre-commit hook
61
+ without its agjan; the next steps then say what to run.
62
+
52
63
  The global `agjan` runs `init`, `--help` and `--version` itself. Every other command runs
53
64
  in the agjan the project pins in `node_modules`. If that is not installed (a fresh clone),
54
65
  the command offers to run the install first; without a terminal it fails and says how
55
66
  (`agjan --yes <command>` installs without asking). Without a global install, `npx agjan init
56
67
  <folder>` works the same.
57
68
 
69
+ The global install is for starting projects. Day to day, use `npx agjan <command>` in the
70
+ project: it runs the pinned copy directly and works on every machine, with or without a
71
+ global install. The hooks, the MCP configuration and the skills all call it that way.
72
+
58
73
  `init` writes `agjan.config.json`, the skills (`.claude/skills/`), the reviewer agents,
59
74
  the guardrails against agents running approvals, the MCP configuration, a block in
60
75
  `AGENTS.md` and `CLAUDE.md`, a pre-commit hook and a CI workflow. Your own content in
@@ -147,7 +162,10 @@ decide comes to you as a "Spec question". The tests stay in `test/qa/<feature>/`
147
162
  in `test/ui/qa/<feature>/`) as regression tests; a change to them after QA makes QA run
148
163
  again. The final review, `check --ci` and `approve verify` wait for a passing QA round.
149
164
  QA runs on the deep reviewer's model unless you give it its own:
150
- `npx agjan models set qa <model>`.
165
+ `npx agjan models set qa <model>`. `npx agjan models` shows the three tiers (`balanced` and
166
+ `deep` are the reviewers `agjan-reviewer` and `agjan-reviewer-deep`, `qa` is `agjan-qa`), the
167
+ model each runs on and the steps it covers; `qa` is marked "follows the deep tier" while it has
168
+ no model of its own, and `models set deep` tells you when QA moves with it.
151
169
 
152
170
  The completion block gives you the last gate:
153
171
 
@@ -195,8 +213,15 @@ npx agjan auto on # this feature; asks you to type its key
195
213
  npx agjan auto off # this feature's gates wait for you again
196
214
  npx agjan auto on --default # every feature you create in this checkout from now on
197
215
  npx agjan auto off --default # new features wait at their gates again
216
+ npx agjan auto status # what is set: your default, and every existing feature
198
217
  ```
199
218
 
219
+ The two forms do different things. `auto on` switches one existing feature (the one that
220
+ changed on your branch, or `--feature <slug>`). `auto on --default` changes nothing that
221
+ exists; it only makes the features you create afterwards start in auto mode. To have both,
222
+ run both. `auto status` shows the real settings, read-only: your default and the mode of every
223
+ existing feature.
224
+
200
225
  The default is yours only: it lives in `.agjan/auto.json`, which is git-ignored, so
201
226
  teammates' checkouts keep their gates. A feature takes it when it is created (its
202
227
  `approvals.json` records `from: default`); existing features keep their mode, and
@@ -213,7 +238,8 @@ review still stops the gate. You stay in charge of:
213
238
 
214
239
  Every automatic approval is recorded as `by: auto` with your name as the one who switched
215
240
  auto mode on, never as your approval; `status`, the progress pages and the PR summary
216
- show it. Auto mode belongs to one feature: the next one starts with the gates on. Agents
241
+ show it. Auto mode belongs to one feature: the next one starts with the gates on, unless your
242
+ default is on. Agents
217
243
  cannot switch it on: like `approve`, it needs your terminal, and the guard denies it.
218
244
 
219
245
  ### Following the progress
@@ -1,5 +1,5 @@
1
1
  {
2
- "cap": { "package": "@cap-js/mcp-server", "version": "0.0.8", "areas": ["cap"] },
3
- "ui5": { "package": "@ui5/mcp-server", "version": "0.3.2", "areas": ["fiori"] },
4
- "fiori": { "package": "@sap-ux/fiori-mcp-server", "version": "1.15.13", "areas": ["fiori"] }
2
+ "cap": { "package": "@cap-js/mcp-server", "version": "0.0.8", "about": "CAP documentation and model search", "areas": ["cap"] },
3
+ "ui5": { "package": "@ui5/mcp-server", "version": "0.3.2", "about": "UI5 API reference and linting", "areas": ["fiori"] },
4
+ "fiori": { "package": "@sap-ux/fiori-mcp-server", "version": "1.15.13", "about": "Fiori elements app tooling", "areas": ["fiori"] }
5
5
  }
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "agjan",
3
- "version": "0.0.14",
4
- "description": "Spec-driven workflow kit for AI coding agents, with human approval gates and a read-only reviewer at every step.",
3
+ "version": "0.0.16",
4
+ "description": "Agentic engineering harness for AI coding agents: role agents, human approval gates, independent review and CI-enforced checks. SAP BTP first.",
5
5
  "keywords": [
6
+ "agentic-engineering",
7
+ "agent-harness",
6
8
  "ai",
7
9
  "agents",
10
+ "ai-agents",
8
11
  "claude-code",
9
12
  "copilot",
10
13
  "spec-driven",
14
+ "code-review",
11
15
  "workflow",
16
+ "sap",
12
17
  "cap",
13
18
  "fiori",
14
19
  "ui5"