agjan 0.0.16 → 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/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);
@@ -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,9 @@ 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;
23
- }
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 agent' },
29
- };
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";
30
12
  /** Whether the QA agent has no model of its own on `host`, so it runs on the deep tier's (decision 81). */
31
13
  function followsDeep(config, host, tier) {
32
14
  return tier === 'qa' && !config.models?.[host]?.qa;
@@ -67,20 +49,20 @@ function show(ctx) {
67
49
  const config = ctx.config;
68
50
  for (const line of markLine(s, ctx.kit, 'models'))
69
51
  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.'));
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."));
71
53
  for (const host of config.hosts) {
72
54
  ctx.out('', s.bold(host));
73
55
  const head = (text, width) => pad(s.gray(text), text, width);
74
56
  // As wide as the longest model name here: real names (claude-sonnet-5.5) outgrow a fixed column.
75
57
  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')}`);
58
+ ctx.out(` ${head('TIER', 10)}${head('AGENT', 21)}${head('MODEL', modelWidth)}${head('EFFORT', EFFORT.length + 2)}${s.gray('RUNS')}`);
77
59
  for (const tier of AGENT_TIERS) {
78
60
  const { agent, label } = AGENTS[tier];
79
61
  const model = agentModel(config, host, tier);
80
62
  const shown = model ? s.cyan(model) : s.gray('session model');
81
63
  const plain = model ?? 'session model';
82
64
  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}`);
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}`);
84
66
  }
85
67
  }
86
68
  ctx.out('', s.bold('Change, in your terminal:'));
@@ -18,6 +18,7 @@ import { AgjanError, UsageError } from '../errors.js';
18
18
  import { blink, mark, pad, tone, verdictColor } from '../ui.js';
19
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';
@@ -98,6 +99,78 @@ function copilotMcpOffer(ctx, servers) {
98
99
  '',
99
100
  ];
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
+ }
101
174
  const SETUP_BRANCH = 'chore/set-up-agjan';
102
175
  const SETUP_COMMIT = 'chore: set up agjan';
103
176
  /** The next steps after init, for the configured hosts (design decision 69). */
@@ -150,8 +223,10 @@ const INIT_USAGE = [
150
223
  ' --hosts <host,...> claude-code, copilot (asked for on a terminal when left out)',
151
224
  ' --domains btp --language en --base <ref> --no-hook --no-ci --prepare',
152
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)',
153
227
  ' --commit | --no-commit commit the setup (a new repository: on main; else on chore/set-up-agjan) or leave it to you',
154
228
  ' --no-install pin agjan in package.json but do not install it',
229
+ ' --yes do not ask "Continue?" after the summary',
155
230
  ` --pm <${PACKAGE_MANAGERS.join('|')}> the package manager to install with (default: from the lockfile, else npm)`,
156
231
  ' --dry-run show what would be done and stop',
157
232
  ];
@@ -221,7 +296,7 @@ function scaffold(ctx, target, found, { install, manager }) {
221
296
  /**
222
297
  * agjan init <folder | .> --hosts claude-code,copilot [--domains btp] [--language en] [--base <ref>]
223
298
  * [--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
224
- * [--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]
225
300
  */
226
301
  export async function init(ctx, argv) {
227
302
  const { values, positionals } = parseArgs({
@@ -239,7 +314,9 @@ export async function init(ctx, argv) {
239
314
  'no-copilot-mcp': { type: 'boolean' },
240
315
  commit: { type: 'boolean' },
241
316
  'no-commit': { type: 'boolean' },
317
+ models: { type: 'string' },
242
318
  'no-install': { type: 'boolean' },
319
+ yes: { type: 'boolean' },
243
320
  pm: { type: 'string' },
244
321
  'dry-run': { type: 'boolean' },
245
322
  },
@@ -278,11 +355,7 @@ export async function init(ctx, argv) {
278
355
  const hosts = chosen ?? await ctx.select('Which hosts should agjan set up?', supported.map((id) => ({ id, label: id })));
279
356
  if (!hosts)
280
357
  throw new UsageError(`no host chosen and no terminal to ask on; pass --hosts <host,...> (supported: ${supported.join(', ')})`);
281
- const origin = ctx.cwd;
282
- ctx.out('');
283
- scaffold(ctx, target, found, { install: !values['no-install'], manager });
284
- ctx.chdir(target);
285
- const root = ctx.root;
358
+ const flagged = parseModels(values.models, hosts);
286
359
  // Enter takes the recommended answer (yes); without a terminal the default (no) applies.
287
360
  const flag = (yes, no) => (values[yes] ? true : values[no] ? false : null);
288
361
  // Copilot loads the project's .mcp.json only in folders it remembers as trusted; its
@@ -294,13 +367,38 @@ export async function init(ctx, argv) {
294
367
  const offered = mcpServers({ areas }).servers;
295
368
  const copilotMcp = hosts.includes('copilot') && Object.keys(offered).length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
296
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;
297
395
  const config = {
298
396
  $schema: './node_modules/agjan/schemas/config.schema.json',
299
397
  kit: ctx.kit,
300
398
  domains,
301
399
  hosts,
302
400
  language: values.language ?? 'en',
303
- models: missingModels({}, hosts, { existing: false }),
401
+ models,
304
402
  git: { ...(values.base ? { base: values.base } : {}) },
305
403
  };
306
404
  writeJson(join(root, CONFIG_FILE), config);
@@ -325,21 +423,8 @@ export async function init(ctx, argv) {
325
423
  ctx.out(` ${pad(tone(s, 'created'), 'created', 14)} ${CI_FILE}`);
326
424
  }
327
425
  }
328
- const firstCommit = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) === null;
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
426
  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) {
427
+ if (wantCommit) {
343
428
  const result = commitSetup(root, { firstCommit });
344
429
  if ('error' in result) {
345
430
  ctx.out('', s.yellow(`Could not commit the setup: ${result.error}`));
@@ -349,9 +434,9 @@ export async function init(ctx, argv) {
349
434
  ctx.out('', ` ${pad(tone(s, 'created'), 'created', 14)} commit "${SETUP_COMMIT}" on ${result.branch}`);
350
435
  }
351
436
  }
352
- const cd = relative(origin, target);
437
+ const back = relative(origin, target);
353
438
  ctx.out(...nextSteps(ctx, hosts, {
354
- cd: cd && cd !== '.' ? cd : null,
439
+ cd: back && back !== '.' ? back : null,
355
440
  install: values['no-install'] ? `${manager} install` : null,
356
441
  committed,
357
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,7 +39,7 @@ 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
44
  npx agjan doctor # from here on, npx runs the project's pinned agjan
45
45
  ```
@@ -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),
@@ -164,8 +178,10 @@ again. The final review, `check --ci` and `approve verify` wait for a passing QA
164
178
  QA runs on the deep reviewer's model unless you give it its own:
165
179
  `npx agjan models set qa <model>`. `npx agjan models` shows the three tiers (`balanced` and
166
180
  `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.
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.
169
185
 
170
186
  The completion block gives you the last gate:
171
187
 
@@ -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.16",
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",