Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .agents/skills/make-bot-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const server = createServer(async (req, res) => {
return
}
if (req.method !== 'POST' || req.url !== '/wake') return res.writeHead(404).end()
if (req.headers.authorization !== `Bearer ${KEY}`) return res.writeHead(401).end()
let raw = ''
for await (const chunk of req) raw += chunk
let body
Expand Down Expand Up @@ -69,23 +68,20 @@ Keep these properties:

## 3. Write the page

`index.html` sends `POST /wake` with `Authorization: Bearer <BOT_UI_KEY>` and a JSON body.
`index.html` posts to this same-origin server at `POST /wake` with a JSON body and no key. Only the server holds `BOT_UI_KEY`.

```html
<script>
const key = sessionStorage.getItem('bot-ui-key')
async function wake(action, payload) {
await fetch('/wake', {
method: 'POST',
headers: { 'content-type': 'application/json', authorization: `Bearer ${key}` },
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ action, payload }),
})
}
</script>
```

The key in `sessionStorage` is a UI action key, not the model credential. It never reaches `dsh headless`; the CLI uses the user's stored DSH credentials. If the user does not want a key in the browser at all, bind to `127.0.0.1` and use a local browser profile, or put Tailscale Serve in front with its own identity check. State the tradeoff before choosing.

Never put a provider API key, a DSH credential, or a Tailscale auth key in the page.

## 4. Request the key
Expand All @@ -105,7 +101,6 @@ Start the server in the background with `bash`, then probe once with a harmless
```bash
node server.mjs &
curl -sS -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:8787/wake \
-H "authorization: Bearer $BOT_UI_KEY" \
-H 'content-type: application/json' \
-d '{"action":"review","payload":{"probe":true}}'
```
Expand All @@ -121,7 +116,7 @@ If `tailscale status` shows an online node, read the hostname from `tailscale st
- `http://<hostname>.<tailnet>.ts.net:<port>`
- `http://<100.x.x.x>:<port>`

Use HTTP. Do not add HTTPS unless the user asks. Bind the server to `0.0.0.0` only when the user accepts that anyone on the tailnet can reach the page, and keep the UI action key on.
Use HTTP. Do not add HTTPS unless the user asks. Bind the server to `0.0.0.0` only when the user accepts that anyone on the tailnet can reach the page. The page still posts with no key.

If Tailscale is not installed, install it:

Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/poteto-mode/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Remaining triggers:
- Before review → the **no-comments** skill (`/no-comments`).
- Shipping UI / IDE / CLI → the matching control skill (`control-cli` for CLIs and TUIs, `control-ui` for browser / Electron / web UIs). For bug fixes, reproduce first on the same surface yourself. Hand to the user only under the narrow Bug fix step 1 exception.
- Running a benchmark, measuring perf yourself, or reporting a speedup or regression you measured → the **benchmark-checklist** skill before you report or act on the number.
- Any PR-status request ("babysit this", "get it green", "address the bot comments", and most often "check on PR X" or "anything outstanding on X") → the **Babysit** playbook (`playbooks/babysit.md`). Never triggered by merely opening a PR. Declare its mode before polling. The playbook's step 1 owns the request-to-mode mapping. Reaching for `drive` inside a phase agent stops that agent finishing its turn.
- Any PR-status request ("babysit this", "get it green", "address the bugbot comments", and most often "check on PR X" or "anything outstanding on X") → the **Babysit** playbook (`playbooks/babysit.md`). Never triggered by merely opening a PR. Declare its mode before polling. The playbook's step 1 owns the request-to-mode mapping. Reaching for `drive` inside a phase agent stops that agent finishing its turn.
- Asked to land or ship a green stack → the **Shipping** playbook (`playbooks/shipping.md`). Green is not safe. Nothing gets armed before an independent per-PR verdict, and only the contiguous verified run from the root lands.
- An agentic review bot or the security review commented → skeptical posture. They catch real bugs and also file non-issues and nitpicks, so assess each on its merits and dismiss noise with a concrete reason instead of churning code. Triage fix / dismiss / ask per `references/review-bot-triage.md`.
- Broken skill mid-task → fix it in its own PR. Don't block. Don't silently work around it.
Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/poteto-mode/playbooks/babysit.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Babysitting starts when the user asks for it, which is normally once a phase or

Answer a user question mid-loop and continue. Only an explicit stop ends the loop before the active forge's stop condition. On GitHub, that is `READY` in single or stack mode, or a `WAITING`/`merge-queue` report or `COMPLETE` in queued mode. On Origin, that is the merge-ready state defined above. For a GitHub queued stack, capture the PR list bottom-to-top once and pass the same frozen list to every rearm. Revise the list only for the sanctioned follow-up PR from step 4. Append it at the end, drop the merged owner, and rearm with the corrected snapshot.
7. **Classify CI before any retrigger.** Flake or infrastructure earns one fresh build, never a job retry. One retry only. An identical second failure means it was never flake, so reclassify and read the child logs instead of retrying blind. A failure in code the diff never touches means a stale base, so check with `git merge-base --is-ancestor` before assuming flake. Report a stale base as needing a rebase instead of burning retries. Only a failure in the diff's own code gets a commit.
8. **The review bot is triaged skeptically, always.** Verify each claim against the code per `../references/review-bot-triage.md`. Fix real findings with a red-first proof in the lowest PR that owns the code, never at the tip unless the owning PR has merged. In that case, use step 4's sanctioned follow-up PR. Per step 2, upstack fixes wait for step 5's next frontier-driven push wave. Push that wave before replying so the reply cites the commit. On Origin, reply with `origin pr thread reply <thread-id> <pr> --body-file <reply-file>`. On GitHub, call `gh api --method POST "repos/<owner>/<repo>/pulls/<pr>/comments/<comment-id>/replies" --input <payload.json>` and put the reply body in the JSON file as data. Never interpolate comment text or a reply into a shell command. Dismiss noise with the concrete disproof on the thread. On GitHub, use the watcher's review-bot pass count. On Origin, derive the pass count from `origin pr thread list` and the review history. From the third pass on, lean toward dismissing documented patterns, still escalating anything touching security, auth, billing, data, or migrations rather than dismissing it yourself. Never churn code to quiet a bot.
8. **The review bot is triaged skeptically, always.** Verify each claim against the code per `../references/review-bot-triage.md`. Fix real findings with a red-first proof in the lowest PR that owns the code, never at the tip unless the owning PR has merged. In that case, use step 4's sanctioned follow-up PR. Per step 2, upstack fixes wait for step 5's next frontier-driven push wave. Push that wave before replying so the reply cites the commit. On Origin, reply with `origin pr thread reply <thread-id> <pr> --body-file <reply-file>`. On GitHub, call `gh api --method POST "repos/<owner>/<repo>/pulls/<pr>/comments/<comment-id>/replies" --input <payload.json>` and put the reply body in the JSON file as data. Never interpolate comment text or a reply into a shell command. Dismiss noise with the concrete disproof on the thread. On GitHub, use the watcher's Bugbot pass count. On Origin, derive the pass count from `origin pr thread list` and the review history. From the third pass on, lean toward dismissing documented patterns, still escalating anything touching security, auth, billing, data, or migrations rather than dismissing it yourself. Never churn code to quiet a bot.
9. **Stop at the human's line.** Owner approval is a wait, not a blocker to fix. Babysitting never authorizes merging. Only an explicit request to merge, land, ship, or merge when ready does. Route that request to Shipping. Surface the escalation and keep working the rest. After GitHub reports `READY`, a queued `WAITING`/`merge-queue` stop, or `COMPLETE`, or after Origin reports the frontier merge-ready, sweep the run's triage decisions once. Offer any team-useful dismissal pattern as a candidate entry in the shared rubric (`../references/review-bot-triage.md`) and its own PR. Never keep it only in private memory.

`drive` ends at merge-ready. Landing the stack is `playbooks/shipping.md`.
4 changes: 2 additions & 2 deletions .agents/skills/poteto-mode/playbooks/eval.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
1. **Frame.** State what variant is under test and what behavior counts as success. Write the rubric (3-6 concrete criteria) for the judge only. Hold it back from candidates.
2. **Set up sanitized environments.** Per-candidate working dir with the variant in place. Plant any context an organic task would have: a project skeleton, the skills the candidate would naturally read.
3. **Author one organic prompt.** What a user would type. No leakage of what's being measured.
4. **Spawn N parallel candidates** with `subagent` calls in one assistant message, using the `arena runners` route from `~/.agents/pstack-models.md` when one is configured. Each works in its own sanitized dir passed as `cwd`. Same prompt to each. Pass `provider`, `model`, and `reasoning_effort` only when the `subagent` tool exposes them; otherwise omit route fields.
5. **Spawn one blinded judge** with the `arena cross-judge pool` route when one is configured, otherwise a fresh `subagent` on the parent model. Judge sees outputs by sanitized label and the rubric, never a model name.
4. **Spawn N parallel candidates** on different models per the **arena** skill's Phase B. Each works in its own sanitized dir passed as `cwd`. Same prompt to each.
5. **Spawn one blinded judge** on a different model family per the **arena** skill's Phase C. Judge sees outputs by sanitized label and the rubric, never a model name.
6. **Verify the chain from session logs, not self-report.** Each candidate returns a child session id. Read it with `../scripts/session-log.sh <id>` from this playbook's directory. Do not read another project's session slug. That crosses workspace boundaries and reads private chats from unrelated projects. Look at which files each candidate actually opened. Grade chain-following from the files it really read plus the shape of the code, never from the candidate's own claims.
7. **Read every candidate output yourself** end to end. Compare to the judge's verdict. Disagreement means a model is biased or the rubric is ambiguous. Synthesize.

Expand Down
2 changes: 1 addition & 1 deletion .agents/skills/poteto-mode/playbooks/multi-phase-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Each live lane runs in its own git worktree on this machine, checked out at the
- [ ] <Deliver input only through the control skill's commands. Name the read-only diagnostics.>
- [ ] Save every screenshot to `/tmp/swarm-<pr-id>/worker-<n>/<slug>.png` and return the paths with the report.

## <Change as a verb phrase> (<PR id>)
## <Task as a verb phrase> (<PR id>)

**Depends on.** <PR id, or None.>

Expand Down
4 changes: 2 additions & 2 deletions .agents/skills/poteto-mode/playbooks/worktree-cleanup.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
### Worktree and simulator cleanup

1. Snapshot and audit. Record `df -h /`, then run `scripts/worktree-audit.sh [-b <pr-base-ref>] [repo-path]` (principle-build-the-lever). Without `-b` it checks `MERGED` against `origin/HEAD`, so pass `-b origin/<branch>` when PRs target another branch. It reads paths from `git worktree list`, never hand-typed, since a hand-typed `myrepo-worktrees/x` misses one that lives under `.dsh/worktrees/myrepo/x` or another agent's tree (principle-encode-lessons-in-structure). It classifies each worktree by size, age, merge state, uncommitted work, PR state, and the newest DSH session that touched it, then suggests a bucket. The session-log scan is slow, so background it.
1. Snapshot and audit. Record `df -h /`, then run `scripts/worktree-audit.sh [-b <pr-base-ref>] [repo-path]` (principle-build-the-lever). Without `-b` it checks `MERGED` against `origin/HEAD`, so pass `-b origin/<branch>` when PRs target another branch. It reads paths from `git worktree list`, never hand-typed, since a hand-typed `myrepo-worktrees/x` misses one that lives at `.agents/worktrees/<name>` inside the checkout (principle-encode-lessons-in-structure). It classifies each worktree by size, age, merge state, uncommitted work, PR state, and the newest DSH session that touched it, then suggests a bucket. The session-log scan is slow, so background it.
2. The bucket is advice, not permission. The pinned and active chats are the real artifact (principle-prove-it-works). Get that set from the user or sidebar and cross-check every candidate. The lever has marked `safe` a worktree the user had pinned, so the pinned set wins.
3. Verify usage before deleting. For every `verify-recent-chat` row, or anything you doubt, fan subagents out to read the session logs and report whether the session is pinned or ongoing and which worktrees it touches (principle-guard-the-context-window, logs are bulk). A pinned chat spawns arena and repro trees into sibling worktrees via background subagents, and those are in use even when their names never hit the sidebar. Pass `provider`, `model`, and `reasoning_effort` only when the `subagent` tool exposes them and `~/.agents/pstack-models.md` configures a route.
4. Pause on irreversible loss. `wip:N` is N tracked uncommitted edits. Show the diff and get a decision first, since removing a clean worktree is recoverable from its branch but uncommitted work is gone. `scratch:N` is untracked throwaway, safe to drop, but name the files. Per Autonomy, clean and merged and not-in-use proceeds. `wip` and in-use pause.
5. Prune the confirmed set. Per path, `git worktree remove --force <path>`. If the dir survives on ignored build artifacts, `rm -rf` it, then `git worktree prune`. Branch refs survive, so no commits are lost. Confirm with `df -h /` and re-list.
6. Simulators and other reclaimers. Simulators are usually the next-biggest win. `xcrun simctl --set testing delete all` (XCTestDevices clones), `xcrun simctl delete unavailable`, and `xcrun simctl runtime list` then `runtime delete <id>` for old runtimes. More when needed: Xcode `DerivedData` and `iOS DeviceSupport`, `~/Library/Application Support/DeepSeek Harness` (caches and snapshots), package caches (pnpm, uv, brew, yarn). Clear only caches the user has not said to keep.
6. Simulators and other reclaimers. Simulators are usually the next-biggest win. `xcrun simctl --set testing delete all` (XCTestDevices clones), `xcrun simctl delete unavailable`, and `xcrun simctl runtime list` then `runtime delete <id>` for old runtimes. More when needed: Xcode `DerivedData` and `iOS DeviceSupport`, `$DSH_HOME` (default `~/.dsh`, including `cache/` and `logs/`), package caches (pnpm, uv, brew, yarn). Clear only caches the user has not said to keep.

This is the one playbook that deletes user state with no code review to catch a slip, so the gates above are the review.

Expand Down
39 changes: 35 additions & 4 deletions .agents/skills/poteto-mode/scripts/session-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,45 @@
# # search the newest n sessions, default 10
# session-log.sh --all # with --list or --grep, search every project
#
# DSH stores each session as $DSH_HOME/sessions/<project-slug>/<session-id>/session*.jsonl.zstd.
# The project slug is the cwd with its leading slash removed, every "/" replaced
# by "-", wrapped in "--". Plain .jsonl logs are supported too.
# DSH stores each session as $DSH_HOME/sessions/<projectKey>/<session-id>/session*.jsonl.zstd.
# projectKey (@deepseek-ai/dsh-session-persistence-jsonl): separators (/ \ :)
# become "-", runs collapse to one "-", a code unit outside [A-Za-z0-9._-]
# or "~" becomes "~" plus 4 uppercase hex, leading hyphens are stripped
# (empty becomes "root"), then cut at 251 chars and wrapped in "--".
# /Users/you/My Projects/repo -> --Users-you-My~0020Projects-repo--.
# Plain .jsonl logs are supported too.
set -euo pipefail

home="${DSH_HOME:-$HOME/.dsh}"
sessions="$home/sessions"
slug="--$(printf '%s' "${PWD#/}" | tr '/' '-')--"

# Same directory name as dsh-session-persistence-jsonl projectKey.
project_key() {
PROJECT_KEY_CWD="$1" node -e '
const cwd = process.env.PROJECT_KEY_CWD ?? ""
if (cwd.length === 0) throw new Error("empty cwd")
let readable = ""
let separatorRun = false
for (let i = 0; i < cwd.length; i++) {
const code = cwd.charCodeAt(i)
const ch = String.fromCharCode(code)
if (ch === "/" || ch === "\\" || ch === ":") {
if (!separatorRun) readable += "-"
separatorRun = true
} else if (ch !== "~" && /^[A-Za-z0-9._-]$/.test(ch)) {
readable += ch
separatorRun = false
} else {
readable += "~" + code.toString(16).toUpperCase().padStart(4, "0")
separatorRun = false
}
}
const body = (readable.replace(/^-+/, "") || "root").slice(0, 251)
process.stdout.write("--" + body + "--")
'
}

slug="$(project_key "$PWD")"

die() { printf 'session-log: %s\n' "$*" >&2; exit 2; }

Expand Down
19 changes: 15 additions & 4 deletions .agents/skills/poteto-mode/scripts/worktree-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,19 @@ elif raw=$(gh pr list --author "@me" --state all --limit 1000 \
fi
[ -s "$prs" ] || echo "[]" > "$prs"

# DSH session logs: $DSH_HOME/sessions/<project-slug>/<session-id>/session*.jsonl.zstd.
# DSH session logs: $DSH_HOME/sessions/<projectKey>/<session-id>/session*.jsonl or session*.jsonl.zstd.
transcripts="${DSH_HOME:-$HOME/.dsh}/sessions"

# Same reader as session-log.sh: zstd -dc for .zstd, cat otherwise.
read_session_log() {
case "$1" in
*.zstd)
command -v zstd >/dev/null 2>&1 || return 1
zstd -dc "$1" 2>/dev/null
;;
*) cat "$1" ;;
esac
}
now=$(date +%s)

echo "# base: $base"
Expand Down Expand Up @@ -110,10 +121,10 @@ git worktree list --porcelain | awk '/^worktree /{print $2}' | while read -r wt;
# Most recent DSH session whose log names this worktree. Match the path
# followed by "/" or a quote so glint-482 does not match glint-482-r37.
last="-"; last_ts=0
if [ -d "$transcripts" ] && command -v zstd >/dev/null 2>&1; then
f=$(find "$transcripts" -type f -name 'session*.jsonl.zstd' -mtime -14 2>/dev/null \
if [ -d "$transcripts" ]; then
f=$(find "$transcripts" -type f \( -name 'session*.jsonl' -o -name 'session*.jsonl.zstd' \) 2>/dev/null \
| while IFS= read -r log; do
if zstd -dc "$log" 2>/dev/null | grep -q -F -e "${wt}/" -e "${wt}\""; then
if read_session_log "$log" | grep -q -F -e "${wt}/" -e "${wt}\""; then
stat "${stat_fmt[@]}" "$log" 2>/dev/null
fi
done \
Expand Down
Loading
Loading