Merge origin/main into task/14: CLAUDE.md became the AGENTS.md pointer
Rename-vs-edit conflict: task 13 (landed) moved the workflow brief to AGENTS.md leaving CLAUDE.md as a pointer, while this branch had edited the brief's work-launch section in place. Resolution: CLAUDE.md keeps main's pointer form; this branch's documentation of the branch-from-origin behaviour moved verbatim into AGENTS.md where that text now lives. agents.py and the rest auto-merged; 103 tests green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,13 +15,31 @@ BOARD_AGENT_ADAPTER=claude
|
||||
BOARD_CLAUDE_BIN=claude
|
||||
BOARD_OPENCODE_BIN=opencode
|
||||
|
||||
# The model headless agents run on — an opaque vendor-native name the
|
||||
# adapter passes through untranslated (claude: a model name or alias for
|
||||
# --model; opencode: the "provider/model-id" config key). Empty = inherit
|
||||
# the vendor's own default, i.e. whatever the CLI on this machine would
|
||||
# pick anyway. The per-intent settings beat the general one for their
|
||||
# intent only; _REVIEW covers both PR reviews and relevance checks. Work
|
||||
# agents write code; reviews just read and judge — they can ride a
|
||||
# cheaper, faster model.
|
||||
BOARD_AGENT_MODEL=
|
||||
BOARD_AGENT_MODEL_WORK=
|
||||
BOARD_AGENT_MODEL_ACT_PR=
|
||||
BOARD_AGENT_MODEL_REVIEW=
|
||||
|
||||
# Command prefixes headless agents may run in their worktree — the
|
||||
# project's test/check commands, comma-separated, in plain neutral form
|
||||
# (each adapter renders them into its vendor's permission rules; the
|
||||
# git/gh grants per launch intent are built in). Headless runs have no
|
||||
# human at a permission prompt, so a test runner missing from this list
|
||||
# is a test the work agent cannot run.
|
||||
BOARD_AGENT_COMMANDS=python3 -m unittest,python3 -m pytest
|
||||
BOARD_AGENT_COMMANDS=python3 -m unittest
|
||||
|
||||
# What counts as a definition-of-done check (the Focus view's CHECKS
|
||||
# panel) is a file, not an env var: core/checks ships a generic default,
|
||||
# and a `checks` file in manager/local/ replaces it wholesale. Format
|
||||
# (`<label>: <command regex>`) is documented in the default file itself.
|
||||
|
||||
# Where work-agent worktrees are created, relative to the repo root.
|
||||
BOARD_WORKTREES=.worktrees
|
||||
|
||||
@@ -15,14 +15,19 @@ An adapter is a directory with two executables:
|
||||
|
||||
- env in: `AGENT_PROMPT` (the full prompt), `AGENT_MODE` (the launch
|
||||
intent, below), `AGENT_COMMANDS` (the project's allowed command
|
||||
prefixes, below), `AGENT_CWD`, and the `BOARD_*` passthrough
|
||||
(`BOARD_AGENT_ID`, `BOARD_TASK`, `BOARD_PORT`) which your event bridge
|
||||
must forward with every event.
|
||||
prefixes, below), `AGENT_MODEL` (optional, below), `AGENT_CWD`, and
|
||||
the `BOARD_*` passthrough (`BOARD_AGENT_ID`, `BOARD_TASK`,
|
||||
`BOARD_PORT`) which your event bridge must forward with every event.
|
||||
- stdout is captured by the board as the job log. The prompts instruct the
|
||||
agent to end with marker lines (`NOT READY:`, `RELEVANCE REVIEW:`,
|
||||
`PR REVIEW:`, `ADDRESSED:`) — the board parses them from this output, so
|
||||
the agent's final text must reach stdout.
|
||||
- exit 0 = completed; anything else = failed.
|
||||
- The workflow brief the prompts point agents at is `AGENTS.md` at the
|
||||
repo root (`CLAUDE.md` beside it is only a compatibility pointer).
|
||||
Vendors that read `AGENTS.md` from the working directory's tree
|
||||
natively — opencode does, as does current Claude Code — pick it up in
|
||||
every worktree with no adapter work; `run` never needs to inject it.
|
||||
|
||||
### Launch intents (`AGENT_MODE`)
|
||||
|
||||
@@ -57,6 +62,17 @@ prefix-pattern based, so the translation is mechanical:
|
||||
"allow"}}` in a generated config, wildcard rules, last match wins
|
||||
(`opencode/permission_config.py`)
|
||||
|
||||
### The model (`AGENT_MODEL`) — optional
|
||||
|
||||
Absent = the vendor's own default: launch without any model argument and
|
||||
let your CLI resolve it however it normally would. When set, it is an
|
||||
opaque vendor-native model name — a claude alias, an opencode
|
||||
`provider/model-id` — that core never validates or interprets; pass it
|
||||
through untranslated (claude → `--model "$AGENT_MODEL"`, opencode → the
|
||||
generated config's `model` key). Never send your vendor an empty value:
|
||||
the board only sets the variable when a model is actually configured
|
||||
(`BOARD_AGENT_MODEL` and its per-intent overrides in `local/.env`).
|
||||
|
||||
### `wire` — wire live-session visibility into the host project
|
||||
|
||||
Called by `install.py` with the project root as argv[1] (plus `--dry-run`).
|
||||
|
||||
@@ -25,6 +25,10 @@ from pathlib import Path
|
||||
|
||||
EDIT_TOOLS = {"Edit", "Write", "MultiEdit", "NotebookEdit"}
|
||||
|
||||
# manager/ — the same distance up from core/adapters/claude/ as from a
|
||||
# local/adapters/claude/ override, so both copies resolve the same files.
|
||||
MANAGER = Path(__file__).resolve().parents[3]
|
||||
|
||||
|
||||
def _txt(value, cap=600):
|
||||
return value[:cap] if isinstance(value, str) else ""
|
||||
@@ -51,6 +55,56 @@ def _resp_text(resp):
|
||||
return ""
|
||||
|
||||
|
||||
def check_defs():
|
||||
"""The project's definition-of-done checks: `<label>: <command regex>`
|
||||
per line, local/checks replacing core/checks wholesale — the same file
|
||||
the board serves to the Focus panel, read here for classification so
|
||||
the two never drift. (Core's config.py mirrors this parser; the bridge
|
||||
stays standalone.) Read fresh per event; must never raise."""
|
||||
for base in (MANAGER / "local", MANAGER / "core"):
|
||||
try:
|
||||
text = (base / "checks").read_text(encoding="utf-8")
|
||||
except OSError:
|
||||
continue
|
||||
defs = []
|
||||
for line in text.splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
label, sep, pattern = line.partition(":")
|
||||
label, pattern = label.strip(), pattern.strip()
|
||||
if not sep or not label or not pattern:
|
||||
continue
|
||||
try:
|
||||
defs.append((label, re.compile(pattern)))
|
||||
except re.error:
|
||||
continue
|
||||
return defs
|
||||
return []
|
||||
|
||||
|
||||
def judge(out):
|
||||
"""Generic pass/fail from a check's output — the hook payload carries
|
||||
no exit status (stdout/stderr/interrupted only), so judgment rests on
|
||||
the summaries test tools print: counted results ('3 passed',
|
||||
'1 failed', '2 errors'), lint-style broken totals, and OK/FAILED
|
||||
verdict lines. Returns (ok, summary bit); (None, '') when the output
|
||||
says nothing recognizable either way."""
|
||||
failed = re.search(r"\b\d+ (?:failed|errors?)\b", out)
|
||||
passed = re.search(r"\b\d+ passed\b", out)
|
||||
if failed:
|
||||
return False, failed.group(0) + (f", {passed.group(0)}" if passed else "")
|
||||
if passed:
|
||||
return True, passed.group(0)
|
||||
broken = re.search(r"\b(\d+) broken\b", out)
|
||||
if broken:
|
||||
return broken.group(1) == "0", broken.group(0)
|
||||
verdict = re.search(r"^(OK|FAILED)\b.*", out, re.M)
|
||||
if verdict:
|
||||
return verdict.group(1) == "OK", verdict.group(0)[:60]
|
||||
return None, ""
|
||||
|
||||
|
||||
def classify(hook, tool, tool_input, resp):
|
||||
if hook == "SessionStart":
|
||||
return {"kind": "session", "summary": "session started"}
|
||||
@@ -88,31 +142,19 @@ def classify(hook, tool, tool_input, resp):
|
||||
cmd = _txt(tool_input.get("command"), 240)
|
||||
running = hook == "PreToolUse"
|
||||
out = "" if running else _resp_text(resp)[:1200]
|
||||
kind, ok = "command", None
|
||||
if re.search(r"\bpytest\b", cmd):
|
||||
kind = "test"
|
||||
elif "lint-imports" in cmd or re.search(r"type-check|vue-tsc|\bnpm (run )?test\b|\bvitest\b", cmd):
|
||||
kind = "check"
|
||||
elif re.match(r"\s*git (commit|add|push|checkout|switch|merge|worktree)", cmd):
|
||||
kind, ok, label = "command", None, None
|
||||
for name, pattern in check_defs():
|
||||
if pattern.search(cmd):
|
||||
kind, label = "check", name
|
||||
break
|
||||
if kind == "command" and re.match(r"\s*git (commit|add|push|checkout|switch|merge|worktree)", cmd):
|
||||
kind = "git"
|
||||
|
||||
if running:
|
||||
summary = f"running: {cmd[:90]}"
|
||||
elif kind == "test":
|
||||
passed = re.search(r"(\d+) passed", out)
|
||||
failed = re.search(r"(\d+) failed", out) or re.search(r"(\d+) error", out)
|
||||
if failed:
|
||||
ok = False
|
||||
summary = f"pytest — {failed.group(0)}" + (f", {passed.group(0)}" if passed else "")
|
||||
elif passed:
|
||||
ok = True
|
||||
summary = f"pytest — {passed.group(0)}"
|
||||
else:
|
||||
summary = f"ran: {cmd[:90]}"
|
||||
elif kind == "check":
|
||||
if "broken" in out:
|
||||
ok = not re.search(r"[1-9]\d* broken", out)
|
||||
summary = f"ran: {cmd[:90]}"
|
||||
ok, bits = judge(out)
|
||||
summary = f"{label} — {bits}" if bits else f"ran: {cmd[:90]}"
|
||||
elif kind == "git":
|
||||
m = re.search(r"""-m ["']([^"']{1,90})""", cmd)
|
||||
summary = f"git: {m.group(1) if m else cmd[:80]}"
|
||||
@@ -129,7 +171,7 @@ def board_port():
|
||||
if port:
|
||||
return port
|
||||
try:
|
||||
env_file = Path(__file__).resolve().parents[3] / "local" / ".env"
|
||||
env_file = MANAGER / "local" / ".env"
|
||||
for line in env_file.read_text().splitlines():
|
||||
key, _, value = line.strip().partition("=")
|
||||
if key.strip() == "BOARD_PORT":
|
||||
@@ -139,31 +181,36 @@ def board_port():
|
||||
return port or "26071"
|
||||
|
||||
|
||||
try:
|
||||
payload = json.load(sys.stdin)
|
||||
except Exception:
|
||||
payload = {}
|
||||
def main():
|
||||
try:
|
||||
payload = json.load(sys.stdin)
|
||||
except Exception:
|
||||
payload = {}
|
||||
|
||||
tool_input = payload.get("tool_input")
|
||||
event = {
|
||||
"v": 1,
|
||||
"session": payload.get("session_id") or "unknown",
|
||||
"agent": os.environ.get("BOARD_AGENT_ID"),
|
||||
"task": os.environ.get("BOARD_TASK"),
|
||||
**classify(payload.get("hook_event_name") or "?",
|
||||
payload.get("tool_name") or "",
|
||||
tool_input if isinstance(tool_input, dict) else {},
|
||||
payload.get("tool_response")),
|
||||
}
|
||||
tool_input = payload.get("tool_input")
|
||||
event = {
|
||||
"v": 1,
|
||||
"session": payload.get("session_id") or "unknown",
|
||||
"agent": os.environ.get("BOARD_AGENT_ID"),
|
||||
"task": os.environ.get("BOARD_TASK"),
|
||||
**classify(payload.get("hook_event_name") or "?",
|
||||
payload.get("tool_name") or "",
|
||||
tool_input if isinstance(tool_input, dict) else {},
|
||||
payload.get("tool_response")),
|
||||
}
|
||||
|
||||
try:
|
||||
request = urllib.request.Request(
|
||||
f"http://127.0.0.1:{board_port()}/api/events",
|
||||
data=json.dumps(event).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
urllib.request.urlopen(request, timeout=1).read()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
request = urllib.request.Request(
|
||||
f"http://127.0.0.1:{board_port()}/api/events",
|
||||
data=json.dumps(event).encode("utf-8"),
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
urllib.request.urlopen(request, timeout=1).read()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
sys.exit(0)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
# (see core/adapters/README.md)
|
||||
# AGENT_COMMANDS comma-separated neutral command prefixes the
|
||||
# project lets agents run (tests/checks)
|
||||
# AGENT_MODEL optional; a claude model name/alias passed
|
||||
# through as --model. Absent = the CLI's own
|
||||
# resolution (user settings), untouched.
|
||||
# AGENT_CWD working directory (already set as cwd by the board)
|
||||
# BOARD_* passthrough for the event bridge
|
||||
# stdout: captured by the board as the job log; the closing report's
|
||||
@@ -25,12 +28,20 @@ BIN="${BOARD_CLAUDE_BIN:-claude}"
|
||||
MODE="${AGENT_MODE:-work}"
|
||||
SETTINGS="$(python3 "$HERE/hook_settings.py" "$MODE")"
|
||||
|
||||
# The ${arr[@]+...} expansion keeps set -u happy on bash 3.2 when unset.
|
||||
MODEL_ARGS=()
|
||||
if [ -n "${AGENT_MODEL:-}" ]; then
|
||||
MODEL_ARGS=(--model "$AGENT_MODEL")
|
||||
fi
|
||||
|
||||
if [ "$MODE" = "review" ]; then
|
||||
exec "$BIN" -p "$AGENT_PROMPT" --settings "$SETTINGS" \
|
||||
${MODEL_ARGS[@]+"${MODEL_ARGS[@]}"} \
|
||||
--permission-mode default \
|
||||
--disallowedTools Edit Write NotebookEdit
|
||||
else
|
||||
# work and act-pr both mutate the worktree; the allowlist differs.
|
||||
exec "$BIN" -p "$AGENT_PROMPT" --settings "$SETTINGS" \
|
||||
${MODEL_ARGS[@]+"${MODEL_ARGS[@]}"} \
|
||||
--permission-mode acceptEdits
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Print the opencode config JSON for one headless launch: the permission
|
||||
rules for the launch's intent.
|
||||
rules for the launch's intent, plus the model when the board configured one.
|
||||
|
||||
Usage: permission_config.py [work|act-pr|review]
|
||||
|
||||
@@ -21,6 +21,10 @@ and never a blanket allow: the worktree is isolated, the shell is not.
|
||||
The project's test/check commands arrive in AGENT_COMMANDS as comma-
|
||||
separated neutral command prefixes (set BOARD_AGENT_COMMANDS in
|
||||
local/.env); here each becomes "<prefix>" and "<prefix> *" allow rules.
|
||||
|
||||
AGENT_MODEL, when set, becomes the config's top-level "model" key —
|
||||
opencode's "provider/model-id" form (opencode.ai/docs/config), passed
|
||||
through untranslated. Absent = no key, opencode's own resolution applies.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
@@ -56,17 +60,21 @@ def bash_rules(mode: str, commands: list[str]) -> dict:
|
||||
return rules
|
||||
|
||||
|
||||
def build_config(mode: str, commands: list[str]) -> dict:
|
||||
return {
|
||||
def build_config(mode: str, commands: list[str], model: str = "") -> dict:
|
||||
config = {
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"permission": {
|
||||
"edit": "deny" if mode == "review" else "allow",
|
||||
"bash": bash_rules(mode, commands),
|
||||
},
|
||||
}
|
||||
if model:
|
||||
config["model"] = model
|
||||
return config
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mode = sys.argv[1] if len(sys.argv) > 1 else "work"
|
||||
commands = split_commands(os.environ.get("AGENT_COMMANDS", ""))
|
||||
print(json.dumps(build_config(mode, commands)))
|
||||
model = os.environ.get("AGENT_MODEL", "").strip()
|
||||
print(json.dumps(build_config(mode, commands, model)))
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
# (see core/adapters/README.md)
|
||||
# AGENT_COMMANDS comma-separated neutral command prefixes the
|
||||
# project lets agents run (tests/checks)
|
||||
# AGENT_MODEL optional; opencode's "provider/model-id" form,
|
||||
# set as the generated config's model key.
|
||||
# Absent = opencode's own resolution, untouched.
|
||||
# AGENT_CWD working directory (already set as cwd by the board)
|
||||
# BOARD_* passthrough for the event bridge
|
||||
# stdout: captured by the board as the job log; `opencode run` prints
|
||||
|
||||
+24
-12
@@ -81,6 +81,9 @@ def _agent_public(record: dict) -> dict:
|
||||
("id", "task", "branch", "worktree", "status", "rc", "started", "session")}
|
||||
public["mode"] = record.get("mode", "work")
|
||||
public["name"] = record.get("name")
|
||||
# The model the launch was actually given; None = inherited the
|
||||
# vendor's own default. Honesty for the Sessions/Focus views.
|
||||
public["model"] = record.get("model")
|
||||
return public
|
||||
|
||||
|
||||
@@ -111,9 +114,11 @@ def _launch(mode: str, prompt: str, cwd: Path, agent_id: str, filename: str, log
|
||||
|
||||
The adapter contract: `run` gets AGENT_PROMPT, AGENT_MODE (the intent:
|
||||
work = mutate and commit, act-pr = work + push, review = read-only +
|
||||
post PR verdicts) and AGENT_COMMANDS (the project's runnable command
|
||||
prefixes) plus the BOARD_* passthrough for its event bridge; its
|
||||
stdout is the job log; exit 0 = completed.
|
||||
post PR verdicts), AGENT_COMMANDS (the project's runnable command
|
||||
prefixes) and AGENT_MODEL (the configured model, when there is one)
|
||||
plus the BOARD_* passthrough for its event bridge; its stdout is the
|
||||
job log; exit 0 = completed. Returns (proc, log_file, model) with
|
||||
model = '' when the launch inherits the vendor default.
|
||||
"""
|
||||
adapter = config.adapter_dir()
|
||||
if adapter is None:
|
||||
@@ -130,6 +135,13 @@ def _launch(mode: str, prompt: str, cwd: Path, agent_id: str, filename: str, log
|
||||
"BOARD_TASK": filename,
|
||||
"BOARD_PORT": str(state.serve_port),
|
||||
})
|
||||
model = config.agent_model(mode)
|
||||
if model:
|
||||
env["AGENT_MODEL"] = model
|
||||
else:
|
||||
# Inherit = the variable is simply absent. Popping also stops a
|
||||
# stray AGENT_MODEL in the board's own environment leaking through.
|
||||
env.pop("AGENT_MODEL", None)
|
||||
log_file = log_path.open("wb")
|
||||
try:
|
||||
proc = subprocess.Popen(
|
||||
@@ -138,7 +150,7 @@ def _launch(mode: str, prompt: str, cwd: Path, agent_id: str, filename: str, log
|
||||
except OSError as exc:
|
||||
log_file.close()
|
||||
raise ValueError(f"could not launch adapter {adapter}: {exc}")
|
||||
return proc, log_file
|
||||
return proc, log_file, model
|
||||
|
||||
|
||||
def _fresh_branch_point() -> tuple[str | None, str | None]:
|
||||
@@ -229,7 +241,7 @@ def start_agent(filename: str, stage: str) -> dict:
|
||||
|
||||
prompt = config.prompt("work.md").format(
|
||||
branch=branch, filename=filename, body=task["body"])
|
||||
proc, log_file = _launch("work", prompt, worktree, agent_id, filename, log_path)
|
||||
proc, log_file, model = _launch("work", prompt, worktree, agent_id, filename, log_path)
|
||||
|
||||
name = _pick_name(stem)
|
||||
record = {
|
||||
@@ -237,7 +249,7 @@ def start_agent(filename: str, stage: str) -> dict:
|
||||
"worktree": str(worktree), "base": base, "status": "running",
|
||||
"rc": None, "started": time.time(), "session": None,
|
||||
"log": str(log_path), "proc": proc, "origin": stage, "mode": "work",
|
||||
"name": name,
|
||||
"name": name, "model": model or None,
|
||||
}
|
||||
with state.LOCK:
|
||||
state.AGENTS[agent_id] = record
|
||||
@@ -266,14 +278,14 @@ def start_review(filename: str, stage: str) -> dict:
|
||||
|
||||
prompt = config.prompt("review.md").format(
|
||||
stage=stage, filename=filename, body=task["body"])
|
||||
proc, log_file = _launch("review", prompt, config.REPO, agent_id, filename, log_path)
|
||||
proc, log_file, model = _launch("review", prompt, config.REPO, agent_id, filename, log_path)
|
||||
|
||||
name = _pick_name(filename)
|
||||
record = {
|
||||
"id": agent_id, "task": filename, "branch": None, "worktree": None,
|
||||
"base": None, "status": "running", "rc": None, "started": time.time(),
|
||||
"session": None, "log": str(log_path), "proc": proc,
|
||||
"origin": stage, "mode": "review", "name": name,
|
||||
"origin": stage, "mode": "review", "name": name, "model": model or None,
|
||||
}
|
||||
with state.LOCK:
|
||||
state.AGENTS[agent_id] = record
|
||||
@@ -399,13 +411,13 @@ def start_pr_review(filename: str, stage: str) -> dict:
|
||||
|
||||
prompt = config.prompt("review-pr.md").format(
|
||||
filename=filename, pr=task["pr"], branch=branch, body=task["body"])
|
||||
proc, log_file = _launch("review", prompt, config.REPO, agent_id, filename, log_path)
|
||||
proc, log_file, model = _launch("review", prompt, config.REPO, agent_id, filename, log_path)
|
||||
|
||||
record = {
|
||||
"id": agent_id, "task": filename, "branch": branch, "worktree": None,
|
||||
"base": None, "status": "running", "rc": None, "started": time.time(),
|
||||
"session": None, "log": str(log_path), "proc": proc,
|
||||
"origin": stage, "mode": "review", "name": name,
|
||||
"origin": stage, "mode": "review", "name": name, "model": model or None,
|
||||
}
|
||||
with state.LOCK:
|
||||
state.AGENTS[agent_id] = record
|
||||
@@ -450,14 +462,14 @@ def start_pr_fix(filename: str, stage: str) -> dict:
|
||||
prompt = config.prompt("act-pr.md").format(
|
||||
filename=filename, branch=branch, pr=task["pr"], body=task["body"])
|
||||
# act-pr is the one intent allowed to push: the PR must update.
|
||||
proc, log_file = _launch("act-pr", prompt, worktree, agent_id, filename, log_path)
|
||||
proc, log_file, model = _launch("act-pr", prompt, worktree, agent_id, filename, log_path)
|
||||
|
||||
record = {
|
||||
"id": agent_id, "task": filename, "branch": branch,
|
||||
"worktree": str(worktree), "base": None, "status": "running",
|
||||
"rc": None, "started": time.time(), "session": None,
|
||||
"log": str(log_path), "proc": proc, "origin": stage, "mode": "work",
|
||||
"name": name,
|
||||
"name": name, "model": model or None,
|
||||
}
|
||||
with state.LOCK:
|
||||
state.AGENTS[agent_id] = record
|
||||
|
||||
+24
-12
@@ -20,7 +20,7 @@
|
||||
--accent:#56c2d8; --calm:#a6c96f; --alarm:#e08a63; --idle:#5d757b;
|
||||
--on-accent:#0a161b; --on-calm:#141a10;
|
||||
--shadow:0 10px 24px -18px rgba(0,0,0,.9);
|
||||
--pad:14px; --gap:10px; --radius:10px; --col:296px;
|
||||
--pad:14px; --gap:10px; --radius:10px; --col:296px; --col-min:240px;
|
||||
--sans:'IBM Plex Sans',system-ui,sans-serif;
|
||||
--mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
|
||||
}
|
||||
@@ -91,7 +91,7 @@
|
||||
.view.on{display:flex}
|
||||
#view-board{flex-direction:column}
|
||||
#board{flex:1;display:flex;gap:var(--gap);align-items:stretch;padding:14px 18px;overflow-x:auto;min-height:0}
|
||||
.kcol{flex:0 0 var(--col);width:var(--col);display:flex;flex-direction:column;gap:8px;min-height:0}
|
||||
.kcol{flex:1 1 0;min-width:var(--col-min);max-width:var(--col);display:flex;flex-direction:column;gap:8px;min-height:0}
|
||||
.kcol > h2{
|
||||
margin:0;display:flex;align-items:center;gap:8px;padding:0 4px 2px;
|
||||
font-size:11px;font-weight:600;letter-spacing:.09em;text-transform:uppercase;color:var(--muted);
|
||||
@@ -1295,17 +1295,20 @@ function renderFlight() {
|
||||
}
|
||||
const events = S.events[sid] || [];
|
||||
const files = new Set(events.filter(e => e.file && e.kind === 'edit').map(e => e.file));
|
||||
const tests = events.filter(e => e.kind === 'test').length;
|
||||
const checks = events.filter(e => e.kind === 'test' || e.kind === 'check').length;
|
||||
const agent = agentFor(sid);
|
||||
const stopBtn = agent && agent.status === 'running'
|
||||
? `<button id="stopagent" class="stopbtn" data-aid="${esc(agent.id)}">Hold</button>` : '';
|
||||
const branch = agent && agent.branch ? ` · <span class="mono">${esc(agent.branch)}</span>` : '';
|
||||
// Honesty about what the run actually rode: the configured model, or
|
||||
// the vendor default it inherited. Interactive sessions say nothing.
|
||||
const model = agent ? ` · <span class="mono">${agent.model ? esc(agent.model) : 'model inherited'}</span>` : '';
|
||||
$('#fsession').innerHTML =
|
||||
`<div><div class="s-title">${esc((meta.label || sid).split(' · ')[0])}` +
|
||||
`<span class="sid">${esc(sid.slice(0, 8))}</span></div>` +
|
||||
`<div class="s-line">${meta.task ? 'on ' + esc(meta.task) + ' · ' : ''}` +
|
||||
`started ${fmtShort(meta.started)} · ${meta.count || 0} events · ` +
|
||||
`${files.size} files edited · ${tests} test runs${branch}</div></div>` +
|
||||
`${files.size} files edited · ${checks} check runs${branch}${model}</div></div>` +
|
||||
stopBtn + spark(events, meta);
|
||||
const stop = $('#stopagent');
|
||||
if (stop) stop.addEventListener('click', () => stopAgent(stop.dataset.aid));
|
||||
@@ -1490,6 +1493,7 @@ function renderFocus() {
|
||||
refBits.push(task.number ? '#' + esc(task.number) : esc(task.file));
|
||||
refBits.push(`<span class="acc">${esc((meta.label || '').split(' · ')[0])}</span>`);
|
||||
if (agent && agent.branch) refBits.push('worktree ' + esc(agent.branch));
|
||||
if (agent) refBits.push(agent.model ? esc(agent.model) : 'model inherited');
|
||||
refBits.push(esc(task.stage) + '/' + esc(task.file));
|
||||
} else {
|
||||
refBits.push(esc(sid.slice(0, 8)), 'no task attached');
|
||||
@@ -1504,19 +1508,27 @@ function renderFocus() {
|
||||
steps + act + `</div>`;
|
||||
|
||||
const rev = [...events].reverse();
|
||||
const lastTest = rev.find(e => e.kind === 'test' && !e.running);
|
||||
const lastLint = rev.find(e => e.kind === 'check' && (e.cmd || '').includes('lint-imports'));
|
||||
const lastFront = rev.find(e => e.kind === 'check' && /type-check|vitest|npm/.test(e.cmd || ''));
|
||||
const checkRow = (name, ev) => {
|
||||
if (!ev) return `<div class="check-row none"><span class="glyph">—</span><span class="name">${name}</span><span class="state">not run</span></div>`;
|
||||
if (!ev) return `<div class="check-row none"><span class="glyph">—</span><span class="name">${esc(name)}</span><span class="state">not run</span></div>`;
|
||||
const cls = ev.ok === false ? 'fail' : ev.ok === true ? 'pass' : 'none';
|
||||
const glyph = ev.ok === false ? '✕' : ev.ok === true ? '✓' : '·';
|
||||
const state = esc(ev.summary.replace(/^pytest — /, '').replace(/^ran: /, '')) + ' · ' + fmtShort(ev.ts);
|
||||
return `<div class="check-row ${cls}"><span class="glyph">${glyph}</span><span class="name">${name}</span><span class="state">${state}</span></div>`;
|
||||
const text = ev.summary.startsWith(name + ' — ')
|
||||
? ev.summary.slice(name.length + 3) : ev.summary.replace(/^ran: /, '');
|
||||
const state = esc(text) + ' · ' + fmtShort(ev.ts);
|
||||
return `<div class="check-row ${cls}"><span class="glyph">${glyph}</span><span class="name">${esc(name)}</span><span class="state">${state}</span></div>`;
|
||||
};
|
||||
// One row per project-defined check — labels and command patterns come
|
||||
// from the served checks definition (local/checks over core/checks),
|
||||
// the same file the adapter classifies against.
|
||||
const checkRows = (S.state?.checks || []).map(c => {
|
||||
let re = null;
|
||||
try { re = new RegExp(c.pattern); } catch { /* skip unparseable */ }
|
||||
const ev = re && rev.find(e => !e.running && e.cmd && re.test(e.cmd));
|
||||
return checkRow(c.label, ev);
|
||||
}).join('');
|
||||
const checksPanel = `<div class="panel"><div class="phead"><span class="label">Checks</span></div>` +
|
||||
checkRow('pytest', lastTest) + checkRow('lint-imports', lastLint) +
|
||||
checkRow('frontend', lastFront) + `</div>`;
|
||||
(checkRows || `<div class="check-row none"><span class="glyph">—</span><span class="name">no checks defined</span><span class="state"></span></div>`) +
|
||||
`</div>`;
|
||||
|
||||
let fileRows = '', fileHead = '';
|
||||
const diff = agent && S.diffCache[agent.id];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
The manager sits cleanly on top of the tasks/ directory: it reads and moves
|
||||
task files, but the tasks work as a plain folder kanban without it. See
|
||||
../CLAUDE.md for the workflow and the module map:
|
||||
../AGENTS.md for the workflow and the module map:
|
||||
|
||||
config.py paths, stages, launch configuration
|
||||
state.py shared registries, event persistence, SSE fan-out
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Definition-of-done checks — the project half of the Focus view's
|
||||
# CHECKS panel. One check per line:
|
||||
#
|
||||
# <label>: <regex matched against the commands agents run>
|
||||
#
|
||||
# The board never runs anything: the agent adapter classifies each
|
||||
# command an agent runs against these patterns, and Focus shows the last
|
||||
# matching run per row, judged pass/fail from the command's own output.
|
||||
#
|
||||
# Core ships this default; a file named `checks` in manager/local/
|
||||
# replaces it WHOLESALE (same resolution as prompts — the local file
|
||||
# wins by filename). The adapter and the browser read the same file, so
|
||||
# a label edited here flows to classification and rendering alike; keep
|
||||
# patterns in the regex dialect Python and JavaScript share. Read fresh
|
||||
# on every event and request — edits apply without a restart.
|
||||
pytest: \bpytest\b
|
||||
lint-imports: \blint-imports\b
|
||||
frontend: type-check|vue-tsc|\bnpm (run )?test\b|\bvitest\b
|
||||
+50
-2
@@ -9,6 +9,7 @@ things are* lives here. No state, no behaviour.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
@@ -92,8 +93,25 @@ ADAPTER = setting("BOARD_AGENT_ADAPTER", "claude")
|
||||
# test/check commands) — neutral, comma-separated; each adapter renders
|
||||
# them in its own permission-rule syntax. The universal git/gh grants are
|
||||
# the adapter's own knowledge; this list is the project's half.
|
||||
AGENT_COMMANDS = setting("BOARD_AGENT_COMMANDS",
|
||||
"python3 -m unittest,python3 -m pytest")
|
||||
AGENT_COMMANDS = setting("BOARD_AGENT_COMMANDS", "python3 -m unittest")
|
||||
|
||||
# Model per launch intent — an opaque vendor-native name core passes to the
|
||||
# adapter untranslated (what names mean anything is vendor knowledge). Empty
|
||||
# = inherit the vendor's own default, exactly today's behaviour. A per-intent
|
||||
# setting beats the general one; review covers PR reviews and relevance
|
||||
# checks (they share the review intent).
|
||||
AGENT_MODEL = setting("BOARD_AGENT_MODEL", "")
|
||||
AGENT_MODELS = {
|
||||
"work": setting("BOARD_AGENT_MODEL_WORK", ""),
|
||||
"act-pr": setting("BOARD_AGENT_MODEL_ACT_PR", ""),
|
||||
"review": setting("BOARD_AGENT_MODEL_REVIEW", ""),
|
||||
}
|
||||
|
||||
|
||||
def agent_model(mode: str) -> str:
|
||||
"""The model one launch intent rides — '' means inherit."""
|
||||
return AGENT_MODELS.get(mode, "") or AGENT_MODEL
|
||||
|
||||
|
||||
# GitHub plumbing: the gh CLI (stub-able for tests) and the git remote PRs
|
||||
# go to. Empty remote = auto-detect the first remote; no remote = no PRs.
|
||||
@@ -120,6 +138,36 @@ def prompt(name: str) -> str:
|
||||
return (CORE / "prompts" / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def checks() -> list[dict]:
|
||||
"""Definition-of-done checks for the Focus panel: core ships a default
|
||||
(core/checks); a local/checks replaces it wholesale, like prompts. Each
|
||||
line is `<label>: <command regex>`; invalid regexes are skipped. The
|
||||
agent adapter reads the same file to classify commands (the claude
|
||||
adapter's emit.py is standalone, so the parser is mirrored there), and
|
||||
the browser matches with the served patterns — keep them in the regex
|
||||
dialect Python and JavaScript share. Read fresh on every request."""
|
||||
for base in (LOCAL, CORE):
|
||||
path = base / "checks"
|
||||
if not path.is_file():
|
||||
continue
|
||||
entries = []
|
||||
for line in path.read_text(encoding="utf-8").splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
label, sep, pattern = line.partition(":")
|
||||
label, pattern = label.strip(), pattern.strip()
|
||||
if not sep or not label or not pattern:
|
||||
continue
|
||||
try:
|
||||
re.compile(pattern)
|
||||
except re.error:
|
||||
continue
|
||||
entries.append({"label": label, "pattern": pattern})
|
||||
return entries
|
||||
return []
|
||||
|
||||
|
||||
def adapter_dir() -> Path | None:
|
||||
"""The configured agent adapter's directory — local overrides core."""
|
||||
for base in (LOCAL / "adapters", CORE / "adapters"):
|
||||
|
||||
@@ -35,6 +35,7 @@ def state_payload() -> dict:
|
||||
"branches": github.task_branches(),
|
||||
"commands": config.commands(),
|
||||
"commandRuns": commands.public(),
|
||||
"checks": config.checks(),
|
||||
"archivedCount": taskfiles.archived_count(),
|
||||
"boardEvents": board_events,
|
||||
"now": time.time(),
|
||||
|
||||
@@ -14,7 +14,7 @@ Do this properly:
|
||||
repos/{{owner}}/{{repo}}/pulls/<number>/comments`.
|
||||
- Address each point in the code. If you disagree with a point, do not
|
||||
silently ignore it — leave it unchanged and say why in your summary.
|
||||
- Follow repo CLAUDE.md: layering rules, definition of done. Run the tests
|
||||
- Follow repo AGENTS.md: layering rules, definition of done. Run the tests
|
||||
that cover what you changed until they pass.
|
||||
- Commit in clear, reviewable commits and push the branch (`git push`) so
|
||||
the PR updates.
|
||||
|
||||
@@ -14,7 +14,7 @@ Review the PR properly:
|
||||
context, not in isolation.
|
||||
- Check the work against the task: does it do what the task asked? Is
|
||||
anything missing, wrong, or beyond scope?
|
||||
- Check it against CLAUDE.md at the repo root: layering rules, definition of
|
||||
- Check it against AGENTS.md at the repo root: layering rules, definition of
|
||||
done, testing expectations.
|
||||
|
||||
You are read-only on the working tree: make NO edits, NO commits, move
|
||||
|
||||
@@ -14,7 +14,7 @@ written? Specifically:
|
||||
written (renamed modules, replaced approaches, merged tasks)?
|
||||
- Is anything in it now wrong or misleading?
|
||||
|
||||
You are read-only: make NO edits, NO commits, move nothing. Read CLAUDE.md
|
||||
You are read-only: make NO edits, NO commits, move nothing. Read AGENTS.md
|
||||
and the code; run read-only commands (grep, git log) as needed.
|
||||
|
||||
End with a report whose FIRST line is exactly
|
||||
|
||||
@@ -4,7 +4,7 @@ You are in an isolated git worktree on branch `{branch}` created for this task.
|
||||
All your work happens here: commit to this branch, do not push, do not merge,
|
||||
and do not switch branches.
|
||||
|
||||
Read CLAUDE.md at the repo root first and follow it, including its
|
||||
Read AGENTS.md at the repo root first and follow it, including its
|
||||
definition of done — run whatever checks it names until they pass.
|
||||
|
||||
The task is `{filename}`. Its content:
|
||||
@@ -24,7 +24,7 @@ NOT READY: <one-line reason>
|
||||
followed by a bullet list of the specific questions that block the task.
|
||||
The board treats that marker as "send the task back for refinement". Only
|
||||
questions that change what should be built count — implementation details
|
||||
you can decide yourself by reading the codebase and CLAUDE.md do not.
|
||||
you can decide yourself by reading the codebase and AGENTS.md do not.
|
||||
|
||||
Rules:
|
||||
- Do NOT move, rename or edit the task file itself — the board manages its
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Reading and moving task files — the only module that touches tasks/.
|
||||
|
||||
The directory a task file sits in *is* its status (see ../CLAUDE.md). Nothing
|
||||
The directory a task file sits in *is* its status (see ../AGENTS.md). Nothing
|
||||
here knows about agents or HTTP; it is the same folder kanban you could drive
|
||||
by hand with mv.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user