gcf-harness-aif-ext 0.18.2 → 0.20.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 +10 -0
- package/commands/harness.js +167 -15
- package/commands/metrics.js +1 -1
- package/commands/milestones.js +1 -1
- package/commands/run.js +279 -11
- package/extension.json +1 -1
- package/hooks/implement-guard.js +4 -1
- package/node_modules/gcf-session/lib/activity.js +19 -6
- package/node_modules/gcf-session/lib/chat.js +115 -8
- package/node_modules/gcf-session/lib/store.js +14 -2
- package/node_modules/gcf-session/lib/thread.js +6 -17
- package/node_modules/gcf-session/package.json +1 -1
- package/node_modules/gcf-session/types/index.d.ts +26 -0
- package/package.json +2 -2
- package/skills/gcf-run/SKILL.md +15 -4
package/README.md
CHANGED
|
@@ -47,6 +47,16 @@ Updating keeps the hook entry valid — it points into the extension's install d
|
|
|
47
47
|
|
|
48
48
|
0.5.1 is a fix release. During a run, `gcf/config.yml` is always readable, and a Grep inside `gcf/` reads only readset files. An import breaks a `depends:` cycle the pair checks closed and asks a D1 about it. It cuts a section longer than a segment at paragraphs, and lens and pair prompts carry a window around the quote. `/gcf-run` checks the plan against each pillar's invariant and asks each pillar's review question over the diff. Use it with core 0.4.1, which brings the parent feature into the readset.
|
|
49
49
|
|
|
50
|
+
0.20.0 (bundled gcf-session 0.17.4): each item's run chat ends with `run_end`: the outcome, the reason word for word, cost, duration, main's commit, plan tasks left unticked, lessons, a broken step. The board draws it as the run's end card.
|
|
51
|
+
|
|
52
|
+
0.19.1: `next --plan` first closes the features whose children are all finished: a keep by the operator, with no run after it, finishes them too. `card` reports a unit that left design without its item as `drop` (a `gcf(drop)` commit) or `none`, not `card`.
|
|
53
|
+
|
|
54
|
+
0.19.0 (gcf-aif-ext 0.19.0): `next --plan` gives the batch of the milestone being built, the units to card first and why nothing goes (a built milestone to play, an empty one); `--skip` leaves ids out. `gcf-harness card <units>` takes units into work in one session on main (gcf-card `--assume`). After a run the features whose children are all finished close. A run's result reads its move from the commit (`deferred`, `decide`). The skill gets `--assume` and `--decide` from the item's gates.
|
|
55
|
+
|
|
56
|
+
0.18.4 (bundled gcf-session 0.17.3): a refusal keeps only the call's command or file and its `description`, not its whole input; a chain's separators inside quotes split nothing; `**/` matches no folder too; a rule is named only when one alone holds.
|
|
57
|
+
|
|
58
|
+
0.18.3: `gate --each --json` gives `dirty`, the checkout's uncommitted paths outside `gcf/`: the board warns before a main run lands among them. A run's chat names a deny rule's refusal: the refused call's input, the project's rule that holds for it and the rule's group (bundled gcf-session 0.17.2, gcf-aif-ext 0.18.10 for the group).
|
|
59
|
+
|
|
50
60
|
0.18.1 runs an item with no model or effort of its own and none in the project on the agent's default, Opus / High (bundled gcf-session 0.17.0, Board-PRD decision 36); `run-log.csv` records the model and effort that ran.
|
|
51
61
|
|
|
52
62
|
0.18.0 needs gcf-aif-ext 0.18.0 (docs/Round6-Functional-Plan.md): `/gcf-run` files its inbox entries with a category (`inbox add --category <c>`), as the core now asks of an agent; the bundled session engine offers `fable` among claude's model presets. After the update run `ai-factory gcf inbox migrate` once: it writes the entries from before the categories in one commit.
|
package/commands/harness.js
CHANGED
|
@@ -11,6 +11,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
11
11
|
import { metricsCommand, runsCommand } from './metrics.js';
|
|
12
12
|
import {
|
|
13
13
|
run,
|
|
14
|
+
card,
|
|
15
|
+
closeFinishedFeatures,
|
|
14
16
|
cliCore,
|
|
15
17
|
DEFAULT_AGENT,
|
|
16
18
|
DEFAULT_TIMEOUT_MIN,
|
|
@@ -68,8 +70,10 @@ function itemProblem(id, item, report) {
|
|
|
68
70
|
function batchProblem(items, wip, elsewhere = []) {
|
|
69
71
|
// Only an item that ends waiting for a verdict takes a WIP place; `wip.over` is false at
|
|
70
72
|
// count === limit, and this run adds every such item of the batch — and of the other runs.
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
+
// One whose verdict the gates defer closes unplayed and takes none (core 0.19).
|
|
74
|
+
const waits = (i) => i.gate === 'verdict' && !i.deferred;
|
|
75
|
+
const waiting = items.filter(waits).length;
|
|
76
|
+
const coming = elsewhere.filter(waits).length;
|
|
73
77
|
if (waiting && wip.count + coming + waiting > wip.limit) {
|
|
74
78
|
const others = coming ? ` + ${coming} in other runs` : '';
|
|
75
79
|
|
|
@@ -100,23 +104,97 @@ const verdict = (reason) => ({ pass: !reason, reason: reason ?? '' });
|
|
|
100
104
|
const rank = (i) => i.priority ?? Number.MAX_SAFE_INTEGER;
|
|
101
105
|
|
|
102
106
|
/**
|
|
103
|
-
* The
|
|
104
|
-
*
|
|
105
|
-
*
|
|
107
|
+
* The items of the milestone being built (docs/Autonomy-Plan.md, D): those of `build_milestone`,
|
|
108
|
+
* those with no milestone game.md knows, and every item they depend on through a later
|
|
109
|
+
* milestone (the audit names that order a finding). Null when game.md lists no milestones.
|
|
106
110
|
*/
|
|
107
|
-
|
|
111
|
+
function inScope(report) {
|
|
112
|
+
const milestones = report.milestones ?? [];
|
|
113
|
+
if (!milestones.length) return null;
|
|
114
|
+
const names = new Set(milestones.map((m) => m.name));
|
|
115
|
+
const byId = new Map((report.items ?? []).map((i) => [i.id, i]));
|
|
116
|
+
const scope = new Set(
|
|
117
|
+
(report.items ?? [])
|
|
118
|
+
.filter((i) => i.milestone === report.build_milestone || !names.has(i.milestone))
|
|
119
|
+
.map((i) => i.id),
|
|
120
|
+
);
|
|
121
|
+
const todo = [...scope];
|
|
122
|
+
while (todo.length) {
|
|
123
|
+
for (const d of byId.get(todo.pop())?.depends ?? [])
|
|
124
|
+
if (byId.has(d) && !scope.has(d)) {
|
|
125
|
+
scope.add(d);
|
|
126
|
+
todo.push(d);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return scope;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Why nothing goes on by itself now (the autopilot's stop), or null: a milestone built and
|
|
135
|
+
* waiting for its play under `gates.milestone: wait`, or one nobody laid out.
|
|
136
|
+
*/
|
|
137
|
+
function milestoneStop(report) {
|
|
138
|
+
const milestones = report.milestones ?? [];
|
|
139
|
+
const at = (name) => milestones.findIndex((m) => m.name === name);
|
|
140
|
+
const play = report.play_milestone;
|
|
141
|
+
const build = report.build_milestone;
|
|
142
|
+
// A later milestone built first does not stop the one before it.
|
|
143
|
+
if (play && report.gates?.milestone !== 'go' && (build === null || at(play) < at(build)))
|
|
144
|
+
return { kind: 'play', milestone: play, text: `milestone ${play} is built: play it` };
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The batch the gate lets go now, up to `count`, by priority, from the milestone being built:
|
|
151
|
+
* each item is taken while the batch with it still passes the gate — a dependency not played,
|
|
152
|
+
* a shared subsystem, a full WIP leave it out. `units`: the milestone's design units no D1
|
|
153
|
+
* holds, for `gcf-harness card` before their items exist. `stop`: why nothing goes, when the
|
|
154
|
+
* milestones say so. A release is the operator's: no batch takes it. `skip`: ids an autopilot
|
|
155
|
+
* leaves out (its loop guard), items and units alike.
|
|
156
|
+
*/
|
|
157
|
+
export function nextPlan(report, count, skip = []) {
|
|
158
|
+
const stop = milestoneStop(report);
|
|
159
|
+
if (stop) return { ids: [], mode: null, units: [], stop };
|
|
160
|
+
const scope = inScope(report);
|
|
108
161
|
const batch = [];
|
|
109
162
|
const ready = (report.items ?? [])
|
|
110
163
|
.filter((i) => i.status === 'ready' && !i.running && i.type !== 'feature')
|
|
164
|
+
.filter((i) => i.type !== 'release' && (!scope || scope.has(i.id)) && !skip.includes(i.id))
|
|
111
165
|
.sort((a, b) => rank(a) - rank(b));
|
|
166
|
+
// One run mode a batch: an autopilot starts it as one run, a main one in the checkout.
|
|
167
|
+
let mode = null;
|
|
112
168
|
for (const i of ready) {
|
|
113
169
|
if (batch.length >= count) break;
|
|
114
|
-
if (
|
|
170
|
+
if (mode && (i.run_mode ?? mode) !== mode) continue;
|
|
171
|
+
if (gate(report, [...batch, i.id]).pass) {
|
|
172
|
+
batch.push(i.id);
|
|
173
|
+
mode ??= i.run_mode ?? null;
|
|
174
|
+
}
|
|
115
175
|
}
|
|
116
176
|
|
|
117
|
-
|
|
177
|
+
const building = (report.milestones ?? []).find((m) => m.name === report.build_milestone);
|
|
178
|
+
const units = (building?.units ?? [])
|
|
179
|
+
.filter((u) => !u.blocked_by && !skip.includes(u.id))
|
|
180
|
+
.map((u) => u.id);
|
|
181
|
+
|
|
182
|
+
// A milestone nobody laid out stops it only once nothing else is left to take.
|
|
183
|
+
const empty =
|
|
184
|
+
!batch.length && !units.length && building?.empty
|
|
185
|
+
? {
|
|
186
|
+
kind: 'empty',
|
|
187
|
+
milestone: building.name,
|
|
188
|
+
text: `milestone ${building.name} is empty: lay it out`,
|
|
189
|
+
}
|
|
190
|
+
: null;
|
|
191
|
+
|
|
192
|
+
return { ids: batch, mode, units, stop: empty };
|
|
118
193
|
}
|
|
119
194
|
|
|
195
|
+
/** The ids of `nextPlan`: what a board's Run offers. */
|
|
196
|
+
export const nextBatch = (report, count) => nextPlan(report, count).ids;
|
|
197
|
+
|
|
120
198
|
/**
|
|
121
199
|
* Decides whether the work items may enter the paid stages, from one `gcf audit --json` report.
|
|
122
200
|
* Pure: the report is the whole input, so every rule has a test and no model compares numbers.
|
|
@@ -368,13 +446,43 @@ export function gateEach(report, ids) {
|
|
|
368
446
|
return { items: Object.fromEntries(named.map((id) => [id, gate(report, [id])])) };
|
|
369
447
|
}
|
|
370
448
|
|
|
449
|
+
/**
|
|
450
|
+
* The checkout's uncommitted paths outside `gcf/`, untracked ones too (a new folder as one): a
|
|
451
|
+
* main run's code lands among them, so the board warns before its click (Tails "Первым" 6). The
|
|
452
|
+
* moves' own refusals guard `gcf/`. Null outside a git checkout.
|
|
453
|
+
*/
|
|
454
|
+
export function loosePaths(dir) {
|
|
455
|
+
// No optional locks: a main run's agent may be committing in the same checkout.
|
|
456
|
+
const args = ['--no-optional-locks', 'status', '--porcelain', '-z', '--', '.', ':(exclude)gcf'];
|
|
457
|
+
const res = spawnSync('git', args, { cwd: dir, encoding: 'utf8' });
|
|
458
|
+
if (res.status !== 0) return null;
|
|
459
|
+
const parts = res.stdout.split('\0').filter(Boolean);
|
|
460
|
+
const paths = [];
|
|
461
|
+
// A rename or a copy gives its old path as the next part: the new one names it.
|
|
462
|
+
for (let i = 0; i < parts.length; i++) {
|
|
463
|
+
paths.push(parts[i].slice(3));
|
|
464
|
+
if (/^(?:[RC].|.[RC])/.test(parts[i])) i++;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return paths;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* `gate --each` as text: each item's answer, then the loose paths.
|
|
472
|
+
* @param {{ items: Record<string, { pass: boolean, reason: string }>, dirty?: string[] }} each
|
|
473
|
+
*/
|
|
474
|
+
function printEach({ items, dirty }) {
|
|
475
|
+
for (const [id, v] of Object.entries(items))
|
|
476
|
+
console.log(v.pass ? `${id}: pass` : `${id}: ${v.reason}`);
|
|
477
|
+
if (dirty?.length) console.log(`uncommitted outside gcf/: ${dirty.join(', ')}`);
|
|
478
|
+
}
|
|
479
|
+
|
|
371
480
|
function runGate(ids, opts) {
|
|
372
481
|
if (opts.each) {
|
|
373
|
-
const
|
|
482
|
+
const dirty = loosePaths(process.cwd());
|
|
483
|
+
const result = { ...gateEach(auditReport(), [...new Set(ids)]), ...(dirty && { dirty }) };
|
|
374
484
|
if (opts.json) console.log(JSON.stringify(result));
|
|
375
|
-
else
|
|
376
|
-
for (const [id, v] of Object.entries(result.items))
|
|
377
|
-
console.log(v.pass ? `${id}: pass` : `${id}: ${v.reason}`);
|
|
485
|
+
else printEach(result);
|
|
378
486
|
|
|
379
487
|
return;
|
|
380
488
|
}
|
|
@@ -425,9 +533,51 @@ export function register(program) {
|
|
|
425
533
|
.command('next [count]')
|
|
426
534
|
.description('The ready items that can run together now, by priority (the gate decides)')
|
|
427
535
|
.option('--json', 'machine output: a list of ids')
|
|
428
|
-
.
|
|
429
|
-
|
|
430
|
-
|
|
536
|
+
.option(
|
|
537
|
+
'--plan',
|
|
538
|
+
'machine output for an autopilot: {ids, units (to card first), stop (why nothing goes)}',
|
|
539
|
+
)
|
|
540
|
+
.option('--skip <ids>', 'items and units to leave out, comma-separated')
|
|
541
|
+
.action(async (count, o) => {
|
|
542
|
+
// An autopilot's ask first closes the features the operator's verdicts finished: no run
|
|
543
|
+
// follows a keep, and nothing else would close them.
|
|
544
|
+
const features = o.plan ? await closeFinishedFeatures(cliCore(process.cwd())) : [];
|
|
545
|
+
const skip = String(o.skip ?? '')
|
|
546
|
+
.split(',')
|
|
547
|
+
.map((x) => x.trim())
|
|
548
|
+
.filter(Boolean);
|
|
549
|
+
const plan = nextPlan(auditReport(), Math.max(1, Number(count ?? 1) || 1), skip);
|
|
550
|
+
if (o.plan) return console.log(JSON.stringify({ ...plan, features }));
|
|
551
|
+
const { ids } = plan;
|
|
552
|
+
console.log(
|
|
553
|
+
o.json ? JSON.stringify(ids) : ids.join('\n') || plan.stop?.text || 'nothing can run now',
|
|
554
|
+
);
|
|
555
|
+
});
|
|
556
|
+
harness
|
|
557
|
+
.command('card <units...>')
|
|
558
|
+
.description(
|
|
559
|
+
'Take design units into work with no questions: one agent session on main runs gcf-card ' +
|
|
560
|
+
'--assume; a question only you can answer becomes a D1 that holds its unit',
|
|
561
|
+
)
|
|
562
|
+
.option(
|
|
563
|
+
'--agent <command>',
|
|
564
|
+
'the agent command',
|
|
565
|
+
process.env.GCF_SESSION_AGENT ?? process.env.GCF_RUN_AGENT ?? DEFAULT_AGENT,
|
|
566
|
+
)
|
|
567
|
+
.option('--json', 'machine output: {units: [{id, result}]}')
|
|
568
|
+
.action(async (units, o) => {
|
|
569
|
+
try {
|
|
570
|
+
const r = await card(process.cwd(), units, { agent: o.agent });
|
|
571
|
+
if (o.json) console.log(JSON.stringify(r, null, 2));
|
|
572
|
+
else for (const u of r.units) console.log(`${u.id}: ${u.result}`);
|
|
573
|
+
if (r.error) {
|
|
574
|
+
console.error(`gcf-harness card: ${r.error}`);
|
|
575
|
+
process.exitCode = 1;
|
|
576
|
+
}
|
|
577
|
+
} catch (e) {
|
|
578
|
+
console.error(`gcf-harness card: ${e.message}`);
|
|
579
|
+
process.exitCode = 1;
|
|
580
|
+
}
|
|
431
581
|
});
|
|
432
582
|
harness
|
|
433
583
|
.command('metrics')
|
|
@@ -588,6 +738,8 @@ function printRun(r) {
|
|
|
588
738
|
console.log(`orphan ${o.id}: ${o.move ?? o.conflict ?? o.error ?? o.skipped}`);
|
|
589
739
|
if (r.gate) console.error(`gcf gate: ${r.gate}`);
|
|
590
740
|
for (const i of r.items) console.log(itemLine(i));
|
|
741
|
+
for (const f of r.features ?? [])
|
|
742
|
+
console.log(`feature ${f.id}: ${f.result}${f.error ? ` — ${f.error}` : ''}`);
|
|
591
743
|
|
|
592
744
|
if (!r.gate) console.log(`\n${cliCore(process.cwd())(['playtest', 'session']).out.trim()}`);
|
|
593
745
|
}
|
package/commands/metrics.js
CHANGED
|
@@ -86,7 +86,7 @@ export function summarize(dir, since = '') {
|
|
|
86
86
|
// duration_ms, handoffs, process (then run_id, started, model, effort, log_from, log_to)
|
|
87
87
|
const runs = rows(dir, 'run-log.csv', since);
|
|
88
88
|
const finished = runs.filter((r) => !UNFINISHED.includes(r[3]));
|
|
89
|
-
const reached = finished.filter((r) => ['submit', 'close'].includes(r[3]));
|
|
89
|
+
const reached = finished.filter((r) => ['submit', 'close', 'decide', 'deferred'].includes(r[3]));
|
|
90
90
|
const spent = runs.map((r) => num(r[5])).filter((v) => v !== null);
|
|
91
91
|
// plan-log: at, item, ok, problems; verify-log: at, item, ok, failed checks, mark
|
|
92
92
|
const plans = rows(dir, 'plan-log.csv', since);
|
package/commands/milestones.js
CHANGED
|
@@ -15,7 +15,7 @@ const BASH = [
|
|
|
15
15
|
[/\bai-factory\s+gcf\s+plan\s+check\b/, 'plan-check'],
|
|
16
16
|
[/\bai-factory\s+gcf\s+verify\b/, 'dod'],
|
|
17
17
|
[/\bgit\s+commit\b/, 'commit'],
|
|
18
|
-
[/\bai-factory\s+gcf\s+(submit|close|block)\b/, 'move'],
|
|
18
|
+
[/\bai-factory\s+gcf\s+(submit|close|block|decide)\b/, 'move'],
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
/** The step a shell command is, or null. */
|
package/commands/run.js
CHANGED
|
@@ -98,6 +98,37 @@ export function cliCore(projectDir) {
|
|
|
98
98
|
* Merge the verified branches now (`gcf integrate`): their results; none, `waits`, while a main
|
|
99
99
|
* run works in the checkout: the core merges nothing under it, and they go in when it ends.
|
|
100
100
|
*/
|
|
101
|
+
/**
|
|
102
|
+
* Close each feature every child of which is finished (ended, unplayed or parked): nobody
|
|
103
|
+
* else would — a run drives no feature (docs/Autonomy-Plan.md, D). A close is an agent's move;
|
|
104
|
+
* one the core refuses (no live: delta, an open dependency) goes into the report as it is.
|
|
105
|
+
*/
|
|
106
|
+
export async function closeFinishedFeatures(core) {
|
|
107
|
+
const read = await core(['board', '--json']);
|
|
108
|
+
if (!read.ok) return [];
|
|
109
|
+
const items = json(read, 'board').items ?? [];
|
|
110
|
+
const byId = new Map(items.map((i) => [i.id, i]));
|
|
111
|
+
const finished = (c) => !byId.has(c) || ['unplayed', 'parked'].includes(byId.get(c).status);
|
|
112
|
+
const done = items.filter(
|
|
113
|
+
(i) =>
|
|
114
|
+
i.type === 'feature' &&
|
|
115
|
+
i.status === 'ready' &&
|
|
116
|
+
i.children?.length &&
|
|
117
|
+
i.children.every(finished),
|
|
118
|
+
);
|
|
119
|
+
const out = [];
|
|
120
|
+
for (const f of done) {
|
|
121
|
+
const r = await core(['close', f.id]);
|
|
122
|
+
out.push(
|
|
123
|
+
r.ok
|
|
124
|
+
? { id: f.id, result: 'close' }
|
|
125
|
+
: { id: f.id, result: 'error', error: (r.err || r.out).trim().split('\n')[0] },
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
|
|
101
132
|
async function integrateNow(core) {
|
|
102
133
|
const r = await core(['integrate', '--json']);
|
|
103
134
|
if (!r.ok && /a main run works in the main checkout/.test(r.err + r.out))
|
|
@@ -418,13 +449,21 @@ const STAYED = / stays ready, a rerun /;
|
|
|
418
449
|
// on main; in a worktree it records none (shortcut: ask them on main after the merge if it
|
|
419
450
|
// matters). `--ask d1|all`: what the skill asks the operator by a question card in a chat; none
|
|
420
451
|
// without.
|
|
452
|
+
// `--assume` under `gates.question: assume`: a D2 and on, no question card; `--decide` under
|
|
453
|
+
// `gates.decision: agent`: the skill decides its spike go or no (docs/Autonomy-Plan.md, B).
|
|
421
454
|
const taskOf = (r, launch, after) => {
|
|
422
|
-
|
|
455
|
+
// A session that is no item's /gcf-run (a card session) brings its own task.
|
|
456
|
+
if (r.task) return r.task;
|
|
457
|
+
const gates = launch?.gatesOf?.(r.id) ?? null;
|
|
458
|
+
const assume = gates?.question === 'assume';
|
|
459
|
+
const ask = assume ? null : launch?.chat?.ask;
|
|
423
460
|
|
|
424
461
|
return (
|
|
425
462
|
`/gcf-run ${r.id}${r.main ? '' : ' --worktree'}` +
|
|
426
463
|
(after ? ' --no-lessons' : '') +
|
|
427
|
-
(ask && ask !== 'none' ? ` --ask ${ask}` : '')
|
|
464
|
+
(ask && ask !== 'none' ? ` --ask ${ask}` : '') +
|
|
465
|
+
(assume ? ' --assume' : '') +
|
|
466
|
+
(gates?.decision === 'agent' ? ' --decide' : '')
|
|
428
467
|
);
|
|
429
468
|
};
|
|
430
469
|
|
|
@@ -849,7 +888,10 @@ async function launchOf(logs, managed, board, chat) {
|
|
|
849
888
|
},
|
|
850
889
|
learned,
|
|
851
890
|
planOf: (id) => board.items?.find((i) => i.id === id)?.plan_file ?? null,
|
|
852
|
-
|
|
891
|
+
// The gates in force for the item (core 0.19): the skill assumes, decides or asks by them.
|
|
892
|
+
gatesOf: (id) => board.items?.find((i) => i.id === id)?.gates ?? null,
|
|
893
|
+
// The deny rules the session runs by: a refusal in its chat names the rule and its group.
|
|
894
|
+
chat: chat && { ...chatOf(chat, board.chat), deny: managed ? board.agent.rules.deny : [] },
|
|
853
895
|
};
|
|
854
896
|
}
|
|
855
897
|
|
|
@@ -870,7 +912,7 @@ export function chatOf({ answerMin = null, graceMs }, config = {}) {
|
|
|
870
912
|
};
|
|
871
913
|
}
|
|
872
914
|
|
|
873
|
-
// The move an item's status shows after a run on main
|
|
915
|
+
// The move an item's status shows after a run on main, when no commit names it.
|
|
874
916
|
const MOVE_OF = {
|
|
875
917
|
'awaiting-verdict': 'submit',
|
|
876
918
|
'awaiting-decision': 'submit',
|
|
@@ -878,14 +920,34 @@ const MOVE_OF = {
|
|
|
878
920
|
blocked: 'block',
|
|
879
921
|
};
|
|
880
922
|
|
|
881
|
-
/**
|
|
923
|
+
/**
|
|
924
|
+
* The move the item's latest move commit names (`gcf(<move>): …`): a status cannot tell a
|
|
925
|
+
* deferred submit from a close (both unplayed), nor a decide (the item is gone). Null without.
|
|
926
|
+
*/
|
|
927
|
+
export function moveOfCommit(projectDir, id) {
|
|
928
|
+
const grep = String.raw`--grep=^gcf\((submit|close|block|decide)\): (go |no )?` + `${id}( |$)`;
|
|
929
|
+
const res = spawnSync('git', ['log', '-1', '-E', grep, '--format=%s'], {
|
|
930
|
+
cwd: projectDir,
|
|
931
|
+
encoding: 'utf8',
|
|
932
|
+
});
|
|
933
|
+
const m = res.status === 0 ? res.stdout.trim().match(/^gcf\((\w+)\): /) : null;
|
|
934
|
+
if (!m) return null;
|
|
935
|
+
|
|
936
|
+
return m[1] === 'submit' && /→ unplayed \(deferred\)/.test(res.stdout) ? 'deferred' : m[1];
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/** What a run on main left: the item's move read from its commit, else its status, or none. */
|
|
882
940
|
async function mainResult(core, r) {
|
|
883
941
|
const after = json(await core(['board', '--json']), 'board').items?.find((i) => i.id === r.id);
|
|
884
942
|
if (r.error) return { id: r.id, result: 'error', error: r.error };
|
|
885
|
-
// An item that ended left the board: its run closed it.
|
|
886
|
-
if (!after) return { id: r.id, result: 'close' };
|
|
943
|
+
// An item that ended left the board: its run closed or decided it.
|
|
944
|
+
if (!after) return { id: r.id, result: moveOfCommit(r.dir, r.id) ?? 'close' };
|
|
887
945
|
if (after.status !== 'ready')
|
|
888
|
-
return {
|
|
946
|
+
return {
|
|
947
|
+
id: r.id,
|
|
948
|
+
result: moveOfCommit(r.dir, r.id) ?? MOVE_OF[after.status] ?? after.status,
|
|
949
|
+
reason: after.blocked,
|
|
950
|
+
};
|
|
889
951
|
|
|
890
952
|
return noResult(r, 'a rerun picks it up');
|
|
891
953
|
}
|
|
@@ -924,7 +986,9 @@ async function runMain(projectDir, ids, releaseMain, ctx) {
|
|
|
924
986
|
writeAtomic(queueOf(logs), `${ids.slice(n + 1).join('\n')}\n`);
|
|
925
987
|
} catch {}
|
|
926
988
|
};
|
|
989
|
+
|
|
927
990
|
items.push(await mainItem(projectDir, id, { ...ctx, dequeue }));
|
|
991
|
+
await postEnd(ctx, items.at(-1));
|
|
928
992
|
}
|
|
929
993
|
} finally {
|
|
930
994
|
await rm(queueOf(logs), { force: true });
|
|
@@ -968,6 +1032,7 @@ async function mainItem(projectDir, id, ctx) {
|
|
|
968
1032
|
dequeue();
|
|
969
1033
|
throw new Error((claimed.err || claimed.out).trim());
|
|
970
1034
|
}
|
|
1035
|
+
|
|
971
1036
|
marked = true;
|
|
972
1037
|
dequeue();
|
|
973
1038
|
const none = async () => {};
|
|
@@ -1169,9 +1234,12 @@ async function runWorktrees(claims, ctx) {
|
|
|
1169
1234
|
: resultOf(r, integrated),
|
|
1170
1235
|
);
|
|
1171
1236
|
}
|
|
1237
|
+
|
|
1172
1238
|
// A worktree's session records no move: the chat hears of the one main recorded for it.
|
|
1173
1239
|
if (ctx.launch?.chat)
|
|
1174
|
-
for (const i of items.filter((x) =>
|
|
1240
|
+
for (const i of items.filter((x) =>
|
|
1241
|
+
['submit', 'close', 'block', 'decide', 'deferred'].includes(x.result),
|
|
1242
|
+
))
|
|
1175
1243
|
postTo(chatOut(logs, i.id), { type: 'step', step: 'move', move: i.result, ok: true });
|
|
1176
1244
|
for (const r of runs)
|
|
1177
1245
|
await remember(
|
|
@@ -1181,11 +1249,14 @@ async function runWorktrees(claims, ctx) {
|
|
|
1181
1249
|
);
|
|
1182
1250
|
|
|
1183
1251
|
// What each session spent rides on its item's line, when the agent reported it.
|
|
1184
|
-
|
|
1252
|
+
const lines = items.map((i) => {
|
|
1185
1253
|
const r = runs.find((x) => x.id === i.id);
|
|
1186
1254
|
|
|
1187
1255
|
return { ...i, ...r?.cost, ...extras(r) };
|
|
1188
1256
|
});
|
|
1257
|
+
for (const i of lines) if (i.result !== 'verified') await postEnd(ctx, i);
|
|
1258
|
+
|
|
1259
|
+
return lines;
|
|
1189
1260
|
}
|
|
1190
1261
|
|
|
1191
1262
|
/**
|
|
@@ -1205,6 +1276,7 @@ function commandsOf(core, agent, board, override) {
|
|
|
1205
1276
|
choice: choiceOf(item, override, b.agent, defaultsOf(agent)),
|
|
1206
1277
|
};
|
|
1207
1278
|
};
|
|
1279
|
+
|
|
1208
1280
|
const agentOf = async (id) => {
|
|
1209
1281
|
let now = null;
|
|
1210
1282
|
try {
|
|
@@ -1245,6 +1317,180 @@ export const run = async (projectDir, ids, opts) => {
|
|
|
1245
1317
|
}
|
|
1246
1318
|
};
|
|
1247
1319
|
|
|
1320
|
+
// The outcome a run's result word reads as on the board's card.
|
|
1321
|
+
const OUTCOME = {
|
|
1322
|
+
submit: 'submitted',
|
|
1323
|
+
decide: 'submitted',
|
|
1324
|
+
deferred: 'submitted',
|
|
1325
|
+
close: 'submitted',
|
|
1326
|
+
block: 'blocked',
|
|
1327
|
+
error: 'failed',
|
|
1328
|
+
conflict: 'failed',
|
|
1329
|
+
paused: 'paused',
|
|
1330
|
+
};
|
|
1331
|
+
// The words that are a move of the core: the card names them beside the outcome.
|
|
1332
|
+
const MOVES = ['submit', 'close', 'block', 'decide', 'deferred'];
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* How an item's run ended, for its chat (`run_end`): the outcome (submitted, blocked, failed,
|
|
1336
|
+
* paused, stopped, no-result, skipped), the move, the reason word for word, what it cost and
|
|
1337
|
+
* took, main's commit, the plan's tasks left unticked, the lessons it filed, a broken step.
|
|
1338
|
+
*/
|
|
1339
|
+
export function runEndOf(i, projectDir, launch = null) {
|
|
1340
|
+
const result = String(i.result ?? 'merged');
|
|
1341
|
+
const word = result.split(/[\s:(]/)[0];
|
|
1342
|
+
// A stop is the operator's, a paused wait cut by it too; then a limit, then the result word.
|
|
1343
|
+
const stopped = /\bstopped\b/.test(result) && !OUTCOME[word]?.startsWith('sub');
|
|
1344
|
+
const outcome = stopped
|
|
1345
|
+
? 'stopped'
|
|
1346
|
+
: i.limit_resets !== undefined
|
|
1347
|
+
? 'paused'
|
|
1348
|
+
: (OUTCOME[word] ??
|
|
1349
|
+
(word === 'skipped' ? 'skipped' : word === 'merged' ? 'submitted' : 'no-result'));
|
|
1350
|
+
const plan = launch?.planOf?.(i.id) ?? null;
|
|
1351
|
+
let unticked = null;
|
|
1352
|
+
try {
|
|
1353
|
+
if (plan)
|
|
1354
|
+
unticked = (readFileSync(path.join(projectDir, plan), 'utf8').match(/^\s*- \[ \] /gm) ?? [])
|
|
1355
|
+
.length;
|
|
1356
|
+
} catch {
|
|
1357
|
+
// Archived with its item: nothing left.
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
return {
|
|
1361
|
+
type: 'run_end',
|
|
1362
|
+
outcome,
|
|
1363
|
+
move: MOVES.includes(word) ? word : null,
|
|
1364
|
+
// A failure says what failed first; a move without one says why it was made.
|
|
1365
|
+
reason:
|
|
1366
|
+
(outcome === 'failed' ? (i.error ?? i.conflict ?? i.reason) : (i.reason ?? i.error)) ??
|
|
1367
|
+
i.skipped ??
|
|
1368
|
+
(OUTCOME[word] && word !== 'paused' ? null : result),
|
|
1369
|
+
cost_usd: i.cost_usd ?? null,
|
|
1370
|
+
duration_ms: i.duration_ms ?? null,
|
|
1371
|
+
commit: headOf(projectDir)?.slice(0, 7) ?? null,
|
|
1372
|
+
unticked,
|
|
1373
|
+
lessons: i.lessons ?? 0,
|
|
1374
|
+
process: i.process ?? null,
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Post an item's run end to its chat (Tails «Первым» 2), when the run has one: not for an item
|
|
1380
|
+
* that never started (another run's lock), whose chat is that run's. The plan is the board's now:
|
|
1381
|
+
* a first run made it.
|
|
1382
|
+
*/
|
|
1383
|
+
async function postEnd(ctx, item) {
|
|
1384
|
+
if (!ctx.launch?.chat || item.started === false) return;
|
|
1385
|
+
let plans = {};
|
|
1386
|
+
try {
|
|
1387
|
+
const now = json(await ctx.core(['board', '--json']), 'board');
|
|
1388
|
+
plans = Object.fromEntries((now.items ?? []).map((i) => [i.id, i.plan_file ?? null]));
|
|
1389
|
+
} catch {
|
|
1390
|
+
// No board: no plan count.
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
const end = runEndOf(item, ctx.projectDir, { planOf: (id) => plans[id] ?? null });
|
|
1394
|
+
postTo(chatOut(ctx.logs, item.id), end);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/** Whether a commit dropped unit `id` (`gcf(drop): <id>`). */
|
|
1398
|
+
function droppedSince(projectDir, id) {
|
|
1399
|
+
const grep = String.raw`--grep=^gcf\(drop\): ` + `${id}( |$)`;
|
|
1400
|
+
const res = spawnSync('git', ['log', '-1', '-E', grep, '--format=%h'], {
|
|
1401
|
+
cwd: projectDir,
|
|
1402
|
+
encoding: 'utf8',
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
return res.status === 0 && Boolean(res.stdout.trim());
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
// The pseudo item a card session runs as: its log, lock and stop file (`gcf-harness stop card`).
|
|
1409
|
+
export const CARD_RUN = 'card';
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* Units an autopilot takes into work (docs/Autonomy-Plan.md, D): one agent session on main,
|
|
1413
|
+
* holding the main checkout as a main run does, gives the gcf-card skill the units with
|
|
1414
|
+
* `--assume` — it asks nothing, and a question only the human can answer becomes a D1 record
|
|
1415
|
+
* with `blocks: <unit>`. Each unit's result: `card` (its work item is there), `question` (a D1
|
|
1416
|
+
* holds it), or `none`. The core's moves its agent makes are the run's.
|
|
1417
|
+
* @param {string} projectDir
|
|
1418
|
+
* @param {string[]} units
|
|
1419
|
+
*/
|
|
1420
|
+
export const card = async (projectDir, units, opts = {}) => {
|
|
1421
|
+
const was = { by: process.env.GCF_MOVE_BY, owner: process.env.GCF_RUN_OWNER };
|
|
1422
|
+
process.env.GCF_MOVE_BY = 'run';
|
|
1423
|
+
process.env.GCF_RUN_OWNER = `run:${process.pid}`;
|
|
1424
|
+
try {
|
|
1425
|
+
return await cardUnits(projectDir, units, opts);
|
|
1426
|
+
} finally {
|
|
1427
|
+
for (const [k, v] of [
|
|
1428
|
+
['GCF_MOVE_BY', was.by],
|
|
1429
|
+
['GCF_RUN_OWNER', was.owner],
|
|
1430
|
+
])
|
|
1431
|
+
if (v === undefined) delete process.env[k];
|
|
1432
|
+
else process.env[k] = v;
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
async function cardUnits(
|
|
1437
|
+
projectDir,
|
|
1438
|
+
units,
|
|
1439
|
+
{ core = cliCore(projectDir), agent = DEFAULT_AGENT, timeoutMs = undefined, managed } = {},
|
|
1440
|
+
) {
|
|
1441
|
+
const bad = units.find((id) => !/^[a-z0-9]+(-[a-z0-9]+)*$/.test(id));
|
|
1442
|
+
if (bad) throw new Error(`${bad} is not a unit id (a lowercase hyphen slug)`);
|
|
1443
|
+
if (!units.length) throw new Error('name the units to card');
|
|
1444
|
+
const logs = path.join(path.resolve(projectDir), '.gcf-session', 'runs');
|
|
1445
|
+
await mkdir(logs, { recursive: true });
|
|
1446
|
+
const board = json(await core(['board', '--json']), 'board');
|
|
1447
|
+
const release = await holdMain(logs, []);
|
|
1448
|
+
if (!release) throw new Error('another run works in the main checkout: wait for it, or stop it');
|
|
1449
|
+
let launch;
|
|
1450
|
+
let agentFirst;
|
|
1451
|
+
try {
|
|
1452
|
+
launch = await launchOf(logs, managed ?? agent === DEFAULT_AGENT, board, null);
|
|
1453
|
+
({ agentFirst } = commandsOf(core, agent, board, {}));
|
|
1454
|
+
} catch (e) {
|
|
1455
|
+
// Its session never starts: the checkout goes back now, not at the process's end.
|
|
1456
|
+
await release();
|
|
1457
|
+
throw e;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
// The units still in design, and the D1 records that hold each: what is left to card.
|
|
1461
|
+
const left = async () => {
|
|
1462
|
+
const now = json(await core(['board', '--json']), 'board');
|
|
1463
|
+
const held = new Map((now.units ?? []).map((u) => [u.id, u.blocked_by ?? []]));
|
|
1464
|
+
const items = new Set((now.items ?? []).map((i) => i.id));
|
|
1465
|
+
// Out of design: its item is there (card), it was dropped (`gcf(drop)`, "already ships"),
|
|
1466
|
+
// or it left with neither (lost: none).
|
|
1467
|
+
const gone = (id) => (items.has(id) ? 'card' : droppedSince(projectDir, id) ? 'drop' : 'none');
|
|
1468
|
+
|
|
1469
|
+
return units.map((id) => ({
|
|
1470
|
+
id,
|
|
1471
|
+
result: !held.has(id) ? gone(id) : held.get(id).length ? 'question' : 'none',
|
|
1472
|
+
}));
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1475
|
+
const r = {
|
|
1476
|
+
id: CARD_RUN,
|
|
1477
|
+
dir: projectDir,
|
|
1478
|
+
...agentFirst(CARD_RUN),
|
|
1479
|
+
task: `/gcf-card ${units.join(' ')} --assume`,
|
|
1480
|
+
main: true,
|
|
1481
|
+
release,
|
|
1482
|
+
done: async () => (await left()).every((u) => u.result !== 'none'),
|
|
1483
|
+
};
|
|
1484
|
+
const timeout = timeoutMs ?? (board.session_timeout_min ?? DEFAULT_TIMEOUT_MIN) * 60_000;
|
|
1485
|
+
// Fresh: a card session cut before was for other units, nothing of it is to be resumed.
|
|
1486
|
+
const ran = await session(r, { core, logs, timeoutMs: timeout, launch, fresh: true });
|
|
1487
|
+
|
|
1488
|
+
const done = await left();
|
|
1489
|
+
|
|
1490
|
+
// `items`: the units as a run report's lines, for a board.
|
|
1491
|
+
return { units: done, items: done, ...(ran.error ? { error: ran.error } : {}), ...ran.cost };
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1248
1494
|
async function runBatch(
|
|
1249
1495
|
projectDir,
|
|
1250
1496
|
ids,
|
|
@@ -1336,18 +1582,40 @@ async function runBatch(
|
|
|
1336
1582
|
}),
|
|
1337
1583
|
);
|
|
1338
1584
|
const failed = driven.find((d) => d.status === 'rejected');
|
|
1339
|
-
if (failed)
|
|
1585
|
+
if (failed) {
|
|
1586
|
+
const error = String(failed.reason?.message ?? failed.reason);
|
|
1587
|
+
for (const [n, d] of driven.entries())
|
|
1588
|
+
if (d.status === 'rejected')
|
|
1589
|
+
for (const id of parts[n][1]) await postEnd(ctx, { id, result: 'error', error });
|
|
1590
|
+
throw failed.reason;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1340
1593
|
// The branches worktree runs verified while a main part held the checkout go in now; a main
|
|
1341
1594
|
// its session left dirty keeps them for the next run.
|
|
1342
1595
|
const after = claims.has('main')
|
|
1343
1596
|
? (await integrateNow(core).catch(() => ({ results: [] }))).results
|
|
1344
1597
|
: [];
|
|
1598
|
+
const features = await closeFinishedFeatures(core).catch(() => []);
|
|
1599
|
+
// A branch verified while main was held went in just now: its end is that merge's move.
|
|
1600
|
+
for (const d of driven)
|
|
1601
|
+
if (d.status === 'fulfilled')
|
|
1602
|
+
for (const i of d.value.filter((x) => x.result === 'verified')) {
|
|
1603
|
+
const merged = after.find((r) => r.id === i.id);
|
|
1604
|
+
const result = merged?.move ?? (merged?.conflict ? 'conflict' : i.result);
|
|
1605
|
+
await postEnd(ctx, {
|
|
1606
|
+
...i,
|
|
1607
|
+
result,
|
|
1608
|
+
...(merged?.conflict && { conflict: merged.conflict }),
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1345
1611
|
|
|
1346
1612
|
// `limit_wait`: this harness waits for a usage limit's reset itself (AD-19); a board reads it.
|
|
1347
1613
|
return {
|
|
1348
1614
|
orphans: [...orphans, ...after],
|
|
1349
1615
|
mode: parts.map(([m]) => m).join('+'),
|
|
1350
1616
|
items: driven.flatMap((d) => (d.status === 'fulfilled' ? d.value : [])),
|
|
1617
|
+
// The features this run finished, closed after it: their close or the core's refusal.
|
|
1618
|
+
features,
|
|
1351
1619
|
limit_wait: true,
|
|
1352
1620
|
};
|
|
1353
1621
|
} finally {
|
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-harness-aif-ext",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-run",
|
package/hooks/implement-guard.js
CHANGED
|
@@ -63,7 +63,10 @@ const started = (call, name) => skillIs(call, name) || promptIs(call, name);
|
|
|
63
63
|
// The move that ends a run's item, run as a command (not echoed or searched for): the session's
|
|
64
64
|
// work on it is over. A move the core then refuses frees the session too: fail open.
|
|
65
65
|
const CLI = String.raw`((npx\s+|pnpm\s+exec\s+|\S*[\\/])?ai-factory(\.cmd)?\s+)?`;
|
|
66
|
-
const ENDS = new RegExp(
|
|
66
|
+
const ENDS = new RegExp(
|
|
67
|
+
String.raw`(^|[;&|(])\s*${CLI}gcf\s+(block|submit|close|decide)\s+[a-z0-9]`,
|
|
68
|
+
'm',
|
|
69
|
+
);
|
|
67
70
|
const endsRun = (call) => call.kind === 'shell' && ENDS.test(String(call.command ?? ''));
|
|
68
71
|
// A move past the DoD gate (Methodology §6) is the human's: a session that ran /gcf-run never
|
|
69
72
|
// makes one, even after its end move (a close the core refused must not free it for a skip).
|
|
@@ -190,13 +190,14 @@ export const kindOf = (tool) => KINDS[tool] ?? (/^mcp__/.test(tool) ? 'mcp' : 'o
|
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* @typedef {{type: 'said', sub: boolean, text: string}
|
|
193
|
-
* | {type: 'tool_call', sub: boolean, id: string, kind: string, tool: string, input: any
|
|
193
|
+
* | {type: 'tool_call', sub: boolean, id: string, kind: string, tool: string, input: any,
|
|
194
|
+
* title: string}
|
|
194
195
|
* | {type: 'tool_result', sub: boolean, id: string, error: boolean, text: string}
|
|
195
196
|
* | {type: 'read'}
|
|
196
197
|
* | {type: 'question', request_id: string, input: any}
|
|
197
198
|
* | {type: 'permission', request_id: string, tool: string, kind: string, input: any,
|
|
198
199
|
* title: string, reason: string | null, always: string | null}
|
|
199
|
-
* | {type: 'refused', tool: string, reason: string}
|
|
200
|
+
* | {type: 'refused', id: string, tool: string, reason: string}
|
|
200
201
|
* | {type: 'cancel', request_id: string}
|
|
201
202
|
* | {type: 'result', subtype?: string, total_cost_usd: number | null}
|
|
202
203
|
* | {type: 'background', tasks: {id: string, description: string}[]}
|
|
@@ -223,6 +224,7 @@ function eventsOf(e) {
|
|
|
223
224
|
kind: kindOf(b.name),
|
|
224
225
|
tool: String(b.name),
|
|
225
226
|
input: b.input ?? {},
|
|
227
|
+
title: titleOf(String(b.name), b.input ?? {}),
|
|
226
228
|
})),
|
|
227
229
|
{ type: 'said', sub, text: text.join('\n') },
|
|
228
230
|
];
|
|
@@ -237,6 +239,12 @@ function eventsOf(e) {
|
|
|
237
239
|
return e.type === 'system' ? systemEvents(e) : [];
|
|
238
240
|
}
|
|
239
241
|
|
|
242
|
+
/** What a call is about, as a card names it: its file, command, address or pattern; its tool. */
|
|
243
|
+
const titleOf = (tool, input) =>
|
|
244
|
+
String(
|
|
245
|
+
input.file_path ?? input.notebook_path ?? input.command ?? input.url ?? input.pattern ?? tool,
|
|
246
|
+
);
|
|
247
|
+
|
|
240
248
|
/** A user event: a message echoed as read (`--replay-user-messages`), or tool results. */
|
|
241
249
|
function userEvents(e, sub, content) {
|
|
242
250
|
if (e.isReplay) return [{ type: /** @type {const} */ ('read') }];
|
|
@@ -260,8 +268,6 @@ function requested(e) {
|
|
|
260
268
|
if (e.request?.subtype !== 'can_use_tool') return [];
|
|
261
269
|
const { tool_name: tool, input = {} } = e.request;
|
|
262
270
|
if (tool === 'AskUserQuestion') return [{ type: 'question', request_id: e.request_id, input }];
|
|
263
|
-
const title =
|
|
264
|
-
input.file_path ?? input.notebook_path ?? input.command ?? input.url ?? input.pattern ?? tool;
|
|
265
271
|
|
|
266
272
|
return [
|
|
267
273
|
{
|
|
@@ -270,7 +276,7 @@ function requested(e) {
|
|
|
270
276
|
tool,
|
|
271
277
|
kind: kindOf(tool),
|
|
272
278
|
input,
|
|
273
|
-
title:
|
|
279
|
+
title: titleOf(tool, input),
|
|
274
280
|
reason: typeof e.request.description === 'string' ? e.request.description : null,
|
|
275
281
|
...alwaysOf(e.request.permission_suggestions),
|
|
276
282
|
},
|
|
@@ -305,7 +311,14 @@ function systemEvents(e) {
|
|
|
305
311
|
if (e.subtype === 'compact_boundary') return [{ type: 'compacted' }];
|
|
306
312
|
// A deny rule of the settings refused a call (spike 8).
|
|
307
313
|
if (e.subtype === 'permission_denied')
|
|
308
|
-
return [
|
|
314
|
+
return [
|
|
315
|
+
{
|
|
316
|
+
type: 'refused',
|
|
317
|
+
id: String(e.tool_use_id ?? ''),
|
|
318
|
+
tool: String(e.tool_name ?? ''),
|
|
319
|
+
reason: String(e.message ?? ''),
|
|
320
|
+
},
|
|
321
|
+
];
|
|
309
322
|
if (e.subtype !== 'background_tasks_changed') return [];
|
|
310
323
|
const tasks = (Array.isArray(e.tasks) ? e.tasks : []).map((t) => ({
|
|
311
324
|
id: String(t.task_id ?? t.id ?? ''),
|
|
@@ -13,11 +13,87 @@ import {
|
|
|
13
13
|
readSync,
|
|
14
14
|
statSync,
|
|
15
15
|
} from 'node:fs';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
16
17
|
import path from 'node:path';
|
|
17
18
|
import { CHAT_FLAGS, encode as claudeInput } from './adapter/claude.js';
|
|
18
19
|
|
|
19
20
|
export { CHAT_FLAGS };
|
|
20
21
|
|
|
22
|
+
// The kinds whose pattern is a path glob (AD-4).
|
|
23
|
+
const FILE_KINDS = new Set(['read', 'search', 'edit']);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether a neutral rule `{kind, pattern}` holds for a call (`{kind, tool, title}`): its kind,
|
|
27
|
+
* its glob on the title; a shell rule on each command of a chain too (`cd x && git push` is a
|
|
28
|
+
* `git *`), claude's old `cmd:*` as `cmd*`; a path rule on the path's end, as a project glob
|
|
29
|
+
* holds for the absolute path a call names (`.claude/**`, `~/.ssh/**`); an MCP rule on the tool.
|
|
30
|
+
* shortcut: claude's own matcher refuses or asks; this one names the rule, and may miss a form
|
|
31
|
+
* claude reads otherwise (`other` rules, web domains): the refusal then names none.
|
|
32
|
+
*/
|
|
33
|
+
export function ruleHolds(rule, e) {
|
|
34
|
+
if (rule.kind !== e.kind) return false;
|
|
35
|
+
if (!rule.pattern) return true;
|
|
36
|
+
// A server's rule (`unity`) holds for each of its tools, as claude's `mcp__unity` does.
|
|
37
|
+
if (rule.kind === 'mcp')
|
|
38
|
+
return e.tool === `mcp__${rule.pattern}` || e.tool.startsWith(`mcp__${rule.pattern}__`);
|
|
39
|
+
const slash = (p) => p.replaceAll('\\', '/');
|
|
40
|
+
const esc = (p) => p.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
|
|
41
|
+
const title = String(e.title ?? '');
|
|
42
|
+
if (FILE_KINDS.has(rule.kind)) {
|
|
43
|
+
const pattern = slash(rule.pattern.replace(/^~(?=\/)/, homedir()));
|
|
44
|
+
// A path glob: `**/` is any folders, none too; `**` anything; `*` within one folder.
|
|
45
|
+
const glob = pattern
|
|
46
|
+
.split(/(\*\*\/|\*\*|\*)/)
|
|
47
|
+
.map((t) => PATH_GLOB[t] ?? esc(t))
|
|
48
|
+
.join('');
|
|
49
|
+
const re = new RegExp(`(?:^|/)${glob}$`, process.platform === 'win32' ? 'i' : '');
|
|
50
|
+
|
|
51
|
+
return re.test(slash(title));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const re = new RegExp(`^${esc(rule.pattern.replace(/:\*$/, '*')).replaceAll('*', '.*')}$`);
|
|
55
|
+
const parts = rule.kind === 'shell' ? commandsOf(title) : [];
|
|
56
|
+
|
|
57
|
+
return [title, ...parts].some((x) => re.test(x.trim()));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const PATH_GLOB = { '**/': '(?:.*/)?', '**': '.*', '*': '[^/]*' };
|
|
61
|
+
|
|
62
|
+
// How much of a refused call the chat keeps: its command or file, and what it was for.
|
|
63
|
+
const TITLE_MAX = 2000;
|
|
64
|
+
const WHY_MAX = 500;
|
|
65
|
+
const cut = (s, max) => (s.length > max ? `${s.slice(0, max)}…` : s);
|
|
66
|
+
|
|
67
|
+
// A shell line's pieces: a quoted string whole (an unclosed one to the end), a separator, a run
|
|
68
|
+
// of plain characters.
|
|
69
|
+
const SHELL_PIECE = /'[^']*'?|"(?:\\.|[^"\\])*"?|&&|\|\||[;|\n]|[^'";|&\n]+|&/g;
|
|
70
|
+
const SEPARATOR = new Set(['&&', '||', ';', '|', '\n']);
|
|
71
|
+
|
|
72
|
+
/** The commands of a shell chain, split on `&&`, `||`, `;`, `|` and new lines outside quotes. */
|
|
73
|
+
function commandsOf(line) {
|
|
74
|
+
const parts = [''];
|
|
75
|
+
for (const [piece] of line.matchAll(SHELL_PIECE))
|
|
76
|
+
if (SEPARATOR.has(piece)) parts.push('');
|
|
77
|
+
else parts[parts.length - 1] += piece;
|
|
78
|
+
|
|
79
|
+
return parts.map((p) => p.trim()).filter(Boolean);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* What refused a call (`deny`, the rules the session runs by): the rule only when one alone
|
|
84
|
+
* holds, its group when every rule that holds is of it.
|
|
85
|
+
*/
|
|
86
|
+
function refusedBy(deny, call) {
|
|
87
|
+
const held = deny.filter((r) => ruleHolds(r, call));
|
|
88
|
+
const group = held[0]?.group;
|
|
89
|
+
const rule = held.length === 1 ? held[0] : null;
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
...(rule ? { rule: rule.pattern ? `${rule.kind}: ${rule.pattern}` : rule.kind } : {}),
|
|
93
|
+
...(group && held.every((r) => r.group === group) ? { group } : {}),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
21
97
|
/** How long a question waits for the operator when neither the flag nor the config says. */
|
|
22
98
|
export const CHAT_TIMEOUT_MIN = 15;
|
|
23
99
|
|
|
@@ -601,13 +677,28 @@ function waitCards(c) {
|
|
|
601
677
|
/**
|
|
602
678
|
* A tool call the session's permissions leave to someone: the engine refuses it when its
|
|
603
679
|
* policy says (`gate`, AD-29, no card), a run refuses it (nobody approves there), a project
|
|
604
|
-
* chat asks the operator by an approval card (AD-5)
|
|
680
|
+
* chat asks the operator by an approval card (AD-5), or allows the call itself while the
|
|
681
|
+
* operator's YOLO is on (AD-54), with no rule saved. "Always" is offered only for a rule the
|
|
605
682
|
* session does not ask for anyway (`asks`): an allow would not beat that ask (AD-2).
|
|
606
683
|
*/
|
|
607
684
|
function permit(c, e) {
|
|
608
685
|
const why = c.gate(e);
|
|
609
686
|
if (why) return refuse(c, e, why, { title: e.title, reason: why });
|
|
610
687
|
if (!c.approvals) return refuse(c, e, `${e.tool} needs an approval no one gives in a run`);
|
|
688
|
+
if (c.yolo()) {
|
|
689
|
+
send(c, c.encode.allow(e.request_id, e.input));
|
|
690
|
+
|
|
691
|
+
return post(c, {
|
|
692
|
+
type: 'allowed',
|
|
693
|
+
request_id: e.request_id,
|
|
694
|
+
by: 'yolo',
|
|
695
|
+
tool: e.tool,
|
|
696
|
+
kind: e.kind,
|
|
697
|
+
title: e.title,
|
|
698
|
+
...(e.reason ? { reason: e.reason } : {}),
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
|
|
611
702
|
const always = e.always && !c.asks(e) ? e.always : null;
|
|
612
703
|
c.cards.set(e.request_id, {
|
|
613
704
|
approval: true,
|
|
@@ -658,20 +749,31 @@ const SEEN = {
|
|
|
658
749
|
},
|
|
659
750
|
question: asked,
|
|
660
751
|
permission: permit,
|
|
661
|
-
// A deny rule of the settings refused it: no card was ever due.
|
|
662
|
-
|
|
752
|
+
// A deny rule of the settings refused it: no card was ever due. The refused call says what
|
|
753
|
+
// was asked (`title`) and what for (`description`), not its whole input: a write's content
|
|
754
|
+
// stays out of the chat. The session's rule that holds for it, and the rule's group, say what
|
|
755
|
+
// refused it (refusedBy).
|
|
756
|
+
refused: (c, e) => {
|
|
757
|
+
const call = c.calls.get(e.id);
|
|
758
|
+
const why = typeof call?.input?.description === 'string' ? call.input.description : '';
|
|
663
759
|
post(c, {
|
|
664
760
|
type: 'denied',
|
|
665
761
|
tool: e.tool,
|
|
666
762
|
by: 'rule',
|
|
763
|
+
...(call ? { title: cut(call.title, TITLE_MAX), ...refusedBy(c.deny, call) } : {}),
|
|
764
|
+
...(why ? { description: cut(why, WHY_MAX) } : {}),
|
|
667
765
|
...(e.reason ? { reason: e.reason } : {}),
|
|
668
|
-
})
|
|
669
|
-
|
|
766
|
+
});
|
|
767
|
+
},
|
|
768
|
+
// A proposal (AD-12): the call of the center's MCP tool, posted when it succeeded. Each call
|
|
769
|
+
// is kept until its result: a refusal names it by its id.
|
|
670
770
|
tool_call: (c, e) => {
|
|
771
|
+
c.calls.set(e.id, e);
|
|
671
772
|
const m = /^mcp__gcf__propose_(\w+)$/.exec(e.tool);
|
|
672
773
|
if (!e.sub && m) c.proposals.set(e.id, { move: m[1].replaceAll('_', '-'), fields: e.input });
|
|
673
774
|
},
|
|
674
775
|
tool_result: (c, e) => {
|
|
776
|
+
c.calls.delete(e.id);
|
|
675
777
|
const p = c.proposals.get(e.id);
|
|
676
778
|
if (!p) return;
|
|
677
779
|
c.proposals.delete(e.id);
|
|
@@ -716,7 +818,8 @@ function see(c, events) {
|
|
|
716
818
|
* (`{context, context_pct}`); `pause(on)` stops the session's timeout while it waits for the
|
|
717
819
|
* operator; `prompt` is the first message; `kind` how the session started (`start`, `resume`,
|
|
718
820
|
* `handoff`); `pick` the model and effort a project chat's session was started with;
|
|
719
|
-
* `steps.see(e)` the steps an event ends; `defaultAnswer` what silence says
|
|
821
|
+
* `steps.see(e)` the steps an event ends; `defaultAnswer` what silence says; `deny` the neutral
|
|
822
|
+
* deny rules the session runs by (each with its `group`, if any): a refusal names its rule.
|
|
720
823
|
* `see(events)` takes the neutral events of each line the agent prints; `event(e)` posts one
|
|
721
824
|
* the run saw; `encode` writes its input as the agent reads it;
|
|
722
825
|
* `close(code, seen)` stops reading and posts the session's end.
|
|
@@ -724,7 +827,8 @@ function see(c, events) {
|
|
|
724
827
|
* A project chat (AD-5) sets `approvals`: a permission request is an approval card;
|
|
725
828
|
* `gate(e)` names why the engine refuses a call outright, or null; `asks(e)` whether the
|
|
726
829
|
* session asks for such a call anyway (no "always" then); `saveAlways(rule)` keeps an
|
|
727
|
-
* "always" rule; `
|
|
830
|
+
* "always" rule; `yolo()` whether the engine allows a call itself, with no card (AD-54);
|
|
831
|
+
* `onHandoff()` takes the operator's fresh-agent input. `files` names the chat's
|
|
728
832
|
* two files when they are not `<id>.chat*.jsonl` under `logs`.
|
|
729
833
|
*/
|
|
730
834
|
export function openChat(opts) {
|
|
@@ -773,6 +877,8 @@ const CHAT_DEFAULTS = {
|
|
|
773
877
|
approvals: false,
|
|
774
878
|
gate: () => null,
|
|
775
879
|
asks: () => false,
|
|
880
|
+
yolo: () => false,
|
|
881
|
+
deny: [],
|
|
776
882
|
saveAlways: async () => {},
|
|
777
883
|
handover: null,
|
|
778
884
|
prefix: null,
|
|
@@ -793,7 +899,8 @@ function chatState(opts) {
|
|
|
793
899
|
fresh: o.fresh ?? o.kind === 'handoff',
|
|
794
900
|
...{ sent: 0, read: 0, cards: new Map(), wait: null, defaulted: false, closed: false },
|
|
795
901
|
...{ stopped: false, grace: null, idle: false, inTurn: true, tasks: [] },
|
|
796
|
-
...{ proposals: new Map(), heard: false, summary: null, wanted: null
|
|
902
|
+
...{ proposals: new Map(), calls: new Map(), heard: false, summary: null, wanted: null },
|
|
903
|
+
why: null,
|
|
797
904
|
...{ hold: false, late: false, pending: [], echoes: [] },
|
|
798
905
|
};
|
|
799
906
|
}
|
|
@@ -12,15 +12,27 @@ export const runsDir = (dir) => path.join(dir, ROOT, 'runs');
|
|
|
12
12
|
/** `.gcf-session/chats`: the project chat's threads. */
|
|
13
13
|
export const chatsDir = (dir) => path.join(dir, ROOT, 'chats');
|
|
14
14
|
|
|
15
|
+
// What a rename over a file another process holds open meets on Windows (a scanner, an indexer).
|
|
16
|
+
const HELD = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Write `text` to `file` whole or not at all: a temporary file beside it, then a rename. A
|
|
17
|
-
* reader never sees half of it, and two writers leave one whole file.
|
|
20
|
+
* reader never sees half of it, and two writers leave one whole file. A file held for a moment
|
|
21
|
+
* is tried again for up to half a second.
|
|
18
22
|
*/
|
|
19
23
|
export function writeAtomic(file, text) {
|
|
20
24
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
21
25
|
try {
|
|
22
26
|
writeFileSync(tmp, text);
|
|
23
|
-
|
|
27
|
+
for (let i = 0; ; i++)
|
|
28
|
+
try {
|
|
29
|
+
renameSync(tmp, file);
|
|
30
|
+
|
|
31
|
+
return;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
if (!HELD.has(e.code) || i >= 10) throw e;
|
|
34
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 50);
|
|
35
|
+
}
|
|
24
36
|
} catch (e) {
|
|
25
37
|
rmSync(tmp, { force: true });
|
|
26
38
|
throw e;
|
|
@@ -21,7 +21,7 @@ import { createHash } from 'node:crypto';
|
|
|
21
21
|
import { PICKS } from './adapter/claude.js';
|
|
22
22
|
import { adapterFor } from './adapter/index.js';
|
|
23
23
|
import { runJob } from './job.js';
|
|
24
|
-
import { postTo, readFrom } from './chat.js';
|
|
24
|
+
import { postTo, readFrom, ruleHolds } from './chat.js';
|
|
25
25
|
import { realClock } from './limit.js';
|
|
26
26
|
import { alive } from './proc.js';
|
|
27
27
|
import { chatsDir, runsDir, writeAtomic } from './store.js';
|
|
@@ -270,21 +270,6 @@ export function listThreads(dir) {
|
|
|
270
270
|
.sort((a, b) => String(b.created_at).localeCompare(String(a.created_at)));
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
/**
|
|
274
|
-
* Whether a neutral rule `{kind, pattern}` holds for a call: its kind, its glob on the title; a
|
|
275
|
-
* shell rule on each command of a chain too (`cd x && git push` is a `git *`).
|
|
276
|
-
*/
|
|
277
|
-
function ruleHolds(rule, e) {
|
|
278
|
-
if (rule.kind !== e.kind) return false;
|
|
279
|
-
if (!rule.pattern) return true;
|
|
280
|
-
const glob = rule.pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replaceAll('*', '.*');
|
|
281
|
-
const re = new RegExp(`^${glob}$`);
|
|
282
|
-
const title = String(e.title ?? '');
|
|
283
|
-
const parts = e.kind === 'shell' ? title.split(/\s*(?:&&|\|\||[;|\n])\s*/) : [];
|
|
284
|
-
|
|
285
|
-
return [title, ...parts].some((x) => re.test(x.trim()));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
273
|
/** Whether the main run's lock (`runs/<main>.lock`) names a live process. */
|
|
289
274
|
function mainBusy(file) {
|
|
290
275
|
if (!file) return false;
|
|
@@ -350,7 +335,8 @@ function flagsOf({ dir, td, spec, adapter }, settings) {
|
|
|
350
335
|
* Run thread `t` of project `dir` until its session idles out, is stopped, or ends: a job of
|
|
351
336
|
* sessions (AD-41), each resumed from the one before, a fresh one after a handoff (AD-42).
|
|
352
337
|
* `spec` (its `spec.json`): `agent`, `rules` `{deny, ask, allow}`, `mcp` (config files),
|
|
353
|
-
* `answerMin`, `handoffPct`, `window`, `skill`, `mainLock`, `
|
|
338
|
+
* `answerMin`, `handoffPct`, `window`, `skill`, `mainLock`, `yolo` (a file: present, the engine
|
|
339
|
+
* allows each call with no card, AD-54), `timeoutMin`, `pick` (the project's
|
|
354
340
|
* model and effort, under the thread's own, over the agent's defaults). `stopped()` says the
|
|
355
341
|
* operator stopped it.
|
|
356
342
|
* @param {{stopped?: () => boolean}} [opts]
|
|
@@ -555,6 +541,9 @@ function chatOf(s, kind, prev) {
|
|
|
555
541
|
approvals: true,
|
|
556
542
|
gate: gateOf(spec),
|
|
557
543
|
asks: (e) => (spec.rules?.ask ?? []).some((r) => ruleHolds(r, e)),
|
|
544
|
+
// Read at each request: the operator's switch holds at once.
|
|
545
|
+
yolo: () => Boolean(spec.yolo) && existsSync(spec.yolo),
|
|
546
|
+
deny: spec.rules?.deny ?? [],
|
|
558
547
|
saveAlways: (rule) => s.adapter.saveAlways(dir, rule),
|
|
559
548
|
handover: handoverOf(s),
|
|
560
549
|
summary: kind === 'handoff' ? s.summary : null,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gcf-session",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "The session engine of GCF: one agent session and a run as a chain of them, the chat protocol, the provider adapters. Bundled by gcf-harness-aif-ext and gcf-board, never published.",
|
|
6
6
|
"type": "module",
|
|
@@ -75,6 +75,16 @@ export type ChatEvent = At &
|
|
|
75
75
|
always_wide?: boolean;
|
|
76
76
|
}
|
|
77
77
|
| { type: 'allowed'; request_id: string; by: 'operator'; always: boolean; rule?: string }
|
|
78
|
+
/** The engine allowed the call itself, with no card: the operator's YOLO (AD-54). */
|
|
79
|
+
| {
|
|
80
|
+
type: 'allowed';
|
|
81
|
+
request_id: string;
|
|
82
|
+
by: 'yolo';
|
|
83
|
+
tool: string;
|
|
84
|
+
kind: string;
|
|
85
|
+
title: string;
|
|
86
|
+
reason?: string;
|
|
87
|
+
}
|
|
78
88
|
| {
|
|
79
89
|
type: 'denied';
|
|
80
90
|
tool: string;
|
|
@@ -102,6 +112,20 @@ export type ChatEvent = At &
|
|
|
102
112
|
by?: 'operator' | 'threshold' | 'compacted';
|
|
103
113
|
error?: string;
|
|
104
114
|
}
|
|
115
|
+
| {
|
|
116
|
+
// How an item's run ended: the harness posts it last (Tails «Первым» 2).
|
|
117
|
+
type: 'run_end';
|
|
118
|
+
outcome:
|
|
119
|
+
'submitted' | 'blocked' | 'failed' | 'paused' | 'stopped' | 'no-result' | 'skipped';
|
|
120
|
+
move: string;
|
|
121
|
+
reason: string | null;
|
|
122
|
+
cost_usd: number | null;
|
|
123
|
+
duration_ms: number | null;
|
|
124
|
+
commit: string | null;
|
|
125
|
+
unticked: number | null;
|
|
126
|
+
lessons: number;
|
|
127
|
+
process: string | null;
|
|
128
|
+
}
|
|
105
129
|
| { type: 'step'; step: 'plan'; passes: number }
|
|
106
130
|
| {
|
|
107
131
|
type: 'step';
|
|
@@ -159,6 +183,8 @@ export interface ThreadSpec {
|
|
|
159
183
|
window?: number;
|
|
160
184
|
skill?: string;
|
|
161
185
|
mainLock?: string | null;
|
|
186
|
+
/** A file whose presence turns the operator's YOLO on: calls go with no card (AD-54). */
|
|
187
|
+
yolo?: string;
|
|
162
188
|
timeoutMin?: number;
|
|
163
189
|
/** The project's model and effort: a session takes them where the thread picked none. */
|
|
164
190
|
pick?: AgentPick;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gcf-harness-aif-ext",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"prepack": "node -e \"const p=require('./package.json'),e=require('./extension.json');if(p.version!==e.version)throw new Error('version mismatch: package.json '+p.version+' vs extension.json '+e.version);require('node:fs').statSync('node_modules/gcf-session/lib/index.js')\""
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"gcf-aif-ext": "^0.
|
|
31
|
+
"gcf-aif-ext": "^0.20.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"gcf-session": "file:../gcf-session"
|
package/skills/gcf-run/SKILL.md
CHANGED
|
@@ -19,13 +19,22 @@ inputs:
|
|
|
19
19
|
- `--handoff` when the harness started this session after the last one filled its context: the plan's `## Handoff` says where it stopped
|
|
20
20
|
- `--no-lessons` when the harness asks this session's lessons itself, in a turn after it ends
|
|
21
21
|
- `--ask d1` or `--ask all` when the harness opened this session to the operator's chat: what to ask them with the AskUserQuestion tool; without it ask no one that way
|
|
22
|
+
- `--assume` when the project's or the card's gates say `question: assume`: a question goes as your assumption, not to the human
|
|
23
|
+
- `--decide` when they say `decision: agent`: you decide your spike or decision item go or no
|
|
22
24
|
|
|
23
25
|
preconditions:
|
|
24
26
|
- `gcf/` exists and `ai-factory gcf audit` runs (the gcf-aif-ext extension provides it)
|
|
25
27
|
- the agent is Claude Code: this pipeline needs its subagents and the harness hooks; another agent drives the item with aif-plan and aif-implement instead
|
|
26
28
|
|
|
27
29
|
forbidden_behaviors:
|
|
28
|
-
- do not give a verdict
|
|
30
|
+
- do not give a verdict: `verdict` belongs to the human; a decision too, but under `--decide`: then only `go` or `no` of the item you drive, a spike or a decision item, with `--reason`
|
|
31
|
+
- under `--assume`, a question of step 12 that is not one of its four goes as an assumption: take your safe default, write it into the plan, and pass `--assume "<question> = <value>"` on the item's move; the core files it as a D2 in the move's commit
|
|
32
|
+
- do not assume a save format, a public API, a new dependency or a pillar conflict: those stay the human's question of step 12
|
|
33
|
+
- under `--decide`, after the submit of a spike or a decision item, run `ai-factory gcf decide <id> go|no --reason "<why>"`
|
|
34
|
+
- `--unticked "<why>"` only for a task the work made moot: its reason goes into the commit
|
|
35
|
+
- with `--worktree`, a `--decide` decision and each `--assume` assumption go into the plan under `## Outcome` before the commit of step 24
|
|
36
|
+
- its lines: `- decide: go|no`, `- reason: <why>`, one `- assume: <question> = <value>` each; the harness records them on main in the item's move
|
|
37
|
+
- a plan that already holds a `## Outcome` from an earlier run gets this run's in its place, not a second one
|
|
29
38
|
- do not read a `gcf/` file outside the readset from `ai-factory gcf context`, but `gcf/INDEX.md` and `gcf/config.yml`
|
|
30
39
|
- do not continue past a failed gate: report the one-line reason, delete `.gcf-session/readset.json`, and stop - a stop is a normal outcome
|
|
31
40
|
- do not compare the audit numbers yourself: the gate command is the only judge of whether an item may go
|
|
@@ -56,9 +65,11 @@ forbidden_behaviors:
|
|
|
56
65
|
- a call the handoff guard denies with "context at" is no refusal: block nothing, write the `## Handoff` it asks for and end the reply
|
|
57
66
|
- a read the readset guard denies is no refusal either: drop that read; never add a `system:` or `depends:` only to read a file - when one of them is wrong in substance, fix it on main, and under `--worktree` stop with a block that names the fix
|
|
58
67
|
- the context's `graveyard_hits` and `d2` lines belong to the readset: hand them to every fresh subagent of steps 8 and 14 in its prompt
|
|
59
|
-
- a design question of step 12 also gets a D1 record
|
|
68
|
+
- a design question of step 12 also gets a D1 record: `ai-factory gcf question add --class D1 --question "<question>" --proposed "<your answer>" --blocks <id>`, before the block
|
|
60
69
|
- under `--worktree` that question goes into the block reason only, and the human files its D1 on main
|
|
61
70
|
- delete one file with `rm -f <file>` or `Remove-Item -Force <file>`, never with `-r`: the deny rules refuse a recursive delete
|
|
71
|
+
- do not run `git stash`: its stack is the checkout's and every worktree's, and a pop may take the human's work
|
|
72
|
+
- for a clean tree to build or check in, run `git worktree add --detach <tmp> HEAD` and work there
|
|
62
73
|
- write the `live:` delta as `live: {none: "<why>"}`, or as `changes:`, each `{id: <capability slug>, change: added | modified | removed, summary: "<two sentences at most>"}`
|
|
63
74
|
- do not leave a done plan task unticked: `submit` and `close` refuse a plan with unticked tasks, as they refuse code changed since its green verify
|
|
64
75
|
|
|
@@ -79,9 +90,9 @@ workflow:
|
|
|
79
90
|
14. review the diff with a fresh subagent; fix what it finds before the commit; DoD still red after the attempts: commit no code, run `ai-factory gcf block <id> --reason "<diagnosis>"` - its commit carries the item file with its delta
|
|
80
91
|
15. the reviewer also answers the `review_question` of each pillar in `gcf/PILLARS.md` over the diff: an answer that breaks the pillar is a finding
|
|
81
92
|
16. after a review fix, run `ai-factory gcf verify <id>` again (a red run counts against `dod_attempts`); tick the plan tasks done outside aif-implement, the verify and the review; then commit the code, its plan and the `live:` delta via aif-commit
|
|
82
|
-
17. gate `verdict` or `decision`: run `ai-factory gcf submit <id>`; gate `auto`:
|
|
93
|
+
17. gate `verdict` or `decision`: run `ai-factory gcf submit <id>`; gate `auto`: `ai-factory gcf close <id>` - a soft unit closes unplayed; the core defers what the gates defer; never pass `--unverified`, the human's call
|
|
83
94
|
18. a dependency still waiting for its verdict refuses the close: run `ai-factory gcf block <id> --reason "waits for <dep>"`
|
|
84
|
-
19. close the run: delete `.gcf-session/readset.json
|
|
95
|
+
19. close the run: delete `.gcf-session/readset.json`; report a row per plan pass: pass, blocking, polish, result; hand the human `ai-factory gcf playtest session` when the audit's `play_milestone` is set or an item waits for its verdict
|
|
85
96
|
20. after a tune verdict or an unblock, re-enter this pipeline at step 5: the gates re-run because the counters moved
|
|
86
97
|
21. with `--worktree`: skip the integrate of step 1, steps 2-4 and the playtest of step 19, and change no `gcf/` file but the item's `live:` and new inbox entries (`ai-factory gcf inbox add --category <c>`)
|
|
87
98
|
22. with `--worktree`, every stop - a failed gate, an over budget readset, a failed plan check, a refused command, steps 11, 12, 14, 18 - writes `{"block": "<reason>"}` to `.gcf-session/outcome.json` and ends the session
|