gcf-aif-ext 0.12.3 → 0.13.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 +277 -269
- package/commands/gcf.js +33 -5
- package/extension.json +1 -1
- package/lib/agent-permissions.js +1 -0
- package/lib/audit-core.js +2 -1
- package/lib/board.js +37 -6
- package/lib/config-set.js +1 -0
- package/lib/design-check.js +23 -8
- package/lib/domain.js +38 -11
- package/lib/git.js +40 -3
- package/lib/history.js +105 -0
- package/lib/integrate.js +16 -3
- package/lib/phase.js +1 -0
- package/lib/pillars.js +11 -1
- package/lib/questions.js +1 -0
- package/lib/unit-ops.js +19 -5
- package/lib/work-ops.js +41 -12
- package/package.json +1 -1
- package/templates/agents-block.md +2 -0
package/commands/gcf.js
CHANGED
|
@@ -741,6 +741,27 @@ function registerItem(gcf) {
|
|
|
741
741
|
});
|
|
742
742
|
registerAttach(item);
|
|
743
743
|
registerAgent(item);
|
|
744
|
+
registerHistory(item);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function registerHistory(item) {
|
|
748
|
+
item
|
|
749
|
+
.command('history <id>')
|
|
750
|
+
.description("An item's moves from git, newest first (an ended item's too)")
|
|
751
|
+
.option('--json', 'as JSON: {id, moves: [{at, commit, move, subject, by}]}')
|
|
752
|
+
.action(async (id, o) => {
|
|
753
|
+
if (!(await lib('id')).isValidId(id)) throw new Error(`${id} is not an item id`);
|
|
754
|
+
const moves = (await lib('history')).itemHistory(process.cwd(), id);
|
|
755
|
+
if (o.json) {
|
|
756
|
+
console.log(JSON.stringify({ id, moves }, null, 2));
|
|
757
|
+
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (!moves.length) console.log(`${id}: no moves in git`);
|
|
762
|
+
for (const m of moves)
|
|
763
|
+
console.log(`${m.at} ${m.commit} ${m.move} (${m.by ?? '?'}) ${m.subject}`);
|
|
764
|
+
});
|
|
744
765
|
}
|
|
745
766
|
|
|
746
767
|
function registerAgent(item) {
|
|
@@ -907,8 +928,9 @@ function registerDecide(gcf) {
|
|
|
907
928
|
* @param {boolean | undefined} commit
|
|
908
929
|
* @param {string} message
|
|
909
930
|
* @param {{files: string[], inputs?: string[], apply: () => Promise<unknown>}} plan
|
|
931
|
+
* @param {string} key the domain's move key, for the commit's trailer
|
|
910
932
|
*/
|
|
911
|
-
async function inboxMove(commit, message, plan) {
|
|
933
|
+
async function inboxMove(commit, message, plan, key) {
|
|
912
934
|
if (!commit) {
|
|
913
935
|
await plan.apply();
|
|
914
936
|
|
|
@@ -925,6 +947,7 @@ async function inboxMove(commit, message, plan) {
|
|
|
925
947
|
await plan.apply();
|
|
926
948
|
},
|
|
927
949
|
commit: true,
|
|
950
|
+
key,
|
|
928
951
|
});
|
|
929
952
|
}
|
|
930
953
|
|
|
@@ -950,7 +973,7 @@ function registerInboxTag(inbox) {
|
|
|
950
973
|
add: splitList(o.add),
|
|
951
974
|
remove: splitList(o.remove),
|
|
952
975
|
});
|
|
953
|
-
const hash = await inboxMove(o.commit, `gcf(inbox): tag ${id}`, plan);
|
|
976
|
+
const hash = await inboxMove(o.commit, `gcf(inbox): tag ${id}`, plan, 'inbox-tag');
|
|
954
977
|
console.log(`${id} tags: ${plan.tags.join(', ') || 'none'}${shortHash(hash)}`);
|
|
955
978
|
});
|
|
956
979
|
}
|
|
@@ -986,7 +1009,12 @@ function registerInboxDrop(inbox) {
|
|
|
986
1009
|
const { inHead } = await lib('git');
|
|
987
1010
|
const committed = inHead(process.cwd(), plan.files[0]);
|
|
988
1011
|
// An entry never committed leaves nothing to commit: it is only erased, from the index too.
|
|
989
|
-
const hash = await inboxMove(
|
|
1012
|
+
const hash = await inboxMove(
|
|
1013
|
+
o.commit && committed,
|
|
1014
|
+
`gcf(inbox): drop ${id}`,
|
|
1015
|
+
plan,
|
|
1016
|
+
'inbox-drop',
|
|
1017
|
+
);
|
|
990
1018
|
if (!committed)
|
|
991
1019
|
spawnSync('git', ['rm', '--cached', '-q', '--ignore-unmatch', '--', ...plan.files], {
|
|
992
1020
|
cwd: process.cwd(),
|
|
@@ -1041,7 +1069,7 @@ function registerInbox(gcf) {
|
|
|
1041
1069
|
const { planAdd } = await lib('inbox');
|
|
1042
1070
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1043
1071
|
const plan = planAdd(gcfRoot(), text, o.source, { tags: splitList(o.tags) });
|
|
1044
|
-
const hash = await inboxMove(o.commit, 'gcf(inbox): add', plan);
|
|
1072
|
+
const hash = await inboxMove(o.commit, 'gcf(inbox): add', plan, 'inbox-add');
|
|
1045
1073
|
console.log(`${plan.entry.id}${shortHash(hash)}`);
|
|
1046
1074
|
});
|
|
1047
1075
|
registerInboxTag(inbox);
|
|
@@ -1082,7 +1110,7 @@ function registerLessons(gcf) {
|
|
|
1082
1110
|
if (!list.length) return console.log(`recorded 0 lessons for ${id}`);
|
|
1083
1111
|
const { gcfRoot } = await lib('gcf-paths');
|
|
1084
1112
|
const plan = planLessons(gcfRoot(), id, list);
|
|
1085
|
-
const hash = await inboxMove(o.commit, `gcf(lessons): ${id}`, plan);
|
|
1113
|
+
const hash = await inboxMove(o.commit, `gcf(lessons): ${id}`, plan, 'lessons');
|
|
1086
1114
|
console.log(`recorded ${plan.entries.length} lessons for ${id}${shortHash(hash)}`);
|
|
1087
1115
|
});
|
|
1088
1116
|
}
|
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.13.0",
|
|
5
5
|
"description": "Game Context Framework for AI Factory",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-init",
|
package/lib/agent-permissions.js
CHANGED
package/lib/audit-core.js
CHANGED
|
@@ -266,7 +266,8 @@ function staleQuestions(projectDir, root, config) {
|
|
|
266
266
|
*/
|
|
267
267
|
function verdictMatchers(projectDir, ledger, items) {
|
|
268
268
|
const tuned = items.filter((c) => (c.data.tune_count ?? 0) > 0);
|
|
269
|
-
const verdictLog =
|
|
269
|
+
const verdictLog =
|
|
270
|
+
git(['log', '--basic-regexp', '--grep', '^gcf(verdict):', '--format=%s'], projectDir) ?? '';
|
|
270
271
|
|
|
271
272
|
return {
|
|
272
273
|
verdict: (id) =>
|
package/lib/board.js
CHANGED
|
@@ -21,6 +21,7 @@ import { listQuestions } from './questions.js';
|
|
|
21
21
|
import { sessionActive } from './session-mark.js';
|
|
22
22
|
import { agentOf } from './agent-permissions.js';
|
|
23
23
|
import { projectSettings } from './config-set.js';
|
|
24
|
+
import { designUnits } from './design-check.js';
|
|
24
25
|
|
|
25
26
|
// The version of the JSON below (Methodology §11): a board refuses one it does not know. Bump it
|
|
26
27
|
// when a field changes meaning or goes away; a new field does not bump it.
|
|
@@ -241,6 +242,30 @@ function inRunOrder(items) {
|
|
|
241
242
|
|
|
242
243
|
const LISTS = ['children', 'system', 'depends'];
|
|
243
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Its dependencies not ended in history (Board-PRD §5.2): items on the board, design units,
|
|
247
|
+
* graveyard ids and unknown ones. `waits_for` is the part the run gate refuses on now.
|
|
248
|
+
*/
|
|
249
|
+
const needsOf = (ledger, depends) =>
|
|
250
|
+
depends.filter((d) => {
|
|
251
|
+
const { live, terminal } = ledger.where(d);
|
|
252
|
+
|
|
253
|
+
return live.length > 0 || !terminal.some((t) => t !== 'killed');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/** The live design units for the board's pickers: the design check's summary of each. */
|
|
257
|
+
const unitsOf = async (projectDir, ledger) =>
|
|
258
|
+
(await designUnits(projectDir, ledger)).map((u) => ({
|
|
259
|
+
id: u.id,
|
|
260
|
+
title: u.title,
|
|
261
|
+
type: u.type,
|
|
262
|
+
system: u.system,
|
|
263
|
+
file: `gcf/${u.file}`,
|
|
264
|
+
tbd: u.tbd,
|
|
265
|
+
blocked_by: u.blocked_by,
|
|
266
|
+
ready: u.ready,
|
|
267
|
+
}));
|
|
268
|
+
|
|
244
269
|
/** `run`, `session` or null. A harness run's lock wins over the mark its run on main holds. */
|
|
245
270
|
function runningKind(projectDir, id) {
|
|
246
271
|
if (runHolder(projectDir, id) !== null) return 'run';
|
|
@@ -259,6 +284,15 @@ function offered(c, { running, verified, harness }) {
|
|
|
259
284
|
return [...(runs ? ['run'] : []), ...movesOf(c.data)];
|
|
260
285
|
}
|
|
261
286
|
|
|
287
|
+
/**
|
|
288
|
+
* The dependencies the run gate would refuse a ready item on now (Board-PRD §5.2); none while
|
|
289
|
+
* it runs, past the gate.
|
|
290
|
+
*/
|
|
291
|
+
const waitsOf = (c, running, ledger) =>
|
|
292
|
+
c.data.status === 'ready' && !running
|
|
293
|
+
? openDepends(ledger, c.data.depends ?? [], { waiting: true })
|
|
294
|
+
: [];
|
|
295
|
+
|
|
262
296
|
/** One item of the board. */
|
|
263
297
|
async function itemOf(projectDir, c, { verified, ledger, harness }) {
|
|
264
298
|
const id = String(c.data.id);
|
|
@@ -292,12 +326,8 @@ async function itemOf(projectDir, c, { verified, ledger, harness }) {
|
|
|
292
326
|
resumable,
|
|
293
327
|
resume,
|
|
294
328
|
verified: ready,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
waits_for:
|
|
298
|
-
c.data.status === 'ready' && !running
|
|
299
|
-
? openDepends(ledger, c.data.depends ?? [], { waiting: true })
|
|
300
|
-
: [],
|
|
329
|
+
waits_for: waitsOf(c, running, ledger),
|
|
330
|
+
needs: needsOf(ledger, c.data.depends ?? []),
|
|
301
331
|
moves: offered(c, { running, verified: ready, harness }),
|
|
302
332
|
file: `gcf/work/${c.name}`,
|
|
303
333
|
log: logOf(projectDir, id),
|
|
@@ -361,5 +391,6 @@ export async function board(projectDir) {
|
|
|
361
391
|
questions: await listQuestions(root),
|
|
362
392
|
history: await historyOf(root),
|
|
363
393
|
graveyard: await graveyardOf(root),
|
|
394
|
+
units: await unitsOf(projectDir, ledger),
|
|
364
395
|
};
|
|
365
396
|
}
|
package/lib/config-set.js
CHANGED
|
@@ -276,6 +276,7 @@ export async function setConfig(projectDir, key, text, { commit = true } = {}) {
|
|
|
276
276
|
inputs,
|
|
277
277
|
mutate,
|
|
278
278
|
commit: commit && !ignored,
|
|
279
|
+
key: 'config',
|
|
279
280
|
});
|
|
280
281
|
const mutate = async () => {
|
|
281
282
|
const text = existsSync(file) ? await readFile(file, 'utf8') : '';
|
package/lib/design-check.js
CHANGED
|
@@ -726,6 +726,7 @@ function unitSummary(u, own, values, ctx) {
|
|
|
726
726
|
|
|
727
727
|
return {
|
|
728
728
|
id: u.id,
|
|
729
|
+
title: u.header.title ?? null,
|
|
729
730
|
file: u.file,
|
|
730
731
|
system: u.system,
|
|
731
732
|
type: u.header.type ?? null,
|
|
@@ -739,14 +740,8 @@ function unitSummary(u, own, values, ctx) {
|
|
|
739
740
|
};
|
|
740
741
|
}
|
|
741
742
|
|
|
742
|
-
/**
|
|
743
|
-
|
|
744
|
-
* the rest of the report (completeness, readiness, pillars) is a reading, not a gate.
|
|
745
|
-
*/
|
|
746
|
-
export async function designCheck(projectDir) {
|
|
747
|
-
const root = path.join(path.resolve(projectDir), 'gcf');
|
|
748
|
-
const ledger = await buildLedger(projectDir);
|
|
749
|
-
const ctx = await loadContext(root);
|
|
743
|
+
/** The checks of each design unit: their issues and each unit's summary line. */
|
|
744
|
+
async function checkUnits(ledger, ctx) {
|
|
750
745
|
/** @type {Issue[]} */
|
|
751
746
|
const issues = [];
|
|
752
747
|
const units = [];
|
|
@@ -756,6 +751,26 @@ export async function designCheck(projectDir) {
|
|
|
756
751
|
units.push(unitSummary(u, own, values, ctx));
|
|
757
752
|
}
|
|
758
753
|
|
|
754
|
+
return { issues, units };
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/** The summary line of each live design unit, without the rest of the design check. */
|
|
758
|
+
export async function designUnits(projectDir, ledger) {
|
|
759
|
+
const root = path.join(path.resolve(projectDir), 'gcf');
|
|
760
|
+
|
|
761
|
+
return (await checkUnits(ledger, await loadContext(root))).units;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Run every design check over a project. `blocking` counts the issues that refuse a commit;
|
|
766
|
+
* the rest of the report (completeness, readiness, pillars) is a reading, not a gate.
|
|
767
|
+
*/
|
|
768
|
+
export async function designCheck(projectDir) {
|
|
769
|
+
const root = path.join(path.resolve(projectDir), 'gcf');
|
|
770
|
+
const ledger = await buildLedger(projectDir);
|
|
771
|
+
const ctx = await loadContext(root);
|
|
772
|
+
const { issues, units } = await checkUnits(ledger, ctx);
|
|
773
|
+
|
|
759
774
|
for (const c of ledger.items) issues.push(...(await checkItem(c, ctx, ledger)));
|
|
760
775
|
issues.push(...(await unplayedIssues(root, ledger)));
|
|
761
776
|
for (const doc of ['game', 'glossary']) issues.push(...(await checkDoc(root, doc, ctx)));
|
package/lib/domain.js
CHANGED
|
@@ -47,11 +47,12 @@ const UNVERIFIED = {
|
|
|
47
47
|
label: 'No green gcf verify? Why it goes anyway',
|
|
48
48
|
kind: 'text',
|
|
49
49
|
};
|
|
50
|
-
// And a plan with tasks left unticked (AD-50).
|
|
50
|
+
// And a plan with tasks left unticked (AD-50): the board says how many (`excuses: plan`).
|
|
51
51
|
const UNTICKED = {
|
|
52
52
|
key: 'unticked',
|
|
53
53
|
label: 'Plan tasks unticked? Why it goes anyway',
|
|
54
54
|
kind: 'text',
|
|
55
|
+
excuses: 'plan',
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
const verdict = (v, help, fields, danger) => ({
|
|
@@ -234,7 +235,7 @@ const NEW_ITEM = {
|
|
|
234
235
|
text('channel', 'Channel', { required: true, when: { key: 'type', is: ['release'] } }),
|
|
235
236
|
text('title', 'Title: one line, what it gives'),
|
|
236
237
|
text('system', 'Subsystems, comma-separated'),
|
|
237
|
-
|
|
238
|
+
{ key: 'depends', label: 'Depends on ids, comma-separated', kind: 'ids' },
|
|
238
239
|
text('parent', 'Parent feature id'),
|
|
239
240
|
text('milestone', 'Milestone'),
|
|
240
241
|
text('blocked', 'Start blocked: why (e.g. "file needed")'),
|
|
@@ -261,7 +262,13 @@ const BLOCK_SPECS = {
|
|
|
261
262
|
help: 'On to the next phase; against an unmet criterion only with a reason',
|
|
262
263
|
args: ['gcf', 'phase', 'next'],
|
|
263
264
|
fields: [
|
|
264
|
-
|
|
265
|
+
// Needed only against an unmet criterion: the board knows from the phase (`excuses`).
|
|
266
|
+
{
|
|
267
|
+
key: 'reason',
|
|
268
|
+
label: 'Reason (needed when a criterion is not met)',
|
|
269
|
+
kind: 'longtext',
|
|
270
|
+
excuses: 'phase',
|
|
271
|
+
},
|
|
265
272
|
],
|
|
266
273
|
},
|
|
267
274
|
'inbox-add': {
|
|
@@ -311,10 +318,11 @@ const BLOCK_SPECS = {
|
|
|
311
318
|
};
|
|
312
319
|
|
|
313
320
|
// The item fields a board shows: on the card (`card`), in the drawer (all that have a value).
|
|
321
|
+
// `filter`: the board offers a filter by it; `group`: lanes by it.
|
|
314
322
|
const GATE_FIELD_OPTIONS = GATES.map((g) => ({ value: g, label: g, help: GATE_HELP[g] }));
|
|
315
323
|
const FIELDS = [
|
|
316
324
|
{ key: 'priority', label: 'priority', kind: 'rank', help: 'Rank: lower runs sooner', card: true },
|
|
317
|
-
{ key: 'type', label: 'type', kind: 'text', card: true, badge: true },
|
|
325
|
+
{ key: 'type', label: 'type', kind: 'text', card: true, badge: true, filter: true },
|
|
318
326
|
{
|
|
319
327
|
key: 'gate',
|
|
320
328
|
label: 'gate',
|
|
@@ -323,8 +331,9 @@ const FIELDS = [
|
|
|
323
331
|
help: 'Who closes it',
|
|
324
332
|
card: true,
|
|
325
333
|
badge: true,
|
|
334
|
+
filter: true,
|
|
326
335
|
},
|
|
327
|
-
{ key: 'severity', label: 'severity', kind: 'text', card: true, badge: true },
|
|
336
|
+
{ key: 'severity', label: 'severity', kind: 'text', card: true, badge: true, filter: true },
|
|
328
337
|
// `edit`: the move that changes it, from the drawer.
|
|
329
338
|
{ key: 'model', label: 'model', kind: 'text', card: true, edit: 'agent' },
|
|
330
339
|
{ key: 'effort', label: 'effort', kind: 'text', edit: 'agent' },
|
|
@@ -336,12 +345,26 @@ const FIELDS = [
|
|
|
336
345
|
help: 'The run gate refuses it until these are played',
|
|
337
346
|
card: true,
|
|
338
347
|
},
|
|
339
|
-
{ key: 'depends', label: 'depends', kind: 'ids' },
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
{ key: 'depends', label: 'depends', kind: 'ids', edit: 'depends' },
|
|
349
|
+
{
|
|
350
|
+
key: 'needed_by',
|
|
351
|
+
label: 'needed by',
|
|
352
|
+
kind: 'ids',
|
|
353
|
+
help: 'The items that wait for this one',
|
|
354
|
+
card: true,
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
key: 'needs',
|
|
358
|
+
label: 'needs',
|
|
359
|
+
kind: 'ids',
|
|
360
|
+
help: 'Its dependencies that have not ended in history yet',
|
|
361
|
+
card: true,
|
|
362
|
+
},
|
|
363
|
+
{ key: 'system', label: 'system', kind: 'list', filter: true, group: true },
|
|
364
|
+
// One id: a board shows an `ids` field's single value as that one id.
|
|
365
|
+
{ key: 'parent', label: 'parent', kind: 'ids', group: true },
|
|
343
366
|
{ key: 'children', label: 'children', kind: 'ids' },
|
|
344
|
-
{ key: 'milestone', label: 'milestone', kind: 'text' },
|
|
367
|
+
{ key: 'milestone', label: 'milestone', kind: 'text', filter: true, group: true },
|
|
345
368
|
{ key: 'blocked', label: 'blocked', kind: 'longtext', help: 'Why it stopped', card: true },
|
|
346
369
|
];
|
|
347
370
|
|
|
@@ -375,11 +398,15 @@ const SECTIONS = {
|
|
|
375
398
|
questions: { answer: 'question-answer' },
|
|
376
399
|
lessons: {},
|
|
377
400
|
playtest: {
|
|
401
|
+
// The inbox source a note from the playtest screen goes with.
|
|
402
|
+
source: 'playtest',
|
|
378
403
|
waits: ['awaiting-verdict', 'unplayed'],
|
|
379
404
|
verdicts: ['verdict:keep', 'verdict:tune', 'verdict:kill'],
|
|
380
405
|
},
|
|
381
406
|
history: { label: 'Accepted' },
|
|
382
|
-
|
|
407
|
+
// `match`: the item's field Related holds against the graveyard's tags.
|
|
408
|
+
graveyard: { label: 'Graveyard', match: 'system' },
|
|
409
|
+
units: { label: 'Design units' },
|
|
383
410
|
};
|
|
384
411
|
|
|
385
412
|
// The gcf commands that change the project: a project chat asks the operator before each one
|
package/lib/git.js
CHANGED
|
@@ -51,17 +51,54 @@ export function dirtyPaths(projectDir, paths) {
|
|
|
51
51
|
return res.status === 0 ? res.stdout.split('\n').filter(Boolean) : [];
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
const BY = ['run', 'session', 'operator'];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Who makes a move: `GCF_MOVE_BY` when it names one (the harness sets `run` for both run modes),
|
|
58
|
+
* else a harness run's owner, else a Claude Code session, else the operator.
|
|
59
|
+
*/
|
|
60
|
+
export function moveBy(env = process.env) {
|
|
61
|
+
if (BY.includes(env.GCF_MOVE_BY ?? '')) return /** @type {string} */ (env.GCF_MOVE_BY);
|
|
62
|
+
if (env.GCF_RUN_OWNER) return 'run';
|
|
63
|
+
|
|
64
|
+
return env.CLAUDE_CODE_SESSION_ID ? 'session' : 'operator';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The trailer paragraph of a move's commit as `git commit`/`git merge` arguments (`gcf item
|
|
69
|
+
* history` reads it): the items and units it touched, the domain's move key, who made it. A
|
|
70
|
+
* separate `-m`, not `--trailer`: any git version takes it. None without a move key.
|
|
71
|
+
* @param {{key?: string, items?: string[]}} [move]
|
|
72
|
+
*/
|
|
73
|
+
export function moveTrailers({ key, items = [] } = {}) {
|
|
74
|
+
if (!key) return [];
|
|
75
|
+
const ids = [...new Set(items)];
|
|
76
|
+
const lines = [
|
|
77
|
+
...(ids.length ? [`GCF-Items: ${ids.join(', ')}`] : []),
|
|
78
|
+
`GCF-Move: ${key}`,
|
|
79
|
+
`GCF-By: ${moveBy()}`,
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
return ['-m', lines.join('\n')];
|
|
83
|
+
}
|
|
84
|
+
|
|
54
85
|
/**
|
|
55
86
|
* Stage and commit exactly `paths`: `git add -- gcf/` would stage a user's unrelated edits
|
|
56
87
|
* under gcf/, and a rollback only restores what it snapshotted. A path that neither exists nor
|
|
57
|
-
* is tracked is left out — git refuses a pathspec that matches nothing.
|
|
88
|
+
* is tracked is left out — git refuses a pathspec that matches nothing. `move` gives the
|
|
89
|
+
* commit its trailers (moveTrailers). Returns the new HEAD.
|
|
90
|
+
* @param {string} projectDir
|
|
91
|
+
* @param {string} message
|
|
92
|
+
* @param {string[]} paths
|
|
93
|
+
* @param {{key?: string, items?: string[]}} [move]
|
|
58
94
|
*/
|
|
59
|
-
export function commitPaths(projectDir, message, paths) {
|
|
95
|
+
export function commitPaths(projectDir, message, paths, move = {}) {
|
|
60
96
|
const staged = paths.filter((p) => existsSync(p) || tracked(projectDir, p));
|
|
61
97
|
for (const p of staged) spawnSync('git', ['add', '--', p], { cwd: projectDir, stdio: 'ignore' });
|
|
62
98
|
// A file staged but never committed and now deleted is out of the index too: no pathspec.
|
|
63
99
|
const real = staged.filter((p) => existsSync(p) || inHead(projectDir, p));
|
|
64
|
-
const
|
|
100
|
+
const msg = ['-m', message, ...moveTrailers(move)];
|
|
101
|
+
const res = spawnSync('git', ['commit', ...msg, '--only', '--', ...real], {
|
|
65
102
|
cwd: projectDir,
|
|
66
103
|
encoding: 'utf8',
|
|
67
104
|
});
|
package/lib/history.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// `gcf item history <id>` (board v2): the moves an item went through, read from git. A move's
|
|
2
|
+
// commit carries trailers (git.js moveTrailers): GCF-Items, GCF-Move, GCF-By. A commit older
|
|
3
|
+
// than them is read by its subject's fixed format, the id taken only from its place in it.
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
export const HISTORY_MAX = 200;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The subjects of the moves before the trailers: each gives the domain's move key and the ids
|
|
10
|
+
* it moved. A system name in a verdict's tail (`keep dash → movement`) names no item.
|
|
11
|
+
* shortcut: a feature kill's children are not in its subject, so an old kill shows in the
|
|
12
|
+
* feature's history only; the trailers carry them from now on.
|
|
13
|
+
* @type {[RegExp, (m: RegExpMatchArray) => {move: string, ids: string[]}][]}
|
|
14
|
+
*/
|
|
15
|
+
export const OLD_SUBJECTS = [
|
|
16
|
+
[/^gcf\(verdict\): (keep|tune|kill) (\S+) →/, (m) => ({ move: `verdict:${m[1]}`, ids: [m[2]] })],
|
|
17
|
+
// Before 2026-10-09 a verdict named the card's number, then its slug.
|
|
18
|
+
[
|
|
19
|
+
/^gcf\(verdict\): (keep|tune|kill) \S+ (\S+) →/,
|
|
20
|
+
(m) => ({ move: `verdict:${m[1]}`, ids: [m[2]] }),
|
|
21
|
+
],
|
|
22
|
+
[/^gcf\(decide\): ([a-z]+) (\S+)$/, (m) => ({ move: `decide:${m[1]}`, ids: [m[2]] })],
|
|
23
|
+
[/^gcf\(priority\): (\S+(?:, \S+)*)$/, (m) => ({ move: 'prioritize', ids: m[1].split(', ') })],
|
|
24
|
+
[/^gcf\(item\): (\S+) model \S+, effort \S+$/, (m) => ({ move: 'agent', ids: [m[1]] })],
|
|
25
|
+
[/^gcf\(item\): (\S+)$/, (m) => ({ move: 'item-new', ids: [m[1]] })],
|
|
26
|
+
[/^gcf\(integrate\): (\S+)(?: plan)?$/, (m) => ({ move: 'integrate', ids: [m[1]] })],
|
|
27
|
+
// A submit or close may say why it went without a green verify or with tasks unticked.
|
|
28
|
+
[/^gcf\((submit|close)\): (\S+)(?: |$)/, (m) => ({ move: m[1], ids: [m[2]] })],
|
|
29
|
+
[
|
|
30
|
+
/^gcf\((block|unblock|drop|done|depends|attach|verified)\): (\S+)$/,
|
|
31
|
+
(m) => ({ move: m[1], ids: [m[2]] }),
|
|
32
|
+
],
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/** The move key and ids of a commit subject older than the trailers, or null. */
|
|
36
|
+
export function oldMove(subject) {
|
|
37
|
+
for (const [re, read] of OLD_SUBJECTS) {
|
|
38
|
+
const m = subject.match(re);
|
|
39
|
+
if (m) return read(m);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A trailer's value in a commit body, or null: from its last paragraph only, where the trailers
|
|
47
|
+
* stand. Words an operator gave the commit (a phase's reason) come before it and name no move.
|
|
48
|
+
*/
|
|
49
|
+
const trailer = (body, key) =>
|
|
50
|
+
(
|
|
51
|
+
body
|
|
52
|
+
.trim()
|
|
53
|
+
.split(/\n\s*\n/)
|
|
54
|
+
.at(-1) ?? ''
|
|
55
|
+
)
|
|
56
|
+
.match(new RegExp(`^${key}: *(.*)$`, 'm'))?.[1]
|
|
57
|
+
.trim() ?? null;
|
|
58
|
+
|
|
59
|
+
const BY = ['run', 'session', 'operator'];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* What one commit says of item `id`: `{move, by}` when it moved the item, else null. A commit
|
|
63
|
+
* with a GCF-Move trailer is read by its trailers only.
|
|
64
|
+
*/
|
|
65
|
+
export function moveOf(subject, body, id) {
|
|
66
|
+
const key = trailer(body, 'GCF-Move');
|
|
67
|
+
if (key) {
|
|
68
|
+
const items = (trailer(body, 'GCF-Items') ?? '').split(',').map((s) => s.trim());
|
|
69
|
+
if (!items.includes(id)) return null;
|
|
70
|
+
const by = trailer(body, 'GCF-By');
|
|
71
|
+
|
|
72
|
+
return { move: key, by: BY.includes(by ?? '') ? by : null };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const old = oldMove(subject);
|
|
76
|
+
|
|
77
|
+
return old?.ids.includes(id) ? { move: old.move, by: null } : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Field and record separators git writes between the parts of each commit.
|
|
81
|
+
const FS = '\x1f';
|
|
82
|
+
const RS = '\x1e';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The moves of item `id`, newest first, up to `limit`: `{at, commit, move, subject, by}`. An item
|
|
86
|
+
* that ended (history, graveyard) keeps them: its commits stay in git. [] outside a repository.
|
|
87
|
+
*/
|
|
88
|
+
export function itemHistory(projectDir, id, { limit = HISTORY_MAX } = {}) {
|
|
89
|
+
const res = spawnSync(
|
|
90
|
+
'git',
|
|
91
|
+
['log', `--format=%h${FS}%cI${FS}%s${FS}%b${RS}`, '--fixed-strings', '--grep=gcf(', '--'],
|
|
92
|
+
{ cwd: projectDir, encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 },
|
|
93
|
+
);
|
|
94
|
+
if (res.status !== 0) return [];
|
|
95
|
+
const moves = [];
|
|
96
|
+
for (const rec of res.stdout.split(RS)) {
|
|
97
|
+
const [commit, at, subject, body = ''] = rec.replace(/^\n/, '').split(FS);
|
|
98
|
+
if (!subject?.startsWith('gcf(')) continue;
|
|
99
|
+
const move = moveOf(subject, body, id);
|
|
100
|
+
if (move) moves.push({ at, commit, move: move.move, subject, by: move.by });
|
|
101
|
+
if (moves.length >= limit) break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return moves;
|
|
105
|
+
}
|
package/lib/integrate.js
CHANGED
|
@@ -13,6 +13,7 @@ import { verifyItem, deltaProblems } from './verify.js';
|
|
|
13
13
|
import { submitItem, closeItem, blockItem } from './work-ops.js';
|
|
14
14
|
import { isValidId } from './id.js';
|
|
15
15
|
import { writeIndex } from './index-gen.js';
|
|
16
|
+
import { moveTrailers } from './git.js';
|
|
16
17
|
|
|
17
18
|
const TRAILER = 'GCF-Verified';
|
|
18
19
|
export const branchOf = (id) => `work/${id}`;
|
|
@@ -129,7 +130,9 @@ export async function markVerified(worktreeDir, id, opts = {}) {
|
|
|
129
130
|
throw new Error('commit the work first: the trailer marks a commit, not a working tree');
|
|
130
131
|
const r = await verifyItem(worktreeDir, id, opts);
|
|
131
132
|
if (!r.ok) return { ...r, marked: false };
|
|
132
|
-
|
|
133
|
+
// One trailer paragraph: git reads trailers from the last paragraph only.
|
|
134
|
+
const [, trailers] = moveTrailers({ key: 'verified', items: [id] });
|
|
135
|
+
const msg = ['-m', `gcf(verified): ${id}`, '-m', `${TRAILER}: ${id}\n${trailers}`];
|
|
133
136
|
git(worktreeDir, ['commit', '--allow-empty', ...msg]);
|
|
134
137
|
|
|
135
138
|
return { ...r, marked: true };
|
|
@@ -252,7 +255,15 @@ async function integrateSpike(projectDir, item) {
|
|
|
252
255
|
git(projectDir, ['checkout', branchOf(id), '--', plan]);
|
|
253
256
|
// A plan main already holds as it is (a rerun after a crash) has nothing to commit.
|
|
254
257
|
if (!git(projectDir, ['diff', '--cached', '--quiet', '--', plan], { check: false }).ok)
|
|
255
|
-
git(projectDir, [
|
|
258
|
+
git(projectDir, [
|
|
259
|
+
'commit',
|
|
260
|
+
'-m',
|
|
261
|
+
`gcf(integrate): ${id} plan`,
|
|
262
|
+
...moveTrailers({ key: 'integrate', items: [id] }),
|
|
263
|
+
'--only',
|
|
264
|
+
'--',
|
|
265
|
+
plan,
|
|
266
|
+
]);
|
|
256
267
|
}
|
|
257
268
|
|
|
258
269
|
git(projectDir, ['tag', '-f', `spike/${id}`, branchOf(id)]);
|
|
@@ -263,7 +274,8 @@ async function integrateSpike(projectDir, item) {
|
|
|
263
274
|
|
|
264
275
|
/** Merge the branch; null when it went in, else the conflict or the refusal. */
|
|
265
276
|
async function mergeBranch(projectDir, id) {
|
|
266
|
-
const
|
|
277
|
+
const msg = ['-m', `gcf(integrate): ${id}`, ...moveTrailers({ key: 'integrate', items: [id] })];
|
|
278
|
+
const args = ['merge', '--no-ff', '--no-edit', ...msg, branchOf(id)];
|
|
267
279
|
const merge = git(projectDir, args, { check: false });
|
|
268
280
|
if (merge.ok || (await mergedPastIndex(projectDir))) return null;
|
|
269
281
|
const head = ['rev-parse', '-q', '--verify', 'MERGE_HEAD'];
|
|
@@ -337,6 +349,7 @@ function commitMetrics(projectDir) {
|
|
|
337
349
|
'--no-verify',
|
|
338
350
|
'-m',
|
|
339
351
|
'gcf(metrics): run logs',
|
|
352
|
+
...moveTrailers({ key: 'metrics' }),
|
|
340
353
|
'--only',
|
|
341
354
|
'--',
|
|
342
355
|
'gcf/.metrics',
|
package/lib/phase.js
CHANGED
|
@@ -227,6 +227,7 @@ async function nextPhaseUnlocked(projectDir, { reason = '', commit = true } = {}
|
|
|
227
227
|
files: [liveFile(root)],
|
|
228
228
|
mutate: () => writeLive(root, { ...live, phase: status.next }),
|
|
229
229
|
commit,
|
|
230
|
+
key: 'phase-next',
|
|
230
231
|
});
|
|
231
232
|
|
|
232
233
|
return { from: status.phase, to: status.next, forced: unmet.map((c) => c.name), hash };
|
package/lib/pillars.js
CHANGED
|
@@ -66,9 +66,19 @@ async function revise(projectDir, id, { edit, editPillars, tail, commit }) {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
const units = ledger.design
|
|
70
|
+
.flatMap((d) => d.units)
|
|
71
|
+
.filter((u) => [listOf(u.header.pillars)].flat().includes(id));
|
|
72
|
+
|
|
69
73
|
return {
|
|
70
74
|
id,
|
|
71
|
-
hash: await commitMove(projectDir, `gcf(pillar): ${tail}`, {
|
|
75
|
+
hash: await commitMove(projectDir, `gcf(pillar): ${tail}`, {
|
|
76
|
+
files,
|
|
77
|
+
mutate,
|
|
78
|
+
commit,
|
|
79
|
+
key: 'pillar',
|
|
80
|
+
items: [...units.map((u) => u.id), ...items.map((c) => String(c.data.id))],
|
|
81
|
+
}),
|
|
72
82
|
bare: items.filter((c) => !edit(c.data.pillars).length).map((c) => String(c.data.id)),
|
|
73
83
|
};
|
|
74
84
|
}
|
package/lib/questions.js
CHANGED