agjan 0.0.15 → 0.0.17

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
@@ -55,7 +55,7 @@ Linux, macOS or Windows.
55
55
  npm install --global agjan
56
56
  agjan init my-project --hosts claude-code,copilot # or "agjan init ." in an existing folder
57
57
  cd my-project
58
- agjan doctor
58
+ npx agjan doctor
59
59
  ```
60
60
 
61
61
  `agjan init my-project` creates the folder, the git repository (branch `main`) and a
package/dist/cli.js CHANGED
@@ -58,11 +58,12 @@ Usage: agjan <command> [options]
58
58
  Setup (human):
59
59
  init <folder | .> [--hosts claude-code,copilot] [--domains btp] [--base <ref>]
60
60
  [--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
61
- [--commit | --no-commit] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
61
+ [--models balanced=<m>,deep=<m>,qa=<m>] [--commit | --no-commit] [--yes] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
62
62
  set up agjan: <folder> is created (git init, package.json,
63
63
  agjan pinned and installed), . is the current folder; without
64
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:
65
+ whether to choose the reviewer models (default no: the session's
66
+ model), and at the end whether to commit the setup (a new repository:
66
67
  on main; else on chore/set-up-agjan)
67
68
  sync [--force] [--copilot-mcp]
68
69
  regenerate managed files (skills, agents, blocks, settings);
@@ -115,6 +116,8 @@ Human only, in a terminal:
115
116
  approve spec | design | spec design | verify | amendment <id>
116
117
  accept <finding-id> --reason "<why>"
117
118
  reject spec|design --reason "<why>"
119
+ auto status [--feature <s>] show the real auto mode settings: your default for new
120
+ features and every existing feature
118
121
  auto on|off [--default] auto mode for one feature (--default: every new feature in this
119
122
  checkout): spec and design are approved automatically once
120
123
  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] */
@@ -58,6 +58,7 @@ export function run(ctx, argv) {
58
58
  ctx.out(`commit the feature's documents (${message || `${feature.key}: approve ${gate} (auto mode)`}), then continue without stopping:`);
59
59
  ctx.out(`your next action is the shell command: cat .claude/skills/${next}/SKILL.md (then follow it).`);
60
60
  ctx.out('A reply without a tool call ends your run: put any note for the user into the same reply as that command.');
61
+ ctx.out(`Do not tell the user to run /${next}: in auto mode you run it, now.`);
61
62
  }
62
63
  }
