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.
Files changed (92) hide show
  1. package/bin/generate-manifest.mjs +253 -0
  2. package/bin/install.mjs +372 -26
  3. package/docs/INBOX.md +233 -0
  4. package/ftm/SKILL.md +34 -0
  5. package/ftm-audit/SKILL.md +69 -0
  6. package/ftm-brainstorm/SKILL.md +51 -0
  7. package/ftm-browse/SKILL.md +39 -0
  8. package/ftm-capture/SKILL.md +370 -0
  9. package/ftm-capture.yml +4 -0
  10. package/ftm-codex-gate/SKILL.md +59 -0
  11. package/ftm-config/SKILL.md +35 -0
  12. package/ftm-council/SKILL.md +56 -0
  13. package/ftm-dashboard/SKILL.md +34 -0
  14. package/ftm-debug/SKILL.md +84 -0
  15. package/ftm-diagram/SKILL.md +44 -0
  16. package/ftm-executor/SKILL.md +97 -0
  17. package/ftm-git/SKILL.md +60 -0
  18. package/ftm-inbox/backend/__init__.py +0 -0
  19. package/ftm-inbox/backend/adapters/__init__.py +0 -0
  20. package/ftm-inbox/backend/adapters/_retry.py +64 -0
  21. package/ftm-inbox/backend/adapters/base.py +230 -0
  22. package/ftm-inbox/backend/adapters/freshservice.py +104 -0
  23. package/ftm-inbox/backend/adapters/gmail.py +125 -0
  24. package/ftm-inbox/backend/adapters/jira.py +136 -0
  25. package/ftm-inbox/backend/adapters/registry.py +192 -0
  26. package/ftm-inbox/backend/adapters/slack.py +110 -0
  27. package/ftm-inbox/backend/db/__init__.py +0 -0
  28. package/ftm-inbox/backend/db/connection.py +54 -0
  29. package/ftm-inbox/backend/db/schema.py +78 -0
  30. package/ftm-inbox/backend/executor/__init__.py +7 -0
  31. package/ftm-inbox/backend/executor/engine.py +149 -0
  32. package/ftm-inbox/backend/executor/step_runner.py +98 -0
  33. package/ftm-inbox/backend/main.py +103 -0
  34. package/ftm-inbox/backend/models/__init__.py +1 -0
  35. package/ftm-inbox/backend/models/unified_task.py +36 -0
  36. package/ftm-inbox/backend/planner/__init__.py +6 -0
  37. package/ftm-inbox/backend/planner/generator.py +127 -0
  38. package/ftm-inbox/backend/planner/schema.py +34 -0
  39. package/ftm-inbox/backend/requirements.txt +5 -0
  40. package/ftm-inbox/backend/routes/__init__.py +0 -0
  41. package/ftm-inbox/backend/routes/execute.py +186 -0
  42. package/ftm-inbox/backend/routes/health.py +52 -0
  43. package/ftm-inbox/backend/routes/inbox.py +68 -0
  44. package/ftm-inbox/backend/routes/plan.py +271 -0
  45. package/ftm-inbox/bin/launchagent.mjs +91 -0
  46. package/ftm-inbox/bin/setup.mjs +188 -0
  47. package/ftm-inbox/bin/start.sh +10 -0
  48. package/ftm-inbox/bin/status.sh +17 -0
  49. package/ftm-inbox/bin/stop.sh +8 -0
  50. package/ftm-inbox/config.example.yml +55 -0
  51. package/ftm-inbox/package-lock.json +2898 -0
  52. package/ftm-inbox/package.json +26 -0
  53. package/ftm-inbox/postcss.config.js +6 -0
  54. package/ftm-inbox/src/app.css +199 -0
  55. package/ftm-inbox/src/app.html +18 -0
  56. package/ftm-inbox/src/lib/api.ts +166 -0
  57. package/ftm-inbox/src/lib/components/ExecutionLog.svelte +81 -0
  58. package/ftm-inbox/src/lib/components/InboxFeed.svelte +143 -0
  59. package/ftm-inbox/src/lib/components/PlanStep.svelte +271 -0
  60. package/ftm-inbox/src/lib/components/PlanView.svelte +206 -0
  61. package/ftm-inbox/src/lib/components/StreamPanel.svelte +99 -0
  62. package/ftm-inbox/src/lib/components/TaskCard.svelte +190 -0
  63. package/ftm-inbox/src/lib/components/ui/EmptyState.svelte +63 -0
  64. package/ftm-inbox/src/lib/components/ui/KawaiiCard.svelte +86 -0
  65. package/ftm-inbox/src/lib/components/ui/PillButton.svelte +106 -0
  66. package/ftm-inbox/src/lib/components/ui/StatusBadge.svelte +67 -0
  67. package/ftm-inbox/src/lib/components/ui/StreamDrawer.svelte +149 -0
  68. package/ftm-inbox/src/lib/components/ui/ThemeToggle.svelte +80 -0
  69. package/ftm-inbox/src/lib/theme.ts +47 -0
  70. package/ftm-inbox/src/routes/+layout.svelte +76 -0
  71. package/ftm-inbox/src/routes/+page.svelte +401 -0
  72. package/ftm-inbox/static/favicon.png +0 -0
  73. package/ftm-inbox/svelte.config.js +12 -0
  74. package/ftm-inbox/tailwind.config.ts +63 -0
  75. package/ftm-inbox/tsconfig.json +13 -0
  76. package/ftm-inbox/vite.config.ts +6 -0
  77. package/ftm-intent/SKILL.md +44 -0
  78. package/ftm-manifest.json +3794 -0
  79. package/ftm-map/SKILL.md +50 -0
  80. package/ftm-mind/SKILL.md +173 -66
  81. package/ftm-pause/SKILL.md +43 -0
  82. package/ftm-researcher/SKILL.md +55 -0
  83. package/ftm-resume/SKILL.md +47 -0
  84. package/ftm-retro/SKILL.md +54 -0
  85. package/ftm-routine/SKILL.md +36 -0
  86. package/ftm-state/blackboard/capabilities.json +5 -0
  87. package/ftm-state/blackboard/capabilities.schema.json +27 -0
  88. package/ftm-upgrade/SKILL.md +41 -0
  89. package/hooks/ftm-blackboard-enforcer.sh +28 -27
  90. package/hooks/ftm-plan-gate.sh +21 -25
  91. package/install.sh +238 -111
  92. 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
