gcf-aif-ext 0.22.1 → 0.24.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,27 @@ 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.24.0
54
+
55
+ - A card's unfinished work in main mode goes to its branch when another card claims the folder (Methodology §7, [Shelve-Plan](https://github.com/VirtualMaestro/GCF/blob/main/docs/Shelve-Plan.md)). `gcf claim` pins a baseline at `refs/gcf/main-work`; the next card's claim moves what the card changed since to `work/<id>` as a commit with `GCF-Shelved: <id>`, untouched files keep their mtime, and no hook runs. Its own claim brings the work back by a three-way merge: conflicts stay as markers in the file, for the agent. A journal, `refs/gcf/main-switch`, makes every step recoverable.
56
+ - `gcf claim --json` gives `{shelved, returned, moved, conflicts}`; a claim that cannot move the folder refuses with `gcf-refusal: {"code":"shelve","reason":…}`.
57
+ - `close` and `submit` refuse a shelved card. `drop`, `decide no` and a feature's kill delete its branch; no `remove-<id>` when `GCF-Whole: yes` says none of its code reached main and `tune_count` is 0.
58
+ - `gcf audit --json` carries `main_work: {id, paths}` while a baseline stands; `gcf board --json` carries `items[].shelved: {files, commits}`.
59
+ - Needs git 2.40; an older git, a project inside a bigger repository or a linked worktree record nothing and stop a batch as before.
60
+
61
+ ### 0.23.0
62
+
63
+ - `gcf item amend <id>` fixes a live card's text from every stored status but `unplayed`, the status unchanged: `--text` (`--text-file`) replaces the blocks it names, a key alone takes one out; `--add` adds to `notes:`; `--title`; `--from <in-id>` takes an inbox entry in the same commit, its pictures one by one. `provenance:` and `tuning:` cannot be named; a unit's block must be in its profile. `--dry-run --json` writes nothing and gives `{base, title, text, changes}`; `--base <hash>` refuses a card changed since (`gcf-refusal: {"code":"stale"}`). The operator's: a run and a thread are refused, the deny group `human-moves` holds it, and a chat agent proposes it (`propose_amend`). Refused during this card's run or session (`{"code":"running"}`). Findings on the new text come from the pre-commit gate, with its rollback. The domain's `preview` and `hint` tell a board.
64
+ - A resumed worktree takes main's card over what a stopped run wrote into its copy, saved or not; other files' conflicts read as before. A `work/<id>` branch whose folder was deleted syncs with main too.
65
+ - `item new --from <in> --note <text>`: the note goes over the entry's text, not beside it, so a board's form does not double it. The entry's links follow its pictures.
66
+ - The domain's `inbox-add` has the `item` field: an agent's proposal may name its card.
67
+ - gcf-chat, gcf-triage and the `AGENTS.md` block: a decision about a live item goes into its card by `propose_amend`, never the inbox or a new item; a decision against a slot replaces the slot. Run `ai-factory gcf init` once to take the new block.
68
+
69
+ ### 0.22.2
70
+
71
+ - A refusal in a terminal is its words and its machine line on stderr, exit 1: no `file:///…` and no node stack over them. A bug (any error type but a plain `Error`) keeps its stack. An older board or harness reads it as before.
72
+ - The `AGENTS.md` block keeps cnlp's line rules: no line past 250 characters, no passive, no open bound; a test holds it. `gcf_*` block names stay the project's to declare. Run `ai-factory gcf init` after the update to take the new text.
73
+
53
74
  ### 0.22.1
54
75
 
55
76
  - An agent may read the history of past runs: the deny group `human-moves` held `ai-factory gcf-harness run*`, which also caught `gcf-harness runs`, the very command `AGENTS.md` tells it to use. The rule is now `ai-factory gcf-harness run *`. A session started after the update takes it; nothing to re-run in the project.
@@ -99,7 +120,7 @@ On Windows, run `extension add` and `extension update` from PowerShell or cmd, n
99
120
  ### 0.19.0
100
121
 
101
122
  Autonomy (docs/Autonomy-Plan.md): the agent works by itself, the operator plays the milestones.
102
- - 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.
123
+ - 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`, `item gates` and `item amend` refuse a harness run and a board thread (`GCF-By: thread`). A console session and the operator pass.
103
124
  - `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.
104
125
  - A soft unit whose delta modifies or removes a capability no longer refuses its close: it waits for a verdict, `gate_why: modifies <capability>`.
