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.
- package/README.md +45 -6
- package/commands/gcf.js +344 -82
- package/extension.json +1 -1
- package/injections/plan-context.md +3 -0
- package/lib/agent-permissions.js +28 -4
- package/lib/audit-core.js +72 -127
- package/lib/board.js +22 -10
- package/lib/changes.js +7 -1
- package/lib/commit-files.js +1 -0
- package/lib/commit-move.js +56 -10
- package/lib/config-set.js +52 -14
- package/lib/context.js +29 -16
- package/lib/d2-states.js +208 -0
- package/lib/design-parts.js +37 -7
- package/lib/domain.js +144 -11
- package/lib/gcf-paths.js +13 -2
- package/lib/git.js +62 -17
- package/lib/inbox-categories.js +3 -0
- package/lib/inbox.js +69 -4
- package/lib/lessons.js +133 -4
- package/lib/main-lock.js +195 -3
- package/lib/plan-check.js +339 -37
- package/lib/play.js +21 -20
- package/lib/review.js +111 -2
- package/lib/rules.js +428 -0
- package/lib/session-mark.js +2 -1
- package/lib/systems-doc.js +60 -13
- package/lib/validate-item.js +9 -0
- package/lib/work-ops.js +109 -50
- package/package.json +1 -1
- package/profiles/plan.md +1 -1
- package/schemas/item.schema.json +4 -0
- package/skills/gcf-audit/SKILL.md +10 -5
- package/skills/gcf-card/SKILL.md +12 -10
- package/skills/gcf-chat/SKILL.md +14 -10
- package/skills/gcf-triage/SKILL.md +19 -1
- package/skills/gcf-verdict/SKILL.md +7 -5
- package/templates/agents-block.md +23 -2
- package/templates/config.yml +10 -6
package/commands/gcf.js
CHANGED
|
@@ -324,6 +324,7 @@ function registerContext(gcf) {
|
|
|
324
324
|
.action(async (itemId, opts) => {
|
|
325
325
|
await touchSession(itemId);
|
|
326
326
|
const { buildContext, writeReadset } = await lib('context');
|
|
327
|
+
const { fieldOf } = await lib('question-fields');
|
|
327
328
|
const ctx = await buildContext(process.cwd(), itemId);
|
|
328
329
|
if (opts.readset) await writeReadset(process.cwd(), ctx);
|
|
329
330
|
// Metric 1 (GCF-PRD §14): readset size over time, one csv line per call.
|
|
@@ -339,6 +340,15 @@ function registerContext(gcf) {
|
|
|
339
340
|
[
|
|
340
341
|
...c.files.map((f) => `${f.path} (${f.tokens_est})`),
|
|
341
342
|
...(c.graveyard_hits.length ? ['graveyard hits:', ...c.graveyard_hits] : []),
|
|
343
|
+
// Whole records: a plan written without a run reads the value and the answer here.
|
|
344
|
+
...(c.d2.length ? ['D2 assumptions:'] : []),
|
|
345
|
+
...c.d2.map((rec) => {
|
|
346
|
+
const id = rec.match(/^- id:\s*(\S+)/)?.[1];
|
|
347
|
+
|
|
348
|
+
const mark = ` [fired: ${fieldOf(rec, 'until')}]`;
|
|
349
|
+
|
|
350
|
+
return c.d2_fired.includes(id) ? rec.replace(/^.*/, (l) => l + mark) : rec;
|
|
351
|
+
}),
|
|
342
352
|
`total ~${c.total_tokens_est} / ${c.budget}${c.over_budget ? ' OVER BUDGET' : ''}`,
|
|
343
353
|
].join('\n'),
|
|
344
354
|
);
|
|
@@ -1358,11 +1368,18 @@ function registerItemShow(item) {
|
|
|
1358
1368
|
if (!card) throw new Error(`${id} is not on the board`);
|
|
1359
1369
|
const { handoffLines, handoffOf } = await lib('handoff');
|
|
1360
1370
|
const handoff = await handoffOf(process.cwd(), id, { ledger });
|
|
1361
|
-
|
|
1371
|
+
// The plan review's findings with the author's verdicts (Plan-Review-Rework-Plan d2).
|
|
1372
|
+
const findings = (await lib('plan-check')).itemFindings(process.cwd(), { ...card.data, id });
|
|
1373
|
+
const r = { id, title: card.data.title ?? null, status: card.data.status, handoff, findings };
|
|
1362
1374
|
out(o.json, r, (x) =>
|
|
1363
1375
|
[
|
|
1364
1376
|
`${x.id} (${x.status})${x.title ? ` ${x.title}` : ''}`,
|
|
1365
1377
|
...(x.handoff ? handoffLines(x.id, x.handoff) : ['it waits for nothing: no handoff']),
|
|
1378
|
+
...x.findings.map(
|
|
1379
|
+
(f) =>
|
|
1380
|
+
`finding ${f.tag} ${f.severity} ${f.verdict} ${f.where}: ${f.summary}` +
|
|
1381
|
+
(f.reason ? `; ${f.reason}` : ''),
|
|
1382
|
+
),
|
|
1366
1383
|
].join('\n'),
|
|
1367
1384
|
);
|
|
1368
1385
|
});
|
|
@@ -1396,7 +1413,11 @@ function registerItemNew(item) {
|
|
|
1396
1413
|
.option('--depends <list>', 'ids it waits for, comma-separated')
|
|
1397
1414
|
.option('--severity <level>', 'a bug: critical | high | medium | low')
|
|
1398
1415
|
.option('--blocked <why>', 'start blocked, e.g. "file needed" for an asset')
|
|
1399
|
-
.option(
|
|
1416
|
+
.option(
|
|
1417
|
+
'--from <in-ids>',
|
|
1418
|
+
'inbox entries it comes from, comma-separated: erased; several, a bullet each in its ' +
|
|
1419
|
+
'note, which --note replaces',
|
|
1420
|
+
)
|
|
1400
1421
|
.option('--reopens <id>', 'the ended id this item reworks')
|
|
1401
1422
|
.option('--milestone <name>', 'the milestone of game.md it belongs to')
|
|
1402
1423
|
.option('--release <version>', 'a release: the version it ships')
|
|
@@ -1462,13 +1483,14 @@ function registerAmend(item) {
|
|
|
1462
1483
|
.option('--add <lines>', 'lines to add to notes:, up to 4000 characters')
|
|
1463
1484
|
.option('--title <text>', 'the new title')
|
|
1464
1485
|
.option(
|
|
1465
|
-
'--from <in-
|
|
1466
|
-
'the inbox
|
|
1486
|
+
'--from <in-ids>',
|
|
1487
|
+
'the inbox entries it takes, comma-separated: erased; their words go to notes: unless --add',
|
|
1467
1488
|
)
|
|
1468
1489
|
.option('--base <hash>', "the preview's base: refused when the card changed since")
|
|
1469
1490
|
.option('--dry-run', 'show what would change; write nothing; a run may hold the card')
|
|
1470
1491
|
.option('--json', 'with --dry-run: {base, title, text, changes: [{block, old, new}]}')
|
|
1471
1492
|
.option('--no-commit', 'skip the commit (tests only)')
|
|
1493
|
+
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
1472
1494
|
.action(async (id, o) => {
|
|
1473
1495
|
if (o.text !== undefined && o.textFile !== undefined)
|
|
1474
1496
|
throw new Error('give the text once: --text=<blocks> or --text-file <path|->');
|
|
@@ -1484,6 +1506,7 @@ function registerAmend(item) {
|
|
|
1484
1506
|
base: o.base,
|
|
1485
1507
|
dryRun: o.dryRun === true,
|
|
1486
1508
|
commit: o.commit,
|
|
1509
|
+
proposal: o.proposal,
|
|
1487
1510
|
});
|
|
1488
1511
|
if (o.json) console.log(JSON.stringify(r, null, 2));
|
|
1489
1512
|
else if (o.dryRun)
|
|
@@ -1514,6 +1537,23 @@ function registerHistory(item) {
|
|
|
1514
1537
|
});
|
|
1515
1538
|
}
|
|
1516
1539
|
|
|
1540
|
+
/** `gcf item agent <id>`: the item's model and effort, or its phase's. */
|
|
1541
|
+
async function itemAgent(id, o) {
|
|
1542
|
+
const r = await (
|
|
1543
|
+
await lib('work-ops')
|
|
1544
|
+
).setAgent(process.cwd(), id, {
|
|
1545
|
+
model: o.model,
|
|
1546
|
+
effort: o.effort,
|
|
1547
|
+
phase: o.phase,
|
|
1548
|
+
commit: o.commit,
|
|
1549
|
+
});
|
|
1550
|
+
const shown = (v) => v ?? 'default';
|
|
1551
|
+
const phase = r.phase ? ` in its ${r.phase} phase` : '';
|
|
1552
|
+
console.log(
|
|
1553
|
+
`${id} runs${phase} on model ${shown(r.model)}, effort ${shown(r.effort)}` + shortHash(r.hash),
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1517
1557
|
function registerAgent(item) {
|
|
1518
1558
|
item
|
|
1519
1559
|
.command('agent <id>')
|
|
@@ -1526,16 +1566,12 @@ function registerAgent(item) {
|
|
|
1526
1566
|
'--effort <level>',
|
|
1527
1567
|
"e.g. high; default takes the field off: the project's, else the agent's",
|
|
1528
1568
|
)
|
|
1569
|
+
.option(
|
|
1570
|
+
'--phase <phase>',
|
|
1571
|
+
"plan | implement: the phase's own, over the item's in that phase (plan_model, plan_effort)",
|
|
1572
|
+
)
|
|
1529
1573
|
.option('--no-commit', 'skip the commit (tests only)')
|
|
1530
|
-
.action(
|
|
1531
|
-
const r = await (
|
|
1532
|
-
await lib('work-ops')
|
|
1533
|
-
).setAgent(process.cwd(), id, { model: o.model, effort: o.effort, commit: o.commit });
|
|
1534
|
-
const shown = (v) => v ?? 'default';
|
|
1535
|
-
console.log(
|
|
1536
|
-
`${id} runs on model ${shown(r.model)}, effort ${shown(r.effort)}${shortHash(r.hash)}`,
|
|
1537
|
-
);
|
|
1538
|
-
});
|
|
1574
|
+
.action(itemAgent);
|
|
1539
1575
|
item
|
|
1540
1576
|
.command('mode <id>')
|
|
1541
1577
|
.description(
|
|
@@ -1767,33 +1803,45 @@ function registerDecide(gcf) {
|
|
|
1767
1803
|
}
|
|
1768
1804
|
|
|
1769
1805
|
/**
|
|
1770
|
-
* An inbox move (`plan
|
|
1771
|
-
* make it); with `commit`, committed alone under the main lock — a board
|
|
1772
|
-
* commit from. Entries added before without a commit ride along with it.
|
|
1773
|
-
* hash, or null.
|
|
1806
|
+
* An inbox move (`make` builds its plan: its files, the ones that may carry edits not yet
|
|
1807
|
+
* committed, and how to make it); with `commit`, committed alone under the main lock — a board
|
|
1808
|
+
* has no console to commit from. Entries added before without a commit ride along with it.
|
|
1809
|
+
* Returns the commit hash, or null, and the plan it made.
|
|
1810
|
+
* @template {{files: string[], inputs?: string[], apply: () => Promise<unknown>}} P
|
|
1774
1811
|
* @param {boolean | undefined} commit
|
|
1775
1812
|
* @param {string} message
|
|
1776
|
-
* @param {
|
|
1777
|
-
* @param {string
|
|
1813
|
+
* @param {() => P | Promise<P>} make
|
|
1814
|
+
* @param {string | {key: string, proposal?: string, reason?: string, empty?: boolean}} move the
|
|
1815
|
+
* domain's move key, or it with the rest of the commit's trailers
|
|
1816
|
+
* @returns {Promise<{hash: string | null, plan: P}>}
|
|
1778
1817
|
*/
|
|
1779
|
-
async function inboxMove(commit, message,
|
|
1818
|
+
async function inboxMove(commit, message, make, move) {
|
|
1780
1819
|
if (!commit) {
|
|
1820
|
+
const plan = await make();
|
|
1781
1821
|
await plan.apply();
|
|
1782
1822
|
|
|
1783
|
-
return null;
|
|
1823
|
+
return { hash: null, plan };
|
|
1784
1824
|
}
|
|
1785
1825
|
|
|
1786
1826
|
const { commitMove } = await lib('commit-move');
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1827
|
+
const { untrackedEntries } = await lib('inbox');
|
|
1828
|
+
|
|
1829
|
+
// Read under the lock: a move that waited behind a main run plans again from what is there
|
|
1830
|
+
// now, the entries and pictures added meanwhile included.
|
|
1831
|
+
return (await lib('main-lock')).withMainLock(process.cwd(), async () => {
|
|
1832
|
+
const plan = await make();
|
|
1833
|
+
const loose = untrackedEntries(process.cwd());
|
|
1834
|
+
const hash = await commitMove(process.cwd(), message, {
|
|
1835
|
+
files: [...plan.files, ...loose],
|
|
1836
|
+
inputs: [...(plan.inputs ?? plan.files), ...loose],
|
|
1837
|
+
mutate: async () => {
|
|
1838
|
+
await plan.apply();
|
|
1839
|
+
},
|
|
1840
|
+
commit: true,
|
|
1841
|
+
...(typeof move === 'string' ? { key: move } : move),
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
return { hash, plan };
|
|
1797
1845
|
});
|
|
1798
1846
|
}
|
|
1799
1847
|
|
|
@@ -1825,28 +1873,36 @@ function registerInboxSort(inbox) {
|
|
|
1825
1873
|
await refuseOnWork('sort an entry');
|
|
1826
1874
|
const { planCategory } = await lib('inbox');
|
|
1827
1875
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1876
|
+
const vocab = await vocabulary();
|
|
1877
|
+
const { hash, plan } = await inboxMove(
|
|
1878
|
+
o.commit,
|
|
1879
|
+
`gcf(inbox): sort ${id}`,
|
|
1880
|
+
() => planCategory(gcfRoot(), id, { category: o.category, detail: o.detail, vocab }),
|
|
1881
|
+
'inbox-category',
|
|
1882
|
+
);
|
|
1834
1883
|
const { category, detail } = plan.entry;
|
|
1835
1884
|
console.log(`${id} is ${category}${detail ? `:${detail}` : ''}${shortHash(hash)}`);
|
|
1836
1885
|
});
|
|
1837
1886
|
inbox
|
|
1838
|
-
.command('later <in-
|
|
1839
|
-
.description('Put
|
|
1840
|
-
.option('--off', 'take
|
|
1887
|
+
.command('later <in-ids...>')
|
|
1888
|
+
.description('Put entries away to Later, or take them back with --off: one commit')
|
|
1889
|
+
.option('--off', 'take them back from Later')
|
|
1841
1890
|
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
1842
|
-
.
|
|
1891
|
+
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
1892
|
+
.action(async (ids, o) => {
|
|
1843
1893
|
await refuseOnWork('put an entry away');
|
|
1844
|
-
const { planLater } = await lib('inbox');
|
|
1894
|
+
const { planLater, planGroup } = await lib('inbox');
|
|
1845
1895
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1846
|
-
const
|
|
1896
|
+
const vocab = await vocabulary();
|
|
1847
1897
|
const [key, what] = o.off ? ['inbox-back', 'back'] : ['inbox-later', 'later'];
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1898
|
+
const named = [...new Set(ids)].join(', ');
|
|
1899
|
+
const { hash } = await inboxMove(
|
|
1900
|
+
o.commit,
|
|
1901
|
+
`gcf(inbox): ${what} ${named}`,
|
|
1902
|
+
() => planGroup(ids, (id) => planLater(gcfRoot(), id, !o.off, vocab)),
|
|
1903
|
+
{ key, proposal: o.proposal },
|
|
1904
|
+
);
|
|
1905
|
+
console.log(`${named} ${o.off ? 'back from Later' : 'in Later'}${shortHash(hash)}`);
|
|
1850
1906
|
});
|
|
1851
1907
|
registerInboxCategories(inbox);
|
|
1852
1908
|
}
|
|
@@ -1875,12 +1931,17 @@ function registerInboxCategories(inbox) {
|
|
|
1875
1931
|
await refuseOnWork('migrate the inbox');
|
|
1876
1932
|
const { planMigrate } = await lib('inbox');
|
|
1877
1933
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1878
|
-
const
|
|
1879
|
-
const n =
|
|
1934
|
+
const first = await planMigrate(gcfRoot());
|
|
1935
|
+
const n = first.migrated.length;
|
|
1880
1936
|
// Nothing old left: no commit, so a second run changes nothing.
|
|
1881
|
-
const hash = n
|
|
1882
|
-
? await inboxMove(
|
|
1883
|
-
|
|
1937
|
+
const { hash, plan } = n
|
|
1938
|
+
? await inboxMove(
|
|
1939
|
+
true,
|
|
1940
|
+
`gcf(inbox): ${n} entries to categories`,
|
|
1941
|
+
() => planMigrate(gcfRoot()),
|
|
1942
|
+
'inbox-migrate',
|
|
1943
|
+
)
|
|
1944
|
+
: { hash: null, plan: first };
|
|
1884
1945
|
const line = (m) =>
|
|
1885
1946
|
`${m.id} → ${m.category}${m.dropped.length ? ` (dropped: ${m.dropped.join(', ')})` : ''}`;
|
|
1886
1947
|
out(o.json, { migrated: plan.migrated, hash }, (r) =>
|
|
@@ -1917,33 +1978,61 @@ function readTextFile(file) {
|
|
|
1917
1978
|
|
|
1918
1979
|
function registerInboxDrop(inbox) {
|
|
1919
1980
|
inbox
|
|
1920
|
-
.command('drop <in-
|
|
1921
|
-
.description(
|
|
1981
|
+
.command('drop <in-ids...>')
|
|
1982
|
+
.description(
|
|
1983
|
+
'Erase entries: triaged as noise, a duplicate, done, or turned into an item; one commit',
|
|
1984
|
+
)
|
|
1985
|
+
.option('--reason <why>', 'why, in its commit: done | duplicate | noise | reported | amended')
|
|
1986
|
+
.option(
|
|
1987
|
+
'--of <id>',
|
|
1988
|
+
'with --reason: the item, entry or commit hash it is a duplicate of, or did',
|
|
1989
|
+
)
|
|
1922
1990
|
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
1923
|
-
.
|
|
1991
|
+
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
1992
|
+
.action(async (ids, o) => {
|
|
1924
1993
|
await refuseOnWork('erase an entry');
|
|
1925
|
-
const
|
|
1994
|
+
const reason = await dropReason(o);
|
|
1995
|
+
const { planDrop, planGroup } = await lib('inbox');
|
|
1926
1996
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1927
|
-
const
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
'inbox-drop',
|
|
1997
|
+
const named = [...new Set(ids)].join(', ');
|
|
1998
|
+
// An entry never committed leaves nothing of its own to commit: the commit still goes, empty
|
|
1999
|
+
// when nothing else rides along, so its trailers say why (Lessons-Review-Plan d7).
|
|
2000
|
+
const { hash, plan } = await inboxMove(
|
|
2001
|
+
o.commit,
|
|
2002
|
+
`gcf(inbox): drop ${named}${reason ? ` (${reason})` : ''}`,
|
|
2003
|
+
() => planGroup(ids, (id) => planDrop(gcfRoot(), id)),
|
|
2004
|
+
{ key: 'inbox-drop', reason, proposal: o.proposal, empty: true },
|
|
1936
2005
|
);
|
|
1937
|
-
|
|
1938
|
-
|
|
2006
|
+
// Out of the index too: one staged and never committed would stay staged without its file.
|
|
2007
|
+
const { inHead } = await lib('git');
|
|
2008
|
+
const fresh = plan.files.filter((f) => !inHead(process.cwd(), f));
|
|
2009
|
+
if (fresh.length)
|
|
2010
|
+
spawnSync('git', ['rm', '--cached', '-q', '--ignore-unmatch', '--', ...fresh], {
|
|
1939
2011
|
windowsHide: true,
|
|
1940
2012
|
cwd: process.cwd(),
|
|
1941
2013
|
stdio: 'ignore',
|
|
1942
2014
|
});
|
|
1943
|
-
console.log(`erased ${
|
|
2015
|
+
console.log(`erased ${named}${shortHash(hash)}`);
|
|
1944
2016
|
});
|
|
1945
2017
|
}
|
|
1946
2018
|
|
|
2019
|
+
/** The reason of `inbox drop`, `--of` with it: one of DROP_REASONS, an id or a hash, one line. */
|
|
2020
|
+
async function dropReason(o) {
|
|
2021
|
+
if (o.reason === undefined) {
|
|
2022
|
+
if (o.of !== undefined) throw new Error('--of goes with --reason');
|
|
2023
|
+
|
|
2024
|
+
return undefined;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
const reasons = Object.keys((await lib('inbox')).DROP_REASONS);
|
|
2028
|
+
if (!reasons.includes(o.reason))
|
|
2029
|
+
throw new Error(`--reason is ${reasons.join(' | ')}, not ${o.reason}`);
|
|
2030
|
+
if (o.of !== undefined && !/^[a-z0-9]+(-[a-z0-9]+)*$/.test(o.of))
|
|
2031
|
+
throw new Error(`--of is an item id, an entry id or a commit hash, not ${o.of}`);
|
|
2032
|
+
|
|
2033
|
+
return o.of === undefined ? o.reason : `${o.reason} of ${o.of}`;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1947
2036
|
function registerInbox(gcf) {
|
|
1948
2037
|
const inbox = gcf
|
|
1949
2038
|
.command('inbox')
|
|
@@ -2000,7 +2089,8 @@ function registerInbox(gcf) {
|
|
|
2000
2089
|
item: o.item,
|
|
2001
2090
|
vocab: await vocabulary(),
|
|
2002
2091
|
});
|
|
2003
|
-
|
|
2092
|
+
// A new entry reads nothing that a wait could change: its plan holds.
|
|
2093
|
+
const { hash } = await inboxMove(o.commit, 'gcf(inbox): add', () => plan, 'inbox-add');
|
|
2004
2094
|
console.log(`${plan.entry.id}${shortHash(hash)}`);
|
|
2005
2095
|
});
|
|
2006
2096
|
registerInboxSort(inbox);
|
|
@@ -2040,10 +2130,166 @@ function registerLessons(gcf) {
|
|
|
2040
2130
|
if (!Array.isArray(list)) throw new Error(`${o.from}: lessons must be a JSON array`);
|
|
2041
2131
|
if (!list.length) return console.log(`recorded 0 lessons for ${id}`);
|
|
2042
2132
|
const { gcfRoot } = await lib('gcf-paths');
|
|
2043
|
-
const plan =
|
|
2044
|
-
|
|
2133
|
+
const { hash, plan } = await inboxMove(
|
|
2134
|
+
o.commit,
|
|
2135
|
+
`gcf(lessons): ${id}`,
|
|
2136
|
+
() => planLessons(gcfRoot(), id, list),
|
|
2137
|
+
'lessons',
|
|
2138
|
+
);
|
|
2045
2139
|
console.log(`recorded ${plan.entries.length} lessons for ${id}${shortHash(hash)}`);
|
|
2046
2140
|
});
|
|
2141
|
+
registerLessonsReport(lessons);
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/**
|
|
2145
|
+
* A move with a preview: `--dry-run` writes nothing, `--commit` records it; one is needed. Both:
|
|
2146
|
+
* the dry run wins, as a board previews the move by its own args and `--dry-run`.
|
|
2147
|
+
*/
|
|
2148
|
+
function previewOrCommit(o) {
|
|
2149
|
+
if (!o.dryRun && !o.commit) throw new Error('give --dry-run or --commit');
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
function registerLessonsReport(lessons) {
|
|
2153
|
+
lessons
|
|
2154
|
+
.command('report')
|
|
2155
|
+
.description(
|
|
2156
|
+
'Report lessons about GCF or the template: a file each in ~/.gcf/lessons/<to>/, ' +
|
|
2157
|
+
'the entries erased (reported) in one commit',
|
|
2158
|
+
)
|
|
2159
|
+
.requiredOption('--from <in-ids>', 'the lessons, comma-separated')
|
|
2160
|
+
.requiredOption('--to <where>', 'framework | template')
|
|
2161
|
+
.option('--dry-run', 'show the files it would write; write nothing')
|
|
2162
|
+
.option('--json', 'machine output: {to, from, files}')
|
|
2163
|
+
.option('--commit', 'write the files and commit the erase (gcf(inbox))')
|
|
2164
|
+
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
2165
|
+
.action(async (o) => {
|
|
2166
|
+
previewOrCommit(o);
|
|
2167
|
+
if (!o.dryRun) await operatorOnly('lessons report');
|
|
2168
|
+
const r = await (
|
|
2169
|
+
await lib('lessons')
|
|
2170
|
+
).reportLessons(process.cwd(), {
|
|
2171
|
+
from: o.from,
|
|
2172
|
+
to: o.to,
|
|
2173
|
+
dryRun: o.dryRun === true,
|
|
2174
|
+
proposal: o.proposal,
|
|
2175
|
+
});
|
|
2176
|
+
out(o.json, r, (x) =>
|
|
2177
|
+
o.dryRun
|
|
2178
|
+
? x.files.map((f) => `${f.path}\n\n${f.text}`).join('\n')
|
|
2179
|
+
: `reported ${x.from.join(', ')} to ${x.files.join(', ')}${shortHash(x.hash)}`,
|
|
2180
|
+
);
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
// `rules` has a `--json` of its own: a subcommand's, after its word, goes to the group's options.
|
|
2185
|
+
const jsonIn = (o, cmd) => Boolean(o.json || cmd?.optsWithGlobals?.().json);
|
|
2186
|
+
|
|
2187
|
+
function registerRules(gcf) {
|
|
2188
|
+
const rules = () => lib('rules');
|
|
2189
|
+
const group = gcf
|
|
2190
|
+
.command('rules')
|
|
2191
|
+
.description(
|
|
2192
|
+
"The project's rules for its agents: AGENTS.md and a CLAUDE.md, GCF's block and " +
|
|
2193
|
+
'## Project rules',
|
|
2194
|
+
)
|
|
2195
|
+
.option(
|
|
2196
|
+
'--json',
|
|
2197
|
+
'{files: [{file, text, base, bytes, block, imports_agents, dirty}], own_rules}',
|
|
2198
|
+
)
|
|
2199
|
+
.action(async (o) => {
|
|
2200
|
+
const r = (await rules()).readRules(process.cwd());
|
|
2201
|
+
out(o.json, r, (x) =>
|
|
2202
|
+
[
|
|
2203
|
+
...x.files.map(
|
|
2204
|
+
(f) =>
|
|
2205
|
+
`${f.file}: ${f.bytes} bytes${f.block ? '' : ', no GCF block'}` +
|
|
2206
|
+
`${f.imports_agents ? ', imports AGENTS.md' : ''}${f.dirty ? ', uncommitted' : ''}`,
|
|
2207
|
+
),
|
|
2208
|
+
...x.own_rules.map((l) => `- ${l}`),
|
|
2209
|
+
].join('\n'),
|
|
2210
|
+
);
|
|
2211
|
+
});
|
|
2212
|
+
group
|
|
2213
|
+
.command('add')
|
|
2214
|
+
.description("A line under ## Project rules of each file an agent reads (the human's)")
|
|
2215
|
+
.requiredOption('--text <line>', 'the rule: one line, up to 300 characters')
|
|
2216
|
+
.option('--from <in-ids>', 'inbox entries it settles, comma-separated: erased in its commit')
|
|
2217
|
+
.option('--base <hash>', 'the base its dry run gave: refused when the files changed since')
|
|
2218
|
+
.option('--dry-run', "show each file's diff from HEAD; write nothing")
|
|
2219
|
+
.option('--json', 'machine output')
|
|
2220
|
+
.option('--commit', 'write it and commit (gcf(rules)), with any edits the files had')
|
|
2221
|
+
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
2222
|
+
.action(async (o, cmd) => {
|
|
2223
|
+
previewOrCommit(o);
|
|
2224
|
+
if (!o.dryRun) await operatorOnly('rules add');
|
|
2225
|
+
const r = await (
|
|
2226
|
+
await rules()
|
|
2227
|
+
).addRule(process.cwd(), {
|
|
2228
|
+
text: o.text,
|
|
2229
|
+
from: o.from,
|
|
2230
|
+
base: o.base,
|
|
2231
|
+
dryRun: o.dryRun === true,
|
|
2232
|
+
proposal: o.proposal,
|
|
2233
|
+
});
|
|
2234
|
+
out(jsonIn(o, cmd), r, (x) =>
|
|
2235
|
+
o.dryRun
|
|
2236
|
+
? x.files.map((f) => f.diff).join('\n')
|
|
2237
|
+
: `added the rule to ${x.files.join(', ')}${shortHash(x.hash)}`,
|
|
2238
|
+
);
|
|
2239
|
+
});
|
|
2240
|
+
registerRulesSave(group, rules);
|
|
2241
|
+
registerRulesDiff(group, rules);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
function registerRulesDiff(group, rules) {
|
|
2245
|
+
group
|
|
2246
|
+
.command('diff')
|
|
2247
|
+
.description(
|
|
2248
|
+
"What commits from..to changed in the agent's instructions (AGENTS.md, CLAUDE.md, " +
|
|
2249
|
+
'.claude/, .ai-factory/ but plans and archive): no merges, first parent only',
|
|
2250
|
+
)
|
|
2251
|
+
.requiredOption('--from <sha>', 'the commit before, hex')
|
|
2252
|
+
.requiredOption('--to <sha>', 'the commit after, hex')
|
|
2253
|
+
.option('--json', '{from, to, paths, uncommitted, commits: [{sha, subject, diff}]}')
|
|
2254
|
+
.option('--names', 'the paths alone: no commits, no patch')
|
|
2255
|
+
.action(async (o, cmd) => {
|
|
2256
|
+
const range = { from: o.from, to: o.to, names: o.names === true };
|
|
2257
|
+
const r = (await rules()).rulesDiff(process.cwd(), range);
|
|
2258
|
+
out(
|
|
2259
|
+
jsonIn(o, cmd),
|
|
2260
|
+
r,
|
|
2261
|
+
(x) =>
|
|
2262
|
+
[
|
|
2263
|
+
...(x.commits?.map((c) => `commit ${c.sha} ${c.subject}\n\n${c.diff}`) ?? x.paths),
|
|
2264
|
+
...(x.uncommitted.length ? [`not committed: ${x.uncommitted.join(', ')}`] : []),
|
|
2265
|
+
].join('\n') || 'no change to the instructions',
|
|
2266
|
+
);
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
function registerRulesSave(group, rules) {
|
|
2271
|
+
group
|
|
2272
|
+
.command('save')
|
|
2273
|
+
.description("Save the human's text of AGENTS.md or CLAUDE.md; GCF's block stays as it is")
|
|
2274
|
+
.requiredOption('--file <name>', 'AGENTS.md | CLAUDE.md')
|
|
2275
|
+
.requiredOption('--base <hash>', 'the base gcf rules gave: refused when the file changed since')
|
|
2276
|
+
.requiredOption('--text-file <path>', 'the whole new text, - for stdin')
|
|
2277
|
+
.option('--dry-run', 'show the diff from HEAD; write nothing')
|
|
2278
|
+
.option('--json', 'machine output')
|
|
2279
|
+
.option('--commit', 'save and commit (gcf(rules))')
|
|
2280
|
+
.action(async (o, cmd) => {
|
|
2281
|
+
previewOrCommit(o);
|
|
2282
|
+
if (!o.dryRun) await operatorOnly('rules save');
|
|
2283
|
+
const r = await (
|
|
2284
|
+
await rules()
|
|
2285
|
+
).saveRules(process.cwd(), {
|
|
2286
|
+
file: o.file,
|
|
2287
|
+
base: o.base,
|
|
2288
|
+
text: readTextFile(o.textFile),
|
|
2289
|
+
dryRun: o.dryRun === true,
|
|
2290
|
+
});
|
|
2291
|
+
out(jsonIn(o, cmd), r, (x) => (o.dryRun ? x.diff : `saved ${x.file}${shortHash(x.hash)}`));
|
|
2292
|
+
});
|
|
2047
2293
|
}
|
|
2048
2294
|
|
|
2049
2295
|
function registerLive(gcf) {
|
|
@@ -2111,18 +2357,24 @@ function registerPlan(gcf) {
|
|
|
2111
2357
|
}
|
|
2112
2358
|
|
|
2113
2359
|
/**
|
|
2114
|
-
* The
|
|
2360
|
+
* The review passes of a plan and their stop (Hold-Plan d12, d16): a pass is recorded in the
|
|
2115
2361
|
* plan, the verdict decides; a stall blocks the card for the operator's more or accept.
|
|
2116
2362
|
*/
|
|
2117
2363
|
function registerPlanPasses(plan) {
|
|
2118
2364
|
plan
|
|
2119
2365
|
.command('pass <id>')
|
|
2120
2366
|
.description(
|
|
2121
|
-
"Record
|
|
2122
|
-
'answer the verdict: continue,
|
|
2367
|
+
"Record a review pass in the plan's ## Passes: its findings with the author's verdicts " +
|
|
2368
|
+
'(## Findings, the counts from them), or its counts; answer the verdict: continue, ' +
|
|
2369
|
+
'converged or stalled',
|
|
2370
|
+
)
|
|
2371
|
+
.option(
|
|
2372
|
+
'--findings <file>',
|
|
2373
|
+
"JSON: the reviewer's findings, each with the author's verdict (accepted | rejected | " +
|
|
2374
|
+
'downgraded) and reason; a blocking one without a scenario is polish',
|
|
2123
2375
|
)
|
|
2124
|
-
.
|
|
2125
|
-
.
|
|
2376
|
+
.option('--blocking <n>', 'without --findings: findings that block the plan')
|
|
2377
|
+
.option('--polish <n>', 'without --findings: findings that only polish it')
|
|
2126
2378
|
.option('--by <reviewer>', 'who made the pass: agent:model:effort (gcf review row), or self')
|
|
2127
2379
|
.option(
|
|
2128
2380
|
'--for <row>',
|
|
@@ -2135,8 +2387,9 @@ function registerPlanPasses(plan) {
|
|
|
2135
2387
|
const r = await (
|
|
2136
2388
|
await lib('plan-check')
|
|
2137
2389
|
).recordPass(process.cwd(), id, {
|
|
2138
|
-
blocking: Number(o.blocking),
|
|
2139
|
-
polish: Number(o.polish),
|
|
2390
|
+
blocking: o.blocking === undefined ? undefined : Number(o.blocking),
|
|
2391
|
+
polish: o.polish === undefined ? undefined : Number(o.polish),
|
|
2392
|
+
findings: o.findings,
|
|
2140
2393
|
by: o.by,
|
|
2141
2394
|
for: o.for,
|
|
2142
2395
|
kind: o.kind,
|
|
@@ -2156,11 +2409,16 @@ function registerReview(gcf) {
|
|
|
2156
2409
|
.command('row <id>')
|
|
2157
2410
|
.description(
|
|
2158
2411
|
'Who makes pass k of the plan or code review (review.plan|code of gcf/config.yml; past ' +
|
|
2159
|
-
'the rows, the last); --diff writes the
|
|
2412
|
+
'the rows, the last); --diff writes the diff the reviewer reads. A plan pass keeps ' +
|
|
2413
|
+
'the plan it sees in .gcf-session/plans/ and says its mode: full, or check of the fixes',
|
|
2160
2414
|
)
|
|
2161
2415
|
.requiredOption('--kind <kind>', 'plan or code')
|
|
2162
2416
|
.requiredOption('--pass <k>', 'the pass number, 1 or more')
|
|
2163
|
-
.option(
|
|
2417
|
+
.option(
|
|
2418
|
+
'--diff',
|
|
2419
|
+
'code: write .gcf-session/review/<id>.diff; plan, a check: .gcf-session/review/' +
|
|
2420
|
+
"<id>.plan.diff, from the earlier pass's plan; and name it",
|
|
2421
|
+
)
|
|
2164
2422
|
.option('--json', 'machine output')
|
|
2165
2423
|
.action(async (id, o) => {
|
|
2166
2424
|
await touchSession(id);
|
|
@@ -2169,7 +2427,7 @@ function registerReview(gcf) {
|
|
|
2169
2427
|
).reviewRow(process.cwd(), id, { kind: o.kind, pass: Number(o.pass), diff: o.diff });
|
|
2170
2428
|
out(o.json, r, (x) =>
|
|
2171
2429
|
[
|
|
2172
|
-
`pass ${x.pass}: ${x.by ?? 'no review'}`,
|
|
2430
|
+
`pass ${x.pass}: ${x.by ?? 'no review'}${x.mode ? ` (${x.mode})` : ''}`,
|
|
2173
2431
|
...(x.fallback.length
|
|
2174
2432
|
? [`fallback: ${x.fallback.map((f) => `${f.agent}:${f.model}:${f.effort}`).join(', ')}`]
|
|
2175
2433
|
: []),
|
|
@@ -2317,11 +2575,14 @@ function registerSettings(gcf) {
|
|
|
2317
2575
|
.allowExcessArguments(false)
|
|
2318
2576
|
.option('--json', 'machine output')
|
|
2319
2577
|
.action(async (o) => {
|
|
2320
|
-
const { gcfRoot, readConfig } = await lib('gcf-paths');
|
|
2578
|
+
const { gcfRoot, readConfig, readRawConfig } = await lib('gcf-paths');
|
|
2321
2579
|
await readConfig(gcfRoot()); // a config the rules refuse says so here
|
|
2322
|
-
const
|
|
2580
|
+
const settings = await lib('config-set');
|
|
2581
|
+
const list = await settings.projectSettings(process.cwd());
|
|
2582
|
+
// A phase's own model and effort, set by `config set`, have no settings row yet (d10).
|
|
2583
|
+
const phases = settings.phaseValues(await readRawConfig(gcfRoot()));
|
|
2323
2584
|
out(o.json, list, (x) =>
|
|
2324
|
-
x
|
|
2585
|
+
[...x, ...phases]
|
|
2325
2586
|
.map((s) =>
|
|
2326
2587
|
Array.isArray(s.value)
|
|
2327
2588
|
? `${s.key}: # ${s.label}\n${s.value.map((v) => ` ${v}`).join('\n')}`
|
|
@@ -2607,6 +2868,7 @@ export function register(program) {
|
|
|
2607
2868
|
registerDecide(gcf);
|
|
2608
2869
|
registerInbox(gcf);
|
|
2609
2870
|
registerLessons(gcf);
|
|
2871
|
+
registerRules(gcf);
|
|
2610
2872
|
registerLive(gcf);
|
|
2611
2873
|
registerPlan(gcf);
|
|
2612
2874
|
registerReview(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.
|
|
4
|
+
"version": "0.36.0",
|
|
5
5
|
"description": "Game Context Framework for AI Factory",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-init",
|
|
@@ -4,6 +4,9 @@ gcf_gate:
|
|
|
4
4
|
- when `gcf/` exists and the task names a work item, run `ai-factory gcf context <item-id>` first
|
|
5
5
|
- the returned file list is the readset: read those files, `gcf/INDEX.md` and `gcf/config.yml`, and nothing else under `gcf/`; `gcf/LIVE.md` in it says what the game already does
|
|
6
6
|
- its `graveyard_hits` and `d2` lines are context too: what was buried before, and the assumptions in force with their `until:`
|
|
7
|
+
- a `d2` record marked `[fired: <trigger>]` (its id in `d2_fired`) is the human's call now: do not plan on its value
|
|
8
|
+
- only when the plan depends on that value, stop: `ai-factory gcf block <item-id> --reason "needs the human's answer to <q-NNN> (its until fired)"`, unless the item is already blocked on it
|
|
9
|
+
- a fired D2 is not re-filed as a D1: the human answers its own record
|
|
7
10
|
- `over_budget: true` in the result: stop and record a D1 question instead of planning
|
|
8
11
|
- an id in `depends:` that lives in `gcf/design/`, or as an item in any status but unplayed, parked or awaiting-verdict, is not played: do not plan on top of it, stop
|
|
9
12
|
- a dependency awaiting its verdict is planned on: the close of this item then waits for that verdict (`ai-factory gcf block <id> --reason "waits for <dep>"`)
|