@fabersep/atlas 0.1.0 → 0.1.1
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/CHANGELOG.md +20 -1
- package/README.md +50 -14
- package/dist/packs/typescript/calls.js +7 -0
- package/dist/packs/typescript/signals.d.ts +1 -1
- package/dist/packs/typescript/signals.js +127 -3
- package/dist/src/cli.js +109 -3
- package/dist/src/context/pre-grep.d.ts +15 -0
- package/dist/src/context/pre-grep.js +79 -0
- package/dist/src/context/pre-invoke.d.ts +20 -0
- package/dist/src/context/pre-invoke.js +127 -0
- package/dist/src/context/pre-prompt.d.ts +16 -0
- package/dist/src/context/pre-prompt.js +66 -0
- package/dist/src/context/session.d.ts +17 -0
- package/dist/src/context/session.js +57 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/init/init.d.ts +32 -1
- package/dist/src/init/init.js +194 -0
- package/dist/src/init/scout.js +21 -12
- package/dist/src/mcp/server.d.ts +132 -0
- package/dist/src/mcp/server.js +142 -13
- package/dist/src/queries/flow.js +11 -4
- package/dist/src/queries/investigate.d.ts +43 -0
- package/dist/src/queries/investigate.js +216 -0
- package/dist/src/queries/search.d.ts +37 -0
- package/dist/src/queries/search.js +279 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@fabersep/atlas`. Versions follow [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
-
## 0.1.
|
|
5
|
+
## 0.1.1 (unreleased)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Structural `search` query (`faber-atlas search <query>` and MCP tool `search`) that locates symbols, files, HTTP routes, events, and jobs with signatures and call/event/job links in a single step.
|
|
9
|
+
- MCP `initialize` `instructions` and `anthropic/alwaysLoad` on `search`, `map`, `flow`, and `impact` so Claude Code keeps core Atlas tools loaded without a `ToolSearch` turn.
|
|
10
|
+
- Non-blocking Claude Code `PreToolUse` hook (`faber-atlas pre-grep`) installed by `init` (`--no-hooks` skips it, `--undo` removes it): whenever the model calls `Grep` on code, Atlas attaches matching structural symbols and call/event/job links as `additionalContext` without denying `Grep`. In a 6-question multi-turn Immich benchmark (Sonnet low), `search` + `enrich` raised Atlas adoption to 5–6/6 while cutting total tool calls by 45% (Reads 9→1), input tokens by 15%, output tokens by 30%, and latency by 21%.
|
|
11
|
+
- Non-blocking Antigravity `PreInvocation` hook (`faber-atlas pre-invoke`) installed by `init` into `~/.gemini/config/hooks.json` (`--no-hooks` skips it, `--undo` removes only Atlas's hook): injects Atlas structural matches once per new user prompt via `injectSteps`. Measured on a 288-file Flutter/Dart app (`-46%` total tokens on `gemini-3.8-flash-low`, `-34%` total tokens and `3/4 → 4/4` accuracy on `gemini-4-hydrogen-low`) and a 157-file TypeScript API (`-21%` total tokens on `gemini-4-hydrogen-low`).
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- `README.md` benchmark section now reports full multi-turn totals (Claude Code and Antigravity) instead of primary-model-only Scout numbers, and documents `search` and the automatic enrich hooks.
|
|
15
|
+
|
|
16
|
+
- Claude Code Scout benchmark (`bench/run-claude-scout.py`, `bench/results/outline-227f85c-claude-scout/`): 48 fresh sessions on Outline and a private Flutter + TypeScript app. Sonnet low with a Haiku low Scout cost 37% less than Sonnet alone (45% less on questions) but took about twice as long; the README and the Scout guide say so.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- The Claude Code Scout (`~/.claude/agents/atlas-scout.md`) now has the `search` tool and starts with it; before, it could not use Atlas's one-step search.
|
|
20
|
+
- The Antigravity app starts MCP servers in `/`, where Atlas refused to work. Every MCP tool now takes an optional `root` (the project's absolute path), the refusal tells the agent to call again with it, the Antigravity Scout block says to always pass it, and the server asks the client for its workspace roots again when the first answer had none. Start folder and roots are logged to stderr.
|
|
21
|
+
- Claude Code almost never used Atlas on its own (0 of 4 measured questions): it shows MCP tools by name only. `init` now adds a short Atlas block to `~/.claude/CLAUDE.md` (when to use it, how to load its tools; 2 of 4 and 2 of 6 with it) and allows Atlas's read-only tools in `~/.claude/settings.json`, so they run without a prompt. `--no-rules` and `--no-allow` skip either. For Antigravity, `init` says to choose "Always allow" at the first prompt.
|
|
22
|
+
- After this update, run `npx @fabersep/atlas@latest init` once more so the new instructions and the permission rule are added.
|
|
23
|
+
|
|
24
|
+
## 0.1.0 (2026-11-28)
|
|
6
25
|
|
|
7
26
|
First release of FaberSEP Atlas, the successor of the private `code-intelligence` 0.8.0.
|
|
8
27
|
|
package/README.md
CHANGED
|
@@ -20,10 +20,10 @@ On a bigger change it gets worse: it can invent a helper that doesn't exist, or
|
|
|
20
20
|
|
|
21
21
|
Atlas reads your project on your computer and keeps a map of it: every file, every class and function with its signature, who calls whom, and which events and background jobs connect them. When files change, it updates the map in milliseconds.
|
|
22
22
|
|
|
23
|
-
Your assistant asks the map instead of searching:
|
|
23
|
+
Your assistant asks the map instead of searching blindly:
|
|
24
24
|
|
|
25
|
-
1. **"
|
|
26
|
-
2. **"What happens when `changePassword` runs?"**
|
|
25
|
+
1. **"Find where API keys or uploads are handled."** `search` locates matching symbols, files, HTTP routes, events, and jobs in one step — with exact line numbers, signatures, and what each method calls, emits, or queues.
|
|
26
|
+
2. **"What happens when `changePassword` runs?"** `flow` traces the whole chain in one answer, across calls, events, and background jobs:
|
|
27
27
|
|
|
28
28
|
```text
|
|
29
29
|
AuthController.changePassword (src/controllers/auth.controller.ts:121) [POST /change-password]
|
|
@@ -34,9 +34,10 @@ Your assistant asks the map instead of searching:
|
|
|
34
34
|
──calls──▶ SessionRepository.invalidateAll (src/repositories/session.repository.ts:104)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
3. **"What breaks if I change this?"**
|
|
37
|
+
3. **"What breaks if I change this?"** `impact` lists every caller, every web route and job that reaches that code, and the tests to update.
|
|
38
|
+
4. **Automatic enrichment, zero friction.** `init` installs lightweight, non-blocking hooks: in **Claude Code**, whenever the assistant runs `Grep` on code, Atlas attaches matching structural symbols and call/event/job links alongside the result; in **Antigravity**, a `PreInvocation` hook injects a compact routing reminder when Scout is installed (or structural Atlas matches when Scout is disabled) before the first tool call. Nothing is blocked, and the assistant can skip reading whole files.
|
|
38
39
|
|
|
39
|
-
Atlas also sets up
|
|
40
|
+
Atlas also sets up an optional **Scout** helper (`haiku` in Claude Code, `flash` in Antigravity): your main model hands it the looking-up and gets back only the files and lines that matter. In our Claude Code measurement it cut the cost of code questions by 45%, but the answer took about twice as long (below).
|
|
40
41
|
|
|
41
42
|
## Why you can trust it
|
|
42
43
|
|
|
@@ -75,21 +76,53 @@ Run it inside a project. Right after setup it says the map is not built yet. Tha
|
|
|
75
76
|
|
|
76
77
|
> *"Where do we send the order confirmation email, and what triggers it?"*
|
|
77
78
|
|
|
78
|
-
You don't need special commands
|
|
79
|
+
You don't need special commands: setup connects the MCP tools (`search`, `map`, `flow`, `impact`, `brief`, `neighborhood`, `hubs`, `health`), allows Atlas's read-only tools without asking in Claude Code (in Antigravity, choose "Always allow" the first time it asks), and adds non-blocking enrich hooks so Atlas matches show up automatically when your assistant searches code.
|
|
79
80
|
|
|
80
81
|
---
|
|
81
82
|
|
|
82
83
|
## Measured on real projects
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
All numbers below count **total** tokens, time, and accuracy of the full multi-turn conversation (no hidden helper costs):
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
| :--- | ---: | ---: |
|
|
88
|
-
| Main model's tokens | 119,415 | **76,757** (-36%) |
|
|
89
|
-
| Main model's time | 61.8 s | **31.5 s** (-49%) |
|
|
90
|
-
| Tasks done correctly | 3 of 4 | **4 of 4** |
|
|
87
|
+
**Claude Code (`Sonnet`, low effort)** — [Immich](https://github.com/immich-app/immich) `server/` (778 TypeScript files), 6 consecutive code-navigation questions in one session (`--resume`):
|
|
91
88
|
|
|
92
|
-
|
|
89
|
+
| | Baseline (Grep + Read) | With Atlas (`search` + `PreToolUse` enrich) | Change |
|
|
90
|
+
| :--- | ---: | ---: | ---: |
|
|
91
|
+
| Tool calls (file reads) | 20 (9 reads) | **11 (1 read)** | **-45%** |
|
|
92
|
+
| Total input tokens | 697k | **594k** | **-15%** |
|
|
93
|
+
| Output tokens | 6,463 | **4,492** | **-30%** |
|
|
94
|
+
| Cache-neutral cost | $0.31 | **$0.25** | **-19%** |
|
|
95
|
+
| Time | 47 s | **37 s** | **-21%** |
|
|
96
|
+
| Correct | 6 of 6 | **6 of 6** | |
|
|
97
|
+
|
|
98
|
+
**Antigravity (`PreInvocation` enrich hook)** — 4 consecutive trace, impact, and edit-plan tasks in one conversation across two real production apps:
|
|
99
|
+
|
|
100
|
+
| Project | Model | Baseline total tokens | With Atlas enrich | Change | Correct |
|
|
101
|
+
| :--- | :--- | ---: | ---: | ---: | :---: |
|
|
102
|
+
| Flutter/Dart app (288 files) | `gemini-3.8-flash-low` | 3.86M | **2.10M** | **-46%** | 4/4 → 4/4 |
|
|
103
|
+
| Flutter/Dart app (288 files) | `gemini-4-hydrogen-low` | 743k | **488k** | **-34%** (-13% time) | **3/4 → 4/4** |
|
|
104
|
+
| TypeScript API (157 files) | `gemini-4-hydrogen-low` | 1.09M | **859k** | **-21%** | 4/4 → 4/4 |
|
|
105
|
+
|
|
106
|
+
**Claude Code Scout (`Sonnet` low + `Haiku` low Scout)**: [Outline](https://github.com/outline/outline) (2,662 files) and a private Flutter + TypeScript app (992 files). 3 trace or impact questions and 1 edit per repo, each run twice, every run a fresh session:
|
|
107
|
+
|
|
108
|
+
| | Sonnet alone (Grep + Read) | + Atlas | + Atlas + Haiku Scout | Scout vs alone |
|
|
109
|
+
| :--- | ---: | ---: | ---: | ---: |
|
|
110
|
+
| Total cost, Scout included | $2.14 | $2.28 | **$1.34** | **-37%** (questions -45%) |
|
|
111
|
+
| Wall time | **467 s** | 422 s | 926 s | +98% |
|
|
112
|
+
| Correct | 16/16 | 14/16 | 15/16 | |
|
|
113
|
+
|
|
114
|
+
The Scout makes code questions cheaper, not faster: Haiku searches step by step while Sonnet waits. Use it when cost matters more than waiting; on small edits it saves nothing. Setup and every Outline run: [benchmark summary](bench/results/outline-227f85c-claude-scout/SUMMARY.md).
|
|
115
|
+
|
|
116
|
+
**Suite 1.1 — Antigravity (`gemini-4-hydrogen-low`)** — [Immich](https://github.com/immich-app/immich) `v3.4.2` (`mobile/` Flutter/Dart), 10 fresh-session tasks across 5 categories (directional, 1 run per task; Setups B and D pending):
|
|
117
|
+
|
|
118
|
+
| Setup | Subagent model | Paths | Symbols | Facts | Edits (`flutter analyze`) | Routing | Main tok | Sub tok | Total tok | Wall time |
|
|
119
|
+
| :--- | :--- | ---: | ---: | ---: | :---: | :---: | ---: | ---: | ---: | ---: |
|
|
120
|
+
| **A** (Main model alone) | — | 18/20 | 37/40 | 29/33 | 2/2 passed | — | 272.3k | — | **272.3k** | **234 s** |
|
|
121
|
+
| **C** (`+ Atlas + flash_lite` Scout) | `gemini-3.5-flash-lite` | 18/20 | 36/40 | 29/33 | 2/2 passed | 10/10 | **235.3k** | 127.3k | 362.6k | 254 s |
|
|
122
|
+
|
|
123
|
+
Note: when the main model is already lightweight (`gemini-4-hydrogen-low`), delegating to a subagent lowers main-model context (`-14%`) while adding subagent tokens (`127.3k` on `gemini-3.5-flash-lite`). On current Antigravity builds, `Model: "flash"` resolves to `gemini-4-hydrogen-tiered-high` (higher accuracy `20/20` paths, `38/40` symbols, `30/33` facts, but `248.4k` subagent tokens and `392 s`). Suite harness: [bench/suite/README.md](bench/suite/README.md).
|
|
124
|
+
|
|
125
|
+
Savings are largest on multi-turn sessions and larger multi-layer codebases; on small repos or one-off single questions, gains are smaller because plain `Grep` is already fast. Use `npx @fabersep/atlas stats` to inspect compression and latency on your own project.
|
|
93
126
|
|
|
94
127
|
On a private app with a Flutter client, a TypeScript API and a React admin (848 files), the map is 83% smaller than the code it describes; the first scan takes 1.3 s and an update after a change 55 ms (Apple M4 Pro).
|
|
95
128
|
|
|
@@ -101,8 +134,11 @@ TypeScript and JavaScript (including React), Dart and Flutter, C# and .NET, plus
|
|
|
101
134
|
|
|
102
135
|
## Common questions
|
|
103
136
|
|
|
137
|
+
**Will it ask for permission every time?**
|
|
138
|
+
In Claude Code, no: setup allows Atlas's tools, which only read your code. In Antigravity, choose "Always allow" the first time it asks.
|
|
139
|
+
|
|
104
140
|
**Does it slow my assistant down or cost more?**
|
|
105
|
-
It is meant to do the opposite: one short answer from the map replaces many file reads. Its tool descriptions add about 1,
|
|
141
|
+
It is meant to do the opposite: one short answer from the map replaces many file reads. Its tool descriptions add about 1,200 tokens to a chat.
|
|
106
142
|
|
|
107
143
|
**What does it put in my project?**
|
|
108
144
|
Only a `.faber-atlas/` folder with the map, which git ignores. The setup itself lives in your user folder (your AI tools' settings and the Scout), not in your projects.
|
|
@@ -137,6 +137,13 @@ function extractCallsInRange(root, start, end, ownerName, fieldTypes) {
|
|
|
137
137
|
targetKey = key;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
+
else if ((method === 'create' || method === 'schedule') && /^events?$/i.test(receiverType ?? receiver)) {
|
|
141
|
+
const key = extractKeyArg(args);
|
|
142
|
+
if (key) {
|
|
143
|
+
kind = 'emits';
|
|
144
|
+
targetKey = key;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
140
147
|
else if (EVENT_METHODS.has(method) && method === 'emit') {
|
|
141
148
|
const key = extractKeyArg(args);
|
|
142
149
|
if (key) {
|
|
@@ -3,5 +3,5 @@ import type { RoleTag } from '../../src/model.js';
|
|
|
3
3
|
import { type Declared } from '../../src/packs/symbols.js';
|
|
4
4
|
/** Attaches `entrypoints` and `throws` signals to declared TypeScript symbols. */
|
|
5
5
|
export declare function withTypeScriptSignals(items: Declared[], root: Node): Declared[];
|
|
6
|
-
/** Extracts file-level AST role hints (decorators and
|
|
6
|
+
/** Extracts file-level AST role hints (decorators, JSX, and event-listener patterns) from a TypeScript/TSX tree. */
|
|
7
7
|
export declare function typeScriptAstRoles(root: Node): RoleTag[];
|
|
@@ -141,27 +141,151 @@ function indexNodesByRange(root) {
|
|
|
141
141
|
walk(root);
|
|
142
142
|
return byRange;
|
|
143
143
|
}
|
|
144
|
+
const EVENT_ARRAY_FIELDS = new Set(['applicableEvents', 'events', 'subscribedEvents', 'handledEvents']);
|
|
145
|
+
const EVENT_HANDLER_METHODS = new Set(['onEvent', 'handle', 'handleEvent', 'perform', 'process', 'run', 'execute']);
|
|
146
|
+
/** Extracts event name literals from an array (`["users.suspend", ...]`), `as const`, or `new Set([...])`. */
|
|
147
|
+
function extractEventArrayLiterals(node) {
|
|
148
|
+
if (!node)
|
|
149
|
+
return [];
|
|
150
|
+
let target = node;
|
|
151
|
+
while (target && (target.type === 'as_expression' || target.type === 'satisfies_expression' || target.type === 'parenthesized_expression')) {
|
|
152
|
+
target = target.namedChildren[0] ?? null;
|
|
153
|
+
}
|
|
154
|
+
if (!target)
|
|
155
|
+
return [];
|
|
156
|
+
if (target.type === 'new_expression') {
|
|
157
|
+
const args = target.childForFieldName('arguments')?.namedChildren ?? [];
|
|
158
|
+
return extractEventArrayLiterals(args[0]);
|
|
159
|
+
}
|
|
160
|
+
if (target.type !== 'array')
|
|
161
|
+
return [];
|
|
162
|
+
const out = [];
|
|
163
|
+
for (const elem of target.namedChildren) {
|
|
164
|
+
if (!elem)
|
|
165
|
+
continue;
|
|
166
|
+
if (elem.type === 'string' || (elem.type === 'template_string' && !elem.text.includes('${'))) {
|
|
167
|
+
const val = unquote(elem.text);
|
|
168
|
+
if (val && val !== '*')
|
|
169
|
+
out.push(`event:${val}`);
|
|
170
|
+
}
|
|
171
|
+
else if (elem.type === 'member_expression') {
|
|
172
|
+
out.push(`event:${elem.text}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return [...new Set(out)];
|
|
176
|
+
}
|
|
177
|
+
/** Collects `event:<name>` entrypoints from `static applicableEvents = [...]` (or similar) fields on a class node. */
|
|
178
|
+
function classApplicableEventEntrypoints(classNode) {
|
|
179
|
+
const body = classNode.childForFieldName('body');
|
|
180
|
+
if (!body)
|
|
181
|
+
return [];
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const child of body.namedChildren) {
|
|
184
|
+
if (!child || child.type !== 'public_field_definition')
|
|
185
|
+
continue;
|
|
186
|
+
const fieldName = child.childForFieldName('name')?.text;
|
|
187
|
+
if (!fieldName || !EVENT_ARRAY_FIELDS.has(fieldName))
|
|
188
|
+
continue;
|
|
189
|
+
out.push(...extractEventArrayLiterals(child.childForFieldName('value')));
|
|
190
|
+
}
|
|
191
|
+
return [...new Set(out)];
|
|
192
|
+
}
|
|
193
|
+
/** Collects `event:<name>` entrypoints from `switch (event.name) { case "users.suspend": ... }` inside a callable range. */
|
|
194
|
+
function switchEventEntrypointsIn(root, start, end) {
|
|
195
|
+
const found = new Set();
|
|
196
|
+
const walk = (node) => {
|
|
197
|
+
if (node.endIndex <= start || node.startIndex >= end)
|
|
198
|
+
return;
|
|
199
|
+
if (node.type === 'switch_statement' && node.startIndex >= start && node.endIndex <= end) {
|
|
200
|
+
const cond = node.childForFieldName('value')?.text ?? '';
|
|
201
|
+
if (/\bevent(?:\.name|\.type|Name|Type)?\b/i.test(cond)) {
|
|
202
|
+
const body = node.childForFieldName('body');
|
|
203
|
+
for (const clause of body?.namedChildren ?? []) {
|
|
204
|
+
if (!clause || clause.type !== 'switch_case')
|
|
205
|
+
continue;
|
|
206
|
+
const val = clause.childForFieldName('value');
|
|
207
|
+
if (!val)
|
|
208
|
+
continue;
|
|
209
|
+
if (val.type === 'string' || (val.type === 'template_string' && !val.text.includes('${'))) {
|
|
210
|
+
const name = unquote(val.text);
|
|
211
|
+
if (name)
|
|
212
|
+
found.add(`event:${name}`);
|
|
213
|
+
}
|
|
214
|
+
else if (val.type === 'member_expression') {
|
|
215
|
+
found.add(`event:${val.text}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
for (const c of node.children)
|
|
221
|
+
if (c)
|
|
222
|
+
walk(c);
|
|
223
|
+
};
|
|
224
|
+
walk(root);
|
|
225
|
+
return [...found];
|
|
226
|
+
}
|
|
144
227
|
/** Attaches `entrypoints` and `throws` signals to declared TypeScript symbols. */
|
|
145
228
|
export function withTypeScriptSignals(items, root) {
|
|
146
229
|
const byRange = indexNodesByRange(root);
|
|
230
|
+
// Pre-collect class-level `applicableEvents` so we can attach them to both the class and its handler method(s).
|
|
231
|
+
const classEvents = new Map();
|
|
232
|
+
for (const item of items) {
|
|
233
|
+
if (item.kind !== 'class')
|
|
234
|
+
continue;
|
|
235
|
+
const astNode = byRange.get(`${item.start}:${item.end}`);
|
|
236
|
+
if (!astNode)
|
|
237
|
+
continue;
|
|
238
|
+
const evs = classApplicableEventEntrypoints(astNode);
|
|
239
|
+
if (evs.length)
|
|
240
|
+
classEvents.set(item, evs);
|
|
241
|
+
}
|
|
147
242
|
return items.map((item) => {
|
|
148
243
|
const astNode = byRange.get(`${item.start}:${item.end}`);
|
|
149
|
-
const entrypoints = astNode ? entrypointsFromDecorators(decoratorsOf(astNode)) : [];
|
|
244
|
+
const entrypoints = new Set(astNode ? entrypointsFromDecorators(decoratorsOf(astNode)) : []);
|
|
245
|
+
if (item.kind === 'class') {
|
|
246
|
+
for (const ev of classEvents.get(item) ?? [])
|
|
247
|
+
entrypoints.add(ev);
|
|
248
|
+
}
|
|
249
|
+
if (FUNCTION_KINDS.has(item.kind)) {
|
|
250
|
+
for (const ev of switchEventEntrypointsIn(root, item.start, item.end))
|
|
251
|
+
entrypoints.add(ev);
|
|
252
|
+
if (EVENT_HANDLER_METHODS.has(item.name)) {
|
|
253
|
+
for (const [cls, evs] of classEvents) {
|
|
254
|
+
if (item.start > cls.start && item.end <= cls.end) {
|
|
255
|
+
for (const ev of evs)
|
|
256
|
+
entrypoints.add(ev);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
150
261
|
const throws = FUNCTION_KINDS.has(item.kind) ? throwsIn(root, item.start, item.end) : [];
|
|
262
|
+
const epList = [...entrypoints];
|
|
151
263
|
return {
|
|
152
264
|
...item,
|
|
153
|
-
...(
|
|
265
|
+
...(epList.length ? { entrypoints: epList } : {}),
|
|
154
266
|
...(throws.length ? { throws } : {}),
|
|
155
267
|
};
|
|
156
268
|
});
|
|
157
269
|
}
|
|
158
|
-
/** Extracts file-level AST role hints (decorators and
|
|
270
|
+
/** Extracts file-level AST role hints (decorators, JSX, and event-listener patterns) from a TypeScript/TSX tree. */
|
|
159
271
|
export function typeScriptAstRoles(root) {
|
|
160
272
|
const roles = new Set();
|
|
161
273
|
const walk = (node) => {
|
|
162
274
|
if (node.type === 'jsx_element' || node.type === 'jsx_self_closing_element') {
|
|
163
275
|
roles.add('ui');
|
|
164
276
|
}
|
|
277
|
+
else if (node.type === 'public_field_definition') {
|
|
278
|
+
const fieldName = node.childForFieldName('name')?.text;
|
|
279
|
+
if (fieldName && EVENT_ARRAY_FIELDS.has(fieldName) && extractEventArrayLiterals(node.childForFieldName('value')).length > 0) {
|
|
280
|
+
roles.add('event');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else if (node.type === 'switch_statement') {
|
|
284
|
+
const cond = node.childForFieldName('value')?.text ?? '';
|
|
285
|
+
if (/\bevent(?:\.name|\.type|Name|Type)?\b/i.test(cond)) {
|
|
286
|
+
roles.add('event');
|
|
287
|
+
}
|
|
288
|
+
}
|
|
165
289
|
else if (node.type === 'decorator') {
|
|
166
290
|
const dec = parseDecorator(node);
|
|
167
291
|
if (dec) {
|
package/dist/src/cli.js
CHANGED
|
@@ -8,13 +8,18 @@ import { checkLimits, health } from './health/health.js';
|
|
|
8
8
|
import { HealthLimitsError } from './health/types.js';
|
|
9
9
|
import { formatInitPlan, planOrApplyInit } from './init/init.js';
|
|
10
10
|
import { defaultUserHome, discoverLiveAgyModels, formatScoutStatus, readCurrentScoutConfigs, runInteractiveScout, setScoutConfig, } from './init/scout.js';
|
|
11
|
+
import { preGrepEnrich } from './context/pre-grep.js';
|
|
12
|
+
import { preInvokeEnrich } from './context/pre-invoke.js';
|
|
13
|
+
import { prePromptEnrich } from './context/pre-prompt.js';
|
|
11
14
|
import { ensureFreshIndex, projectRootFrom, serveMcp } from './mcp/server.js';
|
|
12
15
|
import { formatDoctor, runDoctor } from './metrics/doctor.js';
|
|
13
16
|
import { computeStats, formatShareCard, formatStats } from './metrics/stats.js';
|
|
14
17
|
import { readCodeMap, readTopology } from './outputs.js';
|
|
15
18
|
import { flow, impact, renderFlow, UnknownSymbolError } from './queries/flow.js';
|
|
19
|
+
import { investigate, renderInvestigate } from './queries/investigate.js';
|
|
16
20
|
import { renderMap } from './queries/map.js';
|
|
17
21
|
import { neighborhood } from './queries/neighborhood.js';
|
|
22
|
+
import { renderSearch, search } from './queries/search.js';
|
|
18
23
|
import { scan } from './scan/scan.js';
|
|
19
24
|
import { briefsText, neighborhoodList, neighborhoodText } from './text/briefs.js';
|
|
20
25
|
import { GENERATOR_VERSION } from './version.js';
|
|
@@ -48,16 +53,29 @@ const USAGE = `Usage: faber-atlas <command> [options] (faber-atlas --version p
|
|
|
48
53
|
health-compare <before.json> <after.json> [--json]
|
|
49
54
|
What changed between two health reports made with the same limits: limits crossed, new
|
|
50
55
|
duplicates, new cycles, and the totals before and after.
|
|
56
|
+
investigate <query> [--budget <tokens>] [--folder <dir>] [--limit <n>] [--depth <n>] [--include-tests] [--out <dir>] [--root <folder>] [--fresh] [--json]
|
|
57
|
+
One-call context pack: structural search hits, flow/impact chains, budgeted source excerpts, and related tests.
|
|
58
|
+
search <query> [--folder <dir>] [--limit <n>] [--include-tests] [--out <dir>] [--fresh] [--json]
|
|
59
|
+
Fast structural search across symbols, files, HTTP routes, events, and jobs.
|
|
60
|
+
pre-grep
|
|
61
|
+
Claude Code PreToolUse hook for Grep: reads hook JSON on stdin and enriches Grep with Atlas matches.
|
|
62
|
+
pre-prompt
|
|
63
|
+
Claude Code UserPromptSubmit hook: reads hook JSON on stdin and injects Atlas matches for each user prompt.
|
|
64
|
+
pre-invoke
|
|
65
|
+
Antigravity PreInvocation hook: reads hook JSON on stdin and injects Atlas matches for each new prompt.
|
|
51
66
|
mcp [--root <folder>] [--out <dir>] [--no-fresh]
|
|
52
|
-
Start a stdio MCP server exposing map, brief, neighborhood, flow, impact, hubs, and health.
|
|
67
|
+
Start a stdio MCP server exposing investigate, search, map, brief, neighborhood, flow, impact, hubs, and health.
|
|
53
68
|
Without --root it maps the project the AI tool has open (its workspace root, else the git
|
|
54
69
|
root above the folder it starts in), never the whole home folder. Runs an incremental scan
|
|
55
70
|
before each query unless --no-fresh is given.
|
|
56
|
-
init [--engine <name>]... [--scout-model <m>] [--scout-effort <low|medium|high>] [--no-scout] [--agents-md] [--root <folder>] [--preview | --undo] [--json]
|
|
71
|
+
init [--engine <name>]... [--scout-model <m>] [--scout-effort <low|medium|high>] [--no-scout] [--no-rules] [--no-allow] [--no-hooks] [--agents-md] [--root <folder>] [--preview | --undo] [--json]
|
|
57
72
|
One-time setup for every project: the MCP server and a read-only Scout for Claude Code,
|
|
58
73
|
Antigravity and Cursor (Claude Desktop with --engine claude-desktop, mapping --root).
|
|
59
74
|
Applies directly (with .faber-atlas.bak backups); --preview shows the changes without writing,
|
|
60
75
|
--undo removes them. --agents-md also adds a navigation block to this project's AGENTS.md.
|
|
76
|
+
For Claude Code it also adds a short Atlas block to ~/.claude/CLAUDE.md (--no-rules skips it),
|
|
77
|
+
allows Atlas's read-only tools (--no-allow skips it), and installs a PreToolUse Grep enrich hook
|
|
78
|
+
in ~/.claude/settings.json (--no-hooks skips it).
|
|
61
79
|
scout [--engine <claude-code|antigravity>] [--model <name>] [--effort <low|medium|high>] [--discover] [--json]
|
|
62
80
|
Inspect or configure the read-only Scout model and reasoning effort per environment.
|
|
63
81
|
Run interactively without flags to pick from supported tiers, or pass --model/--effort directly.
|
|
@@ -76,7 +94,7 @@ const LIMIT_FLAGS = {
|
|
|
76
94
|
};
|
|
77
95
|
const VALUE_FLAGS = new Set([
|
|
78
96
|
'out', 'exclude', 'depth', 'budget', 'top', 'root', 'zoom', 'engine', 'days',
|
|
79
|
-
'model', 'effort', 'scout-model', 'scout-effort',
|
|
97
|
+
'model', 'effort', 'scout-model', 'scout-effort', 'limit', 'folder',
|
|
80
98
|
...Object.values(LIMIT_FLAGS),
|
|
81
99
|
]);
|
|
82
100
|
function parseArgs(argv) {
|
|
@@ -246,6 +264,91 @@ async function main(argv) {
|
|
|
246
264
|
case 'hubs': return runHubs(args);
|
|
247
265
|
case 'health': return runHealth(args);
|
|
248
266
|
case 'health-compare': return runHealthCompare(args);
|
|
267
|
+
case 'investigate': {
|
|
268
|
+
const q = args.positional.slice(1).join(' ');
|
|
269
|
+
if (!q.trim()) {
|
|
270
|
+
console.error('investigate needs a query.');
|
|
271
|
+
return 2;
|
|
272
|
+
}
|
|
273
|
+
const map = await loadMap(args);
|
|
274
|
+
const result = investigate(map, rootDir(args), q, {
|
|
275
|
+
budget: numberValue(args, 'budget'),
|
|
276
|
+
folder: value(args, 'folder'),
|
|
277
|
+
limit: numberValue(args, 'limit'),
|
|
278
|
+
depth: numberValue(args, 'depth'),
|
|
279
|
+
includeTests: args.flags.has('include-tests'),
|
|
280
|
+
});
|
|
281
|
+
if (args.flags.has('json'))
|
|
282
|
+
console.log(JSON.stringify(result, null, 2));
|
|
283
|
+
else
|
|
284
|
+
console.log(renderInvestigate(result));
|
|
285
|
+
return 0;
|
|
286
|
+
}
|
|
287
|
+
case 'search': {
|
|
288
|
+
const q = args.positional.slice(1).join(' ');
|
|
289
|
+
if (!q.trim()) {
|
|
290
|
+
console.error('search needs a query.');
|
|
291
|
+
return 2;
|
|
292
|
+
}
|
|
293
|
+
const result = search(await loadMap(args), q, {
|
|
294
|
+
folder: value(args, 'folder'),
|
|
295
|
+
limit: numberValue(args, 'limit'),
|
|
296
|
+
includeTests: args.flags.has('include-tests'),
|
|
297
|
+
});
|
|
298
|
+
if (args.flags.has('json'))
|
|
299
|
+
console.log(JSON.stringify(result, null, 2));
|
|
300
|
+
else
|
|
301
|
+
console.log(renderSearch(result));
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
case 'pre-grep': {
|
|
305
|
+
let input = {};
|
|
306
|
+
if (!process.stdin.isTTY) {
|
|
307
|
+
try {
|
|
308
|
+
const raw = fs.readFileSync(0, 'utf8');
|
|
309
|
+
input = raw.trim() ? JSON.parse(raw) : {};
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
input = {};
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (input.cwd === undefined)
|
|
316
|
+
input = { ...input, cwd: process.cwd() };
|
|
317
|
+
console.log(await preGrepEnrich(input));
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
case 'pre-prompt': {
|
|
321
|
+
let input = {};
|
|
322
|
+
if (!process.stdin.isTTY) {
|
|
323
|
+
try {
|
|
324
|
+
const raw = fs.readFileSync(0, 'utf8');
|
|
325
|
+
input = raw.trim() ? JSON.parse(raw) : {};
|
|
326
|
+
}
|
|
327
|
+
catch {
|
|
328
|
+
input = {};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (input.cwd === undefined)
|
|
332
|
+
input = { ...input, cwd: process.cwd() };
|
|
333
|
+
console.log(await prePromptEnrich(input));
|
|
334
|
+
return 0;
|
|
335
|
+
}
|
|
336
|
+
case 'pre-invoke': {
|
|
337
|
+
let input = {};
|
|
338
|
+
if (!process.stdin.isTTY) {
|
|
339
|
+
try {
|
|
340
|
+
const raw = fs.readFileSync(0, 'utf8');
|
|
341
|
+
input = raw.trim() ? JSON.parse(raw) : {};
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
input = {};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (input.cwd === undefined && !Array.isArray(input.workspacePaths))
|
|
348
|
+
input = { ...input, cwd: process.cwd() };
|
|
349
|
+
console.log(await preInvokeEnrich(input));
|
|
350
|
+
return 0;
|
|
351
|
+
}
|
|
249
352
|
case 'mcp':
|
|
250
353
|
await serveMcp({
|
|
251
354
|
root: value(args, 'root'),
|
|
@@ -266,6 +369,9 @@ async function main(argv) {
|
|
|
266
369
|
root: value(args, 'root') ?? args.positional[1],
|
|
267
370
|
engines,
|
|
268
371
|
agentsMd: args.flags.has('agents-md'),
|
|
372
|
+
rules: !args.flags.has('no-rules'),
|
|
373
|
+
allow: !args.flags.has('no-allow'),
|
|
374
|
+
hooks: !args.flags.has('no-hooks'),
|
|
269
375
|
scout: !args.flags.has('no-scout'),
|
|
270
376
|
scoutModel: value(args, 'scout-model'),
|
|
271
377
|
scoutEffort,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code PreToolUse hook for Grep (02/AC-24).
|
|
3
|
+
* Never blocks Grep: runs a fast structural Atlas search for the same pattern and attaches matching
|
|
4
|
+
* symbols, signatures, entrypoints, and call/event/job links as `additionalContext`.
|
|
5
|
+
*/
|
|
6
|
+
export interface PreToolUseInput {
|
|
7
|
+
session_id?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
tool_name?: string;
|
|
10
|
+
tool_input?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/** Resolves the project git root for the hook's cwd, or undefined outside any project (home folder or `/`). */
|
|
13
|
+
export declare function hookProjectRoot(cwd: unknown, userHome?: string): string | undefined;
|
|
14
|
+
/** Enriches a Claude Code Grep call with Atlas structural matches; never throws or blocks. */
|
|
15
|
+
export declare function preGrepEnrich(input: PreToolUseInput, userHome?: string): Promise<string>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { PACKS } from '../../packs/index.js';
|
|
5
|
+
import { projectRootFrom } from '../mcp/server.js';
|
|
6
|
+
import { readCodeMap } from '../outputs.js';
|
|
7
|
+
import { renderSearch, search } from '../queries/search.js';
|
|
8
|
+
import { scan } from '../scan/scan.js';
|
|
9
|
+
const NON_CODE_EXTS = /\.(md|markdown|json|yaml|yml|toml|ini|env|txt|csv|tsv|sql|html|css|scss|svg|xml|lock|sh|bash|zsh)$/i;
|
|
10
|
+
function isNonCodeTarget(toolInput) {
|
|
11
|
+
const targetPath = typeof toolInput.path === 'string' ? toolInput.path : '';
|
|
12
|
+
const glob = typeof toolInput.glob === 'string' ? toolInput.glob : '';
|
|
13
|
+
if (targetPath && NON_CODE_EXTS.test(targetPath))
|
|
14
|
+
return true;
|
|
15
|
+
if (glob && NON_CODE_EXTS.test(glob))
|
|
16
|
+
return true;
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/** Resolves the project git root for the hook's cwd, or undefined outside any project (home folder or `/`). */
|
|
20
|
+
export function hookProjectRoot(cwd, userHome = os.homedir()) {
|
|
21
|
+
if (typeof cwd !== 'string' || !path.isAbsolute(cwd) || !fs.existsSync(cwd))
|
|
22
|
+
return undefined;
|
|
23
|
+
const root = projectRootFrom(cwd);
|
|
24
|
+
const real = (p) => (fs.existsSync(p) ? fs.realpathSync(p) : p);
|
|
25
|
+
if (real(root) === real(userHome) || path.dirname(root) === root)
|
|
26
|
+
return undefined;
|
|
27
|
+
return root;
|
|
28
|
+
}
|
|
29
|
+
async function loadFastMap(root) {
|
|
30
|
+
const out = path.join(root, '.faber-atlas');
|
|
31
|
+
try {
|
|
32
|
+
return readCodeMap(out);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return (await scan({ root, out, packs: PACKS })).map;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Broad multi-branch regexes or very long patterns are literal scans, not symbol lookups. */
|
|
39
|
+
function isBroadRegexPattern(pattern) {
|
|
40
|
+
if (pattern.length > 60)
|
|
41
|
+
return true;
|
|
42
|
+
const pipes = (pattern.match(/\|/g) ?? []).length;
|
|
43
|
+
return pipes >= 2;
|
|
44
|
+
}
|
|
45
|
+
/** Enriches a Claude Code Grep call with Atlas structural matches; never throws or blocks. */
|
|
46
|
+
export async function preGrepEnrich(input, userHome = os.homedir()) {
|
|
47
|
+
try {
|
|
48
|
+
if (input.tool_name !== 'Grep')
|
|
49
|
+
return '{}';
|
|
50
|
+
const toolInput = input.tool_input ?? {};
|
|
51
|
+
const pattern = typeof toolInput.pattern === 'string' ? toolInput.pattern.trim() : '';
|
|
52
|
+
if (!pattern || isNonCodeTarget(toolInput) || isBroadRegexPattern(pattern))
|
|
53
|
+
return '{}';
|
|
54
|
+
const root = hookProjectRoot(input.cwd, userHome);
|
|
55
|
+
if (!root)
|
|
56
|
+
return '{}';
|
|
57
|
+
const map = await loadFastMap(root);
|
|
58
|
+
const result = search(map, pattern, { limit: 4 });
|
|
59
|
+
if (result.hits.length === 0)
|
|
60
|
+
return '{}';
|
|
61
|
+
// Skip noisy low-signal keyword matches on huge repos (e.g. generic tokens matching thousands of symbols)
|
|
62
|
+
if (result.totalMatches > 200 && result.hits[0].score < 150)
|
|
63
|
+
return '{}';
|
|
64
|
+
const additionalContext = [
|
|
65
|
+
renderSearch(result),
|
|
66
|
+
'Tip: use mcp__faber-atlas__flow(symbol) or mcp__faber-atlas__impact(symbol) to trace call/event/job chains instead of extra Grep or Read calls.',
|
|
67
|
+
].join('\n');
|
|
68
|
+
return JSON.stringify({
|
|
69
|
+
hookSpecificOutput: {
|
|
70
|
+
hookEventName: 'PreToolUse',
|
|
71
|
+
permissionDecision: 'allow',
|
|
72
|
+
additionalContext,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return '{}';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Antigravity PreInvocation hook (02/AC-25).
|
|
3
|
+
* Runs once per new user prompt (deduplicated per conversationId + prompt hash), searches the project's
|
|
4
|
+
* Atlas index for structural matches, and injects them as a systemMessage via `injectSteps` before the
|
|
5
|
+
* model makes its first tool call. Never throws.
|
|
6
|
+
*/
|
|
7
|
+
export interface PreInvocationInput {
|
|
8
|
+
conversationId?: unknown;
|
|
9
|
+
workspacePaths?: unknown;
|
|
10
|
+
cwd?: unknown;
|
|
11
|
+
lastUserInput?: unknown;
|
|
12
|
+
invocationNum?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** Extracts high-signal search keywords from a natural-language user prompt. */
|
|
15
|
+
export declare function extractPromptKeywords(prompt: string, maxTerms?: number): string;
|
|
16
|
+
/** Enriches a new Antigravity user turn with Atlas structural matches; never throws. */
|
|
17
|
+
export declare function preInvokeEnrich(input: PreInvocationInput, options?: {
|
|
18
|
+
userHome?: string;
|
|
19
|
+
stateDir?: string;
|
|
20
|
+
}): Promise<string>;
|