gcf-aif-ext 0.29.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/GLOSSARY.md +1 -1
  2. package/README.md +2 -1
  3. package/commands/gcf.js +176 -74
  4. package/extension.json +1 -1
  5. package/hooks/pre-commit.js +2 -0
  6. package/lib/agent-permissions.js +11 -6
  7. package/lib/audit-core.js +43 -19
  8. package/lib/board.js +10 -4
  9. package/lib/changes.js +2 -1
  10. package/lib/commit-files.js +2 -1
  11. package/lib/commit-move.js +114 -0
  12. package/lib/config-doc.js +22 -0
  13. package/lib/config-set.js +189 -83
  14. package/lib/design-check.js +8 -3
  15. package/lib/design-parts.js +111 -80
  16. package/lib/devices.js +3 -8
  17. package/lib/domain.js +17 -12
  18. package/lib/edits.js +7 -3
  19. package/lib/frozen.js +24 -0
  20. package/lib/gate.js +1 -1
  21. package/lib/gcf-paths.js +81 -11
  22. package/lib/git.js +18 -4
  23. package/lib/handoff.js +25 -10
  24. package/lib/history.js +1 -1
  25. package/lib/inbox-categories.js +32 -39
  26. package/lib/inbox.js +46 -34
  27. package/lib/integrate.js +3 -12
  28. package/lib/ledger.js +1 -1
  29. package/lib/lessons.js +4 -1
  30. package/lib/metrics.js +1 -0
  31. package/lib/migrate.js +1 -1
  32. package/lib/milestone-state.js +1 -1
  33. package/lib/phase.js +1 -1
  34. package/lib/pillars.js +1 -1
  35. package/lib/plan-check.js +80 -43
  36. package/lib/play-notes.js +115 -21
  37. package/lib/play.js +63 -12
  38. package/lib/playtest-list.js +1 -1
  39. package/lib/push.js +2 -1
  40. package/lib/questions.js +1 -1
  41. package/lib/review.js +106 -0
  42. package/lib/session-mark.js +21 -2
  43. package/lib/shelf.js +1 -0
  44. package/lib/systems-doc.js +27 -17
  45. package/lib/unit-ops.js +31 -109
  46. package/lib/validate-item.js +30 -7
  47. package/lib/verdict-fs.js +2 -1
  48. package/lib/verify-stamp.js +7 -2
  49. package/lib/verify.js +6 -2
  50. package/lib/work-ops.js +197 -104
  51. package/package.json +3 -3
  52. package/schemas/item.schema.json +24 -9
  53. package/templates/agents-block.md +9 -1
  54. package/templates/config.yml +15 -10
@@ -38,7 +38,7 @@ import {
38
38
  recordsIn,
39
39
  uncovered,
40
40
  } from './design-check.js';
41
- import { commitMove } from './unit-ops.js';
41
+ import { commitMove } from './commit-move.js';
42
42
  import { locked } from './main-lock.js';
43
43
  import { buildLedger } from './ledger.js';
44
44
  import { deriveId } from './id.js';
@@ -406,83 +406,89 @@ async function newUnitId(projectDir, kind, title, type) {
406
406
  }
407
407
 
408
408
  /**
409
- * @param {string} projectDir
410
- * @param {string} kind
411
- * @param {string | null | undefined} given
412
- * @param {{fields?: Record<string, any> | null, text?: string | null, base?: string | null,
413
- * system?: string | null, type?: string | null, title?: string | null, commit?: boolean}} opts
409
+ * saveUnlocked's options with their defaults.
410
+ * @typedef {{fields?: Record<string, any> | null, text?: string | null, base?: string | null,
411
+ * system?: string | null, type?: string | null, title?: string | null,
412
+ * commit?: boolean}} SaveOpts
413
+ * @type {(opts: SaveOpts) => Required<SaveOpts>}
414
414
  */