- * Works by finding the npm package root (where the skill files live)
7
- * and symlinking them into the Claude Code skills directory.
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
- if (existsSync(hooksDir)) {
114
- ensureDir(HOOKS_DIR);
341
+
342
+ if (NO_HOOKS) {
115
343
  console.log("");
116
- console.log("Installing hooks...");
117
-
118
- const hookFiles = readdirSync(hooksDir).filter(
119
- (f) => f.startsWith("ftm-") && (f.endsWith(".sh") || f.endsWith(".mjs"))
120
- );
121
- for (const hook of hookFiles) {
122
- const src = join(hooksDir, hook);
123
- const dest = join(HOOKS_DIR, hook);
124
- const action = existsSync(dest) ? "UPDATE" : "INSTALL";
125
- copyFileSync(src, dest);
126
- if (hook.endsWith(".sh")) {
127
- chmodSync(dest, 0o755);
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
- log(`${action} ${hook}`);
130
- hookCount++;
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
- console.log(`Done. ${ymlFiles.length} skills linked, ${hookCount} hooks installed.`);
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("To activate hooks, add them to ~/.claude/settings.json");
138
- console.log(" Option A: ./install.sh --setup-hooks (auto-merge)");
139
- console.log(" Option B: Copy entries from hooks/settings-template.json manually");
140
- console.log(" See docs/HOOKS.md for details.");
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.