feed-the-machine 1.1.0 → 1.3.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/bin/generate-manifest.mjs +253 -0
- package/bin/install.mjs +372 -26
- package/docs/INBOX.md +233 -0
- package/ftm/SKILL.md +34 -0
- package/ftm-audit/SKILL.md +69 -0
- package/ftm-brainstorm/SKILL.md +51 -0
- package/ftm-browse/SKILL.md +39 -0
- package/ftm-capture/SKILL.md +370 -0
- package/ftm-capture.yml +4 -0
- package/ftm-codex-gate/SKILL.md +59 -0
- package/ftm-config/SKILL.md +35 -0
- package/ftm-council/SKILL.md +56 -0
- package/ftm-dashboard/SKILL.md +34 -0
- package/ftm-debug/SKILL.md +84 -0
- package/ftm-diagram/SKILL.md +44 -0
- package/ftm-executor/SKILL.md +97 -0
- package/ftm-git/SKILL.md +60 -0
- package/ftm-inbox/backend/__init__.py +0 -0
- package/ftm-inbox/backend/adapters/__init__.py +0 -0
- package/ftm-inbox/backend/adapters/_retry.py +64 -0
- package/ftm-inbox/backend/adapters/base.py +230 -0
- package/ftm-inbox/backend/adapters/freshservice.py +104 -0
- package/ftm-inbox/backend/adapters/gmail.py +125 -0
- package/ftm-inbox/backend/adapters/jira.py +136 -0
- package/ftm-inbox/backend/adapters/registry.py +192 -0
- package/ftm-inbox/backend/adapters/slack.py +110 -0
- package/ftm-inbox/backend/db/__init__.py +0 -0
- package/ftm-inbox/backend/db/connection.py +54 -0
- package/ftm-inbox/backend/db/schema.py +78 -0
- package/ftm-inbox/backend/executor/__init__.py +7 -0
- package/ftm-inbox/backend/executor/engine.py +149 -0
- package/ftm-inbox/backend/executor/step_runner.py +98 -0
- package/ftm-inbox/backend/main.py +103 -0
- package/ftm-inbox/backend/models/__init__.py +1 -0
- package/ftm-inbox/backend/models/unified_task.py +36 -0
- package/ftm-inbox/backend/planner/__init__.py +6 -0
- package/ftm-inbox/backend/planner/generator.py +127 -0
- package/ftm-inbox/backend/planner/schema.py +34 -0
- package/ftm-inbox/backend/requirements.txt +5 -0
- package/ftm-inbox/backend/routes/__init__.py +0 -0
- package/ftm-inbox/backend/routes/execute.py +186 -0
- package/ftm-inbox/backend/routes/health.py +52 -0
- package/ftm-inbox/backend/routes/inbox.py +68 -0
- package/ftm-inbox/backend/routes/plan.py +271 -0
- package/ftm-inbox/bin/launchagent.mjs +91 -0
- package/ftm-inbox/bin/setup.mjs +188 -0
- package/ftm-inbox/bin/start.sh +10 -0
- package/ftm-inbox/bin/status.sh +17 -0
- package/ftm-inbox/bin/stop.sh +8 -0
- package/ftm-inbox/config.example.yml +55 -0
- package/ftm-inbox/package-lock.json +2898 -0
- package/ftm-inbox/package.json +26 -0
- package/ftm-inbox/postcss.config.js +6 -0
- package/ftm-inbox/src/app.css +199 -0
- package/ftm-inbox/src/app.html +18 -0
- package/ftm-inbox/src/lib/api.ts +166 -0
- package/ftm-inbox/src/lib/components/ExecutionLog.svelte +81 -0
- package/ftm-inbox/src/lib/components/InboxFeed.svelte +143 -0
- package/ftm-inbox/src/lib/components/PlanStep.svelte +271 -0
- package/ftm-inbox/src/lib/components/PlanView.svelte +206 -0
- package/ftm-inbox/src/lib/components/StreamPanel.svelte +99 -0
- package/ftm-inbox/src/lib/components/TaskCard.svelte +190 -0
- package/ftm-inbox/src/lib/components/ui/EmptyState.svelte +63 -0
- package/ftm-inbox/src/lib/components/ui/KawaiiCard.svelte +86 -0
- package/ftm-inbox/src/lib/components/ui/PillButton.svelte +106 -0
- package/ftm-inbox/src/lib/components/ui/StatusBadge.svelte +67 -0
- package/ftm-inbox/src/lib/components/ui/StreamDrawer.svelte +149 -0
- package/ftm-inbox/src/lib/components/ui/ThemeToggle.svelte +80 -0
- package/ftm-inbox/src/lib/theme.ts +47 -0
- package/ftm-inbox/src/routes/+layout.svelte +76 -0
- package/ftm-inbox/src/routes/+page.svelte +401 -0
- package/ftm-inbox/static/favicon.png +0 -0
- package/ftm-inbox/svelte.config.js +12 -0
- package/ftm-inbox/tailwind.config.ts +63 -0
- package/ftm-inbox/tsconfig.json +13 -0
- package/ftm-inbox/vite.config.ts +6 -0
- package/ftm-intent/SKILL.md +44 -0
- package/ftm-manifest.json +3794 -0
- package/ftm-map/SKILL.md +50 -0
- package/ftm-mind/SKILL.md +173 -66
- package/ftm-pause/SKILL.md +43 -0
- package/ftm-researcher/SKILL.md +55 -0
- package/ftm-resume/SKILL.md +47 -0
- package/ftm-retro/SKILL.md +54 -0
- package/ftm-routine/SKILL.md +36 -0
- package/ftm-state/blackboard/capabilities.json +5 -0
- package/ftm-state/blackboard/capabilities.schema.json +27 -0
- package/ftm-upgrade/SKILL.md +41 -0
- package/hooks/ftm-blackboard-enforcer.sh +28 -27
- package/hooks/ftm-plan-gate.sh +21 -25
- package/install.sh +238 -111
- package/package.json +6 -2
package/bin/install.mjs
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* npx feed-the-machine — installs ftm skills into ~/.claude/skills/
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Full install: skills, hooks, settings.json merge, and verification.
|
|
7
|
+
* Safe to re-run — idempotent.
|
|
8
|
+
*
|
|
9
|
+
* Flags:
|
|
10
|
+
* --with-inbox Also install the inbox service
|
|
11
|
+
* --no-hooks Skip hooks entirely
|
|
12
|
+
* --skip-merge Install hook files but don't touch settings.json
|
|
8
13
|
*/
|
|
9
14
|
|
|
10
|
-
import { existsSync, mkdirSync, readdirSync, lstatSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, unlinkSync, chmodSync } from "fs";
|
|
15
|
+
import { existsSync, mkdirSync, readdirSync, lstatSync, readFileSync, writeFileSync, copyFileSync, symlinkSync, unlinkSync, chmodSync, cpSync } from "fs";
|
|
11
16
|
import { join, basename, dirname } from "path";
|
|
12
|
-
import { homedir } from "os";
|
|
17
|
+
import { homedir, platform } from "os";
|
|
13
18
|
import { fileURLToPath } from "url";
|
|
19
|
+
import { execSync, spawnSync } from "child_process";
|
|
14
20
|
|
|
15
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
16
22
|
const __dirname = dirname(__filename);
|
|
@@ -20,11 +26,25 @@ const SKILLS_DIR = join(HOME, ".claude", "skills");
|
|
|
20
26
|
const STATE_DIR = join(HOME, ".claude", "ftm-state");
|
|
21
27
|
const CONFIG_DIR = join(HOME, ".claude");
|
|
22
28
|
const HOOKS_DIR = join(HOME, ".claude", "hooks");
|
|
29
|
+
const SETTINGS_FILE = join(CONFIG_DIR, "settings.json");
|
|
30
|
+
const INBOX_INSTALL_DIR = join(HOME, ".claude", "ftm-inbox");
|
|
31
|
+
|
|
32
|
+
const ARGS = process.argv.slice(2);
|
|
33
|
+
const WITH_INBOX = ARGS.includes("--with-inbox");
|
|
34
|
+
const NO_HOOKS = ARGS.includes("--no-hooks");
|
|
35
|
+
const SKIP_MERGE = ARGS.includes("--skip-merge");
|
|
36
|
+
|
|
37
|
+
let warnCount = 0;
|
|
23
38
|
|
|
24
39
|
function log(msg) {
|
|
25
40
|
console.log(` ${msg}`);
|
|
26
41
|
}
|
|
27
42
|
|
|
43
|
+
function warn(msg) {
|
|
44
|
+
console.log(` WARN: ${msg}`);
|
|
45
|
+
warnCount++;
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
function ensureDir(dir) {
|
|
29
49
|
if (!existsSync(dir)) {
|
|
30
50
|
mkdirSync(dir, { recursive: true });
|
|
@@ -47,7 +67,212 @@ function safeSymlink(src, dest) {
|
|
|
47
67
|
log(`LINK ${name}`);
|
|
48
68
|
}
|
|
49
69
|
|
|
70
|
+
function commandExists(cmd) {
|
|
71
|
+
try {
|
|
72
|
+
execSync(`command -v ${cmd}`, { stdio: "ignore" });
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function commandVersion(cmd, flag = "--version") {
|
|
80
|
+
try {
|
|
81
|
+
return execSync(`${cmd} ${flag}`, { encoding: "utf8" }).trim().split("\n")[0];
|
|
82
|
+
} catch {
|
|
83
|
+
return "unknown";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// --- Preflight ---
|
|
88
|
+
|
|
89
|
+
function preflight() {
|
|
90
|
+
console.log("Preflight checks...");
|
|
91
|
+
|
|
92
|
+
if (!NO_HOOKS) {
|
|
93
|
+
// jq is required for all shell hooks (they parse JSON stdin via jq)
|
|
94
|
+
if (!commandExists("jq")) {
|
|
95
|
+
console.log("");
|
|
96
|
+
console.log(" ERROR: jq is required for FTM hooks.");
|
|
97
|
+
console.log("");
|
|
98
|
+
console.log(" Install it:");
|
|
99
|
+
console.log(" macOS: brew install jq");
|
|
100
|
+
console.log(" Ubuntu: sudo apt-get install jq");
|
|
101
|
+
console.log(" Alpine: apk add jq");
|
|
102
|
+
console.log("");
|
|
103
|
+
console.log(" Or skip hooks: npx feed-the-machine --no-hooks");
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
log(`jq: ${commandVersion("jq")}`);
|
|
107
|
+
log(`node: ${process.version}`);
|
|
108
|
+
} else {
|
|
109
|
+
log("hooks skipped (--no-hooks)");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log("");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// --- Settings Merge ---
|
|
116
|
+
|
|
117
|
+
function mergeHooksIntoSettings() {
|
|
118
|
+
const templatePath = join(REPO_DIR, "hooks", "settings-template.json");
|
|
119
|
+
if (!existsSync(templatePath)) {
|
|
120
|
+
warn("hooks/settings-template.json not found — hooks installed but not registered");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
console.log("");
|
|
125
|
+
console.log("Registering hooks in settings.json...");
|
|
126
|
+
|
|
127
|
+
// Read and expand ~ to actual home directory
|
|
128
|
+
const rawTemplate = readFileSync(templatePath, "utf8");
|
|
129
|
+
const expandedTemplate = rawTemplate.replace(/~\/.claude/g, join(HOME, ".claude"));
|
|
130
|
+
const template = JSON.parse(expandedTemplate);
|
|
131
|
+
const templateHooks = template.hooks || {};
|
|
132
|
+
|
|
133
|
+
if (!existsSync(SETTINGS_FILE)) {
|
|
134
|
+
// No settings.json — create one with just the hooks
|
|
135
|
+
writeFileSync(SETTINGS_FILE, JSON.stringify({ hooks: templateHooks }, null, 2) + "\n");
|
|
136
|
+
log("CREATED settings.json with FTM hooks");
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Read existing settings
|
|
141
|
+
const existing = JSON.parse(readFileSync(SETTINGS_FILE, "utf8"));
|
|
142
|
+
|
|
143
|
+
// Backup
|
|
144
|
+
const ts = new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
145
|
+
const backupPath = `${SETTINGS_FILE}.ftm-backup-${ts}`;
|
|
146
|
+
copyFileSync(SETTINGS_FILE, backupPath);
|
|
147
|
+
log(`BACKUP ${backupPath}`);
|
|
148
|
+
|
|
149
|
+
// Ensure hooks key exists
|
|
150
|
+
if (!existing.hooks) {
|
|
151
|
+
existing.hooks = {};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Merge each event type
|
|
155
|
+
const events = ["PreToolUse", "UserPromptSubmit", "PostToolUse", "Stop"];
|
|
156
|
+
for (const event of events) {
|
|
157
|
+
const templateEntries = templateHooks[event] || [];
|
|
158
|
+
const existingEntries = existing.hooks[event] || [];
|
|
159
|
+
|
|
160
|
+
if (templateEntries.length === 0) continue;
|
|
161
|
+
|
|
162
|
+
// Check if FTM hooks are already present by looking for ftm- in command paths
|
|
163
|
+
const existingCommands = JSON.stringify(existingEntries);
|
|
164
|
+
const alreadyPresent = templateEntries.some((entry) => {
|
|
165
|
+
const hooks = entry.hooks || [];
|
|
166
|
+
return hooks.some((h) => {
|
|
167
|
+
const cmd = h.command || "";
|
|
168
|
+
const cmdBase = basename(cmd.split(" ").pop()); // handle "node foo.mjs"
|
|
169
|
+
return existingCommands.includes(cmdBase);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (alreadyPresent) {
|
|
174
|
+
log(`SKIP ${event} hooks (already configured)`);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
existing.hooks[event] = [...existingEntries, ...templateEntries];
|
|
179
|
+
log(`MERGE ${event} hooks`);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
writeFileSync(SETTINGS_FILE, JSON.stringify(existing, null, 2) + "\n");
|
|
183
|
+
log("UPDATED settings.json");
|
|
184
|
+
console.log("");
|
|
185
|
+
log("Hooks are active.");
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// --- Verification ---
|
|
189
|
+
|
|
190
|
+
function verify(skillCount, hookCount) {
|
|
191
|
+
console.log("");
|
|
192
|
+
console.log("Verifying installation...");
|
|
193
|
+
|
|
194
|
+
let errors = 0;
|
|
195
|
+
|
|
196
|
+
// Check skill symlinks resolve
|
|
197
|
+
let brokenLinks = 0;
|
|
198
|
+
const skillEntries = readdirSync(SKILLS_DIR).filter((f) => f.startsWith("ftm"));
|
|
199
|
+
for (const entry of skillEntries) {
|
|
200
|
+
const fullPath = join(SKILLS_DIR, entry);
|
|
201
|
+
try {
|
|
202
|
+
if (lstatSync(fullPath).isSymbolicLink() && !existsSync(fullPath)) {
|
|
203
|
+
warn(`broken symlink: ${entry}`);
|
|
204
|
+
brokenLinks++;
|
|
205
|
+
}
|
|
206
|
+
} catch {
|
|
207
|
+
// ignore
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (brokenLinks === 0) {
|
|
211
|
+
log(`Skills: ${skillCount} linked, all symlinks valid`);
|
|
212
|
+
} else {
|
|
213
|
+
errors++;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Check blackboard state
|
|
217
|
+
const contextFile = join(STATE_DIR, "blackboard", "context.json");
|
|
218
|
+
const patternsFile = join(STATE_DIR, "blackboard", "patterns.json");
|
|
219
|
+
if (existsSync(contextFile) && existsSync(patternsFile)) {
|
|
220
|
+
log("Blackboard: initialized");
|
|
221
|
+
} else {
|
|
222
|
+
warn("blackboard state incomplete");
|
|
223
|
+
errors++;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Check config
|
|
227
|
+
if (existsSync(join(CONFIG_DIR, "ftm-config.yml"))) {
|
|
228
|
+
log("Config: present");
|
|
229
|
+
} else {
|
|
230
|
+
warn("ftm-config.yml missing");
|
|
231
|
+
errors++;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Check hooks
|
|
235
|
+
if (!NO_HOOKS && hookCount > 0) {
|
|
236
|
+
const hookFiles = readdirSync(HOOKS_DIR).filter((f) => f.startsWith("ftm-"));
|
|
237
|
+
const allExecutable = hookFiles
|
|
238
|
+
.filter((f) => f.endsWith(".sh"))
|
|
239
|
+
.every((f) => {
|
|
240
|
+
try {
|
|
241
|
+
const stat = lstatSync(join(HOOKS_DIR, f));
|
|
242
|
+
return (stat.mode & 0o111) !== 0;
|
|
243
|
+
} catch {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
if (allExecutable) {
|
|
249
|
+
log(`Hooks: ${hookCount} installed, all executable`);
|
|
250
|
+
} else {
|
|
251
|
+
warn("some hook files not executable");
|
|
252
|
+
errors++;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Verify settings.json has FTM hooks
|
|
256
|
+
if (!SKIP_MERGE && existsSync(SETTINGS_FILE)) {
|
|
257
|
+
const settingsContent = readFileSync(SETTINGS_FILE, "utf8");
|
|
258
|
+
const ftmMatches = (settingsContent.match(/ftm-/g) || []).length;
|
|
259
|
+
if (ftmMatches > 0) {
|
|
260
|
+
log(`Settings: ${ftmMatches} FTM entries in settings.json`);
|
|
261
|
+
} else {
|
|
262
|
+
warn("no FTM hooks found in settings.json");
|
|
263
|
+
errors++;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return { errors };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// --- Main ---
|
|
272
|
+
|
|
50
273
|
function main() {
|
|
274
|
+
preflight();
|
|
275
|
+
|
|
51
276
|
console.log(`Installing ftm skills from: ${REPO_DIR}`);
|
|
52
277
|
console.log(`Linking into: ${SKILLS_DIR}`);
|
|
53
278
|
console.log("");
|
|
@@ -77,9 +302,13 @@ function main() {
|
|
|
77
302
|
safeSymlink(join(REPO_DIR, dir), join(SKILLS_DIR, dir));
|
|
78
303
|
}
|
|
79
304
|
|
|
305
|
+
console.log("");
|
|
306
|
+
log(`${ymlFiles.length} skills linked.`);
|
|
307
|
+
|
|
80
308
|
// Set up blackboard state (copy templates, don't overwrite existing data)
|
|
81
309
|
const bbDir = join(REPO_DIR, "ftm-state", "blackboard");
|
|
82
310
|
if (existsSync(bbDir)) {
|
|
311
|
+
console.log("");
|
|
83
312
|
ensureDir(join(STATE_DIR, "blackboard", "experiences"));
|
|
84
313
|
|
|
85
314
|
const jsonFiles = readdirSync(bbDir).filter((f) => f.endsWith(".json"));
|
|
@@ -108,37 +337,154 @@ function main() {
|
|
|
108
337
|
}
|
|
109
338
|
|
|
110
339
|
// Install hooks
|
|
111
|
-
const hooksDir = join(REPO_DIR, "hooks");
|
|
112
340
|
let hookCount = 0;
|
|
113
|
-
|
|
114
|
-
|
|
341
|
+
|
|
342
|
+
if (NO_HOOKS) {
|
|
115
343
|
console.log("");
|
|
116
|
-
console.log("
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
344
|
+
console.log("Skipping hooks (--no-hooks).");
|
|
345
|
+
} else {
|
|
346
|
+
const hooksDir = join(REPO_DIR, "hooks");
|
|
347
|
+
if (existsSync(hooksDir)) {
|
|
348
|
+
ensureDir(HOOKS_DIR);
|
|
349
|
+
console.log("");
|
|
350
|
+
console.log("Installing hooks...");
|
|
351
|
+
|
|
352
|
+
const hookFiles = readdirSync(hooksDir).filter(
|
|
353
|
+
(f) => f.startsWith("ftm-") && (f.endsWith(".sh") || f.endsWith(".mjs"))
|
|
354
|
+
);
|
|
355
|
+
for (const hook of hookFiles) {
|
|
356
|
+
const src = join(hooksDir, hook);
|
|
357
|
+
const dest = join(HOOKS_DIR, hook);
|
|
358
|
+
const action = existsSync(dest) ? "UPDATE" : "INSTALL";
|
|
359
|
+
copyFileSync(src, dest);
|
|
360
|
+
if (hook.endsWith(".sh")) {
|
|
361
|
+
chmodSync(dest, 0o755);
|
|
362
|
+
}
|
|
363
|
+
log(`${action} ${hook}`);
|
|
364
|
+
hookCount++;
|
|
128
365
|
}
|
|
129
|
-
|
|
130
|
-
|
|
366
|
+
|
|
367
|
+
console.log("");
|
|
368
|
+
log(`${hookCount} hooks installed to ${HOOKS_DIR}`);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Merge hooks into settings.json
|
|
372
|
+
if (SKIP_MERGE) {
|
|
373
|
+
console.log("");
|
|
374
|
+
log("Skipping settings.json merge (--skip-merge).");
|
|
375
|
+
log("Add entries from hooks/settings-template.json to ~/.claude/settings.json manually.");
|
|
376
|
+
} else {
|
|
377
|
+
mergeHooksIntoSettings();
|
|
131
378
|
}
|
|
132
379
|
}
|
|
133
380
|
|
|
381
|
+
// Verification
|
|
382
|
+
const { errors } = verify(ymlFiles.length, hookCount);
|
|
383
|
+
|
|
384
|
+
// Summary
|
|
134
385
|
console.log("");
|
|
135
|
-
|
|
386
|
+
if (errors === 0 && warnCount === 0) {
|
|
387
|
+
console.log(`Done. ${ymlFiles.length} skills, ${hookCount} hooks. Everything checks out.`);
|
|
388
|
+
} else {
|
|
389
|
+
console.log(`Done. ${ymlFiles.length} skills, ${hookCount} hooks. ${warnCount} warning(s).`);
|
|
390
|
+
}
|
|
391
|
+
console.log("");
|
|
392
|
+
console.log("Restart Claude Code (or start a new session) to pick up the skills.");
|
|
393
|
+
|
|
394
|
+
if (WITH_INBOX) {
|
|
395
|
+
console.log("");
|
|
396
|
+
installInbox();
|
|
397
|
+
} else {
|
|
398
|
+
console.log("Try: /ftm help");
|
|
399
|
+
console.log(" To also install the inbox service: npx feed-the-machine --with-inbox");
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function installInbox() {
|
|
404
|
+
const inboxSrc = join(REPO_DIR, "ftm-inbox");
|
|
405
|
+
if (!existsSync(inboxSrc)) {
|
|
406
|
+
console.error("ERROR: ftm-inbox/ not found in package. Cannot install inbox service.");
|
|
407
|
+
process.exit(1);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
console.log("Installing ftm-inbox service...");
|
|
411
|
+
console.log(` Source: ${inboxSrc}`);
|
|
412
|
+
console.log(` Destination: ${INBOX_INSTALL_DIR}`);
|
|
413
|
+
console.log("");
|
|
414
|
+
|
|
415
|
+
// Copy ftm-inbox/ to ~/.claude/ftm-inbox/
|
|
416
|
+
ensureDir(INBOX_INSTALL_DIR);
|
|
417
|
+
cpSync(inboxSrc, INBOX_INSTALL_DIR, { recursive: true });
|
|
418
|
+
log("COPY ftm-inbox → ~/.claude/ftm-inbox/");
|
|
419
|
+
|
|
420
|
+
// Make shell scripts executable
|
|
421
|
+
const binDir = join(INBOX_INSTALL_DIR, "bin");
|
|
422
|
+
const scripts = ["start.sh", "stop.sh", "status.sh"];
|
|
423
|
+
for (const script of scripts) {
|
|
424
|
+
const scriptPath = join(binDir, script);
|
|
425
|
+
if (existsSync(scriptPath)) {
|
|
426
|
+
chmodSync(scriptPath, 0o755);
|
|
427
|
+
log(`CHMOD +x bin/${script}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Install Node deps if package.json exists
|
|
432
|
+
const pkgJson = join(INBOX_INSTALL_DIR, "package.json");
|
|
433
|
+
if (existsSync(pkgJson)) {
|
|
434
|
+
console.log("");
|
|
435
|
+
console.log("Installing Node.js dependencies...");
|
|
436
|
+
const npmResult = spawnSync("npm", ["install", "--prefix", INBOX_INSTALL_DIR], {
|
|
437
|
+
stdio: "inherit",
|
|
438
|
+
cwd: INBOX_INSTALL_DIR,
|
|
439
|
+
});
|
|
440
|
+
if (npmResult.status !== 0) {
|
|
441
|
+
console.warn("WARNING: npm install failed. Check Node.js version and try manually.");
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Install Python deps if requirements.txt exists
|
|
446
|
+
const reqTxt = join(INBOX_INSTALL_DIR, "requirements.txt");
|
|
447
|
+
if (existsSync(reqTxt)) {
|
|
448
|
+
console.log("");
|
|
449
|
+
console.log("Installing Python dependencies...");
|
|
450
|
+
const pipResult = spawnSync("pip3", ["install", "-r", reqTxt], {
|
|
451
|
+
stdio: "inherit",
|
|
452
|
+
cwd: INBOX_INSTALL_DIR,
|
|
453
|
+
});
|
|
454
|
+
if (pipResult.status !== 0) {
|
|
455
|
+
console.warn("WARNING: pip3 install failed. Check Python 3 and try manually:");
|
|
456
|
+
console.warn(` pip3 install -r ${reqTxt}`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Run setup wizard
|
|
461
|
+
console.log("");
|
|
462
|
+
console.log("Running setup wizard...");
|
|
463
|
+
const setupScript = join(binDir, "setup.mjs");
|
|
464
|
+
if (existsSync(setupScript)) {
|
|
465
|
+
const setupResult = spawnSync("node", [setupScript], { stdio: "inherit" });
|
|
466
|
+
if (setupResult.status !== 0) {
|
|
467
|
+
console.warn("WARNING: Setup wizard exited with errors.");
|
|
468
|
+
console.warn(`Re-run manually: node ${setupScript}`);
|
|
469
|
+
}
|
|
470
|
+
} else {
|
|
471
|
+
console.warn("WARNING: setup.mjs not found. Run setup manually.");
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Offer LaunchAgent (macOS only)
|
|
475
|
+
if (platform() === "darwin") {
|
|
476
|
+
console.log("");
|
|
477
|
+
console.log("macOS detected. To auto-start ftm-inbox on login, run:");
|
|
478
|
+
console.log(` node ${join(binDir, "launchagent.mjs")}`);
|
|
479
|
+
}
|
|
480
|
+
|
|
136
481
|
console.log("");
|
|
137
|
-
console.log("
|
|
138
|
-
console.log(
|
|
139
|
-
console.log(
|
|
140
|
-
console.log(
|
|
482
|
+
console.log("ftm-inbox installed.");
|
|
483
|
+
console.log(` Start: ${join(binDir, "start.sh")}`);
|
|
484
|
+
console.log(` Stop: ${join(binDir, "stop.sh")}`);
|
|
485
|
+
console.log(` Status: ${join(binDir, "status.sh")}`);
|
|
141
486
|
console.log("");
|
|
487
|
+
console.log("See docs/INBOX.md for full documentation.");
|
|
142
488
|
console.log("Try: /ftm help");
|
|
143
489
|
}
|
|
144
490
|
|
package/docs/INBOX.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# ftm-inbox
|
|
2
|
+
|
|
3
|
+
ftm-inbox is an optional background service that polls your work tools (Jira, Freshservice, Slack, Gmail) and surfaces actionable items directly inside the FTM Operator Cockpit dashboard. It runs locally on your machine and never sends data to external services.
|
|
4
|
+
|
|
5
|
+
## What It Does
|
|
6
|
+
|
|
7
|
+
Without ftm-inbox, the Operator Cockpit is a static interface. With it:
|
|
8
|
+
|
|
9
|
+
- Jira issues assigned to you appear as inbox items
|
|
10
|
+
- Freshservice tickets awaiting your response are surfaced
|
|
11
|
+
- Slack DMs and mentions are queued for triage
|
|
12
|
+
- Gmail threads that match configurable filters are included
|
|
13
|
+
|
|
14
|
+
Each item is stored in a local SQLite database. The FTM skills (`/ftm-mind`, `/ftm-executor`) can read from this inbox to generate plans and take action on your behalf.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx feed-the-machine --with-inbox
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This will:
|
|
23
|
+
|
|
24
|
+
1. Install core FTM skills (same as `npx feed-the-machine`)
|
|
25
|
+
2. Copy `ftm-inbox/` to `~/.claude/ftm-inbox/`
|
|
26
|
+
3. Run `npm install` for Node dependencies
|
|
27
|
+
4. Run `pip3 install -r requirements.txt` for Python dependencies
|
|
28
|
+
5. Launch the interactive setup wizard
|
|
29
|
+
6. Optionally install a macOS LaunchAgent for auto-start on login
|
|
30
|
+
|
|
31
|
+
The core `npx feed-the-machine` install (without `--with-inbox`) is completely unchanged.
|
|
32
|
+
|
|
33
|
+
### Requirements
|
|
34
|
+
|
|
35
|
+
- Node.js 18+
|
|
36
|
+
- Python 3.9+
|
|
37
|
+
- `pip3` in PATH
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
The setup wizard writes credentials to `~/.claude/ftm-inbox/config.yml`. This directory is outside any git repository and should never be committed.
|
|
42
|
+
|
|
43
|
+
### config.yml reference
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
server:
|
|
47
|
+
port: 8042 # Port for the local API (default: 8042)
|
|
48
|
+
|
|
49
|
+
adapters:
|
|
50
|
+
jira:
|
|
51
|
+
enabled: true
|
|
52
|
+
base_url: "https://yourorg.atlassian.net"
|
|
53
|
+
email: "you@example.com"
|
|
54
|
+
api_token: "your-jira-api-token"
|
|
55
|
+
poll_interval_seconds: 60
|
|
56
|
+
|
|
57
|
+
freshservice:
|
|
58
|
+
enabled: true
|
|
59
|
+
domain: "yourorg.freshservice.com"
|
|
60
|
+
api_key: "your-freshservice-api-key"
|
|
61
|
+
poll_interval_seconds: 120
|
|
62
|
+
|
|
63
|
+
slack:
|
|
64
|
+
enabled: true
|
|
65
|
+
bot_token: "xoxb-your-slack-bot-token"
|
|
66
|
+
poll_interval_seconds: 30
|
|
67
|
+
|
|
68
|
+
gmail:
|
|
69
|
+
enabled: false
|
|
70
|
+
credentials_path: "~/credentials.json"
|
|
71
|
+
poll_interval_seconds: 120
|
|
72
|
+
|
|
73
|
+
database:
|
|
74
|
+
path: "~/.claude/ftm-inbox/inbox.db"
|
|
75
|
+
|
|
76
|
+
logging:
|
|
77
|
+
level: "INFO"
|
|
78
|
+
path: "~/.claude/ftm-inbox/logs"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
To re-run the wizard after initial setup:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
node ~/.claude/ftm-inbox/bin/setup.mjs
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
To edit manually:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
$EDITOR ~/.claude/ftm-inbox/config.yml
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Starting and Stopping
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Start the service
|
|
97
|
+
~/.claude/ftm-inbox/bin/start.sh
|
|
98
|
+
|
|
99
|
+
# Stop the service
|
|
100
|
+
~/.claude/ftm-inbox/bin/stop.sh
|
|
101
|
+
|
|
102
|
+
# Check status and last poll times
|
|
103
|
+
~/.claude/ftm-inbox/bin/status.sh
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The port can be overridden at runtime:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
FTM_INBOX_PORT=9000 ~/.claude/ftm-inbox/bin/start.sh
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Auto-start on Login (macOS)
|
|
113
|
+
|
|
114
|
+
To generate and load a LaunchAgent that starts ftm-inbox on login:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
node ~/.claude/ftm-inbox/bin/launchagent.mjs
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
This creates `~/Library/LaunchAgents/com.ftm.inbox.plist` and loads it immediately. Logs are written to `~/.claude/ftm-inbox/logs/`.
|
|
121
|
+
|
|
122
|
+
To remove the LaunchAgent:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
launchctl unload ~/Library/LaunchAgents/com.ftm.inbox.plist
|
|
126
|
+
rm ~/Library/LaunchAgents/com.ftm.inbox.plist
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Architecture
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
External Services ftm-inbox FTM Skills
|
|
133
|
+
────────────────── ───────────────────────── ──────────────────
|
|
134
|
+
Jira REST API ──────► Jira Adapter (poller) ─┐
|
|
135
|
+
Freshservice API ──────► Freshservice Adapter ─┤► SQLite DB ──► FastAPI ──► /ftm-mind
|
|
136
|
+
Slack API ──────► Slack Adapter ─┤ inbox.db 8042 /ftm-executor
|
|
137
|
+
Gmail API ──────► Gmail Adapter ─┘
|
|
138
|
+
▲
|
|
139
|
+
│
|
|
140
|
+
Svelte Dashboard
|
|
141
|
+
(Operator Cockpit)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- **Adapters** poll their respective APIs on configurable intervals and write normalized `InboxItem` records to SQLite
|
|
145
|
+
- **FastAPI backend** (`backend/main.py`) exposes a REST API at `http://localhost:8042`
|
|
146
|
+
- **Svelte dashboard** reads from the API and renders the Operator Cockpit UI
|
|
147
|
+
- **FTM skills** use the API to read inbox items and generate or execute plans
|
|
148
|
+
|
|
149
|
+
## Adding a Custom Poller
|
|
150
|
+
|
|
151
|
+
1. Create a new file in `ftm-inbox/backend/adapters/`:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# ftm-inbox/backend/adapters/my_service.py
|
|
155
|
+
from .base import BaseAdapter, InboxItem
|
|
156
|
+
from typing import List
|
|
157
|
+
|
|
158
|
+
class MyServiceAdapter(BaseAdapter):
|
|
159
|
+
name = "my_service"
|
|
160
|
+
|
|
161
|
+
async def fetch(self) -> List[InboxItem]:
|
|
162
|
+
# Hit your API, return a list of InboxItem objects
|
|
163
|
+
items = []
|
|
164
|
+
# ... your logic here ...
|
|
165
|
+
return items
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
2. Add credentials to `~/.claude/ftm-inbox/config.yml`:
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
adapters:
|
|
172
|
+
my_service:
|
|
173
|
+
enabled: true
|
|
174
|
+
api_key: "your-key"
|
|
175
|
+
poll_interval_seconds: 60
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
3. Register it in `ftm-inbox/backend/adapters/__init__.py`:
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from .my_service import MyServiceAdapter
|
|
182
|
+
ADAPTERS = [..., MyServiceAdapter]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
4. Restart the service: `~/.claude/ftm-inbox/bin/stop.sh && ~/.claude/ftm-inbox/bin/start.sh`
|
|
186
|
+
|
|
187
|
+
## Troubleshooting
|
|
188
|
+
|
|
189
|
+
### Service won't start
|
|
190
|
+
|
|
191
|
+
Check that Python 3 and uvicorn are installed:
|
|
192
|
+
```bash
|
|
193
|
+
python3 --version
|
|
194
|
+
python3 -c "import uvicorn; print(uvicorn.__version__)"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If uvicorn is missing:
|
|
198
|
+
```bash
|
|
199
|
+
pip3 install -r ~/.claude/ftm-inbox/requirements.txt
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### No items appearing in the dashboard
|
|
203
|
+
|
|
204
|
+
1. Check the service is running: `~/.claude/ftm-inbox/bin/status.sh`
|
|
205
|
+
2. Check logs: `tail -f ~/.claude/ftm-inbox/logs/*.log`
|
|
206
|
+
3. Verify credentials in `~/.claude/ftm-inbox/config.yml`
|
|
207
|
+
4. Confirm the adapter is set to `enabled: true`
|
|
208
|
+
|
|
209
|
+
### Port conflict
|
|
210
|
+
|
|
211
|
+
If port 8042 is already in use:
|
|
212
|
+
```bash
|
|
213
|
+
FTM_INBOX_PORT=9042 ~/.claude/ftm-inbox/bin/start.sh
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Update `config.yml` to match so the dashboard connects to the right port.
|
|
217
|
+
|
|
218
|
+
### Jira authentication errors
|
|
219
|
+
|
|
220
|
+
Jira Cloud requires an API token, not your password. Generate one at:
|
|
221
|
+
`https://id.atlassian.com/manage-profile/security/api-tokens`
|
|
222
|
+
|
|
223
|
+
### Freshservice 403 errors
|
|
224
|
+
|
|
225
|
+
Ensure the API key belongs to an agent with at least Viewer permissions on the relevant groups.
|
|
226
|
+
|
|
227
|
+
### Re-running setup
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
node ~/.claude/ftm-inbox/bin/setup.mjs
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
This overwrites `~/.claude/ftm-inbox/config.yml` but does not touch the database.
|