Repository navigation
Expand file tree
/
Copy pathJustfile
More file actions
197 lines (173 loc) · 6.55 KB
/
Copy pathJustfile
File metadata and controls
197 lines (173 loc) · 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Claude Code Workbench — Task Runner
# Usage: just --list
#
# Projects live in $WORKBENCH_PROJECTS_ROOT/<name>/ as independent directories
# (override via env var). Dispatchers below are stubs — extend with your own
# project names, or replace with whatever orchestration fits your stack.
set dotenv-load := false
projects_root := env_var_or_default("WORKBENCH_PROJECTS_ROOT", "./projects")
# List all recipes
default:
@just --list
# === TEST ===
# Run tests — `just test` runs the workbench hook suite; `just test <name>` dispatches to a project.
test project="workbench":
#!/usr/bin/env bash
set -euo pipefail
if [ "{{project}}" = "workbench" ]; then
echo "▶ Testing workbench hooks and scripts..."
just test-hooks
elif [ "{{project}}" = "all" ]; then
echo "▶ Testing workbench + all projects..."
just test-hooks
# Add project names here: just test <name>
else
echo "✗ Project '{{project}}' is not registered."
echo " Edit Justfile recipe 'test' to add dispatch for your projects."
exit 1
fi
# === LINT ===
# Lint a project (stub dispatcher — extend per your stack).
lint project="workbench":
#!/usr/bin/env bash
set -euo pipefail
if [ "{{project}}" = "workbench" ]; then
echo "▶ No active linter for workbench itself (hooks are stdlib Python)."
else
echo "✗ Project '{{project}}' is not registered."
echo " Edit Justfile recipe 'lint' to add dispatch for your projects."
exit 1
fi
# === BUILD / DEV / SETUP ===
# Build a project (stub dispatcher — extend per your stack).
build project:
#!/usr/bin/env bash
echo "✗ Project '{{project}}' has no build recipe. Edit Justfile to add one."
exit 1
# Start a dev server for a project (stub dispatcher — extend per your stack).
dev project:
#!/usr/bin/env bash
echo "✗ Project '{{project}}' has no dev recipe. Edit Justfile to add one."
exit 1
# Install dependencies of a project (stub dispatcher — extend per your stack).
setup project="workbench":
#!/usr/bin/env bash
echo "▶ '{{project}}' has no setup recipe yet. Edit Justfile to add one."
# === WORKBENCH CORE ===
# Read-only audit of the workbench (agents, hooks, git status).
audit:
python3 .claude/scripts/audit.py
# List systems registered in the memory graph (name | README | consumers | last-seen) + orphans.
tools *ARGS:
python3 .claude/scripts/just-tools.py {{ARGS}}
# Snapshot of per-scope session locks + active sentinels (C16).
locks:
python3 .claude/scripts/lock-status.py
# Run the workbench hook and script test suite (stdlib only).
test-hooks:
#!/usr/bin/env bash
set -euo pipefail
echo "▶ Testing workbench hooks (unittest discover)..."
python3 -m unittest discover -s .claude/scripts/tests -v
echo ""
echo "▶ Running script-style tests..."
python3 .claude/scripts/tests/test_pre_playwright_resources.py
# === UTILS ===
# Snapshot of machine resources (RAM/disk/load + top procs) as JSON.
resource-check:
bash .claude/scripts/resource-check.sh
# Rotate logs in .claude/logs/ larger than 5 MB.
rotate-logs:
bash .claude/scripts/rotate-logs.sh
# Quick health check of required CLI tools.
check:
#!/usr/bin/env bash
set -euo pipefail
echo "▶ Workbench health check..."
echo ""
echo "Tools:"
command -v just > /dev/null && echo " just: $(just --version)" || echo " just: MISSING"
command -v python3 > /dev/null && echo " python: $(python3 --version)" || echo " python: MISSING"
command -v git > /dev/null && echo " git: $(git --version)" || echo " git: MISSING"
command -v node > /dev/null && echo " node: $(node --version)" || echo " node: (optional)"
command -v pnpm > /dev/null && echo " pnpm: $(pnpm --version)" || echo " pnpm: (optional)"
command -v uv > /dev/null && echo " uv: $(uv --version)" || echo " uv: (optional)"
echo ""
echo "Projects root: {{projects_root}}"
if [ -d "{{projects_root}}" ]; then
for dir in {{projects_root}}/*/; do
[ -d "$dir" ] || continue
name=$(basename "$dir")
echo " - $name"
done
else
echo " (no projects dir yet — create one or set WORKBENCH_PROJECTS_ROOT)"
fi
# Tail the last 50 lines of a log file under .claude/logs/ (e.g. `just logs audit`).
logs context="":
#!/usr/bin/env bash
set -euo pipefail
DIR=".claude/logs"
if [ ! -d "$DIR" ]; then
echo "✗ Logs directory does not exist yet: $DIR"
exit 0
fi
CTX="{{context}}"
if [ -z "$CTX" ]; then
echo "▶ Available log contexts:"
ls "$DIR"/*.log 2>/dev/null | xargs -n1 basename | sed 's/\.log$//' | sort -u
exit 0
fi
FILE="$DIR/$CTX.log"
if [ ! -f "$FILE" ]; then
echo "✗ Context '$CTX' has no log in $DIR/"
echo "Available:"
ls "$DIR"/*.log 2>/dev/null | xargs -n1 basename | sed 's/\.log$//' | sort -u
exit 1
fi
tail -n 50 "$FILE"
# Show the last N sessions from the journal (default 5).
journal n="5":
#!/usr/bin/env bash
set -euo pipefail
N="{{n}}"
DIR=".claude/journal"
if [ ! -d "$DIR" ]; then
echo "✗ Journal does not exist yet: $DIR"
exit 0
fi
FILES=$(ls "$DIR"/????-??.md 2>/dev/null | sort -r || true)
if [ -z "$FILES" ]; then
echo "✗ Journal is empty."
exit 0
fi
echo "▶ Last $N journal entries:"
echo ""
awk -v n="$N" '
/^## / { if (count < n) { print; in_entry=1; count++; next } else { exit } }
/^---$/ && in_entry { print "---"; in_entry=0; next }
in_entry { print }
' $FILES
# === STAGE ===
# Stage workbench infra files (.claude, CLAUDE.md, Justfile, .gitignore) for commit.
# Projects have their own git repos — stage inside each with `git add` directly.
stage scope="workbench":
#!/usr/bin/env bash
set -euo pipefail
if [ "{{scope}}" != "workbench" ]; then
echo "✗ Scope '{{scope}}' does not apply — projects have their own repos."
echo " Example: cd {{projects_root}}/<name> && git add <files>"
exit 1
fi
paths=(".claude" "CLAUDE.md" "Justfile" ".gitignore" "README.md" "LICENSE")
existing=()
for p in "${paths[@]}"; do
[ -e "$p" ] && existing+=("$p")
done
if [ "${#existing[@]}" -eq 0 ]; then
echo "▶ Scope workbench — no paths to stage."
exit 0
fi
git add -- "${existing[@]}"
echo "▶ Staged (scope=workbench):"
git diff --cached --name-only | sed 's/^/ /' || true