feed-the-machine 1.0.0 → 1.2.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 (136) hide show
  1. package/bin/generate-manifest.mjs +253 -0
  2. package/bin/install.mjs +134 -4
  3. package/docs/HOOKS.md +243 -0
  4. package/docs/INBOX.md +233 -0
  5. package/ftm/SKILL.md +34 -0
  6. package/ftm-audit/SKILL.md +69 -0
  7. package/ftm-brainstorm/SKILL.md +51 -0
  8. package/ftm-browse/SKILL.md +39 -0
  9. package/ftm-capture/SKILL.md +370 -0
  10. package/ftm-capture.yml +4 -0
  11. package/ftm-codex-gate/SKILL.md +59 -0
  12. package/ftm-config/SKILL.md +35 -0
  13. package/ftm-council/SKILL.md +56 -0
  14. package/ftm-dashboard/SKILL.md +163 -0
  15. package/ftm-debug/SKILL.md +84 -0
  16. package/ftm-diagram/SKILL.md +44 -0
  17. package/ftm-executor/SKILL.md +97 -0
  18. package/ftm-git/SKILL.md +60 -0
  19. package/ftm-inbox/backend/__init__.py +0 -0
  20. package/ftm-inbox/backend/__pycache__/main.cpython-314.pyc +0 -0
  21. package/ftm-inbox/backend/adapters/__init__.py +0 -0
  22. package/ftm-inbox/backend/adapters/_retry.py +64 -0
  23. package/ftm-inbox/backend/adapters/base.py +230 -0
  24. package/ftm-inbox/backend/adapters/freshservice.py +104 -0
  25. package/ftm-inbox/backend/adapters/gmail.py +125 -0
  26. package/ftm-inbox/backend/adapters/jira.py +136 -0
  27. package/ftm-inbox/backend/adapters/registry.py +192 -0
  28. package/ftm-inbox/backend/adapters/slack.py +110 -0
  29. package/ftm-inbox/backend/db/__init__.py +0 -0
  30. package/ftm-inbox/backend/db/connection.py +54 -0
  31. package/ftm-inbox/backend/db/schema.py +78 -0
  32. package/ftm-inbox/backend/executor/__init__.py +7 -0
  33. package/ftm-inbox/backend/executor/engine.py +149 -0
  34. package/ftm-inbox/backend/executor/step_runner.py +98 -0
  35. package/ftm-inbox/backend/main.py +103 -0
  36. package/ftm-inbox/backend/models/__init__.py +1 -0
  37. package/ftm-inbox/backend/models/unified_task.py +36 -0
  38. package/ftm-inbox/backend/planner/__init__.py +6 -0
  39. package/ftm-inbox/backend/planner/__pycache__/__init__.cpython-314.pyc +0 -0
  40. package/ftm-inbox/backend/planner/__pycache__/generator.cpython-314.pyc +0 -0
  41. package/ftm-inbox/backend/planner/__pycache__/schema.cpython-314.pyc +0 -0
  42. package/ftm-inbox/backend/planner/generator.py +127 -0
  43. package/ftm-inbox/backend/planner/schema.py +34 -0
  44. package/ftm-inbox/backend/requirements.txt +5 -0
  45. package/ftm-inbox/backend/routes/__init__.py +0 -0
  46. package/ftm-inbox/backend/routes/__pycache__/plan.cpython-314.pyc +0 -0
  47. package/ftm-inbox/backend/routes/execute.py +186 -0
  48. package/ftm-inbox/backend/routes/health.py +52 -0
  49. package/ftm-inbox/backend/routes/inbox.py +68 -0
  50. package/ftm-inbox/backend/routes/plan.py +271 -0
  51. package/ftm-inbox/bin/launchagent.mjs +91 -0
  52. package/ftm-inbox/bin/setup.mjs +188 -0
  53. package/ftm-inbox/bin/start.sh +10 -0
  54. package/ftm-inbox/bin/status.sh +17 -0
  55. package/ftm-inbox/bin/stop.sh +8 -0
  56. package/ftm-inbox/config.example.yml +55 -0
  57. package/ftm-inbox/package-lock.json +2898 -0
  58. package/ftm-inbox/package.json +26 -0
  59. package/ftm-inbox/postcss.config.js +6 -0
  60. package/ftm-inbox/src/app.css +199 -0
  61. package/ftm-inbox/src/app.html +18 -0
  62. package/ftm-inbox/src/lib/api.ts +166 -0
  63. package/ftm-inbox/src/lib/components/ExecutionLog.svelte +81 -0
  64. package/ftm-inbox/src/lib/components/InboxFeed.svelte +143 -0
  65. package/ftm-inbox/src/lib/components/PlanStep.svelte +271 -0
  66. package/ftm-inbox/src/lib/components/PlanView.svelte +206 -0
  67. package/ftm-inbox/src/lib/components/StreamPanel.svelte +99 -0
  68. package/ftm-inbox/src/lib/components/TaskCard.svelte +190 -0
  69. package/ftm-inbox/src/lib/components/ui/EmptyState.svelte +63 -0
  70. package/ftm-inbox/src/lib/components/ui/KawaiiCard.svelte +86 -0
  71. package/ftm-inbox/src/lib/components/ui/PillButton.svelte +106 -0
  72. package/ftm-inbox/src/lib/components/ui/StatusBadge.svelte +67 -0
  73. package/ftm-inbox/src/lib/components/ui/StreamDrawer.svelte +149 -0
  74. package/ftm-inbox/src/lib/components/ui/ThemeToggle.svelte +80 -0
  75. package/ftm-inbox/src/lib/theme.ts +47 -0
  76. package/ftm-inbox/src/routes/+layout.svelte +76 -0
  77. package/ftm-inbox/src/routes/+page.svelte +401 -0
  78. package/ftm-inbox/static/favicon.png +0 -0
  79. package/ftm-inbox/svelte.config.js +12 -0
  80. package/ftm-inbox/tailwind.config.ts +63 -0
  81. package/ftm-inbox/tsconfig.json +13 -0
  82. package/ftm-inbox/vite.config.ts +6 -0
  83. package/ftm-intent/SKILL.md +44 -0
  84. package/ftm-manifest.json +3794 -0
  85. package/ftm-map/SKILL.md +259 -0
  86. package/ftm-map/scripts/db.py +391 -0
  87. package/ftm-map/scripts/index.py +341 -0
  88. package/ftm-map/scripts/parser.py +455 -0
  89. package/ftm-map/scripts/queries/.gitkeep +0 -0
  90. package/ftm-map/scripts/queries/javascript-tags.scm +23 -0
  91. package/ftm-map/scripts/queries/python-tags.scm +17 -0
  92. package/ftm-map/scripts/queries/typescript-tags.scm +29 -0
  93. package/ftm-map/scripts/query.py +149 -0
  94. package/ftm-map/scripts/requirements.txt +2 -0
  95. package/ftm-map/scripts/setup-hooks.sh +27 -0
  96. package/ftm-map/scripts/setup.sh +45 -0
  97. package/ftm-map/scripts/test_db.py +124 -0
  98. package/ftm-map/scripts/test_parser.py +106 -0
  99. package/ftm-map/scripts/test_query.py +66 -0
  100. package/ftm-map/scripts/tests/fixtures/__init__.py +0 -0
  101. package/ftm-map/scripts/tests/fixtures/sample_project/api.ts +16 -0
  102. package/ftm-map/scripts/tests/fixtures/sample_project/auth.py +15 -0
  103. package/ftm-map/scripts/tests/fixtures/sample_project/utils.js +16 -0
  104. package/ftm-map/scripts/views.py +545 -0
  105. package/ftm-mind/SKILL.md +173 -66
  106. package/ftm-pause/SKILL.md +43 -0
  107. package/ftm-researcher/SKILL.md +275 -0
  108. package/ftm-researcher/evals/agent-diversity.yaml +17 -0
  109. package/ftm-researcher/evals/synthesis-quality.yaml +12 -0
  110. package/ftm-researcher/evals/trigger-accuracy.yaml +39 -0
  111. package/ftm-researcher/references/adaptive-search.md +116 -0
  112. package/ftm-researcher/references/agent-prompts.md +193 -0
  113. package/ftm-researcher/references/council-integration.md +193 -0
  114. package/ftm-researcher/references/output-format.md +203 -0
  115. package/ftm-researcher/references/synthesis-pipeline.md +165 -0
  116. package/ftm-researcher/scripts/score_credibility.py +234 -0
  117. package/ftm-researcher/scripts/validate_research.py +92 -0
  118. package/ftm-resume/SKILL.md +47 -0
  119. package/ftm-retro/SKILL.md +54 -0
  120. package/ftm-routine/SKILL.md +170 -0
  121. package/ftm-state/blackboard/capabilities.json +5 -0
  122. package/ftm-state/blackboard/capabilities.schema.json +27 -0
  123. package/ftm-upgrade/SKILL.md +41 -0
  124. package/ftm-upgrade/scripts/check-version.sh +1 -1
  125. package/ftm-upgrade/scripts/upgrade.sh +1 -1
  126. package/hooks/ftm-blackboard-enforcer.sh +94 -0
  127. package/hooks/ftm-discovery-reminder.sh +90 -0
  128. package/hooks/ftm-drafts-gate.sh +61 -0
  129. package/hooks/ftm-event-logger.mjs +107 -0
  130. package/hooks/ftm-map-autodetect.sh +79 -0
  131. package/hooks/ftm-pending-sync-check.sh +22 -0
  132. package/hooks/ftm-plan-gate.sh +96 -0
  133. package/hooks/ftm-post-commit-trigger.sh +57 -0
  134. package/hooks/settings-template.json +81 -0
  135. package/install.sh +140 -11
  136. package/package.json +12 -2
