gcf-aif-ext 0.32.0 → 0.36.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.
@@ -4,8 +4,10 @@ import { readFile } from 'node:fs/promises';
4
4
  import { existsSync } from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { parseBlocks, itemsOf } from 'cnlp-kit';
7
- import { parse } from './frontmatter.js';
8
- import { scalarIn } from './design.js';
7
+ import { parse, serialize } from './frontmatter.js';
8
+ import { blockOrder, scalarIn } from './design.js';
9
+ import { atomicWrite } from './safe-path.js';
10
+ import { PLACEHOLDER_RE } from './d2-states.js';
9
11
 
10
12
  const NONE_LINE = '- none: no item of this subsystem has collapsed yet';
11
13
 
@@ -81,9 +83,9 @@ export function putBlock(lines, specs, spec, { rendered, raw = false }) {
81
83
 
82
84
  /**
83
85
  * Append `addLines` to the `key:` bullet block of a body, skipping lines already there. A
84
- * `- none: …` placeholder gives way: CNL-P reads it as the whole content or not at all. The
85
- * block stands where `order` (the profile's block keys, see blockOrder) puts it: M1 refuses
86
- * any other place.
86
+ * `- none: …` placeholder, or a GCF marker line, gives way: CNL-P reads it as the whole content
87
+ * or not at all. The block stands where `order` (the profile's block keys, see blockOrder) puts
88
+ * it: M1 refuses any other place.
87
89
  */
88
90
  export function upsertBlock(rawBody, key, addLines, order) {
89
91
  // A CRLF checkout: `\r` before each `\n` would stop the block match at its first line and
@@ -91,8 +93,11 @@ export function upsertBlock(rawBody, key, addLines, order) {
91
93
  const body = lf(rawBody);
92
94
  const existing = blockLines(body, key);
93
95
  const fresh = addLines.filter((l) => !existing.includes(l));
94
- if (!fresh.length) return body;
95
- const kept = existing.filter((l) => !/^- none\b/.test(l));
96
+ // GCF's own manual() markers (d2-states.js) stand in for content too; a human's manual() stays.
97
+ // An old merge left one beside the very lines merged again: content arriving takes it out.
98
+ const marked = addLines.length > 0 && existing.some((l) => PLACEHOLDER_RE.test(l));
99
+ if (!fresh.length && !marked) return body;
100
+ const kept = existing.filter((l) => !/^- none\b/.test(l) && !PLACEHOLDER_RE.test(l));
96
101
  // A key the profile does not know goes last, after every block it does.
97
102
  const specs = (order.includes(key) ? order : [...order, key]).map((k) => ({ key: k }));
98
103
  const lead = /** @type {RegExpMatchArray} */ (body.match(/^\n*/))[0];
@@ -178,17 +183,59 @@ export function removeLines(rawBody, key, dropLines) {
178
183
 
179
184
  const lf = (text) => String(text).replace(/\r\n/g, '\n');
180
185
 
181
- /** Purpose lines a new systems doc starts with: design/<sys>.md's `purpose:`, or a marker. */
182
- async function purposeLines(root, system) {
186
+ const markerOf = (system) => `[until: manual(purpose of ${system})]`;
187
+
188
+ const designOf = async (root, system) => {
183
189
  const file = path.join(root, 'design', `${system}.md`);
184
- const text = existsSync(file) ? lf(await readFile(file, 'utf8')) : '';
185
- const pre = text.split(/^## /m)[0];
190
+
191
+ return existsSync(file) ? lf(await readFile(file, 'utf8')) : '';
192
+ };
193
+
194
+ /** The purpose lines of a design text (design/<sys>.md, or a bundle's system part); none: TBD. */
195
+ function purposeIn(text) {
196
+ const pre = lf(text).split(/^## /m)[0];
186
197
  const bullets = blockLines(pre, 'purpose').filter((l) => !/^- (TBD|none\b)/.test(l));
187
198
  if (bullets.length) return bullets;
188
199
  const scalar = scalarIn(pre, 'purpose');
189
- if (scalar && scalar !== 'TBD') return [`- ${scalar}`];
190
200
 
191
- return [`- the purpose of ${system} is not written yet [until: manual(purpose of ${system})]`];
201
+ return scalar && scalar !== 'TBD' ? [`- ${scalar}`] : [];
202
+ }
203
+
204
+ /** Purpose lines a new systems doc starts with: design/<sys>.md's `purpose:`, or a marker. */
205
+ async function purposeLines(root, system) {
206
+ const lines = purposeIn(await designOf(root, system));
207
+
208
+ return lines.length
209
+ ? lines
210
+ : [`- the purpose of ${system} is not written yet ${markerOf(system)}`];
211
+ }
212
+
213
+ /**
214
+ * systems/<system>.md when it holds GCF's purpose marker and `design` (design/<system>.md's
215
+ * text, or what a move is about to write there) has a purpose; else null. Only then does a move
216
+ * stage the doc: a doc it leaves alone would refuse the move for edits of its own.
217
+ * @param {string} root
218
+ * @param {string} system
219
+ * @param {string} [design]
220
+ */
221
+ export async function purposeTarget(root, system, design) {
222
+ const file = path.join(root, 'systems', `${system}.md`);
223
+ if (!existsSync(file) || !purposeIn(design ?? (await designOf(root, system))).length) return null;
224
+ const { body } = parse(lf(await readFile(file, 'utf8')));
225
+
226
+ return blockLines(body, 'purpose').some((l) => l.includes(markerOf(system))) ? file : null;
227
+ }
228
+
229
+ /** The purpose marker of systems/<system>.md replaced by design/'s purpose; never starts a doc. */
230
+ export async function fillPurpose(root, system) {
231
+ const design = await designOf(root, system);
232
+ const file = await purposeTarget(root, system, design);
233
+ if (!file) return null;
234
+ const { data, body } = parse(lf(await readFile(file, 'utf8')));
235
+ const order = await blockOrder('system');
236
+ await atomicWrite(file, serialize(data, upsertBlock(body, 'purpose', purposeIn(design), order)));
237
+
238
+ return file;
192
239
  }
193
240
 
194
241
  /**
@@ -77,6 +77,10 @@ const FIELDS = [
77
77
  'live',
78
78
  'model',
79
79
  'effort',
80
+ 'plan_model',
81
+ 'plan_effort',
82
+ 'implement_model',
83
+ 'implement_effort',
80
84
  'run_mode',
81
85
  'skip_gates',
82
86
  'gate_why',
@@ -226,6 +230,11 @@ const RULES = {
226
230
  live: (v) => liveProblem(v) ?? true,
227
231
  model: (v) => nullable(isText)(v) || 'model must be text or null',
228
232
  effort: (v) => nullable(isText)(v) || 'effort must be text or null',
233
+ // A phase's own (Plan-Review-Rework-Plan d10): over the item's model and effort in that phase.
234
+ plan_model: (v) => nullable(isText)(v) || 'plan_model must be text or null',
235
+ plan_effort: (v) => nullable(isText)(v) || 'plan_effort must be text or null',
236
+ implement_model: (v) => nullable(isText)(v) || 'implement_model must be text or null',
237
+ implement_effort: (v) => nullable(isText)(v) || 'implement_effort must be text or null',
229
238
  run_mode: (v) =>
230
239
  nullable((x) => ['main', 'worktree'].includes(x))(v) || 'run_mode must be main | worktree',
231
240
  skip_gates: (v) => typeof v === 'boolean' || 'skip_gates must be true or false',
package/lib/work-ops.js CHANGED
@@ -10,7 +10,7 @@ import { createHash } from 'node:crypto';
10
10
  import path from 'node:path';
11
11
  import { parse, serialize } from './frontmatter.js';
12
12
  import { buildLedger } from './ledger.js';
13
- import { readConfig, RUN_MODES, RUN_WORD } from './gcf-paths.js';
13
+ import { readConfig, RUN_MODES, RUN_PHASES, RUN_WORD } from './gcf-paths.js';
14
14
  import { atomicWrite, resolveInside } from './safe-path.js';
15
15
  import { allowedFrom, decisionFits, FEATURE_ONLY, fromOf } from './transitions.js';
16
16
  import { ITEM_TYPES, DEFAULT_GATE, GATES, SEVERITIES, UNIT_ITEM_TYPES } from './validate-item.js';
@@ -37,14 +37,14 @@ import {
37
37
  revertDelta,
38
38
  knownIssueOf,
39
39
  } from './live.js';
40
- import { inboxEntry, planTake, untrackedEntries } from './inbox.js';
40
+ import { entryIds, inboxEntry, planTakeGroup, untrackedEntries } from './inbox.js';
41
41
  import { cycleMessage, dependsGraph, gameMilestones, pathTo } from './design-check.js';
42
42
  import { refuseByPhase } from './phase.js';
43
43
  import { locked, runHolder } from './main-lock.js';
44
44
  import { dropAgentSession, ownsMark, releaseSession, sessionActive } from './session-mark.js';
45
45
  import { clearCard, inSwitch, isShelved, leaveFolder, wholeOnShelf } from './shelf.js';
46
46
  import { dropStamp, unverifiedProblem } from './verify-stamp.js';
47
- import { planTicks } from './plan-check.js';
47
+ import { planTicks, snapshotFiles, stallOf } from './plan-check.js';
48
48
  import {
49
49
  commitPaths,
50
50
  dirtyGcf,
@@ -249,6 +249,7 @@ async function finish(m, key, tail, commit) {
249
249
  inputs: m.inputs,
250
250
  key,
251
251
  items: [...m.items],
252
+ proposal: m.proposal,
252
253
  });
253
254
  // A move on the item ends the session that worked it: the board stops showing it running,
254
255
  // and no rerun resumes it.
@@ -896,7 +897,7 @@ async function tune(m, note) {
896
897
  if (item.data.status === 'unplayed') unplay(m, item);
897
898
  const body = note ? await upsertItemNote(item, 'tuning', note) : item.body;
898
899
  const data = {
899
- ...newCycle(without(item.data, 'frozen')),
900
+ ...newCycle(m, without(item.data, 'frozen')),
900
901
  status: 'ready',
901
902
  tune_count: tunes + 1,
902
903
  since: null,
@@ -907,12 +908,19 @@ async function tune(m, note) {
907
908
 
908
909
  /**
909
910
  * The card back to planning (Hold-Plan d12): a new planning cycle, so the passes before it no
910
- * longer count, and the operator's answer to an old stall goes with them.
911
+ * longer count, and the operator's answer to an old stall goes with them. A plan review stalled
912
+ * and not accepted drops its snapshot too: the next pass is full, not a diff blind to the stalled
913
+ * findings (Plan-Review-Rework-Plan d3).
911
914
  */
912
- const newCycle = (data) => ({
913
- ...without(data, 'stall'),
914
- plan_cycle: Number(data.plan_cycle ?? 0) + 1,
915
- });
915
+ function newCycle(m, data) {
916
+ const stall = stallOf(m.item.data, 'plan');
917
+ if (stall && !stall.accepted) {
918
+ const { snap, next } = snapshotFiles(m.projectDir, String(m.item.data.id));
919
+ m.step(() => [snap, next].forEach((f) => rmSync(f, { force: true })));
920
+ }
921
+
922
+ return { ...without(data, 'stall'), plan_cycle: Number(data.plan_cycle ?? 0) + 1 };
923
+ }
916
924
 
917
925
  // Where the operator played it: a note for the history, never a condition (Plan, C).
918
926
  const playedNote = (playedOn) => (playedOn?.length ? ` (played on: ${playedOn.join('; ')})` : '');
@@ -1019,7 +1027,7 @@ async function keepPack(projectDir, name) {
1019
1027
  }
1020
1028
 
1021
1029
  /** Refuse a milestone keep that would carry changes of gcf/ or the plans but the pack's own. */
1022
- function refuseLoose(projectDir, name, own) {
1030
+ function refuseLoose(projectDir, name, own, order) {
1023
1031
  const loose = changedIn(projectDir).filter((c) => !own.has(c.file));
1024
1032
  if (loose.length) {
1025
1033
  // The board's Commit clears only gcf/'s edits: a loose plan gets the words alone.
@@ -1028,6 +1036,7 @@ function refuseLoose(projectDir, name, own) {
1028
1036
  loose.every((c) => all.includes(c.file)) ? all : [],
1029
1037
  `commit or stash these first, keep --milestone ${name} would carry them: ` +
1030
1038
  loose.map((c) => c.file).join(', '),
1039
+ { message: `gcf(verdict): keep ${name}`, items: order },
1031
1040
  );
1032
1041
  }
1033
1042
  }
@@ -1086,7 +1095,7 @@ async function keepMilestoneUnlocked(projectDir, name, opts = {}) {
1086
1095
  const pack = await keepPack(projectDir, name);
1087
1096
  const order = keepOrder(pack);
1088
1097
  const own = new Set(pack.map((i) => path.relative(projectDir, i.file).replaceAll('\\', '/')));
1089
- refuseLoose(projectDir, name, own);
1098
+ refuseLoose(projectDir, name, own, order);
1090
1099
  refuseKeepBusy(projectDir, name, commit);
1091
1100
 
1092
1101
  const saved = pack.map((i) => [i.file, readFileSync(i.file)]);
@@ -1219,7 +1228,7 @@ async function unblockItemUnlocked(projectDir, id, opts = {}) {
1219
1228
  const childDied = / child \S+ died/.test(String(m.item.data.blocked ?? ''));
1220
1229
  const waits = m.item.data.type === 'feature' && childDied;
1221
1230
  const data = {
1222
- ...newCycle(without(m.item.data, 'blocked')),
1231
+ ...newCycle(m, without(m.item.data, 'blocked')),
1223
1232
  status: waits ? 'awaiting-decision' : 'ready',
1224
1233
  since: waits ? headHash(projectDir) : null,
1225
1234
  };
@@ -1309,24 +1318,29 @@ function replaceNamed(body, text, item, order) {
1309
1318
  return blocks.reduce((b, { key, lines }) => replaceBlock(b, key, lines, order ?? []), body);
1310
1319
  }
1311
1320
 
1312
- /** The inbox entry a fix takes: its words for `notes:`, its pictures to the card, one by one. */
1313
- async function amendEntry(projectDir, m, from) {
1321
+ /**
1322
+ * The inbox entries a fix takes (`--from in-a,in-b`): their words for `notes:` (a bullet each
1323
+ * when more than one), their pictures to the card, one by one.
1324
+ */
1325
+ async function amendEntry(projectDir, m, ids, add) {
1314
1326
  if (onWorkBranch(projectDir))
1315
1327
  throw new Error('an inbox entry is taken on main: a work/ branch records no inbox move');
1316
1328
  const id = String(m.item.data.id);
1317
- const take = await planTake(m.root, from, path.join(m.root, 'work', id, 'attachments'));
1329
+ const take = await planTakeGroup(m.root, ids, path.join(m.root, 'work', id, 'attachments'));
1318
1330
  const taken = take.pictures.filter((f) => existsSync(f)).map((f) => path.basename(f));
1319
1331
  if (taken.length)
1320
1332
  throw new Error(`gcf/work/${id}/attachments/ already holds ${taken.join(', ')}: rename it`);
1321
- const relink = (s) => s.replaceAll(`${from}/attachments/`, `${id}/attachments/`);
1322
- const lines = take.entry.text.split('\n');
1333
+ const relink = (s) => take.relink(s, id);
1334
+ if (ids.length > 1) return { ...take, note: groupNote(take.entries, relink, add), relink };
1335
+ const [entry] = take.entries;
1336
+ const lines = entry.text.split('\n');
1323
1337
  const rest = lines
1324
1338
  .slice(lines.findIndex((l) => l.trim()) + 1)
1325
1339
  .join('\n')
1326
1340
  .trim();
1327
1341
 
1328
1342
  // An entry of one line is its title: nothing of what it says may be lost with it.
1329
- return { ...take, note: relink(rest || take.entry.title), relink };
1343
+ return { ...take, note: relink(rest || entry.title), relink };
1330
1344
  }
1331
1345
 
1332
1346
  /**
@@ -1336,22 +1350,24 @@ async function amendEntry(projectDir, m, from) {
1336
1350
  * writes nothing and may read a card a run holds: a form and a proposal show it.
1337
1351
  * @param {string} projectDir
1338
1352
  * @param {string} id
1339
- * @param {{text?: string, add?: string, title?: string, from?: string, base?: string,
1340
- * dryRun?: boolean, commit?: boolean}} [opts]
1353
+ * @param {{text?: string, add?: string, title?: string, from?: string | string[], base?: string,
1354
+ * dryRun?: boolean, commit?: boolean, proposal?: string}} [opts]
1341
1355
  */
1342
1356
  async function amendItemUnlocked(projectDir, id, opts = {}) {
1343
1357
  const { dryRun = false, commit = true } = opts;
1344
1358
  const asked = amendAsked(opts);
1345
1359
  const m = await begin(projectDir, id, 'amend', dryRun ? () => {} : refuseAmendLive);
1346
- const entry = asked.from ? await amendEntry(projectDir, m, asked.from) : null;
1360
+ const from = entryIds(asked.from);
1361
+ const entry = from.length ? await amendEntry(projectDir, m, from, asked.add) : null;
1347
1362
  const { body, title } = await amendedCard(m.item, asked, entry);
1348
1363
  const changes = amendChanges(m.item, title, body);
1349
1364
  if (dryRun) return { id, base: amendBase(m.item), title, text: amendableText(body), changes };
1350
1365
  refuseAmendPointless(m.item, { asked, base: opts.base, changes, entry });
1351
1366
  if (entry) carryEntry(m, entry, commit);
1352
- const data = newCycle(asked.title ? { ...m.item.data, title } : m.item.data);
1367
+ const data = newCycle(m, asked.title ? { ...m.item.data, title } : m.item.data);
1353
1368
  m.step(() => writeItem(m.item, data, body));
1354
1369
  if (m.item.data.status === 'ready') dropPlayNotesOf(m);
1370
+ m.proposal = opts.proposal;
1355
1371
 
1356
1372
  return { id, changes, hash: await finish(m, 'amend', id, commit) };
1357
1373
  }
@@ -1787,17 +1803,30 @@ async function setDependsUnlocked(projectDir, id, { add = [], remove = [], commi
1787
1803
  return { id, depends, hash };
1788
1804
  }
1789
1805
 
1806
+ /**
1807
+ * The field `gcf item agent` sets of `model` or `effort`: the item's own, or with `phase` the
1808
+ * phase's (`plan_model`); `keyOf('')` is the commit's word of the phase (`plan `, or none).
1809
+ */
1810
+ function agentKeyOf(phase) {
1811
+ if (phase === undefined) return (k) => k;
1812
+ if (!RUN_PHASES.includes(phase)) throw new Error(`--phase is ${RUN_PHASES.join(' | ')}`);
1813
+
1814
+ return (k) => (k ? `${phase}_${k}` : `${phase} `);
1815
+ }
1816
+
1790
1817
  /**
1791
1818
  * Set how item `id`'s runs go: its `model` and `effort`, each given one a plain word, `default`
1792
- * taking the field off (the project's `agent.model|effort`, else Opus and High). One commit
1793
- * `gcf(item)`. A run in progress keeps
1819
+ * taking the field off (the project's `agent.model|effort`, else Opus and High). With `phase`
1820
+ * (`plan`, `implement`: Plan-Review-Rework-Plan d10) the phase's own `<phase>_model|effort`,
1821
+ * over the item's in that phase. One commit `gcf(item)`. A run in progress keeps
1794
1822
  * its own; the item's next run takes the new value.
1795
1823
  * @param {string} projectDir
1796
1824
  * @param {string} id
1797
- * @param {{model?: string, effort?: string, commit?: boolean}} [opts]
1825
+ * @param {{model?: string, effort?: string, phase?: string, commit?: boolean}} [opts]
1798
1826
  */
1799
- async function setAgentUnlocked(projectDir, id, { model, effort, commit = true } = {}) {
1827
+ async function setAgentUnlocked(projectDir, id, { model, effort, phase, commit = true } = {}) {
1800
1828
  if (model === undefined && effort === undefined) throw new Error('give --model or --effort');
1829
+ const keyOf = agentKeyOf(phase);
1801
1830
  checkRunWords({ model, effort });
1802
1831
  const ledger = await buildLedger(projectDir);
1803
1832
  const item = ledger.item(id);
@@ -1805,15 +1834,17 @@ async function setAgentUnlocked(projectDir, id, { model, effort, commit = true }
1805
1834
  refuseRunning(projectDir, id);
1806
1835
  const data = { ...item.data };
1807
1836
  for (const [k, v] of Object.entries({ model, effort }))
1808
- if (v === AGENT_DEFAULT) delete data[k];
1809
- else if (v !== undefined) data[k] = v;
1810
- const result = { id, model: data.model ?? null, effort: data.effort ?? null };
1837
+ if (v === AGENT_DEFAULT) delete data[keyOf(k)];
1838
+ else if (v !== undefined) data[keyOf(k)] = v;
1839
+ const [m, e] = RUN_KEYS.map((k) => data[keyOf(k)] ?? null);
1840
+ const result = { id, ...(phase && { phase }), model: m, effort: e };
1811
1841
  // The values it has already: nothing to commit (a form sent as it was opened).
1812
- if (RUN_KEYS.every((k) => data[k] === item.data[k])) return { ...result, hash: null };
1813
- const shown = (k) => `${k} ${data[k] ?? AGENT_DEFAULT}`;
1842
+ if (RUN_KEYS.every((k) => data[keyOf(k)] === item.data[keyOf(k)]))
1843
+ return { ...result, hash: null };
1844
+ const shown = (k) => `${k} ${data[keyOf(k)] ?? AGENT_DEFAULT}`;
1814
1845
  const hash = await commitMove(
1815
1846
  projectDir,
1816
- `gcf(item): ${id} ${shown('model')}, ${shown('effort')}`,
1847
+ `gcf(item): ${id} ${keyOf('')}${shown('model')}, ${shown('effort')}`,
1817
1848
  {
1818
1849
  files: [item.file],
1819
1850
  inputs: [item.file],
@@ -1970,7 +2001,8 @@ function parentWrite(ledger, spec) {
1970
2001
  * its inbox entry's.
1971
2002
  */
1972
2003
  async function titleForId(root, spec) {
1973
- const title = spec.title?.trim() || (spec.from ? (await inboxEntry(root, spec.from)).title : '');
2004
+ const first = entryIds(spec.from)[0];
2005
+ const title = spec.title?.trim() || (first ? (await inboxEntry(root, first)).title : '');
1974
2006
  if (!title)
1975
2007
  throw new Error('a new item needs --title (or --from an inbox entry): its id comes from it');
1976
2008
 
@@ -2048,6 +2080,40 @@ async function newItemUnlocked(projectDir, given) {
2048
2080
  return { id: spec.id, item: `gcf/work/${spec.id}.md`, hash };
2049
2081
  }
2050
2082
 
2083
+ /**
2084
+ * The note of the one entry an item takes: the rest of its text past its title, the whole text
2085
+ * when the item's title is another. Its own title given back as it is (a board's "→ item")
2086
+ * counts as the same one.
2087
+ */
2088
+ function entryNote({ title: own, text }, given, relink) {
2089
+ if (given !== undefined && given !== own && given !== relink(own)) return relink(text);
2090
+ const lines = text.split('\n');
2091
+
2092
+ return relink(
2093
+ lines
2094
+ .slice(lines.findIndex((l) => l.trim()) + 1)
2095
+ .join('\n')
2096
+ .trim(),
2097
+ );
2098
+ }
2099
+
2100
+ /**
2101
+ * The note of a group of entries taken at once (Lessons-Review-Plan d3): a bullet each, its id
2102
+ * first. Refused past NOTE_MAX unless a note is given in its place: a card's run reads it whole.
2103
+ */
2104
+ function groupNote(entries, relink, given) {
2105
+ const note = relink(
2106
+ entries.map(({ id, text }) => `- ${id}: ${text.replace(/\n(?=.)/g, '\n ')}`).join('\n'),
2107
+ );
2108
+ if (!given?.trim() && note.length > NOTE_MAX)
2109
+ throw new Error(
2110
+ `the ${entries.length} entries are ${note.length} characters, a note takes up to ` +
2111
+ `${NOTE_MAX}: shorten or split the group`,
2112
+ );
2113
+
2114
+ return note;
2115
+ }
2116
+
2051
2117
  /**
2052
2118
  * The inbox entry an item comes from (`--from`): its title for the item's unless one is given,
2053
2119
  * the rest of its text for the item's `note:` (the whole text when the title is another), its
@@ -2056,7 +2122,8 @@ async function newItemUnlocked(projectDir, given) {
2056
2122
  * one: raw input. No `from`: nothing to take.
2057
2123
  */
2058
2124
  async function takeEntry(projectDir, root, spec) {
2059
- if (!spec.from)
2125
+ const ids = entryIds(spec.from);
2126
+ if (!ids.length)
2060
2127
  return {
2061
2128
  title: spec.title,
2062
2129
  note: undefined,
@@ -2071,23 +2138,15 @@ async function takeEntry(projectDir, root, spec) {
2071
2138
  // An empty folder a failed try left behind holds nothing to overwrite.
2072
2139
  if (existsSync(pictures) && readdirSync(pictures).length)
2073
2140
  throw new Error(`gcf/work/${spec.id}/attachments/ already exists`);
2074
- const take = await planTake(root, spec.from, pictures);
2075
- const { title: own, text } = take.entry;
2076
- const relink = (s) => s.replaceAll(`${spec.from}/attachments/`, `${spec.id}/attachments/`);
2077
- // The entry's own title, given back as it is (a board's "→ item"), counts as the same one.
2078
- // A blank --title is none: the entry's own goes.
2141
+ const take = await planTakeGroup(root, ids, pictures);
2142
+ const relink = (s) => take.relink(s, spec.id);
2143
+ // A blank --title is none: the first entry's own goes.
2079
2144
  const given = spec.title?.trim() ? spec.title : undefined;
2080
- const same = given === undefined || given === own || given === relink(own);
2081
- const title = relink(given ?? own);
2082
- const lines = text.split('\n');
2083
- const first = lines.findIndex((l) => l.trim());
2084
- const rest = same
2085
- ? lines
2086
- .slice(first + 1)
2087
- .join('\n')
2088
- .trim()
2089
- : text;
2090
- const note = relink(rest);
2145
+ const title = relink(given ?? take.entries[0].title);
2146
+ const note =
2147
+ ids.length > 1
2148
+ ? groupNote(take.entries, relink, spec.note)
2149
+ : entryNote(take.entries[0], given, relink);
2091
2150
  const loose = spec.commit ? untrackedEntries(projectDir) : [];
2092
2151
 
2093
2152
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-aif-ext",
3
- "version": "0.32.0",
3
+ "version": "0.36.0",
4
4
  "description": "Game Context Framework for AI Factory",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/profiles/plan.md CHANGED
@@ -48,5 +48,5 @@ custom_sections:
48
48
  - none: a fact that fits no block belongs to the item or to a decision
49
49
 
50
50
  enforcement:
51
- - `ai-factory gcf plan check` lists every form problem as a `format:` line, and never blocks on one: a format line is polish an improve pass applies
51
+ - `ai-factory gcf plan check` lists every form problem as a `format:` line, and never blocks on one: a format line is polish the plan's author applies; a size line says the plan holds fixture-level detail the implementer's tests own
52
52
  - a plan already in work (a ticked task) is not asked to change its form
@@ -130,6 +130,10 @@
130
130
  },
131
131
  "model": { "$ref": "#/definitions/textOrNull" },
132
132
  "effort": { "$ref": "#/definitions/textOrNull" },
133
+ "plan_model": { "$ref": "#/definitions/textOrNull" },
134
+ "plan_effort": { "$ref": "#/definitions/textOrNull" },
135
+ "implement_model": { "$ref": "#/definitions/textOrNull" },
136
+ "implement_effort": { "$ref": "#/definitions/textOrNull" },
133
137
  "run_mode": { "enum": ["main", "worktree", null] },
134
138
  "version": {
135
139
  "anyOf": [{ "type": "null" }, { "type": "string", "pattern": "^\\S+$" }]
@@ -19,11 +19,16 @@ workflow:
19
19
  1. run `ai-factory gcf audit --json` and read the report
20
20
  2. state the first line verbatim: items waiting too long block dependent work, so they lead
21
21
  3. for each stale until record: name the file, the trigger that fired and the line to re-check; for each entry of `stale_questions`: name the question id and ask the human for the answer
22
- 4. for a stale until record of `gcf/open-questions.md`: the D2 assumption its `id` names expired - ask the human to confirm it, then cite `answer: <id>` and remove the record, or to replace the value
23
- 5. read the `design` summary: blocking findings first (run `ai-factory gcf design check` for the list), then the count of ready units
24
- 6. semantic pass, only when the mechanical report is clean or the human asks: read the systems docs of ONE subsystem the human names and report pairs of lines that contradict each other as D1 questions
25
- 7. list the pragmas: each `gcf:allow` is a standing exception, and a growing list is the linter rotting
26
- 8. propose the next actions, ranked, proposed actions <= 3: playtest, answer a D1, take a ready unit, or collapse a stale record
22
+ 4. for a stale until record of `gcf/open-questions.md`: the D2 assumption its `id` names fired - propose the answer in chat, to confirm the value or replace it; a fired D2 is not re-filed as a D1
23
+ 5. the human answers it: the board's Overrule, or `ai-factory gcf question answer <id> --text="<answer>"`; do not answer it yourself
24
+ 6. only after the record carries the human's `answer:`: write it into each slot that cites `assumed: <id>`, cite `answer: <id>` there, then remove the record
25
+ 7. an unplayed item keeps its `assumed: <id>`, as its body is frozen: the answered record stays while an unplayed item cites it, and leaves after that item's verdict
26
+ 8. a stale until annotation in `gcf/systems/` or `gcf/work/` becomes a D1; on the human's go-ahead file it with `ai-factory gcf question add --class D1 --question "<the line> - still true?" --proposed "<its value>" --sys <s>`
27
+ 9. list the `manual(...)` until records, the `placeholder` ones aside: GCF closes its own placeholders
28
+ 10. read the `design` summary: blocking findings first (run `ai-factory gcf design check` for the list), then the count of ready units
29
+ 11. semantic pass, only when the mechanical report is clean or the human asks: read the systems docs of ONE subsystem the human names and report pairs of lines that contradict each other as D1 questions
30
+ 12. list the pragmas: each `gcf:allow` is a standing exception, and a growing list is the linter rotting
31
+ 13. propose the next actions, ranked, proposed actions <= 3: playtest, answer a D1, take a ready unit, or collapse a stale record
27
32
 
28
33
  invocation:
29
34
  - run at session start, after a long break, or on demand
@@ -29,7 +29,8 @@ forbidden_behaviors:
29
29
  - do not reuse an id: an ended id stays ended; rework gets a new id with `reopens: <old id>`
30
30
  - do not put an id in `depends` for order alone: `depends` names an item whose data or code this one uses, and order goes in `priority`
31
31
  - do not remove an answered D1 record while a unit in its `blocks:` lacks the answer, or names a receiver you cannot tell: it stays
32
- - do not remove a D2 record cited as `assumed: q-NNN`: it stays in `gcf/open-questions.md` until its `until:` fires; when the human confirms the value earlier, rewrite each citation to `answer: q-NNN` first
32
+ - do not remove a D2 record without the human's `answer:`, nor before each citation `assumed: q-NNN` outside an unplayed item reads `answer: q-NNN`
33
+ - do not touch an unplayed item's `assumed: q-NNN`: its body is frozen; the answered record stays while an unplayed item cites it, and leaves after that item's verdict
33
34
 
34
35
  outputs:
35
36
  - each answered slot gets a provenance record `- slot: <block>` with `answer: manual`, or `answer: q-NNN` when it closes a question
@@ -53,15 +54,16 @@ workflow:
53
54
  11. when no pillar fits, ask whether the unit is out of scope or a pillar is missing, and write a D1 question for the answer
54
55
  12. write each answer into the unit in place, with its `answer:` provenance record
55
56
  13. a record of `gcf/open-questions.md` with the human's `answer:` that names this unit in `blocks:` goes into the slot of every unit it blocks, each with `answer: q-NNN`; it leaves the file after the last of them has it
56
- 14. run `ai-factory gcf design check --json` until the unit's entry in `units` reads `ready: true`, then commit the answered unit
57
- 15. run `ai-factory gcf take <id>`, or `take <id> <id> --feature <feature-id>` to group units; a unit without its milestone takes `--milestone <name>` from `gcf/game.md`; it writes `gcf/work/<id>.md`
58
- 16. in each mechanic or resource item write `contract:` from the code tree and `interactions:` from the units and items that write the same state
59
- 17. write the item's `live:` delta (a feature's children keep `none: parent`; the feature writes the capability), run `ai-factory gcf design check`, and commit
60
- 18. when the work is several items (a feature's children, or a batch), cut them along subsystem boundaries: each a thin slice that builds and tests alone
61
- 19. two items of one subsystem that change different files get `parallel: ok`, and their `contract:` or `intent:` names those files
62
- 20. set each item's dependencies with `ai-factory gcf depends <id> --add <ids>`: it commits the item's edits too, and a feature's child never depends on its feature
63
- 21. rank the items with `ai-factory gcf prioritize <id> <id> …`: dependencies first, then by value
64
- 22. report the item paths, each item's gate, and for a verdict item the one question the playtest will answer
57
+ 14. a D2 record with the human's `answer:` overrules its `assumed:`: write it into each slot that cites `assumed: q-NNN`, cite `answer: q-NNN` there, then remove the record, the unplayed items aside
58
+ 15. run `ai-factory gcf design check --json` until the unit's entry in `units` reads `ready: true`, then commit the answered unit
59
+ 16. run `ai-factory gcf take <id>`, or `take <id> <id> --feature <feature-id>` to group units; a unit without its milestone takes `--milestone <name>` from `gcf/game.md`; it writes `gcf/work/<id>.md`
60
+ 17. in each mechanic or resource item write `contract:` from the code tree and `interactions:` from the units and items that write the same state
61
+ 18. write the item's `live:` delta (a feature's children keep `none: parent`; the feature writes the capability), run `ai-factory gcf design check`, and commit
62
+ 19. when the work is several items (a feature's children, or a batch), cut them along subsystem boundaries: each a thin slice that builds and tests alone
63
+ 20. two items of one subsystem that change different files get `parallel: ok`, and their `contract:` or `intent:` names those files
64
+ 21. set each item's dependencies with `ai-factory gcf depends <id> --add <ids>`: it commits the item's edits too, and a feature's child never depends on its feature
65
+ 22. rank the items with `ai-factory gcf prioritize <id> <id> …`: dependencies first, then by value
66
+ 23. report the item paths, each item's gate, and for a verdict item the one question the playtest will answer
65
67
 
66
68
  invocation:
67
69
  - run when work starts on a unit or a group of units, when non-design work needs an item, or when a fresh idea needs a home
@@ -24,6 +24,7 @@ preconditions:
24
24
 
25
25
  forbidden_behaviors:
26
26
  - do not make the human's moves: `verdict`, `decide`, `question answer`, `unblock`, `item amend`, `phase next`, `pillar`, `permissions`, `config set`, `hooks-install`, `edits commit`, `edits discard`, `changes commit`; the rules refuse them
27
+ - do not run `rules add`, `rules save` or `lessons report` either: they are the human's moves too
27
28
  - do not put a decision about a live item into the inbox or a new item: a run reads neither, and it blocks on what its card does not say; the decision goes into the card with `propose_amend`
28
29
  - do not add a line to `notes:` that contradicts a slot of the card: replace the slot through `text`, as only the slots reach the documents of the systems
29
30
  - do not run a verdict, a decision, an unblock or an answer: propose it to the human with its `propose_` tool
@@ -53,16 +54,19 @@ workflow:
53
54
  8. a bug, an idea or a task that is new work: call `propose_item_new` with its title, type, subsystems and a note of what its run should know, no id: the core makes it from the title; note length <= 4000 characters
54
55
  9. a raw thought that is not work yet: propose it for the inbox with `propose_inbox_add` and the category it is: `idea`, `request` (what only a person can give), `bug` or `finding` (a remark about the code), a detail word when one fits
55
56
  10. a move the human asks for, or one the talk shows is due, that has a `propose_<move>` tool: call it with the `id` of the item, inbox entry or question it acts on, and say why in one line; name an item by its title with the id in brackets
56
- 11. a kill, a no or a wontfix: its reason is the human's words; the graveyard keeps it, and the move does not go without it
57
- 12. an open D1 question the talk answers: call `propose_question_answer` with its id and the human's words, or your draft when the human asks for one
58
- 13. an item to play: read its handoff (`ai-factory gcf item show <id>`, or `handoff` in the context file); say its main question, what to try, and which row of Play by platform is ready
59
- 14. then call `propose_play` with its `id`, a `target` and, for a target with devices, the `device` id: the human's click starts it and opens it, and the verdict stops it
60
- 15. the context file says no `play:` is set up and the project's `AGENTS.md` says how the game builds and starts: call `propose_play_setup` with those commands; say what is missing when it does not say
61
- 16. a Set up pass over a `play:` with no `plays_on`: propose `play.builds` with rows from the `platforms` of `gcf/game.md`, and targets with `build`, `for`, `devices` and `launches`
62
- 17. one `propose_play_setup` per build, named in `of`; a release command goes with `profile: release`; `auto_build` names the build a run's card gets
63
- 18. in that pass, turn each line of platforms in a card's `play_on` and `played_on` into the name of its build
64
- 19. another move the human asks for: run its `ai-factory gcf` command; the human approves it on the card, or refuses it
65
- 20. say in one line what changed, or that nothing did
57
+ 11. several inbox entries of one cause go as one proposal: `ids` of `propose_inbox_later` and `propose_inbox_drop` (its `reason`, and `of` for what it duplicates or what did it), `from` of `propose_item_new` and of `propose_amend`
58
+ 12. a standing rule for the project's agents: `propose_rules_add` with one line in `language.ui` that `own_rules` of `ai-factory gcf rules --json` lacks, the entries it settles in `from`
59
+ 13. a lesson about GCF or the template: `propose_lessons_report` with the lessons in `from` and `to` as `framework` or `template`
60
+ 14. a kill, a no or a wontfix: its reason is the human's words; the graveyard keeps it, and the move does not go without it
61
+ 15. an open D1 question the talk answers: call `propose_question_answer` with its id and the human's words, or your draft when the human asks for one
62
+ 16. an item to play: read its handoff (`ai-factory gcf item show <id>`, or `handoff` in the context file); say its main question, what to try, and which row of Play by platform is ready
63
+ 17. then call `propose_play` with its `id`, a `target` and, for a target with devices, the `device` id: the human's click starts it and opens it, and the verdict stops it
64
+ 18. the context file says no `play:` is set up and the project's `AGENTS.md` says how the game builds and starts: call `propose_play_setup` with those commands; say what is missing when it does not say
65
+ 19. a Set up pass over a `play:` with no `plays_on`: propose `play.builds` with rows from the `platforms` of `gcf/game.md`, and targets with `build`, `for`, `devices` and `launches`
66
+ 20. one `propose_play_setup` per build, named in `of`; a release command goes with `profile: release`; `auto_build` names the build a run's card gets
67
+ 21. in that pass, turn each line of platforms in a card's `play_on` and `played_on` into the name of its build
68
+ 22. another move the human asks for: run its `ai-factory gcf` command; the human approves it on the card, or refuses it
69
+ 23. say in one line what changed, or that nothing did
66
70
 
67
71
  invocation:
68
72
  - run at the start of a project chat thread the board opens, and when the user types `/gcf-chat`