gcf-aif-ext 0.22.1 → 0.24.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 +23 -2
- package/commands/gcf.js +122 -4
- package/extension.json +1 -1
- package/lib/agent-permissions.js +4 -1
- package/lib/audit-core.js +7 -1
- package/lib/board.js +6 -2
- package/lib/changes.js +33 -7
- package/lib/commit-files.js +292 -0
- package/lib/design-parts.js +13 -5
- package/lib/domain.js +38 -5
- package/lib/git.js +23 -4
- package/lib/id.js +1 -0
- package/lib/inbox-categories.js +1 -0
- package/lib/inbox.js +6 -1
- package/lib/integrate.js +76 -16
- package/lib/lessons.js +2 -1
- package/lib/main-lock.js +1 -1
- package/lib/migrate.js +1 -0
- package/lib/milestone-state.js +2 -1
- package/lib/session-mark.js +29 -4
- package/lib/shelf.js +1003 -0
- package/lib/systems-doc.js +50 -2
- package/lib/transitions.js +2 -0
- package/lib/work-ops.js +264 -16
- package/package.json +1 -1
- package/skills/gcf-chat/SKILL.md +16 -9
- package/skills/gcf-triage/SKILL.md +9 -7
- package/templates/agents-block.md +61 -23
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// The operator's commit from the Changes screen (Board-PRD decision 50, docs/Round11-Plan.md): the
|
|
2
|
+
// files they ticked with their own message, in the main checkout. Not `commitMove`: its rollback
|
|
3
|
+
// rewrites the files it read, so a save during a slow hook would go, and it always takes INDEX.md,
|
|
4
|
+
// so a commit of code alone would enter the gate. The working tree is never written, but INDEX.md
|
|
5
|
+
// when gcf/ is committed; on a refusal the index and INDEX.md are as they were.
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import { existsSync, lstatSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import os from 'node:os';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { rowsToCommit } from './changes.js';
|
|
11
|
+
import {
|
|
12
|
+
commitOnly,
|
|
13
|
+
dirtyGcf,
|
|
14
|
+
dirtyRefusal,
|
|
15
|
+
inParts,
|
|
16
|
+
literal,
|
|
17
|
+
moveTrailers,
|
|
18
|
+
operationInProgress,
|
|
19
|
+
} from './git.js';
|
|
20
|
+
import { writeIndex } from './index-gen.js';
|
|
21
|
+
import { MAIN_RUN, runHolder, withMainLock } from './main-lock.js';
|
|
22
|
+
import { refusal } from './refusal.js';
|
|
23
|
+
import { onWorkBranch } from './unit-ops.js';
|
|
24
|
+
|
|
25
|
+
const INDEX = 'gcf/INDEX.md';
|
|
26
|
+
// The ids a commit touches, as `gcf edits commit` finds them: item history reads them.
|
|
27
|
+
const ITEM_PATH = /^gcf\/work\/([^/]+?)(?:\.md$|\/)/;
|
|
28
|
+
const UNFIT = ['nested repository', 'not a regular file'];
|
|
29
|
+
|
|
30
|
+
/** Whether the commit gate reads `p` (GATE_SCOPE in git.js). */
|
|
31
|
+
const inGate = (p) =>
|
|
32
|
+
p === 'GLOSSARY.md' ||
|
|
33
|
+
(p.startsWith('gcf/') &&
|
|
34
|
+
!p.startsWith('gcf/.metrics/') &&
|
|
35
|
+
!/^gcf\/source\/[^/]+\.import\.json$/.test(p));
|
|
36
|
+
|
|
37
|
+
const git = (dir, args, opts = {}) =>
|
|
38
|
+
spawnSync('git', ['-c', 'core.quotePath=false', ...args], {
|
|
39
|
+
cwd: dir,
|
|
40
|
+
encoding: 'utf8',
|
|
41
|
+
...opts,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const nul = (dir, paths) => paths.map((p) => `${literal(dir, p)}\0`).join('');
|
|
45
|
+
|
|
46
|
+
/** A commit needs a branch to land on: an unborn one is one, a detached HEAD is not. */
|
|
47
|
+
function refuseWhereNoCommitBelongs(dir, subject) {
|
|
48
|
+
if (onWorkBranch(dir))
|
|
49
|
+
throw new Error(`cannot record ${subject} on a work/ branch: a run commits its own work`);
|
|
50
|
+
const busy = operationInProgress(dir);
|
|
51
|
+
if (busy) throw new Error(`cannot record ${subject} while ${busy} is in progress`);
|
|
52
|
+
if (git(dir, ['symbolic-ref', '-q', 'HEAD']).status !== 0)
|
|
53
|
+
throw new Error(`cannot record ${subject} on a detached HEAD: check out a branch first`);
|
|
54
|
+
if (runHolder(dir, MAIN_RUN))
|
|
55
|
+
throw refusal('running', {}, `cannot record ${subject}: a run writes in the main checkout`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A staged rename only: the index holds the old file's text under the new name. */
|
|
59
|
+
const onlyMoved = (dir, r) =>
|
|
60
|
+
r.xy[0] === 'R' &&
|
|
61
|
+
git(dir, ['rev-parse', `:./${r.path}`]).stdout ===
|
|
62
|
+
git(dir, ['rev-parse', `HEAD:./${r.from}`]).stdout;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* What the disk would overwrite: `--only` takes the disk, so a text staged and changed again
|
|
66
|
+
* would go without a trace, and a file out of the index by `rm --cached` would come back.
|
|
67
|
+
*/
|
|
68
|
+
function stagedAway(dir, base, rows) {
|
|
69
|
+
const out = git(dir, [
|
|
70
|
+
'diff',
|
|
71
|
+
'--cached',
|
|
72
|
+
'--no-renames',
|
|
73
|
+
'--diff-filter=D',
|
|
74
|
+
'--name-only',
|
|
75
|
+
'-z',
|
|
76
|
+
'--relative',
|
|
77
|
+
base,
|
|
78
|
+
]);
|
|
79
|
+
const removed = new Set(out.stdout.split('\0'));
|
|
80
|
+
|
|
81
|
+
return rows.filter((r) =>
|
|
82
|
+
r.status === 'untracked'
|
|
83
|
+
? removed.has(r.path)
|
|
84
|
+
: r.xy && !r.xy.includes('.') && !onlyMoved(dir, r),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// A whole block, not one line: `=======` alone underlines a Markdown heading.
|
|
89
|
+
const MARKERS = /^<{7}[ \r\n][\s\S]*?^={7}\r?$[\s\S]*?^>{7}[ \r\n]/m;
|
|
90
|
+
const MARKERS_READ = 16 * 1024 * 1024;
|
|
91
|
+
|
|
92
|
+
/** The text of a file on the disk with a conflict's markers in it that the last commit lacks. */
|
|
93
|
+
function newMarkers(dir, r) {
|
|
94
|
+
const file = path.join(dir, r.path);
|
|
95
|
+
if (r.status === 'deleted' || !existsSync(file)) return false;
|
|
96
|
+
const st = lstatSync(file);
|
|
97
|
+
if (!st.isFile() || st.size > MARKERS_READ) return false;
|
|
98
|
+
const bytes = readFileSync(file);
|
|
99
|
+
if (bytes.includes(0) || !MARKERS.test(bytes.toString('latin1'))) return false;
|
|
100
|
+
const old = git(dir, ['show', `HEAD:./${r.from ?? r.path}`]);
|
|
101
|
+
|
|
102
|
+
return !(old.status === 0 && MARKERS.test(old.stdout));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A return's conflict leaves its markers in a plain modified file: git sees no conflict, and
|
|
107
|
+
* whatever `-diff` says of it, a commit would take them.
|
|
108
|
+
*/
|
|
109
|
+
function refuseMarkers(dir, rows, subject) {
|
|
110
|
+
const marked = rows.filter((r) => newMarkers(dir, r)).map((r) => r.path);
|
|
111
|
+
if (marked.length)
|
|
112
|
+
throw refusal(
|
|
113
|
+
'unfit',
|
|
114
|
+
{ paths: marked },
|
|
115
|
+
`cannot record ${subject}: ${marked.join(', ')} still hold conflict markers: resolve them ` +
|
|
116
|
+
'first; a file meant to hold them goes by Commit with agent',
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Stops before anything is written. */
|
|
121
|
+
function refuseRows(dir, base, rows, subject) {
|
|
122
|
+
const unfit = rows
|
|
123
|
+
.filter((r) => r.status === 'conflict' || UNFIT.includes(r.why))
|
|
124
|
+
.map((r) => r.path);
|
|
125
|
+
if (unfit.length)
|
|
126
|
+
throw refusal(
|
|
127
|
+
'unfit',
|
|
128
|
+
{ paths: unfit },
|
|
129
|
+
`cannot record ${subject}: ${unfit.join(', ')} cannot be committed: resolve a conflict ` +
|
|
130
|
+
'first; a nested repository or anything but a file stays out',
|
|
131
|
+
);
|
|
132
|
+
refuseMarkers(dir, rows, subject);
|
|
133
|
+
// `--only` takes the disk for the old name too: a new file there would ride along, unticked.
|
|
134
|
+
// Only its letters changed: on a disk that ignores case the old name is the new file.
|
|
135
|
+
const reused = rows.filter(
|
|
136
|
+
(r) =>
|
|
137
|
+
r.status === 'renamed' &&
|
|
138
|
+
r.from &&
|
|
139
|
+
r.from.toLowerCase() !== r.path.toLowerCase() &&
|
|
140
|
+
existsSync(path.join(dir, r.from)),
|
|
141
|
+
);
|
|
142
|
+
if (reused.length)
|
|
143
|
+
throw refusal(
|
|
144
|
+
'staged',
|
|
145
|
+
{ paths: reused.map((r) => r.path) },
|
|
146
|
+
`cannot record ${subject}: something new stands at the old name of ` +
|
|
147
|
+
`${reused.map((r) => `${r.from} → ${r.path}`).join(', ')}: commit that first, ` +
|
|
148
|
+
'or use Commit with agent',
|
|
149
|
+
);
|
|
150
|
+
const staged = stagedAway(dir, base, rows).map((r) => r.path);
|
|
151
|
+
if (staged.length)
|
|
152
|
+
throw refusal(
|
|
153
|
+
'staged',
|
|
154
|
+
{ paths: staged },
|
|
155
|
+
`cannot record ${subject}: ${staged.join(', ')} ha${staged.length === 1 ? 's' : 've'} ` +
|
|
156
|
+
'staged text the disk does not hold, and this commit takes the disk: `git add` to take ' +
|
|
157
|
+
'the disk, `git restore --staged` to drop what is staged, or use Commit with agent',
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The gate reads the whole of its scope: its dirty files go together, or not at all. */
|
|
162
|
+
function refuseGateRest(dir, names, subject) {
|
|
163
|
+
const rest = dirtyGcf(dir, [...names.filter(inGate), INDEX]);
|
|
164
|
+
if (rest.length)
|
|
165
|
+
throw dirtyRefusal(
|
|
166
|
+
rest,
|
|
167
|
+
`cannot record ${subject} while gcf/ holds uncommitted changes: ${rest.join(', ')} — ` +
|
|
168
|
+
'commit or discard them, then try again',
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** `git commit -F`, as a message of many lines and a list on stdin share no command line. */
|
|
173
|
+
function commitWith(dir, subject, specs, text) {
|
|
174
|
+
const tmp = mkdtempSync(path.join(os.tmpdir(), 'gcf-commit-'));
|
|
175
|
+
const file = path.join(tmp, 'message');
|
|
176
|
+
try {
|
|
177
|
+
writeFileSync(file, text);
|
|
178
|
+
|
|
179
|
+
return commitOnly(dir, subject, specs, ['-F', file, '--cleanup=whitespace']);
|
|
180
|
+
} finally {
|
|
181
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Stage `add`, commit `all`; `clean` when nothing of it differs from the last commit. */
|
|
186
|
+
function stageAndCommit(dir, { add, all, subject, text }) {
|
|
187
|
+
// No paths: `git add -A` on an empty list takes the whole tree, a staged text's copy too.
|
|
188
|
+
if (add.length) {
|
|
189
|
+
const staged = git(dir, ['add', '-A', '--pathspec-from-file=-', '--pathspec-file-nul'], {
|
|
190
|
+
input: nul(dir, add),
|
|
191
|
+
});
|
|
192
|
+
if (staged.status !== 0) throw new Error(`commit failed: ${staged.stderr.trim()}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const specs = all.map((p) => literal(dir, p));
|
|
196
|
+
const same = inParts(specs).every(
|
|
197
|
+
(part) => git(dir, ['diff', '--cached', '--quiet', 'HEAD', '--', ...part]).status === 0,
|
|
198
|
+
);
|
|
199
|
+
if (same)
|
|
200
|
+
throw refusal(
|
|
201
|
+
'clean',
|
|
202
|
+
{ paths: all, left: [] },
|
|
203
|
+
`cannot record ${subject}: nothing left to commit in these files`,
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return commitWith(dir, subject, all, text);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** The index file's bytes, and how to put them back: `git add` of a folder takes more. */
|
|
210
|
+
function indexKeeper(dir) {
|
|
211
|
+
const file = path.resolve(dir, git(dir, ['rev-parse', '--git-path', 'index']).stdout.trim());
|
|
212
|
+
const bytes = existsSync(file) ? readFileSync(file) : null;
|
|
213
|
+
const head = git(dir, ['rev-parse', '-q', '--verify', 'HEAD']).stdout;
|
|
214
|
+
|
|
215
|
+
return () => {
|
|
216
|
+
// Someone committed meanwhile: this index is theirs now.
|
|
217
|
+
if (git(dir, ['rev-parse', '-q', '--verify', 'HEAD']).stdout !== head) return;
|
|
218
|
+
if (bytes) writeFileSync(file, bytes);
|
|
219
|
+
else rmSync(file, { force: true });
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** `run` with INDEX.md and the index put back if it throws. */
|
|
224
|
+
async function undoingOnRefusal(dir, gated, run) {
|
|
225
|
+
const index = path.join(dir, INDEX);
|
|
226
|
+
const before = gated && existsSync(index) ? readFileSync(index) : null;
|
|
227
|
+
const putBack = indexKeeper(dir);
|
|
228
|
+
try {
|
|
229
|
+
if (gated) await writeIndex(path.join(dir, 'gcf'));
|
|
230
|
+
|
|
231
|
+
return run();
|
|
232
|
+
} catch (e) {
|
|
233
|
+
putBack();
|
|
234
|
+
if (before) writeFileSync(index, before);
|
|
235
|
+
else if (gated) rmSync(index, { force: true });
|
|
236
|
+
throw e;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** The message as the operator wrote it, and a move's trailers when the commit moves gcf/. */
|
|
241
|
+
function messageOf(message, rows, gated) {
|
|
242
|
+
if (!gated) return message;
|
|
243
|
+
const items = rows.flatMap((r) => ITEM_PATH.exec(r.path)?.[1] ?? []);
|
|
244
|
+
const lines = moveTrailers({ key: 'edits-commit', items })[1];
|
|
245
|
+
|
|
246
|
+
return `${message.trimEnd()}\n\n${lines}\n`;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Commit these rows of the main checkout with `message`: a rename takes both names, a ticked file
|
|
251
|
+
* gone clean meanwhile drops out. Other staged files stay staged, out of the commit.
|
|
252
|
+
* @param {string} projectDir
|
|
253
|
+
* @param {{message: unknown, paths: unknown}} fields
|
|
254
|
+
*/
|
|
255
|
+
export async function commitFiles(projectDir, { message, paths }) {
|
|
256
|
+
const dir = path.resolve(projectDir);
|
|
257
|
+
const subject = typeof message === 'string' ? message.trim().split('\n')[0].trim() : '';
|
|
258
|
+
if (!subject) throw new Error('changes commit: write the message first');
|
|
259
|
+
if (!Array.isArray(paths) || !paths.length || paths.some((p) => typeof p !== 'string'))
|
|
260
|
+
throw new Error('changes commit: name the paths, as `gcf changes` lists them');
|
|
261
|
+
|
|
262
|
+
return withMainLock(dir, async () => {
|
|
263
|
+
refuseWhereNoCommitBelongs(dir, subject);
|
|
264
|
+
const { base, rows } = await rowsToCommit(dir);
|
|
265
|
+
const wanted = new Set(paths);
|
|
266
|
+
const picked = rows.filter((r) => wanted.has(r.path));
|
|
267
|
+
if (!picked.length)
|
|
268
|
+
throw refusal(
|
|
269
|
+
'clean',
|
|
270
|
+
{ paths, left: [] },
|
|
271
|
+
`cannot record ${subject}: nothing left to commit in these files`,
|
|
272
|
+
);
|
|
273
|
+
refuseRows(dir, base, picked, subject);
|
|
274
|
+
const moved = picked.flatMap((r) => (r.status === 'renamed' && r.from ? [r.from] : []));
|
|
275
|
+
const names = [...picked.map((r) => r.path), ...moved];
|
|
276
|
+
const gated = names.some(inGate) && existsSync(path.join(dir, 'gcf'));
|
|
277
|
+
if (gated) refuseGateRest(dir, names, subject);
|
|
278
|
+
const all = [...new Set(gated ? [...names, INDEX] : names)];
|
|
279
|
+
// Neither on disk nor in the index, git add finds nothing by them; `--only` finds them in HEAD.
|
|
280
|
+
const gone = new Set([...moved, ...picked.filter((r) => r.xy?.[0] === 'D').map((r) => r.path)]);
|
|
281
|
+
const text = messageOf(message, picked, gated);
|
|
282
|
+
const hash = await undoingOnRefusal(dir, gated, () =>
|
|
283
|
+
stageAndCommit(dir, { add: all.filter((p) => !gone.has(p)), all, subject, text }),
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return {
|
|
287
|
+
hash: git(dir, ['rev-parse', '--short', hash]).stdout.trim(),
|
|
288
|
+
subject,
|
|
289
|
+
files: picked.length,
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
}
|
package/lib/design-parts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The design as parts a board edits field by field (Board-PRD §5.24): PILLARS.md, game.md,
|
|
2
|
-
// the project's GLOSSARY.md, a subsystem's purpose, a unit. A part reads as the fields its CNL-P
|
|
2
|
+
// the project's GLOSSARY.md, a subsystem's purpose, a unit. A part reads as the fields its CNL-P
|
|
3
|
+
// profile
|
|
3
4
|
// declares; a save writes the edited fields back into the part's text and brings it in as a
|
|
4
5
|
// one-part bundle (lib/bundle.js), so a form edit passes the same three-way check and the same
|
|
5
6
|
// design check a designer's import does. The board writes no file of gcf/ itself.
|
|
@@ -312,6 +313,7 @@ function changedKeys(before, after) {
|
|
|
312
313
|
|
|
313
314
|
return new Map(blocksOf(lf(t)).map((b) => [b.key, raw.slice(b.start - 1, b.end).join('\n')]));
|
|
314
315
|
};
|
|
316
|
+
|
|
315
317
|
const a = read(before);
|
|
316
318
|
const b = read(after);
|
|
317
319
|
|
|
@@ -348,6 +350,7 @@ function pillarIds(part, given) {
|
|
|
348
350
|
|
|
349
351
|
return { ...p, id };
|
|
350
352
|
}
|
|
353
|
+
|
|
351
354
|
const was = before.find((b) => b.id === p.id);
|
|
352
355
|
if (oneLine(was?.name) && oneLine(p.name) && oneLine(was.name) !== oneLine(p.name)) {
|
|
353
356
|
const to = deriveId(oneLine(p.name), (x) => x !== p.id && taken.has(x), 'pillar');
|
|
@@ -379,7 +382,8 @@ async function refuseLooseForRename(projectDir, renames) {
|
|
|
379
382
|
];
|
|
380
383
|
if (loose.length)
|
|
381
384
|
throw new Error(
|
|
382
|
-
`a new pillar name renames its id where it is cited: record or
|
|
385
|
+
`a new pillar name renames its id where it is cited: record or ` +
|
|
386
|
+
`discard ${loose.join(', ')} first`,
|
|
383
387
|
);
|
|
384
388
|
}
|
|
385
389
|
|
|
@@ -416,7 +420,8 @@ async function saveUnlocked(
|
|
|
416
420
|
let part = await designPart(projectDir, kind, name, { type });
|
|
417
421
|
if (part.exists && !base)
|
|
418
422
|
throw new Error(
|
|
419
|
-
`${kind} ${name} exists: pass --base from gcf design part, so an edit made since is
|
|
423
|
+
`${kind} ${name} exists: pass --base from gcf design part, so an edit made since is ` +
|
|
424
|
+
`not overwritten`,
|
|
420
425
|
);
|
|
421
426
|
const owner = part.system ?? system;
|
|
422
427
|
if (kind === 'unit' && !part.exists && !SLUG_RE.test(String(owner ?? '')))
|
|
@@ -441,6 +446,7 @@ async function saveUnlocked(
|
|
|
441
446
|
part = await designPart(projectDir, kind, name, { type });
|
|
442
447
|
base = part.base;
|
|
443
448
|
}
|
|
449
|
+
|
|
444
450
|
let next = text === null ? null : lf(text).trim();
|
|
445
451
|
if (next === null) {
|
|
446
452
|
const start = part.exists
|
|
@@ -540,7 +546,8 @@ async function bundleMove(
|
|
|
540
546
|
const drafts = unrecorded.filter((f) => own.includes(f));
|
|
541
547
|
if (commit && loose.length)
|
|
542
548
|
throw new Error(
|
|
543
|
-
`${loose.join(', ')} holds changes not recorded yet: record the design first (gcf
|
|
549
|
+
`${loose.join(', ')} holds changes not recorded yet: record the design first (gcf ` +
|
|
550
|
+
`design commit)`,
|
|
544
551
|
);
|
|
545
552
|
let result = { applied: [], report: [] };
|
|
546
553
|
try {
|
|
@@ -628,7 +635,8 @@ async function commitUnlocked(projectDir, { message = null, commit = true } = {}
|
|
|
628
635
|
if (blocking.length) {
|
|
629
636
|
const first = blocking.slice(0, 3).map((i) => `${i.file}:${i.line} ${i.check} ${i.message}`);
|
|
630
637
|
throw new Error(
|
|
631
|
-
`the design check has ${blocking.length} blocking finding(s), fix them
|
|
638
|
+
`the design check has ${blocking.length} blocking finding(s), fix them ` +
|
|
639
|
+
`first:\n${first.join('\n')}`,
|
|
632
640
|
);
|
|
633
641
|
}
|
|
634
642
|
|
package/lib/domain.js
CHANGED
|
@@ -232,11 +232,35 @@ const ITEM_SPECS = {
|
|
|
232
232
|
],
|
|
233
233
|
rare: true,
|
|
234
234
|
},
|
|
235
|
+
// `text` goes on stdin, `add` as an argument: a board sends one field on stdin. `base`: the
|
|
236
|
+
// board fills it from the preview it showed, so a card edited meanwhile is not overwritten.
|
|
237
|
+
amend: {
|
|
238
|
+
label: 'amend',
|
|
239
|
+
help: "Fix the card's text: its next run reads it; its status stays",
|
|
240
|
+
args: ['gcf', 'item', 'amend', '{id}'],
|
|
241
|
+
fields: [
|
|
242
|
+
{ key: 'text', label: 'Blocks to replace', kind: 'longtext', stdin: true },
|
|
243
|
+
{ key: 'add', label: 'Lines to add to notes', kind: 'longtext', max: NOTE_MAX },
|
|
244
|
+
text('title', 'Title'),
|
|
245
|
+
text('from', 'Inbox entry it takes: erased'),
|
|
246
|
+
text('base', 'Read at', { hidden: true }),
|
|
247
|
+
],
|
|
248
|
+
rare: true,
|
|
249
|
+
propose: true,
|
|
250
|
+
// `--dry-run --json` says what it would change: a board shows that before the move.
|
|
251
|
+
preview: true,
|
|
252
|
+
// A human fixing a built card: the fix reaches its next run, not the code it has.
|
|
253
|
+
hint: {
|
|
254
|
+
status: ['awaiting-verdict', 'awaiting-decision', 'parked'],
|
|
255
|
+
text: 'Its code stays as built: the text changes what its next run reads.',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
235
258
|
attach: {
|
|
236
259
|
label: 'attach',
|
|
237
260
|
help: 'Give the item a file (a chat image, a reference): committed in its attachments',
|
|
238
261
|
args: ['gcf', 'item', 'attach', '{id}'],
|
|
239
|
-
// `file`: the board picks it on the operator's machine and sends its bytes; the core gets a
|
|
262
|
+
// `file`: the board picks it on the operator's machine and sends its bytes; the core gets a
|
|
263
|
+
// path.
|
|
240
264
|
fields: [{ key: 'file', label: 'File', kind: 'file', required: true }],
|
|
241
265
|
rare: true,
|
|
242
266
|
},
|
|
@@ -257,7 +281,9 @@ const RUN = {
|
|
|
257
281
|
// shows the proposal, the operator's click makes it.
|
|
258
282
|
const NEW_ITEM = {
|
|
259
283
|
label: 'create',
|
|
260
|
-
help:
|
|
284
|
+
help:
|
|
285
|
+
'A new work item, committed; its id comes from the title; the core refuses a type ' +
|
|
286
|
+
'the phase does not take',
|
|
261
287
|
args: ['gcf', 'item', 'new', '--commit'],
|
|
262
288
|
propose: true,
|
|
263
289
|
fields: [
|
|
@@ -332,7 +358,8 @@ const PART_FIELDS = [
|
|
|
332
358
|
];
|
|
333
359
|
|
|
334
360
|
// The design's moves (Board-PRD §5.24): a part saved from its form or as text, a session's
|
|
335
|
-
// files recorded, a designer's bundle brought back, a new unit, a draft discarded, a pillar
|
|
361
|
+
// files recorded, a designer's bundle brought back, a new unit, a draft discarded, a pillar
|
|
362
|
+
// retired, a unit dropped.
|
|
336
363
|
// Every save goes through the import's three-way check and the design check.
|
|
337
364
|
const DESIGN_SPECS = {
|
|
338
365
|
'design-save': {
|
|
@@ -494,7 +521,9 @@ const STARTS = {
|
|
|
494
521
|
// operator records it, edits it in the form, or discards it.
|
|
495
522
|
'draft-glossary': {
|
|
496
523
|
label: 'Draft with agent',
|
|
497
|
-
help:
|
|
524
|
+
help:
|
|
525
|
+
'A draft of the glossary from the vision and the units: you record it, edit or ' +
|
|
526
|
+
'discard it',
|
|
498
527
|
skill: 'gcf-vision',
|
|
499
528
|
say: 'Draft GLOSSARY.md from the vision and the design units. Write it, do not record it.',
|
|
500
529
|
edits: DESIGN_EDITS,
|
|
@@ -639,6 +668,8 @@ const BLOCK_SPECS = {
|
|
|
639
668
|
{ key: 'text', label: 'Text', kind: 'longtext', required: true },
|
|
640
669
|
CATEGORY('note'),
|
|
641
670
|
DETAIL,
|
|
671
|
+
// Goes with the entry; a board shows it beside the item's name.
|
|
672
|
+
text('item', 'The item it is about', { help: 'A live item, by its id' }),
|
|
642
673
|
],
|
|
643
674
|
propose: true,
|
|
644
675
|
},
|
|
@@ -808,7 +839,8 @@ const SECTIONS = {
|
|
|
808
839
|
// A move's `dirty` refusal: the board reads `gcf edits diff` and offers these.
|
|
809
840
|
edits: { commit: 'edits-commit', discard: 'edits-discard' },
|
|
810
841
|
// `gcf changes` reads what is uncommitted: the board's Changes screen and its header's marker.
|
|
811
|
-
changes
|
|
842
|
+
// `commit`: its `gcf changes commit` takes the operator's ticked files and message.
|
|
843
|
+
changes: { commit: true },
|
|
812
844
|
lessons: {},
|
|
813
845
|
playtest: {
|
|
814
846
|
// The inbox category a note from the playtest screen goes with.
|
|
@@ -854,6 +886,7 @@ const CHANGES = [
|
|
|
854
886
|
'design discard',
|
|
855
887
|
'edits commit',
|
|
856
888
|
'edits discard',
|
|
889
|
+
'changes commit',
|
|
857
890
|
'take',
|
|
858
891
|
'done',
|
|
859
892
|
'drop',
|
package/lib/git.js
CHANGED
|
@@ -23,9 +23,11 @@ export function inParts(specs) {
|
|
|
23
23
|
part = [];
|
|
24
24
|
n = 0;
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
part.push(s);
|
|
27
28
|
n += s.length + 1;
|
|
28
29
|
}
|
|
30
|
+
|
|
29
31
|
if (part.length) parts.push(part);
|
|
30
32
|
|
|
31
33
|
return parts;
|
|
@@ -169,11 +171,13 @@ export function restoreFromHead(projectDir, files) {
|
|
|
169
171
|
const r = git(...args);
|
|
170
172
|
if (r.status !== 0) throw new Error(`git ${args.join(' ')}: ${r.stderr.trim()}`);
|
|
171
173
|
};
|
|
174
|
+
|
|
172
175
|
for (const f of files) {
|
|
173
176
|
if (git('cat-file', '-e', `HEAD:./${f}`).status === 0) {
|
|
174
177
|
must('checkout', 'HEAD', '--', literal(projectDir, f));
|
|
175
178
|
continue;
|
|
176
179
|
}
|
|
180
|
+
|
|
177
181
|
must('rm', '--cached', '-q', '--ignore-unmatch', '--', literal(projectDir, f));
|
|
178
182
|
rmSync(path.join(projectDir, f), { force: true });
|
|
179
183
|
}
|
|
@@ -250,7 +254,8 @@ function commitRefusal(message, out) {
|
|
|
250
254
|
'gate',
|
|
251
255
|
{ problems },
|
|
252
256
|
`cannot record ${message}: the gate refuses ${problems.join('; ')}\n` +
|
|
253
|
-
'Nothing was committed. What it names has to change first (the agent can do it), then
|
|
257
|
+
'Nothing was committed. What it names has to change first (the agent can do it), then ' +
|
|
258
|
+
'try again.',
|
|
254
259
|
);
|
|
255
260
|
}
|
|
256
261
|
|
|
@@ -272,8 +277,20 @@ export function commitPaths(projectDir, message, paths, move = {}) {
|
|
|
272
277
|
// path commits the deletion. A file staged but never committed and now deleted matches
|
|
273
278
|
// nothing: no pathspec.
|
|
274
279
|
const real = paths.filter((p) => existsSync(p) || inHead(projectDir, p));
|
|
275
|
-
|
|
276
|
-
|
|
280
|
+
|
|
281
|
+
return commitOnly(projectDir, message, real, ['-m', message, ...moveTrailers(move)]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* `git commit --only` of `paths`, whatever they are, with `msg` its message arguments: the gate's
|
|
286
|
+
* refusals in the words of `message`. Returns the new HEAD.
|
|
287
|
+
* @param {string} projectDir
|
|
288
|
+
* @param {string} message
|
|
289
|
+
* @param {string[]} paths
|
|
290
|
+
* @param {string[]} msg
|
|
291
|
+
*/
|
|
292
|
+
export function commitOnly(projectDir, message, paths, msg) {
|
|
293
|
+
const only = paths.map((p) => literal(projectDir, p));
|
|
277
294
|
// A list past one command line goes on stdin (git 2.25+); a move's few paths as arguments.
|
|
278
295
|
const long = inParts(only).length > 1;
|
|
279
296
|
const res = spawnSync(
|
|
@@ -294,13 +311,14 @@ export function commitPaths(projectDir, message, paths, move = {}) {
|
|
|
294
311
|
// The gate reads the whole gcf/ tree: another file's edit stops the move, in the Operator's
|
|
295
312
|
// words. Its paths from git: the move's own staged files ride along and stop nothing.
|
|
296
313
|
if (res.status !== 0 && /gcf\/ has changes outside the index/.test(out)) {
|
|
297
|
-
const loose = dirtyGcf(projectDir,
|
|
314
|
+
const loose = dirtyGcf(projectDir, paths);
|
|
298
315
|
throw dirtyRefusal(
|
|
299
316
|
loose,
|
|
300
317
|
`cannot record ${message} while gcf/ holds uncommitted changes: ${loose.join(', ')} — ` +
|
|
301
318
|
'commit or discard them, then try again',
|
|
302
319
|
);
|
|
303
320
|
}
|
|
321
|
+
|
|
304
322
|
if (res.status !== 0) throw commitRefusal(message, out);
|
|
305
323
|
|
|
306
324
|
return spawnSync('git', ['rev-parse', 'HEAD'], {
|
|
@@ -329,6 +347,7 @@ export function snapshotIndex(cwd, files) {
|
|
|
329
347
|
if (res.status !== 0) return null;
|
|
330
348
|
stdout += res.stdout;
|
|
331
349
|
}
|
|
350
|
+
|
|
332
351
|
const prefix = spawnSync('git', ['rev-parse', '--show-prefix'], {
|
|
333
352
|
cwd,
|
|
334
353
|
encoding: 'utf8',
|
package/lib/id.js
CHANGED
package/lib/inbox-categories.js
CHANGED
|
@@ -159,6 +159,7 @@ export function mergeVocabulary(base, domain = [], project = []) {
|
|
|
159
159
|
if (!groups.has(r.group)) throw new Error(`inbox category ${r.id}: no group ${r.group}`);
|
|
160
160
|
seen.set(r.id, layer);
|
|
161
161
|
}
|
|
162
|
+
|
|
162
163
|
const rows = [
|
|
163
164
|
...base.map((r) => ({ ...r, layer: 'base' })),
|
|
164
165
|
...domain.map((r) => ({ ...r, layer: 'domain' })),
|
package/lib/inbox.js
CHANGED
|
@@ -91,6 +91,7 @@ export function fromOld({ source, tags = [], kind, item }) {
|
|
|
91
91
|
rest.shift();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
+
|
|
94
95
|
const lostLater = words.includes('later') && !laterOk ? ['later (never on its category)'] : [];
|
|
95
96
|
|
|
96
97
|
return {
|
|
@@ -341,7 +342,10 @@ export async function planCategory(
|
|
|
341
342
|
const actor = actorOrigin(by);
|
|
342
343
|
if (questionOnly(c) || !c.set_by.length)
|
|
343
344
|
throw new Error(
|
|
344
|
-
`no entry moves into ${c.id}:
|
|
345
|
+
`no entry moves into ${c.id}: ` +
|
|
346
|
+
(c.set_by.length
|
|
347
|
+
? 'it is an open question'
|
|
348
|
+
: 'it is for entries from before the categories'),
|
|
345
349
|
);
|
|
346
350
|
if (actor === 'agent' && !c.set_by.includes('agent'))
|
|
347
351
|
throw new Error(
|
|
@@ -419,6 +423,7 @@ export async function planTake(root, id, toDir) {
|
|
|
419
423
|
|
|
420
424
|
return {
|
|
421
425
|
entry,
|
|
426
|
+
pictures: moves.map((m) => m[1]),
|
|
422
427
|
files: [...drop.files, ...moves.map((m) => m[1])],
|
|
423
428
|
inputs: drop.files,
|
|
424
429
|
apply: async () => {
|