gcf-board 0.12.1 → 0.16.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 +16 -15
- package/dist/server/app.js +164 -36
- package/dist/server/chat.js +31 -3
- package/dist/server/moves.js +9 -2
- package/dist/server/propose.js +8 -1
- package/dist/server/talks.js +107 -12
- package/dist/server/themes.js +12 -2
- package/dist/server/upload.js +38 -0
- package/dist/shared/board.js +1 -1
- package/dist/web/assets/index-CswEz8NZ.js +51 -0
- package/dist/web/assets/index-UsK78iqM.css +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/gcf-session/lib/adapter/claude.js +7 -2
- package/node_modules/gcf-session/lib/adapter/index.js +8 -1
- package/node_modules/gcf-session/lib/chat.js +1 -1
- package/node_modules/gcf-session/lib/index.js +1 -1
- package/node_modules/gcf-session/lib/thread.js +19 -10
- package/node_modules/gcf-session/package.json +1 -1
- package/node_modules/gcf-session/types/index.d.ts +16 -3
- package/package.json +2 -1
- package/themes/cream-medium.json +41 -0
- package/themes/dusk.json +41 -0
- package/themes/paper-soft.json +41 -0
- package/themes/sand-contrast.json +41 -0
- package/dist/web/assets/index-CfdW68fJ.js +0 -40
- package/dist/web/assets/index-xG2PuBXE.css +0 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A local web board for game projects on [GCF](../gcf-aif-ext): the items by statu
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
7
|
- Node.js ≥ 22.18
|
|
8
|
-
- [`ai-factory`](https://www.npmjs.com/package/ai-factory) installed globally, and in each project [`gcf-aif-ext`](../gcf-aif-ext) ≥ 0.
|
|
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
9
|
- 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`)
|
|
10
10
|
- for the project chat: `gcf-aif-ext` ≥ 0.12 (`domain.chat`, `agent.rules`) and Claude Code
|
|
11
11
|
- for 0.12: `gcf-aif-ext` ≥ 0.16 for the chat's proposals of moves on items and inbox entries (an older core proposes only new items) and an item's own run mode; `gcf-harness-aif-ext` ≥ 0.16 to run main and worktree side by side safely (the main run's queue in the gate, a merge that waits)
|
|
@@ -35,11 +35,11 @@ It puts **GCF Board** on the desktop (Windows: a shortcut whose server console s
|
|
|
35
35
|
|
|
36
36
|
## What it does
|
|
37
37
|
|
|
38
|
-
The board knows no domain by name: the project's board read gives its columns, moves with their forms, item fields, blocks and Help terms (`domain`, Board-PRD decision 16). The page follows design B (`docs/design/mockup`): a left nav with the project switcher (add a project, take one off the board), the screens **Command**, **Board**, **Chat**, **Inbox**, **Runs**, **Playtest**, **Ended**, **Agent
|
|
38
|
+
The board knows no domain by name: the project's board read gives its columns, moves with their forms, item fields, blocks and Help terms (`domain`, Board-PRD decision 16). The page follows design B (`docs/design/mockup`): a left nav with the project switcher (add a project, take one off the board), the screens **Command**, **Board**, **Chat**, **Inbox**, **Design**, **Runs**, **Playtest**, **Ended**, **Agent** and **Metrics** (a domain without a block has no screen for it, a project without a harness no Runs and no Metrics), and a header with the phase, the runs, the limit wait, the quota, WIP, the release, **waiting for me**, **+ item**, the gear (**Settings**, a dialog over the screen; on a phone in More) and **?**. The project and the screen are in the URL hash. On a phone a bottom bar holds Command, Board, Chat, Inbox and More. When the server is gone, the page says so and reconnects by itself. For a GCF project:
|
|
39
39
|
|
|
40
|
-
- **Command**: **waiting for me**, what only the operator moves on (Board-PRD §1.3), by group: failed run reports and a paused queue, a card waiting in a chat (
|
|
40
|
+
- **Command**: **waiting for me**, what only the operator moves on (Board-PRD §1.3), by group, each a grid of tiles (board 0.16.0, the designer's final round): failed run reports and a paused queue (its tile opens Runs), a card waiting in a chat (its tile opens the chat), the decisions, the items to play and judge, to decide, to unblock (the columns the domain marks `human`), and a `paused: limit` item to resume. Beside it **Live**: the runs going on with their plan progress, **Follow** and **Stop**, the console runs and sessions, **Run next**, the queue, the run reports, and what the board did by itself.
|
|
41
41
|
- **Board**: columns ready, running, blocked, awaiting-verdict, awaiting-decision, unplayed, parked. A card shows the type, the gate, the plan progress (`2/5`), the severity, `verified`, the model, **needs N** and **needed by N**. A running card shows when its run log was last written (`active 12 s ago`), and `quiet 6 min` when the log has been silent for 5 minutes or more. A run's end report gives each item's cost when the agent reported it. Pointing at a card (or focusing it from the keyboard) lights up the cards it needs and the cards that need it, each saying how, and dims the rest. The toolbar (board 0.9.0, core 0.13.0) searches ids and titles, keeps **waiting for me**, filters by the fields the domain marks `filter` (GCF: type, gate, severity, system, milestone; several values at once, each a chip to take off) and lays the board out in lanes by a field it marks `group` (system, parent, milestone): an item with two systems stands in both lanes, one with none in **none**, a parent lane is named by the feature's title. The mouse drags the board sideways from its empty space; the wheel over a column with no scroll of its own pans it.
|
|
42
|
-
- **An item
|
|
42
|
+
- **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.
|
|
43
43
|
- **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}`).
|
|
44
44
|
- **Drag**:
|
|
45
45
|
- a ready card into **running** starts its run;
|
|
@@ -56,19 +56,20 @@ The board knows no domain by name: the project's board read gives its columns, m
|
|
|
56
56
|
- **Run next N independent**: the framework's gate picks the ready items that can run together now, by priority, and the board runs them after asking.
|
|
57
57
|
- **Priority**: drop a ready card on another to put it before; the column's ranks are committed (`gcf prioritize`).
|
|
58
58
|
- **Questions**: each D1 shows its question and proposed answer; **Answer** writes yours into its record (`gcf question answer`), and the next agent on its units puts it in place.
|
|
59
|
-
- **New item**: `gcf item new … --commit`, its form from the core: a bug asks its severity, a release its version and channel. The item's `model` and `effort` go to its run.
|
|
59
|
+
- **New item**: `gcf item new … --commit`, its form from the core: a title and a type, no id (the core makes it from the title; board 0.15.0, Board-PRD decision 34); a bug asks its severity, a release its version and channel; the parent is one live feature and the dependencies are picked by title, each row "title (id)". The item's `model` and `effort` go to its run.
|
|
60
60
|
- **Help** (**?**): the domain's terms, columns, moves and field values with what each means, and the words of runs, under one filter.
|
|
61
|
-
- **Settings
|
|
62
|
-
- **Theme** (board 0.11.0, Board-PRD decision 26): Settings, "Board · this browser": **Dark (built-in)
|
|
61
|
+
- **Settings** (the header's gear): the keys of `gcf/config.yml` and the agents' language (`language.ui`, `language.artifacts` of `.ai-factory/config.yaml`), by the core's groups, each a `gcf config set` commit.
|
|
62
|
+
- **Theme** (board 0.11.0, Board-PRD decision 26): Settings, "Board · this browser": **Dark (built-in)**, the designer's themes the board ships (`themes/`: Paper · soft, Cream · medium, Sand · contrast, Dusk · soft dark; board 0.14.0), or a theme file of `~/.gcf/themes/<id>.json`, which replaces a shipped one of its id — `{"gcf_theme": 1, "name", "scheme": "light" | "dark", "tokens": {…}}`, the colour tokens of `web/tokens.css` without `--gcf-` over the built-in dark (a template: docs/design/theme-sample.json). Each browser keeps its own choice; a file that cannot be read is listed with its reason, and the page falls back to dark when the chosen one is gone. Reload the page after changing a file. `GET /api/themes` lists the files.
|
|
63
63
|
- **Agent**: the deny groups to tick, the rules the ticked groups add, the operator's own deny rules (add, remove) and the allow rules of `agent.allow`, apart; the context limits, read only.
|
|
64
|
-
- **An item's chat** (its drawer's **Chat** tab; harness 0.11.1, core 0.11.1): every run the board starts keeps its agent sessions open; the project's `chat:` settings (Settings: `chat.ask`, `chat.answer_timeout_min`) say what the agent asks and how long a question waits. The tab shows the run's chat, then the item's own thread of the project chat: the talk, question cards (picks, several questions, **Submit**), the run's milestones, its sessions, the limit wait, the context share. A message goes where the server puts it: the live run (its limit wait too), else the item's thread, and the line under the box says where it went. `GET /api/p/<project>/chat/<id>` follows the item's chat from its start, in raw chunks of JSON lines (the page splits them). `POST` there sends `{type: 'say', text, images?, attach?}`, `{type: 'interrupt'}` or `{type: 'answer', request_id, answers}` through `gcf-harness chat`; with no live run a message goes to the item's thread (answer `{talk}`), else a message with no session to read it gets 409, bad input 400. `attach` (`[{kind: item | unit | file, ref}]`) goes into the message's text as a line the agent reads; a design unit (the composer's **+ unit**, from the board read's `units`) goes as `unit <id> (<file>)`. `GET /api/p/<project>/chat/<id>/att/<file>` serves a chat picture; **attach to item…** under a picture gives it to an item (`gcf item attach`).
|
|
65
|
-
- **Functional base A** (board 0.10.0, core and harness 0.14.0; docs/Base-A-Plan.md): Settings has `session_timeout_min` and the project's `agent.model` / `agent.effort
|
|
66
|
-
- **Model and effort** (board 0.8.0, core 0.12.3): pickers in the New item form, in the drawer (**change** beside the model and effort, and **model / effort** under **More**)
|
|
67
|
-
- **Project chat** (the **Chat** screen; core 0.12): threads of an agent in the project's folder, listed newest first and filtered by their item; a new thread is made when its first message is sent. Each thread is run by the bundled session engine (`gcf-session`) through the same detached relay as runs. It asks a card before each edit, git command and framework move (**allow once**, **always** — saved in `.claude/settings.local.json`; the card says saved only when it was — or **deny**); a new item it proposes through the board's MCP server `gcf` (tool `propose_item_new`, asked with no card: the proposal card is the question), the proposal card shows every field it proposed, and the operator's **Create** makes it with `POST /move` (`proposal: {talk, id}`), **Edit…** first in the new-item form. With core 0.16 (board 0.12.0, Board-PRD decision 27) it also proposes a move on an item or an inbox entry already there — `block`, `drop`, `depends`, and the inbox's `add
|
|
68
|
-
- **Inbox
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **
|
|
64
|
+
- **An item's chat** (its drawer's **Chat** tab; harness 0.11.1, core 0.11.1): every run the board starts keeps its agent sessions open; the project's `chat:` settings (Settings: `chat.ask`, `chat.answer_timeout_min`) say what the agent asks and how long a question waits. The tab shows the run's chat, then the item's own thread of the project chat: the talk, question cards (picks, several questions, **Submit**), the run's milestones, its sessions, the limit wait, the context share. A message goes where the server puts it: the live run (its limit wait too), else the item's thread, and the line under the box says where it went. `GET /api/p/<project>/chat/<id>` follows the item's chat from its start, in raw chunks of JSON lines (the page splits them). `POST` there sends `{type: 'say', text, images?, attach?}`, `{type: 'interrupt'}` or `{type: 'answer', request_id, answers}` through `gcf-harness chat`; with no live run a message goes to the item's thread (answer `{talk}`), else a message with no session to read it gets 409, bad input 400. `attach` (`[{kind: item | unit | file, ref}]`) goes into the message's text as a line the agent reads; a file picked on the operator's machine (`{kind: file, ref: <name>, data: <base64>}`, the composer's 📎) is written into `.gcf-session/uploads/` and goes as `file <its absolute path>`; a move's `file` field (`attach`) takes `{name, data}` the same way, its copy removed after the command; a design unit (the composer's **+ unit**, from the board read's `units`) goes as `unit <id> (<file>)`. `GET /api/p/<project>/chat/<id>/att/<file>` serves a chat picture; **attach to item…** under a picture gives it to an item (`gcf item attach`).
|
|
65
|
+
- **Functional base A** (board 0.10.0, core and harness 0.14.0; docs/Base-A-Plan.md): Settings has `session_timeout_min` and the project's `agent.model` / `agent.effort`; the drawer shows the project's model on an item without its own, "(project)". The drawer's Run is off with the run gate's reason when the gate refuses the item now, and the start dialog marks each refused item and runs the rest (`GET /api/p/<project>/gate?ids=` runs `gcf-harness gate --each`). An item's attachments and an inbox entry's pictures are links (`GET /api/p/<project>/attachment?path=`: only `gcf/work/<id>/attachments/` and `gcf/inbox/in-<hex>/attachments/`, no `..`, no link on the way, a picture shown, any other file a download, `nosniff` and `default-src 'none'`), and a picture or link in File or Plan that points there loads through it. A permission card for one MCP tool offers Always, saying it allows every call of the tool with any arguments.
|
|
66
|
+
- **Model and effort** (board 0.8.0, core 0.12.3; a closed select since board 0.15.0, Board-PRD decision 33): pickers in the New item form, in the drawer (**change** beside the model and effort, and **model / effort** under **More**), in a thread's composer and in Settings (`agent.model` / `agent.effort`). Each is one select: Default first — "Default (Opus)" / "Default (High)", or "Default - project setting (Sonnet)" when the project sets one, and "Default - each item's own" in the run dialog; Default sends `default` — then the agent's presets by name (Fable, Opus, xHigh). Nothing set anywhere runs on Opus / High (decision 36). A thread's composer has no Default row: it shows what holds, and **↺ project** takes the thread's own pick off (board 0.16.2). No own word; a value set from the console that the presets lack shows as its own row, so a form sent unchanged keeps it. An item's next run takes them; a thread's next session does (`chats/<t>/agent.json`), and its line in the chat says so.
|
|
67
|
+
- **Project chat** (the **Chat** screen; core 0.12): threads of an agent in the project's folder, listed newest first and filtered by their item; a new thread is made when its first message is sent. Each thread is run by the bundled session engine (`gcf-session`) through the same detached relay as runs. It asks a card before each edit, git command and framework move (**allow once**, **always** — saved in `.claude/settings.local.json`; the card says saved only when it was — or **deny**); a new item it proposes through the board's MCP server `gcf` (tool `propose_item_new`, asked with no card: the proposal card is the question), the proposal card shows every field it proposed, and the operator's **Create** makes it with `POST /move` (`proposal: {talk, id}`), **Edit…** first in the new-item form. A proposed item has no id: the server asks `gcf item new --dry-run` for it, records it, then creates the item with it, so a board that stops halfway does not make it twice. An inbox entry the agent proposed is filed with origin `agent`: the server adds `--origin=agent`, never from the request. With core 0.16 (board 0.12.0, Board-PRD decision 27) it also proposes a move on an item or an inbox entry already there — `block`, `drop`, `depends`, and the inbox's `add` (with its category), sort, Later and erase (sort and Later with core 0.18, board 0.15.0) — naming it in `id`: the card shows the item's id, title and status now (or the entry's first line), warns when the item does not take the move now or is not on the board, its button is the move's name (a drop or an erase asks first), and **Edit…** opens that move's form. A thread's list entry names the card that waits in it and its limit wait (`card`, `limit_until`); a running item names the card of its run's chat (`chat_card`). A long talk hands over to a fresh agent from a summary; an idle agent closes after `chat.answer_timeout_min` (0 means 15) and the next message resumes it. Each item has at most one thread: a message to an item with no live run goes there. `GET /api/p/<project>/talks[?item=]` lists the threads with their proposals' states; `POST` there makes one (`{item?}`); `GET /api/p/<project>/talk/<t>` follows a thread's events; `POST` there sends `say`, `interrupt`, `answer`, `allow`, `deny` or `handoff`; `POST …/talk/<t>/stop` is the composer's **close agent** (board 0.8.1): the thread's agent ends with everything it started, or its limit wait does, and what it had not taken in is dropped with a "not sent" line; the next message resumes the talk; `GET …/talk/<t>/att/<file>` serves its pictures. The files live in `.gcf-session/chats/` (docs/Chat-Plan.md §3).
|
|
68
|
+
- **Inbox** (categories since board 0.15.0, core 0.18.0; Board-PRD decision 32): add an entry (Ctrl+Enter adds, Enter breaks the line; a category of the ones you may file, Note by default, and a detail), **Sort…** it into another category, put it away to **Later** and take it **Back**, erase it, or turn it into an item (its first line the title, the rest the note). Each entry shows its category and detail, its origin, its lines and date. Search the entries, filter them by category (or "in Later") and by detail. Since board 0.16.0 each group is a panel of tiles, Needs you first; a tile opens the record in the detail window (the item window's frame); the filter takes a category, its details, the origin, an item and the text; on the Inbox `j` / `k` move between tiles, Enter opens, `s` sorts, `l` puts Later or Back, `e` erases. The decisions and the agent's assumptions are records of their own categories there too. **Draft with agent** opens a project chat thread bound to the entry and sends "Draft an item from inbox entry <id>:" with its text; a second click opens the same thread. The first proposal's **Create** takes the entry (it is erased); a later one makes an item with no entry. Off while the usage limit holds.
|
|
69
|
+
- **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.
|
|
70
|
+
- **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.
|
|
71
|
+
- **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.
|
|
72
|
+
- **Playtest**: `gcf playtest session` with the checklist grouped by subsystem; keep, tune or kill each item from the list. **Build** runs `dod.build`. A note goes to the inbox as `--category playtest`.
|
|
72
73
|
- **Ended**: history (accepted) and graveyard (killed, dropped, won't-fix); a line opens the item's History.
|
|
73
74
|
- **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.
|
|
74
75
|
|
package/dist/server/app.js
CHANGED
|
@@ -15,14 +15,15 @@ import { BOARD_SCHEMA, runModeOf, } from '../shared/board.js';
|
|
|
15
15
|
import { admit, cookieName, hostAllowed, tokenInUrl } from './auth.js';
|
|
16
16
|
import { briefError, runCli } from './cli.js';
|
|
17
17
|
import { broadcast, planRev, SESSION_TTL_MIN, subscribe, watchProject } from './events.js';
|
|
18
|
-
import { attachesUnit, CHAT_BODY_MAX, chatInput, IMAGE_EXT, talkInput, } from './chat.js';
|
|
18
|
+
import { attachesUnit, CHAT_BODY_MAX, chatInput, IMAGE_EXT, talkInput, withUploads, } from './chat.js';
|
|
19
19
|
import { attachmentOf, follow, followLog, logPart, readShown, shownShape } from './files.js';
|
|
20
20
|
import { HttpError } from './http-error.js';
|
|
21
21
|
import { isCenterMove, moveArgs, moveInput, runIds } from './moves.js';
|
|
22
|
+
import { isUpload, saveUpload, UPLOAD_MAX } from './upload.js';
|
|
22
23
|
import { addProject, listProjects, projectOf, removeProject } from './registry.js';
|
|
23
|
-
import {
|
|
24
|
+
import { allThemes } from './themes.js';
|
|
24
25
|
import { adoptRuns, busyCheck, keepProjects, sweepRuns, closeReport, forgetProject, resumeQueue, runsOf, startRun, unqueue, } from './runs.js';
|
|
25
|
-
import { acceptProposal, agentPresets, chatCard, chatOf, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startTalk, stopTalk, talkEntry, talkId, talkLive, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
26
|
+
import { acceptProposal, agentDefaults, agentPresets, chatCard, chatOf, designTalk, entryTalk, listTalks, openTalk, pickTalk, prepareTalk, startTalk, stopTalk, talkEntry, talkId, talkLive, talkSaid, talkWaits, watchTalks, writeTalk, } from './talks.js';
|
|
26
27
|
import { threadDir, threadOfEntry } from 'gcf-session';
|
|
27
28
|
const send = (res, status, body) => {
|
|
28
29
|
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
|
|
@@ -97,8 +98,34 @@ function runAgent(body) {
|
|
|
97
98
|
}
|
|
98
99
|
return pick.model || pick.effort ? pick : undefined;
|
|
99
100
|
}
|
|
100
|
-
// The Drafts whose first message goes now, `<project path> <entry>`: a second click sends none
|
|
101
|
+
// The Drafts whose first message goes now, `<project path> <entry>`: a second click sends none;
|
|
102
|
+
// the design starts that send now, `<project path> start <key>`.
|
|
101
103
|
const drafting = new Set();
|
|
104
|
+
// A design start's body: a GDD up to 5 MB, its JSON escaping on top.
|
|
105
|
+
const GDD_MAX = 5_000_000;
|
|
106
|
+
const GDD_BODY_MAX = 2 * GDD_MAX;
|
|
107
|
+
/** `item new`'s words with the id the core made in a dry run: after `new`, before the flags. */
|
|
108
|
+
export function withItemId(args, id) {
|
|
109
|
+
const at = args.indexOf('new');
|
|
110
|
+
return at < 0 ? args : [...args.slice(0, at + 1), id, ...args.slice(at + 1)];
|
|
111
|
+
}
|
|
112
|
+
/** What a design start was given: an uploaded GDD, a unit id, a subsystem, the operator's words. */
|
|
113
|
+
function startGiven(b) {
|
|
114
|
+
const f = b.file;
|
|
115
|
+
if (f !== undefined && (typeof f?.name !== 'string' || typeof f.text !== 'string'))
|
|
116
|
+
throw new HttpError(400, 'file is {name, text}');
|
|
117
|
+
if (f && Buffer.byteLength(f.text) > GDD_MAX)
|
|
118
|
+
throw new HttpError(413, 'a GDD of 5 MB at most');
|
|
119
|
+
for (const k of ['unit', 'system', 'text'])
|
|
120
|
+
if (b[k] !== undefined && typeof b[k] !== 'string')
|
|
121
|
+
throw new HttpError(400, `${k} must be text`);
|
|
122
|
+
return {
|
|
123
|
+
...(f ? { file: { name: f.name, text: f.text } } : {}),
|
|
124
|
+
...(typeof b.unit === 'string' ? { unit: b.unit } : {}),
|
|
125
|
+
...(typeof b.system === 'string' ? { system: b.system } : {}),
|
|
126
|
+
...(typeof b.text === 'string' ? { text: b.text } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
102
129
|
/** The project's HEAD commit, or null: a new commit (a move, a merge) tells an open History. */
|
|
103
130
|
const headOf = (dir) => new Promise((resolve) => execFile('git', ['rev-parse', 'HEAD'], { cwd: dir, windowsHide: true }, (e, out) => resolve(e ? null : out.trim())));
|
|
104
131
|
/** Whether the usage limit holds for the account now (decision 22): Draft waits for its reset. */
|
|
@@ -262,7 +289,7 @@ export function createApp(o) {
|
|
|
262
289
|
const routes = [
|
|
263
290
|
['GET', /^\/api\/events$/, async (_req, res) => subscribe(res)],
|
|
264
291
|
['GET', /^\/api\/projects$/, async (_req, res) => send(res, 200, await listProjects())],
|
|
265
|
-
['GET', /^\/api\/themes$/, async (_req, res) => send(res, 200, await
|
|
292
|
+
['GET', /^\/api\/themes$/, async (_req, res) => send(res, 200, await allThemes())],
|
|
266
293
|
[
|
|
267
294
|
'POST',
|
|
268
295
|
/^\/api\/projects$/,
|
|
@@ -301,6 +328,7 @@ export function createApp(o) {
|
|
|
301
328
|
board_version: o.version,
|
|
302
329
|
quota: await lastQuota(),
|
|
303
330
|
presets: agentPresets(),
|
|
331
|
+
defaults: agentDefaults(),
|
|
304
332
|
head: await headOf(p.path),
|
|
305
333
|
};
|
|
306
334
|
const board = await boardOf(p);
|
|
@@ -421,6 +449,7 @@ export function createApp(o) {
|
|
|
421
449
|
async (req, res, m) => {
|
|
422
450
|
const p = await projectOf(m[1]);
|
|
423
451
|
const body = await bodyOf(req, CHAT_BODY_MAX);
|
|
452
|
+
await withUploads(p.path, body);
|
|
424
453
|
const line = chatInput(body, await unitsFor(p, body));
|
|
425
454
|
let harness;
|
|
426
455
|
try {
|
|
@@ -518,6 +547,7 @@ export function createApp(o) {
|
|
|
518
547
|
if (!existsSync(threadDir(p.path, t)))
|
|
519
548
|
throw new HttpError(404, `no thread ${t}`);
|
|
520
549
|
const body = await bodyOf(req, CHAT_BODY_MAX);
|
|
550
|
+
await withUploads(p.path, body);
|
|
521
551
|
const line = await sendTalk(p, t, talkInput(body, await unitsFor(p, body)));
|
|
522
552
|
send(res, 202, { ok: true, ...(typeof line.id === 'string' ? { id: line.id } : {}) });
|
|
523
553
|
},
|
|
@@ -602,41 +632,75 @@ export function createApp(o) {
|
|
|
602
632
|
/^\/api\/p\/([^/]+)\/move$/,
|
|
603
633
|
async (req, res, m) => {
|
|
604
634
|
const p = await projectOf(m[1]);
|
|
605
|
-
|
|
635
|
+
// A designer's bundle comes back through a move: as large as a GDD; a picked file, as
|
|
636
|
+
// large as an attachment.
|
|
637
|
+
const body = await bodyOf(req, Math.max(GDD_BODY_MAX, UPLOAD_MAX + 100_000));
|
|
606
638
|
const domain = isCenterMove(body.cmd)
|
|
607
639
|
? undefined
|
|
608
640
|
: (domains.get(p.name) ?? (await boardOf(p)).domain);
|
|
609
|
-
// A
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
const board = entry ? await boardOf(p) : null;
|
|
618
|
-
if (board &&
|
|
619
|
-
board.domain.new_item === body.cmd &&
|
|
620
|
-
board.inbox?.some((e) => e.id === entry))
|
|
621
|
-
body.from = entry;
|
|
622
|
-
}
|
|
623
|
-
const args = moveArgs(body, domain?.moves);
|
|
624
|
-
const run = () => cli(p, args, undefined, moveInput(body, domain?.moves));
|
|
625
|
-
// An agent's proposal made (AD-16, AD-33): its record goes with the move.
|
|
626
|
-
const { talk, id } = (body.proposal ?? {});
|
|
641
|
+
// A file the operator picked on their machine goes to the command as its written copy.
|
|
642
|
+
const uploads = [];
|
|
643
|
+
for (const f of domain?.moves[String(body.cmd)]?.fields ?? [])
|
|
644
|
+
if (f.kind === 'file' && isUpload(body[f.key])) {
|
|
645
|
+
const file = await saveUpload(p.path, body[f.key]);
|
|
646
|
+
uploads.push(path.dirname(file));
|
|
647
|
+
body[f.key] = file;
|
|
648
|
+
}
|
|
627
649
|
let r;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
650
|
+
try {
|
|
651
|
+
// A proposal of a Draft thread makes the entry's item (Board-V2-Data-Plan §2.7): the
|
|
652
|
+
// entry goes with it while it is there; a second proposal, or one after it went, has none.
|
|
653
|
+
const proposal = (body.proposal ?? {});
|
|
654
|
+
if (typeof proposal.talk === 'string' && body.from === undefined) {
|
|
655
|
+
// A thread that is not there has no entry: acceptProposal says it is not there.
|
|
656
|
+
const entry = existsSync(threadDir(p.path, talkId(proposal.talk)))
|
|
657
|
+
? talkEntry(p, proposal.talk)
|
|
658
|
+
: null;
|
|
659
|
+
const board = entry ? await boardOf(p) : null;
|
|
660
|
+
if (board &&
|
|
661
|
+
board.domain.new_item === body.cmd &&
|
|
662
|
+
board.inbox?.some((e) => e.id === entry))
|
|
663
|
+
body.from = entry;
|
|
664
|
+
}
|
|
665
|
+
let args = moveArgs(body, domain?.moves);
|
|
666
|
+
const run = () => cli(p, args, undefined, moveInput(body, domain?.moves));
|
|
667
|
+
// An agent's proposal made (AD-16, AD-33): its record goes with the move.
|
|
668
|
+
const { talk, id } = (body.proposal ?? {});
|
|
669
|
+
if (body.proposal === undefined)
|
|
670
|
+
r = await run();
|
|
671
|
+
else {
|
|
672
|
+
if (typeof talk !== 'string' || typeof id !== 'string' || !/^[\w-]+$/.test(id))
|
|
673
|
+
throw new HttpError(400, 'a proposal names its talk and its id');
|
|
674
|
+
// Only a move an agent may propose: a line planted in the chat is no proposal of one.
|
|
675
|
+
if (!domain?.moves[String(body.cmd)]?.propose)
|
|
676
|
+
throw new HttpError(400, `${String(body.cmd)} is not a move an agent proposes`);
|
|
677
|
+
// An agent's entry is the agent's (decision 32): the server says so, never the body.
|
|
678
|
+
if (body.cmd === domain?.sections.inbox?.add)
|
|
679
|
+
args = [...args, '--origin=agent'];
|
|
680
|
+
// A new item's id is the core's (decision 34): asked first, then given, so a board that
|
|
681
|
+
// stops after the item is made finds it by that id and does not make it twice.
|
|
682
|
+
if (body.cmd === domain?.new_item) {
|
|
683
|
+
const dryArgs = [...args.filter((a) => a !== '--commit'), '--dry-run'];
|
|
684
|
+
const dry = await cli(p, dryArgs, undefined, moveInput(body, domain?.moves));
|
|
685
|
+
if (!dry.ok) {
|
|
686
|
+
send(res, 200, { ok: false, out: dry.out.trim(), err: briefError(dry.err) });
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
body.id = dry.out.trim().split(/\s/)[0];
|
|
690
|
+
// Its commit names the proposal: a recovery tells it from another's of one id.
|
|
691
|
+
args = [...withItemId(args, String(body.id)), `--proposal=${talk}/${id}`];
|
|
692
|
+
}
|
|
693
|
+
const mark = body.cmd === domain?.new_item ? `${talk}/${id}` : undefined;
|
|
694
|
+
const item = typeof body.id === 'string' ? body.id : '';
|
|
695
|
+
const ids = idsOf(await boardOf(p));
|
|
696
|
+
r = await acceptProposal(p, talk, id, String(body.cmd), item, ids, run, mark);
|
|
697
|
+
broadcast({ type: 'talks', project: p.name });
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
finally {
|
|
701
|
+
// The command copied it, or it never ran: the written copy goes either way.
|
|
702
|
+
for (const dir of uploads)
|
|
703
|
+
await rm(dir, { recursive: true, force: true });
|
|
640
704
|
}
|
|
641
705
|
broadcast({ type: 'board', project: p.name });
|
|
642
706
|
send(res, 200, { ok: r.ok, out: r.out.trim(), err: briefError(r.err) });
|
|
@@ -710,6 +774,70 @@ export function createApp(o) {
|
|
|
710
774
|
send(res, created ? 201 : 200, { thread: id, created });
|
|
711
775
|
},
|
|
712
776
|
],
|
|
777
|
+
[
|
|
778
|
+
// A design start (Board-PRD §5.24): a thread of its own follows the start's skill, its
|
|
779
|
+
// first message sent at once. Each click is a thread of its own; one that is still
|
|
780
|
+
// sending refuses a second.
|
|
781
|
+
'POST',
|
|
782
|
+
/^\/api\/p\/([^/]+)\/start\/([a-z0-9][a-z0-9-]*)$/,
|
|
783
|
+
async (req, res, m) => {
|
|
784
|
+
const p = await projectOf(m[1]);
|
|
785
|
+
const body = await bodyOf(req, GDD_BODY_MAX);
|
|
786
|
+
const board = await boardOf(p);
|
|
787
|
+
chatOf(board);
|
|
788
|
+
const key = `${p.path} start ${m[2]}`;
|
|
789
|
+
if (drafting.has(key))
|
|
790
|
+
throw new HttpError(409, `${m[2]} is starting already`);
|
|
791
|
+
if (limitHolds(await lastQuota()))
|
|
792
|
+
throw new HttpError(409, 'the usage limit holds for the account: start after its reset');
|
|
793
|
+
drafting.add(key);
|
|
794
|
+
try {
|
|
795
|
+
const { id, say } = designTalk(p, board, m[2], startGiven(body));
|
|
796
|
+
await prepareTalk(p, board, id);
|
|
797
|
+
await sendTalk(p, id, { type: 'say', text: say }, board);
|
|
798
|
+
broadcast({ type: 'talks', project: p.name });
|
|
799
|
+
send(res, 201, { thread: id });
|
|
800
|
+
}
|
|
801
|
+
finally {
|
|
802
|
+
drafting.delete(key);
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
],
|
|
806
|
+
[
|
|
807
|
+
// One part of the design as its form shows it (`gcf design part`, core 0.17).
|
|
808
|
+
'GET',
|
|
809
|
+
/^\/api\/p\/([^/]+)\/design\/part$/,
|
|
810
|
+
async (_req, res, m, url) => {
|
|
811
|
+
const p = await projectOf(m[1]);
|
|
812
|
+
const [kind, name, type] = ['kind', 'name', 'type'].map((k) => url.searchParams.get(k));
|
|
813
|
+
if (!['doc', 'system', 'unit'].includes(kind ?? ''))
|
|
814
|
+
throw new HttpError(400, 'kind is doc, system or unit');
|
|
815
|
+
if (!SLUG.test(name ?? '') || (type !== null && !SLUG.test(type)))
|
|
816
|
+
throw new HttpError(400, 'name and type are lowercase hyphen slugs');
|
|
817
|
+
const args = ['gcf', 'design', 'part', String(kind), String(name), '--json'];
|
|
818
|
+
const r = await cli(p, type ? [...args, '--type', type] : args);
|
|
819
|
+
if (!r.ok)
|
|
820
|
+
throw new HttpError(400, briefError(r.err || r.out));
|
|
821
|
+
send(res, 200, jsonOf(r, 'gcf design part'));
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
[
|
|
825
|
+
// The design as one bundle a designer edits (`gcf design export`): a download.
|
|
826
|
+
'GET',
|
|
827
|
+
/^\/api\/p\/([^/]+)\/design\/export$/,
|
|
828
|
+
async (_req, res, m) => {
|
|
829
|
+
const r = await cli(await projectOf(m[1]), ['gcf', 'design', 'export']);
|
|
830
|
+
if (!r.ok)
|
|
831
|
+
throw new HttpError(500, briefError(r.err || r.out));
|
|
832
|
+
res.writeHead(200, {
|
|
833
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
834
|
+
'content-disposition': 'attachment; filename="design.md"',
|
|
835
|
+
'x-content-type-options': 'nosniff',
|
|
836
|
+
'content-security-policy': "default-src 'none'",
|
|
837
|
+
});
|
|
838
|
+
res.end(r.out);
|
|
839
|
+
},
|
|
840
|
+
],
|
|
713
841
|
[
|
|
714
842
|
'POST',
|
|
715
843
|
/^\/api\/p\/([^/]+)\/run$/,
|
package/dist/server/chat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HttpError } from './http-error.js';
|
|
2
|
+
import { saveUpload } from './upload.js';
|
|
2
3
|
/** A chat message may carry images: a body up to 10 MB. */
|
|
3
4
|
export const CHAT_BODY_MAX = 10_000_000;
|
|
4
5
|
/** The file a picture of each type is handed to the harness as. */
|
|
@@ -13,6 +14,8 @@ const BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
|
13
14
|
const TEXT_MAX = 64_000;
|
|
14
15
|
// About 5 MB of image, the most one image may be.
|
|
15
16
|
const IMAGE_MAX = 6_990_000;
|
|
17
|
+
// A picked file, as much as a picture.
|
|
18
|
+
const FILE_MAX = IMAGE_MAX;
|
|
16
19
|
const bad = (why) => new HttpError(400, `chat: ${why}`);
|
|
17
20
|
function images(v) {
|
|
18
21
|
if (v === undefined)
|
|
@@ -30,8 +33,8 @@ function images(v) {
|
|
|
30
33
|
}
|
|
31
34
|
const SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
32
35
|
/**
|
|
33
|
-
* What a message attaches (Round2-review §3): an item, a file of the project
|
|
34
|
-
* `units` (Board-PRD §5.13). They go into the message's text, as a line the agent reads: it
|
|
36
|
+
* What a message attaches (Round2-review §3): an item, a file of the project or one the operator
|
|
37
|
+
* picked on their machine, a design unit of `units` (Board-PRD §5.13). They go into the message's text, as a line the agent reads: it
|
|
35
38
|
* opens them itself.
|
|
36
39
|
*/
|
|
37
40
|
function attachLine(v, units) {
|
|
@@ -48,6 +51,9 @@ function attachLine(v, units) {
|
|
|
48
51
|
return `unit ${ref} (${units.get(ref)})`;
|
|
49
52
|
if (kind === 'unit')
|
|
50
53
|
throw bad(`no design unit ${String(ref)} on the board`);
|
|
54
|
+
// A file the operator picked on their machine, written by withUploads: its absolute path.
|
|
55
|
+
if (kind === 'upload' && typeof ref === 'string')
|
|
56
|
+
return `file ${ref}`;
|
|
51
57
|
// A project path, as the operator names it: relative, inside the project, nothing a shell
|
|
52
58
|
// would expand (`~`, `%VAR%`, `$VAR`) and no drive or scheme (`:`).
|
|
53
59
|
const file = typeof ref === 'string' ? ref.trim() : '';
|
|
@@ -58,10 +64,32 @@ function attachLine(v, units) {
|
|
|
58
64
|
!/[:%$]/.test(file) &&
|
|
59
65
|
!file.split(/[\\/]/).some((part) => part.trim() === '..'))
|
|
60
66
|
return `file ${file}`;
|
|
61
|
-
throw bad('an attachment is {kind: item, ref: <id>}, {kind: unit, ref: <id>}
|
|
67
|
+
throw bad('an attachment is {kind: item, ref: <id>}, {kind: unit, ref: <id>}, {kind: file, ref: <project path>} or {kind: file, ref: <name>, data: <base64>}');
|
|
62
68
|
});
|
|
63
69
|
return refs.length ? `\n\n[attached: ${refs.join('; ')}]` : '';
|
|
64
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A message's attachments with each file the operator picked on their machine (`{kind: file,
|
|
73
|
+
* ref: <its name>, data}`) written into the project's uploads: the agent reads it there, by its
|
|
74
|
+
* absolute path, from the project folder or a worktree alike.
|
|
75
|
+
*/
|
|
76
|
+
export async function withUploads(root, body) {
|
|
77
|
+
if (!Array.isArray(body.attach))
|
|
78
|
+
return;
|
|
79
|
+
if (body.attach.length > 10)
|
|
80
|
+
throw bad('attach is a list of up to 10');
|
|
81
|
+
body.attach = await Promise.all(body.attach.map(async (a) => {
|
|
82
|
+
// Only the server says a file is an upload: the page names a project path or sends bytes.
|
|
83
|
+
if (a?.kind === 'upload')
|
|
84
|
+
throw bad('an attachment is an item, a unit or a file');
|
|
85
|
+
if (a?.kind !== 'file' || a.data === undefined)
|
|
86
|
+
return a;
|
|
87
|
+
return {
|
|
88
|
+
kind: 'upload',
|
|
89
|
+
ref: await saveUpload(root, { name: a.ref, data: a.data }, FILE_MAX),
|
|
90
|
+
};
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
65
93
|
/** Whether a body attaches a design unit: its route reads the board's units for it. */
|
|
66
94
|
export const attachesUnit = (body) => Array.isArray(body.attach) &&
|
|
67
95
|
body.attach.some((a) => a?.kind === 'unit');
|
package/dist/server/moves.js
CHANGED
|
@@ -92,8 +92,13 @@ function fieldArgs(f, b) {
|
|
|
92
92
|
return many(b, f.key, flag);
|
|
93
93
|
if (f.kind === 'remove')
|
|
94
94
|
return remove(b, f.key, flag);
|
|
95
|
-
if (f.kind === 'ids')
|
|
96
|
-
|
|
95
|
+
if (f.kind === 'ids') {
|
|
96
|
+
const ids = idList(b, f.key, flag);
|
|
97
|
+
// One id only (a parent): a list is no value of it.
|
|
98
|
+
if (f.single && String(ids[0] ?? '').includes(','))
|
|
99
|
+
throw new HttpError(400, `${f.key} is one id`);
|
|
100
|
+
return ids;
|
|
101
|
+
}
|
|
97
102
|
if (f.kind === 'tags')
|
|
98
103
|
return tagList(b, f.key, flag);
|
|
99
104
|
if (f.kind === 'choice')
|
|
@@ -101,6 +106,8 @@ function fieldArgs(f, b) {
|
|
|
101
106
|
// Its text goes on stdin (moveInput): the file `-`.
|
|
102
107
|
if (f.stdin)
|
|
103
108
|
return (f.required ? required(b, f.key) : text(b, f.key)) ? [`--${flag}-file=-`] : [];
|
|
109
|
+
if (f.clear && b[f.key] === '')
|
|
110
|
+
return [`--${flag}=`];
|
|
104
111
|
return f.required ? [`--${flag}=${required(b, f.key)}`] : opt(b, f.key, flag);
|
|
105
112
|
}
|
|
106
113
|
/** A move by its domain form: its words with the target, then each field that goes. */
|
package/dist/server/propose.js
CHANGED
|
@@ -27,6 +27,8 @@ export function fieldSchema(f) {
|
|
|
27
27
|
break;
|
|
28
28
|
case 'text':
|
|
29
29
|
case 'longtext':
|
|
30
|
+
// An agent names a file by its path.
|
|
31
|
+
case 'file':
|
|
30
32
|
s = { type: 'string', ...(f.max ? { maxLength: f.max } : {}) };
|
|
31
33
|
break;
|
|
32
34
|
case 'choice':
|
|
@@ -37,7 +39,12 @@ export function fieldSchema(f) {
|
|
|
37
39
|
s = { type: 'array', items: { type: 'string' } };
|
|
38
40
|
break;
|
|
39
41
|
case 'ids':
|
|
40
|
-
|
|
42
|
+
// A parent is one id: a list of two is no value of it.
|
|
43
|
+
s = {
|
|
44
|
+
type: 'array',
|
|
45
|
+
items: { type: 'string', pattern: SLUG },
|
|
46
|
+
...(f.single && { maxItems: 1 }),
|
|
47
|
+
};
|
|
41
48
|
break;
|
|
42
49
|
case 'tags':
|
|
43
50
|
s = { type: 'array', items: { type: 'string', pattern: TAG } };
|