@codedeck/codedeck 2026.3.1-4.63
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/README.md +38 -0
- package/config/default.yaml +51 -0
- package/dist/agent/brain-dispatcher.d.ts +67 -0
- package/dist/agent/brain-dispatcher.d.ts.map +1 -0
- package/dist/agent/brain-dispatcher.js +136 -0
- package/dist/agent/brain-dispatcher.js.map +1 -0
- package/dist/agent/detect.d.ts +20 -0
- package/dist/agent/detect.d.ts.map +1 -0
- package/dist/agent/detect.js +187 -0
- package/dist/agent/detect.js.map +1 -0
- package/dist/agent/drivers/base.d.ts +57 -0
- package/dist/agent/drivers/base.d.ts.map +1 -0
- package/dist/agent/drivers/base.js +3 -0
- package/dist/agent/drivers/base.js.map +1 -0
- package/dist/agent/drivers/claude-code.d.ts +14 -0
- package/dist/agent/drivers/claude-code.d.ts.map +1 -0
- package/dist/agent/drivers/claude-code.js +112 -0
- package/dist/agent/drivers/claude-code.js.map +1 -0
- package/dist/agent/drivers/codex.d.ts +14 -0
- package/dist/agent/drivers/codex.d.ts.map +1 -0
- package/dist/agent/drivers/codex.js +77 -0
- package/dist/agent/drivers/codex.js.map +1 -0
- package/dist/agent/drivers/gemini.d.ts +24 -0
- package/dist/agent/drivers/gemini.d.ts.map +1 -0
- package/dist/agent/drivers/gemini.js +142 -0
- package/dist/agent/drivers/gemini.js.map +1 -0
- package/dist/agent/drivers/opencode.d.ts +18 -0
- package/dist/agent/drivers/opencode.d.ts.map +1 -0
- package/dist/agent/drivers/opencode.js +50 -0
- package/dist/agent/drivers/opencode.js.map +1 -0
- package/dist/agent/drivers/shell.d.ts +13 -0
- package/dist/agent/drivers/shell.d.ts.map +1 -0
- package/dist/agent/drivers/shell.js +30 -0
- package/dist/agent/drivers/shell.js.map +1 -0
- package/dist/agent/env-isolation.d.ts +26 -0
- package/dist/agent/env-isolation.d.ts.map +1 -0
- package/dist/agent/env-isolation.js +103 -0
- package/dist/agent/env-isolation.js.map +1 -0
- package/dist/agent/notify-setup.d.ts +18 -0
- package/dist/agent/notify-setup.d.ts.map +1 -0
- package/dist/agent/notify-setup.js +68 -0
- package/dist/agent/notify-setup.js.map +1 -0
- package/dist/agent/session-manager.d.ts +75 -0
- package/dist/agent/session-manager.d.ts.map +1 -0
- package/dist/agent/session-manager.js +407 -0
- package/dist/agent/session-manager.js.map +1 -0
- package/dist/agent/signal.d.ts +32 -0
- package/dist/agent/signal.d.ts.map +1 -0
- package/dist/agent/signal.js +199 -0
- package/dist/agent/signal.js.map +1 -0
- package/dist/agent/status-poller.d.ts +27 -0
- package/dist/agent/status-poller.d.ts.map +1 -0
- package/dist/agent/status-poller.js +76 -0
- package/dist/agent/status-poller.js.map +1 -0
- package/dist/agent/templates/brain-prompt.d.ts +14 -0
- package/dist/agent/templates/brain-prompt.d.ts.map +1 -0
- package/dist/agent/templates/brain-prompt.js +57 -0
- package/dist/agent/templates/brain-prompt.js.map +1 -0
- package/dist/agent/templates/identity.d.ts +19 -0
- package/dist/agent/templates/identity.d.ts.map +1 -0
- package/dist/agent/templates/identity.js +97 -0
- package/dist/agent/templates/identity.js.map +1 -0
- package/dist/agent/tmux.d.ts +90 -0
- package/dist/agent/tmux.d.ts.map +1 -0
- package/dist/agent/tmux.js +386 -0
- package/dist/agent/tmux.js.map +1 -0
- package/dist/autofix/audit-engine.d.ts +35 -0
- package/dist/autofix/audit-engine.d.ts.map +1 -0
- package/dist/autofix/audit-engine.js +144 -0
- package/dist/autofix/audit-engine.js.map +1 -0
- package/dist/autofix/branch-manager.d.ts +44 -0
- package/dist/autofix/branch-manager.d.ts.map +1 -0
- package/dist/autofix/branch-manager.js +97 -0
- package/dist/autofix/branch-manager.js.map +1 -0
- package/dist/autofix/decision-engine.d.ts +38 -0
- package/dist/autofix/decision-engine.d.ts.map +1 -0
- package/dist/autofix/decision-engine.js +115 -0
- package/dist/autofix/decision-engine.js.map +1 -0
- package/dist/autofix/index.d.ts +23 -0
- package/dist/autofix/index.d.ts.map +1 -0
- package/dist/autofix/index.js +192 -0
- package/dist/autofix/index.js.map +1 -0
- package/dist/autofix/prompt-builder.d.ts +25 -0
- package/dist/autofix/prompt-builder.d.ts.map +1 -0
- package/dist/autofix/prompt-builder.js +137 -0
- package/dist/autofix/prompt-builder.js.map +1 -0
- package/dist/autofix/report-parser.d.ts +18 -0
- package/dist/autofix/report-parser.d.ts.map +1 -0
- package/dist/autofix/report-parser.js +74 -0
- package/dist/autofix/report-parser.js.map +1 -0
- package/dist/autofix/state-machine.d.ts +40 -0
- package/dist/autofix/state-machine.d.ts.map +1 -0
- package/dist/autofix/state-machine.js +76 -0
- package/dist/autofix/state-machine.js.map +1 -0
- package/dist/bind/bind-flow.d.ts +15 -0
- package/dist/bind/bind-flow.d.ts.map +1 -0
- package/dist/bind/bind-flow.js +198 -0
- package/dist/bind/bind-flow.js.map +1 -0
- package/dist/config.d.ts +53 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +89 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon/codex-watcher.d.ts +46 -0
- package/dist/daemon/codex-watcher.d.ts.map +1 -0
- package/dist/daemon/codex-watcher.js +533 -0
- package/dist/daemon/codex-watcher.js.map +1 -0
- package/dist/daemon/command-handler.d.ts +6 -0
- package/dist/daemon/command-handler.d.ts.map +1 -0
- package/dist/daemon/command-handler.js +770 -0
- package/dist/daemon/command-handler.js.map +1 -0
- package/dist/daemon/discussion-orchestrator.d.ts +63 -0
- package/dist/daemon/discussion-orchestrator.d.ts.map +1 -0
- package/dist/daemon/discussion-orchestrator.js +482 -0
- package/dist/daemon/discussion-orchestrator.js.map +1 -0
- package/dist/daemon/gemini-watcher.d.ts +42 -0
- package/dist/daemon/gemini-watcher.d.ts.map +1 -0
- package/dist/daemon/gemini-watcher.js +463 -0
- package/dist/daemon/gemini-watcher.js.map +1 -0
- package/dist/daemon/hook-server.d.ts +42 -0
- package/dist/daemon/hook-server.d.ts.map +1 -0
- package/dist/daemon/hook-server.js +160 -0
- package/dist/daemon/hook-server.js.map +1 -0
- package/dist/daemon/jsonl-watcher.d.ts +35 -0
- package/dist/daemon/jsonl-watcher.d.ts.map +1 -0
- package/dist/daemon/jsonl-watcher.js +635 -0
- package/dist/daemon/jsonl-watcher.js.map +1 -0
- package/dist/daemon/lifecycle.d.ts +20 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +331 -0
- package/dist/daemon/lifecycle.js.map +1 -0
- package/dist/daemon/server-link.d.ts +44 -0
- package/dist/daemon/server-link.d.ts.map +1 -0
- package/dist/daemon/server-link.js +232 -0
- package/dist/daemon/server-link.js.map +1 -0
- package/dist/daemon/subsession-manager.d.ts +37 -0
- package/dist/daemon/subsession-manager.d.ts.map +1 -0
- package/dist/daemon/subsession-manager.js +240 -0
- package/dist/daemon/subsession-manager.js.map +1 -0
- package/dist/daemon/terminal-parser.d.ts +42 -0
- package/dist/daemon/terminal-parser.d.ts.map +1 -0
- package/dist/daemon/terminal-parser.js +278 -0
- package/dist/daemon/terminal-parser.js.map +1 -0
- package/dist/daemon/terminal-streamer.d.ts +93 -0
- package/dist/daemon/terminal-streamer.d.ts.map +1 -0
- package/dist/daemon/terminal-streamer.js +451 -0
- package/dist/daemon/terminal-streamer.js.map +1 -0
- package/dist/daemon/timeline-emitter.d.ts +32 -0
- package/dist/daemon/timeline-emitter.d.ts.map +1 -0
- package/dist/daemon/timeline-emitter.js +97 -0
- package/dist/daemon/timeline-emitter.js.map +1 -0
- package/dist/daemon/timeline-event.d.ts +23 -0
- package/dist/daemon/timeline-event.d.ts.map +1 -0
- package/dist/daemon/timeline-event.js +7 -0
- package/dist/daemon/timeline-event.js.map +1 -0
- package/dist/daemon/timeline-store.d.ts +40 -0
- package/dist/daemon/timeline-store.d.ts.map +1 -0
- package/dist/daemon/timeline-store.js +153 -0
- package/dist/daemon/timeline-store.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/claude-mem.d.ts +9 -0
- package/dist/memory/claude-mem.d.ts.map +1 -0
- package/dist/memory/claude-mem.js +58 -0
- package/dist/memory/claude-mem.js.map +1 -0
- package/dist/memory/context-builder.d.ts +4 -0
- package/dist/memory/context-builder.d.ts.map +1 -0
- package/dist/memory/context-builder.js +35 -0
- package/dist/memory/context-builder.js.map +1 -0
- package/dist/memory/detector.d.ts +7 -0
- package/dist/memory/detector.d.ts.map +1 -0
- package/dist/memory/detector.js +17 -0
- package/dist/memory/detector.js.map +1 -0
- package/dist/memory/extractor.d.ts +21 -0
- package/dist/memory/extractor.d.ts.map +1 -0
- package/dist/memory/extractor.js +83 -0
- package/dist/memory/extractor.js.map +1 -0
- package/dist/memory/injector.d.ts +7 -0
- package/dist/memory/injector.d.ts.map +1 -0
- package/dist/memory/injector.js +18 -0
- package/dist/memory/injector.js.map +1 -0
- package/dist/memory/interface.d.ts +25 -0
- package/dist/memory/interface.d.ts.map +1 -0
- package/dist/memory/interface.js +3 -0
- package/dist/memory/interface.js.map +1 -0
- package/dist/memory/mem0.d.ts +12 -0
- package/dist/memory/mem0.d.ts.map +1 -0
- package/dist/memory/mem0.js +93 -0
- package/dist/memory/mem0.js.map +1 -0
- package/dist/router/command-parser.d.ts +33 -0
- package/dist/router/command-parser.d.ts.map +1 -0
- package/dist/router/command-parser.js +66 -0
- package/dist/router/command-parser.js.map +1 -0
- package/dist/router/message-router.d.ts +42 -0
- package/dist/router/message-router.d.ts.map +1 -0
- package/dist/router/message-router.js +222 -0
- package/dist/router/message-router.js.map +1 -0
- package/dist/router/response-collector.d.ts +28 -0
- package/dist/router/response-collector.d.ts.map +1 -0
- package/dist/router/response-collector.js +164 -0
- package/dist/router/response-collector.js.map +1 -0
- package/dist/store/project-store.d.ts +37 -0
- package/dist/store/project-store.d.ts.map +1 -0
- package/dist/store/project-store.js +70 -0
- package/dist/store/project-store.js.map +1 -0
- package/dist/store/session-store.d.ts +32 -0
- package/dist/store/session-store.d.ts.map +1 -0
- package/dist/store/session-store.js +67 -0
- package/dist/store/session-store.js.map +1 -0
- package/dist/tracker/branch.d.ts +24 -0
- package/dist/tracker/branch.d.ts.map +1 -0
- package/dist/tracker/branch.js +55 -0
- package/dist/tracker/branch.js.map +1 -0
- package/dist/tracker/github.d.ts +31 -0
- package/dist/tracker/github.d.ts.map +1 -0
- package/dist/tracker/github.js +117 -0
- package/dist/tracker/github.js.map +1 -0
- package/dist/tracker/gitlab.d.ts +31 -0
- package/dist/tracker/gitlab.d.ts.map +1 -0
- package/dist/tracker/gitlab.js +116 -0
- package/dist/tracker/gitlab.js.map +1 -0
- package/dist/tracker/index.d.ts +9 -0
- package/dist/tracker/index.d.ts.map +1 -0
- package/dist/tracker/index.js +28 -0
- package/dist/tracker/index.js.map +1 -0
- package/dist/tracker/interface.d.ts +39 -0
- package/dist/tracker/interface.d.ts.map +1 -0
- package/dist/tracker/interface.js +7 -0
- package/dist/tracker/interface.js.map +1 -0
- package/dist/tracker/priority.d.ts +19 -0
- package/dist/tracker/priority.d.ts.map +1 -0
- package/dist/tracker/priority.js +40 -0
- package/dist/tracker/priority.js.map +1 -0
- package/dist/util/logger.d.ts +4 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +14 -0
- package/dist/util/logger.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Full CC hook suite setup.
|
|
4
|
+
*
|
|
5
|
+
* Writes hook scripts to ~/.codedeck/ and registers them in ~/.claude/settings.json.
|
|
6
|
+
* All hooks POST directly to the daemon hook server (no file intermediary).
|
|
7
|
+
*
|
|
8
|
+
* Hook event types registered:
|
|
9
|
+
* Stop → { event: "idle", session, agentType: "claude-code" }
|
|
10
|
+
* Notification → { event: "notification", session, title, message }
|
|
11
|
+
* PreToolUse → { event: "tool_start", session, tool }
|
|
12
|
+
* PostToolUse → { event: "tool_end", session }
|
|
13
|
+
*
|
|
14
|
+
* Hook format required by Claude Code:
|
|
15
|
+
* "Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "..." }] }]
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.setupCCStopHook = exports.SIGNAL_DIR = void 0;
|
|
22
|
+
exports.writeIdleSignal = writeIdleSignal;
|
|
23
|
+
exports.checkIdleSignal = checkIdleSignal;
|
|
24
|
+
exports.setupCCHooks = setupCCHooks;
|
|
25
|
+
const fs_1 = require("fs");
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
const os_1 = __importDefault(require("os"));
|
|
28
|
+
const hook_server_js_1 = require("../daemon/hook-server.js");
|
|
29
|
+
const CODEDECK_DIR = path_1.default.join(os_1.default.homedir(), '.codedeck');
|
|
30
|
+
const CC_SETTINGS_PATH = path_1.default.join(os_1.default.homedir(), '.claude', 'settings.json');
|
|
31
|
+
// ── Signal file API ────────────────────────────────────────────────────────────
|
|
32
|
+
/** Directory where idle signal files are written by hooks and consumed by the daemon. */
|
|
33
|
+
exports.SIGNAL_DIR = path_1.default.join(CODEDECK_DIR, 'signals');
|
|
34
|
+
/** Write an idle signal file for a session (atomic rename). */
|
|
35
|
+
async function writeIdleSignal(signal) {
|
|
36
|
+
await fs_1.promises.mkdir(exports.SIGNAL_DIR, { recursive: true });
|
|
37
|
+
const tmp = path_1.default.join(exports.SIGNAL_DIR, `${signal.session}.tmp`);
|
|
38
|
+
const dest = path_1.default.join(exports.SIGNAL_DIR, `${signal.session}.signal`);
|
|
39
|
+
await fs_1.promises.writeFile(tmp, JSON.stringify(signal));
|
|
40
|
+
await fs_1.promises.rename(tmp, dest);
|
|
41
|
+
}
|
|
42
|
+
/** Read and consume an idle signal for a session. Returns null if none exists. */
|
|
43
|
+
async function checkIdleSignal(session) {
|
|
44
|
+
const filePath = path_1.default.join(exports.SIGNAL_DIR, `${session}.signal`);
|
|
45
|
+
try {
|
|
46
|
+
const raw = await fs_1.promises.readFile(filePath, 'utf8');
|
|
47
|
+
await fs_1.promises.unlink(filePath).catch(() => { });
|
|
48
|
+
return JSON.parse(raw);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Common preamble for all hook scripts: get deck_ session name or exit
|
|
55
|
+
const SESSION_PREAMBLE = `\
|
|
56
|
+
SESSION_NAME=$(tmux display-message -p '#S' 2>/dev/null || echo "")
|
|
57
|
+
[ -z "$SESSION_NAME" ] && exit 0
|
|
58
|
+
case "$SESSION_NAME" in
|
|
59
|
+
deck_*) ;;
|
|
60
|
+
*) exit 0 ;;
|
|
61
|
+
esac`;
|
|
62
|
+
const CURL_BASE = (port) => `curl -s -X POST "http://127.0.0.1:${port}/notify" \\\n -H "Content-Type: application/json"`;
|
|
63
|
+
/** Maps CC hook event name → script file name */
|
|
64
|
+
const HOOK_SCRIPTS = {
|
|
65
|
+
Stop: 'cc_hook_stop.sh',
|
|
66
|
+
Notification: 'cc_hook_notify.sh',
|
|
67
|
+
PreToolUse: 'cc_hook_pretool.sh',
|
|
68
|
+
PostToolUse: 'cc_hook_posttool.sh',
|
|
69
|
+
};
|
|
70
|
+
function buildStopScript(port) {
|
|
71
|
+
return `#!/bin/bash
|
|
72
|
+
# Codedeck CC Stop Hook — notifies daemon when Claude Code session goes idle
|
|
73
|
+
|
|
74
|
+
INPUT=$(cat)
|
|
75
|
+
|
|
76
|
+
# Avoid infinite loop when CC continues due to a stop hook
|
|
77
|
+
STOP_HOOK_ACTIVE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('stop_hook_active','false'))" 2>/dev/null || echo "false")
|
|
78
|
+
[ "$STOP_HOOK_ACTIVE" = "true" ] && exit 0
|
|
79
|
+
|
|
80
|
+
${SESSION_PREAMBLE}
|
|
81
|
+
|
|
82
|
+
${CURL_BASE(port)} \\
|
|
83
|
+
-d "{\\"event\\":\\"idle\\",\\"session\\":\\"$SESSION_NAME\\",\\"agentType\\":\\"claude-code\\"}" \\
|
|
84
|
+
--max-time 2 &>/dev/null || true
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
function buildNotifyScript(port) {
|
|
88
|
+
return `#!/bin/bash
|
|
89
|
+
# Codedeck CC Notification Hook — forwards CC notifications to daemon
|
|
90
|
+
|
|
91
|
+
INPUT=$(cat)
|
|
92
|
+
|
|
93
|
+
${SESSION_PREAMBLE}
|
|
94
|
+
|
|
95
|
+
TITLE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('title',''))" 2>/dev/null || echo "")
|
|
96
|
+
MESSAGE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('message',''))" 2>/dev/null || echo "")
|
|
97
|
+
|
|
98
|
+
# Skip empty notifications
|
|
99
|
+
[ -z "$TITLE" ] && [ -z "$MESSAGE" ] && exit 0
|
|
100
|
+
|
|
101
|
+
PAYLOAD=$(python3 -c "import json,sys; print(json.dumps({'event':'notification','session':'$SESSION_NAME','title':'$TITLE','message':'$MESSAGE'}))" 2>/dev/null || echo "")
|
|
102
|
+
[ -z "$PAYLOAD" ] && exit 0
|
|
103
|
+
|
|
104
|
+
${CURL_BASE(port)} \\
|
|
105
|
+
-d "$PAYLOAD" \\
|
|
106
|
+
--max-time 2 &>/dev/null || true
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
function buildPreToolScript(port) {
|
|
110
|
+
return `#!/bin/bash
|
|
111
|
+
# Codedeck CC PreToolUse Hook — reports active tool with input to daemon
|
|
112
|
+
|
|
113
|
+
INPUT=$(cat)
|
|
114
|
+
|
|
115
|
+
${SESSION_PREAMBLE}
|
|
116
|
+
|
|
117
|
+
PAYLOAD=$(echo "$INPUT" | SESSION_NAME="$SESSION_NAME" python3 -c "
|
|
118
|
+
import sys, json, os
|
|
119
|
+
data = json.load(sys.stdin)
|
|
120
|
+
tool = data.get('tool_name', 'unknown')
|
|
121
|
+
tool_input = data.get('tool_input', {})
|
|
122
|
+
session = os.environ.get('SESSION_NAME', '')
|
|
123
|
+
print(json.dumps({'event':'tool_start','session':session,'tool':tool,'tool_input':tool_input}))
|
|
124
|
+
" 2>/dev/null)
|
|
125
|
+
|
|
126
|
+
[ -z "$PAYLOAD" ] && PAYLOAD="{\\"event\\":\\"tool_start\\",\\"session\\":\\"$SESSION_NAME\\",\\"tool\\":\\"unknown\\"}"
|
|
127
|
+
|
|
128
|
+
${CURL_BASE(port)} \\
|
|
129
|
+
-d "$PAYLOAD" \\
|
|
130
|
+
--max-time 2 &>/dev/null || true
|
|
131
|
+
`;
|
|
132
|
+
}
|
|
133
|
+
function buildPostToolScript(port) {
|
|
134
|
+
return `#!/bin/bash
|
|
135
|
+
# Codedeck CC PostToolUse Hook — reports tool completion to daemon
|
|
136
|
+
|
|
137
|
+
INPUT=$(cat)
|
|
138
|
+
|
|
139
|
+
${SESSION_PREAMBLE}
|
|
140
|
+
|
|
141
|
+
${CURL_BASE(port)} \\
|
|
142
|
+
-d "{\\"event\\":\\"tool_end\\",\\"session\\":\\"$SESSION_NAME\\"}" \\
|
|
143
|
+
--max-time 2 &>/dev/null || true
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
/** Write all hook scripts to ~/.codedeck/ and register them in ~/.claude/settings.json. */
|
|
147
|
+
async function setupCCHooks() {
|
|
148
|
+
await fs_1.promises.mkdir(CODEDECK_DIR, { recursive: true });
|
|
149
|
+
const port = hook_server_js_1.activeHookPort;
|
|
150
|
+
// ── 1. Write hook scripts ───────────────────────────────────────────────────
|
|
151
|
+
const scripts = [
|
|
152
|
+
{ name: HOOK_SCRIPTS['Stop'], content: buildStopScript(port) },
|
|
153
|
+
{ name: HOOK_SCRIPTS['Notification'], content: buildNotifyScript(port) },
|
|
154
|
+
{ name: HOOK_SCRIPTS['PreToolUse'], content: buildPreToolScript(port) },
|
|
155
|
+
{ name: HOOK_SCRIPTS['PostToolUse'], content: buildPostToolScript(port) },
|
|
156
|
+
];
|
|
157
|
+
for (const { name, content } of scripts) {
|
|
158
|
+
const scriptPath = path_1.default.join(CODEDECK_DIR, name);
|
|
159
|
+
await fs_1.promises.writeFile(scriptPath, content);
|
|
160
|
+
await fs_1.promises.chmod(scriptPath, 0o755);
|
|
161
|
+
}
|
|
162
|
+
// ── 2. Update ~/.claude/settings.json ──────────────────────────────────────
|
|
163
|
+
let settings = {};
|
|
164
|
+
try {
|
|
165
|
+
const raw = await fs_1.promises.readFile(CC_SETTINGS_PATH, 'utf-8');
|
|
166
|
+
settings = JSON.parse(raw);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// file may not exist yet — start fresh
|
|
170
|
+
}
|
|
171
|
+
const hooks = settings['hooks'] ?? {};
|
|
172
|
+
for (const [eventName, scriptName] of Object.entries(HOOK_SCRIPTS)) {
|
|
173
|
+
const scriptPath = path_1.default.join(CODEDECK_DIR, scriptName);
|
|
174
|
+
const entries = (hooks[eventName] ?? []);
|
|
175
|
+
// Remove any legacy flat entries pointing to any codedeck script (wrong format)
|
|
176
|
+
const cleaned = entries.filter((entry) => {
|
|
177
|
+
const flat = entry;
|
|
178
|
+
return !(flat.type === 'command' && typeof flat.command === 'string' && flat.command.includes('codedeck'));
|
|
179
|
+
});
|
|
180
|
+
// Remove outdated correct-format entries for codedeck scripts (port may have changed)
|
|
181
|
+
const withoutOld = cleaned.filter((entry) => !(Array.isArray(entry.hooks) &&
|
|
182
|
+
entry.hooks.some((h) => h.command.includes('codedeck'))));
|
|
183
|
+
// Register in correct format
|
|
184
|
+
withoutOld.push({
|
|
185
|
+
matcher: '',
|
|
186
|
+
hooks: [{ type: 'command', command: scriptPath }],
|
|
187
|
+
});
|
|
188
|
+
hooks[eventName] = withoutOld;
|
|
189
|
+
}
|
|
190
|
+
settings['hooks'] = hooks;
|
|
191
|
+
// Validate before writing
|
|
192
|
+
const json = JSON.stringify(settings, null, 2);
|
|
193
|
+
JSON.parse(json); // throws if invalid
|
|
194
|
+
await fs_1.promises.mkdir(path_1.default.dirname(CC_SETTINGS_PATH), { recursive: true });
|
|
195
|
+
await fs_1.promises.writeFile(CC_SETTINGS_PATH, json);
|
|
196
|
+
}
|
|
197
|
+
/** @deprecated Use setupCCHooks() instead */
|
|
198
|
+
exports.setupCCStopHook = setupCCHooks;
|
|
199
|
+
//# sourceMappingURL=signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/agent/signal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AAsBH,0CAMC;AAGD,0CASC;AAuGD,oCAgEC;AA7MD,2BAAoC;AACpC,gDAAwB;AACxB,4CAAoB;AACpB,6DAA0D;AAE1D,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,WAAW,CAAC,CAAC;AAC1D,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAE7E,kFAAkF;AAElF,yFAAyF;AAC5E,QAAA,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAQ7D,+DAA+D;AACxD,KAAK,UAAU,eAAe,CAAC,MAAkB;IACtD,MAAM,aAAE,CAAC,KAAK,CAAC,kBAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAU,EAAE,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAU,EAAE,GAAG,MAAM,CAAC,O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X,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;SAClD,CAAC,CAAC;QAEH,KAAK,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,QAAQ,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IAE1B,0BAA0B;IAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB;IAEtC,MAAM,aAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,MAAM,aAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,6CAA6C;AAChC,QAAA,eAAe,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SessionRecord } from '../store/session-store.js';
|
|
2
|
+
export type IdleCallback = (session: SessionRecord) => Promise<void>;
|
|
3
|
+
export interface StatusPollerOptions {
|
|
4
|
+
pollIntervalMs?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* StatusPoller monitors sessions for idle transitions via multi-sample polling.
|
|
8
|
+
* Used for brain-worker orchestration (detecting when a worker finishes its task).
|
|
9
|
+
*
|
|
10
|
+
* For push notifications the hook server (hook-server.ts) is used instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare class StatusPoller {
|
|
13
|
+
private sessions;
|
|
14
|
+
private idleCallbacks;
|
|
15
|
+
private lastStatus;
|
|
16
|
+
private pollTimer?;
|
|
17
|
+
private opts;
|
|
18
|
+
constructor(opts?: StatusPollerOptions);
|
|
19
|
+
addSession(session: SessionRecord): void;
|
|
20
|
+
removeSession(name: string): void;
|
|
21
|
+
onIdle(cb: IdleCallback): void;
|
|
22
|
+
start(): void;
|
|
23
|
+
stop(): void;
|
|
24
|
+
private pollSessions;
|
|
25
|
+
private triggerIdle;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=status-poller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-poller.d.ts","sourceRoot":"","sources":["../../src/agent/status-poller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,UAAU,CAAuC;IACzD,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,IAAI,CAAgC;gBAEhC,IAAI,CAAC,EAAE,mBAAmB;IAItC,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAIxC,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKjC,MAAM,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI;IAI9B,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;YAIE,YAAY;YA2BZ,WAAW;CAS1B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StatusPoller = void 0;
|
|
7
|
+
const tmux_js_1 = require("./tmux.js");
|
|
8
|
+
const detect_js_1 = require("./detect.js");
|
|
9
|
+
const session_manager_js_1 = require("./session-manager.js");
|
|
10
|
+
const logger_js_1 = __importDefault(require("../util/logger.js"));
|
|
11
|
+
/**
|
|
12
|
+
* StatusPoller monitors sessions for idle transitions via multi-sample polling.
|
|
13
|
+
* Used for brain-worker orchestration (detecting when a worker finishes its task).
|
|
14
|
+
*
|
|
15
|
+
* For push notifications the hook server (hook-server.ts) is used instead.
|
|
16
|
+
*/
|
|
17
|
+
class StatusPoller {
|
|
18
|
+
sessions = new Map();
|
|
19
|
+
idleCallbacks = [];
|
|
20
|
+
lastStatus = new Map();
|
|
21
|
+
pollTimer;
|
|
22
|
+
opts;
|
|
23
|
+
constructor(opts) {
|
|
24
|
+
this.opts = { pollIntervalMs: opts?.pollIntervalMs ?? 2000 };
|
|
25
|
+
}
|
|
26
|
+
addSession(session) {
|
|
27
|
+
this.sessions.set(session.name, session);
|
|
28
|
+
}
|
|
29
|
+
removeSession(name) {
|
|
30
|
+
this.sessions.delete(name);
|
|
31
|
+
this.lastStatus.delete(name);
|
|
32
|
+
}
|
|
33
|
+
onIdle(cb) {
|
|
34
|
+
this.idleCallbacks.push(cb);
|
|
35
|
+
}
|
|
36
|
+
start() {
|
|
37
|
+
this.pollTimer = setInterval(() => { void this.pollSessions(); }, this.opts.pollIntervalMs);
|
|
38
|
+
}
|
|
39
|
+
stop() {
|
|
40
|
+
if (this.pollTimer)
|
|
41
|
+
clearInterval(this.pollTimer);
|
|
42
|
+
}
|
|
43
|
+
async pollSessions() {
|
|
44
|
+
for (const session of this.sessions.values()) {
|
|
45
|
+
try {
|
|
46
|
+
const driver = (0, session_manager_js_1.getDriver)(session.agentType);
|
|
47
|
+
const lines = await (0, tmux_js_1.capturePane)(session.name);
|
|
48
|
+
const status = await (0, detect_js_1.detectStatusMulti)(() => (0, tmux_js_1.capturePane)(session.name), session.agentType);
|
|
49
|
+
const prev = this.lastStatus.get(session.name);
|
|
50
|
+
this.lastStatus.set(session.name, status);
|
|
51
|
+
if (status === 'idle' && prev !== 'idle') {
|
|
52
|
+
logger_js_1.default.debug({ session: session.name }, 'Polling detected idle');
|
|
53
|
+
await this.triggerIdle(session);
|
|
54
|
+
}
|
|
55
|
+
if (driver.isOverlay(lines)) {
|
|
56
|
+
logger_js_1.default.debug({ session: session.name }, 'Overlay detected');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
logger_js_1.default.warn({ session: session.name, err: e }, 'Status poll error');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async triggerIdle(session) {
|
|
65
|
+
for (const cb of this.idleCallbacks) {
|
|
66
|
+
try {
|
|
67
|
+
await cb(session);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
logger_js_1.default.error({ session: session.name, err: e }, 'Idle callback error');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.StatusPoller = StatusPoller;
|
|
76
|
+
//# sourceMappingURL=status-poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-poller.js","sourceRoot":"","sources":["../../src/agent/status-poller.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AACxC,2CAAgD;AAChD,6DAAiD;AAGjD,kEAAuC;AAQvC;;;;;GAKG;AACH,MAAa,YAAY;IACf,QAAQ,GAA+B,IAAI,GAAG,EAAE,CAAC;IACjD,aAAa,GAAmB,EAAE,CAAC;IACnC,UAAU,GAA6B,IAAI,GAAG,EAAE,CAAC;IACjD,SAAS,CAAkB;IAC3B,IAAI,CAAgC;IAE5C,YAAY,IAA0B;QACpC,IAAI,CAAC,IAAI,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,IAAI,IAAI,EAAE,CAAC;IAC/D,CAAC;IAED,UAAU,CAAC,OAAsB;QAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO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E,CAAC;oBACzC,mBAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,uBAAuB,CAAC,CAAC;oBACjE,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAClC,CAAC;gBAED,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC5B,mBAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,kBAAkB,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,mBAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,OAAsB;QAC9C,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACpC,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;YACpB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,mBAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;CACF;AApED,oCAoEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface WorkerInfo {
|
|
2
|
+
n: number;
|
|
3
|
+
agentType: string;
|
|
4
|
+
projectDir: string;
|
|
5
|
+
state: 'idle' | 'running' | 'error' | 'stopped';
|
|
6
|
+
}
|
|
7
|
+
export interface BrainPromptOptions {
|
|
8
|
+
projectName: string;
|
|
9
|
+
projectDir: string;
|
|
10
|
+
workers: WorkerInfo[];
|
|
11
|
+
autoFix?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildBrainSystemPrompt(opts: BrainPromptOptions): string;
|
|
14
|
+
//# sourceMappingURL=brain-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-prompt.d.ts","sourceRoot":"","sources":["../../../src/agent/templates/brain-prompt.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;CACjD;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAyDvE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBrainSystemPrompt = buildBrainSystemPrompt;
|
|
4
|
+
function buildBrainSystemPrompt(opts) {
|
|
5
|
+
const { projectName, projectDir, workers, autoFix = false } = opts;
|
|
6
|
+
const workerList = workers
|
|
7
|
+
.map((w) => ` - w${w.n}: ${w.agentType} in ${w.projectDir} [${w.state}]`)
|
|
8
|
+
.join('\n');
|
|
9
|
+
const workerRefs = workers.map((w) => `@w${w.n}`).join(', ');
|
|
10
|
+
const coreCommands = `## Commands
|
|
11
|
+
|
|
12
|
+
### Dispatching work
|
|
13
|
+
- \`@w<N> <message>\` — send a message or task to worker N
|
|
14
|
+
Examples: \`@w1 fix the login bug in src/auth.ts\`, \`@w2 write unit tests for the API\`
|
|
15
|
+
|
|
16
|
+
### Monitoring
|
|
17
|
+
- \`@status\` — request current state of all workers (idle/running/error)
|
|
18
|
+
- \`@screen w<N>\` — capture and review worker N's current terminal output
|
|
19
|
+
|
|
20
|
+
### Communication
|
|
21
|
+
- \`@reply <message>\` — send a response back to the user
|
|
22
|
+
- \`@ask <question>\` — ask the user for input and wait for their response
|
|
23
|
+
|
|
24
|
+
### Workers report to you with
|
|
25
|
+
- \`@brain <message>\` — message sent from a worker to you`;
|
|
26
|
+
const autoFixCommands = autoFix
|
|
27
|
+
? `
|
|
28
|
+
### Auto-fix audit commands (active in this session)
|
|
29
|
+
- \`@audit w<N>\` — trigger design or code review of worker N's latest output
|
|
30
|
+
- \`@approve w<N>\` — approve worker N's current phase (design or code review)
|
|
31
|
+
- \`@reject w<N> <findings>\` — reject with specific findings; initiates a discussion round
|
|
32
|
+
- \`@merge w<N>\` — merge worker N's branch after full approval`
|
|
33
|
+
: '';
|
|
34
|
+
return `You are the brain controller for project "${projectName}" located at ${projectDir}.
|
|
35
|
+
|
|
36
|
+
Your role is to coordinate AI coding agents (workers) to complete tasks efficiently. You review their work, dispatch new instructions, and communicate with the user.
|
|
37
|
+
|
|
38
|
+
## Available Workers
|
|
39
|
+
|
|
40
|
+
${workerList}
|
|
41
|
+
|
|
42
|
+
${coreCommands}${autoFixCommands}
|
|
43
|
+
|
|
44
|
+
## Behavior rules
|
|
45
|
+
|
|
46
|
+
- Issue commands on their own line, one at a time
|
|
47
|
+
- After dispatching work to a worker, wait for the worker idle notification before acting
|
|
48
|
+
- When a worker completes, review its output and either dispatch the next task or @reply to the user
|
|
49
|
+
- Use @ask sparingly — only when genuinely blocked on user input
|
|
50
|
+
- Keep @reply messages concise and actionable
|
|
51
|
+
- Unrecognized output (no @prefix) is ignored by the daemon
|
|
52
|
+
- You can use ${workerRefs} to target specific workers
|
|
53
|
+
|
|
54
|
+
## Current worker states will be injected when workers report idle. React to them.
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=brain-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brain-prompt.js","sourceRoot":"","sources":["../../../src/agent/templates/brain-prompt.ts"],"names":[],"mappings":";;AAcA,wDAyDC;AAzDD,SAAgB,sBAAsB,CAAC,IAAwB;IAC7D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;IAEnE,MAAM,UAAU,GAAG,OAAO;SACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC;SACzE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;2DAeoC,CAAC;IAE1D,MAAM,eAAe,GAAG,OAAO;QAC7B,CAAC,CAAC;;;;;gEAK0D;QAC5D,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,6CAA6C,WAAW,gBAAgB,UAAU;;;;;;EAMzF,UAAU;;EAEV,YAAY,GAAG,eAAe;;;;;;;;;;gBAUhB,UAAU;;;CAGzB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface BrainIdentityOptions {
|
|
2
|
+
projectName: string;
|
|
3
|
+
projectDir: string;
|
|
4
|
+
workers: Array<{
|
|
5
|
+
n: number;
|
|
6
|
+
agentType: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
export interface WorkerIdentityOptions {
|
|
10
|
+
projectName: string;
|
|
11
|
+
projectDir: string;
|
|
12
|
+
workerN: number;
|
|
13
|
+
agentType: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildBrainAgentsMd(opts: BrainIdentityOptions): string;
|
|
16
|
+
export declare function buildWorkerAgentsMd(opts: WorkerIdentityOptions): string;
|
|
17
|
+
export declare function buildSoulMd(role: 'brain' | 'worker', workerN?: number): string;
|
|
18
|
+
export declare function writeSessionIdentity(dir: string, role: 'brain' | 'worker', opts: BrainIdentityOptions | WorkerIdentityOptions): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/agent/templates/identity.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CA6BrE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,MAAM,CAsBvE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAkB9E;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,GAAG,QAAQ,EACxB,IAAI,EAAE,oBAAoB,GAAG,qBAAqB,GACjD,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBrainAgentsMd = buildBrainAgentsMd;
|
|
4
|
+
exports.buildWorkerAgentsMd = buildWorkerAgentsMd;
|
|
5
|
+
exports.buildSoulMd = buildSoulMd;
|
|
6
|
+
exports.writeSessionIdentity = writeSessionIdentity;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
function buildBrainAgentsMd(opts) {
|
|
10
|
+
const { projectName, projectDir, workers } = opts;
|
|
11
|
+
const workerList = workers.map((w) => `- w${w.n}: ${w.agentType}`).join('\n');
|
|
12
|
+
return `# AGENTS.md — Brain Controller
|
|
13
|
+
|
|
14
|
+
## Role
|
|
15
|
+
You are the brain controller for project "${projectName}". You coordinate coding agents (workers) and communicate with the user.
|
|
16
|
+
|
|
17
|
+
## Project
|
|
18
|
+
- Name: ${projectName}
|
|
19
|
+
- Directory: ${projectDir}
|
|
20
|
+
|
|
21
|
+
## Workers under your coordination
|
|
22
|
+
${workerList}
|
|
23
|
+
|
|
24
|
+
## Responsibilities
|
|
25
|
+
- Review worker output when they go idle
|
|
26
|
+
- Dispatch follow-up tasks using @w<N> commands
|
|
27
|
+
- Use @status and @screen to monitor progress
|
|
28
|
+
- Report completion or blockers to the user via @reply
|
|
29
|
+
- Ask the user for input via @ask when genuinely blocked
|
|
30
|
+
|
|
31
|
+
## Command grammar
|
|
32
|
+
- \`@w<N> <message>\` — send task to worker N
|
|
33
|
+
- \`@status\` — get all worker states
|
|
34
|
+
- \`@screen w<N>\` — view worker N's screen
|
|
35
|
+
- \`@reply <message>\` — respond to user
|
|
36
|
+
- \`@ask <question>\` — ask user for input
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
function buildWorkerAgentsMd(opts) {
|
|
40
|
+
const { projectName, projectDir, workerN, agentType } = opts;
|
|
41
|
+
return `# AGENTS.md — Worker w${workerN}
|
|
42
|
+
|
|
43
|
+
## Role
|
|
44
|
+
You are worker w${workerN} in project "${projectName}". You execute coding tasks assigned by the brain controller.
|
|
45
|
+
|
|
46
|
+
## Project
|
|
47
|
+
- Name: ${projectName}
|
|
48
|
+
- Directory: ${projectDir}
|
|
49
|
+
- Agent type: ${agentType}
|
|
50
|
+
|
|
51
|
+
## Responsibilities
|
|
52
|
+
- Execute tasks as instructed by the brain
|
|
53
|
+
- Work autonomously — make coding decisions without asking for input unless truly blocked
|
|
54
|
+
- Use \`@brain <message>\` to communicate blockers or questions back to the brain
|
|
55
|
+
- Complete tasks fully before going idle — the brain will review your work
|
|
56
|
+
|
|
57
|
+
## Communication
|
|
58
|
+
- \`@brain <message>\` — send a message to the brain controller
|
|
59
|
+
- Only use this when you need clarification or are blocked; otherwise work autonomously
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
function buildSoulMd(role, workerN) {
|
|
63
|
+
const roleLabel = role === 'brain' ? 'brain controller' : `worker w${workerN}`;
|
|
64
|
+
return `# soul.md
|
|
65
|
+
|
|
66
|
+
## Identity
|
|
67
|
+
I am the ${roleLabel} in a multi-agent coding system.
|
|
68
|
+
|
|
69
|
+
## Values
|
|
70
|
+
- Precision: I give clear, actionable instructions or complete focused tasks
|
|
71
|
+
- Efficiency: I minimize back-and-forth; I act on what I know
|
|
72
|
+
- Transparency: I report progress and blockers clearly
|
|
73
|
+
- Autonomy: I make reasonable decisions without unnecessary confirmation
|
|
74
|
+
|
|
75
|
+
## Communication style
|
|
76
|
+
- Concise and direct
|
|
77
|
+
- Technical when appropriate
|
|
78
|
+
- No filler or pleasantries in inter-agent messages
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
async function writeSessionIdentity(dir, role, opts) {
|
|
82
|
+
let agentsMd;
|
|
83
|
+
let workerN;
|
|
84
|
+
if (role === 'brain') {
|
|
85
|
+
agentsMd = buildBrainAgentsMd(opts);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const wo = opts;
|
|
89
|
+
agentsMd = buildWorkerAgentsMd(wo);
|
|
90
|
+
workerN = wo.workerN;
|
|
91
|
+
}
|
|
92
|
+
await Promise.all([
|
|
93
|
+
(0, promises_1.writeFile)((0, path_1.join)(dir, 'AGENTS.md'), agentsMd, 'utf8'),
|
|
94
|
+
(0, promises_1.writeFile)((0, path_1.join)(dir, 'soul.md'), buildSoulMd(role, workerN), 'utf8'),
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/agent/templates/identity.ts"],"names":[],"mappings":";;AAgBA,gDA6BC;AAED,kDAsBC;AAED,kCAkBC;AAED,oDAoBC;AA/GD,0CAAwC;AACxC,+BAA4B;AAe5B,SAAgB,kBAAkB,CAAC,IAA0B;IAC3D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9E,OAAO;;;4CAGmC,WAAW;;;UAG7C,WAAW;eACN,UAAU;;;EAGvB,UAAU;;;;;;;;;;;;;;;CAeX,CAAC;AACF,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAA2B;IAC7D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC7D,OAAO,yBAAyB,OAAO;;;kBAGvB,OAAO,gBAAgB,WAAW;;;UAG1C,WAAW;eACN,UAAU;gBACT,SAAS;;;;;;;;;;;CAWxB,CAAC;AACF,CAAC;AAED,SAAgB,WAAW,CAAC,IAAwB,EAAE,OAAgB;IACpE,MAAM,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,OAAO,EAAE,CAAC;IAC/E,OAAO;;;WAGE,SAAS;;;;;;;;;;;;CAYnB,CAAC;AACF,CAAC;AAEM,KAAK,UAAU,oBAAoB,CACxC,GAAW,EACX,IAAwB,EACxB,IAAkD;IAElD,IAAI,QAAgB,CAAC;IACrB,IAAI,OAA2B,CAAC;IAEhC,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,QAAQ,GAAG,kBAAkB,CAAC,IAA4B,CAAC,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,MAAM,EAAE,GAAG,IAA6B,CAAC;QACzC,QAAQ,GAAG,mBAAmB,CAAC,EAAE,CAAC,CAAC;QACnC,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAA,oBAAS,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC;QACnD,IAAA,oBAAS,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC;KACpE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
|
+
/** Run a raw tmux command. */
|
|
3
|
+
export declare function tmuxExec(args: string): Promise<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Capture the visible content of a tmux pane (scrollback history).
|
|
6
|
+
* Returns lines as a string array.
|
|
7
|
+
*/
|
|
8
|
+
export declare function capturePane(session: string, lines?: number): Promise<string[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Capture only the currently visible pane with ANSI color codes.
|
|
11
|
+
* Used for terminal streaming — gives exactly the rows the user sees.
|
|
12
|
+
*/
|
|
13
|
+
export declare function capturePaneVisible(session: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Capture scrollback history (above the visible area) with ANSI colors.
|
|
16
|
+
* -S -N starts N lines before visible top; -E -1 ends at the line before visible row 0.
|
|
17
|
+
*/
|
|
18
|
+
export declare function capturePaneHistory(session: string, lines?: number): Promise<string>;
|
|
19
|
+
/** Send a string of keys to a tmux pane (newline = Enter). */
|
|
20
|
+
/**
|
|
21
|
+
* Send text then Enter to a tmux session.
|
|
22
|
+
* Text and Enter are sent separately with a short delay to avoid
|
|
23
|
+
* paste-burst detection in TUI agents (Codex, Gemini, etc.).
|
|
24
|
+
*/
|
|
25
|
+
export declare function sendKeys(session: string, keys: string): Promise<void>;
|
|
26
|
+
/** @deprecated Use sendKeys — kept as alias for backward compat. */
|
|
27
|
+
export declare const sendKeysDelayedEnter: typeof sendKeys;
|
|
28
|
+
/** Send raw keys without appending Enter (e.g. for Ctrl-C). */
|
|
29
|
+
export declare function sendKey(session: string, key: string): Promise<void>;
|
|
30
|
+
export interface NewSessionOptions {
|
|
31
|
+
cwd?: string;
|
|
32
|
+
env?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/** Create a new detached tmux session. Throws if it already exists. */
|
|
35
|
+
export declare function newSession(name: string, command?: string, opts?: NewSessionOptions): Promise<void>;
|
|
36
|
+
/** Kill a tmux session by name. Does not throw if it doesn't exist. */
|
|
37
|
+
export declare function killSession(name: string): Promise<void>;
|
|
38
|
+
/** List all tmux sessions. Returns session names. */
|
|
39
|
+
export declare function listSessions(): Promise<string[]>;
|
|
40
|
+
/** Check if a tmux session exists. */
|
|
41
|
+
export declare function sessionExists(name: string): Promise<boolean>;
|
|
42
|
+
/** Resize a tmux session window to the given dimensions. */
|
|
43
|
+
export declare function resizeSession(name: string, cols: number, rows: number): Promise<void>;
|
|
44
|
+
/** Get the pane size (cols x rows) of a tmux session. */
|
|
45
|
+
export declare function getPaneSize(session: string): Promise<{
|
|
46
|
+
cols: number;
|
|
47
|
+
rows: number;
|
|
48
|
+
}>;
|
|
49
|
+
/** Read the tmux paste buffer (used for CC /copy output). */
|
|
50
|
+
export declare function showBuffer(): Promise<string>;
|
|
51
|
+
/** Get the pane ID of the first pane in a tmux session (e.g. "%42"). */
|
|
52
|
+
export declare function getPaneId(session: string): Promise<string>;
|
|
53
|
+
/** Get the current working directory of the first pane of a session. */
|
|
54
|
+
export declare function getPaneCwd(session: string): Promise<string>;
|
|
55
|
+
/** Delete the tmux paste buffer (clipboard cleanup after CC /copy). */
|
|
56
|
+
export declare function deleteBuffer(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Send raw terminal input to a tmux session.
|
|
59
|
+
* Maps xterm escape sequences to tmux key names; literal text uses -l flag.
|
|
60
|
+
* Used for keyboard passthrough from the browser terminal.
|
|
61
|
+
*/
|
|
62
|
+
export declare function sendRawInput(session: string, data: string): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if tmux supports `pipe-pane -O` (requires tmux >= 2.6).
|
|
65
|
+
* Result is cached after first call.
|
|
66
|
+
*/
|
|
67
|
+
export declare function checkPipePaneCapability(): Promise<boolean>;
|
|
68
|
+
interface PipePaneHandle {
|
|
69
|
+
/** Readable stream delivering raw PTY bytes from the FIFO. */
|
|
70
|
+
stream: Readable;
|
|
71
|
+
cleanup: () => Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Start a `tmux pipe-pane -O` raw PTY stream for a session.
|
|
75
|
+
* Uses a PID-scoped FIFO with O_RDWR|O_NONBLOCK to avoid blocking/premature-EOF.
|
|
76
|
+
* Returns a ReadStream and a cleanup function.
|
|
77
|
+
*/
|
|
78
|
+
export declare function startPipePaneStream(session: string, paneId: string): Promise<PipePaneHandle>;
|
|
79
|
+
/**
|
|
80
|
+
* Stop an active pipe-pane stream for a session.
|
|
81
|
+
* No-op if no active stream exists.
|
|
82
|
+
*/
|
|
83
|
+
export declare function stopPipePaneStream(session: string): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Clean up any FIFO temp dirs leftover from a previous daemon run with the same PID.
|
|
86
|
+
* Only removes dirs scoped to the current process.pid.
|
|
87
|
+
*/
|
|
88
|
+
export declare function cleanupOrphanFifos(): Promise<void>;
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=tmux.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../../src/agent/tmux.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKvC,8BAA8B;AAC9B,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG5D;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGhF;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzE;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAEvF;AAED,8DAA8D;AAC9D;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3E;AAED,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,iBAAW,CAAC;AAE7C,+DAA+D;AAC/D,wBAAsB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,uEAAuE;AACvE,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAA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