gcf-board 0.12.1 → 0.16.2
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 +15 -14
- package/dist/server/app.js +116 -7
- package/dist/server/moves.js +9 -2
- package/dist/server/propose.js +6 -1
- package/dist/server/talks.js +107 -12
- package/dist/server/themes.js +12 -2
- package/dist/shared/board.js +1 -1
- package/dist/web/assets/index-BKzKQnZ5.css +1 -0
- package/dist/web/assets/index-C9MtdvLc.js +51 -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
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
|
-
- **
|
|
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
|
@@ -20,9 +20,9 @@ import { attachmentOf, follow, followLog, logPart, readShown, shownShape } from
|
|
|
20
20
|
import { HttpError } from './http-error.js';
|
|
21
21
|
import { isCenterMove, moveArgs, moveInput, runIds } from './moves.js';
|
|
22
22
|
import { addProject, listProjects, projectOf, removeProject } from './registry.js';
|
|
23
|
-
import {
|
|
23
|
+
import { allThemes } from './themes.js';
|
|
24
24
|
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';
|
|
25
|
+
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
26
|
import { threadDir, threadOfEntry } from 'gcf-session';
|
|
27
27
|
const send = (res, status, body) => {
|
|
28
28
|
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
|
|
@@ -97,8 +97,34 @@ function runAgent(body) {
|
|
|
97
97
|
}
|
|
98
98
|
return pick.model || pick.effort ? pick : undefined;
|
|
99
99
|
}
|
|
100
|
-
// The Drafts whose first message goes now, `<project path> <entry>`: a second click sends none
|
|
100
|
+
// The Drafts whose first message goes now, `<project path> <entry>`: a second click sends none;
|
|
101
|
+
// the design starts that send now, `<project path> start <key>`.
|
|
101
102
|
const drafting = new Set();
|
|
103
|
+
// A design start's body: a GDD up to 5 MB, its JSON escaping on top.
|
|
104
|
+
const GDD_MAX = 5_000_000;
|
|
105
|
+
const GDD_BODY_MAX = 2 * GDD_MAX;
|
|
106
|
+
/** `item new`'s words with the id the core made in a dry run: after `new`, before the flags. */
|
|
107
|
+
export function withItemId(args, id) {
|
|
108
|
+
const at = args.indexOf('new');
|
|
109
|
+
return at < 0 ? args : [...args.slice(0, at + 1), id, ...args.slice(at + 1)];
|
|
110
|
+
}
|
|
111
|
+
/** What a design start was given: an uploaded GDD, a unit id, a subsystem, the operator's words. */
|
|
112
|
+
function startGiven(b) {
|
|
113
|
+
const f = b.file;
|
|
114
|
+
if (f !== undefined && (typeof f?.name !== 'string' || typeof f.text !== 'string'))
|
|
115
|
+
throw new HttpError(400, 'file is {name, text}');
|
|
116
|
+
if (f && Buffer.byteLength(f.text) > GDD_MAX)
|
|
117
|
+
throw new HttpError(413, 'a GDD of 5 MB at most');
|
|
118
|
+
for (const k of ['unit', 'system', 'text'])
|
|
119
|
+
if (b[k] !== undefined && typeof b[k] !== 'string')
|
|
120
|
+
throw new HttpError(400, `${k} must be text`);
|
|
121
|
+
return {
|
|
122
|
+
...(f ? { file: { name: f.name, text: f.text } } : {}),
|
|
123
|
+
...(typeof b.unit === 'string' ? { unit: b.unit } : {}),
|
|
124
|
+
...(typeof b.system === 'string' ? { system: b.system } : {}),
|
|
125
|
+
...(typeof b.text === 'string' ? { text: b.text } : {}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
102
128
|
/** The project's HEAD commit, or null: a new commit (a move, a merge) tells an open History. */
|
|
103
129
|
const headOf = (dir) => new Promise((resolve) => execFile('git', ['rev-parse', 'HEAD'], { cwd: dir, windowsHide: true }, (e, out) => resolve(e ? null : out.trim())));
|
|
104
130
|
/** Whether the usage limit holds for the account now (decision 22): Draft waits for its reset. */
|
|
@@ -262,7 +288,7 @@ export function createApp(o) {
|
|
|
262
288
|
const routes = [
|
|
263
289
|
['GET', /^\/api\/events$/, async (_req, res) => subscribe(res)],
|
|
264
290
|
['GET', /^\/api\/projects$/, async (_req, res) => send(res, 200, await listProjects())],
|
|
265
|
-
['GET', /^\/api\/themes$/, async (_req, res) => send(res, 200, await
|
|
291
|
+
['GET', /^\/api\/themes$/, async (_req, res) => send(res, 200, await allThemes())],
|
|
266
292
|
[
|
|
267
293
|
'POST',
|
|
268
294
|
/^\/api\/projects$/,
|
|
@@ -301,6 +327,7 @@ export function createApp(o) {
|
|
|
301
327
|
board_version: o.version,
|
|
302
328
|
quota: await lastQuota(),
|
|
303
329
|
presets: agentPresets(),
|
|
330
|
+
defaults: agentDefaults(),
|
|
304
331
|
head: await headOf(p.path),
|
|
305
332
|
};
|
|
306
333
|
const board = await boardOf(p);
|
|
@@ -602,7 +629,8 @@ export function createApp(o) {
|
|
|
602
629
|
/^\/api\/p\/([^/]+)\/move$/,
|
|
603
630
|
async (req, res, m) => {
|
|
604
631
|
const p = await projectOf(m[1]);
|
|
605
|
-
|
|
632
|
+
// A designer's bundle comes back through a move: as large as a GDD.
|
|
633
|
+
const body = await bodyOf(req, GDD_BODY_MAX);
|
|
606
634
|
const domain = isCenterMove(body.cmd)
|
|
607
635
|
? undefined
|
|
608
636
|
: (domains.get(p.name) ?? (await boardOf(p)).domain);
|
|
@@ -620,7 +648,7 @@ export function createApp(o) {
|
|
|
620
648
|
board.inbox?.some((e) => e.id === entry))
|
|
621
649
|
body.from = entry;
|
|
622
650
|
}
|
|
623
|
-
|
|
651
|
+
let args = moveArgs(body, domain?.moves);
|
|
624
652
|
const run = () => cli(p, args, undefined, moveInput(body, domain?.moves));
|
|
625
653
|
// An agent's proposal made (AD-16, AD-33): its record goes with the move.
|
|
626
654
|
const { talk, id } = (body.proposal ?? {});
|
|
@@ -633,9 +661,26 @@ export function createApp(o) {
|
|
|
633
661
|
// Only a move an agent may propose: a line planted in the chat is no proposal of one.
|
|
634
662
|
if (!domain?.moves[String(body.cmd)]?.propose)
|
|
635
663
|
throw new HttpError(400, `${String(body.cmd)} is not a move an agent proposes`);
|
|
664
|
+
// An agent's entry is the agent's (decision 32): the server says so, never the body.
|
|
665
|
+
if (body.cmd === domain?.sections.inbox?.add)
|
|
666
|
+
args = [...args, '--origin=agent'];
|
|
667
|
+
// A new item's id is the core's (decision 34): asked first, then given, so a board that
|
|
668
|
+
// stops after the item is made finds it by that id and does not make it twice.
|
|
669
|
+
if (body.cmd === domain?.new_item) {
|
|
670
|
+
const dryArgs = [...args.filter((a) => a !== '--commit'), '--dry-run'];
|
|
671
|
+
const dry = await cli(p, dryArgs, undefined, moveInput(body, domain?.moves));
|
|
672
|
+
if (!dry.ok) {
|
|
673
|
+
send(res, 200, { ok: false, out: dry.out.trim(), err: briefError(dry.err) });
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
body.id = dry.out.trim().split(/\s/)[0];
|
|
677
|
+
// Its commit names the proposal: a recovery tells it from another's of one id.
|
|
678
|
+
args = [...withItemId(args, String(body.id)), `--proposal=${talk}/${id}`];
|
|
679
|
+
}
|
|
680
|
+
const mark = body.cmd === domain?.new_item ? `${talk}/${id}` : undefined;
|
|
636
681
|
const item = typeof body.id === 'string' ? body.id : '';
|
|
637
682
|
const ids = idsOf(await boardOf(p));
|
|
638
|
-
r = await acceptProposal(p, talk, id, String(body.cmd), item, ids, run);
|
|
683
|
+
r = await acceptProposal(p, talk, id, String(body.cmd), item, ids, run, mark);
|
|
639
684
|
broadcast({ type: 'talks', project: p.name });
|
|
640
685
|
}
|
|
641
686
|
broadcast({ type: 'board', project: p.name });
|
|
@@ -710,6 +755,70 @@ export function createApp(o) {
|
|
|
710
755
|
send(res, created ? 201 : 200, { thread: id, created });
|
|
711
756
|
},
|
|
712
757
|
],
|
|
758
|
+
[
|
|
759
|
+
// A design start (Board-PRD §5.24): a thread of its own follows the start's skill, its
|
|
760
|
+
// first message sent at once. Each click is a thread of its own; one that is still
|
|
761
|
+
// sending refuses a second.
|
|
762
|
+
'POST',
|
|
763
|
+
/^\/api\/p\/([^/]+)\/start\/([a-z0-9][a-z0-9-]*)$/,
|
|
764
|
+
async (req, res, m) => {
|
|
765
|
+
const p = await projectOf(m[1]);
|
|
766
|
+
const body = await bodyOf(req, GDD_BODY_MAX);
|
|
767
|
+
const board = await boardOf(p);
|
|
768
|
+
chatOf(board);
|
|
769
|
+
const key = `${p.path} start ${m[2]}`;
|
|
770
|
+
if (drafting.has(key))
|
|
771
|
+
throw new HttpError(409, `${m[2]} is starting already`);
|
|
772
|
+
if (limitHolds(await lastQuota()))
|
|
773
|
+
throw new HttpError(409, 'the usage limit holds for the account: start after its reset');
|
|
774
|
+
drafting.add(key);
|
|
775
|
+
try {
|
|
776
|
+
const { id, say } = designTalk(p, board, m[2], startGiven(body));
|
|
777
|
+
await prepareTalk(p, board, id);
|
|
778
|
+
await sendTalk(p, id, { type: 'say', text: say }, board);
|
|
779
|
+
broadcast({ type: 'talks', project: p.name });
|
|
780
|
+
send(res, 201, { thread: id });
|
|
781
|
+
}
|
|
782
|
+
finally {
|
|
783
|
+
drafting.delete(key);
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
],
|
|
787
|
+
[
|
|
788
|
+
// One part of the design as its form shows it (`gcf design part`, core 0.17).
|
|
789
|
+
'GET',
|
|
790
|
+
/^\/api\/p\/([^/]+)\/design\/part$/,
|
|
791
|
+
async (_req, res, m, url) => {
|
|
792
|
+
const p = await projectOf(m[1]);
|
|
793
|
+
const [kind, name, type] = ['kind', 'name', 'type'].map((k) => url.searchParams.get(k));
|
|
794
|
+
if (!['doc', 'system', 'unit'].includes(kind ?? ''))
|
|
795
|
+
throw new HttpError(400, 'kind is doc, system or unit');
|
|
796
|
+
if (!SLUG.test(name ?? '') || (type !== null && !SLUG.test(type)))
|
|
797
|
+
throw new HttpError(400, 'name and type are lowercase hyphen slugs');
|
|
798
|
+
const args = ['gcf', 'design', 'part', String(kind), String(name), '--json'];
|
|
799
|
+
const r = await cli(p, type ? [...args, '--type', type] : args);
|
|
800
|
+
if (!r.ok)
|
|
801
|
+
throw new HttpError(400, briefError(r.err || r.out));
|
|
802
|
+
send(res, 200, jsonOf(r, 'gcf design part'));
|
|
803
|
+
},
|
|
804
|
+
],
|
|
805
|
+
[
|
|
806
|
+
// The design as one bundle a designer edits (`gcf design export`): a download.
|
|
807
|
+
'GET',
|
|
808
|
+
/^\/api\/p\/([^/]+)\/design\/export$/,
|
|
809
|
+
async (_req, res, m) => {
|
|
810
|
+
const r = await cli(await projectOf(m[1]), ['gcf', 'design', 'export']);
|
|
811
|
+
if (!r.ok)
|
|
812
|
+
throw new HttpError(500, briefError(r.err || r.out));
|
|
813
|
+
res.writeHead(200, {
|
|
814
|
+
'content-type': 'text/markdown; charset=utf-8',
|
|
815
|
+
'content-disposition': 'attachment; filename="design.md"',
|
|
816
|
+
'x-content-type-options': 'nosniff',
|
|
817
|
+
'content-security-policy': "default-src 'none'",
|
|
818
|
+
});
|
|
819
|
+
res.end(r.out);
|
|
820
|
+
},
|
|
821
|
+
],
|
|
713
822
|
[
|
|
714
823
|
'POST',
|
|
715
824
|
/^\/api\/p\/([^/]+)\/run$/,
|
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
|
@@ -37,7 +37,12 @@ export function fieldSchema(f) {
|
|
|
37
37
|
s = { type: 'array', items: { type: 'string' } };
|
|
38
38
|
break;
|
|
39
39
|
case 'ids':
|
|
40
|
-
|
|
40
|
+
// A parent is one id: a list of two is no value of it.
|
|
41
|
+
s = {
|
|
42
|
+
type: 'array',
|
|
43
|
+
items: { type: 'string', pattern: SLUG },
|
|
44
|
+
...(f.single && { maxItems: 1 }),
|
|
45
|
+
};
|
|
41
46
|
break;
|
|
42
47
|
case 'tags':
|
|
43
48
|
s = { type: 'array', items: { type: 'string', pattern: TAG } };
|
package/dist/server/talks.js
CHANGED
|
@@ -11,7 +11,7 @@ import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, statSyn
|
|
|
11
11
|
import os from 'node:os';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
-
import { THREAD_ID, createThread, listThreads, presetsOf, readThread, setThreadAgent, threadAgent, threadDir, threadOf, threadOfEntry, } from 'gcf-session';
|
|
14
|
+
import { THREAD_ID, createThread, defaultsOf, listThreads, presetsOf, readThread, setThreadAgent, threadAgent, threadDir, threadOf, threadOfEntry, } from 'gcf-session';
|
|
15
15
|
import { runModeOf } from '../shared/board.js';
|
|
16
16
|
import { writeAtomic } from './atomic.js';
|
|
17
17
|
import { alive } from './events.js';
|
|
@@ -31,10 +31,14 @@ const ASK = [
|
|
|
31
31
|
{ kind: 'edit', pattern: '' },
|
|
32
32
|
{ kind: 'shell', pattern: 'git *' },
|
|
33
33
|
];
|
|
34
|
+
// The files that steer an agent: a design thread that writes its files freely still asks for them.
|
|
35
|
+
const OWN_FILES = ['.claude/**', 'CLAUDE.md', 'AGENTS.md', '.ai-factory/**'].map((pattern) => ({ kind: 'edit', pattern }));
|
|
34
36
|
/** What the operator picks a model and effort from: the agent's presets (Board-PRD decision 24). */
|
|
35
37
|
export const agentPresets = () => presetsOf(process.env.GCF_SESSION_AGENT ?? DEFAULT_AGENT);
|
|
38
|
+
/** What a thread or a run runs on when neither it nor the project picks (decision 36). */
|
|
39
|
+
export const agentDefaults = () => defaultsOf(process.env.GCF_SESSION_AGENT ?? DEFAULT_AGENT);
|
|
36
40
|
/**
|
|
37
|
-
* Pick thread `t`'s model and effort (`default` or none: the agent's
|
|
41
|
+
* Pick thread `t`'s model and effort (`default` or none: the project's setting, else the agent's default); its next session
|
|
38
42
|
* takes them. A word that is not plain is a 400.
|
|
39
43
|
*/
|
|
40
44
|
export function pickTalk(p, t, body) {
|
|
@@ -111,26 +115,49 @@ function homeRules() {
|
|
|
111
115
|
return [
|
|
112
116
|
{ kind: 'read', pattern: `${home}/**` },
|
|
113
117
|
{ kind: 'search', pattern: `${home}/**` },
|
|
118
|
+
{ kind: 'edit', pattern: `${home}/**` },
|
|
114
119
|
...[...spellings].map((s) => ({ kind: 'shell', pattern: `*${s}*` })),
|
|
115
120
|
];
|
|
116
121
|
}
|
|
117
|
-
/**
|
|
118
|
-
export function
|
|
122
|
+
/** The design start a thread was opened for (Board-PRD §5.24), from the domain; none: null. */
|
|
123
|
+
export function startOf(board, start) {
|
|
124
|
+
if (!start)
|
|
125
|
+
return null;
|
|
126
|
+
const s = board.domain.starts?.[start];
|
|
127
|
+
if (!s)
|
|
128
|
+
throw new HttpError(400, `the project's core has no design start ${start}: update gcf-aif-ext`);
|
|
129
|
+
return s;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* What a thread of the project runs by (AD-5, AD-29, AD-31, AD-43), `spec.json`. A design
|
|
133
|
+
* start's thread follows its own skill, and writes the files its start names without a card:
|
|
134
|
+
* an import writes dozens of units; every other edit, git and a changing gcf command still ask.
|
|
135
|
+
*/
|
|
136
|
+
export function talkSpec(p, board, mcp, start = null) {
|
|
119
137
|
const { chat, rules } = chatOf(board);
|
|
138
|
+
const own = startOf(board, start);
|
|
120
139
|
return {
|
|
121
140
|
agent: process.env.GCF_SESSION_AGENT ?? DEFAULT_AGENT,
|
|
122
141
|
rules: {
|
|
123
142
|
deny: [...rules.deny, { kind: 'edit', pattern: '.gcf-session/**' }, ...homeRules()],
|
|
124
|
-
ask:
|
|
143
|
+
// Claude holds ask over allow: the blanket edit ask would shadow the start's edits. The
|
|
144
|
+
// agent's own instructions and settings still ask, whatever the project allows.
|
|
145
|
+
ask: [
|
|
146
|
+
...(own ? [...ASK.filter((r) => r.kind !== 'edit'), ...OWN_FILES] : ASK),
|
|
147
|
+
...chat.confirm,
|
|
148
|
+
],
|
|
125
149
|
// The center's own MCP server only proposes: the proposal card's Create is the
|
|
126
150
|
// operator's say, so the call asks no permission card before it.
|
|
127
|
-
allow: [
|
|
151
|
+
allow: [
|
|
152
|
+
{ kind: 'mcp', pattern: 'gcf' },
|
|
153
|
+
...(own?.edits ?? []).map((pattern) => ({ kind: 'edit', pattern })),
|
|
154
|
+
],
|
|
128
155
|
},
|
|
129
156
|
mcp: [mcp],
|
|
130
157
|
answerMin: board.chat?.answer_timeout_min,
|
|
131
158
|
handoffPct: board.context?.handoff_pct,
|
|
132
159
|
...(board.context?.window ? { window: board.context.window } : {}),
|
|
133
|
-
skill: chat.skill,
|
|
160
|
+
skill: own?.skill ?? chat.skill,
|
|
134
161
|
mainLock: path.join(p.path, '.gcf-session', 'runs', '.main-run.lock'),
|
|
135
162
|
// The project's model and effort: a thread that picked none runs on them.
|
|
136
163
|
pick: Object.fromEntries(['model', 'effort'].flatMap((k) => board.agent?.[k] ? [[k, board.agent[k]]] : [])),
|
|
@@ -217,11 +244,12 @@ export async function prepareTalk(p, board, t) {
|
|
|
217
244
|
const proposable = Object.fromEntries(Object.entries(board.domain.moves).filter(([, m]) => m.propose));
|
|
218
245
|
const moves = path.join(td, 'moves.json');
|
|
219
246
|
const mcp = path.join(td, 'mcp.json');
|
|
220
|
-
const
|
|
247
|
+
const rec = readThread(p.path, t);
|
|
248
|
+
const spec = talkSpec(p, board, mcp, rec.start?.id ?? null);
|
|
221
249
|
await writeAtomic(moves, `${JSON.stringify(proposable, null, 2)}\n`);
|
|
222
250
|
const server = { type: 'stdio', command: process.execPath, args: [MCP, moves] };
|
|
223
251
|
await writeAtomic(mcp, `${JSON.stringify({ mcpServers: { gcf: server } }, null, 2)}\n`);
|
|
224
|
-
await writeAtomic(path.join(td, 'context.md'), contextOf(p, board,
|
|
252
|
+
await writeAtomic(path.join(td, 'context.md'), contextOf(p, board, rec.item));
|
|
225
253
|
await writeAtomic(path.join(td, 'spec.json'), `${JSON.stringify(spec, null, 2)}\n`);
|
|
226
254
|
}
|
|
227
255
|
/**
|
|
@@ -282,6 +310,62 @@ export function entryTalk(p, entry) {
|
|
|
282
310
|
const had = threadOfEntry(p.path, entry);
|
|
283
311
|
return { id: had ?? createThread(p.path, { entry }), created: !had };
|
|
284
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* A new thread for design start `start` (Board-PRD §5.24): an uploaded GDD goes into its `att/`
|
|
315
|
+
* under a name `gcf anchor` keeps in `gcf/source/`. Returns the thread and the first message,
|
|
316
|
+
* `say` with `{file}` (the project path of that copy), `{unit}`, `{system}` and `{text}` filled in.
|
|
317
|
+
*/
|
|
318
|
+
export function designTalk(p, board, start, given) {
|
|
319
|
+
const s = startOf(board, start);
|
|
320
|
+
if (!s)
|
|
321
|
+
throw new HttpError(404, `no design start ${start}`);
|
|
322
|
+
const name = given.file ? gddName(given.file.name) : null;
|
|
323
|
+
if (s.takes === 'file' && !given.file)
|
|
324
|
+
throw new HttpError(400, `${start} takes a GDD file (.md)`);
|
|
325
|
+
if (s.takes === 'unit' && !(board.units ?? []).some((u) => u.id === given.unit))
|
|
326
|
+
throw new HttpError(400, `${start} takes a unit of the design: ${String(given.unit)}`);
|
|
327
|
+
// A subsystem of the design: one the design check reads (decision 35's draft of its purpose).
|
|
328
|
+
const systems = board.design && !('error' in board.design) ? board.design.systems : {};
|
|
329
|
+
if (s.takes === 'system' && !Object.hasOwn(systems, given.system ?? ''))
|
|
330
|
+
throw new HttpError(400, `${start} takes a subsystem of the design: ${String(given.system)}`);
|
|
331
|
+
const text = String(given.text ?? '').trim();
|
|
332
|
+
if (s.takes === 'text' && !text)
|
|
333
|
+
throw new HttpError(400, `${start} takes the change in words`);
|
|
334
|
+
const t = createThread(p.path, { start: { id: start } });
|
|
335
|
+
let file = '';
|
|
336
|
+
if (given.file && name) {
|
|
337
|
+
const att = path.join(writeDir(p, t), 'att');
|
|
338
|
+
mkdirSync(att, { recursive: true });
|
|
339
|
+
writeFileSync(path.join(att, name), given.file.text);
|
|
340
|
+
file = path.relative(p.path, path.join(att, name)).replaceAll('\\', '/');
|
|
341
|
+
}
|
|
342
|
+
const say = s.say
|
|
343
|
+
.replaceAll('{file}', file)
|
|
344
|
+
.replaceAll('{unit}', given.unit ?? '')
|
|
345
|
+
.replaceAll('{system}', given.system ?? '')
|
|
346
|
+
.replaceAll('{text}', text);
|
|
347
|
+
return { id: t, say };
|
|
348
|
+
}
|
|
349
|
+
// A GDD's name kept in gcf/source/: the board's file route shows `[\w./-]` names only.
|
|
350
|
+
const GDD_NAME = /^[\w][\w.-]*\.md$/;
|
|
351
|
+
/**
|
|
352
|
+
* An uploaded GDD's file name, made a plain one: `.md` in lower case (gcf/source/ lists `*.md`),
|
|
353
|
+
* `gdd.md` for a name with no plain letter left (`Дизайн.md`). A name that is no markdown file
|
|
354
|
+
* is a 400.
|
|
355
|
+
*/
|
|
356
|
+
export function gddName(name) {
|
|
357
|
+
const base = path.basename(String(name)).trim();
|
|
358
|
+
if (!/\.md$/i.test(base))
|
|
359
|
+
throw new HttpError(400, `a GDD is a markdown file (.md): ${name}`);
|
|
360
|
+
const plain = base
|
|
361
|
+
.slice(0, -3)
|
|
362
|
+
.replace(/[^\w.-]+/g, '-')
|
|
363
|
+
.replace(/^[-.]+|[-.]+$/g, '');
|
|
364
|
+
const file = `${/[a-z0-9]/i.test(plain) ? plain : 'gdd'}.md`;
|
|
365
|
+
if (!GDD_NAME.test(file))
|
|
366
|
+
throw new HttpError(400, `a GDD is a markdown file (.md): ${name}`);
|
|
367
|
+
return file;
|
|
368
|
+
}
|
|
285
369
|
/** The inbox entry thread `t` drafts an item from; null for any other thread. */
|
|
286
370
|
export const talkEntry = (p, t) => readThread(p.path, talkId(t)).entry ?? null;
|
|
287
371
|
const lineId = () => randomBytes(6).toString('hex');
|
|
@@ -386,7 +470,7 @@ const accepting = new Set();
|
|
|
386
470
|
* made already is made once: a second click, an edited id too, is refused (409), also when a
|
|
387
471
|
* board that stopped mid-move left its record `accepting`.
|
|
388
472
|
*/
|
|
389
|
-
export async function acceptProposal(p, t, id, move, item, ids, run) {
|
|
473
|
+
export async function acceptProposal(p, t, id, move, item, ids, run, mark) {
|
|
390
474
|
const td = writeDir(p, t);
|
|
391
475
|
const offered = eventsOf(td).find((e) => e.type === 'proposal' && e.id === id);
|
|
392
476
|
if (offered?.type !== 'proposal')
|
|
@@ -402,7 +486,13 @@ export async function acceptProposal(p, t, id, move, item, ids, run) {
|
|
|
402
486
|
const made = await settled(td, id, readRecords(td)[id], async () => ids, true);
|
|
403
487
|
if (made?.state === 'accepted')
|
|
404
488
|
throw new HttpError(409, `proposal ${id} is made already: ${made.item ?? ''}`);
|
|
405
|
-
await setRecord(td, id, {
|
|
489
|
+
await setRecord(td, id, {
|
|
490
|
+
state: 'accepting',
|
|
491
|
+
item,
|
|
492
|
+
existed: ids.has(item),
|
|
493
|
+
...(mark ? { mark } : {}),
|
|
494
|
+
at: now(),
|
|
495
|
+
});
|
|
406
496
|
const r = await run();
|
|
407
497
|
await setRecord(td, id, {
|
|
408
498
|
...(r.ok ? { state: 'accepted', item } : { state: 'refused', error: r.err || r.out }),
|
|
@@ -434,7 +524,11 @@ async function settled(td, id, rec, ids, mine = false) {
|
|
|
434
524
|
const latest = readRecords(td)[id];
|
|
435
525
|
if (latest?.state !== 'accepting' || (!mine && accepting.has(`${td} ${id}`)))
|
|
436
526
|
return latest;
|
|
437
|
-
|
|
527
|
+
// The project of a thread's folder: `<project>/.gcf-session/chats/<thread>`.
|
|
528
|
+
const projectDir = path.resolve(td, '..', '..', '..');
|
|
529
|
+
const ours = !rec.mark ||
|
|
530
|
+
git(projectDir, 'log', '-1', '--format=%H', `--grep=^GCF-Proposal: ${rec.mark}$`) !== '';
|
|
531
|
+
const made = !rec.existed && Boolean(rec.item) && board.has(rec.item ?? '') && ours;
|
|
438
532
|
const next = made
|
|
439
533
|
? { state: 'accepted', item: rec.item, at: now() }
|
|
440
534
|
: { state: 'refused', error: 'the board stopped while it was made: try again', at: now() };
|
|
@@ -535,6 +629,7 @@ async function talkOf(p, th, ids) {
|
|
|
535
629
|
title,
|
|
536
630
|
item: th.item,
|
|
537
631
|
entry: th.entry ?? null,
|
|
632
|
+
start: th.start?.id ?? null,
|
|
538
633
|
created_at: th.created_at,
|
|
539
634
|
last_at: events.at(-1)?.at ?? null,
|
|
540
635
|
cost_usd: Math.round(cost * 100) / 100,
|
package/dist/server/themes.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
// The
|
|
2
|
-
//
|
|
1
|
+
// The themes: the designer's that ship with the board (`themes/` of the package), and the
|
|
2
|
+
// operator's, one JSON file each in `<board home>/themes/<id>.json`; an own file of the same id
|
|
3
|
+
// wins. A theme sets design tokens (`--gcf-<name>` of web/tokens.css) over the
|
|
3
4
|
// built-in dark; the page checks the names, it owns the tokens. Read anew on each request.
|
|
4
5
|
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
5
6
|
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
6
8
|
import { homeDir } from './registry.js';
|
|
7
9
|
export const themesDir = () => path.join(homeDir(), 'themes');
|
|
10
|
+
// server/ in the source, dist/server/ once built: the package's themes/ either way.
|
|
11
|
+
const BUILT_IN = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? '../themes/' : '../../themes/', import.meta.url));
|
|
8
12
|
const ID_RE = /^[a-z0-9-]{1,40}$/;
|
|
9
13
|
const FILE_MAX = 64 * 1024;
|
|
10
14
|
const VALUE_MAX = 200;
|
|
@@ -73,3 +77,9 @@ export async function readThemes(dir = themesDir()) {
|
|
|
73
77
|
}
|
|
74
78
|
return themes;
|
|
75
79
|
}
|
|
80
|
+
/** The board's own themes, then the operator's; an own file replaces a built-in one of its id. */
|
|
81
|
+
export async function allThemes(own = themesDir()) {
|
|
82
|
+
const mine = await readThemes(own);
|
|
83
|
+
const ids = new Set(mine.map((t) => t.id));
|
|
84
|
+
return [...(await readThemes(BUILT_IN)).filter((t) => !ids.has(t.id)), ...mine];
|
|
85
|
+
}
|
package/dist/shared/board.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The read model of `ai-factory gcf board --json` (Methodology §11): the board refuses a schema
|
|
2
2
|
// it does not know. Types only, plus the version this board reads.
|
|
3
|
-
export const BOARD_SCHEMA =
|
|
3
|
+
export const BOARD_SCHEMA = 4;
|
|
4
4
|
// Where a project keeps files given to an item or an inbox entry (Board-PRD §5.3, §5.6): only
|
|
5
5
|
// there may the board hand out a file that is not text. One list: a later kind is one line.
|
|
6
6
|
const ATTACHED = [
|