gcf-aif-ext 0.12.1 → 0.12.3

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 CHANGED
@@ -63,6 +63,7 @@ Update together with gcf-harness-aif-ext 0.12.0 and gcf-board 0.6.0 (docs/Sessio
63
63
 
64
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
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 agent <id> --model <m> --effort <e>` sets the model and effort of an item's runs (`default` takes one off: the agent picks); refused while a run drives the item, committed `gcf(item)`; the item's next run takes them. The board offers it as the item move **model / effort**, and as **change** beside those fields.
66
67
  - `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
 
68
69
  ### 0.10.3
package/commands/gcf.js CHANGED
@@ -707,8 +707,8 @@ function registerItem(gcf) {
707
707
  .option('--release <version>', 'a release: the version it ships')
708
708
  .option('--channel <name>', 'a release: where it ships, e.g. steam')
709
709
  .option('--priority <rank>', 'its rank: 1, 2, 3… (lower runs sooner)')
710
- .option('--model <name>', 'the model its run uses, e.g. opus')
711
- .option('--effort <level>', 'the effort its run uses, e.g. high')
710
+ .option('--model <name>', 'the model its run uses, e.g. opus (default: the agent picks)')
711
+ .option('--effort <level>', 'the effort its run uses, e.g. high (default: the agent picks)')
712
712
  .option('--note <text>', "what its run should know: the item's note:, up to 4000 characters")
713
713
  .option('--note-file <path>', 'the note from a file, - for stdin: several lines')
714
714
  .option('--commit', 'commit it (gcf(item)): for a caller with no console, e.g. a board')
@@ -740,6 +740,25 @@ function registerItem(gcf) {
740
740
  console.log(`${r.item}${shortHash(r.hash)}`);
741
741
  });
742
742
  registerAttach(item);
743
+ registerAgent(item);
744
+ }
745
+
746
+ function registerAgent(item) {
747
+ item
748
+ .command('agent <id>')
749
+ .description("Set the model and effort of an item's runs: from its next run (commit)")
750
+ .option('--model <name>', 'e.g. opus; default takes the field off: the agent picks')
751
+ .option('--effort <level>', 'e.g. high; default takes the field off: the agent picks')
752
+ .option('--no-commit', 'skip the commit (tests only)')
753
+ .action(async (id, o) => {
754
+ const r = await (
755
+ await lib('work-ops')
756
+ ).setAgent(process.cwd(), id, { model: o.model, effort: o.effort, commit: o.commit });
757
+ const shown = (v) => v ?? 'default';
758
+ console.log(
759
+ `${id} runs on model ${shown(r.model)}, effort ${shown(r.effort)}${shortHash(r.hash)}`,
760
+ );
761
+ });
743
762
  }
744
763
 