package/ftm-mind/SKILL.md CHANGED
@@ -3,7 +3,7 @@ name: ftm-mind
3
3
  description: Unified OODA cognitive loop for the ftm system. Use for freeform `/ftm` or `/ftm-mind` requests, vague asks, mixed-tool workflows, Jira/ticket-driven work, or any request that should be understood before routing. Also handles explicit ftm skill invocations by honoring the requested skill while still doing a fast orientation pass for context, prerequisites, and approval gates. Triggers on open-ended requests like "help me think through this", bug reports, plan execution asks, Jira URLs, "make this better", mixed MCP asks like "check my calendar and draft a Slack message", and direct skill invocations like "/ftm-debug ..." or "/ftm-brainstorm ...". Do NOT use only when another ftm skill is already actively handling the task and no re-orientation is needed.
4
4
  ---
5
5
 
6
- # FTM Mind
6
+ # Panda Mind
7
7
 
8
8
  `ftm-mind` is the reasoning core of the ftm ecosystem. It does not route by keyword alone. It observes the request, orients against live state and accumulated memory, decides the smallest correct next move, acts, then loops.
9
9
 
@@ -133,6 +133,62 @@ Interpretation rules:
133
133
  - "what would other AIs think" is a council request, not generic brainstorming
134
134
  - "rename this variable" is usually a micro direct task, not a routed skill
135
135
 
