claws-code 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/claws-auto.md +90 -0
- package/.claude/commands/claws-bin.md +28 -0
- package/.claude/commands/claws-cleanup.md +28 -0
- package/.claude/commands/claws-do.md +82 -0
- package/.claude/commands/claws-fix.md +40 -0
- package/.claude/commands/claws-goal.md +111 -0
- package/.claude/commands/claws-help.md +54 -0
- package/.claude/commands/claws-plan.md +103 -0
- package/.claude/commands/claws-report.md +29 -0
- package/.claude/commands/claws-status.md +37 -0
- package/.claude/commands/claws-update.md +32 -0
- package/.claude/commands/claws.md +64 -0
- package/.claude/rules/claws-default-behavior.md +76 -0
- package/.claude/settings.json +112 -0
- package/.claude/settings.local.json +19 -0
- package/.claude/skills/claws-auto-engine/SKILL.md +97 -0
- package/.claude/skills/claws-goal-tracker/SKILL.md +106 -0
- package/.claude/skills/claws-prompt-templates/SKILL.md +203 -0
- package/.claude/skills/claws-wave-lead/SKILL.md +126 -0
- package/.claude/skills/claws-wave-subworker/SKILL.md +60 -0
- package/CHANGELOG.md +1949 -0
- package/LICENSE +21 -0
- package/README.md +420 -0
- package/bin/cli.js +84 -0
- package/cli.js +223 -0
- package/docs/ARCHITECTURE.md +511 -0
- package/docs/event-protocol.md +588 -0
- package/docs/features.md +562 -0
- package/docs/guide.md +891 -0
- package/docs/index.html +716 -0
- package/docs/protocol.md +323 -0
- package/extension/.vscodeignore +15 -0
- package/extension/CHANGELOG.md +1906 -0
- package/extension/LICENSE +21 -0
- package/extension/README.md +137 -0
- package/extension/docs/features.md +424 -0
- package/extension/docs/protocol.md +197 -0
- package/extension/esbuild.mjs +25 -0
- package/extension/icon.png +0 -0
- package/extension/native/.metadata.json +10 -0
- package/extension/native/node-pty/LICENSE +69 -0
- package/extension/native/node-pty/README.md +165 -0
- package/extension/native/node-pty/lib/conpty_console_list_agent.js +16 -0
- package/extension/native/node-pty/lib/conpty_console_list_agent.js.map +1 -0
- package/extension/native/node-pty/lib/eventEmitter2.js +47 -0
- package/extension/native/node-pty/lib/eventEmitter2.js.map +1 -0
- package/extension/native/node-pty/lib/index.js +52 -0
- package/extension/native/node-pty/lib/index.js.map +1 -0
- package/extension/native/node-pty/lib/interfaces.js +7 -0
- package/extension/native/node-pty/lib/interfaces.js.map +1 -0
- package/extension/native/node-pty/lib/shared/conout.js +11 -0
- package/extension/native/node-pty/lib/shared/conout.js.map +1 -0
- package/extension/native/node-pty/lib/terminal.js +190 -0
- package/extension/native/node-pty/lib/terminal.js.map +1 -0
- package/extension/native/node-pty/lib/types.js +7 -0
- package/extension/native/node-pty/lib/types.js.map +1 -0
- package/extension/native/node-pty/lib/unixTerminal.js +346 -0
- package/extension/native/node-pty/lib/unixTerminal.js.map +1 -0
- package/extension/native/node-pty/lib/utils.js +39 -0
- package/extension/native/node-pty/lib/utils.js.map +1 -0
- package/extension/native/node-pty/lib/windowsConoutConnection.js +125 -0
- package/extension/native/node-pty/lib/windowsConoutConnection.js.map +1 -0
- package/extension/native/node-pty/lib/windowsPtyAgent.js +320 -0
- package/extension/native/node-pty/lib/windowsPtyAgent.js.map +1 -0
- package/extension/native/node-pty/lib/windowsTerminal.js +199 -0
- package/extension/native/node-pty/lib/windowsTerminal.js.map +1 -0
- package/extension/native/node-pty/lib/worker/conoutSocketWorker.js +22 -0
- package/extension/native/node-pty/lib/worker/conoutSocketWorker.js.map +1 -0
- package/extension/native/node-pty/package.json +64 -0
- package/extension/native/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
- package/extension/native/node-pty/prebuilds/darwin-x64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty/OpenConsole.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty/conpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/conpty_console_list.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/winpty-agent.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-arm64/winpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty/OpenConsole.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty/conpty.dll +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/conpty_console_list.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/pty.node +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/winpty-agent.exe +0 -0
- package/extension/native/node-pty/prebuilds/win32-x64/winpty.dll +0 -0
- package/extension/package-lock.json +605 -0
- package/extension/package.json +343 -0
- package/extension/scripts/bundle-native.mjs +104 -0
- package/extension/scripts/deploy-dev.mjs +60 -0
- package/extension/src/ansi-strip.ts +52 -0
- package/extension/src/backends/vscode/claws-pty.ts +483 -0
- package/extension/src/backends/vscode/status-bar.ts +99 -0
- package/extension/src/backends/vscode/vscode-backend.ts +282 -0
- package/extension/src/capture-store.ts +125 -0
- package/extension/src/event-log.ts +629 -0
- package/extension/src/event-schemas.ts +478 -0
- package/extension/src/extension.js +492 -0
- package/extension/src/extension.ts +873 -0
- package/extension/src/lifecycle-engine.ts +60 -0
- package/extension/src/lifecycle-rules.ts +171 -0
- package/extension/src/lifecycle-store.ts +506 -0
- package/extension/src/peer-registry.ts +176 -0
- package/extension/src/pipeline-registry.ts +82 -0
- package/extension/src/platform.ts +64 -0
- package/extension/src/protocol.ts +532 -0
- package/extension/src/server-config.ts +98 -0
- package/extension/src/server.ts +2210 -0
- package/extension/src/task-registry.ts +51 -0
- package/extension/src/terminal-backend.ts +211 -0
- package/extension/src/terminal-manager.ts +395 -0
- package/extension/src/topic-registry.ts +70 -0
- package/extension/src/topic-utils.ts +46 -0
- package/extension/src/transport.ts +45 -0
- package/extension/src/uninstall-cleanup.ts +232 -0
- package/extension/src/wave-registry.ts +314 -0
- package/extension/src/websocket-transport.ts +153 -0
- package/extension/tsconfig.json +23 -0
- package/lib/capabilities.js +145 -0
- package/lib/dry-run.js +43 -0
- package/lib/install.js +1018 -0
- package/lib/mcp-setup.js +92 -0
- package/lib/platform.js +240 -0
- package/lib/preflight.js +152 -0
- package/lib/shell-hook.js +343 -0
- package/lib/uninstall.js +162 -0
- package/lib/verify.js +166 -0
- package/mcp_server.js +3529 -0
- package/package.json +48 -0
- package/rules/claws-default-behavior.md +72 -0
- package/scripts/_helpers/atomic-file.mjs +137 -0
- package/scripts/_helpers/fix-repair.js +64 -0
- package/scripts/_helpers/json-safe.mjs +218 -0
- package/scripts/bump-version.sh +84 -0
- package/scripts/codegen/gen-docs.mjs +61 -0
- package/scripts/codegen/gen-json-schema.mjs +62 -0
- package/scripts/codegen/gen-mcp-tools.mjs +358 -0
- package/scripts/codegen/gen-types.mjs +172 -0
- package/scripts/codegen/index.mjs +42 -0
- package/scripts/dev-hooks/check-extension-dirs.js +77 -0
- package/scripts/dev-hooks/check-open-claws-terminals.js +70 -0
- package/scripts/dev-hooks/check-stale-main.js +55 -0
- package/scripts/dev-hooks/check-tag-pushed.js +51 -0
- package/scripts/dev-hooks/check-tag-vs-main.js +56 -0
- package/scripts/dev-vsix-install.sh +60 -0
- package/scripts/fix.sh +702 -0
- package/scripts/gen-client-types.mjs +81 -0
- package/scripts/git-hooks/pre-commit +31 -0
- package/scripts/hooks/lifecycle-state.js +61 -0
- package/scripts/hooks/package.json +4 -0
- package/scripts/hooks/post-tool-use-claws.js +292 -0
- package/scripts/hooks/pre-bash-no-verify-block.js +72 -0
- package/scripts/hooks/pre-tool-use-claws.js +206 -0
- package/scripts/hooks/session-start-claws.js +97 -0
- package/scripts/hooks/stop-claws.js +88 -0
- package/scripts/inject-claude-md.js +205 -0
- package/scripts/inject-dev-hooks.js +96 -0
- package/scripts/inject-global-claude-md.js +140 -0
- package/scripts/inject-settings-hooks.js +370 -0
- package/scripts/install.ps1 +146 -0
- package/scripts/install.sh +1729 -0
- package/scripts/monitor-arm-watch.js +155 -0
- package/scripts/rebuild-node-pty.sh +245 -0
- package/scripts/report.sh +232 -0
- package/scripts/shell-hook.fish +164 -0
- package/scripts/shell-hook.ps1 +33 -0
- package/scripts/shell-hook.sh +232 -0
- package/scripts/stream-events.js +399 -0
- package/scripts/terminal-wrapper.sh +36 -0
- package/scripts/test-enforcement.sh +132 -0
- package/scripts/test-install.sh +174 -0
- package/scripts/test-installer-parity.sh +135 -0
- package/scripts/test-template-enforcement.sh +76 -0
- package/scripts/uninstall.sh +143 -0
- package/scripts/update.sh +337 -0
- package/scripts/verify-release.sh +323 -0
- package/scripts/verify-wrapped.sh +194 -0
- package/templates/CLAUDE.global.md +135 -0
- package/templates/CLAUDE.project.md +37 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Claws — verify a wrapped terminal runs in real pty mode
|
|
3
|
+
#
|
|
4
|
+
# End-to-end test that exercises the full path:
|
|
5
|
+
# 1. Socket is live
|
|
6
|
+
# 2. Create a wrapped terminal via the protocol
|
|
7
|
+
# 3. Send a marker command, read it back via readLog
|
|
8
|
+
# 4. Scan VS Code's Claws output log for pipe-mode warning
|
|
9
|
+
# 5. Close the test terminal
|
|
10
|
+
#
|
|
11
|
+
# Run AFTER reloading VS Code. A successful run proves node-pty loaded
|
|
12
|
+
# inside the extension host and wrapped terminals capture output correctly.
|
|
13
|
+
#
|
|
14
|
+
# Usage:
|
|
15
|
+
# bash ~/.claws-src/scripts/verify-wrapped.sh [project-root]
|
|
16
|
+
#
|
|
17
|
+
# # Or via curl URL:
|
|
18
|
+
# bash <(curl -fsSL https://raw.githubusercontent.com/neunaha/claws/main/scripts/verify-wrapped.sh)
|
|
19
|
+
|
|
20
|
+
set -eo pipefail
|
|
21
|
+
|
|
22
|
+
PROJECT_ROOT="${1:-$(pwd)}"
|
|
23
|
+
SOCK="$PROJECT_ROOT/.claws/claws.sock"
|
|
24
|
+
|
|
25
|
+
C_RESET=$'\033[0m'; C_BOLD=$'\033[1m'
|
|
26
|
+
C_GREEN=$'\033[0;32m'; C_RED=$'\033[0;31m'; C_YELLOW=$'\033[0;33m'; C_BLUE=$'\033[0;34m'; C_DIM=$'\033[2m'
|
|
27
|
+
|
|
28
|
+
ok() { printf " ${C_GREEN}✓${C_RESET} %s\n" "$*"; }
|
|
29
|
+
bad() { printf " ${C_RED}✗${C_RESET} %s\n" "$*"; }
|
|
30
|
+
info() { printf " ${C_DIM}%s${C_RESET}\n" "$*"; }
|
|
31
|
+
h() { printf "\n${C_BOLD}${C_BLUE}═══ %s ═══${C_RESET}\n" "$*"; }
|
|
32
|
+
|
|
33
|
+
# A pure-Node client so we can parse JSON properly and handle async replies.
|
|
34
|
+
# Writes commands to the socket, waits for the matching response, returns it.
|
|
35
|
+
SOCK_CLIENT=$(cat <<'CLIENT_JS'
|
|
36
|
+
const net = require('net');
|
|
37
|
+
const sock = net.createConnection(process.argv[2]);
|
|
38
|
+
const requests = JSON.parse(process.argv[3]);
|
|
39
|
+
let buf = '';
|
|
40
|
+
const results = [];
|
|
41
|
+
let idx = 0;
|
|
42
|
+
|
|
43
|
+
sock.on('connect', () => {
|
|
44
|
+
sock.write(JSON.stringify(requests[idx]) + '\n');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
sock.on('data', (d) => {
|
|
48
|
+
buf += d.toString('utf8');
|
|
49
|
+
while (true) {
|
|
50
|
+
const nl = buf.indexOf('\n');
|
|
51
|
+
if (nl === -1) break;
|
|
52
|
+
const line = buf.slice(0, nl);
|
|
53
|
+
buf = buf.slice(nl + 1);
|
|
54
|
+
if (!line.trim()) continue;
|
|
55
|
+
let resp;
|
|
56
|
+
try { resp = JSON.parse(line); }
|
|
57
|
+
catch { results.push({ parseError: line }); break; }
|
|
58
|
+
results.push(resp);
|
|
59
|
+
idx++;
|
|
60
|
+
if (idx < requests.length) {
|
|
61
|
+
sock.write(JSON.stringify(requests[idx]) + '\n');
|
|
62
|
+
} else {
|
|
63
|
+
sock.end();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
sock.on('error', (e) => { console.error('SOCKET ERROR:', e.message); process.exit(1); });
|
|
69
|
+
sock.on('close', () => { console.log(JSON.stringify(results)); process.exit(0); });
|
|
70
|
+
setTimeout(() => { console.error('TIMEOUT'); process.exit(1); }, 10000);
|
|
71
|
+
CLIENT_JS
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
run_protocol() {
|
|
75
|
+
# Args: a JSON array of requests. Prints a JSON array of responses.
|
|
76
|
+
echo "$1" | xargs -0 -I{} echo "" >/dev/null # dummy to absorb stdin
|
|
77
|
+
node -e "$SOCK_CLIENT" "$SOCK" "$1"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# ─── 1. Socket live? ───────────────────────────────────────────────────────
|
|
81
|
+
h "1. Socket check"
|
|
82
|
+
if [ ! -S "$SOCK" ]; then
|
|
83
|
+
bad "no socket at $SOCK"
|
|
84
|
+
info "the Claws extension isn't running in this project. Open the project in VS Code and reload."
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
list_resp=$(node -e "$SOCK_CLIENT" "$SOCK" '[{"cmd":"list"}]' 2>&1)
|
|
88
|
+
if ! echo "$list_resp" | grep -q '"ok":true'; then
|
|
89
|
+
bad "socket exists but didn't respond to 'list': $list_resp"
|
|
90
|
+
exit 1
|
|
91
|
+
fi
|
|
92
|
+
ok "socket LIVE — extension is listening"
|
|
93
|
+
term_count=$(echo "$list_resp" | node -e "const r=JSON.parse(require('fs').readFileSync(0,'utf8')); console.log(r[0].terminals.length)")
|
|
94
|
+
info "existing terminals: $term_count"
|
|
95
|
+
|
|
96
|
+
# ─── 2. Create a wrapped terminal ──────────────────────────────────────────
|
|
97
|
+
h "2. Create wrapped terminal"
|
|
98
|
+
create_resp=$(node -e "$SOCK_CLIENT" "$SOCK" '[{"cmd":"create","name":"verify-pty","wrapped":true,"show":false}]' 2>&1)
|
|
99
|
+
if ! echo "$create_resp" | grep -q '"ok":true'; then
|
|
100
|
+
bad "create failed: $create_resp"
|
|
101
|
+
exit 1
|
|
102
|
+
fi
|
|
103
|
+
TERM_ID=$(echo "$create_resp" | node -e "const r=JSON.parse(require('fs').readFileSync(0,'utf8')); console.log(r[0].id)")
|
|
104
|
+
WRAPPED=$(echo "$create_resp" | node -e "const r=JSON.parse(require('fs').readFileSync(0,'utf8')); console.log(r[0].wrapped)")
|
|
105
|
+
ok "created terminal id=$TERM_ID wrapped=$WRAPPED"
|
|
106
|
+
if [ "$WRAPPED" != "true" ]; then
|
|
107
|
+
bad "created terminal is NOT wrapped — verification cannot continue"
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# ─── 3. Wait for shell prompt, send marker, read back ──────────────────────
|
|
112
|
+
h "3. Send → readLog round trip"
|
|
113
|
+
info "waiting 2s for shell to initialize..."
|
|
114
|
+
sleep 2
|
|
115
|
+
|
|
116
|
+
MARKER="CLAWS_VERIFY_$(date +%s)_$$"
|
|
117
|
+
send_req=$(node -e "console.log(JSON.stringify([{cmd:'send',id:'$TERM_ID',text:'echo $MARKER',newline:true}]))")
|
|
118
|
+
send_resp=$(node -e "$SOCK_CLIENT" "$SOCK" "$send_req" 2>&1)
|
|
119
|
+
if ! echo "$send_resp" | grep -q '"ok":true'; then
|
|
120
|
+
bad "send failed: $send_resp"
|
|
121
|
+
exit 1
|
|
122
|
+
fi
|
|
123
|
+
ok "sent: echo $MARKER"
|
|
124
|
+
|
|
125
|
+
info "waiting 2s for command to run..."
|
|
126
|
+
sleep 2
|
|
127
|
+
|
|
128
|
+
read_req=$(node -e "console.log(JSON.stringify([{cmd:'readLog',id:'$TERM_ID',strip:true,limit:16384}]))")
|
|
129
|
+
read_resp=$(node -e "$SOCK_CLIENT" "$SOCK" "$read_req" 2>&1)
|
|
130
|
+
BYTES=$(echo "$read_resp" | node -e "try{const r=JSON.parse(require('fs').readFileSync(0,'utf8'));console.log(r[0].bytes||'')}catch{console.log('')}")
|
|
131
|
+
|
|
132
|
+
if echo "$BYTES" | grep -q "$MARKER"; then
|
|
133
|
+
ok "marker '$MARKER' found in readLog output — pty capture is working"
|
|
134
|
+
info "readLog last 3 lines:"
|
|
135
|
+
echo "$BYTES" | tail -3 | sed 's/^/ /'
|
|
136
|
+
else
|
|
137
|
+
bad "marker NOT found in readLog output"
|
|
138
|
+
info "this usually means:"
|
|
139
|
+
info " - the wrapped terminal is in pipe-mode (node-pty not loaded)"
|
|
140
|
+
info " - OR the shell didn't have time to run echo (rare — unlikely after 2s)"
|
|
141
|
+
info " - OR readLog is pulling from a different source (file vs ring buffer)"
|
|
142
|
+
info "received bytes (first 300 chars):"
|
|
143
|
+
echo "${BYTES:0:300}" | sed 's/^/ /'
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# ─── 4. Scan VS Code's Claws log for pipe-mode warning ─────────────────────
|
|
147
|
+
h "4. Pipe-mode warning scan"
|
|
148
|
+
LOGROOT="$HOME/Library/Application Support/Code/logs"
|
|
149
|
+
if [ ! -d "$LOGROOT" ]; then
|
|
150
|
+
info "no VS Code logs dir at $LOGROOT — skipping"
|
|
151
|
+
else
|
|
152
|
+
# Find the most recent Claws output log across all VS Code session dirs
|
|
153
|
+
latest_log=$(find "$LOGROOT" -name "1-Claws.log" -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -1)
|
|
154
|
+
if [ -n "$latest_log" ] && [ -f "$latest_log" ]; then
|
|
155
|
+
info "log: $latest_log"
|
|
156
|
+
# Check ONLY entries from the current hour — older pipe-mode mentions
|
|
157
|
+
# may be stale from pre-fix sessions and don't indicate current breakage
|
|
158
|
+
recent_pipemode=$(grep "pipe-mode" "$latest_log" 2>/dev/null | tail -5)
|
|
159
|
+
if [ -n "$recent_pipemode" ]; then
|
|
160
|
+
bad "pipe-mode mentions found in Claws log:"
|
|
161
|
+
echo "$recent_pipemode" | sed 's/^/ /'
|
|
162
|
+
info "if these are from BEFORE your last reload, they're stale. Check timestamps."
|
|
163
|
+
info "if they're recent, node-pty still isn't loading in the extension host:"
|
|
164
|
+
info " bash <(curl -fsSL https://raw.githubusercontent.com/neunaha/claws/main/scripts/rebuild-node-pty.sh)"
|
|
165
|
+
else
|
|
166
|
+
ok "no pipe-mode mentions in this session's log"
|
|
167
|
+
# Also check for the positive signal
|
|
168
|
+
if grep -q "activating (typescript)" "$latest_log" 2>/dev/null; then
|
|
169
|
+
ok "extension activated with v0.4 TypeScript bundle"
|
|
170
|
+
fi
|
|
171
|
+
fi
|
|
172
|
+
else
|
|
173
|
+
info "no Claws log found — extension may not have logged yet"
|
|
174
|
+
fi
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
# ─── 5. Clean up the test terminal ─────────────────────────────────────────
|
|
178
|
+
h "5. Cleanup"
|
|
179
|
+
close_req=$(node -e "console.log(JSON.stringify([{cmd:'close',id:'$TERM_ID'}]))")
|
|
180
|
+
node -e "$SOCK_CLIENT" "$SOCK" "$close_req" >/dev/null 2>&1 || true
|
|
181
|
+
ok "closed test terminal id=$TERM_ID"
|
|
182
|
+
|
|
183
|
+
# ─── Summary ──────────────────────────────────────────────────────────────
|
|
184
|
+
echo ""
|
|
185
|
+
if echo "$BYTES" | grep -q "$MARKER"; then
|
|
186
|
+
printf "${C_GREEN}${C_BOLD}VERIFICATION PASSED${C_RESET}\n"
|
|
187
|
+
echo " Wrapped terminals are capturing output — node-pty is working."
|
|
188
|
+
echo " TUI apps (claude, vim, htop) will render cleanly."
|
|
189
|
+
else
|
|
190
|
+
printf "${C_RED}${C_BOLD}VERIFICATION FAILED${C_RESET}\n"
|
|
191
|
+
echo " Wrapped terminal did not echo the marker back through readLog."
|
|
192
|
+
echo " Next step: bash <(curl -fsSL https://raw.githubusercontent.com/neunaha/claws/main/scripts/rebuild-node-pty.sh)"
|
|
193
|
+
exit 1
|
|
194
|
+
fi
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!-- CLAWS-GLOBAL:BEGIN -->
|
|
2
|
+
## Claws — Machine-Wide Terminal Policy (v{VERSION}) · npm: claws-code
|
|
3
|
+
|
|
4
|
+
Claws may be installed in the current project. The trigger is the file `.claws/claws.sock` in the project root — if it exists, the rest of this section applies. If it does not, this section is inert.
|
|
5
|
+
|
|
6
|
+
### What is already running for you
|
|
7
|
+
|
|
8
|
+
When you start a session in a Claws project, several things happen automatically before your first message. You do not need to spawn or arm any of them yourself:
|
|
9
|
+
|
|
10
|
+
- **MCP server** (`mcp__claws__*` tools) is registered via `.mcp.json` and exposes the full Claws API.
|
|
11
|
+
- **Sidecar** (`stream-events.js --auto-sidecar`) is spawned by the SessionStart hook, streaming every bus event into `.claws/events.log`.
|
|
12
|
+
- **Hooks** in `~/.claude/settings.json` watch your tool calls: a Monitor gate on spawn-class MCP calls, an orphan-cleanup PostToolUse hook, a `--no-verify` block on Bash, and a Stop hook that kills the sidecar at session end.
|
|
13
|
+
|
|
14
|
+
You should treat these as part of the runtime — do not respawn them, do not kill them.
|
|
15
|
+
|
|
16
|
+
### The simple path: `/claws-do`
|
|
17
|
+
|
|
18
|
+
For most work, run `/claws-do "<task>"`. It classifies the task into one of four buckets and runs the right tool:
|
|
19
|
+
|
|
20
|
+
1. **One-shot shell** — `claws_exec(command, …)` for quick captures.
|
|
21
|
+
2. **Single Claude task** — `claws_worker(name, mission)` for anything that needs a TUI Claude session.
|
|
22
|
+
3. **Parallel fleet** — `claws_fleet(workers=[…])` for independent jobs that can run in parallel.
|
|
23
|
+
4. **Wave with LEAD** — multi-role wave army for coordinated multi-worker missions.
|
|
24
|
+
|
|
25
|
+
`/claws-status` shows live terminal + lifecycle state. `/claws-help` lists every command and tool.
|
|
26
|
+
|
|
27
|
+
Each entry-point command (`/claws-do`, `/claws`, `/claws-fix`) includes a MANDATORY
|
|
28
|
+
cold-start sequence at its top — read it before deliberating.
|
|
29
|
+
|
|
30
|
+
### Terminal hygiene (non-negotiable)
|
|
31
|
+
|
|
32
|
+
- **NEVER use Bash for long-lived processes** — servers, watchers, REPLs, builds. Use `claws_create` + `claws_send`, or let `claws_worker` / `claws_fleet` do it for you.
|
|
33
|
+
- **ALWAYS create wrapped terminals** (`wrapped: true` is the default — leave it on). Wrapped terminals capture every pty byte to a log; unwrapped terminals are invisible to `claws_read_log`.
|
|
34
|
+
- **ALWAYS close terminals you create.** Either via `claws_done()` from inside the worker (preferred), or `claws_close(id)` from the orchestrator at cleanup.
|
|
35
|
+
- **NEVER touch terminals you did not create.**
|
|
36
|
+
- **NEVER run Claude headless** (`claude -p "…"`). Workers must be visible TUI sessions launched via `claws_worker` or by sending `claude --dangerously-skip-permissions` into a wrapped terminal.
|
|
37
|
+
|
|
38
|
+
### Workers boot themselves — do not run the send sequence manually
|
|
39
|
+
|
|
40
|
+
`claws_worker(mission=…)` and `claws_fleet(workers=[…])` run the full boot sequence internally: create wrapped terminal → launch `claude --model … --dangerously-skip-permissions` → wait for the prompt to settle (detected by `❯` + `cost:$` stable for 3 polls) → bracketed-paste the mission → submit. Boot waits default to 25 s.
|
|
41
|
+
|
|
42
|
+
You do **not** call `claws_create` + `claws_send` to boot workers manually. That sequence is automated.
|
|
43
|
+
|
|
44
|
+
`claws_worker` and `claws_fleet` use a **mode-aware** detach default:
|
|
45
|
+
- Mission-mode (you pass `mission=…`) → `detach: true` by default. The call returns immediately with `terminal_id` + `correlation_id` and a copy-pasteable `monitor_arm_command`. Poll completion with `claws_workers_wait(terminal_ids=[…])`.
|
|
46
|
+
- Command-mode (you pass `command=…` instead) → `detach: false` by default. The call blocks until the command exits.
|
|
47
|
+
- Override with `detach: true|false` if needed.
|
|
48
|
+
|
|
49
|
+
`claws_fleet` always defaults to detach unless you pass `detach: false` explicitly.
|
|
50
|
+
|
|
51
|
+
### Worker completion — five layers, `claws_done()` is primary
|
|
52
|
+
|
|
53
|
+
Every worker mission must end with these final actions, in order:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
F1 (Bash): git status --short — verify state
|
|
57
|
+
F2 (Bash): git log --oneline -5 — verify commits
|
|
58
|
+
F3 (MCP): claws_done() — PRIMARY, REQUIRED
|
|
59
|
+
F4 (Bash): printf '%s\n' '__CLAWS_DONE__' — pty-byte backup
|
|
60
|
+
F5 (chat): end final message with __CLAWS_DONE__ — last-resort backup
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`claws_done()` reads `CLAWS_TERMINAL_ID` from the worker's environment (set by the extension at spawn), publishes `system.worker.completed` with `marker:'__CLAWS_DONE__'`, and closes the terminal. Zero arguments. That is the entire signal — you do not need `claws_publish` for completion.
|
|
64
|
+
|
|
65
|
+
The marker the server recognizes is **`__CLAWS_DONE__`** and only that string. No other marker variant is recognized.
|
|
66
|
+
|
|
67
|
+
If a worker exits without firing F3 or F4, VS Code's `onDidCloseTerminal` triggers the Wave D fallback: the extension publishes `system.worker.terminated`, which the MCP server upgrades to `system.worker.completed` with `completion_signal:'terminated'`. So a worker that just dies still gets accounted for — but `claws_done()` is the canonical path and what `/claws-do` and the prompt templates teach.
|
|
68
|
+
|
|
69
|
+
### Monitor — sidecar streams, per-worker filters
|
|
70
|
+
|
|
71
|
+
The sidecar is already running and writing every bus event to `.claws/events.log`. The PreToolUse hook gates spawn-class MCP calls (`claws_create`, `claws_worker`, `claws_fleet`, `claws_dispatch_subworker`) and refuses if no Monitor process is detected — there is a 5 s grace from the first call.
|
|
72
|
+
|
|
73
|
+
The hook accepts either of these patterns:
|
|
74
|
+
- `pgrep -f 'stream-events\.js'` — the canonical bus subscription (preferred)
|
|
75
|
+
- `pgrep -f 'tail.*\.claws/events\.log'` — legacy `tail -F` fallback (still works)
|
|
76
|
+
|
|
77
|
+
Per-worker observation: every spawn response includes a `monitor_arm_command` string. Copy-paste it into a `Monitor(...)` call:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
Monitor(command="node <claws-bin>/stream-events.js --wait <correlation_id>",
|
|
81
|
+
description="claws monitor | term=<id>", timeout_ms=600000, persistent=false)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`stream-events.js --wait <correlation_id>` filters the bus stream to one worker and self-exits on `system.worker.completed`. SIGPIPE-safe, no SIGURG kill — unlike `tail -F | grep`, which the supervisor will kill within ~30 s of inactivity.
|
|
85
|
+
|
|
86
|
+
### Lifecycle (full session phase machine)
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
{LIFECYCLE_PHASES}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`SESSION-BOOT` and `SESSION-END` are session-boundary phases (server-internal). Workers report a 9-phase subset: `PLAN → SPAWN → DEPLOY → OBSERVE → RECOVER → HARVEST → CLEANUP → REFLECT`, plus `FAILED` as an off-path terminal state. `FAILED` exits to `CLEANUP` or `SESSION-END`; `failure_cause` (with optional `recovery_hint`) is preserved across recovery.
|
|
93
|
+
|
|
94
|
+
### Wave Discipline (Wave Army sub-workers only)
|
|
95
|
+
|
|
96
|
+
If you receive a Wave Army mission, you are a sub-worker. You MUST:
|
|
97
|
+
|
|
98
|
+
1. **Register** — call `claws_hello` with `waveId` and `subWorkerRole` within 60 s of boot. (`capabilities: ['push']` is auto-granted as of v0.7.13 — passing it is now optional but harmless.)
|
|
99
|
+
2. **Boot event** — publish `wave.<waveId>.<role>.boot` immediately after hello.
|
|
100
|
+
3. **Heartbeat every 20 s** — publish `worker.<peerId>.heartbeat` (use the `peerId` returned by `claws_hello`, NOT the role name — only `worker.<peerId>.*` topics reset the server's 25 s violation timer).
|
|
101
|
+
4. **Phase events** — publish `worker.<peerId>.phase` on every transition.
|
|
102
|
+
5. **Error events** — publish `worker.<peerId>.event` with `kind=ERROR` for any blocking failure; never silently swallow.
|
|
103
|
+
6. **No `--no-verify`** — every commit must pass pre-commit hooks. The Bash hook hard-blocks `--no-verify` and `--no-gpg-sign`.
|
|
104
|
+
7. **Full suite before commit** — `npm test` (or equivalent) must be green.
|
|
105
|
+
8. **Type-check after `.ts` edits** — `npx tsc --noEmit` must report zero errors.
|
|
106
|
+
9. **Complete event** — publish `wave.<waveId>.<role>.complete` as the absolute final act before printing the role sentinel (the LEAD waits on this).
|
|
107
|
+
|
|
108
|
+
### Worker binary
|
|
109
|
+
|
|
110
|
+
By default, workers spawn `claude`. If the user wants a different binary
|
|
111
|
+
(common for teams using multiple Claude accounts via shell aliases like
|
|
112
|
+
`claude-neu`, `claude-anish`), recognize the natural-language pattern:
|
|
113
|
+
|
|
114
|
+
- "use claude-neu for workers" / "switch to claude-neu" → call `claws_set_bin(name: "claude-neu")`
|
|
115
|
+
- "reset the worker binary" / "go back to claude" → call `claws_set_bin()` (no args)
|
|
116
|
+
- "what binary are workers using?" → call `claws_get_bin()`
|
|
117
|
+
|
|
118
|
+
The setting is per-project, persisted in `.claws/claude-bin` (gitignored), and
|
|
119
|
+
takes effect immediately — next worker spawn uses the new binary. No MCP
|
|
120
|
+
restart, no terminal reopen.
|
|
121
|
+
|
|
122
|
+
### What's automatic now (don't do these manually)
|
|
123
|
+
|
|
124
|
+
- ❌ Manual sidecar spawn — the SessionStart hook does it.
|
|
125
|
+
- ❌ Manual peer registration before publishing — `claws_done` and other helpers do it for you when needed.
|
|
126
|
+
- ❌ Passing `capabilities: ['push']` to `claws_hello` — auto-granted.
|
|
127
|
+
- ❌ Running `claws_create` + `claws_send` to boot Claude in a worker — `claws_worker` / `claws_fleet` do the full sequence.
|
|
128
|
+
- ❌ Choosing a marker string per worker — always `__CLAWS_DONE__`.
|
|
129
|
+
- ❌ Polling `tail -F` for completion — use the per-worker `monitor_arm_command` from the spawn response.
|
|
130
|
+
- ❌ Closing your own terminal at the end — `claws_done()` does it.
|
|
131
|
+
|
|
132
|
+
### If `.claws/claws.sock` does not exist
|
|
133
|
+
|
|
134
|
+
No Claws server is running for this project. Use standard tools (Bash, Edit, Write). Nothing in this section applies.
|
|
135
|
+
<!-- CLAWS-GLOBAL:END -->
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!-- CLAWS:BEGIN -->
|
|
2
|
+
## Claws — {PROJECT_NAME} (v{VERSION}) · npm: claws-code
|
|
3
|
+
|
|
4
|
+
The Claws MCP server is running at `{SOCKET_PATH}`. Machine-wide invariants (boot sequence, completion convention, Monitor pattern, lifecycle phases, Wave Discipline) live in `~/.claude/CLAUDE.md` — do not duplicate them here.
|
|
5
|
+
|
|
6
|
+
### Where to start
|
|
7
|
+
|
|
8
|
+
- **`/claws-do "<task>"`** — daily driver. Auto-classifies into shell / worker / fleet / wave.
|
|
9
|
+
- **`/claws-status`** — live terminal table + lifecycle state.
|
|
10
|
+
- **`/claws-help`** — full command + tool reference.
|
|
11
|
+
|
|
12
|
+
### MCP tools available ({TOOLS_COUNT})
|
|
13
|
+
|
|
14
|
+
{TOOLS_LIST}
|
|
15
|
+
|
|
16
|
+
### Slash commands ({CMDS_COUNT})
|
|
17
|
+
|
|
18
|
+
{CMDS_LIST}
|
|
19
|
+
|
|
20
|
+
### Lifecycle phases
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
{LIFECYCLE_PHASES}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
(Workers report a 9-phase subset — see `~/.claude/CLAUDE.md` for details.)
|
|
27
|
+
|
|
28
|
+
### Reminders
|
|
29
|
+
|
|
30
|
+
- Workers boot themselves via `claws_worker` / `claws_fleet` — do not run the send sequence manually.
|
|
31
|
+
- Completion is `claws_done()` (zero-arg, F3 of the five-layer convention).
|
|
32
|
+
- Marker recognized by the server: `__CLAWS_DONE__` only.
|
|
33
|
+
- `claws_fleet` and `claws_worker` are non-blocking by default in mission mode (LH-14.1) — poll via `claws_workers_wait`.
|
|
34
|
+
- Worker binary: defaults to `claude`. Override with `/claws-bin <name>` or write to `.claws/claude-bin`.
|
|
35
|
+
|
|
36
|
+
See `~/.claude/CLAUDE.md` for the complete invariant policy.
|
|
37
|
+
<!-- CLAWS:END -->
|