@lon-ask/dockit 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -203,38 +203,168 @@ dockit search react "useState" --get-top 3 --json
203
203
 
204
204
  ### Knowledge graph workflow
205
205
 
206
+ When you run `dockit init --code-path src` on a project, Graphify scans the source code with Tree-sitter (AST parser) and produces a dependency graph. Every file, class, function, and import becomes a node with edges tracking imports, calls, and inheritance.
207
+
208
+ The examples below use the **dockit source code itself** (built via `dockit init --path . --code-path apps/server/src`).
209
+
210
+ #### 1. Impact analysis — "What breaks if I change types.ts?"
211
+
206
212
  ```bash
207
- # Find nodes matching a term
208
- dockit graph query my-project "database" --limit 5
213
+ npx @lon-ask/dockit graph gods dockit --limit 5
214
+ ```
209
215
 
210
- # See the most-connected nodes (entry points, god classes)
211
- dockit graph gods my-project
216
+ Output:
217
+ ```
218
+ Name Degree File
219
+ ─────────── ────── ───────────────────────────────
220
+ types.ts 59 server/src/core/domain/types.ts
221
+ index.ts 54 server/src/index.ts
222
+ mcp.ts 49 server/src/mcp.ts
223
+ ```
212
224
 
213
- # Trace how two modules are connected
214
- dockit graph path my-project "app.ts" "database.ts"
225
+ `types.ts` has degree 59 it's imported by nearly every file in the codebase. Changing it means touching more than half the project. To see exactly which files are affected:
215
226
 
216
- # Inspect a node's connections
217
- dockit graph explain my-project "createApp"
227
+ ```bash
228
+ npx @lon-ask/dockit graph explain dockit "types.ts"
218
229
  ```
219
230
 
220
- ---
231
+ This reveals all 59 connections — every use case, repository, search engine, route handler, and source processor that depends on domain types.
221
232
 
222
- ## Supported Documentation Sources
233
+ #### 2. Architecture discovery — "How does the build pipeline work?"
223
234
 
224
- | Type | What it indexes | Remote | Local |
225
- |------|----------------|--------|-------|
226
- | **GitHub Markdown** | All `.md` files in a repo | `repoUrl`, `sourcePath`, `branch` | `localPath` |
227
- | **AsciiDoc** | `.adoc` files via Asciidoctor | `repoUrl`, `sourcePath` | `localPath`, `zipPath` |
228
- | **Antora** | Multi-page Antora documentation sites | `repoUrl` | `localPath`, `zipPath` |
229
- | **ZIP Bundle** | Pre-built HTML in a ZIP archive | `url` | `localPath` |
230
- | **Maven Javadoc** | Javadoc JAR from Maven Central | — | `localJar`, `useMavenCommand` |
231
- | **Source Code** | Knowledge graph via Graphify Tree-sitter AST | `repoUrl`, `sourcePath`, `branch` | `localPath` |
235
+ ```bash
236
+ npx @lon-ask/dockit graph query dockit "Build"
237
+ ```
238
+
239
+ Finds `BuildUseCase.ts`, `BuildResult`, `.build()` method, constructor every node related to builds.
240
+
241
+ ```bash
242
+ npx @lon-ask/dockit graph explain dockit "BuildUseCase.ts"
243
+ ```
244
+
245
+ Shows all 24 connections: the 7 port interfaces it depends on (`ISearchEngine`, `ISourceProcessor`, `IEntryRepository`, etc.), the 4 repositories it calls, the search engines it updates. An LLM can understand the full build architecture in one command instead of reading through hundreds of lines of imports.
246
+
247
+ #### 3. Architecture validation — "Does UI code ever import server code?"
248
+
249
+ ```bash
250
+ npx @lon-ask/dockit graph path dockit "EntryDetail.tsx" "BuildUseCase.ts"
251
+ # → No path found
252
+ ```
253
+
254
+ The graph confirms clean separation: client React components never import server core modules directly. The only bridge is the API client layer:
255
+
256
+ ```bash
257
+ npx @lon-ask/dockit graph query dockit "client.ts"
258
+ # → Finds the HTTP API client — the sole communication channel between UI and server
259
+ ```
260
+
261
+ #### 4. Finding all code that touches a feature — "Where is source-code processing handled?"
262
+
263
+ ```bash
264
+ npx @lon-ask/dockit graph query dockit "SourceCodeSourceProcessor"
265
+ # → Shows the processor class plus everything that references it
266
+
267
+ npx @lon-ask/dockit graph path dockit "SourceCodeSourceProcessor" "graph.json"
268
+ # → Traces the full path from processor to graph output file
269
+ ```
270
+
271
+ #### 5. Entry points and god classes — "What are the most critical modules?"
272
+
273
+ ```bash
274
+ npx @lon-ask/dockit graph gods dockit --limit 10 --json
275
+ ```
276
+
277
+ Returns ranked by degree (total connections). The top nodes are the ones to be most careful with — they're the architectural keystones. `types.ts` (59), `index.ts` (54), `mcp.ts` (49), `BuildUseCase.ts` (24), `configLoader.ts` (22), `entries.ts` (18).
278
+
279
+ #### 6. Cross-boundary tracing — "How does the MCP server reach the database?"
280
+
281
+ ```bash
282
+ npx @lon-ask/dockit graph path dockit "mcp.ts" "connection.ts"
283
+ ```
232
284
 