63
64
  else {
@@ -1,4 +1,3 @@
1
- import { spawnSync } from 'node:child_process';
2
1
  import { join } from 'node:path';
3
2
  import { parseArgs } from 'node:util';
4
3
  import { AGENT_TIERS, CONFIG_FILE, SESSION_MODEL, agentModel } from '../config.js';
@@ -7,26 +6,13 @@ import { AgjanError, UsageError } from '../errors.js';
7
6
  import { markLine, pad } from '../ui.js';
8
7
  import { DEFAULT_TIERS, reviewerFor } from '../review-policy.js';
9
8
  import { sync } from './setup.js';
10
- /**
11
- * The models GitHub Copilot CLI accepts, from `copilot help config` (its `model` setting
12
- * lists them). Null when copilot cannot be run; AGJAN_COPILOT names a stand-in (tests).
13
- */
14
- export function copilotModels() {
15
- const fake = process.env.AGJAN_COPILOT;
16
- const run = fake
17
- ? spawnSync(process.execPath, [fake, 'help', 'config'], { encoding: 'utf8', timeout: 30_000 })
18
- : spawnSync('copilot', ['help', 'config'], { encoding: 'utf8', timeout: 30_000, shell: process.platform === 'win32' });
19
- if (run.error || run.status !== 0)
20
- return null;
21
- const section = /`model`:[^\n]*\n((?:\s+- "[^"]+"\n?)+)/.exec(run.stdout ?? '');
22
- return section ? [...section[1].matchAll(/- "([^"]+)"/g)].map((m) => m[1]) : null;
9
+ import { AGENTS, copilotModels } from '../model-choices.js';
10
+ /** Every agent runs at the effort of the session that starts it (checked on Claude Code and Copilot); agjan sets none. */
11
+ const EFFORT = "session's";
12
+ /** Whether the QA agent has no model of its own on `host`, so it runs on the deep tier's (decision 81). */
13
+ function followsDeep(config, host, tier) {
14
+ return tier === 'qa' && !config.models?.[host]?.qa;
23
15
  }
24
- /** The agent of each tier, and what it does. */
25
- const AGENTS = {
26
- balanced: { agent: 'agjan-reviewer', label: 'reviewer' },
27
- deep: { agent: 'agjan-reviewer-deep', label: 'deep reviewer' },
28
- qa: { agent: 'agjan-qa', label: 'QA' },
29
- };
30
16
  /** The steps a tier runs, from the step tiers (`review.tiers` over the defaults). */
31
17
  function stepsOf(config, tier) {
32
18
  if (tier === 'qa')
@@ -63,25 +49,31 @@ function show(ctx) {
63
49
  const config = ctx.config;
64
50
  for (const line of markLine(s, ctx.kit, 'models'))
65
51
  ctx.out(line);
52
+ ctx.out('', s.gray('A tier is the model setting of one agent: balanced and deep are the reviewers, qa is the tester.'), s.gray("Every agent runs at the effort level of the session that starts it; agjan does not set one."));
66
53
  for (const host of config.hosts) {
67
54
  ctx.out('', s.bold(host));
55
+ const head = (text, width) => pad(s.gray(text), text, width);
56
+ // As wide as the longest model name here: real names (claude-sonnet-5.5) outgrow a fixed column.
57
+ const modelWidth = Math.max(13, ...AGENT_TIERS.map((t) => (agentModel(config, host, t) ?? '').length)) + 2;
58
+ ctx.out(` ${head('TIER', 10)}${head('AGENT', 21)}${head('MODEL', modelWidth)}${head('EFFORT', EFFORT.length + 2)}${s.gray('RUNS')}`);
68
59
  for (const tier of AGENT_TIERS) {
69
60
  const { agent, label } = AGENTS[tier];
70
61
  const model = agentModel(config, host, tier);
71
62
  const shown = model ? s.cyan(model) : s.gray('session model');
72
63
  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}`);
64
+ const follows = followsDeep(config, host, tier) ? s.gray(' (follows the deep tier)') : '';
65
+ ctx.out(` ${pad(s.bold(tier), tier, 10)}${pad(s.gray(agent), agent, 21)}${pad(shown, plain, modelWidth)}${pad(s.gray(EFFORT), EFFORT, EFFORT.length + 2)}${s.gray(stepsOf(config, tier))}${follows}`);
75
66
  }
76
67
  }
77
68
  ctx.out('', s.bold('Change, in your terminal:'));
78
69
  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"],
70
+ ['npx agjan models set balanced <model>', 'the reviewer: most review steps'],
71
+ ['npx agjan models set deep <model>', 'the deep reviewer; tip: another model family than the main agent'],
72
+ ['npx agjan models set qa <model>', 'QA gets its own model (else it follows the deep reviewer)'],
73
+ [`npx agjan models set <tier> ${SESSION_MODEL}`, `back to the session's model (tiers: ${AGENT_TIERS.join(', ')})`],
82
74
  ];
83
75
  for (const [command, why] of change)
84
- ctx.out(` ${pad(s.cyan(command), command, 38)}${s.gray(why)}`);
76
+ ctx.out(` ${pad(s.cyan(command), command, 40)}${s.gray(why)}`);
85
77
  if (config.hosts.length > 1)
86
78
  ctx.out(s.gray(' add --host <host> for one host only'));
87
79
  if (config.hosts.includes('copilot')) {
@@ -115,9 +107,14 @@ function set(ctx, tier, model, host) {
115
107
  if (models && !models.includes(model))
116
108
  throw new AgjanError(`GitHub Copilot does not offer '${model}'; its models: ${models.join(', ')}`);
117
109
  }
118
- const answer = ctx.ask(`Let the ${tier} reviewer run on ${model === SESSION_MODEL ? "the session's model" : model} (${hosts.join(', ')})?`, { defaultYes: true });
110
+ const { agent, label } = AGENTS[tier];
111
+ const following = tier === 'deep' ? hosts.filter((h) => followsDeep(config, h, 'qa')) : [];
112
+ if (following.length) {
113
+ 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>`));
114
+ }
115
+ 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
116
  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.');
117
+ throw new AgjanError('choosing a model needs a human at a terminal; agents must not run it. Run it yourself in a terminal.');
121
118
  if (!answer) {
122
119
  ctx.out(ctx.style.yellow('cancelled, nothing changed'));
123
120
  return 1;
@@ -16,8 +16,9 @@ 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
+ import { AGENTS, FOLLOW, OTHER, copilotModels, hostModels, modelChoices } from '../model-choices.js';
21
22
  import { UI_SCRIPT, hasUiTests, probeBrowser } from '../browser.js';
22
23
  import { readAutoDefault } from '../auto.js';
23
24
  const CI_FILE = '.github/workflows/agjan.yml';
@@ -81,6 +82,95 @@ function doSync(ctx, { force }) {
81
82
  function ask(ctx, question, options) {
82
83
  return ctx.ask(question, options);
83
84
  }
85
+ /** The offer to add the documentation servers to Copilot: why, and what, as a short list. */
86
+ function copilotMcpOffer(ctx, servers) {
87
+ const s = ctx.style;
88
+ const names = Object.keys(servers);
89
+ const width = Math.max(...names.map((n) => n.length));
90
+ const packages = names.map((n) => servers[n].args.at(-1) ?? '');
91
+ const wide = Math.max(...packages.map((p) => p.length));
92
+ return [
93
+ '',
94
+ s.bold('Documentation MCP servers for Copilot'),
95
+ s.gray(" Copilot reads a project's .mcp.json only in folders it remembers as trusted."),
96
+ s.gray(' Added with copilot mcp add, they load in every Copilot session.'),
97
+ '',
98
+ ...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 ?? ''}`),
99
+ '',
100
+ ];
101
+ }
102
+ /** `--models balanced=sonnet,deep=opus`: tier=model pairs, for every chosen host. */
103
+ function parseModels(value, hosts) {
104
+ if (!value)
105
+ return null;
106
+ const out = {};
107
+ for (const pair of value.split(',').map((p) => p.trim()).filter(Boolean)) {
108
+ const [tier, model] = pair.split('=').map((x) => x.trim());
109
+ if (!tier || !model || !AGENT_TIERS.includes(tier)) {
110
+ throw new UsageError(`--models takes tier=model pairs with the tiers ${AGENT_TIERS.join(', ')} (for example balanced=sonnet,deep=opus)`);
111
+ }
112
+ out[tier] = model;
113
+ }
114
+ if (hosts.includes('copilot')) {
115
+ const offered = copilotModels();
116
+ for (const model of Object.values(out)) {
117
+ if (model !== SESSION_MODEL && offered && !offered.includes(model))
118
+ throw new UsageError(`GitHub Copilot does not offer '${model}'; its models: ${offered.join(', ')}`);
119
+ }
120
+ }
121
+ return out;
122
+ }
123
+ /**
124
+ * The reviewer models, chosen while setting up so the setting is not overlooked: one question
125
+ * (default no: every agent stays on the session's model), then a picker per host and tier.
126
+ * Only what differs from the defaults is returned: `models.<host>.<tier>`; QA left to follow
127
+ * the deep reviewer is not written. Null when nothing was chosen.
128
+ */
129
+ async function chooseModels(ctx, hosts, flagged) {
130
+ const s = ctx.style;
131
+ const chosen = {};
132
+ if (flagged) {
133
+ for (const host of hosts)
134
+ chosen[host] = { ...flagged };
135
+ return chosen;
136
+ }
137
+ const yes = ask(ctx, "Choose the reviewer models now? (Enter keeps the session's model for all)", { defaultYes: false });
138
+ if (!yes)
139
+ return null;
140
+ ctx.out('', s.gray('Each tier is the model of one agent. A deep reviewer on another model family than the main agent finds other things.'));
141
+ for (const host of hosts) {
142
+ ctx.out('', s.bold(host));
143
+ for (const tier of AGENT_TIERS) {
144
+ const { agent, label } = AGENTS[tier];
145
+ let answer = await ctx.choose(`${label} (tier ${tier}, ${agent})`, modelChoices(host, tier));
146
+ if (answer === null)
147
+ return chosen;
148
+ if (answer === OTHER)
149
+ answer = (await ctx.edit('Model id: ', '')).trim() || (tier === 'qa' ? FOLLOW : SESSION_MODEL);
150
+ if (answer === FOLLOW || (answer === SESSION_MODEL && tier !== 'qa'))
151
+ continue;
152
+ chosen[host] = { ...(chosen[host] ?? {}), [tier]: answer };
153
+ }
154
+ }
155
+ return chosen;
156
+ }
157
+ /** Per host, the model of every tier as it will run, so the setting is seen: `host: balanced x, deep y, qa follows deep`. */
158
+ function modelParts(ctx, config) {
159
+ const s = ctx.style;
160
+ return config.hosts.map((host) => {
161
+ const parts = AGENT_TIERS.map((tier) => {
162
+ const model = agentModel(config, host, tier);
163
+ const follows = tier === 'qa' && !config.models?.[host]?.qa;
164
+ return `${tier} ${follows ? s.gray('follows deep') : model ? s.cyan(model) : s.gray('session')}`;
165
+ });
166
+ return `${host}: ${parts.join(', ')}`;
167
+ });
168
+ }
169
+ /** What init is about to do, one labeled row each (a row may take several lines). */
170
+ function initSummary(ctx, rows) {
171
+ const s = ctx.style;
172
+ return ['', s.bold('Summary'), ...rows.flatMap(([label, lines]) => lines.map((line, i) => ` ${pad(s.gray(i ? '' : label), i ? '' : label, 18)}${line}`)), ''];
173
+ }
84
174
  const SETUP_BRANCH = 'chore/set-up-agjan';
85
175
  const SETUP_COMMIT = 'chore: set up agjan';
86
176
  /** The next steps after init, for the configured hosts (design decision 69). */
@@ -105,7 +195,7 @@ function nextSteps(ctx, hosts, left) {
105
195
  if (hosts.includes('copilot')) {
106
196
  steps.push(`Start ${s.cyan('copilot')} in this folder and trust it.`);
107
197
  }
108
- steps.push(`Run: ${s.cyan('agjan doctor')}`);
198
+ steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
109
199
  return ['', s.bold('Next steps:'), ...steps.map((text, i) => ` ${i + 1}. ${text}`)];
110
200
  }
111
201
  /**
@@ -133,8 +223,10 @@ const INIT_USAGE = [
133
223
  ' --hosts <host,...> claude-code, copilot (asked for on a terminal when left out)',
134
224
  ' --domains btp --language en --base <ref> --no-hook --no-ci --prepare',
135
225
  ' --copilot-mcp | --no-copilot-mcp',
226
+ ' --models balanced=<m>,deep=<m>,qa=<m> set the reviewer models without asking (default: asked about on a terminal)',
136
227
  ' --commit | --no-commit commit the setup (a new repository: on main; else on chore/set-up-agjan) or leave it to you',
137
228
  ' --no-install pin agjan in package.json but do not install it',
229
+ ' --yes do not ask "Continue?" after the summary',
138
230
  ` --pm <${PACKAGE_MANAGERS.join('|')}> the package manager to install with (default: from the lockfile, else npm)`,
139
231
  ' --dry-run show what would be done and stop',
140
232
  ];
@@ -204,7 +296,7 @@ function scaffold(ctx, target, found, { install, manager }) {
204
296
  /**
205
297
  * agjan init <folder | .> --hosts claude-code,copilot [--domains btp] [--language en] [--base <ref>]
206
298
  * [--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
207
- * [--commit | --no-commit] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
299
+ * [--models balanced=<m>,deep=<m>,qa=<m>] [--commit | --no-commit] [--yes] [--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
208
300
  */
209
301
  export async function init(ctx, argv) {
210
302
  const { values, positionals } = parseArgs({
@@ -222,7 +314,9 @@ export async function init(ctx, argv) {
222
314
  'no-copilot-mcp': { type: 'boolean' },
223
315
  commit: { type: 'boolean' },
224
316
  'no-commit': { type: 'boolean' },
317
+ models: { type: 'string' },
225
318
  'no-install': { type: 'boolean' },
319
+ yes: { type: 'boolean' },
226
320
  pm: { type: 'string' },
227
321
  'dry-run': { type: 'boolean' },
228
322
  },
@@ -261,11 +355,7 @@ export async function init(ctx, argv) {
261
355
  const hosts = chosen ?? await ctx.select('Which hosts should agjan set up?', supported.map((id) => ({ id, label: id })));
262
356
  if (!hosts)
263
357
  throw new UsageError(`no host chosen and no terminal to ask on; pass --hosts <host,...> (supported: ${supported.join(', ')})`);
264
- const origin = ctx.cwd;
265
- ctx.out('');
266
- scaffold(ctx, target, found, { install: !values['no-install'], manager });
267
- ctx.chdir(target);
268
- const root = ctx.root;
358
+ const flagged = parseModels(values.models, hosts);
269
359
  // Enter takes the recommended answer (yes); without a terminal the default (no) applies.
270
360
  const flag = (yes, no) => (values[yes] ? true : values[no] ? false : null);
271
361
  // Copilot loads the project's .mcp.json only in folders it remembers as trusted; its
@@ -274,16 +364,41 @@ export async function init(ctx, argv) {
274
364
  const resolved = { id: `${d}:${a}`, domain: d, name: a, role: area.role };
275
365
  return [[a, resolved], [`${d}:${a}`, resolved]];
276
366
  })));
277
- const servers = Object.keys(mcpServers({ areas }).servers);
278
- const copilotMcp = hosts.includes('copilot') && servers.length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
279
- 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);
367
+ const offered = mcpServers({ areas }).servers;
368
+ const copilotMcp = hosts.includes('copilot') && Object.keys(offered).length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
369
+ (ctx.out(...copilotMcpOffer(ctx, offered)), ask(ctx, 'Add them to your Copilot configuration?', { defaultYes: true })) ?? false);
370
+ const models = missingModels({}, hosts, { existing: false });
371
+ for (const [host, tiers] of Object.entries(await chooseModels(ctx, hosts, flagged) ?? {}))
372
+ models[host] = { ...models[host], ...tiers };
373
+ // Committing the setup: asked now, done at the end. Not when other work is in the folder (git add -A
374
+ // would sweep it in), unless --commit says so; and not while the pre-commit hook has no installed agjan.
375
+ const firstCommit = !found.repo || git(target, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) === null;
376
+ const hookNeedsInstall = Boolean(values['no-install'] && !values['no-hook']);
377
+ const blocker = hookNeedsInstall ? `the pre-commit hook needs the installed agjan (${manager} install, then commit)`
378
+ : !found.clean && !values.commit ? 'the folder had other work in it; commit what belongs to the setup yourself' : null;
379
+ const wantCommit = values['no-commit'] || hookNeedsInstall ? false : values.commit ? true : blocker ? false
380
+ : ask(ctx, firstCommit ? `Commit the setup now (${SETUP_COMMIT})?` : `Commit the setup on a new branch, ${SETUP_BRANCH}?`, { defaultYes: true }) ?? false;
381
+ ctx.out(...initSummary(ctx, [
382
+ ['Project', [`${s.bold(positionals[0])} ${s.gray(found.exists ? '(existing folder)' : `(new folder${found.repo ? '' : ', git repository'}, package.json)`)}`]],
383
+ ['agjan', [`${ctx.kit} pinned in devDependencies, ${values['no-install'] ? s.yellow(`not installed (${manager} install later)`) : `installed with ${manager}`}`]],
384
+ ['Hosts', [hosts.join(', ')]],
385
+ ...(hosts.includes('copilot') && Object.keys(offered).length ? [['Copilot servers', [copilotMcp ? `add ${Object.keys(offered).join(', ')} to your Copilot configuration` : s.gray('not added')]]] : []),
386
+ ['Reviewer models', modelParts(ctx, { hosts, models })],
387
+ ['Commit', [wantCommit ? `"${SETUP_COMMIT}" ${firstCommit ? 'on main' : `on a new branch, ${SETUP_BRANCH}`}` : s.yellow(`not now${values['no-commit'] ? '' : blocker ? `: ${blocker}` : ''}`)]],
388
+ ]));
389
+ if (!values.yes && ask(ctx, 'Continue?', { defaultYes: true }) === false)
390
+ throw new AgjanError('cancelled; nothing was changed');
391
+ const origin = ctx.cwd;
392
+ scaffold(ctx, target, found, { install: !values['no-install'], manager });
393
+ ctx.chdir(target);
394
+ const root = ctx.root;
280
395
  const config = {
281
396
  $schema: './node_modules/agjan/schemas/config.schema.json',
282
397
  kit: ctx.kit,
283
398
  domains,
284
399
  hosts,
285
400
  language: values.language ?? 'en',
286
- models: missingModels({}, hosts, { existing: false }),
401
+ models,
287
402
  git: { ...(values.base ? { base: values.base } : {}) },
288
403
  };
289
404
  writeJson(join(root, CONFIG_FILE), config);
@@ -308,21 +423,8 @@ export async function init(ctx, argv) {
308
423
  ctx.out(` ${pad(tone(s, 'created'), 'created', 14)} ${CI_FILE}`);
309
424
  }
310
425
  }
311
- const firstCommit = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) === null;
312
- // Asked once everything is written. Not when other work is in the folder (git add -A would
313
- // sweep it in), unless --commit says so.
314
426
  let committed = null;
315
- // The pre-commit hook runs the project's agjan: without the install, committing would hang on it.
316
- const hookNeedsInstall = values['no-install'] && !values['no-hook'];
317
- const wanted = values['no-commit'] || hookNeedsInstall ? false : values.commit ? true : !found.clean ? false
318
- : ask(ctx, firstCommit ? `Commit the setup now (${SETUP_COMMIT})?` : `Commit the setup on a new branch, ${SETUP_BRANCH}?`, { defaultYes: true }) ?? false;
319
- if (hookNeedsInstall && !values['no-commit']) {
320
- ctx.out('', s.yellow(`The setup is not committed: the pre-commit hook needs the installed agjan (${manager} install, then commit).`));
321
- }
322
- else if (!found.clean && !values.commit && !values['no-commit']) {
323
- 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.'));
324
- }
325
- if (wanted) {
427
+ if (wantCommit) {
326
428
  const result = commitSetup(root, { firstCommit });
327
429
  if ('error' in result) {
328
430
  ctx.out('', s.yellow(`Could not commit the setup: ${result.error}`));
@@ -332,9 +434,9 @@ export async function init(ctx, argv) {
332
434
  ctx.out('', ` ${pad(tone(s, 'created'), 'created', 14)} commit "${SETUP_COMMIT}" on ${result.branch}`);
333
435
  }
334
436
  }
335
- const cd = relative(origin, target);
437
+ const back = relative(origin, target);
336
438
  ctx.out(...nextSteps(ctx, hosts, {
337
- cd: cd && cd !== '.' ? cd : null,
439
+ cd: back && back !== '.' ? back : null,
338
440
  install: values['no-install'] ? `${manager} install` : null,
339
441
  committed,
340
442
  firstCommit,
package/dist/context.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { repoRoot, userEmail } from './git.js';
3
3
  import { loadConfig } from './config.js';
4
- import { askOnTerminal, confirmOnTerminal, editOnTerminal, selectOnTerminal } from './terminal.js';
4
+ import { askOnTerminal, chooseOnTerminal, confirmOnTerminal, editOnTerminal, selectOnTerminal } from './terminal.js';
5
5
  import { createStyle } from './ui.js';
6
6
  export const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
7
7
  /** UTC timestamp without milliseconds, for example 2026-10-17T09:12:03Z. */
@@ -14,7 +14,7 @@ export function utcNow() {
14
14
  * no option
15
15
  * to skip the confirmation from the command line or the environment.
16
16
  */
17
- export function createContext({ cwd: initialCwd = process.cwd(), stdout = process.stdout, stderr = process.stderr, now = utcNow, confirm = confirmOnTerminal, edit = editOnTerminal, ask = askOnTerminal, select = selectOnTerminal, } = {}) {
17
+ export function createContext({ cwd: initialCwd = process.cwd(), stdout = process.stdout, stderr = process.stderr, now = utcNow, confirm = confirmOnTerminal, edit = editOnTerminal, ask = askOnTerminal, select = selectOnTerminal, choose = chooseOnTerminal, } = {}) {
18
18
  let cwd = initialCwd;
19
19
  let root;
20
20
  let config;
@@ -38,6 +38,8 @@ export function createContext({ cwd: initialCwd = process.cwd(), stdout = proces
38
38
  ask,
39
39
  /** Asks the human to choose among `choices`; null without a terminal. */
40
40
  select,
41
+ /** Asks the human to choose one of `choices`; null without a terminal. */
42
+ choose,
41
43
  kit: pkg.version,
42
44
  get root() {
43
45
  root ??= repoRoot(cwd);
@@ -0,0 +1,47 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { SESSION_MODEL } from './config.js';
3
+ /**
4
+ * The models GitHub Copilot CLI accepts, from `copilot help config` (its `model` setting
5
+ * lists them). Null when copilot cannot be run; AGJAN_COPILOT names a stand-in (tests).
6
+ */
7
+ export function copilotModels() {
8
+ const fake = process.env.AGJAN_COPILOT;
9
+ const run = fake
10
+ ? spawnSync(process.execPath, [fake, 'help', 'config'], { encoding: 'utf8', timeout: 30_000 })
11
+ : spawnSync('copilot', ['help', 'config'], { encoding: 'utf8', timeout: 30_000, shell: process.platform === 'win32' });
12
+ if (run.error || run.status !== 0)
13
+ return null;
14
+ const section = /`model`:[^\n]*\n((?:\s+- "[^"]+"\n?)+)/.exec(run.stdout ?? '');
15
+ return section ? [...section[1].matchAll(/- "([^"]+)"/g)].map((m) => m[1]) : null;
16
+ }
17
+ /** The agent of each tier, and what it does. */
18
+ export const AGENTS = {
19
+ balanced: { agent: 'agjan-reviewer', label: 'reviewer' },
20
+ deep: { agent: 'agjan-reviewer-deep', label: 'deep reviewer' },
21
+ qa: { agent: 'agjan-qa', label: 'QA agent' },
22
+ };
23
+ /** What a tier's picker starts with: the default, which is not a model at all. */
24
+ export const FOLLOW = 'follow';
25
+ export const OTHER = 'other';
26
+ /** The model names a host takes: Claude Code aliases, or what the Copilot CLI offers (null: unknown). */
27
+ export function hostModels(host, copilot = host === 'copilot' ? copilotModels() : null) {
28
+ if (host === 'claude-code')
29
+ return ['sonnet', 'opus', 'haiku', 'fable'];
30
+ return host === 'copilot' ? copilot : null;
31
+ }
32
+ /**
33
+ * The lines of a tier's picker on `host`: the default first (the session's model; for QA
34
+ * that it follows the deep reviewer), then the host's models, then a way to type another.
35
+ */
36
+ export function modelChoices(host, tier) {
37
+ const models = hostModels(host);
38
+ return [
39
+ tier === 'qa'
40
+ ? { id: FOLLOW, label: 'follows the deep reviewer', note: '(default)' }
41
+ : { id: SESSION_MODEL, label: "the session's model", note: '(default)' },
42
+ ...(tier === 'qa' ? [{ id: SESSION_MODEL, label: "the session's model" }] : []),
43
+ ...(models ?? []).map((id) => ({ id, label: id })),
44
+ // A known list is the whole truth for Copilot; elsewhere a full model id can be typed.
45
+ ...(host === 'copilot' && models ? [] : [{ id: OTHER, label: 'another model', note: 'type its id' }]),
46
+ ];
47
+ }
package/dist/select.js CHANGED
@@ -17,38 +17,71 @@ export function keysOf(chunk) {
17
17
  }
18
18
  return keys;
19
19
  }
20
- /** The state after a key; `done` when Enter confirmed a choice or the human cancelled. */
20
+ /**
21
+ * The state after a key; `done` when the human confirmed or cancelled. The cursor runs over
22
+ * the choices and one more row, "Confirm": Enter (or space) on a choice ticks or unticks it,
23
+ * on Confirm it confirms, which needs at least one choice ticked.
24
+ */
21
25
  export function reduceSelect(state, key) {
22
26
  const count = state.picked.length;
27
+ const rows = count + 1;
23
28
  switch (key) {
24
29
  case 'up':
25
- return { state: { ...state, cursor: (state.cursor + count - 1) % count, warn: false } };
30
+ return { state: { ...state, cursor: (state.cursor + rows - 1) % rows, warn: false } };
26
31
  case 'down':
27
- return { state: { ...state, cursor: (state.cursor + 1) % count, warn: false } };
32
+ return { state: { ...state, cursor: (state.cursor + 1) % rows, warn: false } };
28
33
  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
34
  case 'enter':
35
+ if (state.cursor < count)
36
+ return { state: { ...state, picked: state.picked.map((p, i) => (i === state.cursor ? !p : p)), warn: false } };
33
37
  return state.picked.some(Boolean) ? { state, done: 'confirm' } : { state: { ...state, warn: true } };
38
+ case 'all':
39
+ return { state: { ...state, picked: state.picked.map(() => !state.picked.every(Boolean)), warn: false } };
34
40
  case 'cancel':
35
41
  return { state, done: 'cancel' };
36
42
  }
37
43
  }
38
- /** The lines of the picker: the question, one line per choice, and a hint (or the refusal). */
44
+ /** The lines of the picker: the question, a checkbox per choice, the Confirm row and a hint. */
39
45
  export function renderSelect(s, question, choices, state) {
40
46
  const rows = choices.map((choice, i) => {
41
47
  const here = i === state.cursor;
42
- const box = state.picked[i] ? s.green('◉') : s.gray('◯');
48
+ const box = state.picked[i] ? s.green('[x]') : s.gray('[ ]');
43
49
  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}`;
50
+ return `${here ? s.teal('❯') : ' '} ${box} ${label}${choice.note ? ` ${s.gray(choice.note)}` : ''}`;
45
51
  });
52
+ const chosen = choices.filter((_, i) => state.picked[i]).map((c) => c.label);
53
+ const onConfirm = state.cursor === choices.length;
54
+ const confirm = `${onConfirm ? s.teal('❯') : ' '} ${onConfirm ? s.bold(s.teal('Confirm')) : s.bold('Confirm')} ${s.gray(chosen.length ? `(${chosen.join(', ')})` : '(nothing selected yet)')}`;
46
55
  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}`];
56
+ ? s.red('Select at least one with enter, then go to Confirm.')
57
+ : s.gray('↑/↓ move · enter select or deselect · a all · enter on Confirm to continue · esc cancel');
58
+ return [`${s.teal('?')} ${s.bold(question)}`, ...rows, confirm, ` ${hint}`];
50
59
  }
51
60
  /** The one line left on the terminal once the human confirmed. */
52
61
  export function renderChosen(s, question, chosen) {
53
62
  return `${s.green('✔')} ${s.bold(question)} ${s.teal(chosen.join(', '))}`;
54
63
  }
64
+ /** The picker for one choice: the state is the cursor; Enter takes the line under it. */
65
+ export function reduceChoose(cursor, count, key) {
66
+ switch (key) {
67
+ case 'up':
68
+ return { state: (cursor + count - 1) % count };
69
+ case 'down':
70
+ return { state: (cursor + 1) % count };
71
+ case 'enter':
72
+ return { state: cursor, done: 'confirm' };
73
+ case 'cancel':
74
+ return { state: cursor, done: 'cancel' };
75
+ default:
76
+ return { state: cursor };
77
+ }
78
+ }
79
+ /** The lines of the one-choice picker: the question, the choices, a hint. */
80
+ export function renderChoose(s, question, choices, cursor) {
81
+ const rows = choices.map((choice, i) => {
82
+ const here = i === cursor;
83
+ const note = choice.note ? ` ${s.gray(choice.note)}` : '';
84
+ return `${here ? s.teal('❯') : ' '} ${here ? s.bold(s.teal(choice.label)) : choice.label}${note}`;
85
+ });
86
+ return [`${s.teal('?')} ${s.bold(question)}`, ...rows, ` ${s.gray('↑/↓ move · enter choose · esc cancel')}`];
87
+ }
package/dist/terminal.js CHANGED
@@ -2,7 +2,7 @@ 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';
5
+ import { initialSelect, keysOf, reduceChoose, reduceSelect, renderChoose, renderSelect } from './select.js';
6
6
  import { createStyle } from './ui.js';
7
7
  /**
8
8
  * Opens the controlling terminal, bypassing stdin and stdout, so that piped input
@@ -84,19 +84,18 @@ export function askOnTerminal(question, { defaultYes = false } = {}) {
84
84
  }
85
85
  }
86
86
  /**
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.
87
+ * The shared loop of the pickers: draws `render(state)` on the controlling terminal, feeds it
88
+ * the keys through `reduce`, and ends with the chosen line (or cancels). Without raw key input
89
+ * (a console that is not a TTY stream) `typed` asks in lines instead.
91
90
  */
92
- export async function selectOnTerminal(question, choices) {
91
+ async function pickOnTerminal(question, picker) {
93
92
  const tty = openTerminal();
94
93
  if (!tty)
95
94
  return null;
96
95
  const style = createStyle({ isTTY: true });
97
96
  if (!isatty(tty.input)) {
98
97
  try {
99
- return typeSelection(tty, style, question, choices);
98
+ return picker.typed(tty, style);
100
99
  }
101
100
  finally {
102
101
  closeSync(tty.input);
@@ -106,11 +105,11 @@ export async function selectOnTerminal(question, choices) {
106
105
  }
107
106
  const input = new ReadStream(tty.input);
108
107
  const write = (text) => writeSync(tty.output, text);
109
- let state = initialSelect(choices.length);
108
+ let state = picker.initial;
110
109
  let lines = 0;
111
110
  // Draws the picker over its previous drawing.
112
111
  const draw = () => {
113
- const frame = renderSelect(style, question, choices, state);
112
+ const frame = picker.render(style, state);
114
113
  write(`${lines ? `\x1b[${lines - 1}A\r` : ''}${frame.map((l) => `\x1b[2K${l}`).join('\n')}`);
115
114
  lines = frame.length;
116
115
  };
@@ -124,7 +123,7 @@ export async function selectOnTerminal(question, choices) {
124
123
  const done = await new Promise((resolve) => {
125
124
  input.on('data', (chunk) => {
126
125
  for (const key of keysOf(chunk.toString('utf8'))) {
127
- const next = reduceSelect(state, key);
126
+ const next = picker.reduce(state, key);
128
127
  state = next.state;
129
128
  if (next.done)
130
129
  return resolve(next.done);
@@ -137,9 +136,9 @@ export async function selectOnTerminal(question, choices) {
137
136
  leave(`${style.red('✖')} ${style.bold(question)} ${style.gray('cancelled')}\n`);
138
137
  throw new AgjanError('cancelled; nothing was changed');
139
138
  }
140
- const chosen = choices.filter((_, i) => state.picked[i]).map((c) => c.id);
141
- leave(`${renderChosen(style, question, chosen)}\n`);
142
- return chosen;
139
+ const { value, shown } = picker.answer(state);
140
+ leave(`${style.green('✔')} ${style.bold(question)} ${style.teal(shown)}\n`);
141
+ return value;
143
142
  }
144
143
  finally {
145
144
  write('\x1b[?25h');
@@ -148,14 +147,42 @@ export async function selectOnTerminal(question, choices) {
148
147
  closeSync(tty.output);
149
148
  }
150
149
  }
150
+ /**
151
+ * Asks the human to choose one or more of `choices` on the controlling terminal: with the
152
+ * cursor keys, space and Enter where the terminal allows, else by typing numbers or names
153
+ * separated by commas. Returns null when there is no terminal (a script, CI or an agent):
154
+ * the caller then needs the choice from a flag. Cancelling is an error.
155
+ */
156
+ export function selectOnTerminal(question, choices) {
157
+ return pickOnTerminal(question, {
158
+ initial: initialSelect(choices.length),
159
+ reduce: reduceSelect,
160
+ render: (style, state) => renderSelect(style, question, choices, state),
161
+ answer: (state) => {
162
+ const chosen = choices.filter((_, i) => state.picked[i]).map((c) => c.id);
163
+ return { value: chosen, shown: chosen.join(', ') };
164
+ },
165
+ typed: (tty, style) => typeSelection(tty, style, question, choices),
166
+ });
167
+ }
168
+ /** Like `selectOnTerminal`, for exactly one choice: Enter takes the line under the cursor. */
169
+ export function chooseOnTerminal(question, choices) {
170
+ return pickOnTerminal(question, {
171
+ initial: 0,
172
+ reduce: (cursor, key) => reduceChoose(cursor, choices.length, key),
173
+ render: (style, cursor) => renderChoose(style, question, choices, cursor),
174
+ answer: (cursor) => ({ value: choices[cursor].id, shown: choices[cursor].label }),
175
+ typed: (tty, style) => typeSelection(tty, style, question, choices, { one: true })[0],
176
+ });
177
+ }
151
178
  /** The fallback without key input: a numbered list and a typed answer. */
152
- function typeSelection(tty, s, question, choices) {
179
+ function typeSelection(tty, s, question, choices, { one = false } = {}) {
153
180
  writeSync(tty.output, `${s.teal('?')} ${s.bold(question)}\n${choices.map((c, i) => ` ${s.teal(`${i + 1}.`)} ${c.label}`).join('\n')}\n`);
154
181
  for (;;) {
155
- writeSync(tty.output, `${s.gray('Choose one or more (numbers or names, separated by commas):')} `);
182
+ writeSync(tty.output, `${s.gray(one ? 'Choose one (number or name):' : 'Choose one or more (numbers or names, separated by commas):')} `);
156
183
  const answer = readLine(tty.input).trim();
157
184
  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))
185
+ if (picked.length && picked.every(Boolean) && (!one || picked.length === 1))
159
186
  return [...new Set(picked)];
160
187
  writeSync(tty.output, `${s.red('Not understood:')} ${answer === '' ? '(nothing)' : answer}\n`);
161
188
  }
package/docs/guide.md CHANGED
@@ -39,9 +39,9 @@ Requirements: Node.js 22 or later, git, and Claude Code and/or GitHub Copilot.
39
39
 
40
40
  ```sh
41
41
  npm install --global agjan
42
- agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), then to commit the setup
42
+ agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), whether to choose the reviewer models, then to commit the setup
43
43
  cd my-project # a command cannot move your shell: init prints this as its first next step
44
- agjan doctor
44
+ npx agjan doctor # from here on, npx runs the project's pinned agjan
45
45
  ```
46
46
 
47
47
  `agjan init <folder>` creates the folder, runs `git init -b main`, writes a `package.json`
@@ -53,12 +53,26 @@ before changing anything when the folder already has an `agjan.config.json`, whe
53
53
  `package.json` is not valid JSON, or when the folder lies inside another git repository.
54
54
  `--dry-run` shows the plan, `--no-install` only pins the version.
55
55
 
56
- When everything is written, `init` offers to commit the setup (`chore: set up agjan`): on
56
+ `init` also asks "Choose the reviewer models now?" (Enter says no: every agent runs on the
57
+ model of the session that starts it). Say yes to pick the model of each tier per host:
58
+ `balanced` and `deep` (the two reviewers) and `qa` (the tester, which follows the deep tier
59
+ unless you choose a model). The pickers list the host's models, with the default first. A
60
+ deep reviewer on another model family than the main agent finds other things. The result is
61
+ always printed (`Reviewer models`), and `--models balanced=<m>,deep=<m>,qa=<m>` sets it without
62
+ asking. Change it later with `npx agjan models`.
63
+
64
+ All the questions come first (hosts, the Copilot servers, the reviewer models, whether to
65
+ commit), before anything is created. Then `init` prints a **summary** of the answers (project,
66
+ pinned version, hosts, Copilot servers, reviewer models, commit) and asks "Continue?"; No
67
+ stops with nothing written. Without a terminal it prints the summary and goes on; `--yes`
68
+ skips the question.
69
+
70
+ The commit question (`chore: set up agjan`) is about the end of the setup: on
57
71
  `main` in a new repository, on a branch of its own, `chore/set-up-agjan`, in an existing one
58
72
  (the base branch changes through a PR). `--commit` and `--no-commit` answer the question.
59
73
  Nothing is committed for you when the folder had other work in it (files in a folder that was
60
74
  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.
75
+ without its agjan; the summary then says why, and the next steps say what to run.
62
76
 
63
77
  The global `agjan` runs `init`, `--help` and `--version` itself. Every other command runs
64
78
  in the agjan the project pins in `node_modules`. If that is not installed (a fresh clone),
@@ -66,6 +80,10 @@ the command offers to run the install first; without a terminal it fails and say
66
80
  (`agjan --yes <command>` installs without asking). Without a global install, `npx agjan init
67
81
  <folder>` works the same.
68
82
 
83
+ The global install is for starting projects. Day to day, use `npx agjan <command>` in the
84
+ project: it runs the pinned copy directly and works on every machine, with or without a
85
+ global install. The hooks, the MCP configuration and the skills all call it that way.
86
+
69
87
  `init` writes `agjan.config.json`, the skills (`.claude/skills/`), the reviewer agents,
70
88
  the guardrails against agents running approvals, the MCP configuration, a block in
71
89
  `AGENTS.md` and `CLAUDE.md`, a pre-commit hook and a CI workflow. Your own content in
@@ -158,7 +176,12 @@ decide comes to you as a "Spec question". The tests stay in `test/qa/<feature>/`
158
176
  in `test/ui/qa/<feature>/`) as regression tests; a change to them after QA makes QA run
159
177
  again. The final review, `check --ci` and `approve verify` wait for a passing QA round.
160
178
  QA runs on the deep reviewer's model unless you give it its own:
161
- `npx agjan models set qa <model>`.
179
+ `npx agjan models set qa <model>`. `npx agjan models` shows the three tiers (`balanced` and
180
+ `deep` are the reviewers `agjan-reviewer` and `agjan-reviewer-deep`, `qa` is `agjan-qa`), the
181
+ model each runs on, its effort and the steps it covers; `qa` is marked "follows the deep tier" while it has
182
+ no model of its own, and `models set deep` tells you when QA moves with it. Every agent runs at
183
+ the effort level of the session that starts it (checked on Claude Code and Copilot, where the
184
+ reviewer ran at the session's low effort); agjan sets no effort of its own.
162
185
 
163
186
  The completion block gives you the last gate:
164
187
 
@@ -206,8 +229,15 @@ npx agjan auto on # this feature; asks you to type its key
206
229
  npx agjan auto off # this feature's gates wait for you again
207
230
  npx agjan auto on --default # every feature you create in this checkout from now on
208
231
  npx agjan auto off --default # new features wait at their gates again
232
+ npx agjan auto status # what is set: your default, and every existing feature
209
233
  ```
210
234
 
235
+ The two forms do different things. `auto on` switches one existing feature (the one that
236
+ changed on your branch, or `--feature <slug>`). `auto on --default` changes nothing that
237
+ exists; it only makes the features you create afterwards start in auto mode. To have both,
238
+ run both. `auto status` shows the real settings, read-only: your default and the mode of every
239
+ existing feature.
240
+
211
241
  The default is yours only: it lives in `.agjan/auto.json`, which is git-ignored, so
212
242
  teammates' checkouts keep their gates. A feature takes it when it is created (its
213
243
  `approvals.json` records `from: default`); existing features keep their mode, and
@@ -224,7 +254,8 @@ review still stops the gate. You stay in charge of:
224
254
 
225
255
  Every automatic approval is recorded as `by: auto` with your name as the one who switched
226
256
  auto mode on, never as your approval; `status`, the progress pages and the PR summary
227
- show it. Auto mode belongs to one feature: the next one starts with the gates on. Agents
257
+ show it. Auto mode belongs to one feature: the next one starts with the gates on, unless your
258
+ default is on. Agents
228
259
  cannot switch it on: like `approve`, it needs your terminal, and the guard denies it.
229
260
 
230
261
  ### 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
  }
@@ -59,7 +59,8 @@ When `npx agjan status` says all tasks are done and reviewed, tell the user to r
59
59
  `/agjan-verify`. In auto mode (`npx agjan status` shows `auto on`) do not stop: your next
60
60
  action is the shell command `cat .claude/skills/agjan-verify/SKILL.md` (it works on every
61
61
  host), then follow that skill; put a one-line note for the user into the same reply, since
62
- a reply without a tool call ends your run. Its final acceptance, `npx agjan approve
62
+ a reply without a tool call ends your run. Do not end your reply with "run `/agjan-verify`":
63
+ in auto mode that is your next action. Its final acceptance, `npx agjan approve
63
64
  verify`, stays with the user in every mode.
64
65
 
65
66
  ## Never
@@ -101,7 +101,8 @@ passing one.
101
101
  continue without stopping: your next action is the shell command
102
102
  `cat .claude/skills/agjan-build/SKILL.md` (it works on every host), then follow that skill.
103
103
  Put the one line for the user into the same reply as that command: a reply without a
104
- tool call ends your run, and the user has to start it again.
104
+ tool call ends your run, and the user has to start it again. Do not end your reply with
105
+ "run `/agjan-build`": in auto mode that is your next action, not the user's.
105
106
  4. Otherwise tell the user what to review, the open findings, and the command for their
106
107
  terminal: `npx agjan approve design` (it also commits the approval); then
107
108
  `/agjan-build`. Stop.
@@ -106,7 +106,8 @@ and the real files the change would touch (services in
106
106
 
107
107
  ### Full
108
108
 
109
- Hand over the gate (see below) with `spec`. The user runs `/agjan-design` afterwards.
109
+ Hand over the gate (see below) with `spec`. The design follows: in auto mode you continue
110
+ with it yourself right away (step 3 below), otherwise the user runs `/agjan-design`.
110
111
 
111
112
  ## 6. Hand over the gate
112
113
 
@@ -125,6 +126,8 @@ Hand over the gate (see below) with `spec`. The user runs `/agjan-design` afterw
125
126
  every host; `agjan-build` after `spec design`), then follow that skill. Put the one line
126
127
  for the user into the same reply as that command: a reply without a tool call ends
127
128
  your run, and the user has to start it again.
129
+ Do not end your reply with "run `/agjan-design`" (or `/agjan-build`): in auto mode that
130
+ is your next action, not the user's.
128
131
  Stop only where a person is needed: blockers at the round limit, an amendment, a
129
132
  business question, and the acceptance at the end.
130
133
  4. Otherwise tell the user what to review, the open findings they should know about, and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agjan",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
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
6
  "agentic-engineering",