745
764
  function registerAttach(item) {
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.12.1",
4
+ "version": "0.12.3",
5
5
  "description": "Game Context Framework for AI Factory",
6
6
  "skills": [
7
7
  "skills/gcf-init",
package/lib/domain.js CHANGED
@@ -69,6 +69,11 @@ const decide = (choice, help, fields = [], danger) => ({
69
69
  ...(danger && { danger }),
70
70
  });
71
71
  const text = (key, label, extra = {}) => ({ key, label, kind: 'text', ...extra });
72
+ // How an item's run goes: a board offers its agent's presets (`presets`), and `default`, which
73
+ // leaves the choice to the agent; a word of the operator's own goes too.
74
+ const PICKS = 'default: the agent picks';
75
+ const MODEL = text('model', 'Model of its run', { presets: 'model', help: PICKS });
76
+ const EFFORT = text('effort', 'Effort of its run', { presets: 'effort', help: PICKS });
72
77
 
73
78
  // An item's moves (§4.1), offered by `items[].moves`.
74
79
  const ITEM_SPECS = {
@@ -160,6 +165,13 @@ const ITEM_SPECS = {
160
165
  ],
161
166
  rare: true,
162
167
  },
168
+ agent: {
169
+ label: 'model / effort',
170
+ help: 'The model and effort of its runs: the next run takes them',
171
+ args: ['gcf', 'item', 'agent', '{id}'],
172
+ fields: [MODEL, EFFORT],
173
+ rare: true,
174
+ },
163
175
  attach: {
164
176
  label: 'attach',
165
177
  help: 'Give the item a file (a chat image, a reference): committed in its attachments',
@@ -226,8 +238,8 @@ const NEW_ITEM = {
226
238
  text('parent', 'Parent feature id'),
227
239
  text('milestone', 'Milestone'),
228
240
  text('blocked', 'Start blocked: why (e.g. "file needed")'),
229
- text('model', 'Model of its run (e.g. opus)'),
230
- text('effort', 'Effort of its run (e.g. high)'),
241
+ MODEL,
242
+ EFFORT,
231
243
  // A board passes it on stdin (`stdin`: `--note-file -`, AD-39).
232
244
  {
233
245
  key: 'note',
@@ -313,8 +325,9 @@ const FIELDS = [
313
325
  badge: true,
314
326
  },
315
327
  { key: 'severity', label: 'severity', kind: 'text', card: true, badge: true },
316
- { key: 'model', label: 'model', kind: 'text', card: true },
317
- { key: 'effort', label: 'effort', kind: 'text' },
328
+ // `edit`: the move that changes it, from the drawer.
329
+ { key: 'model', label: 'model', kind: 'text', card: true, edit: 'agent' },
330
+ { key: 'effort', label: 'effort', kind: 'text', edit: 'agent' },
318
331
  { key: 'tune_count', label: 'tune', kind: 'text', help: 'Tune verdicts so far', card: true },
319
332
  {
320
333
  key: 'waits_for',
package/lib/integrate.js CHANGED
@@ -39,6 +39,14 @@ export async function excludeSession(projectDir) {
39
39
 
40
40
  const METRICS = ':(exclude)gcf/.metrics';
41
41
 
42
+ /** A worktree's own audit and context lines in gcf/.metrics are no work to keep: dropped. */
43
+ function dropLogs(dir) {
44
+ // Staged ones too: checkout restores from the index.
45
+ git(dir, ['reset', '-q', '--', 'gcf/.metrics'], { check: false });
46
+ git(dir, ['checkout', '--', 'gcf/.metrics'], { check: false });
47
+ git(dir, ['clean', '-fdq', '--', 'gcf/.metrics'], { check: false });
48
+ }
49
+
42
50
  /**
43
51
  * A merge stopped on gcf/INDEX.md alone: both sides counted something (an inbox entry a branch
44
52
  * added, a move on main). The index is generated, so it is written again and the merge goes on,
@@ -69,6 +77,8 @@ async function mergedPastIndex(dir) {
69
77
  async function syncWithMain(projectDir, dir) {
70
78
  const main = git(projectDir, ['rev-parse', '--abbrev-ref', 'HEAD']).out;
71
79
  if (main === 'HEAD' || main.startsWith('work/')) return {};
80
+ // An earlier run's lines in the worktree's logs would stop main's newer logs merging in.
81
+ dropLogs(dir);
72
82
  const res = git(dir, ['merge', '--no-edit', '-m', `gcf(sync): ${main}`, main], { check: false });
73
83
  if (res.ok || (await mergedPastIndex(dir))) return {};
74
84
  if (git(dir, ['rev-parse', '-q', '--verify', 'MERGE_HEAD'], { check: false }).ok)
@@ -151,9 +161,7 @@ function cleanUp(projectDir, id, { force = false } = {}) {
151
161
  const notes = [];
152
162
  const dir = worktreeOf(projectDir, id);
153
163
  if (existsSync(dir)) {
154
- // The run's own audit and context lines are no work to keep.
155
- git(dir, ['checkout', '--', 'gcf/.metrics'], { check: false });
156
- git(dir, ['clean', '-fdq', '--', 'gcf/.metrics'], { check: false });
164
+ dropLogs(dir);
157
165
  const res = git(projectDir, ['worktree', 'remove', dir], { check: false });
158
166
  if (!res.ok) notes.push(`worktree kept: ${res.err}`);
159
167
  }
@@ -32,6 +32,8 @@ const FROM = {
32
32
  depends: STORED,
33
33
  // A file given to the item (a chat image) changes no status.
34
34
  attach: STORED,
35
+ // The model and effort of its next run change no status either.
36
+ agent: STORED,
35
37
  };
36
38
 
37
39
  /** Every move an item may be offered, in the board's order. */
package/lib/work-ops.js CHANGED
@@ -833,23 +833,33 @@ function checkRelease(spec) {
833
833
 
834
834
  const RUN_KEYS = ['model', 'effort'];
835
835
 
836
- /**
837
- * How a new item runs: its model and effort (the run passes them to the agent's command line)
838
- * and its rank among the items.
839
- */
840
- function runFields(spec) {
836
+ // The value that leaves a model or effort to the agent: no flag on its command line.
837
+ const AGENT_DEFAULT = 'default';
838
+
839
+ /** Refuse a model or effort that is not one plain word (`default` included). */
840
+ function checkRunWords(spec) {
841
841
  for (const k of RUN_KEYS)
842
842
  if (spec[k] !== undefined && !RUN_WORD.test(spec[k]))
843
843
  throw new Error(
844
844
  `--${k} is one word that starts with a letter or a digit ` +
845
845
  '(then letters, digits, dots, hyphens, underscores), e.g. opus',
846
846
  );
847
+ }
848
+
849
+ /**
850
+ * How a new item runs: its model and effort (the run passes them to the agent's command line;
851
+ * `default` stores none) and its rank among the items.
852
+ */
853
+ function runFields(spec) {
854
+ checkRunWords(spec);
847
855
  const { priority } = spec;
848
856
  if (priority !== undefined && !(Number.isInteger(priority) && priority >= 1))
849
857
  throw new Error('--priority is a rank: an integer from 1 (lower runs sooner)');
850
858
 
851
859
  return Object.fromEntries(
852
- [...RUN_KEYS, 'priority'].filter((k) => spec[k] !== undefined).map((k) => [k, spec[k]]),
860
+ [...RUN_KEYS, 'priority']
861
+ .filter((k) => spec[k] !== undefined && spec[k] !== AGENT_DEFAULT)
862
+ .map((k) => [k, spec[k]]),
853
863
  );
854
864
  }
855
865
 
@@ -1044,6 +1054,43 @@ async function setDependsUnlocked(projectDir, id, { add = [], remove = [], commi
1044
1054
  return { id, depends, hash };
1045
1055
  }
1046
1056
 
1057
+ /**
1058
+ * Set how item `id`'s runs go: its `model` and `effort`, each given one a plain word, `default`
1059
+ * taking the field off (the agent's own choice). One commit `gcf(item)`. A run in progress keeps
1060
+ * its own; the item's next run takes the new value.
1061
+ * @param {string} projectDir
1062
+ * @param {string} id
1063
+ * @param {{model?: string, effort?: string, commit?: boolean}} [opts]
1064
+ */
1065
+ async function setAgentUnlocked(projectDir, id, { model, effort, commit = true } = {}) {
1066
+ if (model === undefined && effort === undefined) throw new Error('give --model or --effort');
1067
+ checkRunWords({ model, effort });
1068
+ const ledger = await buildLedger(projectDir);
1069
+ const item = ledger.item(id);
1070
+ if (!item) throw new Error(`${id} is not a work item`);
1071
+ refuseRunning(projectDir, id);
1072
+ const data = { ...item.data };
1073
+ for (const [k, v] of Object.entries({ model, effort }))
1074
+ if (v === AGENT_DEFAULT) delete data[k];
1075
+ else if (v !== undefined) data[k] = v;
1076
+ const result = { id, model: data.model ?? null, effort: data.effort ?? null };
1077
+ // The values it has already: nothing to commit (a form sent as it was opened).
1078
+ if (RUN_KEYS.every((k) => data[k] === item.data[k])) return { ...result, hash: null };
1079
+ const shown = (k) => `${k} ${data[k] ?? AGENT_DEFAULT}`;
1080
+ const hash = await commitMove(
1081
+ projectDir,
1082
+ `gcf(item): ${id} ${shown('model')}, ${shown('effort')}`,
1083
+ {
1084
+ files: [item.file],
1085
+ inputs: [item.file],
1086
+ mutate: () => atomicWrite(item.file, serialize(data, item.body)),
1087
+ commit,
1088
+ },
1089
+ );
1090
+
1091
+ return { ...result, hash };
1092
+ }
1093
+
1047
1094
  // An attachment is a picture or a file the operator gave the item (a chat image, a reference).
1048
1095
  const ATTACH_MAX = 10 * 1024 * 1024;
1049
1096
 
@@ -1205,6 +1252,9 @@ export const prioritizeItems = (projectDir, ids, opts = {}) =>
1205
1252
  /** @type {typeof setDependsUnlocked} */
1206
1253
  export const setDepends = (projectDir, id, opts = {}) =>
1207
1254
  locked(projectDir, opts.commit ?? true, () => setDependsUnlocked(projectDir, id, opts));
1255
+ /** @type {typeof setAgentUnlocked} */
1256
+ export const setAgent = (projectDir, id, opts = {}) =>
1257
+ locked(projectDir, opts.commit ?? true, () => setAgentUnlocked(projectDir, id, opts));
1208
1258
  /** @type {typeof newItemUnlocked} */
1209
1259
  export const newItem = (projectDir, spec) =>
1210
1260
  locked(projectDir, spec.commit ?? false, () => newItemUnlocked(projectDir, spec));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-aif-ext",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Game Context Framework for AI Factory",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@ gcf_work:
23
23
  - the human plays from `ai-factory gcf playtest session`; each free note from that play goes to `ai-factory gcf inbox add --source playtest "<note>"`
24
24
  - a release item carries `version:` and `channel:` (`item new <id> --type release --release <v> --channel <c>`): its end writes the `release:` block of `gcf/LIVE.md`
25
25
  - `item new` and `take` refuse a type the current phase does not take: run `ai-factory gcf phase` and bring the refusal to the human
26
- - an item the human wants run on a given model or effort gets `item new <id> --model <m> --effort <e>`: the harness run passes both to the agent
26
+ - an item the human wants run on a given model or effort gets `item new <id> --model <m> --effort <e>`: the harness run passes both to the agent; an existing item changes with `ai-factory gcf item agent <id> --model <m> --effort <e>` (`default` takes one off: the agent picks), never a hand edit; its next run takes them
27
27
  - ready items run in `priority:` order, lower first: rank a set of items with `ai-factory gcf prioritize <id> <id> …`, and put an id in `depends` only when the item uses that one's data or code: `ai-factory gcf depends <id> --add <ids>` or `--remove <ids>`, never a hand edit
28
28
  - a picture or file the human gives an item goes to `ai-factory gcf item attach <id> --file <path>` (its `gcf/work/<id>/attachments/`, committed); read an item's attachments before you plan it
29
29
  - write what the human reads (a question, an assumption, a block reason, an inbox entry, a lesson, a report, an item's `title:`) in `language.ui` of `.ai-factory/config.yaml`, and the body of an item that is not a design unit in its `language.artifacts`