136
+ ### 1.5. Environment Discovery (Orient sub-phase)
137
+
138
+ Before pattern matching or routing, probe the current environment to map available capabilities. This step runs automatically on the first request in a session, then caches results for 15 minutes.
139
+
140
+ **Discovery sequence:**
141
+
142
+ 1. **MCP Server Probe** — List connected MCP servers by checking which tool namespaces are available:
143
+ - For each known MCP server (serena, supabase, playwright, freshservice-mcp, slack, gmail, mcp-atlassian-personal, lusha, apple-doc-mcp), check if tools with that prefix exist
144
+ - Record: server name, tools available, verified status
145
+
146
+ 2. **CLI Probe** — Check for installed CLIs on PATH:
147
+ - Essential: `node`, `python3`, `git`, `npm`
148
+ - FTM tools: `knip`, `codex` (OpenAI Codex CLI)
149
+ - Optional: `gh` (GitHub CLI), `jq`, `curl`
150
+ - For each: run `which <cmd>` and record path + version if available
151
+
152
+ 3. **Environment Variable Check** — Check for key env vars (existence only, never log values):
153
+ - `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GITHUB_TOKEN`
154
+ - `JIRA_API_TOKEN`, `FRESHSERVICE_API_KEY`, `SLACK_BOT_TOKEN`
155
+ - Record: var name, is_set (boolean)
156
+
157
+ 4. **Write capabilities.json** to `~/.claude/ftm-state/blackboard/capabilities.json`:
158
+ ```json
159
+ {
160
+ "discovered_at": "2026-03-20T10:30:00Z",
161
+ "expires_at": "2026-03-20T10:45:00Z",
162
+ "capabilities": [
163
+ {
164
+ "name": "serena",
165
+ "type": "mcp",
166
+ "verified": true,
167
+ "last_verified_at": "2026-03-20T10:30:00Z",
168
+ "operations_verified": ["find_symbol", "search_for_pattern"],
169
+ "confidence": "verified"
170
+ },
171
+ {
172
+ "name": "node",
173
+ "type": "cli",
174
+ "verified": true,
175
+ "path": "/usr/local/bin/node",
176
+ "version": "20.11.0",
177
+ "confidence": "verified"
178
+ }
179
+ ]
180
+ }
181
+ ```
182
+
183
+ 5. **Cache logic** — If `capabilities.json` exists and `expires_at` > now, skip re-probing. If stale or missing, re-probe. User can force refresh by saying "refresh capabilities" or "recon".
184
+
185
+ **How this affects planning:**
186
+
187
+ When ftm-mind generates or routes to a plan, it MUST:
188
+ - Check `capabilities.json` for every tool/MCP/CLI the plan references
189
+ - If a required capability is `verified: false` or missing, use the skill's fallback from its manifest (## Fallbacks section)
190
+ - If no fallback exists for a missing capability, warn the user: "Plan step N requires [capability] which is not available. Skip or find alternative?"
191
+
136
192
  ### 2. Blackboard Loading Protocol
137
193
 
138
194
  Read the blackboard in this order:
@@ -244,7 +300,7 @@ If `experiences/index.json` has no usable matches:
244
300
  - lean harder on current repo state and direct inspection
245
301
  - record the resulting experience aggressively after completion
246
302
 
247
- ### 4. Capability Inventory: 16 FTM Skills
303
+ ### 4. Capability Inventory: 15 Panda Skills
248
304
 
249
305
  Orient must know all ftm capabilities before deciding whether to route or act directly.
250
306
 
@@ -265,8 +321,7 @@ Orient must know all ftm capabilities before deciding whether to route or act di
265
321
  | `ftm-retro` | The user wants a post-run retrospective, lessons learned, or execution review. |
266
322
  | `ftm-config` | The user wants ftm settings, model profile, or feature configuration changed. |
267
323
  | `ftm-git` | Any git commit or push is about to happen, the user asks to scan for secrets/credentials/API keys, or wants to verify no secrets are hardcoded before sharing code. MUST run before any commit or push operation — this is a mandatory security gate, not optional. |
268
- | `ftm-researcher` | The user wants thorough research on a topic, comparison of approaches, state-of-the-art analysis, or evidence-based investigation. Not for ideation (that is ftm-brainstorm). |
269
- | `ftm-map` | The user wants structural code queries: blast radius ("what breaks if I change X"), dependency chains ("what depends on Y"), code search ("where do we handle auth"), or codebase indexing ("map this codebase", "index this project"). Not for documentation updates (that is ftm-intent/ftm-diagram). |
324
+ | `ftm-capture` | The user just completed a repeatable workflow and wants to save it as a reusable routine + playbook + reference doc. Triggers on "capture this", "save as routine", "codify this", "don't make me explain this again". Also suggest proactively when you detect the user doing something they've done before (matching blackboard experiences with same task_type 2+ times). |
270
325
 
271
326
  Routing heuristic:
272
327
 
@@ -442,9 +497,12 @@ Signals:
442
497
  - changes routing, integration, or cross-system references (API endpoints, project keys, board IDs)
443
498
  - the codebase being changed is unfamiliar or hasn't been read yet this session
444
499
  - the task involves both code changes AND communication/coordination
500
+ - **calls any production API that creates, updates, or deletes resources** (Okta, Freshservice, AWS, any external service with real consequences)
445
501
 
446
502
  The reason forced escalation exists: tasks that touch external systems or multiple files feel simple in the moment but have hidden ordering dependencies, stakeholder coordination needs, and blast radius that only becomes visible after you've already started grinding. A 2-minute plan catches these. Grinding without one wastes the user's time when you go in the wrong direction.
447
503
 
504
+ **The Hindsight incident**: In March 2026, a task that "felt small" — set up SSO for Hindsight — resulted in autonomous creation of Okta groups in production, user assignments, Freshservice records, a service catalog item, and S3 config changes. The model never presented a plan. It never asked for approval on any phase. It just researched and executed. This is exactly what forced escalation prevents. If the task will call APIs that modify production state, it is medium. Full stop.
505
+
448
506
  Typical examples:
449
507
 
450
508
  - fix a flaky test with several hypotheses
@@ -514,36 +572,61 @@ Escalate when:
514
572
  - the complexity is obvious from the start
515
573
  - forced escalation signals are present (see Medium and Large sections above)
516
574
 
517
- ### 9. Approval Gates
575
+ ### 9. Approval Gates (HARD STOP — NOT OPTIONAL)
576
+
577
+ **This section is a circuit breaker, not a suggestion. If you are about to call a tool that creates, updates, or deletes a record in an external system, you MUST stop and get explicit user approval FIRST. No exceptions. No "the user implied it." No "it's part of the plan." STOP and ASK.**
578
+
579
+ The reason this exists: in March 2026, ftm-mind took a Hindsight SSO task and autonomously created Okta groups, added users to production Okta, created Freshservice records, created a service catalog item, and modified S3 workflow configs — all without asking once. The user's `approval_mode` was `plan_first`. The model rationalized past every gate because it "had momentum." That is exactly the failure mode this section prevents.
580
+
581
+ #### What requires approval (STOP before each one)
518
582
 