105
126
  - `--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.
@@ -377,7 +398,7 @@ Removal leaves `gcf/` and `cnlp.config.json` in place. It also leaves the pre-co
377
398
 
378
399
  **A deterministic core** behind `ai-factory gcf …`:
379
400
 
380
- - work items — `take <ids...> [--feature <id>]`, `item new [id] --title <text> --type <type>`, `submit`, `close`, `verdict <id> keep|tune|kill`, `decide <id> go|no|wontfix|known|close|continue|kill`, `block`, `unblock`, `drop`, `done`, `where`
401
+ - work items — `take <ids...> [--feature <id>]`, `item new [id] --title <text> --type <type>`, `submit`, `close`, `verdict <id> keep|tune|kill`, `decide <id> go|no|wontfix|known|close|continue|kill`, `block`, `unblock`, `drop`, `done`, `where`, `item amend <id> [--text <blocks>] [--add <lines>] [--title <text>] [--from <in-id>] [--dry-run --json]`
381
402
  - inbox and snapshot — `inbox [add <text> [--category <c>] [--detail <word>] | add --text-file <path|-> | category <in-id> | later <in-id> [--off] | categories | drop <in-id> | migrate]`, `live`, `live check`
382
403
  - runs and play — `context`, `plan check <id>`, `verify <id>`, `playtest`, `playtest session [--build]`, `audit`
383
404
  - project phase and board — `phase`, `phase next [--reason]`, `board [--json]` (everything a board shows, in one read)
package/commands/gcf.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // CLI wrapper over the deterministic core (GCF-PRD §10.1): harness and human call
2
2
  // the same functions. Registered by AIF via extension.json `commands`.
3
+ import { inspect } from 'node:util';
3
4
  import { mkdir, copyFile, readFile, writeFile } from 'node:fs/promises';
4
5
  import { existsSync, readFileSync } from 'node:fs';
5
6
  import { spawnSync } from 'node:child_process';
@@ -7,6 +8,10 @@ import path from 'node:path';
7
8
  import { fileURLToPath } from 'node:url';
8
9
 
9
10
  const EXT_ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
11
+ /** The commit a switch kept of what a card had staged apart from the disk. */
12
+ const stagedLine = (r) =>
13
+ r.staged ? [`what ${r.id} had staged apart from the disk: commit ${r.staged}`] : [];
14
+
10
15
  const lib = (name) => import(new URL(`../lib/${name}.js`, import.meta.url).href);
11
16
 
12
17
  // Must stay byte-identical to the comment line inside the shim below: hooks-install
@@ -86,11 +91,37 @@ function registerSession(gcf) {
86
91
  'An agent session starts working the item on main: the board shows it running until a ' +
87
92
  'move ends it, release, or 2 hours without a gcf command on it',
88
93
  )
89
- .action(async (id) => {
94
+ .option('--json', 'machine output: what moved in the folder')
95
+ .action(async (id, o) => {
90
96
  const { buildLedger } = await lib('ledger');
91
97
  if (!(await buildLedger(process.cwd())).item(id)) throw new Error(`${id} is not a work item`);
92
- await (await lib('session-mark')).claimSession(process.cwd(), id);
93
- console.log(`claimed ${id}`);
98
+ const moved = await (await lib('session-mark')).claimSession(process.cwd(), id);
99
+ out(o.json, moved, (m) =>
100
+ [
101
+ `claimed ${id}`,
102
+ ...(m.shelved
103
+ ? [
104
+ `shelved ${m.shelved.id}: ${m.shelved.files} file(s) went to ${m.shelved.branch}`,
105
+ ...stagedLine(m.shelved),
106
+ ]
107
+ : []),
108
+ ...(m.returned
109
+ ? [
110
+ `returned ${m.returned.id}: ${m.returned.files} file(s), ` +
111
+ `main moved ${m.moved} commit(s)`,
112
+ ...stagedLine(m.returned),
113
+ ...(m.returned.branch_moved
114
+ ? [`work/${m.returned.id} moved on and stays: its new commits are not here`]
115
+ : []),
116
+ ]
117
+ : []),
118
+ ...m.conflicts.map((c) =>
119
+ c.kept_main
120
+ ? `conflict ${c.path}: kept main's, the card's copy is in commit ${m.returned.copy}`
121
+ : `conflict ${c.path}: resolve its markers first, or block`,
122
+ ),
123
+ ].join('\n'),
124
+ );
94
125
  });
95
126
  gcf
96
127
  .command('release <id>')
@@ -802,7 +833,7 @@ function registerChanges(gcf) {
802
833
  const allOf = (o, cmd) => cmd?.optsWithGlobals?.() ?? o;
803
834
  const group = gcf
804
835
  .command('changes')
805
- .description("What is not committed in the main checkout or a run's worktree: read only")
836
+ .description("What is not committed in the main checkout or a run's worktree")
806
837
  .allowExcessArguments(false)
807
838
  .option('--worktree <id>', TREE)
808
839
  .option('--json', '{tree, base, count, files, trees, more, watch}')
@@ -859,6 +890,27 @@ function registerChanges(gcf) {
859
890
  ).changeFile(process.cwd(), o.path, o.side, { worktree: o.worktree });
860
891
  out(true, r);
861
892
  });
893
+ registerChangesCommit(group, allOf);
894
+ }
895
+
896
+ function registerChangesCommit(group, allOf) {
897
+ group
898
+ .command('commit')
899
+ .description(
900
+ "Commit these files of the main checkout with this message: the board's Commit, the " +
901
+ "operator's move",
902
+ )
903
+ .requiredOption('--fields-file <path>', '{message, paths} as JSON, - for stdin')
904
+ .option('--json', '{hash, subject, files}')
905
+ .action(async (own, cmd) => {
906
+ const o = allOf(own, cmd);
907
+ if (o.worktree) throw new Error('changes commit: a run commits its own work in a worktree');
908
+ await operatorOnly('changes commit');
909
+ const r = await (
910
+ await lib('commit-files')
911
+ ).commitFiles(process.cwd(), fieldsOf(o.fieldsFile));
912
+ out(o.json, r, (x) => `committed ${x.files} file${x.files === 1 ? '' : 's'} ${x.hash}`);
913
+ });
862
914
  }
863
915
 
864
916
  function registerMigrate(design) {
@@ -1041,9 +1093,54 @@ function registerItem(gcf) {
1041
1093
  });
1042
1094
  registerAttach(item);
1043
1095
  registerAgent(item);
1096
+ registerAmend(item);
1044
1097
  registerHistory(item);
1045
1098
  }
1046
1099
 
1100
+ function registerAmend(item) {
1101
+ item
1102
+ .command('amend <id>')
1103
+ .description(
1104
+ "Fix a live card's text, any status but unplayed: its status stays, its next run reads it " +
1105
+ '(commit)',
1106
+ )
1107
+ .option('--text <blocks>', 'the blocks to replace, in block syntax; a key alone takes it out')
1108
+ .option('--text-file <path>', 'the blocks from a file, - for stdin')
1109
+ .option('--add <lines>', 'lines to add to notes:, up to 4000 characters')
1110
+ .option('--title <text>', 'the new title')
1111
+ .option(
1112
+ '--from <in-id>',
1113
+ 'the inbox entry it takes: erased; its words go to notes: unless --add',
1114
+ )
1115
+ .option('--base <hash>', "the preview's base: refused when the card changed since")
1116
+ .option('--dry-run', 'show what would change; write nothing; a run may hold the card')
1117
+ .option('--json', 'with --dry-run: {base, title, text, changes: [{block, old, new}]}')
1118
+ .option('--no-commit', 'skip the commit (tests only)')
1119
+ .action(async (id, o) => {
1120
+ if (o.text !== undefined && o.textFile !== undefined)
1121
+ throw new Error('give the text once: --text=<blocks> or --text-file <path|->');
1122
+ // A preview changes nothing: a board shows it for an agent's proposal too.
1123
+ if (!o.dryRun) await operatorOnly('item amend');
1124
+ const r = await (
1125
+ await lib('work-ops')
1126
+ ).amendItem(process.cwd(), id, {
1127
+ text: o.textFile === undefined ? o.text : readTextFile(o.textFile),
1128
+ add: o.add,
1129
+ title: o.title,
1130
+ from: o.from,
1131
+ base: o.base,
1132
+ dryRun: o.dryRun === true,
1133
+ commit: o.commit,
1134
+ });
1135
+ if (o.json) console.log(JSON.stringify(r, null, 2));
1136
+ else if (o.dryRun)
1137
+ console.log(
1138
+ r.changes.map((c) => `${c.block}: ${c.new.length} lines`).join('\n') || 'no change',
1139
+ );
1140
+ else console.log(`amended ${id}${shortHash(r.hash)}`);
1141
+ });
1142
+ }
1143
+
1047
1144
  function registerHistory(item) {
1048
1145
  item
1049
1146
  .command('history <id>')
@@ -1960,8 +2057,29 @@ function registerPillar(gcf) {
1960
2057
  });
1961
2058
  }
1962
2059
 
2060
+ let plainRefusals = false;
2061
+
2062
+ /**
2063
+ * A move's refusal is its words on stderr, with its machine line, not node's stack over them; a
2064
+ * bug (any other error type) keeps its report: its stack, what a rollback could not restore.
2065
+ * Past the action: a caller that awaits the parse catches the error first, and another
2066
+ * extension's commands never get here.
2067
+ */
2068
+ function refuseInWords() {
2069
+ if (plainRefusals) return;
2070
+ plainRefusals = true;
2071
+ const fail = (e) => {
2072
+ const words = e instanceof Error && e.name !== 'Error' ? inspect(e) : (e?.message ?? String(e));
2073
+ process.stderr.write(`${words}\n`, () => process.exit(1));
2074
+ };
2075
+
2076
+ process.on('uncaughtException', fail);
2077
+ process.on('unhandledRejection', fail);
2078
+ }
2079
+
1963
2080
  export function register(program) {
1964
2081
  const gcf = program.command('gcf').description('Game Context Framework core');
2082
+ gcf.hook('preAction', refuseInWords);
1965
2083
  registerPillar(gcf);
1966
2084
  registerInit(gcf, program);
1967
2085
  registerIndex(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.22.1",
4
+ "version": "0.24.0",
5
5
  "description": "Game Context Framework for AI Factory",
6
6
  "skills": [
7
7
  "skills/gcf-init",
@@ -180,7 +180,7 @@ export const DENY_GROUPS = [
180
180
  {
181
181
  id: 'human-moves',
182
182
  label:
183
- "the human's GCF moves: verdict, answer, unblock, a card's gates, phase, pillars, " +
183
+ "the human's GCF moves: verdict, answer, unblock, a card's gates or text, phase, pillars, " +
184
184
  'settings, permissions, setup, hand edits (decide the core holds by the gates)',
185
185
  on: true,
186
186
  rules: shell(
@@ -188,6 +188,7 @@ export const DENY_GROUPS = [
188
188
  'ai-factory gcf question answer*',
189
189
  'ai-factory gcf unblock*',
190
190
  'ai-factory gcf item gates*',
191
+ 'ai-factory gcf item amend*',
191
192
  'ai-factory gcf phase next*',
192
193
  'ai-factory gcf pillar*',
193
194
  'ai-factory gcf permissions*',
@@ -196,6 +197,8 @@ export const DENY_GROUPS = [
196
197
  // A human's hand edits under gcf/: their unfinished work, not the agent's to keep or erase.
197
198
  'ai-factory gcf edits commit*',
198
199
  'ai-factory gcf edits discard*',
200
+ // What goes into the operator's commit is theirs to say; an agent commits with git.
201
+ 'ai-factory gcf changes commit*',
199
202
  'ai-factory gcf-harness init*',
200
203
  // The space keeps `gcf-harness runs`, the history of past runs, a read the agent may make.
201
204
  'ai-factory gcf-harness run *',
package/lib/audit-core.js CHANGED
@@ -17,6 +17,7 @@ import { inboxProblems } from './inbox.js';
17
17
  import { inboxVocabulary } from './domain.js';
18
18
  import { gatePolicy, verdictDeferred } from './gates.js';
19
19
  import { milestoneState } from './milestone-state.js';
20
+ import { mainWork } from './shelf.js';
20
21
 
21
22
  function git(args, cwd) {
22
23
  // A blame of a long file overflows the 1 MiB default, and an overflow reads as a git failure.
@@ -57,6 +58,7 @@ function runningOf(projectDir, id) {
57
58
  * @property {Array<{id: string, tune_count: number, limit: number}>} tune_limit
58
59
  * @property {Array<{id: string, depends: string[]}>} open_depends
59
60
  * @property {{count: number, limit: number, over: boolean}} wip
61
+ * @property {{id: string, paths: string[]}} [main_work] the card in the folder (lib/shelf.js)
60
62
  * @property {{count: number, warn_after: number, over: boolean}} unplayed
61
63
  * @property {string[]} legacy_cards
62
64
  * @property {{tokens: number, budget: number, over: boolean, count: number, too_many: boolean}
@@ -143,6 +145,9 @@ export async function audit(projectDir) {
143
145
  deferred: verdictDeferred(config, c.data),
144
146
  ...runningOf(projectDir, String(c.data.id)),
145
147
  }));
148
+ // The card whose unfinished work lies in the folder (lib/shelf.js): the next claim shelves it.
149
+ const work = mainWork(projectDir);
150
+ if (work) report.main_work = work;
146
151
  const design = await designCheck(projectDir);
147
152
  checkItems(report, items, config, { projectDir, ledger });
148
153
  report.design = {
@@ -403,7 +408,8 @@ const inboxAlerts = (i) => [
403
408
  i.broken_links.length && `${i.broken_links.length} inbox picture link(s) lead nowhere`,
404
409
  i.orphan_dirs.length && `${i.orphan_dirs.length} inbox picture folder(s) without their entry`,
405
410
  i.unmigrated.length &&
406
- `${i.unmigrated.length} inbox entr(ies) from before the categories: ai-factory gcf inbox migrate`,
411
+ `${i.unmigrated.length} inbox entr(ies) from before the categories: ai-factory gcf inbox ` +
412
+ `migrate`,
407
413
  i.unknown_category.length &&
408
414
  `${i.unknown_category.length} inbox entr(ies) of a category the vocabulary lacks: ` +
409
415
  i.unknown_category.join(', '),
package/lib/board.js CHANGED
@@ -20,6 +20,7 @@ import { lessonRepeats } from './inbox-categories.js';
20
20
  import { openDepends } from './work-ops.js';
21
21
  import { listQuestions } from './questions.js';
22
22
  import { sessionActive } from './session-mark.js';
23
+ import { shelvedCards } from './shelf.js';
23
24
  import { agentOf } from './agent-permissions.js';
24
25
  import { projectSettings } from './config-set.js';
25
26
  import { designCheck, designUnits } from './design-check.js';
@@ -315,7 +316,7 @@ async function attachmentsOf(projectDir, id) {
315
316
  }
316
317
 
317
318
  /** One item of the board. */
318
- async function itemOf(projectDir, c, { verified, ledger, harness, config }) {
319
+ async function itemOf(projectDir, c, { verified, shelved, ledger, harness, config }) {
319
320
  const id = String(c.data.id);
320
321
  // A trailer counts only while the item waits on main for its integrate.
321
322
  const ready = c.data.status === 'ready' && verified.has(id);
@@ -349,6 +350,8 @@ async function itemOf(projectDir, c, { verified, ledger, harness, config }) {
349
350
  resumable,
350
351
  resume,
351
352
  verified: ready,
353
+ // Its unfinished work waits on its branch (lib/shelf.js); a run brings it back.
354
+ ...(shelved.has(id) ? { shelved: shelved.get(id) } : {}),
352
355
  waits_for: waitsOf(c, running, ledger),
353
356
  needs: needsOf(ledger, c.data.depends ?? []),
354
357
  moves: offered(c, { running, verified: ready, harness }),
@@ -365,12 +368,13 @@ export async function board(projectDir) {
365
368
  const root = path.join(path.resolve(projectDir), 'gcf');
366
369
  const ledger = await buildLedger(projectDir);
367
370
  const verified = verifiedOf(projectDir);
371
+ const shelved = shelvedCards(projectDir);
368
372
  const { extensions, error: extensionsError } = await extensionsOf(projectDir);
369
373
  const harness = hasHarness(extensions);
370
374
  const config = await readConfig(root);
371
375
  const items = [];
372
376
  for (const c of ledger.items)
373
- items.push(await itemOf(projectDir, c, { verified, ledger, harness, config }));
377
+ items.push(await itemOf(projectDir, c, { verified, shelved, ledger, harness, config }));
374
378
  inRunOrder(items);
375
379
  // When the wait began: the time of the commit `since` names (Board-PRD §13).
376
380
  const times = commitTimes(
package/lib/changes.js CHANGED
@@ -143,6 +143,7 @@ function doubleStar(glob, i) {
143
143
  return atStart && glob[i + 2] === '/' ? ['(?:.*/)?', 3] : ['.*', 2];
144
144
  }
145
145
 
146
+ // Every class git's wildmatch knows, as it reads them: ASCII only.
146
147
  const CLASSES = {
147
148
  alpha: 'a-zA-Z',
148
149
  digit: '0-9',
@@ -150,10 +151,19 @@ const CLASSES = {
150
151
  upper: 'A-Z',
151
152
  lower: 'a-z',
152
153
  xdigit: '0-9a-fA-F',
153
- space: '\\s',
154
+ space: ' \\t\\n\\r',
155
+ blank: ' \\t',
154
156
  punct: '!-\\/:-@\\[-`{-~',
157
+ graph: '!-~',
158
+ print: ' -~',
159
+ cntrl: '\\x00-\\x1f\\x7f',
155
160
  };
