gcf-board 0.21.0 → 0.23.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 +6 -1
- package/dist/server/app.js +105 -8
- package/dist/server/cli.js +3 -1
- package/dist/server/events.js +31 -3
- package/dist/server/runs.js +229 -30
- package/dist/server/talks.js +38 -0
- package/dist/server/usage.js +49 -109
- package/dist/web/assets/index-CmVruskr.js +113 -0
- package/dist/web/assets/index-D-qaIlaa.css +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/gcf-session/lib/chat.js +39 -5
- package/node_modules/gcf-session/lib/index.js +15 -0
- package/node_modules/gcf-session/lib/job.js +133 -34
- package/node_modules/gcf-session/lib/session.js +64 -10
- package/node_modules/gcf-session/lib/usage.js +288 -0
- package/node_modules/gcf-session/package.json +1 -1
- package/node_modules/gcf-session/types/index.d.ts +60 -2
- package/package.json +1 -1
- package/dist/web/assets/index-BbBRDApN.css +0 -1
- package/dist/web/assets/index-CQjhJ0I-.js +0 -104
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A local web board for game projects on [GCF](../gcf-aif-ext): the items by statu
|
|
|
6
6
|
|
|
7
7
|
- Node.js ≥ 22.18
|
|
8
8
|
- [`ai-factory`](https://www.npmjs.com/package/ai-factory) installed globally, and in each project [`gcf-aif-ext`](../gcf-aif-ext) ≥ 0.18 (`gcf board --json` with `schema: 4`: the columns, the moves, the item's fields, the blocks and the Help terms come from it as data)
|
|
9
|
+
- for 0.23: `gcf-aif-ext` ≥ 0.25 and `gcf-harness-aif-ext` ≥ 0.24 for **Play** (an older core shows no bar)
|
|
10
|
+
- for 0.22: `gcf-aif-ext` ≥ 0.24 and `gcf-harness-aif-ext` ≥ 0.23 for the **shelved** chip (an older pair stops a main batch at a card's loose code, as before)
|
|
9
11
|
- for 0.21: `gcf-aif-ext` ≥ 0.23 for **amend** (an older core offers no such move)
|
|
10
12
|
- for 0.20: `gcf-aif-ext` ≥ 0.22 for **Changes** (an older core shows neither the screen nor its marker)
|
|
11
13
|
- for runs: [`gcf-harness-aif-ext`](../gcf-harness-aif-ext) ≥ 0.11 (every board run opens its chat: `--chat`, `gcf-harness chat`; it waits the project's answer time) and Claude Code (`claude -p`); ≥ 0.12 to wait for the usage limit's reset and for queued runs (`--wait-limit`)
|
|
@@ -44,6 +46,7 @@ The board knows no domain by name: the project's board read gives its columns, m
|
|
|
44
46
|
- **An item** (a window over the screen, dragged by its head; a page on a phone; board 0.14.0): its **Status** (why it is blocked or waits, its fields, its dependencies; it opens there when it is blocked or waits), its file (the front matter folded, a `key:` body by sections), its plan and its run log as it grows, its **Lessons**, and the moves the core offers for it (`items[].moves`, Methodology §4.1): run, verdict, decide, block, unblock, drop, close, submit, depends. Each move's form comes from the core; the core still checks the rest itself, and the board shows its answer. **Dependencies**: what it needs that has not ended in history (an item with its column, a design unit with its TBDs or the questions that block it, a graveyard line, an unknown id) and the items that need it, each a link; **Edit…** opens the picker of the board's items and design units (search by id and title, or type an id), and Save sends the `depends` move's adds and removes. **History** (core 0.13.0): its moves newest first, when, which, who (a run, your session, you; unknown on a commit older than the framework's marks), the commit and its subject; then its runs, as on the Runs screen. **Related**: its feature's other children, and the graveyard lines tagged with its system ("did we kill this before?"). An item that ended opens from **Ended** with its History.
|
|
45
47
|
- **Runs** (harness 0.13.0): what runs now with the run's model and effort, its last log lines, **Whole log** and **Stop**; the queue with what each item will run on; the past runs of the harness's run log, newest first, 50 at a time: start, end, mode, cost, and per item its result word, the reason word for word, cost, tokens, turns, handoffs, a broken step and what it ran on. **log** opens the part of the item's log that run wrote, **chat** that run's chat. Every start the operator asks for (Run selected, Run next, a drop on running, this screen) asks first with a model and effort picker for that run only (**default: each item's own**); the drawer's Run is one click. An older harness shows the active runs only, and the dialog has no pickers. The API: `GET /api/p/<project>/runs/past?limit=` (`gcf-harness runs --json`; 404 without a harness that keeps them), `GET …/item/<id>/history` (`{id, moves, runs}`), `GET …/log/<id>?from=&to=` (a past run's part, once: `{text, cut}`, at most its last 2 MB; without `from` and `to` the log as it grows), `POST …/run` with `model` and `effort`, `POST …/inbox/<entry>/draft` (`{thread, created}`).
|
|
46
48
|
- **Log** (board 0.20.1, gcf-session 0.18.1): a subagent's lines say so (`subagent:`, `subagent tool:`, `subagent tool error:`), drawn as the main agent's kinds; the pulse's current action names a subagent's call as one.
|
|
49
|
+
- **Play** (board 0.23.0, core 0.25.0): a card waiting for play shows its own build, **Play** per target of `play:`, **Stop** and **Build**, on its run's end card, in its window and on Playtest; a verdict stops the player and removes the build.
|
|
47
50
|
- **Amend** (board 0.21.0, core 0.23.0): under "more" on a card: the form opens on its text, shows old and new lines before the move, and refuses an edit made meanwhile with the text you typed kept beside it. A chat agent's proposal shows the same lines. During that card's run it is refused, and the proposal offers **Send to the run**, to a live session only.
|
|
48
51
|
- **Run again** (board 0.20.1): an item a main batch has ended, blocked for one, can be run again while the batch goes on: it queues behind the batch. An item the batch works or has yet to reach is still refused with `already running from this board`, and so is every item of a worktree batch until that batch ends.
|
|
49
52
|
- **Changes** (board 0.20.0, core 0.22.0): what is not committed and how it differs, view only: the agent commits. The header's `● 7 changed` counts the main checkout, and says `run writing in main` while a run works there; the screen switches between the main checkout and each run's worktree. A text file opens its diff, a picture its before and after; a binary file, the project's `no_diff:` globs (one glob a line in Settings), links, submodules, nested repositories and Git LFS files are listed and open nothing. It follows a move, a commit or an add at once, a save in an editor within 30 s.
|
|
@@ -75,12 +78,14 @@ The board knows no domain by name: the project's board read gives its columns, m
|
|
|
75
78
|
- **Design**: where a game starts and its design changes. The steps from an empty project to the first work (the design, the pillars, the open questions, a ready unit), each with what does it: **Import GDD** (a markdown file), **Review GDD first**, **Create with agent**, **Draft with agent** for the glossary, **Pillars interview**, **Name with agent** for pillars without a name; each opens a project chat thread that follows its own skill and writes the design files without a card. **Record design** commits what a thread wrote, and **Discard draft…** takes an agent's unrecorded draft back (`gcf design discard`); a form save of the drafted part takes the draft along. The pillars, the vision, the glossary, a subsystem's purpose and each unit open in a form whose fields come from the core; a save goes through the core's checks, a refusal says why. A pillar is edited by its name, its id read-only (a changed name renames the id after the save); Retire. **Add unit** asks a subsystem, a type and a title, no id, and opens the new unit. A subsystem's purpose has **Draft with agent**. A unit's Drop, the design questions with their answer box, the designer's Export and Import. Until the first work, while steps are left, Command says how many and opens Design.
|
|
76
79
|
- **Keys**: `/` search, `i` a new inbox entry, `n` a new item, `j` / `k` between cards, Enter opens one, `r` runs the focused card (it asks), `1`–`7` a column, `?` Help, `g` then a letter goes to a screen (`g c` Command, `g b` Board, `g t` Chat, `g i` Inbox, `g d` Design, `g r` Runs, `g p` Playtest, `g e` Ended, `g a` Agent, `g m` Metrics, `g s` Settings; the nav's icons say theirs), Esc closes a dialog, Help, the item's or the detail window; none while a field has the focus. Board 0.16.0: the nav is a rail of icons, the project switcher sits at the header's left.
|
|
77
80
|
- **Lessons** (core 0.7.10, harness 0.9.2): what got in an agent's way, asked at the end of each session, lands in the inbox as the category Lesson, its kind (`tool`, `rules`, `framework`, `template`, `other`) the detail, with its item. The inbox filters them; a card shows `N lessons`, and the item's **Lessons** tab lists them with the inbox's buttons. A run's report line ends with `, N lessons`, and with `— code written outside aif-implement` when a session skipped that skill.
|
|
78
|
-
- **Playtest**: `gcf playtest session` with the checklist grouped by subsystem; keep, tune or kill each item from the list. **
|
|
81
|
+
- **Playtest**: `gcf playtest session` with the checklist grouped by subsystem; keep, tune or kill each item from the list. Each card has its own **Play** bar. A note goes to the inbox as `--category playtest`.
|
|
79
82
|
- **Ended**: history (accepted) and graveyard (killed, dropped, won't-fix); a line opens the item's History.
|
|
80
83
|
- **Metrics**: `gcf-harness metrics --json` of the project — how many runs reached submit or close, what they cost, handoffs, plan checks, DoD attempts, guard firings, block reasons — and, with harness 0.9.5, the cost per item over all its runs and per week and day.
|
|
81
84
|
|
|
82
85
|
The page updates by itself: the server watches each project's `gcf/` and `.gcf-session/runs/`.
|
|
83
86
|
|
|
87
|
+
Hold: a card's Hold (its chat and window), the project's hold chip, and `quota_reserve_pct` in Settings: the queue and the autopilot leave that share of each usage window to you.
|
|
88
|
+
|
|
84
89
|
## Security
|
|
85
90
|
|
|
86
91
|
The board starts agents that write code and commit: whoever can talk to it runs code on this machine.
|
package/dist/server/app.js
CHANGED
|
@@ -24,9 +24,9 @@ import { isUpload, saveUpload, UPLOAD_MAX } from './upload.js';
|
|
|
24
24
|
import { addProject, homeDir, listProjects, projectOf, removeProject, yoloFile, } from './registry.js';
|
|
25
25
|
import { allThemes } from './themes.js';
|
|
26
26
|
import { askIfDue, askUsage, configureUsage, lastUsage } from './usage.js';
|
|
27
|
-
import { activeRuns, adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, runsOf, setAutopilot, startRun, unqueue, } from './runs.js';
|
|
27
|
+
import { activeRuns, adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, holdProject, retryWaiting, runsOf, setAutopilot, startRun, unqueue, whileClickBuilds, } from './runs.js';
|
|
28
28
|
import { acceptProposal, agentDefaults, agentPresets, chatCard, deniedGroupIn, lastDeniedOf, lastRunEnd, chatOf, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startDesign, startTalk, stopTalk, talkEntry, talkId, talkLive, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
29
|
-
import { threadDir, threadOfEntry } from 'gcf-session';
|
|
29
|
+
import { accountSettings, saveAccountSettings, threadDir, threadOfEntry } from 'gcf-session';
|
|
30
30
|
const send = (res, status, body) => {
|
|
31
31
|
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
|
|
32
32
|
res.end(JSON.stringify(body));
|
|
@@ -75,6 +75,9 @@ const treeArgs = (url) => {
|
|
|
75
75
|
return tree && tree !== 'main' ? [`--worktree=${tree}`] : [];
|
|
76
76
|
};
|
|
77
77
|
/** Parse the JSON a command printed, or say what it printed instead. */
|
|
78
|
+
// How long the board waits for a build: the core ends it by the project's `dod_timeout_min`, and
|
|
79
|
+
// the board must not cut it sooner, on POSIX with its engine still going.
|
|
80
|
+
const PLAY_BUILD_MS = 24 * 60 * 60_000;
|
|
78
81
|
function jsonOf(r, what) {
|
|
79
82
|
try {
|
|
80
83
|
return JSON.parse(r.out);
|
|
@@ -99,6 +102,9 @@ const questionText = (b, move, id) => {
|
|
|
99
102
|
return undefined;
|
|
100
103
|
return (b.questions ?? []).find((q) => q.id === id)?.question ?? null;
|
|
101
104
|
};
|
|
105
|
+
/** The core lists 2000 rows at most, so a Commit ticks no more. */
|
|
106
|
+
const CHANGE_PATHS_MAX = 2000;
|
|
107
|
+
const COMMIT_TIMEOUT_MS = 600_000;
|
|
102
108
|
/** The most paths one edits diff takes: a refusal past this many is read in the console. */
|
|
103
109
|
const EDIT_PATHS_MAX = 2000;
|
|
104
110
|
/** The same for an older core, each path an argument (core 0.20.1). */
|
|
@@ -376,6 +382,19 @@ export function createApp(o) {
|
|
|
376
382
|
send(res, 200, { on: b.on });
|
|
377
383
|
},
|
|
378
384
|
],
|
|
385
|
+
// The account's settings (Hold-Plan d10): the quota's reserve, one for every project.
|
|
386
|
+
['GET', /^\/api\/settings$/, async (_req, res) => send(res, 200, accountSettings())],
|
|
387
|
+
[
|
|
388
|
+
'PUT',
|
|
389
|
+
/^\/api\/settings$/,
|
|
390
|
+
async (req, res) => {
|
|
391
|
+
const pct = (await bodyOf(req)).quota_reserve_pct;
|
|
392
|
+
if (typeof pct !== 'number' || !Number.isInteger(pct) || pct < 0 || pct > 50)
|
|
393
|
+
throw new HttpError(400, 'quota_reserve_pct is a whole percent, 0 to 50');
|
|
394
|
+
saveAccountSettings({ ...accountSettings(), quota_reserve_pct: pct });
|
|
395
|
+
send(res, 200, accountSettings());
|
|
396
|
+
},
|
|
397
|
+
],
|
|
379
398
|
['GET', /^\/api\/projects$/, async (_req, res) => send(res, 200, await listProjects())],
|
|
380
399
|
['GET', /^\/api\/themes$/, async (_req, res) => send(res, 200, await allThemes())],
|
|
381
400
|
[
|
|
@@ -734,14 +753,37 @@ export function createApp(o) {
|
|
|
734
753
|
},
|
|
735
754
|
],
|
|
736
755
|
[
|
|
737
|
-
//
|
|
756
|
+
// Playing a card: the project's own commands, so POSTs with their Origin checked. A refusal
|
|
757
|
+
// comes back as an error with its words; a build that failed is an answer (`ok: false`).
|
|
738
758
|
'POST',
|
|
739
|
-
/^\/api\/p\/([^/]+)\/
|
|
740
|
-
async (
|
|
741
|
-
const
|
|
759
|
+
/^\/api\/p\/([^/]+)\/play\/(build|start|stop)$/,
|
|
760
|
+
async (req, res, m) => {
|
|
761
|
+
const p = await projectOf(m[1]);
|
|
762
|
+
const body = await bodyOf(req);
|
|
763
|
+
const word = (v, what) => {
|
|
764
|
+
if (typeof v !== 'string' || !/^[\w][\w-]*$/.test(v))
|
|
765
|
+
throw new HttpError(400, `${what} is one word`);
|
|
766
|
+
return v;
|
|
767
|
+
};
|
|
768
|
+
const args = m[2] === 'stop'
|
|
769
|
+
? ['gcf', 'playtest', 'stop', '--json']
|
|
770
|
+
: m[2] === 'build'
|
|
771
|
+
? ['gcf', 'playtest', 'build', word(body.id, 'id'), '--json']
|
|
772
|
+
: [
|
|
773
|
+
...['gcf', 'playtest', 'start', word(body.id, 'id'), '--json'],
|
|
774
|
+
...['--target', word(body.target, 'target')],
|
|
775
|
+
];
|
|
742
776
|
// A build of a real game takes minutes.
|
|
743
|
-
const r =
|
|
744
|
-
|
|
777
|
+
const r = m[2] === 'build'
|
|
778
|
+
? await whileClickBuilds(p, () => cli(p, args, PLAY_BUILD_MS))
|
|
779
|
+
: await cli(p, args);
|
|
780
|
+
broadcast({ type: 'board', project: p.name });
|
|
781
|
+
try {
|
|
782
|
+
send(res, 200, JSON.parse(r.out));
|
|
783
|
+
}
|
|
784
|
+
catch {
|
|
785
|
+
throw new HttpError(409, briefError(r.err || r.out));
|
|
786
|
+
}
|
|
745
787
|
},
|
|
746
788
|
],
|
|
747
789
|
[
|
|
@@ -822,6 +864,9 @@ export function createApp(o) {
|
|
|
822
864
|
await rm(dir, { recursive: true, force: true });
|
|
823
865
|
}
|
|
824
866
|
broadcast({ type: 'board', project: p.name });
|
|
867
|
+
// A move may have ended what a queued card waits for, or taken it out of its depends.
|
|
868
|
+
if (r.ok)
|
|
869
|
+
retryWaiting(p.name);
|
|
825
870
|
// A refusal the board can act on (core 0.20): the page offers its fixes.
|
|
826
871
|
const refusal = r.ok ? undefined : refusalOf(r.err);
|
|
827
872
|
send(res, 200, {
|
|
@@ -1015,6 +1060,28 @@ export function createApp(o) {
|
|
|
1015
1060
|
send(res, 200, jsonOf(r, 'gcf changes'));
|
|
1016
1061
|
},
|
|
1017
1062
|
],
|
|
1063
|
+
[
|
|
1064
|
+
// The operator's Commit on Changes (`gcf changes commit`, core 0.24): their ticked files and
|
|
1065
|
+
// their text on stdin. Long enough for a slow project hook: a kill would leave index.lock.
|
|
1066
|
+
'POST',
|
|
1067
|
+
/^\/api\/p\/([^/]+)\/changes\/commit$/,
|
|
1068
|
+
async (req, res, m) => {
|
|
1069
|
+
const p = await projectOf(m[1]);
|
|
1070
|
+
const { message, paths } = await bodyOf(req);
|
|
1071
|
+
if (typeof message !== 'string' || !message.trim())
|
|
1072
|
+
throw new HttpError(400, 'message: the text of the commit');
|
|
1073
|
+
if (!Array.isArray(paths) ||
|
|
1074
|
+
!paths.length ||
|
|
1075
|
+
paths.length > CHANGE_PATHS_MAX ||
|
|
1076
|
+
paths.some((x) => typeof x !== 'string'))
|
|
1077
|
+
throw new HttpError(400, `paths: 1 to ${CHANGE_PATHS_MAX} paths from the list`);
|
|
1078
|
+
const r = await cli(p, ['gcf', 'changes', 'commit', '--fields-file=-', '--json'], COMMIT_TIMEOUT_MS, JSON.stringify({ message, paths }));
|
|
1079
|
+
broadcast({ type: 'board', project: p.name });
|
|
1080
|
+
send(res, 200, r.ok
|
|
1081
|
+
? { ok: true, ...jsonOf(r, 'gcf changes commit') }
|
|
1082
|
+
: { ok: false, err: briefError(r.err || r.out) });
|
|
1083
|
+
},
|
|
1084
|
+
],
|
|
1018
1085
|
[
|
|
1019
1086
|
'GET',
|
|
1020
1087
|
/^\/api\/p\/([^/]+)\/changes\/diff$/,
|
|
@@ -1133,6 +1200,36 @@ export function createApp(o) {
|
|
|
1133
1200
|
send(res, 200, { ok: r.ok, out: r.out.trim(), err: briefError(r.err) });
|
|
1134
1201
|
},
|
|
1135
1202
|
],
|
|
1203
|
+
[
|
|
1204
|
+
// The operator's Hold of a card (Hold-Plan d6, d20): its session hands over at the next
|
|
1205
|
+
// call, its work waits ready; the harness keeps the mark, so a restart keeps the hold.
|
|
1206
|
+
'POST',
|
|
1207
|
+
/^\/api\/p\/([^/]+)\/hold\/([^/]+)$/,
|
|
1208
|
+
async (_req, res, m) => {
|
|
1209
|
+
const p = await projectOf(m[1]);
|
|
1210
|
+
const [id] = runIds({ ids: [decodeURIComponent(m[2])] });
|
|
1211
|
+
const r = await cli(p, [await harnessOf(p), 'hold', id]);
|
|
1212
|
+
broadcast({ type: 'board', project: p.name });
|
|
1213
|
+
send(res, r.ok ? 200 : 409, { ok: r.ok, out: r.out.trim(), err: briefError(r.err) });
|
|
1214
|
+
},
|
|
1215
|
+
],
|
|
1216
|
+
[
|
|
1217
|
+
// The operator holds the whole project, or releases it (Hold-Plan d20).
|
|
1218
|
+
'POST',
|
|
1219
|
+
/^\/api\/p\/([^/]+)\/hold$/,
|
|
1220
|
+
async (_req, res, m) => {
|
|
1221
|
+
const p = await projectOf(m[1]);
|
|
1222
|
+
send(res, 200, await holdProject(o.entry, p, await harnessOf(p), true));
|
|
1223
|
+
},
|
|
1224
|
+
],
|
|
1225
|
+
[
|
|
1226
|
+
'DELETE',
|
|
1227
|
+
/^\/api\/p\/([^/]+)\/hold$/,
|
|
1228
|
+
async (_req, res, m) => {
|
|
1229
|
+
const p = await projectOf(m[1]);
|
|
1230
|
+
send(res, 200, await holdProject(o.entry, p, await harnessOf(p), false));
|
|
1231
|
+
},
|
|
1232
|
+
],
|
|
1136
1233
|
[
|
|
1137
1234
|
'POST',
|
|
1138
1235
|
/^\/api\/p\/([^/]+)\/queue\/resume$/,
|
package/dist/server/cli.js
CHANGED
|
@@ -77,9 +77,11 @@ export function refusalOf(err) {
|
|
|
77
77
|
catch {
|
|
78
78
|
return undefined;
|
|
79
79
|
}
|
|
80
|
-
const { code, paths, left } = (data ?? {});
|
|
80
|
+
const { code, paths, left, reason } = (data ?? {});
|
|
81
81
|
if (code === 'running' || code === 'stale')
|
|
82
82
|
return { code };
|
|
83
|
+
if (code === 'shelve')
|
|
84
|
+
return { code, reason: typeof reason === 'string' ? reason : '' };
|
|
83
85
|
if (!Array.isArray(paths))
|
|
84
86
|
return undefined;
|
|
85
87
|
const safe = (a) => (Array.isArray(a) ? a : []).filter(gatePath);
|
package/dist/server/events.js
CHANGED
|
@@ -187,11 +187,34 @@ export function runsState(dir, ttlMin = SESSION_TTL_MIN, now = Date.now()) {
|
|
|
187
187
|
// so the page reads an open plan again when the count moves.
|
|
188
188
|
const planRevs = new Map();
|
|
189
189
|
export const planRev = (project) => planRevs.get(project) ?? 0;
|
|
190
|
+
/** What of a card's builds and its player the board shows: a build ends, a game is closed. */
|
|
191
|
+
export function playState(project) {
|
|
192
|
+
const session = path.join(project, '.gcf-session');
|
|
193
|
+
let builds = [];
|
|
194
|
+
try {
|
|
195
|
+
builds = readdirSync(path.join(session, 'builds'))
|
|
196
|
+
.filter((f) => f.endsWith('.json'))
|
|
197
|
+
.map((f) => `${f}:${statSync(path.join(session, 'builds', f)).mtimeMs}`)
|
|
198
|
+
.sort();
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
// None yet.
|
|
202
|
+
}
|
|
203
|
+
let player = '';
|
|
204
|
+
try {
|
|
205
|
+
const p = JSON.parse(readFileSync(path.join(session, 'play.json'), 'utf8'));
|
|
206
|
+
player = `${p.pid}:${alive(p.pid)}`;
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
// None plays.
|
|
210
|
+
}
|
|
211
|
+
return `${builds.join(',')}|${player}`;
|
|
212
|
+
}
|
|
190
213
|
/**
|
|
191
214
|
* Watch a project: `gcf/` (every move writes there), `.ai-factory/plans` (a plan is written and
|
|
192
|
-
* edited)
|
|
193
|
-
*
|
|
194
|
-
* event. Returns the stop.
|
|
215
|
+
* edited), `.gcf-session/runs` (a run's lock or session mark comes, goes or goes stale) and its
|
|
216
|
+
* builds and player. The session folder may not exist yet, so it is polled, not watched. Bursts
|
|
217
|
+
* of writes make one event. Returns the stop.
|
|
195
218
|
*/
|
|
196
219
|
export function watchProject(p, debounceMs = 300, ttlMin = () => SESSION_TTL_MIN) {
|
|
197
220
|
let timer = null;
|
|
@@ -236,11 +259,16 @@ export function watchProject(p, debounceMs = 300, ttlMin = () => SESSION_TTL_MIN
|
|
|
236
259
|
}
|
|
237
260
|
};
|
|
238
261
|
let read = quotaAt();
|
|
262
|
+
let playing = playState(p.path);
|
|
239
263
|
const poll = setInterval(() => {
|
|
240
264
|
const now = runsState(runs, ttlMin());
|
|
241
265
|
if (now !== last)
|
|
242
266
|
fire();
|
|
243
267
|
last = now;
|
|
268
|
+
const nowPlaying = playState(p.path);
|
|
269
|
+
if (nowPlaying !== playing)
|
|
270
|
+
fire();
|
|
271
|
+
playing = nowPlaying;
|
|
244
272
|
// The limit is the account's: a new reading here changes every project's top bar.
|
|
245
273
|
const quota = quotaAt();
|
|
246
274
|
if (quota !== read)
|