feed-the-machine 1.3.1 → 1.4.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/ftm-git/SKILL.md +0 -1
- package/ftm-map/SKILL.md +46 -14
- package/ftm-map/scripts/db.py +439 -118
- package/ftm-map/scripts/index.py +128 -54
- package/ftm-map/scripts/parser.py +89 -320
- package/ftm-map/scripts/queries/go-tags.scm +20 -0
- package/ftm-map/scripts/queries/javascript-tags.scm +19 -7
- package/ftm-map/scripts/queries/python-tags.scm +22 -8
- package/ftm-map/scripts/queries/ruby-tags.scm +19 -0
- package/ftm-map/scripts/queries/rust-tags.scm +37 -0
- package/ftm-map/scripts/queries/typescript-tags.scm +20 -8
- package/ftm-map/scripts/query.py +176 -24
- package/ftm-map/scripts/ranker.py +377 -0
- package/ftm-map/scripts/requirements.txt +3 -0
- package/ftm-map/scripts/setup.sh +11 -0
- package/ftm-map/scripts/test_db.py +355 -115
- package/ftm-map/scripts/test_parser.py +169 -101
- package/ftm-map/scripts/test_query.py +178 -61
- package/ftm-map/scripts/test_ranker.py +199 -0
- package/ftm-map/scripts/views.py +107 -61
- package/ftm-mind/references/event-registry.md +0 -10
- package/hooks/ftm-blackboard-enforcer.sh +1 -4
- package/package.json +1 -1
- package/ftm-inbox/backend/__pycache__/main.cpython-314.pyc +0 -0
- package/ftm-inbox/backend/planner/__pycache__/__init__.cpython-314.pyc +0 -0
- package/ftm-inbox/backend/planner/__pycache__/generator.cpython-314.pyc +0 -0
- package/ftm-inbox/backend/planner/__pycache__/schema.cpython-314.pyc +0 -0
- package/ftm-inbox/backend/routes/__pycache__/plan.cpython-314.pyc +0 -0
- package/ftm-map/scripts/tests/fixtures/__init__.py +0 -0
- package/ftm-map/scripts/tests/fixtures/sample_project/api.ts +0 -16
- package/ftm-map/scripts/tests/fixtures/sample_project/auth.py +0 -15
- package/ftm-map/scripts/tests/fixtures/sample_project/utils.js +0 -16
package/ftm-git/SKILL.md
CHANGED
|
@@ -14,7 +14,6 @@ description: Secret scanning and credential safety gate for git operations. Prev
|
|
|
14
14
|
### Listens To
|
|
15
15
|
- `code_changed` — run a quick scan on modified files before they get staged
|
|
16
16
|
- `code_committed` — verify the commit doesn't contain secrets (post-commit safety net)
|
|
17
|
-
- `push_requested` — block push and run full scan if not already cleared
|
|
18
17
|
|
|
19
18
|
## Blackboard Read
|
|
20
19
|
|
package/ftm-map/SKILL.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ftm-map
|
|
3
|
-
description: Persistent code knowledge graph powered by tree-sitter and SQLite with FTS5 full-text search. Builds structural dependency graphs for blast radius
|
|
3
|
+
description: Persistent code knowledge graph powered by tree-sitter and SQLite with FTS5 full-text search. Uses a v2 hybrid architecture combining file-level PageRank with symbol-level blast radius analysis. Builds structural dependency graphs for blast radius, dependency chains, context selection, and keyword search. Use when user asks "what breaks if I change X", "blast radius", "what depends on", "where do we handle", "map codebase", "index project", "what calls", "dependency chain", "what's relevant for", "context for", "ftm-map".
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# ftm-map
|
|
7
7
|
|
|
8
|
-
Persistent code knowledge graph powered by tree-sitter and SQLite with FTS5 full-text search. Parses the local codebase into a
|
|
8
|
+
Persistent code knowledge graph powered by tree-sitter and SQLite with FTS5 full-text search. Uses a v2 hybrid architecture: file-level PageRank (via fast-pagerank with scipy sparse matrices) for broad relevance ranking, combined with symbol-level blast radius for precise impact analysis. Parses the local codebase using Aider-style def/ref extraction with tags.scm into a 5-table schema (files, symbols, refs, file_edges, symbol_edges) stored in `.ftm-map/map.db`, then answers structural queries (blast radius, dependency chains, context selection, symbol lookup) and keyword searches without re-reading the source tree on every question.
|
|
9
9
|
|
|
10
10
|
## Events
|
|
11
11
|
|
|
12
12
|
### Emits
|
|
13
13
|
- `map_updated` — when the graph database has been updated (bootstrap or incremental)
|
|
14
|
-
- Payload: `{ project_path, symbols_count, edges_count, files_parsed, duration_ms, mode }`
|
|
14
|
+
- Payload: `{ project_path, symbols_count, edges_count, file_edges_count, reference_count, files_parsed, duration_ms, mode }`
|
|
15
15
|
- `task_completed` — when any ftm-map operation finishes
|
|
16
16
|
|
|
17
17
|
### Listens To
|
|
@@ -43,8 +43,9 @@ Bootstrap: "map this codebase" / "index this project" / no map.db exists yet
|
|
|
43
43
|
Incremental: Triggered by code_committed event or PostToolUse hook
|
|
44
44
|
Parses only changed files and updates their graph entries.
|
|
45
45
|
|
|
46
|
-
Query: Structural or
|
|
46
|
+
Query: Structural, keyword, or context question about existing graph
|
|
47
47
|
Detects query type and runs appropriate script.
|
|
48
|
+
Includes context selection for token-budgeted file retrieval.
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
If `.ftm-map/map.db` does not exist when a query arrives, fall back to offering bootstrap (see Graceful Degradation below).
|
|
@@ -98,15 +99,24 @@ Trigger: user asks a structural or keyword question about the codebase.
|
|
|
98
99
|
| "find X in the codebase" | FTS5 keyword search | `--search "X"` |
|
|
99
100
|
| "tell me about function X" | symbol info | `--info X` |
|
|
100
101
|
| "show dependencies for X" | dependency chain | `--deps X` |
|
|
102
|
+
| "what's relevant for X" | context selection | `--context --seed-keywords X` |
|
|
103
|
+
| "context for X" | context selection | `--context --seed-keywords X` |
|
|
104
|
+
| "important files for X" | context selection | `--context --seed-files X` |
|
|
105
|
+
| "what should I look at for X" | context selection | `--context --seed-keywords X` |
|
|
106
|
+
| "show stats" / "how big is the index" | statistics | `--stats` |
|
|
101
107
|
|
|
102
108
|
### Execution
|
|
103
109
|
|
|
104
110
|
Run the appropriate query script with the venv python:
|
|
105
111
|
```
|
|
106
|
-
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --blast-radius <symbol>
|
|
107
|
-
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --deps <symbol>
|
|
108
|
-
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --search "<keywords>"
|
|
109
|
-
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --info <symbol>
|
|
112
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --blast-radius <symbol> --project-root .
|
|
113
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --deps <symbol> --project-root .
|
|
114
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --search "<keywords>" --project-root .
|
|
115
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --info <symbol> --project-root .
|
|
116
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --context --seed-files src/auth.py --token-budget 4000 --project-root .
|
|
117
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --context --seed-keywords authenticate --project-root .
|
|
118
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --context --seed-symbols handleAuth --token-budget 8000 --project-root .
|
|
119
|
+
ftm-map/scripts/.venv/bin/python3 ftm-map/scripts/query.py --stats --project-root .
|
|
110
120
|
```
|
|
111
121
|
|
|
112
122
|
### Output Formatting
|
|
@@ -151,9 +161,29 @@ Symbol: authenticateUser
|
|
|
151
161
|
Signature: authenticateUser(token: string, opts?: AuthOptions) → Promise<Session>
|
|
152
162
|
Callers: 3 direct, 5 transitive
|
|
153
163
|
Callees: validateToken, decodeJWT, createSession
|
|
164
|
+
References: 12 across codebase
|
|
154
165
|
Dependents: 8 symbols total
|
|
155
166
|
```
|
|
156
167
|
|
|
168
|
+
**Context selection** — PageRank-ranked files with token budget:
|
|
169
|
+
```
|
|
170
|
+
Context for "authenticate" (budget: 4000 tokens):
|
|
171
|
+
1. src/auth/index.ts score: 0.142 tokens: 850
|
|
172
|
+
2. src/handlers/auth.ts score: 0.098 tokens: 620
|
|
173
|
+
3. src/middleware/session.ts score: 0.076 tokens: 540
|
|
174
|
+
Total: 2010 / 4000 tokens
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Stats** — database overview:
|
|
178
|
+
```
|
|
179
|
+
Index statistics:
|
|
180
|
+
Files: 42
|
|
181
|
+
Symbols: 318
|
|
182
|
+
References: 1204
|
|
183
|
+
File edges: 86
|
|
184
|
+
Symbol edges: 542
|
|
185
|
+
```
|
|
186
|
+
|
|
157
187
|
## Graceful Degradation
|
|
158
188
|
|
|
159
189
|
If `.ftm-map/map.db` does not exist when a query is requested:
|
|
@@ -170,11 +200,12 @@ All heavy lifting is done by Python scripts in `ftm-map/scripts/`. The skill orc
|
|
|
170
200
|
| Script | Purpose |
|
|
171
201
|
|--------|---------|
|
|
172
202
|
| `setup.sh` | Creates virtualenv, installs tree-sitter and dependencies |
|
|
173
|
-
| `db.py` | SQLite schema,
|
|
174
|
-
| `parser.py` | tree-sitter
|
|
175
|
-
| `index.py` | Full bootstrap scan and incremental file indexing |
|
|
176
|
-
| `query.py` | Blast radius, dependency chain, FTS5
|
|
177
|
-
| `
|
|
203
|
+
| `db.py` | 5-table SQLite schema (files, symbols, refs, file_edges, symbol_edges), CRUD, graph traversal |
|
|
204
|
+
| `parser.py` | Aider-style def/ref extraction via tree-sitter tags.scm queries |
|
|
205
|
+
| `index.py` | Full bootstrap scan and incremental file indexing with Aider weight heuristics |
|
|
206
|
+
| `query.py` | Blast radius, dependency chain, FTS5 search, symbol info, context selection, stats |
|
|
207
|
+
| `ranker.py` | PageRank-based file ranking with fast-pagerank and scipy sparse matrices |
|
|
208
|
+
| `views.py` | INTENT.md and ARCHITECTURE.mmd generation from the 5-table graph |
|
|
178
209
|
|
|
179
210
|
Always use the venv python — never the system python — to ensure tree-sitter bindings are available:
|
|
180
211
|
```
|
|
@@ -215,6 +246,7 @@ After `map_updated` or session end:
|
|
|
215
246
|
- tool: `ftm-map/scripts/index.py` | required | bootstrap and incremental indexer
|
|
216
247
|
- tool: `ftm-map/scripts/query.py` | required | blast radius, dependency, and FTS5 search queries
|
|
217
248
|
- tool: `ftm-map/scripts/views.py` | required | INTENT.md and .mmd diagram generation from graph
|
|
249
|
+
- tool: `ftm-map/scripts/ranker.py` | required | PageRank file ranking with fast-pagerank and scipy
|
|
218
250
|
- tool: `git` | optional | changed file detection for incremental mode
|
|
219
251
|
- config: `~/.claude/ftm-config.yml` | optional | model profile and skills.ftm-map.enabled flag
|
|
220
252
|
|
|
@@ -255,5 +287,5 @@ After `map_updated` or session end:
|
|
|
255
287
|
### task_completed
|
|
256
288
|
- skill: string — "ftm-map"
|
|
257
289
|
- operation: string — "bootstrap" | "incremental" | "query"
|
|
258
|
-
- query_type: string | null — "blast-radius" | "deps" | "search" | "info" (for query mode)
|
|
290
|
+
- query_type: string | null — "blast-radius" | "deps" | "search" | "info" | "context" | "stats" (for query mode)
|
|
259
291
|
- duration_ms: number — total operation duration
|