Skip to content

Commit c852e7d

Browse files
committed
chore: adopt upstream workflow tooling
Ported from the pythinker-cli reference repo: - typos spell-check workflow with _typos.toml (tests/fixtures excluded, real names allow-listed); fixes one real comment typo it surfaced - monthly update-flake-lock workflow (flake.nix is hand-maintained) - CodeRabbit commit_status for the local merge-gate hook - worktree-status skill for auditing delegation worktrees
1 parent ebcaaa3 commit c852e7d

6 files changed

Lines changed: 220 additions & 1 deletion

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
name: worktree-status
3+
description: Audit all git worktrees in the current project. Use when the user asks about worktree status, which branches are merged, which have uncommitted changes, or which worktrees can be safely cleaned up.
4+
---
5+
6+
# worktree-status
7+
8+
Report the status of every git worktree for the current project, covering
9+
dirty state and merge status.
10+
11+
## When to use
12+
13+
- User asks "which worktrees can I clean up?"
14+
- User asks "what's the status of my worktrees / branches?"
15+
- Before batch-cleaning worktrees, to avoid losing uncommitted work
16+
17+
## Procedure
18+
19+
### 1. Pull latest main (MANDATORY)
20+
21+
You MUST pull latest main before any status checks. Without this, merge
22+
detection (both ancestry and content diff) will produce stale results and
23+
you may mistakenly conclude a branch is not merged.
24+
25+
```bash
26+
cd "$(git rev-parse --show-toplevel)" && git pull origin main
27+
```
28+
29+
### 2. Collect worktree info
30+
31+
```bash
32+
PROJECT_DIR="$(git rev-parse --show-toplevel)"
33+
34+
for wt in $(git worktree list --porcelain | grep "^worktree " | sed 's/^worktree //' | grep -v "$PROJECT_DIR$"); do
35+
branch=$(git -C "$wt" branch --show-current 2>/dev/null)
36+
[ -z "$branch" ] && branch="(detached)"
37+
name=$(basename "$wt")
38+
39+
# dirty?
40+
if [ -z "$(git -C "$wt" status --short 2>/dev/null)" ]; then
41+
dirty="clean"
42+
else
43+
dirty="DIRTY"
44+
fi
45+
46+
# merged into origin/main?
47+
# NOTE: `git merge-base --is-ancestor` does NOT detect squash-merged
48+
# branches. Always follow up with a content diff (step 3) for branches
49+
# that appear "not merged".
50+
if [ "$branch" != "(detached)" ]; then
51+
if git merge-base --is-ancestor "$branch" origin/main 2>/dev/null; then
52+
merged="merged"
53+
else
54+
merged="not merged (verify with content diff)"
55+
fi
56+
else
57+
merged="n/a"
58+
fi
59+
60+
echo ""
61+
echo "[$name] branch=$branch $dirty $merged"
62+
if [ "$dirty" = "DIRTY" ]; then
63+
git -C "$wt" status --short 2>/dev/null | sed 's/^/ /'
64+
fi
65+
done
66+
```
67+
68+
### 3. Detect squash-merged branches (content diff)
69+
70+
For any branch that shows "not merged", check whether the branch's
71+
changes are already in main. The correct method is:
72+
73+
1. Find the files the branch actually changed (relative to merge-base).
74+
2. For each changed file, compare the branch version with main.
75+
If all files are identical, the branch was squash-merged.
76+
77+
**⚠️ Do NOT use `git diff origin/main <branch>`** — that compares the
78+
two tips directly, so commits added to main *after* the branch diverged
79+
will show up as false differences.
80+
81+
```bash
82+
BRANCH="<branch>"
83+
BASE=$(git merge-base origin/main "$BRANCH")
84+
85+
# List files the branch touched
86+
FILES=$(git diff --name-only "$BASE" "$BRANCH")
87+
88+
# Compare each file between branch and current main
89+
for f in $FILES; do
90+
d=$(git diff "$BRANCH" origin/main -- "$f" | wc -l)
91+
if [ "$d" != "0" ]; then
92+
echo "$f — differs"
93+
else
94+
echo "$f — identical in main"
95+
fi
96+
done
97+
# All ✅ = squash-merged
98+
```
99+
100+
### 4. Present results
101+
102+
**Always present results as a Markdown table.** Every worktree must appear
103+
as a row. Never use abbreviated or prose-only summaries.
104+
105+
| Worktree | Branch | Dirty | Merged | Can clean? |
106+
|---|---|---|---|---|
107+
| `example-wt` | `feat-foo` | ✅ clean | ✅ squash-merged ||
108+
| `another-wt` | `fix-bar` | ⚠️ 3 files | ❌ not merged | ❌ dirty + not merged |
109+
| `detached-wt` | (detached) | ⚠️ 14 files | n/a | ❌ has uncommitted changes |
110+
111+
Column definitions:
112+
113+
- **Dirty**: `✅ clean` or `⚠️ N files`
114+
- **Merged**: `✅ merged` / `✅ squash-merged` (confirmed via content diff) / `❌ not merged` / `n/a`
115+
- **Can clean?**: `` only when merged (or squash-merged) AND clean
116+
117+
Add extra columns (e.g. notes) only when relevant.
118+
119+
### 5. Cleanup (only when asked)
120+
121+
Only clean worktrees the user explicitly approves. For each:
122+
123+
```bash
124+
NAME="<worktree-name>"
125+
git worktree remove "/path/to/$NAME"
126+
git branch -D "<branch>" # only if the branch is no longer needed
127+
```

