gcf-aif-ext 0.29.0 → 0.29.2
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/commands/gcf.js +114 -57
- package/extension.json +1 -1
- package/hooks/pre-commit.js +2 -0
- package/lib/agent-permissions.js +7 -4
- package/lib/audit-core.js +28 -18
- package/lib/board.js +1 -1
- package/lib/build-queue.js +5 -2
- package/lib/changes.js +1 -0
- package/lib/commit-files.js +2 -1
- package/lib/commit-move.js +114 -0
- package/lib/config-doc.js +22 -0
- package/lib/config-set.js +34 -39
- package/lib/design-check.js +8 -3
- package/lib/design-parts.js +123 -74
- package/lib/devices.js +5 -9
- package/lib/edits.js +7 -3
- package/lib/frozen.js +24 -0
- package/lib/gate.js +1 -1
- package/lib/gates.js +2 -1
- package/lib/gcf-paths.js +13 -10
- package/lib/git.js +19 -5
- package/lib/handoff.js +6 -1
- package/lib/history.js +1 -1
- package/lib/inbox-categories.js +37 -35
- package/lib/inbox.js +65 -34
- package/lib/integrate.js +7 -12
- package/lib/ledger.js +1 -1
- package/lib/lessons.js +4 -1
- package/lib/metrics.js +1 -0
- package/lib/migrate.js +1 -1
- package/lib/milestone-state.js +1 -1
- package/lib/phase.js +1 -1
- package/lib/pillars.js +1 -1
- package/lib/play-notes.js +4 -0
- package/lib/play-on.js +2 -1
- package/lib/play.js +36 -9
- package/lib/playtest-list.js +1 -1
- package/lib/push.js +9 -5
- package/lib/questions.js +4 -2
- package/lib/session-mark.js +21 -2
- package/lib/shelf.js +1 -0
- package/lib/systems-doc.js +31 -20
- package/lib/unit-ops.js +31 -109
- package/lib/validate-item.js +1 -2
- package/lib/verdict-fs.js +2 -1
- package/lib/verify-stamp.js +6 -1
- package/lib/verify.js +6 -2
- package/lib/work-ops.js +126 -86
- package/package.json +1 -1
- package/templates/agents-block.md +3 -0
package/commands/gcf.js
CHANGED
|
@@ -413,19 +413,30 @@ function itemLines(c, linesOf) {
|
|
|
413
413
|
];
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
/** The
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const decide = s.decisions.length
|
|
416
|
+
/** The sheet's decisions: a go or a no each, none when there are none. */
|
|
417
|
+
function decideLines(decisions) {
|
|
418
|
+
return decisions.length
|
|
420
419
|
? [
|
|
421
420
|
'',
|
|
422
421
|
'## decide: no verdict, a go or a no; play it first where the build shows it',
|
|
423
|
-
...
|
|
424
|
-
(d) => `[ ] ${d.id} [${d.system.join(',')}] ${d.title ?? d.intent ?? ''}`,
|
|
425
|
-
),
|
|
422
|
+
...decisions.map((d) => `[ ] ${d.id} [${d.system.join(',')}] ${d.title ?? d.intent ?? ''}`),
|
|
426
423
|
]
|
|
427
424
|
: [];
|
|
428
|
-
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** A milestone's head on the sheet (`m` null: no milestone): how to play it, what holds it. */
|
|
428
|
+
function sliceHead(m) {
|
|
429
|
+
const head = ['', m ? `# ${m.name}${m.goal ? `: ${m.goal}` : ''}` : '# no milestone'];
|
|
430
|
+
if (m?.play) head.push(`play: ${m.play}`);
|
|
431
|
+
if (m && (m.building || m.blocked))
|
|
432
|
+
head.push(`still building ${m.building}, blocked ${m.blocked}`);
|
|
433
|
+
|
|
434
|
+
return head;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** The sheet's items, slice by slice, each with what to check and how to get there. */
|
|
438
|
+
function itemsLines(s, linesOf) {
|
|
439
|
+
const lines = [];
|
|
429
440
|
let group = null;
|
|
430
441
|
let slice;
|
|
431
442
|
const known = new Map((s.milestones ?? []).map((m) => [m.name, m]));
|
|
@@ -433,27 +444,36 @@ export function sessionText(s, linesOf = null) {
|
|
|
433
444
|
// its question first, then system by system.
|
|
434
445
|
for (const c of s.items) {
|
|
435
446
|
const m = known.get(c.milestone) ?? null;
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
lines.push(`still building ${m.building}, blocked ${m.blocked}`);
|
|
441
|
-
slice = m?.name ?? null;
|
|
447
|
+
const name = m?.name ?? null;
|
|
448
|
+
if (slice === undefined || name !== slice) {
|
|
449
|
+
lines.push(...sliceHead(m));
|
|
450
|
+
slice = name;
|
|
442
451
|
group = null;
|
|
443
452
|
}
|
|
444
453
|
|
|
445
454
|
const system = c.system[0] ?? '(no subsystem)';
|
|
446
455
|
if (system !== group) lines.push('', `## ${system}`);
|
|
447
456
|
group = system;
|
|
448
|
-
lines.push(
|
|
449
|
-
'',
|
|
450
|
-
`[ ] ${c.id} (${c.status}) [${c.system.join(',')}] ${c.title ?? c.intent ?? ''}`,
|
|
451
|
-
);
|
|
457
|
+
lines.push('', cardHead(c));
|
|
452
458
|
lines.push(...itemLines(c, linesOf));
|
|
453
459
|
}
|
|
454
460
|
|
|
461
|
+
return lines;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** An item's head line on the sheet: its box to tick, status, subsystems and title. */
|
|
465
|
+
const cardHead = (c) =>
|
|
466
|
+
`[ ] ${c.id} (${c.status}) [${c.system.join(',')}] ${c.title ?? c.intent ?? ''}`;
|
|
467
|
+
|
|
468
|
+
/** The session sheet: the build, then per item what to check and how to get there. */
|
|
469
|
+
export function sessionText(s, linesOf = null) {
|
|
470
|
+
const lines = sessionHead(s);
|
|
471
|
+
const decide = decideLines(s.decisions);
|
|
472
|
+
if (!s.items.length) return [...lines, 'nothing waits for a playtest', ...decide].join('\n');
|
|
473
|
+
|
|
455
474
|
return [
|
|
456
475
|
...lines,
|
|
476
|
+
...itemsLines(s, linesOf),
|
|
457
477
|
...decide,
|
|
458
478
|
'',
|
|
459
479
|
'after play: a verdict per item — /gcf-verdict <id> keep|tune|kill;',
|
|
@@ -616,7 +636,7 @@ function registerPlayQueue(playtest, jsonOf) {
|
|
|
616
636
|
.description("The devices a target's script finds, each under the plays_on row it fits")
|
|
617
637
|
.option('--json', 'machine output')
|
|
618
638
|
.action(async (target, o) => {
|
|
619
|
-
const r = await (await lib('
|
|
639
|
+
const r = await (await lib('play')).devicesOf(process.cwd(), target);
|
|
620
640
|
out(jsonOf(o), r, devicesText);
|
|
621
641
|
if (r.problem) process.exitCode = 1;
|
|
622
642
|
});
|
|
@@ -996,6 +1016,10 @@ function registerDesignParts(design) {
|
|
|
996
1016
|
r.applied.length ? `saved ${r.applied.join(', ')}${shortHash(r.hash)}` : 'nothing changed',
|
|
997
1017
|
);
|
|
998
1018
|
});
|
|
1019
|
+
registerDesignDrafts(design, parts);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function registerDesignDrafts(design, parts) {
|
|
999
1023
|
design
|
|
1000
1024
|
.command('discard [files...]')
|
|
1001
1025
|
.description(
|
|
@@ -1098,6 +1122,11 @@ function registerChanges(gcf) {
|
|
|
1098
1122
|
: 'nothing uncommitted',
|
|
1099
1123
|
);
|
|
1100
1124
|
});
|
|
1125
|
+
registerChangesFiles(group, { changes, TREE, allOf });
|
|
1126
|
+
registerChangesCommit(group, allOf);
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
function registerChangesFiles(group, { changes, TREE, allOf }) {
|
|
1101
1130
|
group
|
|
1102
1131
|
.command('diff')
|
|
1103
1132
|
.description("A text file's diff against the tree's base")
|
|
@@ -1136,7 +1165,6 @@ function registerChanges(gcf) {
|
|
|
1136
1165
|
).changeFile(process.cwd(), o.path, o.side, { worktree: o.worktree });
|
|
1137
1166
|
out(true, r);
|
|
1138
1167
|
});
|
|
1139
|
-
registerChangesCommit(group, allOf);
|
|
1140
1168
|
}
|
|
1141
1169
|
|
|
1142
1170
|
function registerChangesCommit(group, allOf) {
|
|
@@ -1282,6 +1310,10 @@ function registerMoves(gcf) {
|
|
|
1282
1310
|
).doneUnit(process.cwd(), id, { constraints: o.constraint, commit: o.commit });
|
|
1283
1311
|
console.log(`done ${r.id}${r.hash ? ` (${r.hash.slice(0, 7)})` : ''}`);
|
|
1284
1312
|
});
|
|
1313
|
+
registerDrop(gcf, ops);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function registerDrop(gcf, ops) {
|
|
1285
1317
|
removeOptions(
|
|
1286
1318
|
gcf
|
|
1287
1319
|
.command('drop <id>')
|
|
@@ -1339,6 +1371,14 @@ function registerItemShow(item) {
|
|
|
1339
1371
|
function registerItem(gcf) {
|
|
1340
1372
|
const item = gcf.command('item').description('Work items in gcf/work/ (Methodology §3)');
|
|
1341
1373
|
registerItemShow(item);
|
|
1374
|
+
registerItemNew(item);
|
|
1375
|
+
registerAttach(item);
|
|
1376
|
+
registerAgent(item);
|
|
1377
|
+
registerAmend(item);
|
|
1378
|
+
registerHistory(item);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
function registerItemNew(item) {
|
|
1342
1382
|
item
|
|
1343
1383
|
.command('new [id]')
|
|
1344
1384
|
.description(
|
|
@@ -1375,40 +1415,39 @@ function registerItem(gcf) {
|
|
|
1375
1415
|
.option('--commit', 'commit it (gcf(item)): for a caller with no console, e.g. a board')
|
|
1376
1416
|
.option('--dry-run', 'print the id it would take and the checks; write nothing')
|
|
1377
1417
|
.option('--proposal <key>', "the board's proposal it makes, <thread>/<id>: its commit names it")
|
|
1378
|
-
.action(
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
registerHistory(item);
|
|
1418
|
+
.action(itemNew);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/** `item new`'s action. */
|
|
1422
|
+
async function itemNew(id, o) {
|
|
1423
|
+
if (o.note !== undefined && o.noteFile !== undefined)
|
|
1424
|
+
throw new Error('give the note once: --note=<text> or --note-file <path|->');
|
|
1425
|
+
const { newItem } = await lib('work-ops');
|
|
1426
|
+
const r = await newItem(process.cwd(), {
|
|
1427
|
+
id,
|
|
1428
|
+
type: o.type,
|
|
1429
|
+
gate: o.gate,
|
|
1430
|
+
title: o.title,
|
|
1431
|
+
parent: o.parent,
|
|
1432
|
+
system: splitList(o.system),
|
|
1433
|
+
depends: splitList(o.depends),
|
|
1434
|
+
severity: o.severity,
|
|
1435
|
+
blocked: o.blocked,
|
|
1436
|
+
from: o.from,
|
|
1437
|
+
reopens: o.reopens,
|
|
1438
|
+
milestone: o.milestone,
|
|
1439
|
+
version: o.release,
|
|
1440
|
+
channel: o.channel,
|
|
1441
|
+
model: o.model,
|
|
1442
|
+
effort: o.effort,
|
|
1443
|
+
note: o.noteFile === undefined ? o.note : readTextFile(o.noteFile),
|
|
1444
|
+
priority: o.priority === undefined ? undefined : Number(o.priority),
|
|
1445
|
+
commit: o.commit === true,
|
|
1446
|
+
dryRun: o.dryRun === true,
|
|
1447
|
+
proposal: o.proposal,
|
|
1448
|
+
});
|
|
1449
|
+
// The id first: a caller that gave a title reads it from here.
|
|
1450
|
+
console.log(`${r.id} ${r.item}${shortHash(r.hash)}`);
|
|
1412
1451
|
}
|
|
1413
1452
|
|
|
1414
1453
|
function registerAmend(item) {
|
|
@@ -1577,6 +1616,11 @@ function registerItemMoves(gcf) {
|
|
|
1577
1616
|
console.log(`ranked ${r.ids.join(', ')}${shortHash(r.hash)}`);
|
|
1578
1617
|
});
|
|
1579
1618
|
registerDepends(gcf);
|
|
1619
|
+
registerQuestion(gcf);
|
|
1620
|
+
registerItemEnds(gcf, ops);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
function registerQuestion(gcf) {
|
|
1580
1624
|
const question = gcf.command('question').description('Open questions (gcf/open-questions.md)');
|
|
1581
1625
|
question
|
|
1582
1626
|
.command('answer <qid>')
|
|
@@ -1623,6 +1667,9 @@ function registerItemMoves(gcf) {
|
|
|
1623
1667
|
);
|
|
1624
1668
|
console.log(`${r.id}${shortHash(r.hash)}`);
|
|
1625
1669
|
});
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
function registerItemEnds(gcf, ops) {
|
|
1626
1673
|
gcf
|
|
1627
1674
|
.command('submit <id>')
|
|
1628
1675
|
.description('ready → awaiting-verdict / awaiting-decision (commit gcf(submit))')
|
|
@@ -1732,7 +1779,7 @@ async function inboxMove(commit, message, plan, key) {
|
|
|
1732
1779
|
return null;
|
|
1733
1780
|
}
|
|
1734
1781
|
|
|
1735
|
-
const { commitMove } = await lib('
|
|
1782
|
+
const { commitMove } = await lib('commit-move');
|
|
1736
1783
|
const loose = (await lib('inbox')).untrackedEntries(process.cwd());
|
|
1737
1784
|
|
|
1738
1785
|
return commitMove(process.cwd(), message, {
|
|
@@ -1748,7 +1795,7 @@ async function inboxMove(commit, message, plan, key) {
|
|
|
1748
1795
|
|
|
1749
1796
|
/** A work/ branch's gcf/ state is main's: an inbox entry is tagged or erased on main. */
|
|
1750
1797
|
async function refuseOnWork(what) {
|
|
1751
|
-
const { onWorkBranch } = await lib('
|
|
1798
|
+
const { onWorkBranch } = await lib('commit-move');
|
|
1752
1799
|
if (onWorkBranch(process.cwd()))
|
|
1753
1800
|
throw new Error(`${what} on main: a work/ branch records no inbox move`);
|
|
1754
1801
|
}
|
|
@@ -1797,6 +1844,10 @@ function registerInboxSort(inbox) {
|
|
|
1797
1844
|
const hash = await inboxMove(o.commit, `gcf(inbox): ${what} ${id}`, plan, key);
|
|
1798
1845
|
console.log(`${id} ${o.off ? 'back from Later' : 'in Later'}${shortHash(hash)}`);
|
|
1799
1846
|
});
|
|
1847
|
+
registerInboxCategories(inbox);
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1850
|
+
function registerInboxCategories(inbox) {
|
|
1800
1851
|
inbox
|
|
1801
1852
|
.command('categories')
|
|
1802
1853
|
.description('The categories an entry may have, and who may file each')
|
|
@@ -1881,6 +1932,7 @@ function registerInboxDrop(inbox) {
|
|
|
1881
1932
|
);
|
|
1882
1933
|
if (!committed)
|
|
1883
1934
|
spawnSync('git', ['rm', '--cached', '-q', '--ignore-unmatch', '--', ...plan.files], {
|
|
1935
|
+
windowsHide: true,
|
|
1884
1936
|
cwd: process.cwd(),
|
|
1885
1937
|
stdio: 'ignore',
|
|
1886
1938
|
});
|
|
@@ -2222,6 +2274,11 @@ function registerSettings(gcf) {
|
|
|
2222
2274
|
.join('\n'),
|
|
2223
2275
|
);
|
|
2224
2276
|
});
|
|
2277
|
+
registerConfigSet(config);
|
|
2278
|
+
registerPermissions(gcf);
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
function registerConfigSet(config) {
|
|
2225
2282
|
config
|
|
2226
2283
|
.command('set [key]')
|
|
2227
2284
|
.description(
|
|
@@ -2274,7 +2331,6 @@ function registerSettings(gcf) {
|
|
|
2274
2331
|
: '';
|
|
2275
2332
|
console.log(r.unchanged ? `${now} (unchanged)` : `${now}${shortHash(r.hash)}${note}`);
|
|
2276
2333
|
});
|
|
2277
|
-
registerPermissions(gcf);
|
|
2278
2334
|
}
|
|
2279
2335
|
|
|
2280
2336
|
/** `gcf permissions`: the deny groups and custom rules of agent runs. */
|
|
@@ -2378,6 +2434,7 @@ function registerHooksInstall(gcf) {
|
|
|
2378
2434
|
// --git-path resolves the hooks dir for a plain repo, a worktree and a submodule alike,
|
|
2379
2435
|
// where a bare existsSync('.git') passes on a worktree and then fails with ENOTDIR.
|
|
2380
2436
|
const res = spawnSync('git', ['rev-parse', '--git-path', 'hooks'], {
|
|
2437
|
+
windowsHide: true,
|
|
2381
2438
|
cwd: process.cwd(),
|
|
2382
2439
|
encoding: 'utf8',
|
|
2383
2440
|
});
|
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.29.
|
|
4
|
+
"version": "0.29.2",
|
|
5
5
|
"description": "Game Context Framework for AI Factory",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-init",
|
package/hooks/pre-commit.js
CHANGED
|
@@ -24,6 +24,7 @@ const fail = (msg) => {
|
|
|
24
24
|
function git(args) {
|
|
25
25
|
// quotePath off: a non-ASCII path in the refusal reads as itself, not as octal escapes.
|
|
26
26
|
const res = spawnSync('git', ['-c', 'core.quotePath=false', ...args], {
|
|
27
|
+
windowsHide: true,
|
|
27
28
|
cwd: projectDir,
|
|
28
29
|
encoding: 'utf8',
|
|
29
30
|
});
|
|
@@ -74,6 +75,7 @@ if (problems.length) fail(problems[0]);
|
|
|
74
75
|
await writeIndex(root);
|
|
75
76
|
// An unstaged INDEX (gitignored, locked index) would leave the commit without the row it validated.
|
|
76
77
|
const added = spawnSync('git', ['add', '--', path.join(root, 'INDEX.md')], {
|
|
78
|
+
windowsHide: true,
|
|
77
79
|
cwd: projectDir,
|
|
78
80
|
stdio: 'ignore',
|
|
79
81
|
});
|
package/lib/agent-permissions.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
import { readFile } from 'node:fs/promises';
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import { commitMove } from './
|
|
10
|
+
import { commitMove } from './commit-move.js';
|
|
11
11
|
import { atomicWrite } from './safe-path.js';
|
|
12
12
|
import { gcfRoot, RUN_WORD } from './gcf-paths.js';
|
|
13
|
-
import { configDoc, ensureMap } from './config-
|
|
13
|
+
import { configDoc, ensureMap } from './config-doc.js';
|
|
14
14
|
|
|
15
15
|
const GROUPS_SHAPE = 'gcf/config.yml: agent.groups must map a group id to true or false';
|
|
16
16
|
|
|
@@ -94,7 +94,10 @@ function claudePath(pattern) {
|
|
|
94
94
|
return pattern.startsWith('/') && !pattern.startsWith('//') ? `/${pattern}` : pattern;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* A rule as the operator reads it: `shell: git push --force*`.
|
|
99
|
+
* @public gcf.js imports lib modules by name at run time, out of knip's sight.
|
|
100
|
+
*/
|
|
98
101
|
export const ruleText = (r) => `${r.kind}: ${r.pattern}`;
|
|
99
102
|
|
|
100
103
|
const sameRule = (a, b) => a?.kind === b?.kind && a?.pattern === b?.pattern;
|
|
@@ -102,7 +105,7 @@ const sameRule = (a, b) => a?.kind === b?.kind && a?.pattern === b?.pattern;
|
|
|
102
105
|
const shell = (...patterns) => patterns.map((pattern) => ({ kind: 'shell', pattern }));
|
|
103
106
|
const files = (kind, ...globs) => globs.map((pattern) => ({ kind, pattern }));
|
|
104
107
|
|
|
105
|
-
/** @type {{ id: string, label: string, on: boolean, rules: Rule[] }[]} */
|
|
108
|
+
/** @type {{ id: string, label: string, on: boolean, run_only?: boolean, rules: Rule[] }[]} */
|
|
106
109
|
export const DENY_GROUPS = [
|
|
107
110
|
{
|
|
108
111
|
id: 'git-history',
|
package/lib/audit-core.js
CHANGED
|
@@ -23,7 +23,12 @@ import { platformsOf } from './playtest-list.js';
|
|
|
23
23
|
|
|
24
24
|
function git(args, cwd) {
|
|
25
25
|
// A blame of a long file overflows the 1 MiB default, and an overflow reads as a git failure.
|
|
26
|
-
const res = spawnSync('git', args, {
|
|
26
|
+
const res = spawnSync('git', args, {
|
|
27
|
+
windowsHide: true,
|
|
28
|
+
cwd,
|
|
29
|
+
encoding: 'utf8',
|
|
30
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
31
|
+
});
|
|
27
32
|
|
|
28
33
|
return res.status === 0 ? res.stdout.trim() : null;
|
|
29
34
|
}
|
|
@@ -129,7 +134,28 @@ export async function audit(projectDir) {
|
|
|
129
134
|
};
|
|
130
135
|
// The harness gate reads everything from this one report — it never parses gcf/ itself.
|
|
131
136
|
Object.assign(report, { schema: config.schema, gates: config.gates });
|
|
132
|
-
report.items = items.map((c) => (
|
|
137
|
+
report.items = items.map((c) => itemRow(projectDir, config, c));
|
|
138
|
+
// The card whose unfinished work lies in the folder (lib/shelf.js): the next claim shelves it.
|
|
139
|
+
const work = mainWork(projectDir);
|
|
140
|
+
if (work) report.main_work = work;
|
|
141
|
+
const design = await designCheck(projectDir);
|
|
142
|
+
checkItems(report, items, config, { projectDir, ledger });
|
|
143
|
+
report.design = {
|
|
144
|
+
blocking: design.blocking,
|
|
145
|
+
units: design.units.length,
|
|
146
|
+
ready: design.units.filter((u) => u.ready).length,
|
|
147
|
+
};
|
|
148
|
+
// Where each milestone stands, and what the autopilot builds and stops to play (Plan, D).
|
|
149
|
+
Object.assign(report, await milestoneState(projectDir, ledger, design.units));
|
|
150
|
+
lintSystems(report, systems);
|
|
151
|
+
report.first_line = firstLine(report);
|
|
152
|
+
|
|
153
|
+
return report;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** An item as the report lists it for the harness gate. */
|
|
157
|
+
function itemRow(projectDir, config, c) {
|
|
158
|
+
return {
|
|
133
159
|
id: c.data.id,
|
|
134
160
|
type: c.data.type,
|
|
135
161
|
gate: c.data.gate,
|
|
@@ -147,23 +173,7 @@ export async function audit(projectDir) {
|
|
|
147
173
|
gates: gatePolicy(config, c.data),
|
|
148
174
|
deferred: verdictDeferred(config, c.data),
|
|
149
175
|
...runningOf(projectDir, String(c.data.id)),
|
|
150
|
-
}));
|
|
151
|
-
// The card whose unfinished work lies in the folder (lib/shelf.js): the next claim shelves it.
|
|
152
|
-
const work = mainWork(projectDir);
|
|
153
|
-
if (work) report.main_work = work;
|
|
154
|
-
const design = await designCheck(projectDir);
|
|
155
|
-
checkItems(report, items, config, { projectDir, ledger });
|
|
156
|
-
report.design = {
|
|
157
|
-
blocking: design.blocking,
|
|
158
|
-
units: design.units.length,
|
|
159
|
-
ready: design.units.filter((u) => u.ready).length,
|
|
160
176
|
};
|
|
161
|
-
// Where each milestone stands, and what the autopilot builds and stops to play (Plan, D).
|
|
162
|
-
Object.assign(report, await milestoneState(projectDir, ledger, design.units));
|
|
163
|
-
lintSystems(report, systems);
|
|
164
|
-
report.first_line = firstLine(report);
|
|
165
|
-
|
|
166
|
-
return report;
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
/**
|
package/lib/board.js
CHANGED
|
@@ -110,7 +110,7 @@ function commitTimes(projectDir, hashes) {
|
|
|
110
110
|
const res = spawnSync(
|
|
111
111
|
'git',
|
|
112
112
|
['log', '--no-walk=unsorted', '--ignore-missing', '--format=%H %cI', ...asked],
|
|
113
|
-
{ cwd: projectDir, encoding: 'utf8' },
|
|
113
|
+
{ windowsHide: true, cwd: projectDir, encoding: 'utf8' },
|
|
114
114
|
);
|
|
115
115
|
const found = (res.status === 0 ? res.stdout : '').split('\n').filter(Boolean);
|
|
116
116
|
|
package/lib/build-queue.js
CHANGED
|
@@ -55,7 +55,7 @@ export function ticketsOf(projectDir) {
|
|
|
55
55
|
|
|
56
56
|
return readdirSync(runsOf(dir))
|
|
57
57
|
.map((name) => TICKET_RE.exec(name))
|
|
58
|
-
.filter(
|
|
58
|
+
.filter((m) => m !== null)
|
|
59
59
|
.map((m) => readTicket(dir, Number(m[1])))
|
|
60
60
|
.filter((t) => t && alive(t.pid))
|
|
61
61
|
.sort((a, b) => a.n - b.n);
|
|
@@ -92,7 +92,10 @@ export function ticketSet(dir, n, fields) {
|
|
|
92
92
|
return t;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* The ticket goes with what its waiter ended with; a yield naming it lets its run go on.
|
|
97
|
+
* @param {Record<string, unknown> | null} [outcome]
|
|
98
|
+
*/
|
|
96
99
|
export function ticketClose(projectDir, n, outcome = null) {
|
|
97
100
|
const dir = path.resolve(projectDir);
|
|
98
101
|
if (outcome) writeJson(outcomeFile(dir, n), { n, at: new Date().toISOString(), ...outcome });
|
package/lib/changes.js
CHANGED
package/lib/commit-files.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { writeIndex } from './index-gen.js';
|
|
21
21
|
import { MAIN_RUN, runHolder, withMainLock } from './main-lock.js';
|
|
22
22
|
import { refusal } from './refusal.js';
|
|
23
|
-
import { onWorkBranch } from './
|
|
23
|
+
import { onWorkBranch } from './commit-move.js';
|
|
24
24
|
|
|
25
25
|
const INDEX = 'gcf/INDEX.md';
|
|
26
26
|
// The ids a commit touches, as `gcf edits commit` finds them: item history reads them.
|
|
@@ -36,6 +36,7 @@ const inGate = (p) =>
|
|
|
36
36
|
|
|
37
37
|
const git = (dir, args, opts = {}) =>
|
|
38
38
|
spawnSync('git', ['-c', 'core.quotePath=false', ...args], {
|
|
39
|
+
windowsHide: true,
|
|
39
40
|
cwd: dir,
|
|
40
41
|
encoding: 'utf8',
|
|
41
42
|
...opts,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// The fixed-format commit every committed move ends with (Methodology §4.1): all of the move or
|
|
2
|
+
// none of it, under the main lock, refused on a work/ branch or over uncommitted edits.
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { withFileRollback } from './safe-path.js';
|
|
7
|
+
import { writeIndex } from './index-gen.js';
|
|
8
|
+
import { operationInProgress, commitPaths, dirtyGcf, dirtyRefusal } from './git.js';
|
|
9
|
+
import { withMainLock } from './main-lock.js';
|
|
10
|
+
|
|
11
|
+
/** A file's text at a git revision spec (`HEAD:./x`, `:./x` for the index), '' when absent. */
|
|
12
|
+
function gitText(projectDir, spec) {
|
|
13
|
+
const res = spawnSync('git', ['show', spec], {
|
|
14
|
+
windowsHide: true,
|
|
15
|
+
cwd: projectDir,
|
|
16
|
+
encoding: 'utf8',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return res.status === 0 ? res.stdout : '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* True when `file` differs from HEAD in the index or on disk. Line endings do not count: a file
|
|
24
|
+
* stored with CRLF and checked out with LF is not an edit.
|
|
25
|
+
*/
|
|
26
|
+
function uncommitted(projectDir, file) {
|
|
27
|
+
const rel = `./${path.relative(projectDir, file).replaceAll('\\', '/')}`;
|
|
28
|
+
const norm = (t) => String(t).replace(/\r\n/g, '\n').trimEnd();
|
|
29
|
+
const head = norm(gitText(projectDir, `HEAD:${rel}`));
|
|
30
|
+
const disk = norm(existsSync(file) ? readFileSync(file, 'utf8') : '');
|
|
31
|
+
|
|
32
|
+
return head !== norm(gitText(projectDir, `:${rel}`)) || head !== disk;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** A worktree of the integrator (Methodology §7): its gcf/ state is main's to move. */
|
|
36
|
+
export const onWorkBranch = (projectDir) =>
|
|
37
|
+
/^work\//.test(
|
|
38
|
+
spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
39
|
+
windowsHide: true,
|
|
40
|
+
cwd: projectDir,
|
|
41
|
+
encoding: 'utf8',
|
|
42
|
+
}).stdout?.trim() ?? '',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {{files: string[], mutate: () => Promise<unknown>, commit: boolean, inputs?: string[],
|
|
47
|
+
* key?: string, items?: string[], proposal?: string}} Move
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Run a move that ends with its fixed-format commit, all of it or none of it. The commit takes
|
|
52
|
+
* whole files and deletes the unit's section, so any uncommitted edit in them refuses the move
|
|
53
|
+
* up front — an answer in the unit itself included: it would leave in a commit that never held
|
|
54
|
+
* it, and no history would keep it. `inputs` are the item files the move reads and rewrites:
|
|
55
|
+
* their own uncommitted edits (an answer, a live: delta) ride along on purpose.
|
|
56
|
+
* @param {string} projectDir
|
|
57
|
+
* @param {string} message
|
|
58
|
+
* `key` is the domain's move key, `items` the ids it touched and `proposal` the board's proposal
|
|
59
|
+
* it carries out: the commit's trailers (moveTrailers).
|
|
60
|
+
* @param {Move} move
|
|
61
|
+
* @returns {Promise<string | null>} the commit's hash, null when it does not commit
|
|
62
|
+
*/
|
|
63
|
+
export async function commitMove(projectDir, message, move) {
|
|
64
|
+
// A move that commits holds the main lock while it writes and commits (Methodology §7).
|
|
65
|
+
return move.commit
|
|
66
|
+
? withMainLock(projectDir, () => record(projectDir, message, move))
|
|
67
|
+
: record(projectDir, message, move);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @param {string} projectDir @param {string} message @param {Move} move */
|
|
71
|
+
async function record(
|
|
72
|
+
projectDir,
|
|
73
|
+
message,
|
|
74
|
+
{ files, mutate, commit, inputs = [], key, items, proposal },
|
|
75
|
+
) {
|
|
76
|
+
if (commit && onWorkBranch(projectDir))
|
|
77
|
+
throw new Error(
|
|
78
|
+
`cannot record ${message} on a work/ branch: a worktree records no move — the run ` +
|
|
79
|
+
'leaves .gcf-session/outcome.json, and the main checkout records it',
|
|
80
|
+
);
|
|
81
|
+
const busy = commit ? operationInProgress(projectDir) : null;
|
|
82
|
+
if (busy) throw new Error(`cannot record ${message} while ${busy} is in progress`);
|
|
83
|
+
const dirty = commit
|
|
84
|
+
? files.filter((f) => !inputs.includes(f) && uncommitted(projectDir, f))
|
|
85
|
+
: [];
|
|
86
|
+
if (dirty.length) {
|
|
87
|
+
const rels = dirty.map((f) => path.relative(projectDir, f).replaceAll('\\', '/'));
|
|
88
|
+
// The whole of gcf/'s edits, not only these: the gate would refuse the next one at once.
|
|
89
|
+
// Only when that set holds them all: a move's own file outside it (an archived plan) is no
|
|
90
|
+
// edit `gcf edits` takes, and a Commit of the rest would be refused again.
|
|
91
|
+
const all = dirtyGcf(projectDir, inputs);
|
|
92
|
+
throw dirtyRefusal(
|
|
93
|
+
rels.every((r) => all.includes(r)) ? all : [],
|
|
94
|
+
`commit or stash these first (an answered unit is committed before its move), ` +
|
|
95
|
+
`${message} would carry them: ${rels.join(', ')}`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const root = path.join(path.resolve(projectDir), 'gcf');
|
|
100
|
+
const touched = [...files, path.join(root, 'INDEX.md')];
|
|
101
|
+
/** @type {string | null} */
|
|
102
|
+
let hash = null;
|
|
103
|
+
await withFileRollback(
|
|
104
|
+
touched,
|
|
105
|
+
async () => {
|
|
106
|
+
await mutate();
|
|
107
|
+
await writeIndex(root);
|
|
108
|
+
if (commit) hash = commitPaths(projectDir, message, touched, { key, items, proposal });
|
|
109
|
+
},
|
|
110
|
+
{ gitCwd: commit ? path.resolve(projectDir) : null },
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return hash;
|
|
114
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// A YAML settings file as an editable document: the edit keeps the file's comments.
|
|
2
|
+
import YAML from 'yaml';
|
|
3
|
+
|
|
4
|
+
/** A YAML file as a document with a map on top: an edit keeps its comments. */
|
|
5
|
+
export function configDoc(text, name = 'gcf/config.yml') {
|
|
6
|
+
const doc = YAML.parseDocument(text);
|
|
7
|
+
if (doc.errors.length) throw new Error(`${name}: ${doc.errors[0].message}`);
|
|
8
|
+
// A file of a list or a word on top is not a settings file: replacing it would lose it.
|
|
9
|
+
if (doc.contents != null && !YAML.isMap(doc.contents) && doc.contents.toJSON() != null)
|
|
10
|
+
throw new Error(`${name} must map its keys`);
|
|
11
|
+
if (!YAML.isMap(doc.contents)) doc.contents = /** @type {any} */ (doc.createNode({}));
|
|
12
|
+
|
|
13
|
+
return doc;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Make `keys` a map. A blank key (`dod:` with nothing or only comments under it) is none yet. */
|
|
17
|
+
export function ensureMap(doc, keys, error) {
|
|
18
|
+
const node = doc.getIn(keys, true);
|
|
19
|
+
if (YAML.isMap(node)) return;
|
|
20
|
+
if (node != null && !(YAML.isScalar(node) && node.value == null)) throw new Error(error);
|
|
21
|
+
doc.setIn(keys, doc.createNode({}));
|
|
22
|
+
}
|