gcf-aif-ext 0.19.1 → 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 +12 -0
- package/commands/gcf.js +44 -0
- package/extension.json +1 -1
- package/hooks/pre-commit.js +5 -5
- package/lib/agent-permissions.js +4 -1
- package/lib/design-parts.js +3 -15
- package/lib/domain.js +34 -10
- package/lib/edits.js +115 -0
- package/lib/git.js +116 -12
- package/lib/refusal.js +27 -0
- package/lib/safe-path.js +22 -6
- package/lib/unit-ops.js +9 -4
- package/lib/work-ops.js +18 -5
- package/package.json +1 -1
- package/skills/gcf-chat/SKILL.md +16 -7
- package/templates/agents-block.md +5 -3
package/README.md
CHANGED
|
@@ -50,6 +50,17 @@ Updating preserves `gcf/`, `cnlp.config.json` and the pre-commit hook. Run `ai-f
|
|
|
50
50
|
|
|
51
51
|
On Windows, run `extension add` and `extension update` from PowerShell or cmd, not Git Bash: the installer unpacks with `tar`, and Git Bash's GNU tar reads `C:\…` as a remote host (`Cannot connect to C: resolve failed`). The Windows `tar.exe` handles it.
|
|
52
52
|
|
|
53
|
+
### 0.20.0
|
|
54
|
+
|
|
55
|
+
- `edits diff|commit|discard --path <p>…`: the hand edits under `gcf/` that a move's refusal names. `diff` shows the staged part and the part not staged (`--json`); `commit` records them as they are, `gcf(edit): <n> files`, through the gate; `discard` puts them back as the last commit has them, a new file deleted. Commit and discard are the operator's moves: a run and a board thread are refused, and the deny group `human-moves` holds them.
|
|
56
|
+
- A move refused for uncommitted `gcf/` edits (its own files, the commit gate, a milestone's keep) ends its error with one machine line, `gcf-refusal: {"code":"dirty","paths":[…]}`: every dirty path under the gate's scope, from git, with `/`. A board offers Show diff, Commit and Discard from it. The words for people stay as they were.
|
|
57
|
+
- The domain lets a project chat agent propose `verdict:*`, `decide:*`, `unblock` and `question-answer` (`propose: true`); `sections.edits` names the two edit moves. The reason of every move into the graveyard (`verdict:kill` note, `decide:no|wontfix|kill` reason) is `required` in its form: the core refused it without one already.
|
|
58
|
+
- The gcf-chat skill and the AGENTS.md block: a verdict is proposed only after the human said they played the item, its note in their words; `remove` is left to the rule unless the human says otherwise; hand edits are the human's.
|
|
59
|
+
|
|
60
|
+
### 0.19.2
|
|
61
|
+
|
|
62
|
+
- A write retries its rename a few times when Windows refuses it (`EPERM`, `EACCES`, `EBUSY`: an antivirus or indexer holds the file open). A rollback's delete of a file the move created retries too. A move's rollback no longer stops halfway and leaves `gcf/` half-written.
|
|
63
|
+
|
|
53
64
|
### 0.19.1
|
|
54
65
|
|
|
55
66
|
- `verdict <milestone> keep --milestone` that fails, its commit too, puts the pack's items back with the index as the operator left it: a staged compress edit stays staged.
|
|
@@ -342,6 +353,7 @@ Removal leaves `gcf/` and `cnlp.config.json` in place. It also leaves the pre-co
|
|
|
342
353
|
- project phase and board — `phase`, `phase next [--reason]`, `board [--json]` (everything a board shows, in one read)
|
|
343
354
|
- branches — `worktree <id>`, `verify <id> --mark`, `integrate [<id>...]`: a run in its own worktree, the `GCF-Verified` trailer, the merge into main and the move; every committed move holds `.gcf-session/main.lock`
|
|
344
355
|
- design and sources — `design check`, `design export`, `design import`, `design part`, `design save`, `design discard`, `design commit`, `design migrate`, `anchor`, `section`, `quotes`, `lint`
|
|
356
|
+
- hand edits under `gcf/` — `edits diff|commit|discard --path <p>…`: what a move's `dirty` refusal names, shown, committed or put back
|
|
345
357
|
- setup — `init`, `index`, `hooks-install`
|
|
346
358
|
|
|
347
359
|
Every move of an item makes one commit `gcf(<move>): <id>` with every file it touched — the item, history or graveyard, `LIVE.md`, the systems documents, the parent feature, a removal item, the archived plan. `take`, `item new` and `inbox` do not commit. These are plain Node scripts with no LLM in the loop: the same functions the skills call, the pre-commit gate runs, and the harness gates against.
|
package/commands/gcf.js
CHANGED
|
@@ -744,6 +744,49 @@ function registerDesignParts(design) {
|
|
|
744
744
|
});
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
+
function registerEdits(gcf) {
|
|
748
|
+
const edits = () => lib('edits');
|
|
749
|
+
const group = gcf
|
|
750
|
+
.command('edits')
|
|
751
|
+
.description(
|
|
752
|
+
"Hand edits under gcf/ that a move's refusal names: show them; commit or discard them " +
|
|
753
|
+
"(the human's)",
|
|
754
|
+
);
|
|
755
|
+
const PATH = 'a path from the project, as the refusal lists it (repeatable)';
|
|
756
|
+
group
|
|
757
|
+
.command('diff')
|
|
758
|
+
.description('The edits of these paths: the staged part and the part not staged')
|
|
759
|
+
.requiredOption('--path <path>', PATH, repeated, [])
|
|
760
|
+
.option('--json', '{files, staged, unstaged}')
|
|
761
|
+
.action(async (o) => {
|
|
762
|
+
const r = (await edits()).editsDiff(process.cwd(), o.path);
|
|
763
|
+
if (o.json) return out(true, r);
|
|
764
|
+
if (r.staged) console.log(`staged:\n${r.staged}`);
|
|
765
|
+
if (r.unstaged) console.log(`not staged:\n${r.unstaged}`);
|
|
766
|
+
});
|
|
767
|
+
group
|
|
768
|
+
.command('commit')
|
|
769
|
+
.description('Commit the hand edits of these paths as they are: gcf(edit), through the gate')
|
|
770
|
+
.requiredOption('--path <path>', PATH, repeated, [])
|
|
771
|
+
.action(async (o) => {
|
|
772
|
+
await operatorOnly('edits commit');
|
|
773
|
+
const r = await (await edits()).editsCommit(process.cwd(), o.path);
|
|
774
|
+
console.log(`committed ${r.files.join(', ')}${shortHash(r.hash)}`);
|
|
775
|
+
});
|
|
776
|
+
group
|
|
777
|
+
.command('discard')
|
|
778
|
+
.description(
|
|
779
|
+
'Put these paths back as the last commit has them, the index too; a new file goes. ' +
|
|
780
|
+
'It cannot be undone: look at edits diff first',
|
|
781
|
+
)
|
|
782
|
+
.requiredOption('--path <path>', PATH, repeated, [])
|
|
783
|
+
.action(async (o) => {
|
|
784
|
+
await operatorOnly('edits discard');
|
|
785
|
+
const r = await (await edits()).editsDiscard(process.cwd(), o.path);
|
|
786
|
+
console.log(`discarded ${r.files.join(', ')}`);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
|
|
747
790
|
function registerMigrate(design) {
|
|
748
791
|
design
|
|
749
792
|
.command('migrate')
|
|
@@ -1833,6 +1876,7 @@ export function register(program) {
|
|
|
1833
1876
|
registerSection(gcf);
|
|
1834
1877
|
registerQuotes(gcf);
|
|
1835
1878
|
registerDesign(gcf);
|
|
1879
|
+
registerEdits(gcf);
|
|
1836
1880
|
registerWhere(gcf);
|
|
1837
1881
|
registerMoves(gcf);
|
|
1838
1882
|
registerItem(gcf);
|
package/extension.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
|
|
3
3
|
"name": "gcf-aif-ext",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"description": "Game Context Framework for AI Factory",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-init",
|
package/hooks/pre-commit.js
CHANGED
|
@@ -8,6 +8,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { writeIndex } from '../lib/index-gen.js';
|
|
10
10
|
import { gateProblems } from '../lib/gate.js';
|
|
11
|
+
import { GATE_SCOPE } from '../lib/git.js';
|
|
11
12
|
|
|
12
13
|
const projectDir = process.cwd();
|
|
13
14
|
const root = path.join(projectDir, 'gcf');
|
|
@@ -30,11 +31,10 @@ function git(args) {
|
|
|
30
31
|
return res.status === 0 ? res.stdout.trim() : null;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
const scope = ['--', 'gcf', ':(exclude)gcf/.metrics', ':(exclude,glob)gcf/source/*.import.json'];
|
|
34
|
+
// The gate's scope (lib/git.js GATE_SCOPE): gcf/ without gcf/.metrics and an unfinished
|
|
35
|
+
// import's held anchor map; a move's refusal names the same paths. Hooks run from the
|
|
36
|
+
// repository root, so the pathspecs are relative.
|
|
37
|
+
const scope = ['--', ...GATE_SCOPE];
|
|
38
38
|
const staged = git(['diff', '--cached', '--name-only', ...scope]);
|
|
39
39
|
if (staged === '') process.exit(0); // this commit does not touch gcf/
|
|
40
40
|
if (staged !== null) {
|
package/lib/agent-permissions.js
CHANGED
|
@@ -180,7 +180,7 @@ export const DENY_GROUPS = [
|
|
|
180
180
|
id: 'human-moves',
|
|
181
181
|
label:
|
|
182
182
|
"the human's GCF moves: verdict, answer, unblock, a card's gates, phase, pillars, " +
|
|
183
|
-
'settings, permissions, setup (decide the core holds by the gates)',
|
|
183
|
+
'settings, permissions, setup, hand edits (decide the core holds by the gates)',
|
|
184
184
|
on: true,
|
|
185
185
|
rules: shell(
|
|
186
186
|
'ai-factory gcf verdict*',
|
|
@@ -192,6 +192,9 @@ export const DENY_GROUPS = [
|
|
|
192
192
|
'ai-factory gcf permissions*',
|
|
193
193
|
'ai-factory gcf config set*',
|
|
194
194
|
'ai-factory gcf hooks-install*',
|
|
195
|
+
// A human's hand edits under gcf/: their unfinished work, not the agent's to keep or erase.
|
|
196
|
+
'ai-factory gcf edits commit*',
|
|
197
|
+
'ai-factory gcf edits discard*',
|
|
195
198
|
'ai-factory gcf-harness init*',
|
|
196
199
|
'ai-factory gcf-harness run*',
|
|
197
200
|
// The autopilot's card session: an agent starts none.
|
package/lib/design-parts.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// declares; a save writes the edited fields back into the part's text and brings it in as a
|
|
4
4
|
// one-part bundle (lib/bundle.js), so a form edit passes the same three-way check and the same
|
|
5
5
|
// design check a designer's import does. The board writes no file of gcf/ itself.
|
|
6
|
-
import { readFile, readdir
|
|
6
|
+
import { readFile, readdir } from 'node:fs/promises';
|
|
7
7
|
import { existsSync } from 'node:fs';
|
|
8
8
|
import { spawnSync } from 'node:child_process';
|
|
9
9
|
import path from 'node:path';
|
|
@@ -34,7 +34,7 @@ import { locked } from './main-lock.js';
|
|
|
34
34
|
import { buildLedger } from './ledger.js';
|
|
35
35
|
import { deriveId } from './id.js';
|
|
36
36
|
import { renamePillar } from './pillars.js';
|
|
37
|
-
import { dirtyPaths } from './git.js';
|
|
37
|
+
import { dirtyPaths, restoreFromHead } from './git.js';
|
|
38
38
|
import { blocksOf, putBlock } from './systems-doc.js';
|
|
39
39
|
|
|
40
40
|
const PROFILES_DIR = fileURLToPath(new URL('../profiles/', import.meta.url));
|
|
@@ -656,19 +656,7 @@ export const discardDesign = (projectDir, only = []) =>
|
|
|
656
656
|
if (off.length)
|
|
657
657
|
throw new Error(`${off.join(', ')}: no draft to discard (${drafts.join(', ') || 'none'})`);
|
|
658
658
|
const files = only.length ? only : drafts;
|
|
659
|
-
|
|
660
|
-
const must = (...args) => {
|
|
661
|
-
const r = git(...args);
|
|
662
|
-
if (r.status !== 0) throw new Error(`git ${args.join(' ')}: ${r.stderr.trim()}`);
|
|
663
|
-
};
|
|
664
|
-
for (const f of files) {
|
|
665
|
-
if (git('cat-file', '-e', `HEAD:./${f}`).status === 0) {
|
|
666
|
-
must('checkout', 'HEAD', '--', f);
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
must('rm', '--cached', '-q', '--ignore-unmatch', '--', f);
|
|
670
|
-
await rm(path.join(projectDir, f), { force: true });
|
|
671
|
-
}
|
|
659
|
+
restoreFromHead(projectDir, files);
|
|
672
660
|
|
|
673
661
|
return { files };
|
|
674
662
|
});
|
package/lib/domain.js
CHANGED
|
@@ -40,8 +40,8 @@ const GATE_HELP = {
|
|
|
40
40
|
// `remove` is `--remove` / `--no-remove`, or the command's own rule when left empty; `slug` is
|
|
41
41
|
// the target id the operator types (`{id}`); a field with `when` goes only while another field
|
|
42
42
|
// holds one of those values.
|
|
43
|
+
// The graveyard keeps a reason (work-ops endToGraveyard): every move into it needs one.
|
|
43
44
|
const REASON = { key: 'reason', label: 'Reason', kind: 'longtext', required: true };
|
|
44
|
-
const OPTIONAL_REASON = { ...REASON, required: false };
|
|
45
45
|
const REMOVE = { key: 'remove', label: 'Removal item for its code', kind: 'remove' };
|
|
46
46
|
const CONSTRAINT = { key: 'constraint', label: 'Constraint lines', kind: 'list' };
|
|
47
47
|
// Where the operator played it: lines of game.md's platforms, a note for the history (Plan, C).
|
|
@@ -61,12 +61,16 @@ const UNTICKED = {
|
|
|
61
61
|
excuses: 'plan',
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
// A project chat agent proposes a verdict only after the operator said in its talk that they
|
|
65
|
+
// played it and how it felt, the note in their words (the gcf-chat skill holds it); the click
|
|
66
|
+
// that makes it is the operator's "I played it" (Board-PRD decision 42, AD-53).
|
|
64
67
|
const verdict = (v, help, fields, danger) => ({
|
|
65
68
|
label: v,
|
|
66
69
|
help,
|
|
67
70
|
args: ['gcf', 'verdict', '{id}', v],
|
|
68
71
|
fields,
|
|
69
72
|
...(danger && { danger }),
|
|
73
|
+
propose: true,
|
|
70
74
|
});
|
|
71
75
|
const decide = (choice, help, fields = [], danger) => ({
|
|
72
76
|
label: choice,
|
|
@@ -74,6 +78,7 @@ const decide = (choice, help, fields = [], danger) => ({
|
|
|
74
78
|
args: ['gcf', 'decide', '{id}', choice],
|
|
75
79
|
fields,
|
|
76
80
|
...(danger && { danger }),
|
|
81
|
+
propose: true,
|
|
77
82
|
});
|
|
78
83
|
const text = (key, label, extra = {}) => ({ key, label, kind: 'text', ...extra });
|
|
79
84
|
// How an item's run goes (decision 36): a board offers Default (`default`), which leaves the
|
|
@@ -115,7 +120,7 @@ const ITEM_SPECS = {
|
|
|
115
120
|
'kill',
|
|
116
121
|
'Played and rejected: it goes to the graveyard',
|
|
117
122
|
[
|
|
118
|
-
{ key: 'note', label: 'Why', kind: 'longtext' },
|
|
123
|
+
{ key: 'note', label: 'Why', kind: 'longtext', required: true },
|
|
119
124
|
{
|
|
120
125
|
key: 'tags',
|
|
121
126
|
label: 'Graveyard tags',
|
|
@@ -127,16 +132,11 @@ const ITEM_SPECS = {
|
|
|
127
132
|
true,
|
|
128
133
|
),
|
|
129
134
|
'decide:go': decide('go', 'Approved: it goes to history as decided'),
|
|
130
|
-
'decide:no': decide(
|
|
131
|
-
'no',
|
|
132
|
-
'Not doing it: it goes to the graveyard',
|
|
133
|
-
[OPTIONAL_REASON, REMOVE],
|
|
134
|
-
true,
|
|
135
|
-
),
|
|
135
|
+
'decide:no': decide('no', 'Not doing it: it goes to the graveyard', [REASON, REMOVE], true),
|
|
136
136
|
'decide:wontfix': decide(
|
|
137
137
|
'wontfix',
|
|
138
138
|
'A bug left as it is: it goes to the graveyard',
|
|
139
|
-
[
|
|
139
|
+
[REASON, REMOVE],
|
|
140
140
|
true,
|
|
141
141
|
),
|
|
142
142
|
'decide:known': decide('known', 'A bug kept as a known issue: it goes to parked'),
|
|
@@ -145,7 +145,7 @@ const ITEM_SPECS = {
|
|
|
145
145
|
'decide:kill': decide(
|
|
146
146
|
'kill',
|
|
147
147
|
'The feature is dropped: it goes to the graveyard with its live children',
|
|
148
|
-
[
|
|
148
|
+
[REASON],
|
|
149
149
|
true,
|
|
150
150
|
),
|
|
151
151
|
block: {
|
|
@@ -161,6 +161,7 @@ const ITEM_SPECS = {
|
|
|
161
161
|
args: ['gcf', 'unblock', '{id}'],
|
|
162
162
|
fields: [{ key: 'note', label: 'Answer or "file: <path>"', kind: 'longtext' }],
|
|
163
163
|
drag: RUNS_FROM,
|
|
164
|
+
propose: true,
|
|
164
165
|
},
|
|
165
166
|
drop: {
|
|
166
167
|
label: 'drop',
|
|
@@ -602,6 +603,9 @@ const DETAIL = {
|
|
|
602
603
|
help: 'One lowercase word after the category: asset, static-analysis, framework',
|
|
603
604
|
};
|
|
604
605
|
|
|
606
|
+
// The paths of a `dirty` refusal: `--path=<path>` each.
|
|
607
|
+
const EDIT_PATHS = { key: 'paths', flag: 'path', label: 'Paths', kind: 'list', hidden: true };
|
|
608
|
+
|
|
605
609
|
// The moves of the domain's blocks: the phase, the inbox, the questions, the run order.
|
|
606
610
|
const BLOCK_SPECS = {
|
|
607
611
|
'item-new': NEW_ITEM,
|
|
@@ -664,6 +668,22 @@ const BLOCK_SPECS = {
|
|
|
664
668
|
help: 'The answer goes into the record; the next agent on its units puts it in place',
|
|
665
669
|
args: ['gcf', 'question', 'answer', '{id}'],
|
|
666
670
|
fields: [{ key: 'text', label: 'Answer', kind: 'text', required: true }],
|
|
671
|
+
propose: true,
|
|
672
|
+
},
|
|
673
|
+
// Hand edits under gcf/ that a move's `dirty` refusal names (Rich-Chat-Plan §5): the board
|
|
674
|
+
// fills the paths from the refusal; the operator's moves, never proposed.
|
|
675
|
+
'edits-commit': {
|
|
676
|
+
label: 'commit',
|
|
677
|
+
help: 'Commit the hand edits under gcf/ as they are, then try the move again',
|
|
678
|
+
args: ['gcf', 'edits', 'commit'],
|
|
679
|
+
fields: [EDIT_PATHS],
|
|
680
|
+
},
|
|
681
|
+
'edits-discard': {
|
|
682
|
+
label: 'discard',
|
|
683
|
+
help: 'Put the edited files back as the last commit has them; a new file goes. No undo',
|
|
684
|
+
args: ['gcf', 'edits', 'discard'],
|
|
685
|
+
fields: [EDIT_PATHS],
|
|
686
|
+
danger: true,
|
|
667
687
|
},
|
|
668
688
|
prioritize: {
|
|
669
689
|
label: 'prioritize',
|
|
@@ -777,6 +797,8 @@ const SECTIONS = {
|
|
|
777
797
|
...inboxVocabulary(),
|
|
778
798
|
},
|
|
779
799
|
questions: { answer: 'question-answer' },
|
|
800
|
+
// A move's `dirty` refusal: the board reads `gcf edits diff` and offers these.
|
|
801
|
+
edits: { commit: 'edits-commit', discard: 'edits-discard' },
|
|
780
802
|
lessons: {},
|
|
781
803
|
playtest: {
|
|
782
804
|
// The inbox category a note from the playtest screen goes with.
|
|
@@ -820,6 +842,8 @@ const CHANGES = [
|
|
|
820
842
|
'design save',
|
|
821
843
|
'design commit',
|
|
822
844
|
'design discard',
|
|
845
|
+
'edits commit',
|
|
846
|
+
'edits discard',
|
|
823
847
|
'take',
|
|
824
848
|
'done',
|
|
825
849
|
'drop',
|
package/lib/edits.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Hand edits under gcf/ (Rich-Chat-Plan §5): what a move's `dirty` refusal names, shown, committed
|
|
2
|
+
// or put back. Reading is anyone's; commit and discard are the operator's (the CLI holds them,
|
|
3
|
+
// and the deny group human-moves): an agent does not decide over a human's unfinished work.
|
|
4
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { dirtyGcf, literal, restoreFromHead } from './git.js';
|
|
8
|
+
import { locked } from './main-lock.js';
|
|
9
|
+
import { commitMove } from './unit-ops.js';
|
|
10
|
+
|
|
11
|
+
/** A path from the project with `/`: the form dirtyGcf gives and a refusal names. */
|
|
12
|
+
const norm = (projectDir, p) =>
|
|
13
|
+
path.relative(path.resolve(projectDir), path.resolve(projectDir, p)).replaceAll('\\', '/');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `paths` as dirtyGcf names them; one with no change under the gate's scope is refused (a
|
|
17
|
+
* clean path, one outside gcf/, a typo): the command acts only on what a refusal can name.
|
|
18
|
+
* @param {string} projectDir
|
|
19
|
+
* @param {string[]} paths
|
|
20
|
+
* @param {string} verb
|
|
21
|
+
*/
|
|
22
|
+
function changed(projectDir, paths, verb) {
|
|
23
|
+
if (!paths.length)
|
|
24
|
+
throw new Error(`edits ${verb}: name the paths (--path), as a refusal lists them`);
|
|
25
|
+
const dirty = new Set(dirtyGcf(projectDir));
|
|
26
|
+
const files = [...new Set(paths.map((p) => norm(projectDir, p)))];
|
|
27
|
+
const off = files.filter((f) => !dirty.has(f));
|
|
28
|
+
if (off.length)
|
|
29
|
+
throw new Error(`edits ${verb}: no change under gcf/ to ${verb} in ${off.join(', ')}`);
|
|
30
|
+
|
|
31
|
+
return files;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const git = (projectDir, ...args) =>
|
|
35
|
+
spawnSync('git', ['-c', 'core.quotePath=false', ...args], { cwd: projectDir, encoding: 'utf8' })
|
|
36
|
+
.stdout ?? '';
|
|
37
|
+
|
|
38
|
+
/** A file git does not know yet as a diff of its own: each line added. */
|
|
39
|
+
function newFileDiff(projectDir, f) {
|
|
40
|
+
const file = path.join(projectDir, f);
|
|
41
|
+
if (!existsSync(file)) return '';
|
|
42
|
+
const text = readFileSync(file, 'utf8');
|
|
43
|
+
if (text.includes('\0')) return `new file ${f}: binary\n`;
|
|
44
|
+
const lines = text.replace(/\n$/, '').split('\n');
|
|
45
|
+
|
|
46
|
+
return `new file ${f}\n--- /dev/null\n+++ b/${f}\n${lines.map((l) => `+${l}`).join('\n')}\n`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Literal pathspecs: a `[` in a name is no glob that takes its siblings along. */
|
|
50
|
+
const lits = (projectDir, files) => files.map((f) => literal(projectDir, f));
|
|
51
|
+
|
|
52
|
+
const tracked = (projectDir, f) =>
|
|
53
|
+
spawnSync('git', ['ls-files', '--error-unmatch', '--', literal(projectDir, f)], {
|
|
54
|
+
cwd: projectDir,
|
|
55
|
+
stdio: 'ignore',
|
|
56
|
+
}).status === 0;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The edits of `paths` in two parts: `staged` (the index against HEAD) and `unstaged` (the
|
|
60
|
+
* working file against the index), a new file's lines in the second. One diff against HEAD
|
|
61
|
+
* would hide an edit held only in the index when the file on disk equals HEAD; discard resets
|
|
62
|
+
* the index too, and that edit would go unseen.
|
|
63
|
+
* @param {string} projectDir
|
|
64
|
+
* @param {string[]} paths
|
|
65
|
+
*/
|
|
66
|
+
export function editsDiff(projectDir, paths) {
|
|
67
|
+
const files = changed(projectDir, paths, 'diff');
|
|
68
|
+
const staged = git(projectDir, 'diff', '--cached', '--', ...lits(projectDir, files));
|
|
69
|
+
const known = files.filter((f) => tracked(projectDir, f));
|
|
70
|
+
const fresh = files.filter((f) => !known.includes(f));
|
|
71
|
+
const unstaged =
|
|
72
|
+
(known.length ? git(projectDir, 'diff', '--', ...lits(projectDir, known)) : '') +
|
|
73
|
+
fresh.map((f) => newFileDiff(projectDir, f)).join('');
|
|
74
|
+
|
|
75
|
+
return { files, staged, unstaged };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The ids an edit touches: gcf/work/<id>.md and anything in gcf/work/<id>/ (item history finds
|
|
79
|
+
// the commit by them).
|
|
80
|
+
const ITEM_PATH = /^gcf\/work\/([^/]+?)(?:\.md$|\/)/;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Commit the hand edits of `paths` as they are, `gcf(edit): <n> files`, the move
|
|
84
|
+
* `edits-commit`. Through the gate like any move: its refusal comes up as it is.
|
|
85
|
+
* @param {string} projectDir
|
|
86
|
+
* @param {string[]} paths
|
|
87
|
+
*/
|
|
88
|
+
export const editsCommit = (projectDir, paths) =>
|
|
89
|
+
locked(projectDir, true, async () => {
|
|
90
|
+
const files = changed(projectDir, paths, 'commit');
|
|
91
|
+
const abs = files.map((f) => path.join(projectDir, f));
|
|
92
|
+
const items = files.flatMap((f) => ITEM_PATH.exec(f)?.[1] ?? []);
|
|
93
|
+
const hash = await commitMove(
|
|
94
|
+
projectDir,
|
|
95
|
+
`gcf(edit): ${files.length} file${files.length === 1 ? '' : 's'}`,
|
|
96
|
+
// The files are the edits themselves: none is "dirty" to its own commit.
|
|
97
|
+
{ files: abs, inputs: abs, mutate: async () => {}, commit: true, key: 'edits-commit', items },
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
return { files, hash };
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Put the files of `paths` back as the last commit has them, the index too: a new one goes.
|
|
105
|
+
* It cannot be undone; a board shows the diff first.
|
|
106
|
+
* @param {string} projectDir
|
|
107
|
+
* @param {string[]} paths
|
|
108
|
+
*/
|
|
109
|
+
export const editsDiscard = (projectDir, paths) =>
|
|
110
|
+
locked(projectDir, true, async () => {
|
|
111
|
+
const files = changed(projectDir, paths, 'discard');
|
|
112
|
+
restoreFromHead(projectDir, files);
|
|
113
|
+
|
|
114
|
+
return { files };
|
|
115
|
+
});
|
package/lib/git.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
2
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { refusal } from './refusal.js';
|
|
4
5
|
|
|
5
6
|
// `git commit --only <paths>` is a partial commit, which git refuses outright while a merge
|
|
6
7
|
// or a sequencer operation is in progress. Detect it up front so the failure has a reason.
|
|
@@ -24,9 +25,17 @@ export function operationInProgress(projectDir) {
|
|
|
24
25
|
return IN_PROGRESS.find((name) => existsSync(path.join(dir, name))) ?? null;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A path as a literal pathspec from the project: git would read `[`, `*` or `?` in a name as a
|
|
30
|
+
* glob and take its siblings too (`a[1].md` matching `a1.md`). An absolute path goes relative.
|
|
31
|
+
*/
|
|
32
|
+
export const literal = (projectDir, p) => `:(literal)${relOf(projectDir, p)}`;
|
|
33
|
+
|
|
27
34
|
const tracked = (projectDir, p) =>
|
|
28
|
-
spawnSync('git', ['ls-files', '--error-unmatch', '--', p], {
|
|
29
|
-
|
|
35
|
+
spawnSync('git', ['ls-files', '--error-unmatch', '--', literal(projectDir, p)], {
|
|
36
|
+
cwd: projectDir,
|
|
37
|
+
stdio: 'ignore',
|
|
38
|
+
}).status === 0;
|
|
30
39
|
|
|
31
40
|
/** Whether the last commit holds `p`: a file only staged is not in it. */
|
|
32
41
|
export const inHead = (projectDir, p) =>
|
|
@@ -51,6 +60,94 @@ export function dirtyPaths(projectDir, paths) {
|
|
|
51
60
|
return res.status === 0 ? res.stdout.split('\n').filter(Boolean) : [];
|
|
52
61
|
}
|
|
53
62
|
|
|
63
|
+
/**
|
|
64
|
+
* What the commit gate reads (hooks/pre-commit.js), as pathspecs from the project: gcf/ without
|
|
65
|
+
* gcf/.metrics (audit and context append to it on every run) and without an unfinished
|
|
66
|
+
* import's held anchor map (`source/*.import.json`, kept until `gcf anchor --done`).
|
|
67
|
+
*/
|
|
68
|
+
export const GATE_SCOPE = [
|
|
69
|
+
'gcf',
|
|
70
|
+
':(exclude)gcf/.metrics',
|
|
71
|
+
':(exclude,glob)gcf/source/*.import.json',
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Every path under the gate's scope git sees changed, staged or not, or new, from the project
|
|
76
|
+
* with `/`: the whole set a refusal names, so committing it all clears the gate in one go.
|
|
77
|
+
* From git, not a refusal's text: a name may hold `, ` or any letter. `skip`: paths (absolute
|
|
78
|
+
* or from the project) that ride along with a move and stop nothing.
|
|
79
|
+
* @param {string} projectDir
|
|
80
|
+
* @param {Iterable<string>} [skip]
|
|
81
|
+
*/
|
|
82
|
+
export function dirtyGcf(projectDir, skip = []) {
|
|
83
|
+
const res = spawnSync(
|
|
84
|
+
'git',
|
|
85
|
+
['-c', 'core.quotePath=false', 'status', '--porcelain', '-z', '-uall', '--', ...GATE_SCOPE],
|
|
86
|
+
{ cwd: projectDir, encoding: 'utf8' },
|
|
87
|
+
);
|
|
88
|
+
if (res.status !== 0) return [];
|
|
89
|
+
// Porcelain paths are the repository's: a project inside a bigger repository is a prefix in.
|
|
90
|
+
const prefix = spawnSync('git', ['rev-parse', '--show-prefix'], {
|
|
91
|
+
cwd: projectDir,
|
|
92
|
+
encoding: 'utf8',
|
|
93
|
+
}).stdout.trim();
|
|
94
|
+
const recs = res.stdout.split('\0');
|
|
95
|
+
const ours = (file) => (prefix && file.startsWith(prefix) ? file.slice(prefix.length) : file);
|
|
96
|
+
const paths = [];
|
|
97
|
+
for (let i = 0; i < recs.length; i++) {
|
|
98
|
+
const rec = recs[i];
|
|
99
|
+
if (rec.length < 4) continue;
|
|
100
|
+
paths.push(ours(rec.slice(3)));
|
|
101
|
+
// A rename or a copy: its old path is the next record. A rename's is a deletion the gate
|
|
102
|
+
// sees too, so it goes with it (under gcf/); a copy's source is unchanged.
|
|
103
|
+
const xy = rec.slice(0, 2);
|
|
104
|
+
if (!/[RC]/.test(xy)) continue;
|
|
105
|
+
i++;
|
|
106
|
+
const old = ours(recs[i] ?? '');
|
|
107
|
+
if (xy.includes('R') && old.startsWith('gcf/')) paths.push(old);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const off = new Set([...skip].map((p) => relOf(projectDir, p)));
|
|
111
|
+
|
|
112
|
+
return [...new Set(paths)].filter((p) => !off.has(p)).sort();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The refusal of a move that uncommitted gcf/ edits stop: `dirty` with `paths` (dirtyGcf) when
|
|
117
|
+
* there are any, so a board offers to show, commit or discard them; else the words alone.
|
|
118
|
+
* @param {string[]} paths
|
|
119
|
+
* @param {string} message
|
|
120
|
+
*/
|
|
121
|
+
export const dirtyRefusal = (paths, message) =>
|
|
122
|
+
paths.length ? refusal('dirty', { paths }, message) : new Error(message);
|
|
123
|
+
|
|
124
|
+
/** A path from the project with `/`, from an absolute one or one already relative. */
|
|
125
|
+
const relOf = (projectDir, p) =>
|
|
126
|
+
path.relative(path.resolve(projectDir), path.resolve(projectDir, p)).replaceAll('\\', '/');
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Put `files` (from the project) back as the last commit has them, the index too: a tracked one
|
|
130
|
+
* checked out from HEAD, a new one out of the index and off the disk. No lock: the caller holds
|
|
131
|
+
* gcf/ (design discard, edits discard).
|
|
132
|
+
* @param {string} projectDir
|
|
133
|
+
* @param {string[]} files
|
|
134
|
+
*/
|
|
135
|
+
export function restoreFromHead(projectDir, files) {
|
|
136
|
+
const git = (...args) => spawnSync('git', args, { cwd: projectDir, encoding: 'utf8' });
|
|
137
|
+
const must = (...args) => {
|
|
138
|
+
const r = git(...args);
|
|
139
|
+
if (r.status !== 0) throw new Error(`git ${args.join(' ')}: ${r.stderr.trim()}`);
|
|
140
|
+
};
|
|
141
|
+
for (const f of files) {
|
|
142
|
+
if (git('cat-file', '-e', `HEAD:./${f}`).status === 0) {
|
|
143
|
+
must('checkout', 'HEAD', '--', literal(projectDir, f));
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
must('rm', '--cached', '-q', '--ignore-unmatch', '--', literal(projectDir, f));
|
|
147
|
+
rmSync(path.join(projectDir, f), { force: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
54
151
|
const BY = ['run', 'thread', 'session', 'operator'];
|
|
55
152
|
|
|
56
153
|
/**
|
|
@@ -121,22 +218,29 @@ export function moveTrailers({ key, items = [], proposal } = {}) {
|
|
|
121
218
|
*/
|
|
122
219
|
export function commitPaths(projectDir, message, paths, move = {}) {
|
|
123
220
|
const staged = paths.filter((p) => existsSync(p) || tracked(projectDir, p));
|
|
124
|
-
for (const p of staged)
|
|
125
|
-
|
|
126
|
-
|
|
221
|
+
for (const p of staged)
|
|
222
|
+
spawnSync('git', ['add', '--', literal(projectDir, p)], { cwd: projectDir, stdio: 'ignore' });
|
|
223
|
+
// A staged deletion (`git rm`) is off the disk and out of the index, but HEAD holds it: its
|
|
224
|
+
// path commits the deletion. A file staged but never committed and now deleted matches
|
|
225
|
+
// nothing: no pathspec.
|
|
226
|
+
const real = paths.filter((p) => existsSync(p) || inHead(projectDir, p));
|
|
127
227
|
const msg = ['-m', message, ...moveTrailers(move)];
|
|
128
|
-
const
|
|
228
|
+
const only = real.map((p) => literal(projectDir, p));
|
|
229
|
+
const res = spawnSync('git', ['commit', ...msg, '--only', '--', ...only], {
|
|
129
230
|
cwd: projectDir,
|
|
130
231
|
encoding: 'utf8',
|
|
131
232
|
});
|
|
132
233
|
const out = res.stderr || res.stdout;
|
|
133
|
-
// The gate reads the whole gcf/ tree: another file's edit stops the move, in the Operator's
|
|
134
|
-
|
|
135
|
-
if (res.status !== 0 &&
|
|
136
|
-
|
|
137
|
-
|
|
234
|
+
// The gate reads the whole gcf/ tree: another file's edit stops the move, in the Operator's
|
|
235
|
+
// words. Its paths from git: the move's own staged files ride along and stop nothing.
|
|
236
|
+
if (res.status !== 0 && /gcf\/ has changes outside the index/.test(out)) {
|
|
237
|
+
const loose = dirtyGcf(projectDir, real);
|
|
238
|
+
throw dirtyRefusal(
|
|
239
|
+
loose,
|
|
240
|
+
`cannot record ${message} while gcf/ holds uncommitted changes: ${loose.join(', ')} — ` +
|
|
138
241
|
'commit or discard them, then try again',
|
|
139
242
|
);
|
|
243
|
+
}
|
|
140
244
|
if (res.status !== 0) throw new Error(`commit failed: ${out}`);
|
|
141
245
|
|
|
142
246
|
return spawnSync('git', ['rev-parse', 'HEAD'], {
|
package/lib/refusal.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// A refusal a board can act on (Rich-Chat-Plan §5): the words for people, then one machine line
|
|
2
|
+
// `gcf-refusal: {"code":…}` at the end of the message. The CLI prints an unhandled error whole,
|
|
3
|
+
// so the line reaches stderr with no wrapper around the commands; a board reads its last such
|
|
4
|
+
// line instead of parsing the words, which change.
|
|
5
|
+
|
|
6
|
+
export const REFUSAL_LINE = 'gcf-refusal: ';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An Error whose message ends with the machine line, with the same data in `refusal`. Paths go
|
|
10
|
+
* with `/` on every system (a board matches them against its own).
|
|
11
|
+
* @param {string} code
|
|
12
|
+
* @param {{paths?: string[]} & Record<string, unknown>} data
|
|
13
|
+
* @param {string} message
|
|
14
|
+
*/
|
|
15
|
+
export function refusal(code, data, message) {
|
|
16
|
+
const body = {
|
|
17
|
+
code,
|
|
18
|
+
...data,
|
|
19
|
+
...(data.paths && { paths: data.paths.map((p) => p.replaceAll('\\', '/')) }),
|
|
20
|
+
};
|
|
21
|
+
const err = /** @type {Error & {refusal: typeof body}} */ (
|
|
22
|
+
new Error(`${message}\n${REFUSAL_LINE}${JSON.stringify(body)}`)
|
|
23
|
+
);
|
|
24
|
+
err.refusal = body;
|
|
25
|
+
|
|
26
|
+
return err;
|
|
27
|
+
}
|
package/lib/safe-path.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { readFile, writeFile, rename, mkdir, unlink } from 'node:fs/promises';
|
|
1
|
+
import { readFile, writeFile, rename, mkdir, unlink, rm } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
3
4
|
import { snapshotIndex, restoreIndex } from './git.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -25,6 +26,23 @@ export function resolveInside(projectDir, target) {
|
|
|
25
26
|
return resolved;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
// Windows refuses a rename over a file another process holds open for a moment (antivirus,
|
|
30
|
+
// indexer); without a retry a rollback stops halfway and leaves gcf/ half-written.
|
|
31
|
+
const BUSY = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
32
|
+
// The board's writeAtomicSync budget: a scan of a fresh file often outlasts 200 ms.
|
|
33
|
+
const RENAME_TRIES = 10;
|
|
34
|
+
|
|
35
|
+
async function renameRetrying(from, to) {
|
|
36
|
+
for (let attempt = 1; ; attempt++) {
|
|
37
|
+
try {
|
|
38
|
+
return await rename(from, to);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (!BUSY.has(err.code) || attempt >= RENAME_TRIES) throw err;
|
|
41
|
+
await sleep(50);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
28
46
|
/** Write atomically: tmp file in the same dir, then rename over the target. */
|
|
29
47
|
export async function atomicWrite(file, data) {
|
|
30
48
|
// pid+random: writeIndex is reachable from both the pre-commit hook and applyVerdict,
|
|
@@ -33,7 +51,7 @@ export async function atomicWrite(file, data) {
|
|
|
33
51
|
await mkdir(path.dirname(file), { recursive: true });
|
|
34
52
|
await writeFile(tmp, data, 'utf8');
|
|
35
53
|
try {
|
|
36
|
-
await
|
|
54
|
+
await renameRetrying(tmp, file);
|
|
37
55
|
} catch (err) {
|
|
38
56
|
await unlink(tmp).catch(() => {});
|
|
39
57
|
throw err;
|
|
@@ -42,10 +60,8 @@ export async function atomicWrite(file, data) {
|
|
|
42
60
|
|
|
43
61
|
/** Put one snapshotted file back: `null` content means it did not exist before. */
|
|
44
62
|
async function restoreSnapshot(file, content) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (e.code !== 'ENOENT') throw e;
|
|
48
|
-
});
|
|
63
|
+
// rm retries a held file (EBUSY, EPERM) itself; force passes one already gone.
|
|
64
|
+
if (content === null) await rm(file, { force: true, maxRetries: 5 });
|
|
49
65
|
else await atomicWrite(file, content);
|
|
50
66
|
}
|
|
51
67
|
|
package/lib/unit-ops.js
CHANGED
|
@@ -11,7 +11,7 @@ import { buildLedger } from './ledger.js';
|
|
|
11
11
|
import { cycleMessage, designCheck, dependsGraph, gameMilestones, pathTo } from './design-check.js';
|
|
12
12
|
import { atomicWrite, withFileRollback } from './safe-path.js';
|
|
13
13
|
import { writeIndex } from './index-gen.js';
|
|
14
|
-
import { operationInProgress, commitPaths } from './git.js';
|
|
14
|
+
import { operationInProgress, commitPaths, dirtyGcf, dirtyRefusal } from './git.js';
|
|
15
15
|
import { upsertBlock, openSystemDoc } from './systems-doc.js';
|
|
16
16
|
import { buryLine, recordLine } from './verdict-fs.js';
|
|
17
17
|
import { defaultGate } from './validate-item.js';
|
|
@@ -301,10 +301,15 @@ async function record(
|
|
|
301
301
|
? files.filter((f) => !inputs.includes(f) && uncommitted(projectDir, f))
|
|
302
302
|
: [];
|
|
303
303
|
if (dirty.length) {
|
|
304
|
-
const
|
|
305
|
-
|
|
304
|
+
const rels = dirty.map((f) => path.relative(projectDir, f).replaceAll('\\', '/'));
|
|
305
|
+
// The whole of gcf/'s edits, not only these: the gate would refuse the next one at once.
|
|
306
|
+
// Only when that set holds them all: a move's own file outside it (an archived plan) is no
|
|
307
|
+
// edit `gcf edits` takes, and a Commit of the rest would be refused again.
|
|
308
|
+
const all = dirtyGcf(projectDir, inputs);
|
|
309
|
+
throw dirtyRefusal(
|
|
310
|
+
rels.every((r) => all.includes(r)) ? all : [],
|
|
306
311
|
`commit or stash these first (an answered unit is committed before its move), ` +
|
|
307
|
-
`${message} would carry them: ${
|
|
312
|
+
`${message} would carry them: ${rels.join(', ')}`,
|
|
308
313
|
);
|
|
309
314
|
}
|
|
310
315
|
|
package/lib/work-ops.js
CHANGED
|
@@ -43,7 +43,15 @@ import { locked, runHolder } from './main-lock.js';
|
|
|
43
43
|
import { dropAgentSession, ownsMark, releaseSession, sessionActive } from './session-mark.js';
|
|
44
44
|
import { dropStamp, unverifiedProblem } from './verify-stamp.js';
|
|
45
45
|
import { planTicks } from './plan-check.js';
|
|
46
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
commitPaths,
|
|
48
|
+
dirtyGcf,
|
|
49
|
+
dirtyRefusal,
|
|
50
|
+
GATE_SCOPE,
|
|
51
|
+
operationInProgress,
|
|
52
|
+
restoreIndex,
|
|
53
|
+
snapshotIndex,
|
|
54
|
+
} from './git.js';
|
|
47
55
|
import { verdictDeferred } from './gates.js';
|
|
48
56
|
import { appendQuestions, questionsFile } from './questions.js';
|
|
49
57
|
|
|
@@ -838,8 +846,9 @@ async function verdictItemUnlocked(projectDir, id, verdict, opts = {}) {
|
|
|
838
846
|
return { verdict, id, systems, hash, removal };
|
|
839
847
|
}
|
|
840
848
|
|
|
841
|
-
// What a milestone's keep may write: gcf/
|
|
842
|
-
|
|
849
|
+
// What a milestone's keep may write: gcf/ as the gate reads it (no .metrics, which audit and
|
|
850
|
+
// context append to on every run) and the plans its items archive.
|
|
851
|
+
const KEEP_SCOPE = [...GATE_SCOPE, '.ai-factory/plans', '.ai-factory/archive'];
|
|
843
852
|
|
|
844
853
|
/** The paths under KEEP_SCOPE git sees changed or new, relative to the project. */
|
|
845
854
|
function changedIn(projectDir) {
|
|
@@ -928,11 +937,15 @@ async function keepMilestoneUnlocked(projectDir, name, opts = {}) {
|
|
|
928
937
|
const order = keepOrder(pack);
|
|
929
938
|
const own = new Set(pack.map((i) => path.relative(projectDir, i.file).replaceAll('\\', '/')));
|
|
930
939
|
const loose = changedIn(projectDir).filter((c) => !own.has(c.file));
|
|
931
|
-
if (loose.length)
|
|
932
|
-
|
|
940
|
+
if (loose.length) {
|
|
941
|
+
// The board's Commit clears only gcf/'s edits: a loose plan gets the words alone.
|
|
942
|
+
const all = dirtyGcf(projectDir, own);
|
|
943
|
+
throw dirtyRefusal(
|
|
944
|
+
loose.every((c) => all.includes(c.file)) ? all : [],
|
|
933
945
|
`commit or stash these first, keep --milestone ${name} would carry them: ` +
|
|
934
946
|
loose.map((c) => c.file).join(', '),
|
|
935
947
|
);
|
|
948
|
+
}
|
|
936
949
|
|
|
937
950
|
if (commit && onWorkBranch(projectDir))
|
|
938
951
|
throw new Error('keep --milestone records on main: a work/ branch records no move');
|
package/package.json
CHANGED
package/skills/gcf-chat/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@ mode: human gate
|
|
|
8
8
|
purpose:
|
|
9
9
|
- answer the human's questions about the game, its design, its work items and its runs from what `gcf/` and the run files say
|
|
10
10
|
- turn a bug, an idea or a task the talk finds into a proposed work item the human accepts with one click
|
|
11
|
-
- propose a move on an item
|
|
11
|
+
- propose a move on an item, an inbox entry or an open question (block, drop, depends, unblock, a verdict, a decision, an answer, inbox add, category, Later, erase) as a card the human makes with one click
|
|
12
12
|
- make another move the human asks for through its `ai-factory gcf` command, which the chat shows the human as a card first
|
|
13
13
|
|
|
14
14
|
inputs:
|
|
@@ -17,13 +17,20 @@ inputs:
|
|
|
17
17
|
|
|
18
18
|
preconditions:
|
|
19
19
|
- `gcf/` exists and `ai-factory gcf board --json` runs
|
|
20
|
-
- the board started this session: a project chat asks the human before each change
|
|
20
|
+
- the board started this session: a project chat asks the human before each change, unless the human turned YOLO on
|
|
21
|
+
- a thread may run with YOLO, the human's switch in the board's Settings: your calls run without a card, the deny rules and the refusal while a main run works still hold; turning it on or off is not yours
|
|
22
|
+
- with YOLO a framework move that changes the project runs without a card too: a move with a `propose_` tool stays a proposal, and any other move is one the human asked for
|
|
21
23
|
|
|
22
24
|
forbidden_behaviors:
|
|
23
|
-
- do not make the human's moves: `verdict`, `decide`, `question answer`, `unblock`, `phase next`, `pillar`, `permissions`, `config set`, `hooks-install`; the rules refuse them to any agent
|
|
25
|
+
- do not make the human's moves: `verdict`, `decide`, `question answer`, `unblock`, `phase next`, `pillar`, `permissions`, `config set`, `hooks-install`, `edits commit`, `edits discard`; the rules refuse them to any agent
|
|
26
|
+
- do not run a verdict, a decision, an unblock or an answer: propose it to the human with its `propose_` tool
|
|
24
27
|
- do not run `ai-factory gcf-harness run|stop|chat|init` or `ai-factory extension`: the rules refuse them; name the board's button instead
|
|
25
28
|
- do not make a new item with `ai-factory gcf item new`: propose it with the `propose_item_new` tool of the `gcf` MCP server, and the human's click makes it
|
|
26
|
-
- do not run the command of a move that has a `propose_` tool of the `gcf` MCP server
|
|
29
|
+
- do not run the command of a move that has a `propose_` tool of the `gcf` MCP server: call the tool; every `propose_` tool of the server is such a move
|
|
30
|
+
- do not propose a verdict (`propose_verdict_keep`, `propose_verdict_tune`, `propose_verdict_kill`) unless the human said in this talk that they played the item and how it felt
|
|
31
|
+
- do not base a verdict on tests, code or your own judgment: its note is the human's words
|
|
32
|
+
- do not set `remove` of `propose_verdict_kill`, `propose_decide_no` or `propose_decide_wontfix`: the rule decides it, as in the human's form; `true` or `false` only on the human's words; the graveyard `tags` only on the human's words too
|
|
33
|
+
- do not commit, discard or stash the human's hand edits under `gcf/`: they are the human's unfinished work; a move refused for them waits for the human, and `ai-factory gcf edits diff --path <path>` shows them
|
|
27
34
|
- do not write code or edit files to fix what the talk finds: a fix is a work item, and its run builds it
|
|
28
35
|
- do not answer from memory what a file says: read the file, then answer
|
|
29
36
|
- do not ask again for a move the human refused: say what it would have done and leave it
|
|
@@ -35,9 +42,11 @@ workflow:
|
|
|
35
42
|
3. answer the question from the files you read, with the paths that say it; for the runs' numbers run `ai-factory gcf-harness metrics` when the project has the harness
|
|
36
43
|
4. a bug, an idea or a task that is new work: call `propose_item_new` with its title, type, subsystems and a note of what its run should know, no id: the core makes it from the title; note length <= 4000 characters
|
|
37
44
|
5. a raw thought that is not work yet: propose it for the inbox with `propose_inbox_add` and the category it is: `idea`, `request` (what only a person can give), `bug` or `finding` (a remark about the code), a detail word when one fits
|
|
38
|
-
6. a move the human asks for, or one the talk shows is due, that has a `propose_<move>` tool: call it with the `id` of the item
|
|
39
|
-
7.
|
|
40
|
-
8.
|
|
45
|
+
6. a move the human asks for, or one the talk shows is due, that has a `propose_<move>` tool: call it with the `id` of the item, inbox entry or question it acts on, and say why in one line; name an item by its title with the id in brackets
|
|
46
|
+
7. a kill, a no or a wontfix: its reason is the human's words; the graveyard keeps it, and the move does not go without it
|
|
47
|
+
8. an open D1 question the talk answers: call `propose_question_answer` with its id and the human's words, or your draft when the human asks for one
|
|
48
|
+
9. another move the human asks for: run its `ai-factory gcf` command; the human approves it on the card, or refuses it
|
|
49
|
+
10. say in one line what changed, or that nothing did
|
|
41
50
|
|
|
42
51
|
invocation:
|
|
43
52
|
- run at the start of a project chat thread the board opens, and when the user types `/gcf-chat`
|
|
@@ -46,16 +46,18 @@ gcf_work:
|
|
|
46
46
|
- a draft the human asked for (the glossary, a subsystem's purpose, the pillars' names) is written and not recorded: the human records it, edits it in its form or discards it (`ai-factory gcf design discard`)
|
|
47
47
|
- one part of the design (`pillars`, `game`, `glossary`, a subsystem, a unit) reads as fields with `ai-factory gcf design part <kind> <name> --json`; `ai-factory gcf design save <name> --kind <kind> --base <hash> --fields-file -` writes it back, refused when the part changed since its read; a new unit is `design save --kind unit --system <s> --type <t> --title "<title>" --fields-file -`, its id printed first
|
|
48
48
|
- a new item's `--note "<text>"` (or `--note-file -` for several lines) says what its run should know, up to 4000 characters
|
|
49
|
-
- in the project chat (the gcf-chat skill) a new item is proposed with the `propose_item_new` tool of the `gcf` MCP server, not made with `item new`: the human's click makes it; so are a block, a drop, a dependency change and the inbox's add, category, Later and erase, with their `propose_` tools and the `id` they act on; a new item is proposed by its title, never an id
|
|
49
|
+
- in the project chat (the gcf-chat skill) a new item is proposed with the `propose_item_new` tool of the `gcf` MCP server, not made with `item new`: the human's click makes it; so are a block, a drop, a dependency change, an unblock, a verdict, a decision, an answer to an open question and the inbox's add, category, Later and erase, with their `propose_` tools and the `id` they act on; a new item is proposed by its title, never an id
|
|
50
|
+
- a verdict is proposed only after the human said in the talk that they played the item and how it felt, its note in the human's words; the `remove` of a kill, a no or a wontfix is left to the rule unless the human says otherwise
|
|
51
|
+
- a move refused for hand edits under `gcf/` ends its error with `gcf-refusal: {"code":"dirty","paths":[…]}`: `ai-factory gcf edits diff --path <path>` shows them; `gcf edits commit` and `gcf edits discard` are the human's moves, never the agent's
|
|
50
52
|
- a chat thread bound to an item reads the item's file, its plan, its run's log and run chat first (the paths its context names), answers the question, and only then proposes a move
|
|
51
53
|
|
|
52
54
|
gcf_forbidden:
|
|
53
55
|
- do not edit `status:`, `frozen:`, `gcf/LIVE.md`, `gcf/history.md`, `gcf/graveyard.md`, `gcf/inbox/` or `gcf/INDEX.md` by hand: the commands own them
|
|
54
56
|
- do not give a verdict: `verdict` belongs to the human, through the gcf-verdict skill; nor a decision, but `go` or `no` of the spike you drive when the gates say `decision: agent`
|
|
55
|
-
- the core refuses the human's moves to a harness run and a board chat (`verdict`, `decide`, `drop` of a work item, `unblock`, `question answer`, `config set`, `permissions`, `phase next`, `pillar`, `hooks-install`): bring the move to the human, or block the item with the question
|
|
57
|
+
- the core refuses the human's moves to a harness run and a board chat (`verdict`, `decide`, `drop` of a work item, `unblock`, `question answer`, `config set`, `permissions`, `phase next`, `pillar`, `hooks-install`, `edits commit`, `edits discard`): bring the move to the human, or block the item with the question
|
|
56
58
|
- do not answer a `TBD` of a design unit yourself: ask the human and offer your draft as the proposed answer
|
|
57
59
|
- do not run `ai-factory gcf phase next`: the phase moves on the human's word only
|
|
58
|
-
- do not change what agent runs may do: `ai-factory gcf permissions
|
|
60
|
+
- do not change what agent runs may do: `ai-factory gcf permissions`, its deny groups and the board's YOLO belong to the human
|
|
59
61
|
- do not change a setting of `gcf/config.yml` or the `language` of `.ai-factory/config.yaml`: `ai-factory gcf config set` belongs to the human
|
|
60
62
|
- do not reuse an ended id: rework gets a new id with `reopens: <old id>`
|
|
61
63
|
- do not commit past the gate with `--no-verify`: a refused commit names what to fix
|