.coderabbit.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ reviews:
1919
suggested_reviewers: false
2020
poem: false
2121
review_status: true
22+
# Commit status "CodeRabbit" on the PR head: pending while reviewing, success
23+
# when done. Consumed by .claude/hooks/coderabbit-merge-gate.sh to block
24+
# `gh pr merge` until the review of the latest push has finished.
25+
commit_status: true
2226
collapse_walkthrough: true
2327
abort_on_close: true
2428

.github/workflows/typos.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Typo checker
2+
3+
# Config: _typos.toml (excludes tests/fixtures with deliberate misspellings,
4+
# allow-lists real names like `sherif` and variant spellings).
5+
6+
on: [pull_request]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
run:
13+
name: Spell Check with Typos
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
18+
with:
19+
persist-credentials: false
20+
21+
- name: Check spelling of the entire repository
22+
uses: crate-ci/typos@80c8a4945eec0f6d464eaf9e65ed98ef085283d1 # pinned from v1.38.1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update flake.lock
2+
3+
on:
4+
schedule:
5+
# 06:00 UTC on the 1st of each month.
6+
- cron: "0 6 1 * *"
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: update-flake-lock
11+
cancel-in-progress: false
12+
13+
jobs:
14+
update-lock:
15+
name: Update Nix flake.lock
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
23+
with:
24+
persist-credentials: false
25+
26+
- name: Install Nix
27+
uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # pinned from main
28+
29+
- name: Update flake.lock and open PR
30+
uses: DeterminateSystems/update-flake-lock@5ba4a20ae344a5edd7b97ed3002219974f4d20d7 # pinned from main
31+
with:
32+
pr-title: "chore(nix): monthly flake.lock update"
33+
pr-labels: dependencies
34+
# NOTE: this PR is opened with the default GITHUB_TOKEN, which does
35+
# not trigger required status checks under branch protection. A
36+
# maintainer must push an empty commit or close+reopen the PR to fire
37+
# CI before merge. Use a fine-grained PAT/App token in a follow-up if
38+
# fully hands-off dependency PRs become necessary.
39+
branch: update-flake-lock

_typos.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Config for crate-ci/typos (CI: .github/workflows/typos.yml).
2+
# Tests and fixtures are excluded wholesale: they contain deliberate
3+
# misspellings (fuzzy-match inputs like `comand`, `buton`) and base64/id
4+
# blobs that false-positive on short tokens.
5+
6+
[files]
7+
extend-exclude = [
8+
"blackbox/",
9+
"**/test/**",
10+
"**/tests/**",
11+
"**/*.test.ts",
12+
"**/__snapshots__/**",
13+
"**/CHANGELOG.md",
14+
"pnpm-lock.yaml",
15+
]
16+
17+
[default.extend-words]
18+
# Real names / accepted spellings, not typos.
19+
sherif = "sherif" # https://github.com/QuiiBz/sherif — monorepo linter
20+
unparseable = "unparseable" # valid variant spelling used across the codebase
21+
uncatalogued = "uncatalogued" # valid British spelling
22+
mis = "mis" # hyphenated prefix in comments: mis-parses, mis-set
23+
flase = "flase" # deliberate typo example in a config-error comment
24+
nd = "nd" # ndJsonStream, `Nd` cron interval token
25+
dows = "dows" # formatDows — days-of-week (cron)
26+
fo = "fo" # `/FO` flag of Windows schtasks
27+
pn = "pn" # "PNGs" tokenized as PN by the checker

apps/pythinker-web/src/api/daemon/agentEventProjector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export interface AgentProjector {
445445
/** Project a single raw agent-core event into zero or more AppEvents. Never throws. */
446446
project(rawType: string, payload: unknown, sessionId: string, meta?: ProjectMeta): AppEvent[];
447447
/**
448-
* Bind an externally-known promptId to the next turn.startd for this session.
448+
* Bind an externally-known promptId to the next turn.started for this session.
449449
* Call this right after submitPrompt() returns, before the first turn.started arrives.
450450
*/
451451
bindNextPromptId(sessionId: string, promptId: string): void;

0 commit comments

Comments
 (0)