@askexenow/exe-os 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/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/bin/backfill-responses.js +1912 -0
- package/dist/bin/backfill-vectors.js +1642 -0
- package/dist/bin/cleanup-stale-review-tasks.js +1339 -0
- package/dist/bin/cli.js +18800 -0
- package/dist/bin/exe-agent.js +1858 -0
- package/dist/bin/exe-assign.js +1957 -0
- package/dist/bin/exe-boot.js +6460 -0
- package/dist/bin/exe-call.js +197 -0
- package/dist/bin/exe-cloud.js +850 -0
- package/dist/bin/exe-dispatch.js +1146 -0
- package/dist/bin/exe-doctor.js +1657 -0
- package/dist/bin/exe-export-behaviors.js +1494 -0
- package/dist/bin/exe-forget.js +1627 -0
- package/dist/bin/exe-gateway.js +7732 -0
- package/dist/bin/exe-healthcheck.js +207 -0
- package/dist/bin/exe-heartbeat.js +1647 -0
- package/dist/bin/exe-kill.js +1479 -0
- package/dist/bin/exe-launch-agent.js +1704 -0
- package/dist/bin/exe-link.js +192 -0
- package/dist/bin/exe-new-employee.js +852 -0
- package/dist/bin/exe-pending-messages.js +1446 -0
- package/dist/bin/exe-pending-notifications.js +1321 -0
- package/dist/bin/exe-pending-reviews.js +1468 -0
- package/dist/bin/exe-repo-drift.js +95 -0
- package/dist/bin/exe-review.js +1590 -0
- package/dist/bin/exe-search.js +2651 -0
- package/dist/bin/exe-session-cleanup.js +3173 -0
- package/dist/bin/exe-settings.js +354 -0
- package/dist/bin/exe-status.js +1532 -0
- package/dist/bin/exe-team.js +1324 -0
- package/dist/bin/git-sweep.js +2185 -0
- package/dist/bin/graph-backfill.js +1968 -0
- package/dist/bin/graph-export.js +1604 -0
- package/dist/bin/install.js +656 -0
- package/dist/bin/list-providers.js +140 -0
- package/dist/bin/scan-tasks.js +1820 -0
- package/dist/bin/setup.js +951 -0
- package/dist/bin/shard-migrate.js +1494 -0
- package/dist/bin/update.js +95 -0
- package/dist/bin/wiki-sync.js +1514 -0
- package/dist/gateway/index.js +8848 -0
- package/dist/hooks/bug-report-worker.js +2743 -0
- package/dist/hooks/commit-complete.js +2108 -0
- package/dist/hooks/error-recall.js +2861 -0
- package/dist/hooks/exe-heartbeat-hook.js +232 -0
- package/dist/hooks/ingest-worker.js +4793 -0
- package/dist/hooks/ingest.js +684 -0
- package/dist/hooks/instructions-loaded.js +1880 -0
- package/dist/hooks/notification.js +1726 -0
- package/dist/hooks/post-compact.js +1751 -0
- package/dist/hooks/pre-compact.js +1746 -0
- package/dist/hooks/pre-tool-use.js +2191 -0
- package/dist/hooks/prompt-ingest-worker.js +2126 -0
- package/dist/hooks/prompt-submit.js +4693 -0
- package/dist/hooks/response-ingest-worker.js +1936 -0
- package/dist/hooks/session-end.js +1752 -0
- package/dist/hooks/session-start.js +2795 -0
- package/dist/hooks/stop.js +1835 -0
- package/dist/hooks/subagent-stop.js +1726 -0
- package/dist/hooks/summary-worker.js +2661 -0
- package/dist/index.js +11834 -0
- package/dist/lib/cloud-sync.js +495 -0
- package/dist/lib/config.js +222 -0
- package/dist/lib/consolidation.js +476 -0
- package/dist/lib/crypto.js +51 -0
- package/dist/lib/database.js +730 -0
- package/dist/lib/device-registry.js +900 -0
- package/dist/lib/embedder.js +632 -0
- package/dist/lib/employee-templates.js +543 -0
- package/dist/lib/employees.js +177 -0
- package/dist/lib/error-detector.js +156 -0
- package/dist/lib/exe-daemon-client.js +451 -0
- package/dist/lib/exe-daemon.js +8285 -0
- package/dist/lib/file-grep.js +199 -0
- package/dist/lib/hybrid-search.js +1819 -0
- package/dist/lib/identity-templates.js +320 -0
- package/dist/lib/identity.js +223 -0
- package/dist/lib/keychain.js +145 -0
- package/dist/lib/license.js +377 -0
- package/dist/lib/messaging.js +1376 -0
- package/dist/lib/reminders.js +63 -0
- package/dist/lib/schedules.js +1396 -0
- package/dist/lib/session-registry.js +52 -0
- package/dist/lib/skill-learning.js +477 -0
- package/dist/lib/status-brief.js +235 -0
- package/dist/lib/store.js +1551 -0
- package/dist/lib/task-router.js +62 -0
- package/dist/lib/tasks.js +2456 -0
- package/dist/lib/tmux-routing.js +2836 -0
- package/dist/lib/tmux-status.js +261 -0
- package/dist/lib/tmux-transport.js +83 -0
- package/dist/lib/transport.js +128 -0
- package/dist/lib/ws-auth.js +19 -0
- package/dist/lib/ws-client.js +160 -0
- package/dist/mcp/server.js +10538 -0
- package/dist/mcp/tools/complete-reminder.js +67 -0
- package/dist/mcp/tools/create-reminder.js +52 -0
- package/dist/mcp/tools/create-task.js +1853 -0
- package/dist/mcp/tools/deactivate-behavior.js +263 -0
- package/dist/mcp/tools/list-reminders.js +62 -0
- package/dist/mcp/tools/list-tasks.js +463 -0
- package/dist/mcp/tools/send-message.js +1382 -0
- package/dist/mcp/tools/update-task.js +1692 -0
- package/dist/runtime/index.js +6809 -0
- package/dist/tui/App.js +17479 -0
- package/package.json +104 -0
- package/src/commands/exe/assign.md +17 -0
- package/src/commands/exe/build-adv.md +381 -0
- package/src/commands/exe/call.md +133 -0
- package/src/commands/exe/cloud.md +17 -0
- package/src/commands/exe/employee-heartbeat.md +44 -0
- package/src/commands/exe/forget.md +15 -0
- package/src/commands/exe/heartbeat.md +92 -0
- package/src/commands/exe/intercom.md +81 -0
- package/src/commands/exe/kill.md +34 -0
- package/src/commands/exe/launch.md +52 -0
- package/src/commands/exe/link.md +17 -0
- package/src/commands/exe/logs.md +22 -0
- package/src/commands/exe/new-employee.md +12 -0
- package/src/commands/exe/review.md +14 -0
- package/src/commands/exe/schedule.md +108 -0
- package/src/commands/exe/search.md +13 -0
- package/src/commands/exe/sessions.md +25 -0
- package/src/commands/exe/settings.md +13 -0
- package/src/commands/exe/setup.md +171 -0
- package/src/commands/exe/status.md +15 -0
- package/src/commands/exe/team.md +11 -0
- package/src/commands/exe/update.md +11 -0
- package/src/commands/exe.md +181 -0
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/adapters/claude/installer.ts
|
|
4
|
+
import { readFile as readFile3, writeFile as writeFile3, mkdir as mkdir3, readdir } from "fs/promises";
|
|
5
|
+
import { existsSync as existsSync4, readFileSync as readFileSync2 } from "fs";
|
|
6
|
+
import path4 from "path";
|
|
7
|
+
import os3 from "os";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
|
|
10
|
+
// src/lib/agent-symlinks.ts
|
|
11
|
+
import os2 from "os";
|
|
12
|
+
import path3 from "path";
|
|
13
|
+
import {
|
|
14
|
+
existsSync as existsSync3,
|
|
15
|
+
lstatSync,
|
|
16
|
+
mkdirSync,
|
|
17
|
+
readlinkSync as readlinkSync2,
|
|
18
|
+
symlinkSync as symlinkSync2
|
|
19
|
+
} from "fs";
|
|
20
|
+
|
|
21
|
+
// src/lib/employees.ts
|
|
22
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
23
|
+
import { existsSync as existsSync2, symlinkSync, readlinkSync } from "fs";
|
|
24
|
+
import { execSync } from "child_process";
|
|
25
|
+
import path2 from "path";
|
|
26
|
+
|
|
27
|
+
// src/lib/config.ts
|
|
28
|
+
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
29
|
+
import { readFileSync, existsSync, renameSync } from "fs";
|
|
30
|
+
import path from "path";
|
|
31
|
+
import os from "os";
|
|
32
|
+
function resolveDataDir() {
|
|
33
|
+
if (process.env.EXE_OS_DIR) return process.env.EXE_OS_DIR;
|
|
34
|
+
if (process.env.EXE_MEM_DIR) return process.env.EXE_MEM_DIR;
|
|
35
|
+
const newDir = path.join(os.homedir(), ".exe-os");
|
|
36
|
+
const legacyDir = path.join(os.homedir(), ".exe-mem");
|
|
37
|
+
if (!existsSync(newDir) && existsSync(legacyDir)) {
|
|
38
|
+
try {
|
|
39
|
+
renameSync(legacyDir, newDir);
|
|
40
|
+
process.stderr.write(`[exe-os] Migrated data directory: ~/.exe-mem \u2192 ~/.exe-os
|
|
41
|
+
`);
|
|
42
|
+
} catch {
|
|
43
|
+
return legacyDir;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return newDir;
|
|
47
|
+
}
|
|
48
|
+
var EXE_AI_DIR = resolveDataDir();
|
|
49
|
+
var DB_PATH = path.join(EXE_AI_DIR, "memories.db");
|
|
50
|
+
var MODELS_DIR = path.join(EXE_AI_DIR, "models");
|
|
51
|
+
var CONFIG_PATH = path.join(EXE_AI_DIR, "config.json");
|
|
52
|
+
var LEGACY_LANCE_PATH = path.join(EXE_AI_DIR, "local.lance");
|
|
53
|
+
var CURRENT_CONFIG_VERSION = 1;
|
|
54
|
+
var DEFAULT_CONFIG = {
|
|
55
|
+
config_version: CURRENT_CONFIG_VERSION,
|
|
56
|
+
dbPath: DB_PATH,
|
|
57
|
+
modelFile: "jina-embeddings-v5-small-q4_k_m.gguf",
|
|
58
|
+
embeddingDim: 1024,
|
|
59
|
+
batchSize: 20,
|
|
60
|
+
flushIntervalMs: 1e4,
|
|
61
|
+
autoIngestion: true,
|
|
62
|
+
autoRetrieval: true,
|
|
63
|
+
searchMode: "hybrid",
|
|
64
|
+
hookSearchMode: "hybrid",
|
|
65
|
+
fileGrepEnabled: true,
|
|
66
|
+
splashEffect: true,
|
|
67
|
+
consolidationEnabled: true,
|
|
68
|
+
consolidationIntervalMs: 6 * 60 * 60 * 1e3,
|
|
69
|
+
consolidationModel: "claude-haiku-4-5-20251001",
|
|
70
|
+
consolidationMaxCallsPerRun: 20,
|
|
71
|
+
selfQueryRouter: true,
|
|
72
|
+
selfQueryModel: "claude-haiku-4-5-20251001",
|
|
73
|
+
rerankerEnabled: true,
|
|
74
|
+
scalingRoadmap: {
|
|
75
|
+
rerankerAutoTrigger: {
|
|
76
|
+
enabled: true,
|
|
77
|
+
broadQueryMinCardinality: 5e4,
|
|
78
|
+
fetchTopK: 150,
|
|
79
|
+
returnTopK: 5
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
graphRagEnabled: true,
|
|
83
|
+
wikiEnabled: false,
|
|
84
|
+
wikiUrl: "",
|
|
85
|
+
wikiApiKey: "",
|
|
86
|
+
wikiSyncIntervalMs: 30 * 60 * 1e3,
|
|
87
|
+
wikiWorkspaceMapping: {
|
|
88
|
+
exe: "Executive",
|
|
89
|
+
yoshi: "Engineering",
|
|
90
|
+
mari: "Marketing",
|
|
91
|
+
tom: "Engineering",
|
|
92
|
+
sasha: "Production"
|
|
93
|
+
},
|
|
94
|
+
wikiAutoUpdate: true,
|
|
95
|
+
wikiAutoUpdateThreshold: 0.5,
|
|
96
|
+
wikiAutoUpdateCreateNew: true,
|
|
97
|
+
skillLearning: true,
|
|
98
|
+
skillThreshold: 3,
|
|
99
|
+
skillModel: "claude-haiku-4-5-20251001",
|
|
100
|
+
exeHeartbeat: {
|
|
101
|
+
enabled: true,
|
|
102
|
+
intervalSeconds: 60,
|
|
103
|
+
staleInProgressThresholdHours: 2
|
|
104
|
+
},
|
|
105
|
+
sessionLifecycle: {
|
|
106
|
+
idleKillEnabled: true,
|
|
107
|
+
idleKillTicksRequired: 3,
|
|
108
|
+
idleKillIntercomAckWindowMs: 1e4,
|
|
109
|
+
maxAutoInstances: 10
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/lib/employees.ts
|
|
114
|
+
var EMPLOYEES_PATH = path2.join(EXE_AI_DIR, "exe-employees.json");
|
|
115
|
+
async function loadEmployees(employeesPath = EMPLOYEES_PATH) {
|
|
116
|
+
if (!existsSync2(employeesPath)) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
const raw = await readFile2(employeesPath, "utf-8");
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(raw);
|
|
122
|
+
} catch {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/lib/agent-symlinks.ts
|
|
128
|
+
function claudeAgentsDir(homeDir) {
|
|
129
|
+
return path3.join(homeDir, ".claude", "agents");
|
|
130
|
+
}
|
|
131
|
+
function identitySourcePath(homeDir, agentId) {
|
|
132
|
+
return path3.join(homeDir, ".exe-os", "identity", `${agentId}.md`);
|
|
133
|
+
}
|
|
134
|
+
function claudeAgentLinkPath(homeDir, agentId) {
|
|
135
|
+
return path3.join(claudeAgentsDir(homeDir), `${agentId}.md`);
|
|
136
|
+
}
|
|
137
|
+
function ensureAgentSymlink(agentId, homeDir = os2.homedir()) {
|
|
138
|
+
const target = identitySourcePath(homeDir, agentId);
|
|
139
|
+
const link = claudeAgentLinkPath(homeDir, agentId);
|
|
140
|
+
mkdirSync(claudeAgentsDir(homeDir), { recursive: true });
|
|
141
|
+
if (existsSync3(link)) {
|
|
142
|
+
let stat;
|
|
143
|
+
try {
|
|
144
|
+
stat = lstatSync(link);
|
|
145
|
+
} catch {
|
|
146
|
+
return { agentId, action: "conflict", target, link, conflict: "stat_failed" };
|
|
147
|
+
}
|
|
148
|
+
if (!stat.isSymbolicLink()) {
|
|
149
|
+
return { agentId, action: "conflict", target, link, conflict: "regular_file" };
|
|
150
|
+
}
|
|
151
|
+
let currentTarget;
|
|
152
|
+
try {
|
|
153
|
+
currentTarget = readlinkSync2(link);
|
|
154
|
+
} catch {
|
|
155
|
+
return { agentId, action: "conflict", target, link, conflict: "readlink_failed" };
|
|
156
|
+
}
|
|
157
|
+
if (currentTarget === target) {
|
|
158
|
+
return { agentId, action: "already_correct", target, link };
|
|
159
|
+
}
|
|
160
|
+
return { agentId, action: "conflict", target, link, conflict: `points_to:${currentTarget}` };
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
symlinkSync2(target, link);
|
|
164
|
+
} catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
agentId,
|
|
167
|
+
action: "conflict",
|
|
168
|
+
target,
|
|
169
|
+
link,
|
|
170
|
+
conflict: err instanceof Error ? err.message : String(err)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return { agentId, action: "created", target, link };
|
|
174
|
+
}
|
|
175
|
+
async function ensureAllAgentSymlinks(homeDir = os2.homedir()) {
|
|
176
|
+
const employees = await loadEmployees();
|
|
177
|
+
return employees.map((emp) => ensureAgentSymlink(emp.name, homeDir));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// src/lib/mcp-prefix.ts
|
|
181
|
+
var MCP_PRIMARY_KEY = "exe-os";
|
|
182
|
+
var MCP_LEGACY_KEY = "exe-mem";
|
|
183
|
+
var MCP_TOOL_PREFIXES = [
|
|
184
|
+
`mcp__${MCP_PRIMARY_KEY}__`,
|
|
185
|
+
`mcp__${MCP_LEGACY_KEY}__`
|
|
186
|
+
];
|
|
187
|
+
function expandDualPrefixTools(shortNames) {
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const name of shortNames) {
|
|
190
|
+
for (const prefix of MCP_TOOL_PREFIXES) {
|
|
191
|
+
out.push(prefix + name);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/adapters/claude/installer.ts
|
|
198
|
+
function resolvePackageRoot() {
|
|
199
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
200
|
+
let dir = path4.dirname(thisFile);
|
|
201
|
+
const root = path4.parse(dir).root;
|
|
202
|
+
while (dir !== root) {
|
|
203
|
+
const pkgPath = path4.join(dir, "package.json");
|
|
204
|
+
if (existsSync4(pkgPath)) {
|
|
205
|
+
try {
|
|
206
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
|
|
207
|
+
if (pkg.name === "exe-os") return dir;
|
|
208
|
+
} catch {
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
dir = path4.dirname(dir);
|
|
212
|
+
}
|
|
213
|
+
return path4.resolve(path4.dirname(thisFile), "..", "..", "..");
|
|
214
|
+
}
|
|
215
|
+
async function copySlashCommands(packageRoot, homeDir = os3.homedir()) {
|
|
216
|
+
let copied = 0;
|
|
217
|
+
let skipped = 0;
|
|
218
|
+
const skillsBase = path4.join(homeDir, ".claude", "skills");
|
|
219
|
+
const exeDir = path4.join(packageRoot, "src", "commands", "exe");
|
|
220
|
+
if (existsSync4(exeDir)) {
|
|
221
|
+
const entries = await readdir(exeDir);
|
|
222
|
+
const mdFiles = entries.filter((f) => f.endsWith(".md"));
|
|
223
|
+
for (const file of mdFiles) {
|
|
224
|
+
const name = file.replace(".md", "");
|
|
225
|
+
const destDir = path4.join(skillsBase, `exe-${name}`);
|
|
226
|
+
await mkdir3(destDir, { recursive: true });
|
|
227
|
+
const srcPath = path4.join(exeDir, file);
|
|
228
|
+
const destPath = path4.join(destDir, "SKILL.md");
|
|
229
|
+
const result = await copyAsSkill(srcPath, destPath, `exe-${name}`);
|
|
230
|
+
if (result) copied++;
|
|
231
|
+
else skipped++;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const topLevelSrc = path4.join(packageRoot, "src", "commands", "exe.md");
|
|
235
|
+
if (existsSync4(topLevelSrc)) {
|
|
236
|
+
const destDir = path4.join(skillsBase, "exe");
|
|
237
|
+
await mkdir3(destDir, { recursive: true });
|
|
238
|
+
const destPath = path4.join(destDir, "SKILL.md");
|
|
239
|
+
const result = await copyAsSkill(topLevelSrc, destPath, "exe");
|
|
240
|
+
if (result) copied++;
|
|
241
|
+
else skipped++;
|
|
242
|
+
}
|
|
243
|
+
return { copied, skipped };
|
|
244
|
+
}
|
|
245
|
+
async function copyAsSkill(srcPath, destPath, skillName) {
|
|
246
|
+
let content = await readFile3(srcPath, "utf-8");
|
|
247
|
+
const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
|
|
248
|
+
if (fmMatch?.[1]) {
|
|
249
|
+
const fm = fmMatch[1];
|
|
250
|
+
if (fm.includes("name:")) {
|
|
251
|
+
content = content.replace(
|
|
252
|
+
/^(---\n[\s\S]*?)name:\s*[^\n]+/,
|
|
253
|
+
`$1name: ${skillName}`
|
|
254
|
+
);
|
|
255
|
+
} else {
|
|
256
|
+
content = content.replace(/^---\n/, `---
|
|
257
|
+
name: ${skillName}
|
|
258
|
+
`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (existsSync4(destPath)) {
|
|
262
|
+
const existing = await readFile3(destPath, "utf-8");
|
|
263
|
+
if (existing === content) return false;
|
|
264
|
+
}
|
|
265
|
+
await writeFile3(destPath, content);
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
async function registerMcpServer(packageRoot, homeDir = os3.homedir()) {
|
|
269
|
+
const claudeJsonPath = path4.join(homeDir, ".claude.json");
|
|
270
|
+
let claudeJson = {};
|
|
271
|
+
if (existsSync4(claudeJsonPath)) {
|
|
272
|
+
try {
|
|
273
|
+
claudeJson = JSON.parse(await readFile3(claudeJsonPath, "utf-8"));
|
|
274
|
+
} catch {
|
|
275
|
+
claudeJson = {};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!claudeJson.mcpServers) {
|
|
279
|
+
claudeJson.mcpServers = {};
|
|
280
|
+
}
|
|
281
|
+
const newEntry = {
|
|
282
|
+
type: "stdio",
|
|
283
|
+
command: "node",
|
|
284
|
+
args: [path4.join(packageRoot, "dist", "mcp", "server.js")],
|
|
285
|
+
env: {}
|
|
286
|
+
};
|
|
287
|
+
const legacy = claudeJson.mcpServers[MCP_LEGACY_KEY];
|
|
288
|
+
const current = claudeJson.mcpServers[MCP_PRIMARY_KEY];
|
|
289
|
+
const currentMatches = current && JSON.stringify(current) === JSON.stringify(newEntry);
|
|
290
|
+
if (currentMatches && !legacy) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
claudeJson.mcpServers[MCP_PRIMARY_KEY] = newEntry;
|
|
294
|
+
if (legacy) {
|
|
295
|
+
delete claudeJson.mcpServers[MCP_LEGACY_KEY];
|
|
296
|
+
}
|
|
297
|
+
await writeFile3(claudeJsonPath, JSON.stringify(claudeJson, null, 2) + "\n");
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
async function mergeHooks(packageRoot, homeDir = os3.homedir()) {
|
|
301
|
+
const settingsPath = path4.join(homeDir, ".claude", "settings.json");
|
|
302
|
+
let settings = {};
|
|
303
|
+
if (existsSync4(settingsPath)) {
|
|
304
|
+
try {
|
|
305
|
+
settings = JSON.parse(await readFile3(settingsPath, "utf-8"));
|
|
306
|
+
} catch {
|
|
307
|
+
settings = {};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (!settings.hooks) {
|
|
311
|
+
settings.hooks = {};
|
|
312
|
+
}
|
|
313
|
+
const hooksToRegister = [
|
|
314
|
+
{
|
|
315
|
+
event: "PostToolUse",
|
|
316
|
+
group: {
|
|
317
|
+
matcher: "Bash|Edit|Write|Read|Glob|Grep|Agent|mcp__.*",
|
|
318
|
+
hooks: [
|
|
319
|
+
{
|
|
320
|
+
type: "command",
|
|
321
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "ingest.js")}"`
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
type: "command",
|
|
325
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "error-recall.js")}"`
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
},
|
|
329
|
+
marker: "dist/hooks/ingest.js"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
event: "SessionStart",
|
|
333
|
+
group: {
|
|
334
|
+
hooks: [
|
|
335
|
+
{
|
|
336
|
+
type: "command",
|
|
337
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "session-start.js")}"`,
|
|
338
|
+
timeout: 1e4
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
},
|
|
342
|
+
marker: "dist/hooks/session-start.js"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
event: "UserPromptSubmit",
|
|
346
|
+
group: {
|
|
347
|
+
hooks: [
|
|
348
|
+
{
|
|
349
|
+
type: "command",
|
|
350
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "prompt-submit.js")}"`
|
|
351
|
+
}
|
|
352
|
+
]
|
|
353
|
+
},
|
|
354
|
+
marker: "dist/hooks/prompt-submit.js"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
event: "UserPromptSubmit",
|
|
358
|
+
group: {
|
|
359
|
+
hooks: [
|
|
360
|
+
{
|
|
361
|
+
type: "command",
|
|
362
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "exe-heartbeat-hook.js")}"`,
|
|
363
|
+
timeout: 5e3
|
|
364
|
+
}
|
|
365
|
+
]
|
|
366
|
+
},
|
|
367
|
+
marker: "dist/hooks/exe-heartbeat-hook.js"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
event: "Stop",
|
|
371
|
+
group: {
|
|
372
|
+
hooks: [
|
|
373
|
+
{
|
|
374
|
+
type: "command",
|
|
375
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "stop.js")}"`
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
marker: "dist/hooks/stop.js"
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
event: "PreToolUse",
|
|
383
|
+
group: {
|
|
384
|
+
matcher: "Write|Edit|Read|Bash",
|
|
385
|
+
hooks: [
|
|
386
|
+
{
|
|
387
|
+
type: "command",
|
|
388
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "pre-tool-use.js")}"`
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
},
|
|
392
|
+
marker: "dist/hooks/pre-tool-use.js"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
event: "SubagentStop",
|
|
396
|
+
group: {
|
|
397
|
+
hooks: [
|
|
398
|
+
{
|
|
399
|
+
type: "command",
|
|
400
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "subagent-stop.js")}"`
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
},
|
|
404
|
+
marker: "dist/hooks/subagent-stop.js"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
event: "PreCompact",
|
|
408
|
+
group: {
|
|
409
|
+
hooks: [
|
|
410
|
+
{
|
|
411
|
+
type: "command",
|
|
412
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "pre-compact.js")}"`,
|
|
413
|
+
timeout: 1e4
|
|
414
|
+
}
|
|
415
|
+
]
|
|
416
|
+
},
|
|
417
|
+
marker: "dist/hooks/pre-compact.js"
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
event: "SessionEnd",
|
|
421
|
+
group: {
|
|
422
|
+
hooks: [
|
|
423
|
+
{
|
|
424
|
+
type: "command",
|
|
425
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "session-end.js")}"`
|
|
426
|
+
}
|
|
427
|
+
]
|
|
428
|
+
},
|
|
429
|
+
marker: "dist/hooks/session-end.js"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
event: "Notification",
|
|
433
|
+
group: {
|
|
434
|
+
hooks: [
|
|
435
|
+
{
|
|
436
|
+
type: "command",
|
|
437
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "notification.js")}"`
|
|
438
|
+
}
|
|
439
|
+
]
|
|
440
|
+
},
|
|
441
|
+
marker: "dist/hooks/notification.js"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
event: "PostCompact",
|
|
445
|
+
group: {
|
|
446
|
+
hooks: [
|
|
447
|
+
{
|
|
448
|
+
type: "command",
|
|
449
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "post-compact.js")}"`,
|
|
450
|
+
timeout: 1e4
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
},
|
|
454
|
+
marker: "dist/hooks/post-compact.js"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
event: "InstructionsLoaded",
|
|
458
|
+
group: {
|
|
459
|
+
hooks: [
|
|
460
|
+
{
|
|
461
|
+
type: "command",
|
|
462
|
+
command: `node "${path4.join(packageRoot, "dist", "hooks", "instructions-loaded.js")}"`
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
},
|
|
466
|
+
marker: "dist/hooks/instructions-loaded.js"
|
|
467
|
+
}
|
|
468
|
+
];
|
|
469
|
+
let added = 0;
|
|
470
|
+
let skipped = 0;
|
|
471
|
+
for (const { event, group, marker } of hooksToRegister) {
|
|
472
|
+
if (!settings.hooks[event]) {
|
|
473
|
+
settings.hooks[event] = [];
|
|
474
|
+
}
|
|
475
|
+
const existing = settings.hooks[event];
|
|
476
|
+
const alreadyExists = existing.some(
|
|
477
|
+
(g) => g.hooks.some((h) => h.command.includes(marker))
|
|
478
|
+
);
|
|
479
|
+
if (alreadyExists) {
|
|
480
|
+
skipped++;
|
|
481
|
+
} else {
|
|
482
|
+
existing.push(group);
|
|
483
|
+
added++;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const perms = settings.permissions;
|
|
487
|
+
if (!perms) {
|
|
488
|
+
settings.permissions = {};
|
|
489
|
+
}
|
|
490
|
+
const permissions = settings.permissions;
|
|
491
|
+
if (!Array.isArray(permissions.allow)) {
|
|
492
|
+
permissions.allow = [];
|
|
493
|
+
}
|
|
494
|
+
const toolNames = [
|
|
495
|
+
"store_memory",
|
|
496
|
+
"recall_my_memory",
|
|
497
|
+
"create_task",
|
|
498
|
+
"list_tasks",
|
|
499
|
+
"get_task",
|
|
500
|
+
"update_task",
|
|
501
|
+
"close_task",
|
|
502
|
+
"store_behavior",
|
|
503
|
+
"deactivate_behavior",
|
|
504
|
+
"send_message",
|
|
505
|
+
"get_identity",
|
|
506
|
+
"update_identity",
|
|
507
|
+
"ask_team_memory",
|
|
508
|
+
"get_session_context",
|
|
509
|
+
"create_reminder",
|
|
510
|
+
"complete_reminder",
|
|
511
|
+
"list_reminders",
|
|
512
|
+
"list_behaviors",
|
|
513
|
+
"query_relationships",
|
|
514
|
+
"commit_to_long_term_memory"
|
|
515
|
+
];
|
|
516
|
+
const allowList = permissions.allow;
|
|
517
|
+
for (const tool of expandDualPrefixTools(toolNames)) {
|
|
518
|
+
if (!allowList.includes(tool)) {
|
|
519
|
+
allowList.push(tool);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
await mkdir3(path4.dirname(settingsPath), { recursive: true });
|
|
523
|
+
await writeFile3(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
524
|
+
return { added, skipped };
|
|
525
|
+
}
|
|
526
|
+
var EXE_SECTION_START = "<!-- exe-os:orchestration-start -->";
|
|
527
|
+
var EXE_SECTION_END = "<!-- exe-os:orchestration-end -->";
|
|
528
|
+
var ORCHESTRATION_RULES = `${EXE_SECTION_START}
|
|
529
|
+
## exe-os Multi-Agent Orchestration (auto-managed \u2014 do not edit)
|
|
530
|
+
|
|
531
|
+
These rules are injected by exe-os and override default behavior for multi-agent coordination.
|
|
532
|
+
|
|
533
|
+
- **Session routing is deterministic.** When working in exeN (e.g. exe1), ALL employee sessions use the same number: yoshi-exe1, tom-exe1, mari-exe1. NEVER reference, consider, or dispatch to employee sessions from other project numbers. This is not a choice \u2014 it is a hard constraint.
|
|
534
|
+
- **Always use create_task to assign work.** Never use messages, tmux send-keys, or ad-hoc instructions as a substitute for tasks.
|
|
535
|
+
- **Never modify another agent's in-progress task.** Create a new task instead. Modifying active tasks causes race conditions.
|
|
536
|
+
- **Chain of command:** founder \u2192 exe \u2192 yoshi \u2192 engineers. Exe does not assign directly to tom or other engineers below yoshi.
|
|
537
|
+
- **Verify dispatch.** After every create_task, confirm the employee received and started the task via tmux capture-pane.
|
|
538
|
+
${EXE_SECTION_END}`;
|
|
539
|
+
async function injectOrchestrationRules(homeDir) {
|
|
540
|
+
const claudeDir = path4.join(homeDir, ".claude");
|
|
541
|
+
const claudeMdPath = path4.join(claudeDir, "CLAUDE.md");
|
|
542
|
+
await mkdir3(claudeDir, { recursive: true });
|
|
543
|
+
let existing = "";
|
|
544
|
+
try {
|
|
545
|
+
existing = await readFile3(claudeMdPath, "utf-8");
|
|
546
|
+
} catch {
|
|
547
|
+
}
|
|
548
|
+
const startIdx = existing.indexOf(EXE_SECTION_START);
|
|
549
|
+
const endIdx = existing.indexOf(EXE_SECTION_END);
|
|
550
|
+
if (startIdx !== -1 && endIdx !== -1) {
|
|
551
|
+
const currentSection = existing.slice(startIdx, endIdx + EXE_SECTION_END.length);
|
|
552
|
+
if (currentSection === ORCHESTRATION_RULES) {
|
|
553
|
+
return "unchanged";
|
|
554
|
+
}
|
|
555
|
+
const updated = existing.slice(0, startIdx) + ORCHESTRATION_RULES + existing.slice(endIdx + EXE_SECTION_END.length);
|
|
556
|
+
await writeFile3(claudeMdPath, updated, "utf-8");
|
|
557
|
+
return "updated";
|
|
558
|
+
}
|
|
559
|
+
const separator = existing.length > 0 && !existing.endsWith("\n\n") ? "\n\n" : "";
|
|
560
|
+
await writeFile3(claudeMdPath, existing + separator + ORCHESTRATION_RULES + "\n", "utf-8");
|
|
561
|
+
return "injected";
|
|
562
|
+
}
|
|
563
|
+
async function runInstaller(homeDir) {
|
|
564
|
+
const packageRoot = resolvePackageRoot();
|
|
565
|
+
process.stderr.write(`exe-os installer v1.3.0
|
|
566
|
+
`);
|
|
567
|
+
process.stderr.write(`Package root: ${packageRoot}
|
|
568
|
+
|
|
569
|
+
`);
|
|
570
|
+
const cmdResult = await copySlashCommands(packageRoot, homeDir);
|
|
571
|
+
process.stderr.write(
|
|
572
|
+
`Slash commands: ${cmdResult.copied} copied, ${cmdResult.skipped} unchanged
|
|
573
|
+
`
|
|
574
|
+
);
|
|
575
|
+
const mcpChanged = await registerMcpServer(packageRoot, homeDir);
|
|
576
|
+
process.stderr.write(
|
|
577
|
+
`MCP server: ${mcpChanged ? "registered" : "already registered"}
|
|
578
|
+
`
|
|
579
|
+
);
|
|
580
|
+
const hookResult = await mergeHooks(packageRoot, homeDir);
|
|
581
|
+
process.stderr.write(
|
|
582
|
+
`Hooks: ${hookResult.added} added, ${hookResult.skipped} unchanged
|
|
583
|
+
`
|
|
584
|
+
);
|
|
585
|
+
const resolvedHome = homeDir ?? os3.homedir();
|
|
586
|
+
const exeWorkspace = path4.join(resolvedHome, "exe");
|
|
587
|
+
if (!existsSync4(exeWorkspace)) {
|
|
588
|
+
try {
|
|
589
|
+
await mkdir3(path4.join(exeWorkspace, "content"), { recursive: true });
|
|
590
|
+
await mkdir3(path4.join(exeWorkspace, "operations"), { recursive: true });
|
|
591
|
+
await mkdir3(path4.join(exeWorkspace, "output"), { recursive: true });
|
|
592
|
+
process.stderr.write(
|
|
593
|
+
`Created ~/exe/ \u2014 your automation workspace for non-code projects
|
|
594
|
+
`
|
|
595
|
+
);
|
|
596
|
+
} catch {
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
const claudeMdResult = await injectOrchestrationRules(resolvedHome);
|
|
600
|
+
process.stderr.write(
|
|
601
|
+
`CLAUDE.md orchestration: ${claudeMdResult}
|
|
602
|
+
`
|
|
603
|
+
);
|
|
604
|
+
const symlinkResults = await ensureAllAgentSymlinks(resolvedHome);
|
|
605
|
+
process.stderr.write(
|
|
606
|
+
`Agent symlinks: ${summarizeSymlinkResults(symlinkResults)}
|
|
607
|
+
`
|
|
608
|
+
);
|
|
609
|
+
process.stderr.write(`
|
|
610
|
+
exe-os installed successfully.
|
|
611
|
+
`);
|
|
612
|
+
}
|
|
613
|
+
function summarizeSymlinkResults(results) {
|
|
614
|
+
if (results.length === 0) return "no employees in roster";
|
|
615
|
+
const created = results.filter((r) => r.action === "created").length;
|
|
616
|
+
const already = results.filter((r) => r.action === "already_correct").length;
|
|
617
|
+
const conflicts = results.filter((r) => r.action === "conflict");
|
|
618
|
+
let summary = `${created} created, ${already} already linked`;
|
|
619
|
+
if (conflicts.length > 0) {
|
|
620
|
+
const details = conflicts.map((r) => `${r.agentId} (${r.conflict ?? "unknown"})`).join(", ");
|
|
621
|
+
summary += `, ${conflicts.length} conflict(s): ${details}`;
|
|
622
|
+
}
|
|
623
|
+
return summary;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/bin/install.ts
|
|
627
|
+
var args = process.argv.slice(2);
|
|
628
|
+
if (args.includes("--commands-only")) {
|
|
629
|
+
try {
|
|
630
|
+
const packageRoot = resolvePackageRoot();
|
|
631
|
+
const result = await copySlashCommands(packageRoot);
|
|
632
|
+
if (result.copied > 0) {
|
|
633
|
+
process.stderr.write(
|
|
634
|
+
`exe-os: ${result.copied} slash command(s) updated
|
|
635
|
+
`
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
} catch {
|
|
639
|
+
}
|
|
640
|
+
} else if (args.includes("--global")) {
|
|
641
|
+
try {
|
|
642
|
+
await runInstaller();
|
|
643
|
+
} catch (err) {
|
|
644
|
+
console.error(
|
|
645
|
+
"Installation failed:",
|
|
646
|
+
err instanceof Error ? err.message : String(err)
|
|
647
|
+
);
|
|
648
|
+
process.exit(1);
|
|
649
|
+
}
|
|
650
|
+
} else {
|
|
651
|
+
console.error("Usage: npx exe-os --global");
|
|
652
|
+
console.error(
|
|
653
|
+
" Installs exe-os commands, MCP server, and hooks into ~/.claude/"
|
|
654
|
+
);
|
|
655
|
+
process.exit(1);
|
|
656
|
+
}
|