mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-20 09:31:15 +00:00
* refactor: clean up SPA code — extract helpers, use isString, DRY Slack calls
helpers.ts:
- Extract parseAssistantEvent/parseUserEvent/formatToolHint from parseStreamEvent
- Eliminate redundant second scans for toolName and isError (captured during loop)
- Use isString() from @openrouter/spawn-shared instead of typeof checks
- Split long node:fs import across multiple lines
main.ts:
- Extract postOrUpdate() to DRY the post-vs-update pattern (was 3 copy-paste blocks)
- Add SlackClient type alias (replaces 4x InstanceType<typeof App>["client"])
- Remove unused Mapping import
- Inline REQUIRED_VARS into for loop
- Rename currentMsgTs → msgTs
- Tighten formatting throughout
spa.test.ts:
- Remove unused beforeEach import
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add biome config to SPA, fix all lint/format, add PostToolUse hook
- Add biome.json extending lint/biome.json (2-space indent, 120 line width,
useBlockStatements, expand:always, etc.)
- Fix all 36 useBlockStatements violations (braceless if/continue/return)
- Fix all format issues (line width, expand, trailing commas)
- Add biome lint+format to PostToolUse hook — runs automatically on any
.ts file edit when a biome.json is found in the file's directory
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: enforce separated type imports via biome useImportType
Add `style: "separatedType"` to the base biome config's useImportType
rule. This enforces `import type { T }` on its own line instead of
mixing `type` into value imports (`import { type T, foo }`).
Auto-fixed 21 violations across CLI (18) and SPA (3).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
2.8 KiB
JSON
32 lines
2.8 KiB
JSON
{
|
|
"env": {
|
|
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
|
|
},
|
|
"permissions": {
|
|
"defaultMode": "bypassPermissions"
|
|
},
|
|
"hooks": {
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Write|Edit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "bash -c 'INPUT=$(cat); FILE=$(echo \"$INPUT\" | jq -r \".tool_input.file_path // empty\"); [ -z \"$FILE\" ] && exit 0; DIR=$(dirname \"$FILE\"); [ ! -d \"$DIR\" ] && exit 0; GD=$(cd \"$DIR\" && git rev-parse --git-dir 2>/dev/null) || exit 0; GC=$(cd \"$DIR\" && git rev-parse --git-common-dir 2>/dev/null) || exit 0; AGD=$(cd \"$DIR\" && cd \"$GD\" && pwd); AGC=$(cd \"$DIR\" && cd \"$GC\" && pwd); if [ \"$AGD\" = \"$AGC\" ]; then echo \"BLOCKED: Edits must happen in a git worktree, not the main checkout.\" >&2; echo \"Create a worktree first: git worktree add /tmp/spawn-worktrees/FEATURE -b branch-name\" >&2; echo \"Then use absolute paths under /tmp/spawn-worktrees/FEATURE/ for all edits.\" >&2; exit 2; fi; BRANCH=$(cd \"$DIR\" && git rev-parse --abbrev-ref HEAD 2>/dev/null); if [ \"$BRANCH\" = \"main\" ]; then echo \"BLOCKED: Cannot edit on main branch, even in a worktree.\" >&2; echo \"Create a worktree with a feature branch: git worktree add /tmp/spawn-worktrees/FEATURE -b branch-name\" >&2; exit 2; fi'"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PostToolUse": [
|
|
{
|
|
"matcher": "Write|Edit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "bash -c 'FILE=\"$CLAUDE_FILE\"; if [[ \"$FILE\" == *.sh ]]; then bash -n \"$FILE\" 2>&1 || { echo \"SYNTAX ERROR in $FILE\"; exit 2; }; if grep -qn \"source \\.\\./\\|source \\./\" \"$FILE\" 2>/dev/null; then echo \"RELATIVE SOURCE detected in $FILE — breaks curl|bash execution\"; exit 2; fi; if grep -qn \"echo -e \" \"$FILE\" 2>/dev/null; then echo \"echo -e detected in $FILE — use printf instead (macOS bash 3.x compat)\"; exit 2; fi; if grep -qn \"set -.*u\" \"$FILE\" 2>/dev/null && ! grep -qn \"set -eo pipefail\" \"$FILE\" 2>/dev/null; then echo \"set -u (nounset) detected in $FILE — use set -eo pipefail instead\"; exit 2; fi; fi; if [[ \"$FILE\" == *.ts ]]; then if grep -Pn \"^\\s*//\\s*[-=*#]{10,}\\s*$\" \"$FILE\" 2>/dev/null; then echo \"BANNER COMMENT in $FILE — use // #region Name / // #endregion instead\"; exit 2; fi; DIR=$(dirname \"$FILE\"); BIOME=\"\"; if [ -f \"$DIR/biome.json\" ] || [ -f \"$DIR/biome.jsonc\" ]; then BIOME=\"$DIR\"; elif [ -f \"$DIR/../biome.json\" ] || [ -f \"$DIR/../biome.jsonc\" ]; then BIOME=\"$DIR/..\"; fi; if [ -n \"$BIOME\" ]; then cd \"$BIOME\" && bunx @biomejs/biome lint \"$FILE\" 2>&1 || { echo \"BIOME LINT FAILED for $FILE\"; exit 2; }; bunx @biomejs/biome format \"$FILE\" 2>&1 || { echo \"BIOME FORMAT FAILED for $FILE\"; exit 2; }; fi; fi'"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|