519
- Ask for approval only for external-facing actions.
583
+ Every individual external mutation needs its own approval. "The user approved the plan" does not mean "the user approved every API call in the plan." Present what you're about to do, wait for "go" / "yes" / "approved", then execute that one action.
520
584
 
521
- External-facing means actions that leave the local workspace and affect people, systems of record, or deployed environments.
585
+ - **Okta**: creating apps, groups, assigning users, modifying policies
586
+ - **Freshservice**: creating tickets, records, catalog items, custom objects
587
+ - **Jira / Confluence**: creating or updating issues, pages, comments
588
+ - **Slack / Email**: sending messages (draft-before-send protocol applies)
589
+ - **Calendar**: creating or modifying events
590
+ - **S3 / cloud storage**: writing or modifying objects
591
+ - **Browser forms**: submitting data through playwright/puppeteer
592
+ - **Deploys**: any production-affecting operation
593
+ - **Git remote**: pushes, PR creation
522
594
 
523
- Approval required:
595
+ When multiple mutations are part of one plan, batch the approval request by phase — not one API call at a time (that would be annoying), but not "approve the whole plan and I'll do 15 things silently" either. Group related mutations:
524
596
 
525
- - sending Slack messages
526
- - sending emails
527
- - creating or mutating Jira, Confluence, or Freshservice records
528
- - changing calendar events
529
- - submitting browser forms or uploads
530
- - deploys and production-affecting operations
531
- - remote pushes or other outward publication steps
597
+ ```
598
+ Phase 1 ready — Okta setup:
599
+ - Create SAML app "Hindsight"
600
+ - Create groups: hindsight_admins, hindsight_users
601
+ - Add 3 users to hindsight_users
602
+
603
+ Proceed with Phase 1? (yes/skip/modify)
604
+ ```
532
605
 
533
- Auto-proceed without approval:
606
+ Then after Phase 1 completes, present Phase 2 before executing it.
534
607
 
535
- - local code edits
536
- - local documentation updates
608
+ #### What auto-proceeds (no approval needed)
609
+
610
+ - local code edits, documentation updates
537
611
  - tests, lint, builds, audits
538
- - local git inspection
539
- - local branches and local commits
540
- - reading from any MCP
612
+ - local git operations (branch, commit, inspection)
613
+ - reading from any MCP or API (GET requests)
541
614
  - blackboard reads and writes
542
- - saving drafts to `.ftm-drafts/` (the draft is local; sending is what needs approval)
615
+ - saving drafts to `.ftm-drafts/`
616
+
617
+ #### The momentum trap
543
618
 
544
- If the user has explicitly requested stricter gates, honor that preference.
619
+ If you notice yourself thinking any of these, STOP you are rationalizing past a gate:
545
620
 
546
- If authentication or permission is missing, ask instead of guessing.
621
+ - "The user clearly wants this done, I'll just do it"
622
+ - "This is part of the approved plan"
623
+ - "I already started, might as well finish"
624
+ - "It's just one more API call"
625
+ - "The user will appreciate me being proactive"
626
+
627
+ None of these override the gate. Present the action, wait for approval, then execute.
628
+
629
+ If the user has explicitly requested stricter gates, honor that preference. If authentication or permission is missing, ask instead of guessing.
547
630
 
548
631
  ### 10. Ask-the-User Heuristic
549
632
 
@@ -723,45 +806,6 @@ Approve? Or adjust the approach.
723
806
 
724
807
  This gives the user control over the *strategy* even when delegating to skills.
725
808
 
726
- ### Research tasks → ftm-researcher
727
-
728
- Route to ftm-researcher when the request is primarily about gathering information,
729
- comparing approaches, or understanding the state of the art on a topic.
730
-
731
- Signals:
732
- - "research X", "find out about Y", "what's the state of the art on Z"
733
- - "compare approaches to W", "how do others handle X"
734
- - "deep dive into X", "investigate Y", "look into Z"
735
- - "find me examples of X", "what's out there for Y"
736
- - The user wants facts and evidence, not ideation or planning
737
-
738
- Distinguish from ftm-brainstorm:
739
- - Brainstorm: user has an idea and wants to develop it → exploratory, iterative, extractive
740
- - Researcher: user wants information about a topic → factual, evidence-based, comprehensive
741
- - Ambiguous: if the user seems to want both exploration AND research, route to brainstorm (which calls researcher internally)
742
-
743
- Mode selection:
744
- - "quick look" / "briefly" → quick mode
745
- - Default → standard mode
746
- - "deep dive" / "thorough" / "comprehensive" → deep mode
747
-
748
- ### Structural code queries → ftm-map
749
-
750
- Route to ftm-map when the request involves understanding code structure and dependencies:
751
-
752
- **Strong signals (route immediately):**
753
- - "what breaks if I change X" / "blast radius"
754
- - "what depends on X" / "dependency chain"
755
- - "what calls X" / "who calls X"
756
- - "where do we handle X" (code search, not docs)
757
- - "map this codebase" / "index this project"
758
-
759
- **Disambiguation:**
760
- - "document this function" → ftm-intent (documentation), NOT ftm-map
761
- - "show the architecture diagram" → ftm-diagram, NOT ftm-map
762
- - "search for X in the codebase" → could be ftm-map (if structural) or Grep (if text-literal)
763
- - If `.ftm-map/map.db` doesn't exist and the query is structural, suggest bootstrapping first
764
-
765
809
  ### 2. Choose direct vs routed execution
766
810
 
767
811
  Use direct execution when:
@@ -793,7 +837,15 @@ If the next move will reveal new information, plan to re-enter Observe after the
793
837
 
794
838
  ## Act
795
839
 