415
- async function saveUnlocked(
416
- projectDir,
417
- kind,
418
- given,
419
- {
420
- fields = null,
421
- text = null,
422
- base = null,
423
- system = null,
424
- type = null,
425
- title = null,
426
- commit = true,
427
- },
428
- ) {
429
- if ((fields === null) === (text === null))
430
- throw new Error('give the part once: its fields or its text');
431
- const name = given || (await newUnitId(projectDir, kind, title, type));
432
- let part = await designPart(projectDir, kind, name, { type });
433
- if (part.exists && !base)
434
- throw new Error(
435
- `${kind} ${name} exists: pass --base from gcf design part, so an edit made since is ` +
436
- `not overwritten`,
437
- );
415
+ const saveOpts = ({
416
+ fields = null,
417
+ text = null,
418
+ base = null,
419
+ system = null,
420
+ type = null,
421
+ title = null,
422
+ commit = true,
423
+ }) => ({ fields, text, base, system, type, title, commit });
424
+
425
+ /** The subsystem a part goes into; a new unit must name one. */
426
+ function ownerOf(kind, part, system) {
438
427
  const owner = part.system ?? system;
439
428
  if (kind === 'unit' && !part.exists && !SLUG_RE.test(String(owner ?? '')))
440
429
  throw new Error('a new unit needs --system: the subsystem file it goes into');
441
- const specs = await specsOf(kind, name, part.type);
430
+
431
+ return owner;
432
+ }
433
+
434
+ /**
435
+ * The pillars doc's form save renames the pillars whose names changed before it saves: the
436
+ * part read again after, its base the new one. Any other save goes on as it was given.
437
+ */
438
+ async function renameFirst(projectDir, kind, name, { part, base, fields, type, commit }) {
442
439
  const pillars = kind === 'doc' && name === 'pillars' && Array.isArray(fields?.pillars);
443
440
  const { records, renames } = pillars ? pillarIds(part, fields.pillars) : {};
444
- let edits = pillars ? { ...fields, pillars: records } : fields;
441
+ const edits = pillars ? { ...fields, pillars: records } : fields;
442
+ if (!renames?.length) return { part, base, edits, hash: null, renames };
443
+ // The rename goes first, on the part the operator read: changed since, nothing moves.
444
+ if (part.base !== base)
445
+ throw new Error(`conflict doc:pillars: ${noteOf({ outcome: 'conflict' })}`);
446
+ if (commit) await refuseLooseForRename(projectDir, renames);
447
+ /** @type {string | null} */
445
448
  let hash = null;
446
- if (renames?.length) {
447
- // The rename goes first, on the part the operator read: changed since, nothing moves.
448
- if (part.base !== base)
449
- throw new Error(`conflict doc:pillars: ${noteOf({ outcome: 'conflict' })}`);
450
- if (commit) await refuseLooseForRename(projectDir, renames);
451
- for (const [from, to] of renames)
452
- hash = (await renamePillar(projectDir, from, to, { commit })).hash;
453
- const moved = new Map(renames);
454
- edits = {
449
+ for (const [from, to] of renames)
450
+ hash = (await renamePillar(projectDir, from, to, { commit })).hash;
451
+ const moved = new Map(renames);
452
+ const read = await designPart(projectDir, kind, name, { type });
453
+
454
+ return {
455
+ part: read,
456
+ base: read.base,
457
+ edits: {
455
458
  ...edits,
456
459
  pillars: records.map((p) => (moved.has(p?.id) ? { ...p, id: moved.get(p.id) } : p)),
457
- };
458
- part = await designPart(projectDir, kind, name, { type });
459
- base = part.base;
460
- }
461
-
462
- let next = text === null ? null : lf(text).trim();
463
- if (next === null) {
464
- const start = part.exists
465
- ? part.text
466
- : kind === 'unit'
467
- ? skeleton(specs, { id: name, type: part.type, system: owner, title })
468
- : '';
469
- let lines = start ? start.split('\n') : [];
470
- // `fields` is given when `text` is not (checked above).
471
- for (const [key, value] of Object.entries(/** @type {Record<string, any>} */ (edits))) {
472
- const spec = specs.find((s) => s.key === key);
473
- if (!spec) throw new Error(`${key} is not a field of ${kind} ${name}`);
474
- const field = part.fields.find((f) => f.key === key);
475
- if (part.exists && field && !field.exact)
476
- throw new Error(`${key} holds text a form cannot keep: edit the part as text`);
477
- lines = putBlock(lines, specs, spec, renderField(spec, value));
478
- }
460
+ },
461
+ hash,
462
+ renames,
463
+ };
464
+ }
479
465
 
480
- next = lines.join('\n').trim();
466
+ /** The part's text with the form's fields put in: over what it holds, a new unit's skeleton. */
467
+ function formText(kind, name, part, { specs, owner, title, edits }) {
468
+ const start = part.exists
469
+ ? part.text
470
+ : kind === 'unit'
471
+ ? skeleton(specs, { id: name, type: part.type, system: owner, title })
472
+ : '';
473
+ let lines = start ? start.split('\n') : [];
474
+ // `fields` is given when `text` is not (checked above).
475
+ for (const [key, value] of Object.entries(/** @type {Record<string, any>} */ (edits))) {
476
+ const spec = specs.find((s) => s.key === key);
477
+ if (!spec) throw new Error(`${key} is not a field of ${kind} ${name}`);
478
+ const field = part.fields.find((f) => f.key === key);
479
+ if (part.exists && field && !field.exact)
480
+ throw new Error(`${key} holds text a form cannot keep: edit the part as text`);
481
+ lines = putBlock(lines, specs, spec, { rendered: renderField(spec, value) });
481
482
  }
482
483
 
483
- if (kind === 'unit')
484
- next = await withManualAnswers(next, changedKeys(part.text, next), part.type);
485
- if (part.exists && hashOf(next) === part.base) return { applied: [], hash: null };
484
+ return lines.join('\n').trim();
485
+ }
486
+
487
+ /** The part's new text through the import, under its marker line; nothing when it is the same. */
488
+ async function savePart(projectDir, kind, name, { part, base, owner, next, commit }) {
489
+ const text =
490
+ kind === 'unit' ? await withManualAnswers(next, changedKeys(part.text, next), part.type) : next;
491
+ if (part.exists && hashOf(text) === part.base) return null;
486
492
  // The base goes into the marker line: anything but a hash would break the bundle's shape.
487
493
  if (part.exists && !/^[0-9a-f]{8}$/.test(/** @type {string} */ (base)))
488
494
  throw new Error(`--base is the 8-hex hash gcf design part gave: ${base}`);
@@ -491,18 +497,41 @@ async function saveUnlocked(
491
497
  ...(kind === 'unit' ? [`system=${owner}`] : []),
492
498
  ...(part.exists ? [`base=${base}`] : []),
493
499
  ].join(' ');
494
- const r = await bundleMove(
495
- projectDir,
496
- `gcf(design): ${kind} ${name}`,
497
- `${marker} -->\n${next}\n`,
498
- {
499
- key: 'design-save',
500
- items: kind === 'unit' ? [name] : [],
501
- strict: true,
502
- draft: true,
503
- commit,
504
- },
505
- );
500
+
501
+ return bundleMove(projectDir, `gcf(design): ${kind} ${name}`, `${marker} -->\n${text}\n`, {
502
+ key: 'design-save',
503
+ items: kind === 'unit' ? [name] : [],
504
+ strict: true,
505
+ draft: true,
506
+ commit,
507
+ });
508
+ }
509
+
510
+ /**
511
+ * @param {string} projectDir
512
+ * @param {string} kind
513
+ * @param {string | null | undefined} given
514
+ * @param {SaveOpts} opts
515
+ */
516
+ async function saveUnlocked(projectDir, kind, given, opts) {
517
+ const { fields, text, base, system, type, title, commit } = saveOpts(opts);
518
+ if ((fields === null) === (text === null))
519
+ throw new Error('give the part once: its fields or its text');
520
+ const name = given || (await newUnitId(projectDir, kind, title, type));
521
+ const read = await designPart(projectDir, kind, name, { type });
522
+ if (read.exists && !base)
523
+ throw new Error(
524
+ `${kind} ${name} exists: pass --base from gcf design part, so an edit made since is ` +
525
+ `not overwritten`,
526
+ );
527
+ const owner = ownerOf(kind, read, system);
528
+ const specs = await specsOf(kind, name, read.type);
529
+ const now = await renameFirst(projectDir, kind, name, { part: read, base, fields, type, commit });
530
+ const { part, edits, hash, renames } = now;
531
+ const next =
532
+ text === null ? formText(kind, name, part, { specs, owner, title, edits }) : lf(text).trim();
533
+ const r = await savePart(projectDir, kind, name, { part, base: now.base, owner, next, commit });
534
+ if (!r) return { applied: [], hash: null };
506
535
 
507
536
  return { id: name, applied: r.applied, hash: r.hash ?? hash, renamed: renames ?? [] };
508
537
  }
@@ -534,7 +563,8 @@ class NothingApplied extends Error {}
534
563
  * @param {string} projectDir
535
564
  * @param {string} message
536
565
  * @param {string} text
537
- * @param {{key: string, items?: string[], strict?: boolean, draft?: boolean, commit?: boolean}} opts
566
+ * @param {{key: string, items?: string[], strict?: boolean, draft?: boolean,
567
+ * commit?: boolean}} opts
538
568
  */
539
569
  async function bundleMove(
540
570
  projectDir,
@@ -609,11 +639,12 @@ export function unrecordedDesign(projectDir, { renamed = false } = {}) {
609
639
  const res = spawnSync(
610
640
  'git',
611
641
  ['status', '--porcelain', '-z', '--untracked-files=all', '--', ...DESIGN_PATHS],
612
- { cwd: projectDir, encoding: 'utf8' },
642
+ { windowsHide: true, cwd: projectDir, encoding: 'utf8' },
613
643
  );
614
644
  if (res.status !== 0) return [];
615
645
  // git prints paths from the repository's root: a project in a subfolder strips its prefix.
616
646
  const prefix = spawnSync('git', ['rev-parse', '--show-prefix'], {
647
+ windowsHide: true,
617
648
  cwd: projectDir,
618
649
  encoding: 'utf8',
619
650
  }).stdout.trim();
package/lib/devices.js CHANGED
@@ -5,8 +5,6 @@
5
5
  // would hold an inherited pipe open on Windows.
6
6
  import { mkdir, open, readFile } from 'node:fs/promises';
7
7
  import path from 'node:path';
8
- import { readConfig } from './gcf-paths.js';
9
- import { NOT_SET_UP, playOf } from './play.js';
10
8
  import { runCommand } from './verify.js';
11
9
 
12
10
  const DEVICES_MS = 30000;
@@ -82,16 +80,13 @@ function deviceOf(v, rows) {
82
80
  const tailOf = (text) => text.trimEnd().split(/\r?\n/).slice(-20).join('\n');
83
81
 
84
82
  /**
85
- * `gcf playtest devices <target>`: what the target's script finds, each device placed under a row
86
- * of `plays_on` it fits, or why not.
83
+ * What target `targetName` of the project's `play` (playOf) finds with its script, each device
84
+ * placed under a row of `plays_on` it fits, or why not. `devicesOf` of play.js reads the config.
87
85
  * @returns {Promise<{target: string, rows: object[], devices: Array<Record<string, any>>,
88
86
  * unavailable?: string,
89
87
  * problem?: string, tail?: string}>}
90
88
  */
91
- export async function devicesOf(projectDir, targetName, { ms = DEVICES_MS } = {}) {
92
- const dir = path.resolve(projectDir);
93
- const play = playOf(await readConfig(path.join(dir, 'gcf')));
94
- if (!play) throw new Error(NOT_SET_UP);
89
+ export async function targetDevices(dir, play, targetName, { ms = DEVICES_MS } = {}) {
95
90
  const t = Object.hasOwn(play.targets, targetName) ? play.targets[targetName] : null;
96
91
  if (!t) throw new Error(`no target ${targetName}: ${Object.keys(play.targets).join(', ')}`);
97
92
  const rows = play.builds[t.build].plays_on.filter((r) => serves(t, t.build, r));
package/lib/domain.js CHANGED
@@ -212,11 +212,12 @@ const ITEM_SPECS = {
212
212
  },
213
213
  ],
214
214
  },
215
- // Planning that does not converge (Hold-Plan d16): the run's stall, the operator's two answers.
215
+ // A review that does not converge (Hold-Plan d16, Operator-Tasks-Plan t2): the plan's or the
216
+ // code's; the run's stall, the operator's two answers, which take the kind the card stands on.
216
217
  plan_stall: {
217
- label: 'planning stall',
218
- help: "The run's stop: the plan's passes keep finding blocking issues past plan_passes",
219
- args: ['gcf', 'plan', 'stall', '{id}'],
218
+ label: 'review stall',
219
+ help: "The run's stop: the review's rows are over and a pass still finds blocking issues",
220
+ args: ['gcf', 'review', 'stall', '{id}'],
220
221
  fields: [
221
222
  { key: 'passes', label: 'Blocking findings of each pass', kind: 'text', required: true },
222
223
  { key: 'reason', label: 'Reason', kind: 'longtext' },
@@ -224,8 +225,10 @@ const ITEM_SPECS = {
224
225
  },
225
226
  plan_more: {
226
227
  label: 'more passes',
227
- help: 'The plan improves N more passes, then the same check decides',
228
- args: ['gcf', 'plan', 'more', '{id}'],
228
+ help:
229
+ 'The plan or the code gets N more review passes on the last row, then the same check ' +
230
+ 'decides',
231
+ args: ['gcf', 'review', 'more', '{id}'],
229
232
  fields: [
230
233
  {
231
234
  key: 'passes',
@@ -238,9 +241,11 @@ const ITEM_SPECS = {
238
241
  ],
239
242
  },
240
243
  plan_accept: {
241
- label: 'implement as is',
242
- help: 'The plan goes to implementation as it is, its open findings with it',
243
- args: ['gcf', 'plan', 'accept', '{id}'],
244
+ label: 'go on as is',
245
+ help:
246
+ 'The plan goes to implementation, or the code to its submit, as it is, its open ' +
247
+ 'findings with it',
248
+ args: ['gcf', 'review', 'accept', '{id}'],
244
249
  fields: [],
245
250
  },
246
251
  mode: {
@@ -1014,9 +1019,9 @@ const CHANGES = [
1014
1019
  'block',
1015
1020
  'unblock',
1016
1021
  'plan pass',
1017
- 'plan stall',
1018
- 'plan more',
1019
- 'plan accept',
1022
+ 'review stall',
1023
+ 'review more',
1024
+ 'review accept',
1020
1025
  'inbox add',
1021
1026
  'inbox category',
1022
1027
  'inbox later',
package/lib/edits.js CHANGED
@@ -7,7 +7,7 @@ import { dirtyGcf, inParts, literal, restoreFromHead } from './git.js';
7
7
  import { locked } from './main-lock.js';
8
8
  import { refusal } from './refusal.js';
9
9
  import { newFileDiff } from './tree-file.js';
10
- import { commitMove } from './unit-ops.js';
10
+ import { commitMove } from './commit-move.js';
11
11
 
12
12
  /** A path from the project with `/`: the form dirtyGcf gives and a refusal names. */
13
13
  const norm = (projectDir, p) =>
@@ -39,8 +39,11 @@ function changed(projectDir, paths, verb) {
39
39
  }
40
40
 
41
41
  const git = (projectDir, ...args) =>
42
- spawnSync('git', ['-c', 'core.quotePath=false', ...args], { cwd: projectDir, encoding: 'utf8' })
43
- .stdout ?? '';
42
+ spawnSync('git', ['-c', 'core.quotePath=false', ...args], {
43
+ windowsHide: true,
44
+ cwd: projectDir,
45
+ encoding: 'utf8',
46
+ }).stdout ?? '';
44
47
 
45
48
  /** Literal pathspecs: a `[` in a name is no glob that takes its siblings along. */
46
49
  const lits = (projectDir, files) => files.map((f) => literal(projectDir, f));
@@ -81,6 +84,7 @@ const diffOf = (projectDir, opts, files) =>
81
84
 
82
85
  const tracked = (projectDir, f) =>
83
86
  spawnSync('git', ['ls-files', '--error-unmatch', '--', literal(projectDir, f)], {
87
+ windowsHide: true,
84
88
  cwd: projectDir,
85
89
  stdio: 'ignore',
86
90
  }).status === 0;
package/lib/frozen.js ADDED
@@ -0,0 +1,24 @@
1
+ // The `frozen:` stamp of an unplayed item (Methodology §5.4): the hash a tune or a kill checks
2
+ // before it takes the item's lines back out of systems/ and LIVE.md.
3
+ import { createHash } from 'node:crypto';
4
+
5
+ /**
6
+ * The hash an unplayed item is frozen at (Methodology §5.4): its body and its `live:` delta —
7
+ * the two things a tune or a kill takes back out of systems/ and LIVE.md.
8
+ */
9
+ export const frozenHash = (item) =>
10
+ createHash('sha1')
11
+ .update(String(item.body).replace(/\r\n/g, '\n').trim())
12
+ .update(`\nlive: ${JSON.stringify(item.data.live ?? null)}`)
13
+ .digest('hex');
14
+
15
+ /** The 0.4.0 `frozen:`: the sha1 of the body alone, without the `live:` delta. */
16
+ export const legacyFrozen = (item) =>
17
+ createHash('sha1').update(String(item.body).replace(/\r\n/g, '\n').trim()).digest('hex');
18
+
19
+ /**
20
+ * Whether an unplayed item still matches its `frozen:`. An item closed by 0.4.0 holds the
21
+ * legacy form, which guards the body only, until `gcf init` restamps it (restampFrozen).
22
+ */
23
+ export const matchesFrozen = (item) =>
24
+ item.data.frozen === frozenHash(item) || item.data.frozen === legacyFrozen(item);
package/lib/gate.js CHANGED
@@ -9,7 +9,7 @@ import { stemMatches } from './id.js';
9
9
  import { lint } from './linter.js';
10
10
  import { buildLedger } from './ledger.js';
11
11
  import { designCheck } from './design-check.js';
12
- import { matchesFrozen } from './work-ops.js';
12
+ import { matchesFrozen } from './frozen.js';
13
13
  import { checkLive } from './live.js';
14
14
 
15
15
  /** Problems of form: legacy cards, item frontmatter and filenames, `until` grammar. */
package/lib/gcf-paths.js CHANGED
@@ -14,7 +14,6 @@ export const DEFAULT_CONFIG = {
14
14
  pillars_budget: 1500,
15
15
  envelope_default_spread: 0.3,
16
16
  unplayed_warn_after: 5,
17
- plan_passes: 3,
18
17
  dod_attempts: 2,
19
18
  // Minutes a dod.test or dod.build command may take before it is killed (0: no limit).
20
19
  dod_timeout_min: 60,
@@ -110,6 +109,73 @@ function gatesOf(v = {}) {
110
109
  );
111
110
  }
112
111
 
112
+ // The review passes of a plan and of the code (Operator-Tasks-Plan t2 d1): row k makes pass k,
113
+ // the next goes only while the last found something blocking; the rows over, the operator
114
+ // decides. An empty list: no review of that kind.
115
+ export const REVIEW_AGENTS = ['claude', 'codex'];
116
+ export const REVIEW_DEFAULTS = {
117
+ plan: [
118
+ { agent: 'claude', model: 'opus', effort: 'high' },
119
+ { agent: 'claude', model: 'opus', effort: 'high' },
120
+ { agent: 'codex', model: 'astra', effort: 'medium' },
121
+ ],
122
+ code: [
123
+ { agent: 'claude', model: 'opus', effort: 'high' },
124
+ { agent: 'claude', model: 'opus', effort: 'high' },
125
+ ],
126
+ };
127
+
128
+ /** A review row's refusal, if any: three plain words, the agent one GCF runs. */
129
+ export function reviewRowProblem(r) {
130
+ if (typeof r !== 'object' || r === null || Array.isArray(r))
131
+ return 'a row is {agent, model, effort}';
132
+ if (!REVIEW_AGENTS.includes(r.agent))
133
+ return `agent must be ${REVIEW_AGENTS.join(' | ')}, got ${r.agent}`;
134
+ for (const k of ['model', 'effort'])
135
+ if (typeof r[k] !== 'string' || !RUN_WORD.test(r[k])) return `${k} must be one plain word`;
136
+
137
+ return null;
138
+ }
139
+
140
+ /**
141
+ * The one command that moves a config from before t2 (`plan_passes`, `plan_review:`) to
142
+ * `review.plan` (t2 d1), or null: `plan_passes N` gives N Claude rows, the pass `plan_review.at`
143
+ * the outside reviewer's (Codex unless `agent: none`). `config set review.*` drops the old keys.
144
+ * @param {Record<string, any>} raw config.yml as the file has it
145
+ */
146
+ export function reviewMigration(raw) {
147
+ const old = raw?.plan_review;
148
+ if (raw?.plan_passes === undefined && old === undefined) return null;
149
+ const n = Number.isInteger(raw.plan_passes) ? raw.plan_passes : 3;
150
+ const at = Number(old?.at ?? 3);
151
+ const codex = (old?.agent ?? 'codex') === 'codex';
152
+ const rows = Array.from({ length: n }, (_, k) =>
153
+ codex && k + 1 === at
154
+ ? `codex:${old?.model ?? 'astra'}:${old?.effort ?? 'medium'}`
155
+ : 'claude:opus:high',
156
+ );
157
+
158
+ return `ai-factory gcf config set review.plan --value "${rows.join(', ') || 'none'}"`;
159
+ }
160
+
161
+ function reviewOf(v = {}) {
162
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
163
+ throw new Error('gcf/config.yml: review must map plan and code to their rows');
164
+ const out = {};
165
+ for (const kind of ['plan', 'code']) {
166
+ const rows = v[kind] ?? REVIEW_DEFAULTS[kind];
167
+ if (!Array.isArray(rows))
168
+ throw new Error(`gcf/config.yml: review.${kind} must be a list of rows`);
169
+ rows.forEach((r, n) => {
170
+ const why = reviewRowProblem(r);
171
+ if (why) throw new Error(`gcf/config.yml: review.${kind} row ${n + 1}: ${why}`);
172
+ });
173
+ out[kind] = rows.map(({ agent, model, effort }) => ({ agent, model, effort }));
174
+ }
175
+
176
+ return out;
177
+ }
178
+
113
179
  // Files listed and never opened on the board's Changes screen (Board-PRD §5.25): the project's
114
180
  // call, GCF names no stack's files.
115
181
  function noDiffOf(v = []) {
@@ -131,6 +197,18 @@ export async function readRawConfig(root) {
131
197
  return existsSync(file) ? (YAML.parse(await readFile(file, 'utf8')) ?? {}) : {};
132
198
  }
133
199
 
200
+ function checkLimits(config) {
201
+ // A limit that is not a number compares false against everything, which silently
202
+ // switches its gate off — the one failure a gate must not have.
203
+ for (const key of Object.keys(DEFAULT_CONFIG)) {
204
+ if (!Number.isFinite(config[key]) || config[key] < 0) {
205
+ throw new Error(
206
+ `gcf/config.yml: ${key} must be a non-negative number, got ${JSON.stringify(config[key])}`,
207
+ );
208
+ }
209
+ }
210
+ }
211
+
134
212
  /**
135
213
  * The config a parsed config.yml gives, checked: defaults for what it does not set, every limit
136
214
  * a non-negative number, the shares 0-100, the run mode one of RUN_MODES, the chat as chatOf
@@ -147,16 +225,7 @@ export function configOf(parsed) {
147
225
  ...DEFAULT_CONFIG,
148
226
  ...Object.fromEntries(Object.entries(parsed).filter(([, v]) => v !== null)),
149
227
  };
150
- // A limit that is not a number compares false against everything, which silently
151
- // switches its gate off — the one failure a gate must not have.
152
- for (const key of Object.keys(DEFAULT_CONFIG)) {
153
- if (!Number.isFinite(config[key]) || config[key] < 0) {
154
- throw new Error(
155
- `gcf/config.yml: ${key} must be a non-negative number, got ${JSON.stringify(config[key])}`,
156
- );
157
- }
158
- }
159
-
228
+ checkLimits(config);
160
229
  if (config.session_timeout_min === 0)
161
230
  throw new Error('gcf/config.yml: session_timeout_min must be above 0: a session needs a limit');
162
231
  for (const key of PCT_KEYS)
@@ -176,6 +245,7 @@ export function configOf(parsed) {
176
245
  chat: chatOf(config.chat),
177
246
  gates: gatesOf(config.gates),
178
247
  no_diff: noDiffOf(config.no_diff),
248
+ review: reviewOf(config.review),
179
249
  };
180
250
  }
181
251
 
package/lib/git.js CHANGED
@@ -46,6 +46,7 @@ const IN_PROGRESS = [
46
46
  /** The name of the merge or sequencer operation in progress, or null. */
47
47
  export function operationInProgress(projectDir) {
48
48
  const gitDir = spawnSync('git', ['rev-parse', '--git-dir'], {
49
+ windowsHide: true,
49
50
  cwd: projectDir,
50
51
  encoding: 'utf8',
51
52
  });
@@ -63,6 +64,7 @@ export const literal = (projectDir, p) => `:(literal)${relOf(projectDir, p)}`;
63
64
 
64
65
  const tracked = (projectDir, p) =>
65
66
  spawnSync('git', ['ls-files', '--error-unmatch', '--', literal(projectDir, p)], {
67
+ windowsHide: true,
66
68
  cwd: projectDir,
67
69
  stdio: 'ignore',
68
70
  }).status === 0;
@@ -70,6 +72,7 @@ const tracked = (projectDir, p) =>
70
72
  /** Whether the last commit holds `p`: a file only staged is not in it. */
71
73
  export const inHead = (projectDir, p) =>
72
74
  spawnSync('git', ['ls-tree', '--name-only', 'HEAD', '--', p], {
75
+ windowsHide: true,
73
76
  cwd: projectDir,
74
77
  encoding: 'utf8',
75
78
  }).stdout?.trim() !== '';
@@ -83,6 +86,7 @@ export function dirtyPaths(projectDir, paths) {
83
86
  // writing that file anew would commit away every line the deleted file held.
84
87
  if (!paths.length) return [];
85
88
  const res = spawnSync('git', ['status', '--porcelain', '--', ...paths], {
89
+ windowsHide: true,
86
90
  cwd: projectDir,
87
91
  encoding: 'utf8',
88
92
  });
@@ -116,11 +120,12 @@ export function dirtyGcf(projectDir, skip = []) {
116
120
  const res = spawnSync(
117
121
  'git',
118
122
  ['-c', 'core.quotePath=false', 'status', '--porcelain', '-z', '-uall', '--', ...GATE_SCOPE],
119
- { cwd: projectDir, encoding: 'utf8' },
123
+ { windowsHide: true, cwd: projectDir, encoding: 'utf8' },
120
124
  );
121
125
  if (res.status !== 0) return [];
122
126
  // Porcelain paths are the repository's: a project inside a bigger repository is a prefix in.
123
127
  const prefix = spawnSync('git', ['rev-parse', '--show-prefix'], {
128
+ windowsHide: true,
124
129
  cwd: projectDir,
125
130
  encoding: 'utf8',
126
131
  }).stdout.trim();
@@ -166,7 +171,8 @@ const relOf = (projectDir, p) =>
166
171
  * @param {string[]} files
167
172
  */
168
173
  export function restoreFromHead(projectDir, files) {
169
- const git = (...args) => spawnSync('git', args, { cwd: projectDir, encoding: 'utf8' });
174
+ const git = (...args) =>
175
+ spawnSync('git', args, { windowsHide: true, cwd: projectDir, encoding: 'utf8' });
170
176
  const must = (...args) => {
171
177
  const r = git(...args);
172
178
  if (r.status !== 0) throw new Error(`git ${args.join(' ')}: ${r.stderr.trim()}`);
@@ -272,7 +278,11 @@ function commitRefusal(message, out) {
272
278
  export function commitPaths(projectDir, message, paths, move = {}) {
273
279
  const staged = paths.filter((p) => existsSync(p) || tracked(projectDir, p));
274
280
  for (const p of staged)
275
- spawnSync('git', ['add', '--', literal(projectDir, p)], { cwd: projectDir, stdio: 'ignore' });
281
+ spawnSync('git', ['add', '--', literal(projectDir, p)], {
282
+ windowsHide: true,
283
+ cwd: projectDir,
284
+ stdio: 'ignore',
285
+ });
276
286
  // A staged deletion (`git rm`) is off the disk and out of the index, but HEAD holds it: its
277
287
  // path commits the deletion. A file staged but never committed and now deleted matches
278
288
  // nothing: no pathspec.
@@ -302,6 +312,7 @@ export function commitOnly(projectDir, message, paths, msg) {
302
312
  ...(long ? ['--pathspec-from-file=-', '--pathspec-file-nul'] : ['--', ...only]),
303
313
  ],
304
314
  {
315
+ windowsHide: true,
305
316
  cwd: projectDir,
306
317
  encoding: 'utf8',
307
318
  ...(long && { input: only.map((p) => `${p}\0`).join('') }),
@@ -322,6 +333,7 @@ export function commitOnly(projectDir, message, paths, msg) {
322
333
  if (res.status !== 0) throw commitRefusal(message, out);
323
334
 
324
335
  return spawnSync('git', ['rev-parse', 'HEAD'], {
336
+ windowsHide: true,
325
337
  cwd: projectDir,
326
338
  encoding: 'utf8',
327
339
  }).stdout.trim();
@@ -341,6 +353,7 @@ export function snapshotIndex(cwd, files) {
341
353
  let stdout = '';
342
354
  for (const part of inParts(rels)) {
343
355
  const res = spawnSync('git', ['ls-files', '-s', '-z', '--', ...part], {
356
+ windowsHide: true,
344
357
  cwd,
345
358
  encoding: 'utf8',
346
359
  });
@@ -349,6 +362,7 @@ export function snapshotIndex(cwd, files) {
349
362
  }
350
363
 
351
364
  const prefix = spawnSync('git', ['rev-parse', '--show-prefix'], {
365
+ windowsHide: true,
352
366
  cwd,
353
367
  encoding: 'utf8',
354
368
  }).stdout.trim();
@@ -385,7 +399,7 @@ export function restoreIndex(snapshot) {
385
399
  `${entry.mode},${entry.blob},${snapshot.prefix}${rel}`,
386
400
  ]
387
401
  : ['update-index', '--force-remove', '--', rel];
388
- const res = spawnSync('git', args, { cwd: snapshot.cwd, encoding: 'utf8' });
402
+ const res = spawnSync('git', args, { windowsHide: true, cwd: snapshot.cwd, encoding: 'utf8' });
389
403
  const reason = (res.stderr || '').trim() || res.error?.message;
390
404
  if (res.status !== 0)
391
405
  errors.push(new Error(`could not restore the index entry of ${rel}: ${reason}`));