gcf-aif-ext 0.18.9 → 0.20.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.
package/README.md CHANGED
@@ -50,6 +50,33 @@ Updating preserves `gcf/`, `cnlp.config.json` and the pre-commit hook. Run `ai-f
50
50
 
51
51
  On Windows, run `extension add` and `extension update` from PowerShell or cmd, not Git Bash: the installer unpacks with `tar`, and Git Bash's GNU tar reads `C:\…` as a remote host (`Cannot connect to C: resolve failed`). The Windows `tar.exe` handles it.
52
52
 
53
+ ### 0.20.0
54
+
55
+ - `edits diff|commit|discard --path <p>…`: the hand edits under `gcf/` that a move's refusal names. `diff` shows the staged part and the part not staged (`--json`); `commit` records them as they are, `gcf(edit): <n> files`, through the gate; `discard` puts them back as the last commit has them, a new file deleted. Commit and discard are the operator's moves: a run and a board thread are refused, and the deny group `human-moves` holds them.
56
+ - A move refused for uncommitted `gcf/` edits (its own files, the commit gate, a milestone's keep) ends its error with one machine line, `gcf-refusal: {"code":"dirty","paths":[…]}`: every dirty path under the gate's scope, from git, with `/`. A board offers Show diff, Commit and Discard from it. The words for people stay as they were.
57
+ - The domain lets a project chat agent propose `verdict:*`, `decide:*`, `unblock` and `question-answer` (`propose: true`); `sections.edits` names the two edit moves. The reason of every move into the graveyard (`verdict:kill` note, `decide:no|wontfix|kill` reason) is `required` in its form: the core refused it without one already.
58
+ - The gcf-chat skill and the AGENTS.md block: a verdict is proposed only after the human said they played the item, its note in their words; `remove` is left to the rule unless the human says otherwise; hand edits are the human's.
59
+
60
+ ### 0.19.2
61
+
62
+ - A write retries its rename a few times when Windows refuses it (`EPERM`, `EACCES`, `EBUSY`: an antivirus or indexer holds the file open). A rollback's delete of a file the move created retries too. A move's rollback no longer stops halfway and leaves `gcf/` half-written.
63
+
64
+ ### 0.19.1
65
+
66
+ - `verdict <milestone> keep --milestone` that fails, its commit too, puts the pack's items back with the index as the operator left it: a staged compress edit stays staged.
67
+ - The deny group `git-history` also holds `git push <remote> :<branch>`, which deletes the remote branch.
68
+
69
+ ### 0.19.0
70
+
71
+ Autonomy (docs/Autonomy-Plan.md): the agent works by itself, the operator plays the milestones.
72
+ - The core holds the operator's moves: `verdict`, `decide` (but under the gates), `drop` of a work item, `unblock`, `question answer`, `config set`, `permissions`, `phase next`, `pillar`, `hooks-install` and `item gates` refuse a harness run and a board thread (`GCF-By: thread`). A console session and the operator pass.
73
+ - `gates:` in `gcf/config.yml`: `milestone` wait|go, `verdict` wait|defer (a mechanic's or resource's submit closes it unplayed), `decision` wait|agent (a run decides go or no of its own spike, with `--reason`), `question` wait|assume. A card's `skip_gates`: `ai-factory gcf item gates <id> --to skip|wait|project`. `config set --pair key=value …` sets several keys in one commit.
74
+ - A soft unit whose delta modifies or removes a capability no longer refuses its close: it waits for a verdict, `gate_why: modifies <capability>`.
75
+ - `--assume "<question> = <value>"` on `submit`, `close`, `decide` files a D2 in the move's commit; `ai-factory gcf question add --class D1|D2 …` files one alone. `decide`'s reason goes into its commit.
76
+ - The integrator reads a worktree plan's `## Outcome` (`decide:`, `reason:`, `assume:`) and records it in the item's move, one commit.
77
+ - Milestones: `take --milestone <name>`; a mechanic or resource with a milestone is gate auto; a feature needs one while `game.md` lists them; `verdict <milestone> keep --milestone` keeps all of it that waits for play; `verdict keep --played-on "<line>"`. `gcf audit --json` and `gcf board --json` give `milestones`, `build_milestone`, `play_milestone`, `milestone_order`, and each item's `gates`; the playtest sheet goes by milestone; phases count every milestone up to theirs.
78
+ - The deny group `git-destroy` is `git-history` and `git-discard` (`stash list` and `show` are free); the old id names both.
79
+
53
80
  ### 0.18.9
54
81
 
55
82
  - `gcf design import --commit` that applied some parts and refused others exits 0: it committed what it applied, and the refused parts stay in its report. Before, it exited 1 and gcf-board showed the move as failed. A plain import and an import that applied nothing still exit 1.
