@nodesify/astria 1.0.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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/commands/add.d.ts +8 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +34 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/affected.d.ts +6 -0
- package/dist/commands/affected.d.ts.map +1 -0
- package/dist/commands/affected.js +30 -0
- package/dist/commands/affected.js.map +1 -0
- package/dist/commands/cluster.d.ts +2 -0
- package/dist/commands/cluster.d.ts.map +1 -0
- package/dist/commands/cluster.js +51 -0
- package/dist/commands/cluster.js.map +1 -0
- package/dist/commands/diagnose.d.ts +5 -0
- package/dist/commands/diagnose.d.ts.map +1 -0
- package/dist/commands/diagnose.js +20 -0
- package/dist/commands/diagnose.js.map +1 -0
- package/dist/commands/diff.d.ts +2 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +36 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/explain.d.ts +4 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +38 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/export.d.ts +7 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +33 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/feedback.d.ts +12 -0
- package/dist/commands/feedback.d.ts.map +1 -0
- package/dist/commands/feedback.js +41 -0
- package/dist/commands/feedback.js.map +1 -0
- package/dist/commands/global.d.ts +7 -0
- package/dist/commands/global.d.ts.map +1 -0
- package/dist/commands/global.js +61 -0
- package/dist/commands/global.js.map +1 -0
- package/dist/commands/history.d.ts +5 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +28 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/hook-guard.d.ts +2 -0
- package/dist/commands/hook-guard.d.ts.map +1 -0
- package/dist/commands/hook-guard.js +145 -0
- package/dist/commands/hook-guard.js.map +1 -0
- package/dist/commands/hook.d.ts +3 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +53 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/install.d.ts +3 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +40 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/map.d.ts +6 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +16 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/mcp.d.ts +4 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +15 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/merge.d.ts +2 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.js +51 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/migrate.d.ts +4 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +75 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/path.d.ts +6 -0
- package/dist/commands/path.d.ts.map +1 -0
- package/dist/commands/path.js +19 -0
- package/dist/commands/path.js.map +1 -0
- package/dist/commands/prs.d.ts +5 -0
- package/dist/commands/prs.d.ts.map +1 -0
- package/dist/commands/prs.js +133 -0
- package/dist/commands/prs.js.map +1 -0
- package/dist/commands/query.d.ts +10 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +22 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/run.d.ts +10 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +69 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/stats.d.ts +4 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +18 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.d.ts +4 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +57 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/tree.d.ts +6 -0
- package/dist/commands/tree.d.ts.map +1 -0
- package/dist/commands/tree.js +53 -0
- package/dist/commands/tree.js.map +1 -0
- package/dist/commands/update.d.ts +7 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +66 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/watch.d.ts +4 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +114 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/wiki.d.ts +7 -0
- package/dist/commands/wiki.d.ts.map +1 -0
- package/dist/commands/wiki.js +60 -0
- package/dist/commands/wiki.js.map +1 -0
- package/dist/graphify.node +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +251 -0
- package/dist/index.js.map +1 -0
- package/dist/install/hooks.d.ts +12 -0
- package/dist/install/hooks.d.ts.map +1 -0
- package/dist/install/hooks.js +307 -0
- package/dist/install/hooks.js.map +1 -0
- package/dist/install/index.d.ts +3 -0
- package/dist/install/index.d.ts.map +1 -0
- package/dist/install/index.js +362 -0
- package/dist/install/index.js.map +1 -0
- package/dist/install/markdown-inject.d.ts +7 -0
- package/dist/install/markdown-inject.d.ts.map +1 -0
- package/dist/install/markdown-inject.js +178 -0
- package/dist/install/markdown-inject.js.map +1 -0
- package/dist/install/platforms.d.ts +13 -0
- package/dist/install/platforms.d.ts.map +1 -0
- package/dist/install/platforms.js +130 -0
- package/dist/install/platforms.js.map +1 -0
- package/dist/install/settings-inject.d.ts +18 -0
- package/dist/install/settings-inject.d.ts.map +1 -0
- package/dist/install/settings-inject.js +425 -0
- package/dist/install/settings-inject.js.map +1 -0
- package/dist/native.d.ts +32 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +107 -0
- package/dist/native.js.map +1 -0
- package/package.json +72 -0
- package/skills/skill-aider.md +40 -0
- package/skills/skill-codex.md +46 -0
- package/skills/skill-copilot.md +46 -0
- package/skills/skill-cursor.md +39 -0
- package/skills/skill-gemini.md +46 -0
- package/skills/skill-kiro.md +39 -0
- package/skills/skill-opencode.md +44 -0
- package/skills/skill-trae.md +46 -0
- package/skills/skill.md +266 -0
package/skills/skill.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: astria
|
|
3
|
+
description: Turn any directory into a queryable knowledge graph. Trigger: /astria
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /astria
|
|
7
|
+
|
|
8
|
+
Turn any directory of source code into a queryable knowledge graph with community detection, hub node analysis, and a plain-language graph report. Uses AST-based extraction via tree-sitter for deterministic, fast analysis.
|
|
9
|
+
|
|
10
|
+
## What You Must Do When Invoked
|
|
11
|
+
|
|
12
|
+
If no path was given, use `.` (current directory). Do not ask the user for a path.
|
|
13
|
+
|
|
14
|
+
Follow these steps in order. Do not skip steps.
|
|
15
|
+
|
|
16
|
+
### Step 1 - Check graph state and build if needed
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
node -e "const fs=require('fs');const p='.astria/graph.json';if(!fs.existsSync(p)){console.log('missing');process.exit(0)}const age=Math.round((Date.now()-fs.statSync(p).mtimeMs)/60000);console.log(age>30?'stale':'fresh')"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Act on the result:
|
|
23
|
+
- `missing`: Run `astria run .` — this builds the full graph from scratch. Wait for it to complete.
|
|
24
|
+
- `stale`: Run `astria update .` — incremental rebuild of changed files. Wait for it to complete.
|
|
25
|
+
- `fresh`: Skip to Step 2.
|
|
26
|
+
|
|
27
|
+
After running `run` or `update`, verify with `astria stats --graph .` that Nodes > 0 (an incremental update with no changes correctly reports 0 nodes added). If Nodes is 0, tell the user: "No supported files found. astria supports Python, JS, TS, Rust, Go, Java, C, C++, Ruby, Swift, Scala, PHP, C#, Lua, Haskell, Elixir, Bash, Dart, Zig, CSS, Markdown, plain text, and PDF."
|
|
28
|
+
|
|
29
|
+
### Step 2 - Read the graph report
|
|
30
|
+
|
|
31
|
+
Read `.astria/graph_report.md`. Present a clean summary:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
Knowledge graph built: X nodes, Y edges, Z communities
|
|
35
|
+
|
|
36
|
+
Hub nodes (most connected):
|
|
37
|
+
1. NodeName — N connections (community C)
|
|
38
|
+
2. ...
|
|
39
|
+
|
|
40
|
+
Surprising connections:
|
|
41
|
+
- SourceNode → TargetNode [cross-community edge]
|
|
42
|
+
|
|
43
|
+
Suggested questions:
|
|
44
|
+
- "Question 1?"
|
|
45
|
+
- "Question 2?"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Do NOT dump the raw report. Summarize it.
|
|
49
|
+
|
|
50
|
+
### Step 3 - Ready for queries
|
|
51
|
+
|
|
52
|
+
Tell the user the graph is ready and they can ask questions. Example queries they might try:
|
|
53
|
+
- `astria query "authentication flow"`
|
|
54
|
+
- `astria path "AuthService" "UserModel"`
|
|
55
|
+
- `astria explain "validate_token"`
|
|
56
|
+
|
|
57
|
+
## Enforcement Rules
|
|
58
|
+
|
|
59
|
+
When working in a project with a `.astria/` directory, these rules are MANDATORY:
|
|
60
|
+
|
|
61
|
+
### FORBIDDEN
|
|
62
|
+
|
|
63
|
+
Do NOT use `Grep`, `Glob`, or file browsing as your first step for architecture or codebase questions. This includes:
|
|
64
|
+
- Searching for "where is X defined"
|
|
65
|
+
- Looking for "how does X connect to Y"
|
|
66
|
+
- Exploring "what files are in this project"
|
|
67
|
+
- Finding "all files that reference X"
|
|
68
|
+
|
|
69
|
+
### REQUIRED
|
|
70
|
+
|
|
71
|
+
Instead, use these astria commands:
|
|
72
|
+
|
|
73
|
+
| User asks | Use this command |
|
|
74
|
+
|-----------|-----------------|
|
|
75
|
+
| "Where is X implemented?" | `astria query "X"` |
|
|
76
|
+
| "How does X connect to Y?" | `astria path "X" "Y"` |
|
|
77
|
+
| "What does X do?" | `astria explain "X"` |
|
|
78
|
+
| "What is the architecture?" | Read `.astria/wiki/index.md` if present, else `.astria/graph_report.md` |
|
|
79
|
+
| "Give me a navigable overview" | `astria wiki --graph .` then read `.astria/wiki/index.md` |
|
|
80
|
+
| "Find all references to X" | `astria query "X" --depth 3` |
|
|
81
|
+
| "What community is X in?" | `astria explain "X"` |
|
|
82
|
+
|
|
83
|
+
Only use native file reading AFTER the graph has identified the exact files you need.
|
|
84
|
+
|
|
85
|
+
### When native tools ARE appropriate
|
|
86
|
+
|
|
87
|
+
- Editing a specific file (after graph identified which file)
|
|
88
|
+
- Reading a file the user explicitly named
|
|
89
|
+
- Running tests or build commands
|
|
90
|
+
- Git operations
|
|
91
|
+
|
|
92
|
+
### When direct search / file reading is better than the graph
|
|
93
|
+
|
|
94
|
+
The graph models entities and relationships — it does NOT model behavior.
|
|
95
|
+
Use Grep/Glob/file reads first for:
|
|
96
|
+
|
|
97
|
+
- **Predicate-level bugs**: "is this window check off by one?", "does this
|
|
98
|
+
regex match branch slugs?" — expression semantics are invisible to a
|
|
99
|
+
graph. Read the code.
|
|
100
|
+
- **Exact string audits**: checking every occurrence of a literal in a
|
|
101
|
+
handful of files, or auditing env var names and CLI flags. Grep is
|
|
102
|
+
deterministic and fast here.
|
|
103
|
+
- **Natural-language discovery**: the graph anchors on symbol names.
|
|
104
|
+
`query` handles typos and partial matches, but if you don't know any
|
|
105
|
+
symbol name yet, a broad grep for a distinctive string is often faster.
|
|
106
|
+
|
|
107
|
+
Rule of thumb: use the graph to identify WHICH files matter (blast radius,
|
|
108
|
+
architecture, cross-module dependencies), then read those files directly
|
|
109
|
+
for exact logic. Graph output includes `file:line` anchors precisely so
|
|
110
|
+
you can jump straight from a node or edge to the source.
|
|
111
|
+
|
|
112
|
+
### Provenance and reference nodes
|
|
113
|
+
|
|
114
|
+
- Every `NODE` line in `query` output carries `src=path:line`, and every
|
|
115
|
+
`EDGE` line ends with `@path:line` — the exact spot the relationship was
|
|
116
|
+
extracted from. `explain` prints `File: path:line` for the node and each
|
|
117
|
+
neighbor.
|
|
118
|
+
- Identifier-shaped string literals (env vars like `PLANE_URL`, snake_case
|
|
119
|
+
keys like `needs_human`, dotted/kebab/slash chains like
|
|
120
|
+
`harness/hr-101-fix-redis-leak`) are indexed as global `reference` nodes
|
|
121
|
+
with `references` edges — so "where is this config key / status value
|
|
122
|
+
used?" is a graph query, not a grep. Query output ends with a
|
|
123
|
+
`# graph built at <timestamp>` line so you can judge freshness.
|
|
124
|
+
|
|
125
|
+
## Command Reference
|
|
126
|
+
|
|
127
|
+
### `astria run <path>`
|
|
128
|
+
|
|
129
|
+
Full pipeline: detect → extract → build → cluster → analyze → report.
|
|
130
|
+
|
|
131
|
+
Creates `.astria/` with `db.sqlite`, `graph.json`, `graph_report.md`.
|
|
132
|
+
|
|
133
|
+
### `astria update <path>`
|
|
134
|
+
|
|
135
|
+
Incremental rebuild — only re-extracts files that changed (SHA-256 detection).
|
|
136
|
+
|
|
137
|
+
Much faster than `run` for existing projects.
|
|
138
|
+
|
|
139
|
+
### `astria query <question> [options]`
|
|
140
|
+
|
|
141
|
+
BFS (default) or DFS graph traversal from nodes matching your question.
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
astria query "authentication" # BFS, depth 2, budget 2000
|
|
145
|
+
astria query "database" --dfs --depth 3 # DFS, deeper
|
|
146
|
+
astria query "error handling" --budget 3000 # more output
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Options:
|
|
150
|
+
- `--dfs` — depth-first search (traces specific paths)
|
|
151
|
+
- `--depth <n>` — traversal depth (default: 2)
|
|
152
|
+
- `--budget <n>` — token budget for output (default: 2000)
|
|
153
|
+
- `--directed` — follow edges only in their stored direction (caller -> callee, importer -> module)
|
|
154
|
+
- `--detail high` — keep only EXTRACTED/DECLARED facts, dropping inferred/semantic edges
|
|
155
|
+
- `--cursor <n>` — continuation token from a previous truncated query
|
|
156
|
+
- `--graph <path>` — project root (default: `.`)
|
|
157
|
+
|
|
158
|
+
### `astria explain <node> [options]`
|
|
159
|
+
|
|
160
|
+
Show a node's details and all its connections.
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
astria explain "UserService"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### `astria path <A> <B> [options]`
|
|
167
|
+
|
|
168
|
+
Find shortest path between two concepts.
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
astria path "AuthService" "Database"
|
|
172
|
+
astria path "AuthService" "Database" --directed # only caller -> callee direction
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### `astria affected <node> [options]`
|
|
176
|
+
|
|
177
|
+
Blast radius — everything impacted by changing a node (reverse reachability over calls/imports/uses).
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
astria affected "UserService" --depth 3
|
|
181
|
+
astria affected "UserService" --relation calls
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `astria map [options]`
|
|
185
|
+
|
|
186
|
+
Aider-style repo map: files ranked by PageRank over the reference graph, with each file's most-connected symbols. Best first command when orienting on a codebase.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
astria map --budget 2000
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Semantic layer (local embeddings)
|
|
193
|
+
|
|
194
|
+
When the graph was built with `run --embed`, `query` automatically merges semantic recall with token matching — conceptual questions with zero string overlap still find their symbols, and `similar_to` edges link related concepts across files. No API key; the model is downloaded once and cached (`ASTRIA_EMBED_CACHE_DIR` overrides the location).
|
|
195
|
+
|
|
196
|
+
### Learning from usage
|
|
197
|
+
|
|
198
|
+
Repeated queries leave a trace: node pairs that keep coming up across distinct questions are promoted to `learned` edges on the next `run`/`update`. The graph gets better connected in exactly the places the codebase is actually explored.
|
|
199
|
+
|
|
200
|
+
### MCP server
|
|
201
|
+
|
|
202
|
+
`astria mcp --graph .` runs an MCP stdio server exposing the graph to AI agents with tools: `query_graph` (supports `cursor` continuation and `detail` tiers), `repo_map`, `explain`, `get_neighbors`, `shortest_path`, `affected`, `god_nodes`, `list_communities`, `graph_stats`.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
### `astria stats [options]`
|
|
206
|
+
|
|
207
|
+
Quick graph health check: node count, edge count, communities, files.
|
|
208
|
+
|
|
209
|
+
### `astria status [options]`
|
|
210
|
+
|
|
211
|
+
Graph staleness check: fresh/stale/very_stale with age in minutes.
|
|
212
|
+
|
|
213
|
+
### `astria export [options]`
|
|
214
|
+
|
|
215
|
+
Export graph to JSON, HTML, GraphML, or Cypher (Neo4j).
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
astria export --format html --out graph.html
|
|
219
|
+
astria export --format graphml --out graph.graphml
|
|
220
|
+
astria export --format cypher --out astria.cypher # idempotent MERGE script for Neo4j
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### `astria wiki [options]`
|
|
224
|
+
|
|
225
|
+
Wikipedia-style markdown wiki of the graph: `index.md` plus one article per community and per god node, cross-linked with relative markdown links. Readable by any agent without the CLI — point an agent at `.astria/wiki/index.md` and it navigates by reading files.
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
astria wiki --graph . # writes .astria/wiki/
|
|
229
|
+
astria wiki --out docs/wiki # e.g. for GitHub
|
|
230
|
+
astria wiki --format obsidian --out my-vault # Obsidian vault + canvas
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Post-Edit Protocol
|
|
234
|
+
|
|
235
|
+
After modifying code files in a session with an active graph:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
astria update .
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Or start a watcher at session beginning:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
astria watch . --debounce 3000
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This keeps the graph current so subsequent queries reflect your changes.
|
|
248
|
+
|
|
249
|
+
## Troubleshooting
|
|
250
|
+
|
|
251
|
+
**"Graph is empty (0 nodes)"**
|
|
252
|
+
- Run `astria run .` to build from scratch
|
|
253
|
+
- Check that the directory has supported file types
|
|
254
|
+
|
|
255
|
+
**"Query returns no results"**
|
|
256
|
+
- Try different search terms (partial matches work)
|
|
257
|
+
- Use broader terms: "auth" instead of "authenticateUserWithOAuth"
|
|
258
|
+
- Check `astria stats` to verify graph has data
|
|
259
|
+
|
|
260
|
+
**"Graph seems stale"**
|
|
261
|
+
- Run `astria update .` for incremental refresh
|
|
262
|
+
- Or `astria run .` for full rebuild
|
|
263
|
+
|
|
264
|
+
**"Status says stale"**
|
|
265
|
+
- The `graph.json` was built more than 30 minutes ago
|
|
266
|
+
- Run `astria update .` before querying
|