796
- Act is clean, decisive execution.
840
+ Act is clean, decisive execution — but execution of **approved** work only.
841
+
842
+ **Pre-Act checkpoint**: Before executing anything, verify:
843
+
844
+ 1. If `approval_mode` is `plan_first` or `always_ask`, did the user explicitly approve the plan? (Words like "go", "yes", "approved", "do it", "ship it" — not silence, not your own narration of the plan.)
845
+ 2. If the task involves external mutations (see Approval Gates section 9), have you presented the specific actions and received approval?
846
+ 3. If neither condition applies, proceed.
847
+
848
+ If you cannot point to a specific user message that approved the plan, you have not received approval. Go back to Decide and present the plan.
797
849
 
798
850
  ### 1. Direct action
799
851
 
@@ -876,6 +928,7 @@ After every completed task — not just "meaningful" ones — update the blackbo
876
928
 
877
929
  1. Update `context.json` — set `current_task` to reflect what was done, append to `recent_decisions`
878
930
  2. Update `session_metadata.skills_invoked` if a skill was used
931
+ 3. If environment discovery ran this session, ensure `capabilities.json` is written to `/Users/kioja.kudumu/.claude/ftm-state/blackboard/capabilities.json` with the current snapshot (schema: `capabilities.schema.json` in the same directory)
879
932
 
880
933
  **After task completion, always record an experience file:**
881
934
 
@@ -934,13 +987,12 @@ Use these as behavioral tests.
934
987
  When the user asks for help, shows empty input, or says `?` or `menu`, show:
935
988
 