156
161
 
162
+ const NAMED_CLASS = /\[:([^\]]*):\]/g;
163
+
164
+ /** A name as git's wildmatch reads it, byte by byte: one letter outside ASCII is several. */
165
+ const asBytes = (s) => Buffer.from(s, 'utf8').toString('latin1');
166
+
157
167
  /** Where the bracket at `i` ends, past `[:digit:]` inside it; a first `]` is its own letter. */
158
168
  function bracketEnd(glob, i) {
159
169
  let at = glob[i + 1] === '!' || glob[i + 1] === '^' ? i + 2 : i + 1;
@@ -166,14 +176,19 @@ function bracketEnd(glob, i) {
166
176
  return at < glob.length ? at : -1;
167
177
  }
168
178
 
169
- /** A bracket as a regex: it never takes a `/`, as git's does not. */
179
+ /**
180
+ * A bracket as a regex: it never takes a `/`, as git's does not. A class git does not know stops
181
+ * its whole pattern there, whatever else the bracket holds.
182
+ */
170
183
  function bracket(glob, i, end) {
171
184
  const inner = glob.slice(i + 1, end);
185
+ const named = [...inner.matchAll(NAMED_CLASS)].map((m) => m[1]);
186
+ if (named.some((n) => !Object.hasOwn(CLASSES, n))) return '(?!)';
172
187
  const not = /^[!^]/.test(inner);
173
188
  const body = (not ? inner.slice(1) : inner)
174
- .replace(/\[:(\w+):\]/g, (_, n) => `\0${n}\0`)
189
+ .replace(NAMED_CLASS, (_, n) => `\0${n}\0`)
175
190
  .replace(/[\\[\]]/g, '\\$&')
176
- .replace(/\0(\w+)\0/g, (_, n) => CLASSES[n] ?? '');
191
+ .replace(/\0(\w+)\0/g, (_, n) => CLASSES[n]);
177
192
 
178
193
  return `(?!/)[${not ? '^' : ''}${body}]`;
179
194
  }
@@ -199,7 +214,7 @@ function globPiece(glob, i) {
199
214
  * @returns {(p: string) => boolean}
200
215
  */
201
216
  export function globTest(written) {
202
- const glob = written.replace(/^(?:\.\/)+/, '');
217
+ const glob = asBytes(written).replace(/^(?:\.\/)+/, '');
203
218
  const folder = glob.endsWith('/');
204
219
  const bare = folder ? glob.slice(0, -1) : glob;
205
220
  const asName = (p) => p.startsWith(`${bare}/`) || (!folder && p === bare);
@@ -213,9 +228,13 @@ export function globTest(written) {
213
228
  try {
214
229
  const test = new RegExp(`^${re}$`);
215
230
 
216
- return (p) => asName(p) || (!folder && test.test(p));
231
+ return (name) => {
232
+ const p = asBytes(name);
233
+
234
+ return asName(p) || (!folder && test.test(p));
235
+ };
217
236
  } catch {
218
- return asName;
237
+ return (name) => asName(asBytes(name));
219
238
  }
220
239
  }
221
240
 
@@ -495,6 +514,13 @@ export async function changesOf(projectDir, { worktree } = {}) {
495
514
  };
496
515
  }
497
516
 
517
+ /** The main checkout's rows as a commit reads them, past the list's limit: `xy` and `why` kept. */
518
+ export async function rowsToCommit(projectDir) {
519
+ const { tree, rows } = await readTree(projectDir);
520
+
521
+ return { base: tree.base, rows: (rows ?? []).map((r) => byDisk(tree.dir, r)) };
522
+ }
523
+
498
524
  /** The row of `p` with its view, or the refusal of a path the list does not hold. */
499
525
  async function rowOf(projectDir, p, worktree) {
500
526
  const { tree, rows, noDiff } = await readTree(projectDir, worktree);