From 94b725d991ca3d08d8ba8ac8bdc7ba5aebbbf669 Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Fri, 27 Nov 2026 09:15:45 +0000 Subject: [PATCH 1/6] docs: commit diff design and plan Co-Authored-By: Claude Opus 5.5 --- .../plans/2026-11-27-commit-diff.md | 59 +++++++++++++++++++ .../specs/2026-11-27-commit-diff-design.md | 43 ++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 docs/superpowers/plans/2026-11-27-commit-diff.md create mode 100644 docs/superpowers/specs/2026-11-27-commit-diff-design.md diff --git a/docs/superpowers/plans/2026-11-27-commit-diff.md b/docs/superpowers/plans/2026-11-27-commit-diff.md new file mode 100644 index 0000000..786adb1 --- /dev/null +++ b/docs/superpowers/plans/2026-11-27-commit-diff.md @@ -0,0 +1,59 @@ +# Commit diffs in the web UI — Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Show a worker's commit as a GitHub link (from a `Repo:` goal line) and as a local diff in the drawer. + +**Architecture:** The runner accepts `repo` and records its workspace in `state.json`; the skill's start recipe writes +`Repo:` into the goal; the local web server gains `GET /diff//`; the drawer gains the link and a Diff tab. + +**Tech Stack:** Python 3.11 stdlib; Markdown skill; Deno server; plain ES modules. + +**Spec:** `docs/superpowers/specs/2026-11-27-commit-diff-design.md` + +## Global Constraints + +- `repo` is `owner/name`: `^[A-Za-z0-9][A-Za-z0-9-]*/[A-Za-z0-9._-]+$`, at most 100 characters. +- A commit is the first `^Commit: ([0-9a-f]{7,40})\b` line of a memory's content; `Commit: none` is no commit. +- Link: `https://github.com//commit/`, text "View on GitHub (if pushed)", `rel="noopener noreferrer"`, + `target="_blank"`. +- `/diff`: board `^[a-z0-9]+(-[a-z0-9]+)*$`, SHA `^[0-9a-f]{7,40}$`, `view` `commit` (default) or `main`; git with no + shell, `--no-pager`, `-c core.pager=cat`, `--no-ext-diff --no-textconv`, `-C `; 10 s timeout; output + capped at 2 MiB with `truncated: true`. GET only, like `/logs`. Errors: 400 bad shape, 404 no workspace recorded / + unknown board / not a commit, 504 timeout. `deno task web` adds `--allow-run=git` and nothing else. +- Browser text through `textContent` only; no `innerHTML`. + +## Review Focus + +1. A SHA or board that is not the exact shape never reaches `git`; `view` other than the two values is 400. +2. A huge diff is cut at 2 MiB without breaking a UTF-8 sequence, and says so. +3. A board whose state has no `workspace` (runner not restarted) shows a clear message, not an error. +4. `Commit: none on …` gives neither link nor tab. + +### Task 1: Runner and skill + +**Files:** `runner/board_runner/board_file.py` (optional `repo`, validated), `runner/board_runner/cli.py` (`state["workspace"] = str(bf.workspace)` when the state is saved at start), `skills/blackboard/start.md` (goal template `Repo:` line when the file has `repo`; step 4 adds a missing `Repo:` line only), `skills/blackboard/SKILL.md` if it lists goal lines, `runner/README.md` (board file table). Tests: `runner/tests/test_board_file.py`, `runner/tests/test_cli.py`. + +- [ ] Tests: `repo = "springfall2008/batpred"` loads; absent → None; `"not a repo"` and a 101-character value → `BoardFileError` naming `repo`; after `run`, `state.json` has `workspace` equal to the board file's workspace. +- [ ] Run `cd runner && python3 -m unittest` — fail; implement; pass. +- [ ] Commit `feat(runner): repo key and the workspace in state.json`, then the skill edit as `feat(skill): Repo line in the goal`. + +### Task 2: Local `/diff` route + +**Files:** create `web/lib/diff.ts` (`serveDiff(url: URL, runnerHome: string, run?: GitRunner): Promise`, with `type GitRunner = (cwd: string, args: string[], timeoutMs: number) => Promise<{ code: number; out: Uint8Array; timedOut: boolean }>`), modify `web/server.ts` (route `/diff/`), `deno.json` (`--allow-run=git`). Tests: `tests/unit/web-server.test.ts`. + +**Produces:** `GET /diff//?view=commit|main` → 200 `{ sha, view, base: string | null, text: string, truncated: boolean }`. + +- [ ] Tests with a fake `GitRunner` and a temp runner home: bad board / SHA / view → 400 and the runner is never called; no state file or no `workspace` → 404 `{ error: 'No workspace recorded for this board: restart its board-runner' }`; `cat-file` not `commit` → 404; `view=commit` runs `show --stat --patch` with the safety flags; `view=main` resolves the first existing base and runs `diff --stat --patch ...` plus `log --oneline`; output over 2 MiB is cut at a UTF-8 boundary with `truncated: true`; a timeout → 504; POST → 405. +- [ ] One test against a real temp git repo (two commits) for both views. +- [ ] Run `deno task check && deno task test:unit` — fail; implement; pass. +- [ ] Commit `feat(web): local /diff route for a board's commits`. + +### Task 3: Drawer link and Diff tab + +**Files:** `web/public/commits.js` (pure: `commitOf(content): { sha: string; branch: string | null } | null`, `githubCommitUrl(repo, sha): string | null` (null unless `repo` matches the shape)), `web/public/status.js` (`parseStatus` gains `repo`), `web/public/drawer.js` (link under the content; a Diff tab with the two views), `web/public/style.css`, `README.md` (Web UI: the Diff tab and the `repo` key). Tests: `tests/unit/web-public.test.ts`. + +- [ ] Tests: `commitOf` for `Commit: faf6fed5 on board/x/e98ecb9f`, a 40-char SHA, `Commit: none; branch …` → null, no line → null, uppercase → null; `githubCommitUrl('springfall2008/batpred', 'faf6fed5')`; a bad repo → null; `parseStatus` reads `Repo:`. +- [ ] Run `deno task test:unit` — fail; implement; pass; `deno task check`. +- [ ] Local smoke on the local server: a fact from a live board shows the link and both diff views. +- [ ] Commit `feat(web): GitHub link and local Diff tab for a fact's commit`. diff --git a/docs/superpowers/specs/2026-11-27-commit-diff-design.md b/docs/superpowers/specs/2026-11-27-commit-diff-design.md new file mode 100644 index 0000000..2fe9f8c --- /dev/null +++ b/docs/superpowers/specs/2026-11-27-commit-diff-design.md @@ -0,0 +1,43 @@ +# Commit diffs in the web UI — design (small change) + +Status: approved in conversation, 2026-11-27. + +## Why + +Board workers commit their work on local branches and write `Commit: on ` into their facts. The person +wants to see those diffs from the web UI. The SHA is already in the database (in the fact). What a reader elsewhere +lacks is the repository it belongs to; and the commits stay local until someone pushes them. + +## What + +- **Repository in the database.** A board file may name its GitHub repository: `repo = "owner/name"` (optional). The + start recipe writes it into the goal as a `Repo: owner/name` line after `Ideas model:`. For an existing board whose + goal lacks a `Repo:` line, `start from=` adds that one line and changes nothing else: a second narrow exception to + "from= never edits an existing board", allowed because it is metadata that cannot change what the board does. + The runner accepts the key (it validates `owner/name`) and does nothing else with it. +- **View on GitHub.** A memory with a `Commit: ` line shows a "View on GitHub (if pushed)" link to + `https://github.com//commit/` when the board's goal has a `Repo:` line. Shown anywhere, to anyone. No + GitHub API call checks whether the commit exists. +- **Local Diff tab.** On the same memories, when the web UI runs on the machine with the board's workspace: a Diff tab + in the drawer with two views, "This commit" (`git show `, the default) and "All changes vs main" + (`git diff ...`, with its commit list; `` is the first of `origin/HEAD`, `origin/main`, `main`, + `master` that exists). Added lines green, removed red, hunk headers blue. + - The runner records its board's workspace in `state.json` (`workspace`). The local web server reads it from + `~/.board-runner//state.json` (or `$BOARD_RUNNER_HOME`), as the worker logs already do. Without it the tab + says to restart the runner. + - `GET /diff//?view=commit|main` on the local server: the board name and SHA must match strict shapes, + the workspace must be a directory, the SHA must name a commit (`git cat-file -t`). `git` runs without a shell, + with `--no-ext-diff --no-textconv` and `-c core.pager=cat`, a 10 s timeout and at most 2 MB of output (marked as + cut short). `deno task web` gains `--allow-run=git` only. +- Nothing is pushed and nothing about pushing changes; `Commit: none` gets neither link nor tab. + +## Approaches + +A GitHub link alone needs the branches pushed, which the person does not want by default; a local diff alone is +invisible elsewhere. The person chose both: the repository in the database so the link works anywhere once pushed, +and the local diff for the machine that has the data. + +## Left to the builder + +Module boundaries (a pure `commitOf` / `githubCommitUrl` in the browser, a `web/lib/diff.ts` beside `logs.ts`), the +JSON shape of `/diff`, and the tab's layout. From b9044b26f0ab0d328adb6075952bdaf92a1f6efc Mon Sep 17 00:00:00 2001 From: Trefor Southwell <48591903+springfall2008@users.noreply.github.com> Date: Fri, 27 Nov 2026 09:17:52 +0000 Subject: [PATCH 2/6] feat(runner): repo key and the workspace in state.json Co-Authored-By: Claude Opus 5.5 --- runner/README.md | 5 +++-- runner/board_runner/board_file.py | 15 ++++++++++++++- runner/board_runner/cli.py | 3 ++- runner/tests/test_board_file.py | 8 ++++++++ runner/tests/test_cli.py | 7 +++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/runner/README.md b/runner/README.md index 0a0d0bb..070a355 100644 --- a/runner/README.md +++ b/runner/README.md @@ -58,8 +58,8 @@ Runner state lives in `~/.board-runner//`, or under `$BOARD_RUNNER_HOME`: - `workers/-