233
- ### Source code knowledge graphs
285
+ Traces: `mcp.ts` `getDb()` → imports from `connection.ts`. Shows exactly which function calls form the chain.
234
286
 
235
- The `source-code` source type runs [Graphify](https://github.com/safishamsi/graphify) which parses your code with Tree-sitter (AST) and produces a `graph.json` containing nodes (classes, functions, files) and edges (imports, calls, inherits). No LLM required — pure static analysis. Supports TypeScript, JavaScript, Python, Java, Go, Rust, C++, and 10 more languages.
287
+ #### Why this matters for LLMs
236
288
 
237
- Add `graphifyEnabled: true` to any doc source to also generate a graph alongside the docs:
289
+ Traditional code search (grep) finds strings but not structure. Graphify's AST-based graph lets an LLM:
290
+
291
+ | Question | Grep approach | Graph approach |
292
+ |----------|--------------|----------------|
293
+ | "What impacts does changing types.ts have?" | Search 59 files manually | `graph explain` shows all 59 connections instantly |
294
+ | "Does the UI import server code?" | Read every import line | `graph path` confirms no path exists |
295
+ | "What's the entry point of the build system?" | Guess based on naming conventions | `graph gods` ranks by degree — `BuildUseCase.ts` at #4 |
296
+ | "How does data flow from MCP to SQLite?" | Trace imports across 12 files | `graph path` shows exact chain in 1 command |
297
+
298
+ ### Real LLM use case: adding a new source type to dockit
299
+
300
+ Here's how an LLM uses graph search to understand the codebase before implementing a feature — end to end, step by step.
301
+
302
+ **Task**: "Add support for a new documentation source type called 'wiki'."
303
+
304
+ **Step 1: Find existing source type references** — understand the pattern:
305
+ ```bash
306
+ npx @lon-ask/dockit graph query dockit "SourceCodeSourceProcessor"
307
+ ```
308
+ Returns `SourceCodeSourceProcessor.ts` — this is the template to follow for a new source processor.
309
+
310
+ **Step 2: Trace the dependency chain** — where does the processor fit?
311
+ ```bash
312
+ npx @lon-ask/dockit graph explain dockit "SourceCodeSourceProcessor.ts"
313
+ ```
314
+ Shows the processor is used by: `BuildUseCase.ts`, `mcp.ts`, `index.ts`. The LLM now knows to update these 3 files when adding a new processor.
315
+
316
+ **Step 3: Find the registration point** — where are processors registered?
317
+ ```bash
318
+ npx @lon-ask/dockit graph gods dockit
319
+ ```
320
+ `types.ts` is the top god node (degree 59). The LLM knows to check here next.
321
+
322
+ ```bash
323
+ npx @lon-ask/dockit graph query dockit "types"
324
+ ```
325
+ Returns `types.ts` in `core/domain/` — this is where `SourceType` is defined. The LLM finds the union type that needs a new `'wiki'` variant.
326
+
327
+ **Step 4: Trace the full modification path** — from entry point to database:
328
+ ```bash
329
+ npx @lon-ask/dockit graph path dockit "mcp.ts" "connection.ts"
330
+ ```
331
+ Shows: `mcp.ts` → `getDb()` → `connection.ts`. The LLM now knows how the system starts up and where the DB gets initialized.
332
+
333
+ **Step 5: Verify no duplicates** — is "wiki" already handled?
334
+ ```bash
335
+ npx @lon-ask/dockit graph query dockit "wiki"
336
+ ```
337
+ Returns empty — confirmed no existing wiki handling. Safe to proceed.
338
+
339
+ **Step 6: Before coding, understand the build pipeline**:
340
+ ```bash
341
+ npx @lon-ask/dockit graph explain dockit "BuildUseCase.ts"
342
+ ```
343
+ Shows 24 connections — the LLM now understands which interfaces (`ISourceProcessor`) and repositories get called during a build. It knows exactly which files to read and which interfaces to implement.
344
+
345
+ **Result**: The LLM has a complete mental model before writing a single line of code:
346
+ - Files to modify: `types.ts` (add type), `SourceCodeSourceProcessor.ts` (use as template), `BuildUseCase.ts`, `mcp.ts`, `index.ts` (register)
347
+ - Interfaces to implement: `ISourceProcessor`
348
+ - Pattern to follow: `SourceCodeSourceProcessor.ts`
349
+ - Build pipeline behavior: understands how processors get invoked
350
+
351
+ This turns what would be 20+ minutes of grepping and reading imports into 6 graph commands executed in under 30 seconds.
352
+
353
+ ### What Graphify supports
354
+
355
+ | Language | Status |
356
+ |----------|--------|
357
+ | TypeScript / JavaScript | ✅ Full (imports, calls, classes, functions) |
358
+ | Python | ✅ Full |
359
+ | Java | ✅ Full |
360
+ | Go | ✅ Full |
361
+ | Rust | ✅ Full |
362
+ | C / C++ | ✅ Full |
363
+ | Ruby, PHP, C#, Swift, Kotlin, Scala, Lua, Elixir | ✅ AST parsing (import resolution varies) |
364
+
365
+ ### Enabling graphs on doc sources
366
+
367
+ Add `graphifyEnabled: true` to any doc source (AsciiDoc, Markdown, Antora) that lives in a repo with source code:
238
368
 
239
369
  ```yaml
240
370
  sources:
@@ -246,6 +376,21 @@ sources:
246
376
  graphifySourcePath: "src" # where source code lives
247
377
  ```
248
378
 
379
+ This generates a graph alongside the document index during build. The search engine then boosts results that match graph node names (e.g., searching "BuildUseCase" ranks it higher because it's a known node).
380
+
381
+ ---
382
+
383
+ ## Supported Documentation Sources
384
+
385
+ | Type | What it indexes | Remote | Local |
386
+ |------|----------------|--------|-------|
387
+ | **GitHub Markdown** | All `.md` files in a repo | `repoUrl`, `sourcePath`, `branch` | `localPath` |
388
+ | **AsciiDoc** | `.adoc` files via Asciidoctor | `repoUrl`, `sourcePath` | `localPath`, `zipPath` |
389
+ | **Antora** | Multi-page Antora documentation sites | `repoUrl` | `localPath`, `zipPath` |
390
+ | **ZIP Bundle** | Pre-built HTML in a ZIP archive | `url` | `localPath` |
391
+ | **Maven Javadoc** | Javadoc JAR from Maven Central | — | `localJar`, `useMavenCommand` |
392
+ | **Source Code** | Knowledge graph via Graphify Tree-sitter AST | `repoUrl`, `sourcePath`, `branch` | `localPath` |
393
+
249
394
  ---
250
395
 
251
396
  ## Search Engine
package/SKILL.md CHANGED
@@ -8,6 +8,29 @@ metadata:
8
8
  workflow: documentation
9
9
  ---
10
10
 
11
+ # ⚠️ CRITICAL: USE DOCKIT, NOT GREP
12
+
13
+ **When a dockit entry exists for the codebase, dockit's graph and search tools MUST be used for ALL structural queries. Do NOT use grep, rg, find, glob, or any text search tool for questions about code imports, dependencies, structure, architecture, or relationships.**
14
+
15
+ Dockit's knowledge graph (Graphify Tree-sitter AST) has already parsed every import, call, and inheritance edge. Using grep for structural questions is slower AND less accurate. You are discarding pre-parsed structural data to re-parse text — this is wasteful and produces worse results.
16
+
17
+ | Question | ✅ Use dockit | ❌ Do NOT use |
18
+ |----------|------------|-------------|
19
+ | "What files import X?" | `dockit graph query <entry> "X"` | `grep`, `rg`, `glob` |
20
+ | "What does X depend on?" | `dockit graph explain <entry> "X"` | Reading files, `grep "import"` |
21
+ | "Does UI import server code?" | `dockit graph path <entry> "A" "B"` | Manually checking imports |
22
+ | "Most critical modules?" | `dockit graph gods <entry>` | Guessing, `ls`, `wc -l` |
23
+ | "How are A and B connected?" | `dockit graph path <entry> "A" "B"` | Tracing imports across files |
24
+ | "Docs for X?" | `dockit search <entry> "X"` | `grep "X"` on docs |
25
+ | "Find all files about X" | `dockit search <entry> "X"` or `dockit graph query <entry> "X"` | `grep -r "X"` |
26
+
27
+ **Only use grep / glob when:**
28
+ 1. No dockit entry exists for the target codebase (not yet built)
29
+ 2. You have already found the right files via dockit and now need to read their content
30
+ 3. The question is about raw text patterns, not code structure
31
+
32
+ **If a source-code entry is built (status = ready): graph tools get priority. Every time. No exceptions.**
33
+
11
34
  ## What dockit does
12
35
 
13
36
  Dockit is a local documentation hub. It indexes documentation from multiple sources (GitHub Markdown, AsciiDoc, Antora, Maven Javadoc, ZIP archives) and builds source code knowledge graphs (Tree-sitter AST via Graphify). It provides hybrid TF-IDF + vector semantic search across all indexed content.
@@ -36,69 +59,6 @@ Use when you need:
36
59
  - Source code structure analysis (imports, calls, inheritance graphs)
37
60
  - To find which files/modules a function touches in a codebase
38
61
 
39
- ## Core Workflow
40
-
41
- ### Step 1: Discover available documentation
42
-
43
- ```bash
44
- dockit list
45
- # or
46
- npx @lon-ask/dockit list
47
- ```
48
-
49
- ### Step 2: Global search (find the right entry)
50
-
51
- ```bash
52
- dockit search "cache"
53
- # Returns top result per built entry
54
- ```
55
-
56
- ### Step 3: Scoped search with full content
57
-
58
- ```bash
59
- dockit search quarkus "configure cache" --get-top 3
60
- ```
61
-
62
- The `--get-top` flag fetches full document text for the top N results. This is the primary command for LLMs — it combines search + retrieval in one invocation.
63
-
64
- ### Step 4: Knowledge graph queries (source-code entries)
65
-
66
- For entries with `source-code` sources:
67
-
68
- ```bash
69
- dockit graph query my-project "database" --limit 10 # find nodes by name/file/type
70
- dockit graph gods my-project # most-connected nodes
71
- dockit graph path my-project "app.ts" "database.ts" # dependency path
72
- dockit graph explain my-project "createApp" # node details + connections
73
- ```
74
-
75
- ## CLI Reference
76
-
77
- | Command | Purpose |
78
- |---------|---------|
79
- | `dockit list` | List all configured entries |
80
- | `dockit search [<entry>] <query>` | Search docs (scoped or global) |
81
- | `dockit search [<entry>] <query> --get-top [N]` | Search + full content for top N |
82
- | `dockit get <entry> <path>` | Fetch specific document by path |
83
- | `dockit build <entry>` | Build/rebuild documentation |
84
- | `dockit status <entry>` | Check build status |
85
- | `dockit init --path <dir> [--code-path <sub>]` | Index a local project |
86
- | `dockit graph query <entry> <query>` | Search graph nodes |
87
- | `dockit graph path <entry> <from> <to>` | Dependency path between nodes |
88
- | `dockit graph gods <entry>` | Highest-degree (most connected) nodes |
89
- | `dockit graph explain <entry> <node>` | Node details with edges |
90
-
91
- ## Query Refinement
92
-
93
- Strip conversational filler. Keep only technical keywords:
94
-
95
- | User question | Good query |
96
- |---------------|------------|
97
- | "How do I create a custom hook in React?" | `"create custom hook"` |
98
- | "What's the Quarkus caching configuration?" | `"caching configuration"` |
99
- | "How does the auth middleware work?" | `"auth middleware"` |
100
- | "Find all files that import database.ts" | `graph query my-project "database.ts"` |
101
-
102
62
  ## Entry Types and Behavior
103
63
 
104
64
  | Entry has | `dockit search` | `dockit graph` |