936
989
  ```text
937
- FTM Skills:
990
+ Panda Skills:
938
991
  /ftm brainstorm [idea] — Research-backed idea development
939
992
  /ftm execute [plan-path] — Autonomous plan execution with agent teams
940
993
  /ftm debug [description] — Multi-vector deep debugging war room
941
994
  /ftm audit — Wiring verification
942
995
  /ftm council [question] — Multi-model deliberation
943
- /ftm research [topic] — Deep parallel research engine
944
996
  /ftm intent — Manage INTENT.md documentation
945
997
  /ftm diagram — Manage architecture diagrams
946
998
  /ftm codex-gate — Run adversarial Codex validation
@@ -984,3 +1036,58 @@ Avoid these failures:
984
1036
  6. Read before write.
985
1037
  7. Session trajectory matters.
986
1038
  8. The best route is often no route at all.
1039
+
1040
+ ## Requirements
1041
+
1042
+ - tool: `git` | required | codebase state inspection (git status, git log)
1043
+ - config: `~/.claude/ftm-config.yml` | optional | approval_mode, execution preferences
1044
+ - reference: `~/.claude/skills/ftm-mind/references/mcp-inventory.md` | required | MCP capability routing table
1045
+ - reference: `~/.claude/ftm-state/blackboard/context.json` | optional | session state and preferences
1046
+ - reference: `~/.claude/ftm-state/blackboard/experiences/index.json` | optional | experience retrieval index
1047
+ - reference: `~/.claude/ftm-state/blackboard/patterns.json` | optional | promoted patterns for orientation
1048
+
1049
+ ## Risk
1050
+
1051
+ - level: low_write
1052
+ - scope: writes blackboard context and experience files; local code edits only on micro/small direct tasks; routes to other skills for larger work
1053
+ - rollback: blackboard writes can be reverted by editing JSON files; no destructive mutations performed directly
1054
+
1055
+ ## Approval Gates
1056
+
1057
+ - trigger: task_size >= medium AND involves external systems | action: present numbered plan and wait for explicit user approval
1058
+ - trigger: any external mutation (Okta, Freshservice, Jira, Slack, email, calendar, S3, deploys, git push) | action: present phase-level approval request before executing each mutation
1059
+ - trigger: task_size == small AND approval_mode == always_ask | action: show pre-flight summary before proceeding
1060
+ - complexity_routing: micro → auto | small → auto (pre-flight summary if plan_first) | medium → plan_first | large → plan_first | xl → always_ask
1061
+
1062
+ ## Fallbacks
1063
+
1064
+ - condition: blackboard context.json missing or malformed | action: treat as empty state, proceed at full capability using live observation
1065
+ - condition: experiences/index.json empty or no matching entries | action: skip experience retrieval, lean on current repo state and direct inspection
1066
+ - condition: patterns.json missing | action: skip pattern application, rely on direct analysis
1067
+ - condition: ftm-config.yml missing | action: default to plan_first approval_mode and balanced model profile
1068
+ - condition: mcp-inventory.md missing | action: rely on built-in MCP routing heuristics from skill body
1069
+ - condition: requested ftm skill unavailable | action: notify user and attempt direct handling or alternate routing
1070
+
1071
+ ## Capabilities
1072
+
1073
+ - mcp: `git` | optional | codebase state, diffs, history, commits
1074
+ - mcp: `mcp-atlassian-personal` | optional | Jira/Confluence reads for ticket-driven work
1075
+ - mcp: `slack` | optional | Slack context reads, draft messages
1076
+ - mcp: `gmail` | optional | email reads, drafts
1077
+ - mcp: `google-calendar` | optional | calendar inspection for scheduling requests
1078
+ - mcp: `freshservice-mcp` | optional | IT ticketing reads
1079
+ - mcp: `sequential-thinking` | optional | multi-step reflective reasoning
1080
+ - mcp: `playwright` | optional | browser automation for visual tasks
1081
+ - mcp: `glean_default` | optional | internal company knowledge search
1082
+ - mcp: `context7` | optional | external library documentation
1083
+ - env: none required
1084
+
1085
+ ## Event Payloads
1086
+
1087
+ ### task_completed
1088
+ - skill: string — "ftm-mind"
1089
+ - task_type: string — detected task type (feature, bug, refactor, investigation, etc.)
1090
+ - task_size: string — micro | small | medium | large
1091
+ - route: string — direct | skill name routed to
1092
+ - duration_ms: number — time from observe to act completion
1093
+ - blackboard_updated: boolean — whether context.json and experience were written
@@ -131,3 +131,46 @@ Tailor the counts to the skill: brainstorm shows decisions + turns, executor sho
131
131
  **Skill invoked, no user interaction yet:** Save what exists (Phase 0 scan, initial question). "Next Step" notes that the user hasn't answered yet.
132
132
 
133
133
  **Large state:** Do not truncate. Some sessions produce massive state files. Completeness is required for reliable restoration.
134
+
135
+ ## Requirements
136
+
137
+ - reference: `~/.claude/ftm-state/STATE.md` | optional | existing state file to overwrite
138
+ - reference: `~/.claude/ftm-pause/references/protocols/SKILL-RESTORE-PROTOCOLS.md` | required | per-skill capture field specifications
139
+ - reference: `~/.claude/ftm-pause/references/protocols/VALIDATION.md` | required | pre-write and post-write validation checklist
140
+ - tool: `git` | optional | git branch and commit hash capture for state file
141
+
142
+ ## Risk
143
+
144
+ - level: low_write
145
+ - scope: writes ~/.claude/ftm-state/STATE.md only; does not modify project source files or blackboard experiences; overwrites existing STATE.md without backup
146
+ - rollback: no project mutations; prior STATE.md is overwritten (not backed up) by design
147
+
148
+ ## Approval Gates
149
+
150
+ - trigger: multiple skills active and unclear which to pause | action: ask user which skill state to save before writing
151
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
152
+
153
+ ## Fallbacks
154
+
155
+ - condition: ~/.claude/ftm-state/ directory doesn't exist | action: create directory before writing STATE.md
156
+ - condition: no ftm skill detected as active | action: report "No active ftm session detected" and list which skills this applies to
157
+ - condition: git not available | action: omit git_branch and git_commit fields from state file frontmatter
158
+ - condition: artifact files referenced in state don't exist on disk | action: note as "path recorded but file not found" in Artifacts section
159
+
160
+ ## Capabilities
161
+
162
+ - cli: `git` | optional | branch name and commit hash for state file metadata
163
+
164
+ ## Event Payloads
165
+
166
+ ### session_paused
167
+ - skill: string — "ftm-pause"
168
+ - saved_skill: string — the ftm skill whose state was saved
169
+ - phase: string — phase at which the session was paused
170
+ - state_file: string — absolute path to written STATE.md
171
+ - artifacts_count: number — number of artifact paths recorded
172
+
173
+ ### task_completed
174
+ - skill: string — "ftm-pause"
175
+ - saved_skill: string — the ftm skill whose state was saved
176
+ - state_file: string — absolute path to STATE.md
@@ -0,0 +1,275 @@
1
+ ---
2
+ name: ftm-researcher
3
+ description: Deep parallel research engine with 7 domain-specialized finder agents, adversarial review via ftm-council, adaptive wave-based search, structured reconciliation with disagreement maps, credibility scoring, and conversational iteration. Use when the user wants thorough research on any topic — "research X", "find out about Y", "what's the state of the art on Z", "compare approaches to W", "deep dive into X", "look into Y". Also invoked by ftm-brainstorm for its research sprints. Triggers on "research", "investigate", "deep dive", "state of the art", "compare", "find examples of", "what's out there for", "how do others handle", "find me evidence", "look into". For idea exploration and brainstorming, use ftm-brainstorm instead (which calls ftm-researcher internally for research).
4
+ ---
5
+
6
+ # ftm-researcher
7
+
8
+ Deep parallel research engine with 7 domain-specialized finder agents, adversarial review via ftm-council, adaptive wave-based search, structured reconciliation with disagreement maps, credibility scoring, and conversational iteration.
9
+
10
+ ## Events
11
+
12
+ ### Emits
13
+ - `research_complete` — when synthesis pipeline finishes and structured output is ready
14
+ - Payload: `{ query, mode, findings_count, consensus_count, contested_count, unique_count, sources_count, duration_ms }`
15
+ - `task_completed` — when the full research session finishes (including any conversational iteration)
16
+ - Payload: `{ task_title, duration_ms }`
17
+
18
+ ### Listens To
19
+ - `task_received` — begin research when ftm-mind or ftm-brainstorm routes a research request
20
+ - Expected payload: `{ task_description, plan_path, wave_number, task_number }`
21
+ - Note: `depth_mode` and `context_register` are derived internally from request context, not from event payload
22
+
23
+ ## Config Read
24
+
25
+ Read `~/.claude/ftm-config.yml`:
26
+ - Use `planning` model from the active profile for finder agents
27
+ - Use `review` model for fallback challenger agents
28
+ - Read `execution.per_skill_overrides.ftm-researcher` for agent cap (default 10 if override absent, fall back to `execution.max_parallel_agents` if neither is set)
29
+
30
+ ## Blackboard Read
31
+
32
+ On startup, load context from the FTM blackboard:
33
+ 1. Load `~/.claude/ftm-blackboard/context.json`
34
+ 2. Filter experiences by `task_type: "research"`
35
+ 3. Load matching experience files to inform agent dispatch and subtopic decomposition
36
+ 4. Load `~/.claude/ftm-blackboard/patterns.json` for recurring research patterns
37
+
38
+ ## Mode System
39
+
40
+ Three depth modes calibrate agent count, synthesis pipeline, and council invocation:
41
+
42
+ ```
43
+ Quick: 3 finders (Web Surveyor, GitHub Miner, Codebase Analyst), no council, no reconciler.
44
+ Single-pass synthesis by orchestrator. ~1-2 min.
45
+
46
+ Standard: 7 finders + reconciler, no council. Normalize → rank → reconcile. ~3-5 min.
47
+
48
+ Deep: 7 finders → adaptive wave 2 → ftm-council → reconciler. Full pipeline. ~5-10 min.
49
+ ```
50
+
51
+ Mode is detected from request context:
52
+ - "quick look" / "briefly" / "just a quick" → quick mode
53
+ - "deep dive" / "thorough" / "comprehensive" / "exhaustive" → deep mode
54
+ - Default (no explicit signal) → standard mode
55
+
56
+ ## The Main Loop
57
+
58
+ ```
59
+ PHASE 0: REPO SCAN
60
+ Silent background Explore agent scans the local codebase (same as ftm-brainstorm).
61
+ Produces: project_context { tech_stack, key_files, existing_patterns, integration_points }
62
+ Used by: Codebase Analyst finder + orchestrator subtopic decomposition
63
+
64
+ PHASE 1: INTAKE
65
+ - Parse the research question
66
+ - Detect depth mode
67
+ - Decompose into 7 subtopics (one per finder domain)
68
+ - Load blackboard context and filter relevant prior research
69
+
70
+ PHASE 2: WAVE 1
71
+ - Dispatch 7 finders in parallel, each with:
72
+ - Their unique domain constraint
73
+ - Their assigned subtopic
74
+ - Project context from Phase 0
75
+ - Context register (accumulated findings from prior waves/turns)
76
+ - Summary of previous findings to build on (do NOT re-search)
77
+ - Collect all findings (3-8 per agent = 21-56 total)
78
+
79
+ PHASE 3: ADAPTIVE REFINEMENT (deep mode only)
80
+ - Analyze wave 1 findings across 4 dimensions:
81
+ SATURATED: subtopic has 3+ diverse findings — reassign agent to a gap
82
+ THIN: subtopic has 1-2 findings — same agent, more specific query
83
+ GAP: subtopic has 0 findings — agent gets broader query + alternative terms
84
+ CONTESTED: 2+ agents directly contradict — assign 2 agents (one per side) to resolve
85
+ SURPRISE: findings outside original subtopics — assign most relevant agent to explore
86
+ - Dispatch wave 2 agents with reshaped queries
87
+ - Merge wave 2 findings with wave 1 before synthesis
88
+
89
+ PHASE 4: SYNTHESIS PIPELINE
90
+ See ftm-researcher/references/synthesis-pipeline.md for full pipeline.
91
+ Summary:
92
+ 1. Normalize & deduplicate (group by semantic similarity, track agent_count, source diversity)
93
+ 2. Adversarial review: ftm-council (deep mode) or fallback challengers (standard mode)
94
+ 3. Pairwise rank contested claims (LLM-as-judge tournament)
95
+ 4. Reconcile into disagreement map (consensus / contested / unique / refuted tiers)
96
+
97
+ PHASE 5: PRESENT
98
+ - Render disagreement map as structured markdown
99
+ - Show consensus findings, contested pairs, unique insights (flagged), refuted claims
100
+ - Include source summary table (type | count | avg credibility)
101
+ - Emit `research_complete` event
102
+
103
+ PHASE 6: ITERATE
104
+ - Enter conversational iteration mode
105
+ - Wait for user response
106
+ - Route based on intent (see Conversational Iteration Protocol below)
107
+ ```
108
+
109
+ ## Conversational Iteration Protocol
110
+
111
+ After presenting results, the skill enters iteration mode. Route user responses:
112
+
113
+ - "dig deeper on finding #N" / "more on #N" → spawn 3 targeted agents on that specific finding's topic
114
+ - "I disagree with X" / "I think X is wrong because Y" → spawn counter-evidence agents, update findings
115
+ - "focus on [angle]" / "what about the security angle" → reshape subtopics with new weighting, re-dispatch
116
+ - "council finding #N" / "get more opinions on #N" → route specific claim to ftm-council
117
+ - "more on [agent]'s findings" → re-dispatch that agent with broader query
118
+ - "compare A vs B" → spawn comparison agent with both findings as context
119
+ - "done" / "thanks" / "that's enough" / "looks good" → finalize, write blackboard, emit events
120
+
121
+ Each iteration:
122
+ 1. Updates the structured JSON artifact
123
+ 2. Re-renders the markdown output
124
+ 3. Updates the context register for subsequent turns
125
+
126
+ ## Agent Roster
127
+
128
+ See `ftm-researcher/references/agent-prompts.md` for full prompts.
129
+
130
+ | Agent | Domain | Source Types |
131
+ |---|---|---|
132
+ | Web Surveyor | Blog posts, case studies, tutorials, technical write-ups | blog, news |
133
+ | Academic Scout | Papers (arxiv, ACM, IEEE), official docs, RFCs, specs | peer_reviewed, primary, official_docs |
134
+ | GitHub Miner | GitHub repos, OSS implementations, code patterns | code_repo |
135
+ | Competitive Analyst | Products, user reviews (Reddit/HN/Twitter), market analysis | forum, news |
136
+ | Stack Overflow Digger | Stack Overflow, community Q&A, pitfalls, solved problems | qa_site |
137
+ | Codebase Analyst | Local repo only — Grep, Read, Glob tools, git log | codebase |
138
+ | Historical Investigator | Solutions from 5-10+ years ago, evolution, failed approaches | primary, blog |
139
+
140
+ ## Synthesis Pipeline
141
+
142
+ See `ftm-researcher/references/synthesis-pipeline.md` for full specification.
143
+
144
+ 5 phases: Normalize → Adversarial Review → Pairwise Rank → Reconcile → Render
145
+
146
+ Output tiers:
147
+ 1. **Consensus** — 3+ agents agree, council agreed, multiple source types. Highest confidence.
148
+ 2. **Contested** — Council disagreed or pairwise ranking was close. Present both sides.
149
+ 3. **Unique Insights** — 1 agent only, not contradicted. High value OR hallucination — flag for user.
150
+ 4. **Refuted** — Council rejected or pairwise loser with weak evidence. Still present briefly.
151
+
152
+ ## Adaptive Search
153
+
154
+ See `ftm-researcher/references/adaptive-search.md` for full protocol.
155
+
156
+ Deep mode only. Reshapes wave 2 queries based on wave 1 coverage analysis across 4 dimensions: SATURATED, THIN, GAP, CONTESTED, SURPRISE.
157
+
158
+ ## Output Format
159
+
160
+ See `ftm-researcher/references/output-format.md` for JSON schema and markdown template.
161
+
162
+ Primary output: structured JSON artifact for skill-to-skill consumption (ftm-brainstorm, ftm-executor).
163
+ Secondary output: rendered markdown for human display.
164
+
165
+ ## Council Integration
166
+
167
+ See `ftm-researcher/references/council-integration.md` for full protocol.
168
+
169
+ Deep mode only. Routes top claims through ftm-council (Claude + Codex + Gemini independent review).
170
+
171
+ Fallback (council unavailable): 2 standalone agents on the `review` model:
172
+ - Devil's Advocate — finds reasons each claim is WRONG
173
+ - Edge Case Hunter — finds where each claim BREAKS
174
+
175
+ ## Credibility Scoring
176
+
177
+ See `ftm-researcher/scripts/score_credibility.py` for implementation.
178
+
179
+ 4 dimensions (weighted):
180
+ - Source type weight (35%): primary > peer_reviewed > official_docs > news > blog > forum
181
+ - Recency (20%): decay based on age, faster for fast-moving topics
182
+ - Domain authority (25%): HIGH_AUTHORITY domains (arxiv, MDN, AWS docs) score 0.9
183
+ - Bias detection (20%): sensationalism penalties, balanced language bonuses
184
+
185
+ Bonuses and penalties:
186
+ - Corroboration bonus: +0.15 if independently found by 2+ agents from different source types
187
+ - Circular sourcing: -0.20 flag if multiple sources trace to same original
188
+
189
+ Trust levels: high (>=0.75) | moderate (>=0.55) | low (>=0.35) | verify (<0.35)
190
+
191
+ ## Blackboard Write
192
+
193
+ After `research_complete` or session end:
194
+ 1. Update `~/.claude/ftm-blackboard/context.json` with research session summary
195
+ 2. Write experience file: `~/.claude/ftm-blackboard/experiences/research-[timestamp].json`
196
+ - Fields: query, mode, findings_count, top_consensus_claims, source_diversity, duration_ms
197
+ 3. Update `~/.claude/ftm-blackboard/index.json` with new experience entry
198
+ 4. Emit `task_completed` event
199
+
200
+ ## Session State (for ftm-pause/resume)
201
+
202
+ The following state is persisted for pause/resume support:
203
+ - Current phase (0-6)
204
+ - Depth mode
205
+ - All wave 1 and wave 2 findings (raw)
206
+ - Synthesis state (normalized claims, council verdicts, ranked pairs)
207
+ - Disagreement map (current version)
208
+ - Conversation history (iteration turns)
209
+ - Context register (accumulated findings across turns)
210
+ - Project context from Phase 0 repo scan
211
+
212
+ ## References
213
+
214
+ - `ftm-researcher/references/agent-prompts.md` — 7 finder agent prompts + orchestrator decomposition protocol
215
+ - `ftm-researcher/references/synthesis-pipeline.md` — 5-phase synthesis pipeline + reconciler prompt
216
+ - `ftm-researcher/references/adaptive-search.md` — Wave 1 → wave 2 refinement protocol
217
+ - `ftm-researcher/references/output-format.md` — JSON schema + markdown template + iteration protocol
218
+ - `ftm-researcher/references/council-integration.md` — ftm-council interface + fallback challenger prompts
219
+ - `ftm-researcher/scripts/score_credibility.py` — Source credibility scoring
220
+ - `ftm-researcher/scripts/validate_research.py` — Research output validation
221
+
222
+ ## Requirements
223
+
224
+ - config: `~/.claude/ftm-config.yml` | optional | planning and review model profiles, per_skill_overrides.ftm-researcher agent cap
225
+ - reference: `ftm-researcher/references/agent-prompts.md` | required | 7 finder agent prompts and orchestrator decomposition protocol
226
+ - reference: `ftm-researcher/references/synthesis-pipeline.md` | required | 5-phase synthesis pipeline
227
+ - reference: `ftm-researcher/references/adaptive-search.md` | optional | wave 2 adaptive refinement (deep mode only)
228
+ - reference: `ftm-researcher/references/output-format.md` | required | JSON schema and markdown template
229
+ - reference: `ftm-researcher/references/council-integration.md` | optional | ftm-council interface (deep mode only)
230
+ - reference: `~/.claude/ftm-blackboard/context.json` | optional | session state
231
+ - reference: `~/.claude/ftm-blackboard/patterns.json` | optional | recurring research patterns
232
+
233
+ ## Risk
234
+
235
+ - level: read_only
236
+ - scope: reads web sources and local codebase via agents; writes blackboard experience entry; writes structured JSON artifact; does not modify project source files
237
+ - rollback: no project mutations; blackboard write can be reverted by editing JSON files
238
+
239
+ ## Approval Gates
240
+
241
+ - trigger: research complete and user says "done" / "thanks" | action: finalize, write blackboard, emit events
242
+ - trigger: deep mode and ftm-council invoked | action: council runs automatically on top claims (no user gate needed for this step)
243
+ - complexity_routing: micro → auto | small → auto | medium → auto | large → auto | xl → auto
244
+
245
+ ## Fallbacks
246
+
247
+ - condition: ftm-council not available (deep mode) | action: use 2 fallback challenger agents (Devil's Advocate + Edge Case Hunter) instead
248
+ - condition: agent cap exceeded | action: queue excess agents and dispatch after current wave completes
249
+ - condition: research agent returns no findings | action: broaden query and retry; if still empty, report "No prior art found — this may be novel"
250
+ - condition: blackboard missing | action: proceed without experience-informed shortcuts
251
+
252
+ ## Capabilities
253
+
254
+ - mcp: `WebSearch` | optional | finder agents for web, GitHub, and competitive research
255
+ - mcp: `WebFetch` | optional | fetching specific URLs found during research
256
+ - mcp: `sequential-thinking` | optional | complex synthesis and reconciliation
257
+
258
+ ## Event Payloads
259
+
260
+ ### research_complete
261
+ - skill: string — "ftm-researcher"
262
+ - query: string — original research question
263
+ - mode: string — "quick" | "standard" | "deep"
264
+ - findings_count: number — total normalized findings
265
+ - consensus_count: number — findings with 3+ agent agreement
266
+ - contested_count: number — findings with council disagreement
267
+ - unique_count: number — single-agent findings
268
+ - sources_count: number — total sources cited
269
+ - council_used: boolean — whether ftm-council was invoked
270
+ - duration_ms: number — total research duration
271
+
272
+ ### task_completed
273
+ - skill: string — "ftm-researcher"
274
+ - task_title: string — research topic title
275
+ - duration_ms: number — total session duration including iterations