gcf-aif-ext 0.10.2 → 0.12.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 -4
- package/commands/gcf.js +140 -60
- package/extension.json +3 -2
- package/lib/agent-permissions.js +125 -20
- package/lib/audit-core.js +46 -6
- package/lib/board.js +6 -2
- package/lib/config-set.js +28 -2
- package/lib/context.js +24 -1
- package/lib/domain.js +81 -5
- package/lib/gcf-paths.js +26 -2
- package/lib/git.js +11 -2
- package/lib/inbox.js +265 -108
- package/lib/index-gen.js +7 -4
- package/lib/integrate.js +45 -8
- package/lib/lessons.js +31 -15
- package/lib/plan-check.js +22 -13
- package/lib/safe-path.js +2 -1
- package/lib/transitions.js +2 -0
- package/lib/unit-ops.js +1 -1
- package/lib/validate-item.js +7 -1
- package/lib/work-ops.js +141 -14
- package/package.json +1 -1
- package/skills/gcf-chat/SKILL.md +40 -0
- package/skills/gcf-triage/SKILL.md +10 -8
- package/templates/agents-block.md +12 -4
- package/templates/config.yml +7 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Game Context Framework as an [AI Factory](https://github.com/lee-to/ai-factory) extension: a documentary layer for building games with an AI agent, where the documents hold **state instead of history**.
|
|
4
4
|
|
|
5
|
-
A Design Model: the design lives in `gcf/design/<system>.md` as units with typed slots — what the GDD says, quoted and anchored, and `TBD` for everything it does not. Every piece of work — a mechanic, a bug, tech, an asset, a spike, a release — is a work item `gcf/work/<id>.md` with a `type` and a `gate`: who closes it, the human after play (`verdict`), a check (`auto`), or the human without a build (`decision`). A unit taken into work moves into its item with the same body; a soft unit collapses into its subsystem's document on a human playtest verdict and the item ceases to exist. `gcf/LIVE.md` is a short snapshot of what the game is now — capabilities and known issues. `gcf/inbox
|
|
5
|
+
A Design Model: the design lives in `gcf/design/<system>.md` as units with typed slots — what the GDD says, quoted and anchored, and `TBD` for everything it does not. Every piece of work — a mechanic, a bug, tech, an asset, a spike, a release — is a work item `gcf/work/<id>.md` with a `type` and a `gate`: who closes it, the human after play (`verdict`), a check (`auto`), or the human without a build (`decision`). A unit taken into work moves into its item with the same body; a soft unit collapses into its subsystem's document on a human playtest verdict and the item ceases to exist. `gcf/LIVE.md` is a short snapshot of what the game is now — capabilities and known issues. `gcf/inbox/` holds raw input waiting for triage, one file an entry. A history and a graveyard keep how each id ended and why things were killed. Read rules keep the token cost of a task flat as the project ages.
|
|
6
6
|
|
|
7
7
|
The methodology is [Methodology.md](https://github.com/VirtualMaestro/GCF/blob/main/docs/Methodology.md) (RU).
|
|
8
8
|
|
|
@@ -31,7 +31,7 @@ ai-factory gcf init # seeds gcf/, cnlp.config.json and .gitattributes
|
|
|
31
31
|
ai-factory gcf hooks-install # arms the pre-commit gate
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
`gcf init` is idempotent: it creates what is missing and overwrites nothing. Among what it seeds: `gcf/work/` for the work items, `gcf/inbox
|
|
34
|
+
`gcf init` is idempotent: it creates what is missing and overwrites nothing. Among what it seeds: `gcf/work/` for the work items, `gcf/inbox/` for raw input (one file an entry), `gcf/LIVE.md` for the project snapshot, `gcf/history.md` and `gcf/graveyard.md` — the two files that record how an id's life ended — and two lines in `.gitattributes` (`gcf/history.md merge=union`, `gcf/graveyard.md merge=union`) so that two branches appending different lines to those files never conflict there.
|
|
35
35
|
|
|
36
36
|
It then offers the optional [harness](../gcf-harness-aif-ext) — orchestration and a readset guard for **Claude Code only** — and on yes runs `ai-factory extension add gcf-harness-aif-ext` and `ai-factory gcf-harness init`. It asks only in a terminal and only when `.ai-factory.json` lists the Claude Code agent; an agent or CI run is never asked and installs nothing. `--harness` installs it without asking, `--no-harness` skips the question.
|
|
37
37
|
|
|
@@ -50,6 +50,25 @@ 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.12.0
|
|
54
|
+
|
|
55
|
+
Update together with gcf-harness-aif-ext 0.12.0 and gcf-board 0.6.0 (docs/Session-Engine.md).
|
|
56
|
+
- `submit` and `close` of an item with a plan refuse while the plan has unticked tasks: `<id>: plan tasks not ticked: N of M — tick what is done, or block the item`. The human passes it with `--unticked "<why>"`, which goes into the commit like `--unverified`. A feature and an item without a plan are not checked; `/gcf-run` ticks the tasks the run did itself (verify, review) before its commit. The integrator is held to it too: `gcf integrate` blocks a merged item whose plan has unticked tasks, with the reason.
|
|
57
|
+
- `item new --note=<text>` or `--note-file <path|->` writes what the item's run should know into its `note:`, up to 4000 characters; the board passes it on stdin.
|
|
58
|
+
- The board read adds `agent.rules` (every deny rule neutral, `{kind, pattern}`: `shell`, `read`, `edit`…), `domain.chat` (the project chat's skill and the commands it asks for) and `propose` on the `item-new` move. Own deny rules are taken in the neutral form (`shell: curl *`) or claude's (`Bash(curl *)`); `gcf permissions` lists them neutral. The `edit` kind denies MultiEdit and NotebookEdit too, not only Edit and Write.
|
|
59
|
+
- The new skill `gcf-chat`: the board's project chat. It answers from `gcf/` and the runs, proposes a new item with the board's MCP tool `propose_item_new` rather than making it, and makes a move only when the human approves its card. A thread bound to an item reads the item's file, plan, run log and run chat first. The AGENTS.md block says the same, and gives the exact form of an item's `live:` delta.
|
|
60
|
+
- `gcf context --readset` writes the readset manifest with its owner (the run's `GCF_RUN_OWNER` or the Claude Code session) and item: the guards act only on that session.
|
|
61
|
+
|
|
62
|
+
### 0.11.1
|
|
63
|
+
|
|
64
|
+
- The inbox is one file an entry: `gcf/inbox/in-<8 hex>.md` with frontmatter `source`, `at`, `tags` (a lesson also `kind`, `item`) and the text as markdown of any number of lines; its first non-empty line is the title. Pictures go by hand into `gcf/inbox/in-<id>/attachments/`, linked from the text. `inbox add` takes the text one way: an argument, `--text=`, or `--text-file <path|->` (`-` reads stdin; use it for several lines: from cmd.exe the `.cmd` shim cuts an argument at a newline). `gcf inbox` lists `in-x [source] <title> (+N lines) (tags: …)`; `--json` and the board read give `{id, source, at, title, text, tags[], kind?, item?, attachments?}`, sorted by `at`. `inbox tag`, `inbox drop` and `item new --from` refuse on a `work/` branch; `drop` deletes the entry with its pictures. `item new --from` without `--title` takes the entry's title and puts the rest, quoted (`> `), in a `note:` block (with another `--title` the whole text), and moves its pictures to `gcf/work/<id>/attachments/`. No `merge=union` any more: branches add different files, and `gcf integrate` merges an entry a `work/` branch added. The audit reports `inbox: {legacy, bad_names, untitled, broken_links, orphan_dirs}`. An old `gcf/inbox.md` is read by nothing: the audit and `gcf inbox` say so; move its lines with `inbox add` (or by hand) and delete it — there is no migration.
|
|
65
|
+
- `chat:` in `gcf/config.yml`: `ask` (`d1` by default, `all`, `none`: what a harness run's agent asks the operator by a question card) and `answer_timeout_min` (15; 0: nobody watches, the default answer goes at once). `gcf config set chat.ask --value=all` and `chat.answer_timeout_min` set them; `gcf board --json` carries `chat`, and a setting of kind `mode` its `options`. gcf-harness-aif-ext 0.11.1 reads them.
|
|
66
|
+
- `ai-factory gcf item attach <id> --file <path>` gives an item a file (a chat picture, a reference): copied into `gcf/work/<id>/attachments/` under its own name (`-2`, `-3`… on a clash) and committed alone, `gcf(attach): <id>`, also while the item runs, as long as `gcf/` has no uncommitted changes (a main-mode session edits the item file, and the commit gate then refuses; a worktree run sees the file only in its next run). A link, a file over 10 MB and a `work/` branch are refused. The board offers it as the item move **attach**; the AGENTS.md block tells agents to read an item's attachments.
|
|
67
|
+
|
|
68
|
+
### 0.10.3
|
|
69
|
+
|
|
70
|
+
- `gcf audit --json` says who works a running item: `running_by` is `run` (a harness run's lock), `you` (a session mark this session or its harness run owns), `unowned` (a mark that names nobody; a claim takes both), `session` (another session's mark), or null. Before, `running: true` alone left a `/gcf-run` on main to guess whether its own run's mark would refuse its claim.
|
|
71
|
+
|
|
53
72
|
### 0.10.2
|
|
54
73
|
|
|
55
74
|
- `gcf claim` is exclusive. The session mark names its owner: `GCF_RUN_OWNER` (a harness run sets it, its agent sessions inherit it), else the Claude Code session's `CLAUDE_CODE_SESSION_ID`. While the mark is fresh, a claim by another owner, or by none, is refused, and so is a `--claimed` move from another owner. A mark that names nobody (written before 0.10.2, or claimed from a console with neither id), a stale one, or one of a harness run whose process is gone holds nobody. Only the owner's own commands on the item keep its mark fresh (a fresh mark that names nobody, any session's), and only the named owner revives a stale one. `gcf release` stays the human's way out, also for a session whose id changed (`/clear`). Update together with gcf-harness-aif-ext 0.9.10: an older harness started from inside a Claude Code session would claim under that session's id, and its own agent would be refused.
|
|
@@ -221,12 +240,12 @@ Removal leaves `gcf/` and `cnlp.config.json` in place. It also leaves the pre-co
|
|
|
221
240
|
|
|
222
241
|
## What it adds
|
|
223
242
|
|
|
224
|
-
**Skills** — `gcf-init`, `gcf-adopt`, `gcf-card` (put work into `gcf/work/`: take units, group them under a feature, or create a non-design item), `gcf-verdict` (verdicts and decisions), `gcf-triage` (inbox entries into items, tunes, units or nothing, with the human approving each), `gcf-audit`, `gcf-vision`, `gcf-debate`, `gcf-ingest`.
|
|
243
|
+
**Skills** — `gcf-init`, `gcf-adopt`, `gcf-chat` (the board's project chat: answers, proposes new items, makes the moves the human approves), `gcf-card` (put work into `gcf/work/`: take units, group them under a feature, or create a non-design item), `gcf-verdict` (verdicts and decisions), `gcf-triage` (inbox entries into items, tunes, units or nothing, with the human approving each), `gcf-audit`, `gcf-vision`, `gcf-debate`, `gcf-ingest`.
|
|
225
244
|
|
|
226
245
|
**A deterministic core** behind `ai-factory gcf …`:
|
|
227
246
|
|
|
228
247
|
- work items — `take <ids...> [--feature <id>]`, `item new <id> --type <type>`, `submit`, `close`, `verdict <id> keep|tune|kill`, `decide <id> go|no|wontfix|known|close|continue|kill`, `block`, `unblock`, `drop`, `done`, `where`
|
|
229
|
-
- inbox and snapshot — `inbox [add <text> | drop <in-id>]`, `live`, `live check`
|
|
248
|
+
- inbox and snapshot — `inbox [add <text> | add --text-file <path|-> | tag <in-id> | drop <in-id>]`, `live`, `live check`
|
|
230
249
|
- runs and play — `context`, `plan check <id>`, `verify <id>`, `playtest`, `playtest session [--build]`, `audit`
|
|
231
250
|
- project phase and board — `phase`, `phase next [--reason]`, `board [--json]` (everything a board shows, in one read)
|
|
232
251
|
- 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`
|
package/commands/gcf.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// CLI wrapper over the deterministic core (GCF-PRD §10.1): harness and human call
|
|
2
2
|
// the same functions. Registered by AIF via extension.json `commands`.
|
|
3
3
|
import { mkdir, copyFile, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { existsSync } from 'node:fs';
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -24,6 +24,7 @@ const verifiedMove = (o) => ({
|
|
|
24
24
|
commit: o.commit,
|
|
25
25
|
requireVerify: true,
|
|
26
26
|
unverified: o.unverified === undefined ? undefined : reasonOf(o.unverified),
|
|
27
|
+
unticked: o.unticked === undefined ? undefined : reasonOf(o.unticked),
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
/** The reason of `--unverified`, one line in the commit's subject; an empty one is no reason. */
|
|
@@ -36,6 +37,8 @@ function reasonOf(text) {
|
|
|
36
37
|
|
|
37
38
|
const UNVERIFIED =
|
|
38
39
|
'move without a green gcf verify of the code as it is now; the reason goes into the commit';
|
|
40
|
+
const UNTICKED =
|
|
41
|
+
"move with plan tasks left unticked (the human's call); the reason goes into the commit";
|
|
39
42
|
|
|
40
43
|
/** `--claimed`: this move comes from the session that holds the item's mark. */
|
|
41
44
|
const claimedBy = (o, id) => {
|
|
@@ -124,13 +127,12 @@ const today = () => new Date().toISOString().slice(0, 10);
|
|
|
124
127
|
const UNION = [
|
|
125
128
|
'gcf/history.md merge=union',
|
|
126
129
|
'gcf/graveyard.md merge=union',
|
|
127
|
-
'gcf/inbox.md merge=union',
|
|
128
130
|
'gcf/.metrics/*.csv merge=union',
|
|
129
131
|
];
|
|
130
132
|
|
|
131
133
|
/**
|
|
132
|
-
* Two branches that end different lives may add their lines at the same spot of history.md
|
|
133
|
-
* graveyard.md
|
|
134
|
+
* Two branches that end different lives may add their lines at the same spot of history.md or
|
|
135
|
+
* graveyard.md: a union merge keeps both instead of a conflict whose "ours" loses
|
|
134
136
|
* one. Adds the missing rules to `<dir>/.gitattributes`; a project that ran an older init gets
|
|
135
137
|
* them on re-run.
|
|
136
138
|
*/
|
|
@@ -144,7 +146,7 @@ export async function unionAttributes(dir) {
|
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
async function seedSkeleton(root) {
|
|
147
|
-
for (const dir of ['design', 'work', 'systems', 'source', '.metrics']) {
|
|
149
|
+
for (const dir of ['design', 'work', 'systems', 'source', 'inbox', '.metrics']) {
|
|
148
150
|
await mkdir(path.join(root, dir), { recursive: true });
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -160,12 +162,10 @@ async function seedSkeleton(root) {
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
const { HISTORY_HEAD, GRAVEYARD_HEAD } = await lib('verdict-fs');
|
|
163
|
-
const { INBOX_HEAD } = await lib('inbox');
|
|
164
165
|
const { serializeLive } = await lib('live');
|
|
165
166
|
for (const [name, header] of [
|
|
166
167
|
['history.md', HISTORY_HEAD],
|
|
167
168
|
['graveyard.md', GRAVEYARD_HEAD],
|
|
168
|
-
['inbox.md', INBOX_HEAD],
|
|
169
169
|
['LIVE.md', serializeLive({ capabilities: [], knownIssues: [] })],
|
|
170
170
|
[
|
|
171
171
|
'open-questions.md',
|
|
@@ -245,10 +245,15 @@ function registerContext(gcf) {
|
|
|
245
245
|
.command('context <item-id>')
|
|
246
246
|
.description('Assemble the readset for a work item (GCF-PRD §9.1)')
|
|
247
247
|
.option('--json', 'machine output')
|
|
248
|
+
.option(
|
|
249
|
+
'--readset',
|
|
250
|
+
"write .gcf-session/readset.json, the readset guard's manifest, for this session",
|
|
251
|
+
)
|
|
248
252
|
.action(async (itemId, opts) => {
|
|
249
253
|
await touchSession(itemId);
|
|
250
|
-
const { buildContext } = await lib('context');
|
|
254
|
+
const { buildContext, writeReadset } = await lib('context');
|
|
251
255
|
const ctx = await buildContext(process.cwd(), itemId);
|
|
256
|
+
if (opts.readset) await writeReadset(process.cwd(), ctx);
|
|
252
257
|
// Metric 1 (GCF-PRD §14): readset size over time, one csv line per call.
|
|
253
258
|
const { appendFile, mkdir } = await import('node:fs/promises');
|
|
254
259
|
const metricsDir = path.join(process.cwd(), 'gcf', '.metrics');
|
|
@@ -704,8 +709,12 @@ function registerItem(gcf) {
|
|
|
704
709
|
.option('--priority <rank>', 'its rank: 1, 2, 3… (lower runs sooner)')
|
|
705
710
|
.option('--model <name>', 'the model its run uses, e.g. opus')
|
|
706
711
|
.option('--effort <level>', 'the effort its run uses, e.g. high')
|
|
712
|
+
.option('--note <text>', "what its run should know: the item's note:, up to 4000 characters")
|
|
713
|
+
.option('--note-file <path>', 'the note from a file, - for stdin: several lines')
|
|
707
714
|
.option('--commit', 'commit it (gcf(item)): for a caller with no console, e.g. a board')
|
|
708
715
|
.action(async (id, o) => {
|
|
716
|
+
if (o.note !== undefined && o.noteFile !== undefined)
|
|
717
|
+
throw new Error('give the note once: --note=<text> or --note-file <path|->');
|
|
709
718
|
const { newItem } = await lib('work-ops');
|
|
710
719
|
const r = await newItem(process.cwd(), {
|
|
711
720
|
id,
|
|
@@ -724,11 +733,27 @@ function registerItem(gcf) {
|
|
|
724
733
|
channel: o.channel,
|
|
725
734
|
model: o.model,
|
|
726
735
|
effort: o.effort,
|
|
736
|
+
note: o.noteFile === undefined ? o.note : readTextFile(o.noteFile),
|
|
727
737
|
priority: o.priority === undefined ? undefined : Number(o.priority),
|
|
728
738
|
commit: o.commit === true,
|
|
729
739
|
});
|
|
730
740
|
console.log(`${r.item}${shortHash(r.hash)}`);
|
|
731
741
|
});
|
|
742
|
+
registerAttach(item);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function registerAttach(item) {
|
|
746
|
+
item
|
|
747
|
+
.command('attach <id>')
|
|
748
|
+
.description('Give an item a file: copied into gcf/work/<id>/attachments/ (commit)')
|
|
749
|
+
.requiredOption('--file <path>', 'the file, e.g. a chat image')
|
|
750
|
+
.option('--no-commit', 'skip the commit (tests only)')
|
|
751
|
+
.action(async (id, o) => {
|
|
752
|
+
const r = await (
|
|
753
|
+
await lib('work-ops')
|
|
754
|
+
).attachItem(process.cwd(), id, o.file, { commit: o.commit });
|
|
755
|
+
console.log(`${r.file}${shortHash(r.hash)}`);
|
|
756
|
+
});
|
|
732
757
|
}
|
|
733
758
|
|
|
734
759
|
function registerDepends(gcf) {
|
|
@@ -781,6 +806,7 @@ function registerItemMoves(gcf) {
|
|
|
781
806
|
.description('ready → awaiting-verdict / awaiting-decision (commit gcf(submit))')
|
|
782
807
|
.option('--claimed', CLAIMED)
|
|
783
808
|
.option('--unverified <why>', UNVERIFIED)
|
|
809
|
+
.option('--unticked <why>', UNTICKED)
|
|
784
810
|
.option('--no-commit', 'skip the commit (tests only)')
|
|
785
811
|
.action(async (id, o) => {
|
|
786
812
|
claimedBy(o, id);
|
|
@@ -798,6 +824,7 @@ function registerItemMoves(gcf) {
|
|
|
798
824
|
)
|
|
799
825
|
.option('--claimed', CLAIMED)
|
|
800
826
|
.option('--unverified <why>', UNVERIFIED)
|
|
827
|
+
.option('--unticked <why>', UNTICKED)
|
|
801
828
|
.option('--no-commit', 'skip the commit (tests only)')
|
|
802
829
|
.action(async (id, o) => {
|
|
803
830
|
claimedBy(o, id);
|
|
@@ -854,35 +881,41 @@ function registerDecide(gcf) {
|
|
|
854
881
|
}
|
|
855
882
|
|
|
856
883
|
/**
|
|
857
|
-
* An inbox
|
|
858
|
-
* commit
|
|
884
|
+
* An inbox move (`plan`: its files, the ones that may carry edits not yet committed, and how to
|
|
885
|
+
* make it); with `commit`, committed alone under the main lock — a board has no console to
|
|
886
|
+
* commit from. Entries added before without a commit ride along with it. Returns the commit
|
|
887
|
+
* hash, or null.
|
|
859
888
|
* @param {boolean | undefined} commit
|
|
860
889
|
* @param {string} message
|
|
861
|
-
* @param {
|
|
890
|
+
* @param {{files: string[], inputs?: string[], apply: () => Promise<unknown>}} plan
|
|
862
891
|
*/
|
|
863
|
-
async function inboxMove(commit, message,
|
|
864
|
-
const { gcfRoot } = await lib('gcf-paths');
|
|
865
|
-
const root = gcfRoot();
|
|
892
|
+
async function inboxMove(commit, message, plan) {
|
|
866
893
|
if (!commit) {
|
|
867
|
-
await
|
|
894
|
+
await plan.apply();
|
|
868
895
|
|
|
869
896
|
return null;
|
|
870
897
|
}
|
|
871
898
|
|
|
872
899
|
const { commitMove } = await lib('unit-ops');
|
|
873
|
-
const
|
|
900
|
+
const loose = (await lib('inbox')).untrackedEntries(process.cwd());
|
|
874
901
|
|
|
875
|
-
// Raw input (merge=union): lines added before without a commit ride along with this one.
|
|
876
902
|
return commitMove(process.cwd(), message, {
|
|
877
|
-
files: [
|
|
878
|
-
inputs: [
|
|
903
|
+
files: [...plan.files, ...loose],
|
|
904
|
+
inputs: [...(plan.inputs ?? plan.files), ...loose],
|
|
879
905
|
mutate: async () => {
|
|
880
|
-
await
|
|
906
|
+
await plan.apply();
|
|
881
907
|
},
|
|
882
908
|
commit: true,
|
|
883
909
|
});
|
|
884
910
|
}
|
|
885
911
|
|
|
912
|
+
/** A work/ branch's gcf/ state is main's: an inbox entry is tagged or erased on main. */
|
|
913
|
+
async function refuseOnWork(what) {
|
|
914
|
+
const { onWorkBranch } = await lib('unit-ops');
|
|
915
|
+
if (onWorkBranch(process.cwd()))
|
|
916
|
+
throw new Error(`${what} on main: a work/ branch records no inbox move`);
|
|
917
|
+
}
|
|
918
|
+
|
|
886
919
|
function registerInboxTag(inbox) {
|
|
887
920
|
inbox
|
|
888
921
|
.command('tag <in-id>')
|
|
@@ -891,34 +924,84 @@ function registerInboxTag(inbox) {
|
|
|
891
924
|
.option('--remove <tags>', 'tags to remove, comma-separated')
|
|
892
925
|
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
893
926
|
.action(async (id, o) => {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
}));
|
|
927
|
+
await refuseOnWork('tag an entry');
|
|
928
|
+
const { planTag } = await lib('inbox');
|
|
929
|
+
const { gcfRoot } = await lib('gcf-paths');
|
|
930
|
+
const plan = await planTag(gcfRoot(), id, {
|
|
931
|
+
add: splitList(o.add),
|
|
932
|
+
remove: splitList(o.remove),
|
|
901
933
|
});
|
|
902
|
-
|
|
934
|
+
const hash = await inboxMove(o.commit, `gcf(inbox): tag ${id}`, plan);
|
|
935
|
+
console.log(`${id} tags: ${plan.tags.join(', ') || 'none'}${shortHash(hash)}`);
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/** The text of `inbox add`: its argument, `--text`, or `--text-file` (`-`: stdin), one of them. */
|
|
940
|
+
function entryText(arg, o) {
|
|
941
|
+
const given = [arg, o.text, o.textFile].filter((x) => x !== undefined);
|
|
942
|
+
if (given.length !== 1)
|
|
943
|
+
throw new Error('give the entry once: as the argument, --text=<text> or --text-file <path|->');
|
|
944
|
+
if (o.textFile === undefined) return given[0];
|
|
945
|
+
|
|
946
|
+
return readTextFile(o.textFile);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/** A text file's text, `-` for stdin. */
|
|
950
|
+
function readTextFile(file) {
|
|
951
|
+
const text = readFileSync(file === '-' ? 0 : file, 'utf8');
|
|
952
|
+
|
|
953
|
+
// A file Notepad saved starts with a byte-order mark.
|
|
954
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
function registerInboxDrop(inbox) {
|
|
958
|
+
inbox
|
|
959
|
+
.command('drop <in-id>')
|
|
960
|
+
.description('Erase an entry: triaged as noise, a duplicate, or turned into an item')
|
|
961
|
+
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
962
|
+
.action(async (id, o) => {
|
|
963
|
+
await refuseOnWork('erase an entry');
|
|
964
|
+
const { planDrop } = await lib('inbox');
|
|
965
|
+
const { gcfRoot } = await lib('gcf-paths');
|
|
966
|
+
const plan = await planDrop(gcfRoot(), id);
|
|
967
|
+
const { inHead } = await lib('git');
|
|
968
|
+
const committed = inHead(process.cwd(), plan.files[0]);
|
|
969
|
+
// An entry never committed leaves nothing to commit: it is only erased, from the index too.
|
|
970
|
+
const hash = await inboxMove(o.commit && committed, `gcf(inbox): drop ${id}`, plan);
|
|
971
|
+
if (!committed)
|
|
972
|
+
spawnSync('git', ['rm', '--cached', '-q', '--ignore-unmatch', '--', ...plan.files], {
|
|
973
|
+
cwd: process.cwd(),
|
|
974
|
+
stdio: 'ignore',
|
|
975
|
+
});
|
|
976
|
+
console.log(`erased ${id}${shortHash(hash)}`);
|
|
903
977
|
});
|
|
904
978
|
}
|
|
905
979
|
|
|
906
980
|
function registerInbox(gcf) {
|
|
907
981
|
const inbox = gcf
|
|
908
982
|
.command('inbox')
|
|
909
|
-
.description('Raw input waiting for triage (gcf/inbox
|
|
983
|
+
.description('Raw input waiting for triage (gcf/inbox/, one file an entry); no commit')
|
|
910
984
|
.option('--json', 'machine output')
|
|
911
985
|
.action(async (o) => {
|
|
912
986
|
const { gcfRoot } = await lib('gcf-paths');
|
|
913
|
-
const
|
|
987
|
+
const { legacyInbox, listInbox } = await lib('inbox');
|
|
988
|
+
const root = gcfRoot();
|
|
989
|
+
if (legacyInbox(root))
|
|
990
|
+
console.error(
|
|
991
|
+
'gcf/inbox.md is the old one-line inbox: the core reads gcf/inbox/ only — move its ' +
|
|
992
|
+
"lines with ai-factory gcf inbox add (the operator's call), then delete it",
|
|
993
|
+
);
|
|
994
|
+
const list = await listInbox(root);
|
|
914
995
|
out(o.json, list, (l) =>
|
|
915
996
|
l.length
|
|
916
997
|
? l
|
|
917
998
|
.map((e) => {
|
|
918
999
|
const source = e.kind ? `lesson:${e.kind}:${e.item}` : e.source;
|
|
1000
|
+
const more = e.text.split('\n').length - 1;
|
|
1001
|
+
const lines = more ? ` (+${more} lines)` : '';
|
|
919
1002
|
const tags = e.tags.length ? ` (tags: ${e.tags.join(', ')})` : '';
|
|
920
1003
|
|
|
921
|
-
return `${e.id} [${source}] ${e.
|
|
1004
|
+
return `${e.id} [${source}] ${e.title}${lines}${tags}`;
|
|
922
1005
|
})
|
|
923
1006
|
.join('\n')
|
|
924
1007
|
: 'inbox empty',
|
|
@@ -926,36 +1009,24 @@ function registerInbox(gcf) {
|
|
|
926
1009
|
});
|
|
927
1010
|
inbox
|
|
928
1011
|
.command('add [text]')
|
|
929
|
-
.description('
|
|
1012
|
+
.description('Add an entry: gcf/inbox/in-<id>.md; its first line is its title')
|
|
930
1013
|
.option('--source <source>', 'playtest | ci | agent | operator', 'operator')
|
|
931
1014
|
// A text that starts with a hyphen ("-5 fps on level 3") reads as a flag at every level of
|
|
932
1015
|
// ai-factory's commands, `--` included: as `--text=<text>` it stays one value.
|
|
933
1016
|
.option('--text <text>', 'the entry, when it starts with a hyphen')
|
|
1017
|
+
.option('--text-file <path>', 'the entry from a file, - for stdin: several lines')
|
|
934
1018
|
.option('--tags <tags>', 'its tags, comma-separated: idea, later, ui:hud')
|
|
935
1019
|
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
936
1020
|
.action(async (arg, o) => {
|
|
937
|
-
const text = o
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
id = (await addInbox(root, text, o.source, { tags: splitList(o.tags) })).id;
|
|
944
|
-
});
|
|
945
|
-
console.log(`${id}${shortHash(hash)}`);
|
|
1021
|
+
const text = entryText(arg, o);
|
|
1022
|
+
const { planAdd } = await lib('inbox');
|
|
1023
|
+
const { gcfRoot } = await lib('gcf-paths');
|
|
1024
|
+
const plan = planAdd(gcfRoot(), text, o.source, { tags: splitList(o.tags) });
|
|
1025
|
+
const hash = await inboxMove(o.commit, 'gcf(inbox): add', plan);
|
|
1026
|
+
console.log(`${plan.entry.id}${shortHash(hash)}`);
|
|
946
1027
|
});
|
|
947
1028
|
registerInboxTag(inbox);
|
|
948
|
-
inbox
|
|
949
|
-
.command('drop <in-id>')
|
|
950
|
-
.description('Erase an entry: triaged as noise, a duplicate, or turned into an item')
|
|
951
|
-
.option('--commit', 'commit it (gcf(inbox)): for a caller with no console, e.g. a board')
|
|
952
|
-
.action(async (id, o) => {
|
|
953
|
-
const { dropInbox } = await lib('inbox');
|
|
954
|
-
const hash = await inboxMove(o.commit, `gcf(inbox): drop ${id}`, (root) =>
|
|
955
|
-
dropInbox(root, id),
|
|
956
|
-
);
|
|
957
|
-
console.log(`erased ${id}${shortHash(hash)}`);
|
|
958
|
-
});
|
|
1029
|
+
registerInboxDrop(inbox);
|
|
959
1030
|
}
|
|
960
1031
|
|
|
961
1032
|
function registerLessons(gcf) {
|
|
@@ -981,7 +1052,7 @@ function registerLessons(gcf) {
|
|
|
981
1052
|
.option('--from <file>', 'a JSON array [{kind, text, where}] instead of --kind/--text')
|
|
982
1053
|
.option('--commit', 'commit it (gcf(lessons)): for a caller with no console, e.g. the harness')
|
|
983
1054
|
.action(async (id, o) => {
|
|
984
|
-
const {
|
|
1055
|
+
const { planLessons, lessonsFile, KINDS } = await lib('lessons');
|
|
985
1056
|
if (Boolean(o.from) === Boolean(o.text))
|
|
986
1057
|
throw new Error('give the lessons once: --from <file>, or --kind and --text');
|
|
987
1058
|
if (o.text && !KINDS.includes(o.kind)) throw new Error(`--kind must be ${KINDS.join(' | ')}`);
|
|
@@ -990,11 +1061,10 @@ function registerLessons(gcf) {
|
|
|
990
1061
|
: [{ kind: o.kind, text: o.text, where: o.where }];
|
|
991
1062
|
if (!Array.isArray(list)) throw new Error(`${o.from}: lessons must be a JSON array`);
|
|
992
1063
|
if (!list.length) return console.log(`recorded 0 lessons for ${id}`);
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
});
|
|
997
|
-
console.log(`recorded ${n} lessons for ${id}${shortHash(hash)}`);
|
|
1064
|
+
const { gcfRoot } = await lib('gcf-paths');
|
|
1065
|
+
const plan = planLessons(gcfRoot(), id, list);
|
|
1066
|
+
const hash = await inboxMove(o.commit, `gcf(lessons): ${id}`, plan);
|
|
1067
|
+
console.log(`recorded ${plan.entries.length} lessons for ${id}${shortHash(hash)}`);
|
|
998
1068
|
});
|
|
999
1069
|
}
|
|
1000
1070
|
|
|
@@ -1163,13 +1233,22 @@ function registerSettings(gcf) {
|
|
|
1163
1233
|
: '';
|
|
1164
1234
|
console.log(r.unchanged ? `${now} (unchanged)` : `${now}${shortHash(r.hash)}${note}`);
|
|
1165
1235
|
});
|
|
1236
|
+
registerPermissions(gcf);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
/** `gcf permissions`: the deny groups and custom rules of agent runs. */
|
|
1240
|
+
function registerPermissions(gcf) {
|
|
1166
1241
|
const many = (v, prev = []) => [...prev, v];
|
|
1167
1242
|
gcf
|
|
1168
1243
|
.command('permissions')
|
|
1169
1244
|
.description("What agent runs may not do: deny groups and custom rules (the human's; commit)")
|
|
1170
1245
|
.option('--on <group>', 'turn a deny group on (repeatable)', many)
|
|
1171
1246
|
.option('--off <group>', 'turn a deny group off (repeatable)', many)
|
|
1172
|
-
.option(
|
|
1247
|
+
.option(
|
|
1248
|
+
'--deny <rule>',
|
|
1249
|
+
'add a custom deny rule, like "shell: cmd*" or Bash(cmd*) (repeatable)',
|
|
1250
|
+
many,
|
|
1251
|
+
)
|
|
1173
1252
|
.option('--undeny <rule>', 'remove a custom deny rule (repeatable)', many)
|
|
1174
1253
|
.option('--json', 'machine output')
|
|
1175
1254
|
.option('--no-commit', 'skip the commit (tests only)')
|
|
@@ -1183,7 +1262,8 @@ function registerSettings(gcf) {
|
|
|
1183
1262
|
out(o.json, r, (x) =>
|
|
1184
1263
|
[
|
|
1185
1264
|
...x.groups.map((g) => `${g.on ? '[x]' : '[ ]'} ${g.id}: ${g.label}`),
|
|
1186
|
-
|
|
1265
|
+
// The neutral form (AD-4): `deny: shell: curl *`, whichever way the line is written.
|
|
1266
|
+
...x.deny_extra.map((d) => `deny: ${perms.ruleText(perms.parseRule(d))}`),
|
|
1187
1267
|
...(x.hash ? [`committed${shortHash(x.hash)}`] : []),
|
|
1188
1268
|
].join('\n'),
|
|
1189
1269
|
);
|
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.12.0",
|
|
5
5
|
"description": "Game Context Framework for AI Factory",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/gcf-init",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"skills/gcf-audit",
|
|
13
13
|
"skills/gcf-vision",
|
|
14
14
|
"skills/gcf-debate",
|
|
15
|
-
"skills/gcf-ingest"
|
|
15
|
+
"skills/gcf-ingest",
|
|
16
|
+
"skills/gcf-chat"
|
|
16
17
|
],
|
|
17
18
|
"commands": [
|
|
18
19
|
{
|