@@ -207,7 +234,7 @@ Update together with gcf-harness-aif-ext 0.12.0 and gcf-board 0.6.0 (docs/Sessio
207
234
 
208
235
  ### 0.7.6
209
236
 
210
- - `ai-factory gcf permissions [--on <group>] [--off <group>] [--deny <rule>] [--undeny <rule>]` — what agent runs may not do: deny groups and the human's own rules in the `agent:` section of `gcf/config.yml`, one `gcf(permissions)` commit; with no change it lists them. On by default: `git-destroy`, `mass-delete`, `publish`, `human-moves`, `guards`; off: `secrets`, `outside`, `processes`. `agent.groups` keeps only the human's choices (`secrets: true`): a group it does not name keeps its default, so one a later version adds comes on. `git push` is in none. `gcf board --json` carries `agent` (`groups`, `deny_extra`, the resolved `deny`, `allow`).
237
+ - `ai-factory gcf permissions [--on <group>] [--off <group>] [--deny <rule>] [--undeny <rule>]` — what agent runs may not do: deny groups and the human's own rules in the `agent:` section of `gcf/config.yml`, one `gcf(permissions)` commit; with no change it lists them. On by default: `git-history` (force push, `branch -D`, stash entries dropped), `git-discard` (`reset --hard`, `clean`, stash; `stash list` and `show` are free; the old `git-destroy` names both), `mass-delete`, `publish`, `human-moves`, `guards`; off: `secrets`, `outside`, `processes`. `agent.groups` keeps only the human's choices (`secrets: true`): a group it does not name keeps its default, so one a later version adds comes on. `git push` is in none. `gcf board --json` carries `agent` (`groups`, `deny_extra`, the resolved `deny`, `allow`).
211
238
  - New `config.yml` keys for harness runs: `context_handoff_pct` (60; 0 turns the handoff off), `context_window` (0: the model's) and `auto_compact_pct` (0: the agent's default; at least the handoff share + 15). `gcf board --json` carries them as `context`; a kept session that handed over reads `resume: {ended: 'handoff', handoffs}`.
212
239
  - The AGENTS.md block tells the agent that the permissions are the human's.
213
240
 
@@ -326,6 +353,7 @@ Removal leaves `gcf/` and `cnlp.config.json` in place. It also leaves the pre-co
326
353
  - project phase and board — `phase`, `phase next [--reason]`, `board [--json]` (everything a board shows, in one read)
327
354
  - branches — `worktree <id>`, `verify <id> --mark`, `integrate [<id>...]`: a run in its own worktree, the `GCF-Verified` trailer, the merge into main and the move; every committed move holds `.gcf-session/main.lock`
328
355
  - design and sources — `design check`, `design export`, `design import`, `design part`, `design save`, `design discard`, `design commit`, `design migrate`, `anchor`, `section`, `quotes`, `lint`
356
+ - hand edits under `gcf/` — `edits diff|commit|discard --path <p>…`: what a move's `dirty` refusal names, shown, committed or put back
329
357
  - setup — `init`, `index`, `hooks-install`
330
358
 
331
359
  Every move of an item makes one commit `gcf(<move>): <id>` with every file it touched — the item, history or graveyard, `LIVE.md`, the systems documents, the parent feature, a removal item, the archived plan. `take`, `item new` and `inbox` do not commit. These are plain Node scripts with no LLM in the loop: the same functions the skills call, the pre-commit gate runs, and the harness gates against.
package/commands/gcf.js CHANGED
@@ -25,6 +25,7 @@ const verifiedMove = (o) => ({
25
25
  requireVerify: true,
26
26
  unverified: o.unverified === undefined ? undefined : reasonOf(o.unverified),
27
27
  unticked: o.unticked === undefined ? undefined : reasonOf(o.unticked),
28
+ assume: o.assume,
28
29
  });
29
30
 
30
31
  /** The reason of `--unverified`, one line in the commit's subject; an empty one is no reason. */
@@ -45,6 +46,36 @@ const claimedBy = (o, id) => {
45
46
  if (o.claimed) process.env.GCF_RUN_ITEM = id;
46
47
  };
47
48
 
49
+ /** Refuse the operator's move from a harness run or a board thread (lib/git.js needOperator). */
50
+ const operatorOnly = async (move) => (await lib('git')).needOperator(move);
51
+
52
+ /**
53
+ * decide: the operator's, or a run's under the gates' policy (lib/gates.js agentDecideProblem);
54
+ * a board thread proposes it.
55
+ */
56
+ async function deciderMay(id, choice, reason) {
57
+ const by = (await lib('git')).moveBy();
58
+ if (by === 'thread') return operatorOnly('decide');
59
+ if (by !== 'run') return;
60
+ // Its own item only: a run's session decides the spike it drives, not another one.
61
+ const own = process.env.GCF_RUN_ITEM;
62
+ if (own && own !== id)
63
+ throw new Error(
64
+ `decide is the operator's here: ${id} is not the item this run drives (${own})`,
65
+ );
66
+ const item = (await (await lib('ledger')).buildLedger(process.cwd())).item(id);
67
+ if (!item) return;
68
+ const { gcfRoot, readConfig } = await lib('gcf-paths');
69
+ const config = await readConfig(gcfRoot());
70
+ const problem = (await lib('gates')).agentDecideProblem(config, item.data, choice, reason);
71
+ if (problem) throw new Error(problem);
72
+ }
73
+
74
+ const ASSUME =
75
+ "an assumption you took instead of asking: a D2 record in the move's commit, " +
76
+ '"<question> = <value>" (repeatable)';
77
+ const repeated = (v, p) => [...p, v];
78
+
48
79
  /** A session's own command on its item keeps the item's running mark fresh. */
49
80
  const touchSession = async (id) => (await lib('session-mark')).touchSession(process.cwd(), id);
50
81
 
@@ -328,7 +359,7 @@ function sessionHead(s) {
328
359
  }
329
360
 
330
361
  /** The session sheet: the build, then per item what to check and how to get there. */
331
- function sessionText(s) {
362
+ export function sessionText(s) {
332
363
  const lines = sessionHead(s);
333
364
  const decide = s.decisions.length
334
365
  ? [
@@ -341,8 +372,21 @@ function sessionText(s) {
341
372
  : [];
342
373
  if (!s.items.length) return [...lines, 'nothing waits for a playtest', ...decide].join('\n');
343
374
  let group = null;
344
- // Items come sorted by their first subsystem: one header each, so play goes system by system.
375
+ let slice;
376
+ const known = new Map((s.milestones ?? []).map((m) => [m.name, m]));
377
+ // Items come sorted by milestone, then first subsystem: a milestone is played as one slice,
378
+ // its question first, then system by system.
345
379
  for (const c of s.items) {
380
+ const m = known.get(c.milestone) ?? null;
381
+ if (slice === undefined || (m?.name ?? null) !== slice) {
382
+ lines.push('', m ? `# ${m.name}${m.goal ? `: ${m.goal}` : ''}` : '# no milestone');
383
+ if (m?.play) lines.push(`play: ${m.play}`);
384
+ if (m && (m.building || m.blocked))
385
+ lines.push(`still building ${m.building}, blocked ${m.blocked}`);
386
+ slice = m?.name ?? null;
387
+ group = null;
388
+ }
389
+
346
390
  const system = c.system[0] ?? '(no subsystem)';
347
391
  if (system !== group) lines.push('', `## ${system}`);
348
392
  group = system;
@@ -351,6 +395,7 @@ function sessionText(s) {
351
395
  `[ ] ${c.id} (${c.status}) [${c.system.join(',')}] ${c.title ?? c.intent ?? ''}`,
352
396
  );
353
397
  lines.push(` check: ${c.question}`);
398
+ if (c.play_on?.length) lines.push(` play on: ${c.play_on.join('; ')}`);
354
399
  for (const r of c.reach) lines.push(` try: ${r}`);
355
400
  for (const f of c.feel) lines.push(` feel: ${f}`);
356
401
  }
@@ -418,14 +463,39 @@ function registerVerdict(gcf) {
418
463
  [],
419
464
  ),
420
465
  )
466
+ .option(
467
+ '--played-on <line>',
468
+ 'where you played it, a line of platforms in game.md (repeatable; a note, not a must)',
469
+ repeated,
470
+ [],
471
+ )
472
+ .option(
473
+ '--milestone',
474
+ 'the first argument names a milestone: keep all of it that waits for play, one commit',
475
+ )
421
476
  .option('--no-commit', 'skip the verdict commit (tests only)')
422
477
  .action(async (itemId, verdict, opts) => {
423
- const { verdictItem } = await lib('work-ops');
478
+ await operatorOnly('verdict');
479
+ const { keepMilestone, verdictItem } = await lib('work-ops');
480
+ if (opts.milestone) {
481
+ if (verdict !== 'keep')
482
+ throw new Error('a milestone takes keep only: tune or kill per item');
483
+ const r = await keepMilestone(process.cwd(), itemId, {
484
+ note: opts.note ?? '',
485
+ playedOn: opts.playedOn,
486
+ commit: opts.commit,
487
+ });
488
+ console.log(`keep ${r.milestone} → ${r.ids.join(', ')}${shortHash(r.hash)}`);
489
+
490
+ return;
491
+ }
492
+
424
493
  const res = await verdictItem(process.cwd(), itemId, verdict, {
425
494
  note: opts.note ?? '',
426
495
  tags: splitList(opts.tags),
427
496
  remove: opts.remove,
428
497
  constraints: opts.constraint,
498
+ playedOn: opts.playedOn,
429
499
  commit: opts.commit,
430
500
  });
431
501
  console.log(
@@ -674,6 +744,49 @@ function registerDesignParts(design) {
674
744
  });
675
745
  }
676
746
 
747
+ function registerEdits(gcf) {
748
+ const edits = () => lib('edits');
749
+ const group = gcf
750
+ .command('edits')
751
+ .description(
752
+ "Hand edits under gcf/ that a move's refusal names: show them; commit or discard them " +
753
+ "(the human's)",
754
+ );
755
+ const PATH = 'a path from the project, as the refusal lists it (repeatable)';
756
+ group
757
+ .command('diff')
758
+ .description('The edits of these paths: the staged part and the part not staged')
759
+ .requiredOption('--path <path>', PATH, repeated, [])
760
+ .option('--json', '{files, staged, unstaged}')
761
+ .action(async (o) => {
762
+ const r = (await edits()).editsDiff(process.cwd(), o.path);
763
+ if (o.json) return out(true, r);
764
+ if (r.staged) console.log(`staged:\n${r.staged}`);
765
+ if (r.unstaged) console.log(`not staged:\n${r.unstaged}`);
766
+ });
767
+ group
768
+ .command('commit')
769
+ .description('Commit the hand edits of these paths as they are: gcf(edit), through the gate')
770
+ .requiredOption('--path <path>', PATH, repeated, [])
771
+ .action(async (o) => {
772
+ await operatorOnly('edits commit');
773
+ const r = await (await edits()).editsCommit(process.cwd(), o.path);
774
+ console.log(`committed ${r.files.join(', ')}${shortHash(r.hash)}`);
775
+ });
776
+ group
777
+ .command('discard')
778
+ .description(
779
+ 'Put these paths back as the last commit has them, the index too; a new file goes. ' +
780
+ 'It cannot be undone: look at edits diff first',
781
+ )
782
+ .requiredOption('--path <path>', PATH, repeated, [])
783
+ .action(async (o) => {
784
+ await operatorOnly('edits discard');
785
+ const r = await (await edits()).editsDiscard(process.cwd(), o.path);
786
+ console.log(`discarded ${r.files.join(', ')}`);
787
+ });
788
+ }
789
+
677
790
  function registerMigrate(design) {
678
791
  design
679
792
  .command('migrate')
@@ -726,8 +839,14 @@ function registerMoves(gcf) {
726
839
  .command('take <ids...>')
727
840
  .description('Move ready units from gcf/design/ into work items gcf/work/<id>.md (no commit)')
728
841
  .option('--feature <id>', 'group them under this feature item, new or live')
842
+ .option('--milestone <name>', 'the milestone of game.md a unit without its own is played with')
729
843
  .action(async (ids, o) => {
730
- const r = await (await ops()).takeUnits(process.cwd(), ids, { feature: o.feature ?? null });
844
+ const r = await (
845
+ await ops()
846
+ ).takeUnits(process.cwd(), ids, {
847
+ feature: o.feature ?? null,
848
+ milestone: o.milestone ?? null,
849
+ });
731
850
  console.log(r.items.join('\n'));
732
851
  });
733
852
  gcf
@@ -760,6 +879,8 @@ function registerMoves(gcf) {
760
879
  const tags = splitList(o.tags);
761
880
  const { buildLedger } = await lib('ledger');
762
881
  const isItem = (await buildLedger(process.cwd())).item(id);
882
+ // A unit's drop stays the agent's: gcf-card drops one that already ships on the human's yes.
883
+ if (isItem) await operatorOnly('drop of a work item');
763
884
  const r = isItem
764
885
  ? await (
765
886
  await lib('work-ops')
@@ -904,6 +1025,25 @@ function registerAgent(item) {
904
1025
  ).setRunMode(process.cwd(), id, { run: o.run, commit: o.commit });
905
1026
  console.log(`${id} runs in ${r.run_mode ?? "the project's run_mode"}${shortHash(r.hash)}`);
906
1027
  });
1028
+ item
1029
+ .command('gates <id>')
1030
+ .description(
1031
+ "The operator's choice of an item's stops: skip (verdict defer, decision agent, question " +
1032
+ "assume), wait, or the project's gates: (commit)",
1033
+ )
1034
+ .requiredOption(
1035
+ '--to <choice>',
1036
+ "skip (the agent goes on), wait (they wait for you), project (the project's gates: hold)",
1037
+ )
1038
+ .option('--no-commit', 'skip the commit (tests only)')
1039
+ .action(async (id, o) => {
1040
+ await operatorOnly('item gates');
1041
+ const r = await (
1042
+ await lib('work-ops')
1043
+ ).setGates(process.cwd(), id, { gates: o.to, commit: o.commit });
1044
+ const now = { true: 'skip', false: 'wait', null: "the project's" }[String(r.skip_gates)];
1045
+ console.log(`${id} gates: ${now}${shortHash(r.hash)}`);
1046
+ });
907
1047
  }
908
1048
 
909
1049
  function registerAttach(item) {
@@ -960,17 +1100,51 @@ function registerItemMoves(gcf) {
960
1100
  .requiredOption('--text <text>', 'the answer, one line')
961
1101
  .option('--no-commit', 'skip the commit (tests only)')
962
1102
  .action(async (qid, o) => {
1103
+ await operatorOnly('question answer');
963
1104
  const r = await (
964
1105
  await lib('questions')
965
1106
  ).answerQuestion(process.cwd(), qid, o.text, { commit: o.commit });
966
1107
  console.log(`answered ${r.id}${shortHash(r.hash)}`);
967
1108
  });
1109
+ question
1110
+ .command('add')
1111
+ .description(
1112
+ 'File a question only the human answers (D1, --blocks the units it holds) or your ' +
1113
+ 'assumption (D2, --assumed the value you took): commit gcf(question)',
1114
+ )
1115
+ .requiredOption('--class <class>', 'D1 or D2')
1116
+ .requiredOption('--question <text>', 'the question, one line')
1117
+ .option('--proposed <text>', 'your proposed answer (D1)')
1118
+ .option('--assumed <text>', 'the value you took (D2)')
1119
+ .option('--blocks <ids>', 'the units or items a D1 holds, comma-separated')
1120
+ .option('--until <trigger>', 'when a D2 comes back: verdict(<id>), retune(<sys>), manual(...)')
1121
+ .option('--sys <list>', 'the subsystems it is about, comma-separated')
1122
+ .option('--no-commit', 'skip the commit (tests only)')
1123
+ .action(async (o) => {
1124
+ const r = await (
1125
+ await lib('questions')
1126
+ ).addQuestion(
1127
+ process.cwd(),
1128
+ {
1129
+ class: o.class,
1130
+ question: o.question,
1131
+ proposed: o.proposed,
1132
+ assumed: o.assumed,
1133
+ blocks: o.blocks,
1134
+ until: o.until,
1135
+ sys: o.sys,
1136
+ },
1137
+ { commit: o.commit },
1138
+ );
1139
+ console.log(`${r.id}${shortHash(r.hash)}`);
1140
+ });
968
1141
  gcf
969
1142
  .command('submit <id>')
970
1143
  .description('ready → awaiting-verdict / awaiting-decision (commit gcf(submit))')
971
1144
  .option('--claimed', CLAIMED)
972
1145
  .option('--unverified <why>', UNVERIFIED)
973
1146
  .option('--unticked <why>', UNTICKED)
1147
+ .option('--assume <line>', ASSUME, repeated, [])
974
1148
  .option('--no-commit', 'skip the commit (tests only)')
975
1149
  .action(async (id, o) => {
976
1150
  claimedBy(o, id);
@@ -989,6 +1163,7 @@ function registerItemMoves(gcf) {
989
1163
  .option('--claimed', CLAIMED)
990
1164
  .option('--unverified <why>', UNVERIFIED)
991
1165
  .option('--unticked <why>', UNTICKED)
1166
+ .option('--assume <line>', ASSUME, repeated, [])
992
1167
  .option('--no-commit', 'skip the commit (tests only)')
993
1168
  .action(async (id, o) => {
994
1169
  claimedBy(o, id);
@@ -1005,15 +1180,18 @@ function registerDecide(gcf) {
1005
1180
  gcf
1006
1181
  .command('decide <id> <choice>')
1007
1182
  .description('go | no | wontfix | known | close | continue | kill (Methodology §4.1)')
1008
- .option('--reason <text>', 'why: the graveyard keeps it'),
1183
+ .option('--reason <text>', 'why: the graveyard and the commit keep it'),
1009
1184
  )
1185
+ .option('--assume <line>', ASSUME, repeated, [])
1010
1186
  .option('--no-commit', 'skip the commit (tests only)')
1011
1187
  .action(async (id, choice, o) => {
1188
+ await deciderMay(id, choice, o.reason);
1012
1189
  const r = await (
1013
1190
  await ops()
1014
1191
  ).decideItem(process.cwd(), id, choice, {
1015
1192
  reason: o.reason ?? '',
1016
1193
  remove: o.remove,
1194
+ assume: o.assume,
1017
1195
  commit: o.commit,
1018
1196
  });
1019
1197
  console.log(`${r.choice} ${r.id}${shortHash(r.hash)}${removalLine(r)}`);
@@ -1037,6 +1215,7 @@ function registerDecide(gcf) {
1037
1215
  .option('--note <text>', 'the answer, or "file: <path>" for an asset')
1038
1216
  .option('--no-commit', 'skip the commit (tests only)')
1039
1217
  .action(async (id, o) => {
1218
+ await operatorOnly('unblock');
1040
1219
  const r = await (
1041
1220
  await ops()
1042
1221
  ).unblockItem(process.cwd(), id, { note: o.note ?? '', commit: o.commit });
@@ -1458,14 +1637,45 @@ function registerSettings(gcf) {
1458
1637
  );
1459
1638
  });
1460
1639
  config
1461
- .command('set <key>')
1462
- .description('Set one key; an empty --value= takes a number back to its default, a word off')
1640
+ .command('set [key]')
1641
+ .description(
1642
+ 'Set one key; an empty --value= takes a number back to its default, a word off; or ' +
1643
+ 'several keys of gcf/config.yml in one commit with --pair key=value (a preset)',
1644
+ )
1463
1645
  // The value only through --value: `set plan_passes 7` must not read as a reset. A value
1464
1646
  // may start with a hyphen (a command's flag); as `--value=<text>` it stays one value.
1465
1647
  .allowExcessArguments(false)
1466
- .requiredOption('--value <value>', 'the new value; empty (--value=) for the default')
1648
+ .option('--value <value>', 'the new value; empty (--value=) for the default')
1649
+ .option(
1650
+ '--pair <key=value>',
1651
+ 'a key and its value, repeatable: one commit for all',
1652
+ repeated,
1653
+ [],
1654
+ )
1467
1655
  .option('--no-commit', 'skip the commit (tests only)')
1468
1656
  .action(async (key, o) => {
1657
+ await operatorOnly('config set');
1658
+ if (o.pair.length) {
1659
+ if (key !== undefined || o.value !== undefined)
1660
+ throw new Error('give a key with --value, or --pair key=value, not both');
1661
+ const pairs = o.pair.map((p) => {
1662
+ const at = p.indexOf('=');
1663
+ if (at < 1) throw new Error(`--pair is key=value, not ${p}`);
1664
+
1665
+ return [p.slice(0, at), p.slice(at + 1)];
1666
+ });
1667
+ const r = await (
1668
+ await lib('config-set')
1669
+ ).setConfigs(process.cwd(), pairs, {
1670
+ commit: o.commit,
1671
+ });
1672
+ console.log(`${r.keys.join(', ')}${r.unchanged ? ' (unchanged)' : shortHash(r.hash)}`);
1673
+
1674
+ return;
1675
+ }
1676
+
1677
+ if (key === undefined || o.value === undefined)
1678
+ throw new Error('give a key and --value <value>, or --pair key=value');
1469
1679
  const r = await (
1470
1680
  await lib('config-set')
1471
1681
  ).setConfig(process.cwd(), key, o.value, {
@@ -1501,6 +1711,7 @@ function registerPermissions(gcf) {
1501
1711
  const perms = await lib('agent-permissions');
1502
1712
  const { gcfRoot, readConfig } = await lib('gcf-paths');
1503
1713
  const change = [o.on, o.off, o.deny, o.undeny].some(Boolean);
1714
+ if (change) await operatorOnly('permissions');
1504
1715
  const r = change
1505
1716
  ? await perms.setPermissions(process.cwd(), o, { commit: o.commit })
1506
1717
  : perms.agentOf(await readConfig(gcfRoot()));
@@ -1560,6 +1771,7 @@ function registerPhase(gcf) {
1560
1771
  .option('--reason <text>', 'why, when an exit criterion is not met')
1561
1772
  .option('--no-commit', 'skip the commit (tests only)')
1562
1773
  .action(async (o) => {
1774
+ await operatorOnly('phase next');
1563
1775
  const r = await (
1564
1776
  await lib('phase')
1565
1777
  ).nextPhase(process.cwd(), { reason: o.reason ?? '', commit: o.commit });
@@ -1575,6 +1787,7 @@ function registerHooksInstall(gcf) {
1575
1787
  .command('hooks-install')
1576
1788
  .description('Install the gcf pre-commit gate into the repository hooks dir (idempotent)')
1577
1789
  .action(async () => {
1790
+ await operatorOnly('hooks-install');
1578
1791
  const { writeFile } = await import('node:fs/promises');
1579
1792
  // --git-path resolves the hooks dir for a plain repo, a worktree and a submodule alike,
1580
1793
  // where a bare existsSync('.git') passes on a worktree and then fails with ENOTDIR.
@@ -1627,6 +1840,7 @@ function registerPillar(gcf) {
1627
1840
  .option('--to <id>', 'the new id, for a caller that passes options only (a board)')
1628
1841
  .option('--no-commit', 'skip the commit (tests only)')
1629
1842
  .action(async (from, arg, o) => {
1843
+ await operatorOnly('pillar rename');
1630
1844
  if ((arg === undefined) === (o.to === undefined))
1631
1845
  throw new Error('give the new id once: as the argument or --to <id>');
1632
1846
  const to = arg ?? o.to;
@@ -1639,6 +1853,7 @@ function registerPillar(gcf) {
1639
1853
  .requiredOption('--reason <text>', 'why the game no longer holds it')
1640
1854
  .option('--no-commit', 'skip the commit (tests only)')
1641
1855
  .action(async (id, o) => {
1856
+ await operatorOnly('pillar retire');
1642
1857
  const r = await (await lib('pillars')).retirePillar(process.cwd(), id, o);
1643
1858
  console.log(`retired ${id}${shortHash(r.hash)}`);
1644
1859
  if (r.bare.length)
@@ -1661,6 +1876,7 @@ export function register(program) {
1661
1876
  registerSection(gcf);
1662
1877
  registerQuotes(gcf);
1663
1878
  registerDesign(gcf);
1879
+ registerEdits(gcf);
1664
1880
  registerWhere(gcf);
1665
1881
  registerMoves(gcf);
1666
1882
  registerItem(gcf);
package/extension.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
3
3
  "name": "gcf-aif-ext",
4
- "version": "0.18.9",
4
+ "version": "0.20.0",
5
5
  "description": "Game Context Framework for AI Factory",
6
6
  "skills": [
7
7
  "skills/gcf-init",
@@ -8,6 +8,7 @@ import { spawnSync } from 'node:child_process';
8
8
  import path from 'node:path';
9
9
  import { writeIndex } from '../lib/index-gen.js';
10
10
  import { gateProblems } from '../lib/gate.js';
11
+ import { GATE_SCOPE } from '../lib/git.js';
11
12
 
12
13
  const projectDir = process.cwd();
13
14
  const root = path.join(projectDir, 'gcf');
@@ -30,11 +31,10 @@ function git(args) {
30
31
  return res.status === 0 ? res.stdout.trim() : null;
31
32
  }
32
33
 
33
- // gcf/.metrics is left out: `gcf audit` and `gcf context` append to it on every run, and the
34
- // gate reads none of it. So is an unfinished import's held anchor map (`source/*.import.json`):
35
- // it lives until `gcf anchor --done`, and the design moves of that import must still commit.
36
- // Hooks run from the repository root, so the pathspecs are relative.
37
- const scope = ['--', 'gcf', ':(exclude)gcf/.metrics', ':(exclude,glob)gcf/source/*.import.json'];
34
+ // The gate's scope (lib/git.js GATE_SCOPE): gcf/ without gcf/.metrics and an unfinished
35
+ // import's held anchor map; a move's refusal names the same paths. Hooks run from the
36
+ // repository root, so the pathspecs are relative.
37
+ const scope = ['--', ...GATE_SCOPE];
38
38
  const staged = git(['diff', '--cached', '--name-only', ...scope]);
39
39
  if (staged === '') process.exit(0); // this commit does not touch gcf/
40
40
  if (staged !== null) {
@@ -105,13 +105,10 @@ const files = (kind, ...globs) => globs.map((pattern) => ({ kind, pattern }));
105
105
  /** @type {{ id: string, label: string, on: boolean, rules: Rule[] }[]} */
106
106
  export const DENY_GROUPS = [
107
107
  {
108
- id: 'git-destroy',
109
- label: 'git history and uncommitted work: reset --hard, clean, stash, force push',
108
+ id: 'git-history',
109
+ label: 'git history: force push, branch -D, a ref deleted, stash entries dropped',
110
110
  on: true,
111
111
  rules: shell(
112
- 'git reset --hard*',
113
- 'git clean*',
114
- 'git stash*',
115
112
  'git branch -D*',
116
113
  'git filter-branch*',
117
114
  'git update-ref -d*',
@@ -123,10 +120,32 @@ export const DENY_GROUPS = [
123
120
  'git push *+*',
124
121
  'git push*--mirror*',
125
122
  'git push*--delete*',
123
+ // A refspec with no source deletes the remote branch: git push origin :old.
124
+ 'git push * :*',
125
+ 'git stash drop*',
126
+ 'git stash clear*',
127
+ ),
128
+ },
129
+ {
130
+ // The stash stack is the checkout's and every worktree's: a pop may take the operator's.
131
+ id: 'git-discard',
132
+ label:
133
+ 'uncommitted work: reset --hard, clean, checkout or restore of all, stash (list and show are free)',
134
+ on: true,
135
+ rules: shell(
136
+ 'git reset --hard*',
137
+ 'git clean*',
126
138
  'git checkout .',
127
139
  'git checkout -- .',
128
140
  'git restore .',
129
141
  'git restore -- .',
142
+ 'git stash',
143
+ 'git stash -*',
144
+ 'git stash push*',
145
+ 'git stash save*',
146
+ 'git stash pop*',
147
+ 'git stash apply*',
148
+ 'git stash branch*',
130
149
  ),
131
150
  },
132
151
  {
@@ -160,21 +179,26 @@ export const DENY_GROUPS = [
160
179
  {
161
180
  id: 'human-moves',
162
181
  label:
163
- "the human's GCF moves: verdict, decide, answer, unblock, phase, pillars, settings, " +
164
- 'permissions, setup',
182
+ "the human's GCF moves: verdict, answer, unblock, a card's gates, phase, pillars, " +
183
+ 'settings, permissions, setup, hand edits (decide the core holds by the gates)',
165
184
  on: true,
166
185
  rules: shell(
167
186
  'ai-factory gcf verdict*',
168
- 'ai-factory gcf decide*',
169
187
  'ai-factory gcf question answer*',
170
188
  'ai-factory gcf unblock*',
189
+ 'ai-factory gcf item gates*',
171
190
  'ai-factory gcf phase next*',
172
191
  'ai-factory gcf pillar*',
173
192
  'ai-factory gcf permissions*',
174
193
  'ai-factory gcf config set*',
175
194
  'ai-factory gcf hooks-install*',
195
+ // A human's hand edits under gcf/: their unfinished work, not the agent's to keep or erase.
196
+ 'ai-factory gcf edits commit*',
197
+ 'ai-factory gcf edits discard*',
176
198
  'ai-factory gcf-harness init*',
177
199
  'ai-factory gcf-harness run*',
200
+ // The autopilot's card session: an agent starts none.
201
+ 'ai-factory gcf-harness card*',
178
202
  'ai-factory gcf-harness stop*',
179
203
  // The operator's chat input: an agent answering its own question would be no answer.
180
204
  'ai-factory gcf-harness chat*',
@@ -231,7 +255,10 @@ export const DENY_GROUPS = [
231
255
  ];
232
256
 
233
257
  const GROUP_IDS = DENY_GROUPS.map((g) => g.id);
234
- const known = (x) => GROUP_IDS.includes(x);
258
+ // A group a later version split: its old id still names all of its parts.
259
+ const ALIASES = { 'git-destroy': ['git-history', 'git-discard'] };
260
+ const known = (x) => GROUP_IDS.includes(x) || x in ALIASES;
261
+ const partsOf = (id) => ALIASES[id] ?? [id];
235
262
  const rule = (x) => parseRule(x) !== null;
236
263
 
237
264
  function rules(agent, key) {
@@ -260,8 +287,12 @@ function choices(agent) {
260
287
  `gcf/config.yml: agent.groups.${id} must be true or false, ` +
261
288
  `for one of ${GROUP_IDS.join(' | ')}`,
262
289
  );
290
+ // An old id holds each part it split into, unless the file names that part itself.
291
+ const parts = Object.entries(g)
292
+ .filter(([id]) => id in ALIASES)
293
+ .flatMap(([id, on]) => ALIASES[id].filter((p) => !(p in g)).map((p) => [p, on]));
263
294
 
264
- return g;
295
+ return { ...Object.fromEntries(parts), ...g };
265
296
  }
266
297
 
267
298
  /**
@@ -284,7 +315,8 @@ function picksOf(agent) {
284
315
  /**
285
316
  * The `agent:` section resolved: the project's model and effort, each group on or off, the deny
286
317
  * rules the run gets, the extra allow rules (for an agent run without bypass). No section: the
287
- * default groups. `rules` holds them neutral (AD-4), `deny` and `allow` as claude rules for a
318
+ * default groups. `rules` holds them neutral (AD-4), a group's deny rule with its `group` (the
319
+ * operator's own have none), `deny` and `allow` as claude rules for a
288
320
  * harness before 0.12; `deny_extra` is the operator's own deny lines as written, `extra` the
289
321
  * same neutral.
290
322
  */
@@ -296,8 +328,11 @@ export function agentOf(config) {
296
328
  const extra = rules(agent, 'deny');
297
329
  const allowed = rules(agent, 'allow').map(parseRule);
298
330
  const groups = DENY_GROUPS.map((g) => ({ id: g.id, label: g.label, on: chosen[g.id] ?? g.on }));
331
+ // A group's rule names its group: a refusal in a chat says which group to turn off.
299
332
  const denied = [
300
- ...DENY_GROUPS.filter((g, i) => groups[i].on).flatMap((g) => g.rules),
333
+ ...DENY_GROUPS.filter((g, i) => groups[i].on).flatMap((g) =>
334
+ g.rules.map((r) => ({ ...r, group: g.id })),
335
+ ),
301
336
  ...extra.map(parseRule),
302
337
  ].filter((r, i, all) => all.findIndex((x) => sameRule(x, r)) === i);
303
338
 
@@ -346,8 +381,19 @@ export async function setPermissions(projectDir, change, { commit = true } = {})
346
381
  ensureMap(doc, ['agent', 'groups'], GROUPS_SHAPE);
347
382
  const current = agentOf({ agent: doc.toJS().agent });
348
383
  checkChange(change, current);
349
- for (const id of change.on ?? []) doc.setIn(['agent', 'groups', id], true);
350
- for (const id of change.off ?? []) doc.setIn(['agent', 'groups', id], false);
384
+ // An old id goes to its parts; the old key leaves the file once they are written.
385
+ for (const id of change.on ?? [])
386
+ for (const p of partsOf(id)) doc.setIn(['agent', 'groups', p], true);
387
+ for (const id of change.off ?? [])
388
+ for (const p of partsOf(id)) doc.setIn(['agent', 'groups', p], false);
389
+ for (const old of Object.keys(ALIASES))
390
+ if (doc.hasIn(['agent', 'groups', old])) {
391
+ for (const p of ALIASES[old])
392
+ if (!doc.hasIn(['agent', 'groups', p]))
393
+ doc.setIn(['agent', 'groups', p], doc.getIn(['agent', 'groups', old]));
394
+ doc.deleteIn(['agent', 'groups', old]);
395
+ }
396
+
351
397
  const deny = [...new Set([...current.deny_extra, ...(change.deny ?? [])])].filter(
352
398
  (r) => !change.undeny?.some((u) => sameRule(parseRule(u), parseRule(r))),
353
399
  );