structx 1.0.0 → 2.1.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 (62) hide show
  1. package/README.md +72 -0
  2. package/dist/cli.js +260 -211
  3. package/dist/cli.js.map +1 -1
  4. package/dist/db/connection.js +28 -1
  5. package/dist/db/connection.js.map +1 -1
  6. package/dist/db/queries.d.ts +144 -0
  7. package/dist/db/queries.d.ts.map +1 -1
  8. package/dist/db/queries.js +282 -6
  9. package/dist/db/queries.js.map +1 -1
  10. package/dist/db/schema.sql +59 -0
  11. package/dist/ingest/constant-extractor.d.ts +11 -0
  12. package/dist/ingest/constant-extractor.d.ts.map +1 -0
  13. package/dist/ingest/constant-extractor.js +38 -0
  14. package/dist/ingest/constant-extractor.js.map +1 -0
  15. package/dist/ingest/file-metadata.d.ts +13 -0
  16. package/dist/ingest/file-metadata.d.ts.map +1 -0
  17. package/dist/ingest/file-metadata.js +55 -0
  18. package/dist/ingest/file-metadata.js.map +1 -0
  19. package/dist/ingest/ingester.d.ts +15 -0
  20. package/dist/ingest/ingester.d.ts.map +1 -0
  21. package/dist/ingest/ingester.js +217 -0
  22. package/dist/ingest/ingester.js.map +1 -0
  23. package/dist/ingest/parser.d.ts +12 -0
  24. package/dist/ingest/parser.d.ts.map +1 -1
  25. package/dist/ingest/parser.js +48 -0
  26. package/dist/ingest/parser.js.map +1 -1
  27. package/dist/ingest/route-extractor.d.ts +12 -0
  28. package/dist/ingest/route-extractor.d.ts.map +1 -0
  29. package/dist/ingest/route-extractor.js +64 -0
  30. package/dist/ingest/route-extractor.js.map +1 -0
  31. package/dist/ingest/type-extractor.d.ts +11 -0
  32. package/dist/ingest/type-extractor.d.ts.map +1 -0
  33. package/dist/ingest/type-extractor.js +47 -0
  34. package/dist/ingest/type-extractor.js.map +1 -0
  35. package/dist/instructions/claude.md +54 -25
  36. package/dist/instructions/codex.md +70 -0
  37. package/dist/instructions/copilot.md +57 -26
  38. package/dist/instructions/cursor.md +54 -25
  39. package/dist/instructions/generic.md +54 -25
  40. package/dist/query/answerer.d.ts.map +1 -1
  41. package/dist/query/answerer.js +6 -2
  42. package/dist/query/answerer.js.map +1 -1
  43. package/dist/query/classifier.d.ts +6 -1
  44. package/dist/query/classifier.d.ts.map +1 -1
  45. package/dist/query/classifier.js +22 -2
  46. package/dist/query/classifier.js.map +1 -1
  47. package/dist/query/context-builder.d.ts.map +1 -1
  48. package/dist/query/context-builder.js +152 -6
  49. package/dist/query/context-builder.js.map +1 -1
  50. package/dist/query/retriever.d.ts +44 -0
  51. package/dist/query/retriever.d.ts.map +1 -1
  52. package/dist/query/retriever.js +211 -14
  53. package/dist/query/retriever.js.map +1 -1
  54. package/dist/semantic/analyzer.d.ts +10 -0
  55. package/dist/semantic/analyzer.d.ts.map +1 -1
  56. package/dist/semantic/analyzer.js +147 -1
  57. package/dist/semantic/analyzer.js.map +1 -1
  58. package/dist/semantic/prompt.d.ts +21 -0
  59. package/dist/semantic/prompt.d.ts.map +1 -1
  60. package/dist/semantic/prompt.js +63 -0
  61. package/dist/semantic/prompt.js.map +1 -1
  62. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ # StructX — Code Intelligence Graph (MANDATORY)
2
+
3
+ This project uses **StructX**, a graph-powered code intelligence tool for TypeScript.
4
+ StructX maintains a knowledge graph of the codebase including functions, types, routes,
5
+ constants, and file summaries. **You MUST use StructX as your primary source of codebase
6
+ understanding. Do NOT read raw source files to learn about the codebase.**
7
+
8
+ ## Mandatory Workflow
9
+
10
+ ### Step 1: Initialize (ALWAYS do this first)
11
+ Run `npx structx status` to check the graph state.
12
+ - If it says "not initialized", run `npx structx setup .`
13
+ - If Functions/Types/Routes counts are 0, run `npx structx setup .`
14
+ - **Do NOT proceed to any code task until StructX is initialized and populated.**
15
+
16
+ ### Step 2: Understand the codebase via StructX (NEVER skip this)
17
+ Before writing ANY code, you MUST query StructX to understand the codebase:
18
+ ```
19
+ npx structx overview --repo .
20
+ npx structx ask "what types and interfaces exist?" --repo .
21
+ npx structx ask "what routes/endpoints exist?" --repo .
22
+ npx structx ask "how does <relevant feature> work?" --repo .
23
+ ```
24
+ **You are FORBIDDEN from reading .ts source files to understand the codebase architecture,
25
+ discover what functions exist, learn about types, or understand how features work.
26
+ StructX provides all of this. Use it.**
27
+
28
+ ### Step 3: Read source files ONLY for editing
29
+ You may ONLY use raw file reads when you have ALREADY queried StructX and now need to
30
+ see the exact code at a specific location to make an edit. The workflow is:
31
+ 1. Ask StructX what exists and where it is
32
+ 2. StructX tells you the file path and line numbers
33
+ 3. THEN read that specific file to make your edit
34
+
35
+ **Reading source files to "explore" or "understand" the codebase is PROHIBITED.
36
+ That is what StructX is for.**
37
+
38
+ ### Step 4: After making changes
39
+ After editing any TypeScript files:
40
+ ```
41
+ npx structx ingest .
42
+ npx structx analyze . --yes
43
+ ```
44
+
45
+ ### Step 5: Impact analysis before modifying existing code
46
+ Before changing any existing function, type, or route:
47
+ ```
48
+ npx structx ask "what breaks if I change <name>?" --repo .
49
+ ```
50
+
51
+ ## Available Commands
52
+
53
+ | Command | Description |
54
+ |---------|-------------|
55
+ | `npx structx status` | Check graph state — ALWAYS run first |
56
+ | `npx structx setup .` | Full bootstrap (init + ingest + analyze) |
57
+ | `npx structx overview --repo .` | Full codebase summary in one shot |
58
+ | `npx structx ask "<question>" --repo .` | Query the knowledge graph |
59
+ | `npx structx ingest .` | Re-parse codebase after changes |
60
+ | `npx structx analyze . --yes` | Run semantic analysis on new/changed entities |
61
+
62
+ ## Rules Summary
63
+
64
+ 1. **ALWAYS** run `structx status` at session start
65
+ 2. **ALWAYS** run `structx setup .` if not initialized
66
+ 3. **ALWAYS** use `structx ask` or `structx overview` to understand the codebase
67
+ 4. **NEVER** read .ts files to explore/understand architecture — use StructX
68
+ 5. **ONLY** read .ts files when you know exactly what file+line to edit (from StructX output)
69
+ 6. **ALWAYS** run `structx ingest .` after making code changes
70
+ 7. **ALWAYS** run impact analysis before modifying existing functions
@@ -1,39 +1,70 @@
1
- # StructX — Code Intelligence Graph
1
+ # StructX — Code Intelligence Graph (MANDATORY)
2
2
 
3
3
  This project uses **StructX**, a graph-powered code intelligence tool for TypeScript.
4
- StructX maintains a function-level knowledge graph of the codebase that you should use
5
- instead of reading raw source files when answering code questions.
4
+ StructX maintains a knowledge graph of the codebase including functions, types, routes,
5
+ constants, and file summaries. **You MUST use StructX as your primary source of codebase
6
+ understanding. Do NOT read raw source files to learn about the codebase.**
6
7
 
7
- ## Rules
8
+ ## Mandatory Workflow
8
9
 
9
- 1. **On session start:** Run `npx structx status` to check if the graph is initialized.
10
- If not initialized, run `npx structx setup .` to bootstrap (init + ingest + analyze).
10
+ ### Step 1: Initialize (ALWAYS do this first)
11
+ Run `npx structx status` to check the graph state.
12
+ - If it says "not initialized", run `npx structx setup .`
13
+ - If Functions/Types/Routes counts are 0, run `npx structx setup .`
14
+ - **Do NOT proceed to any code task until StructX is initialized and populated.**
11
15
 
12
- 2. **Before answering code questions:** Run `npx structx ask "your question" --repo .`
13
- instead of reading raw files. The graph provides function signatures, purposes,
14
- relationships, and semantic metadata that raw file reads miss.
16
+ ### Step 2: Understand the codebase via StructX (NEVER skip this)
17
+ Before writing ANY code, you MUST query StructX to understand the codebase:
18
+ ```
19
+ npx structx overview --repo .
20
+ npx structx ask "what types and interfaces exist?" --repo .
21
+ npx structx ask "what routes/endpoints exist?" --repo .
22
+ npx structx ask "how does <relevant feature> work?" --repo .
23
+ ```
24
+ **You are FORBIDDEN from reading .ts source files to understand the codebase architecture,
25
+ discover what functions exist, learn about types, or understand how features work.
26
+ StructX provides all of this. Use it.**
15
27
 
16
- 3. **After making code changes:** Run `npx structx ingest .` to update the function graph
17
- with your changes.
28
+ ### Step 3: Read source files ONLY for editing
29
+ You may ONLY use raw file reads when you have ALREADY queried StructX and now need to
30
+ see the exact code at a specific location to make an edit. The workflow is:
31
+ 1. Ask StructX what exists and where it is
32
+ 2. StructX tells you the file path and line numbers
33
+ 3. THEN read that specific file to make your edit
18
34
 
19
- 4. **After ingestion queues new functions:** Run `npx structx analyze . --yes` to enrich
20
- newly discovered or changed functions with semantic metadata.
35
+ **Reading source files to "explore" or "understand" the codebase is PROHIBITED.
36
+ That is what StructX is for.**
21
37
 
22
- 5. **For impact analysis:** Before modifying a function, run
23
- `npx structx ask "what breaks if I change <functionName>" --repo .`
24
- to understand downstream effects.
38
+ ### Step 4: After making changes
39
+ After editing any TypeScript files:
40
+ ```
41
+ npx structx ingest .
42
+ npx structx analyze . --yes
43
+ ```
44
+
45
+ ### Step 5: Impact analysis before modifying existing code
46
+ Before changing any existing function, type, or route:
47
+ ```
48
+ npx structx ask "what breaks if I change <name>?" --repo .
49
+ ```
25
50
 
26
51
  ## Available Commands
27
52
 
28
- - `npx structx status` — Check if graph is initialized and view stats
29
- - `npx structx setup .` — One-step bootstrap (init + ingest + analyze)
30
- - `npx structx ingest .`Re-parse codebase after changes
31
- - `npx structx analyze . --yes` Run semantic analysis on new/changed functions
32
- - `npx structx ask "question" --repo .` Query the function graph
53
+ | Command | Description |
54
+ |---------|-------------|
55
+ | `npx structx status` | Check graph state ALWAYS run first |
56
+ | `npx structx setup .` | Full bootstrap (init + ingest + analyze) |
57
+ | `npx structx overview --repo .` | Full codebase summary in one shot |
58
+ | `npx structx ask "<question>" --repo .` | Query the knowledge graph |
59
+ | `npx structx ingest .` | Re-parse codebase after changes |
60
+ | `npx structx analyze . --yes` | Run semantic analysis on new/changed entities |
33
61
 
34
- ## When to Use StructX vs Raw File Reads
62
+ ## Rules Summary
35
63
 
36
- - **Use StructX** for: understanding function purposes, finding callers/callees,
37
- impact analysis, discovering related functions, understanding code architecture.
38
- - **Use raw file reads** for: viewing exact implementation details, making edits,
39
- reading config files, non-TypeScript files.
64
+ 1. **ALWAYS** run `structx status` at session start
65
+ 2. **ALWAYS** run `structx setup .` if not initialized
66
+ 3. **ALWAYS** use `structx ask` or `structx overview` to understand the codebase
67
+ 4. **NEVER** read .ts files to explore/understand architecture — use StructX
68
+ 5. **ONLY** read .ts files when you know exactly what file+line to edit (from StructX output)
69
+ 6. **ALWAYS** run `structx ingest .` after making code changes
70
+ 7. **ALWAYS** run impact analysis before modifying existing functions
@@ -1,39 +1,68 @@
1
- # StructX — Code Intelligence Graph
1
+ # StructX — Code Intelligence Graph (MANDATORY)
2
2
 
3
3
  This project uses **StructX**, a graph-powered code intelligence tool for TypeScript.
4
- StructX maintains a function-level knowledge graph of the codebase that you should use
5
- instead of reading raw source files when answering code questions.
4
+ StructX maintains a knowledge graph of the codebase including functions, types, routes,
5
+ constants, and file summaries. **You MUST use StructX as your primary source of codebase
6
+ understanding. Do NOT read raw source files to learn about the codebase.**
6
7
 
7
- ## Rules
8
+ ## Mandatory Workflow
8
9
 
9
- 1. **On session start:** Run `npx structx status` to check if the graph is initialized.
10
- If not initialized, run `npx structx setup .` to bootstrap (init + ingest + analyze).
10
+ ### Step 1: Initialize (ALWAYS do this first)
11
+ Run `npx structx status` to check the graph state.
12
+ - If it says "not initialized", run `npx structx setup .`
13
+ - If Functions/Types/Routes counts are 0, run `npx structx setup .`
14
+ - **Do NOT proceed to any code task until StructX is initialized and populated.**
11
15
 
12
- 2. **Before answering code questions:** Run `npx structx ask "your question" --repo .`
13
- instead of reading raw files. The graph provides function signatures, purposes,
14
- relationships, and semantic metadata that raw file reads miss.
16
+ ### Step 2: Understand the codebase via StructX (NEVER skip this)
17
+ Before writing ANY code, you MUST query StructX to understand the codebase:
18
+ ```
19
+ npx structx overview --repo .
20
+ npx structx ask "what types and interfaces exist?" --repo .
21
+ npx structx ask "what routes/endpoints exist?" --repo .
22
+ npx structx ask "how does <relevant feature> work?" --repo .
23
+ ```
24
+ **You are FORBIDDEN from reading .ts source files to understand the codebase architecture,
25
+ discover what functions exist, learn about types, or understand how features work.
26
+ StructX provides all of this. Use it.**
15
27
 
16
- 3. **After making code changes:** Run `npx structx ingest .` to update the function graph
17
- with your changes.
28
+ ### Step 3: Read source files ONLY for editing
29
+ You may ONLY use raw file reads when you have ALREADY queried StructX and now need to
30
+ see the exact code at a specific location to make an edit. The workflow is:
31
+ 1. Ask StructX what exists and where it is
32
+ 2. StructX tells you the file path and line numbers
33
+ 3. THEN read that specific file to make your edit
18
34
 
19
- 4. **After ingestion queues new functions:** Run `npx structx analyze . --yes` to enrich
20
- newly discovered or changed functions with semantic metadata.
35
+ **Reading source files to "explore" or "understand" the codebase is PROHIBITED.
36
+ That is what StructX is for.**
21
37
 
22
- 5. **For impact analysis:** Before modifying a function, run
23
- `npx structx ask "what breaks if I change <functionName>" --repo .`
24
- to understand downstream effects.
38
+ ### Step 4: After making changes
39
+ After editing any TypeScript files:
40
+ ```
41
+ npx structx ingest .
42
+ npx structx analyze . --yes
43
+ ```
44
+
45
+ ### Step 5: Impact analysis before modifying existing code
46
+ Before changing any existing function, type, or route:
47
+ ```
48
+ npx structx ask "what breaks if I change <name>?" --repo .
49
+ ```
25
50
 
26
51
  ## Available Commands
27
52
 
28
- - `npx structx status` — Check if graph is initialized and view stats
29
- - `npx structx setup .` — One-step bootstrap (init + ingest + analyze)
53
+ - `npx structx status` — Check graph state ALWAYS run first
54
+ - `npx structx setup .` — Full bootstrap (init + ingest + analyze)
55
+ - `npx structx overview --repo .` — Full codebase summary in one shot
56
+ - `npx structx ask "<question>" --repo .` — Query the knowledge graph
30
57
  - `npx structx ingest .` — Re-parse codebase after changes
31
- - `npx structx analyze . --yes` — Run semantic analysis on new/changed functions
32
- - `npx structx ask "question" --repo .` — Query the function graph
58
+ - `npx structx analyze . --yes` — Run semantic analysis on new/changed entities
33
59
 
34
- ## When to Use StructX vs Raw File Reads
60
+ ## Rules Summary
35
61
 
36
- - **Use StructX** for: understanding function purposes, finding callers/callees,
37
- impact analysis, discovering related functions, understanding code architecture.
38
- - **Use raw file reads** for: viewing exact implementation details, making edits,
39
- reading config files, non-TypeScript files.
62
+ 1. **ALWAYS** run `structx status` at session start
63
+ 2. **ALWAYS** run `structx setup .` if not initialized
64
+ 3. **ALWAYS** use `structx ask` or `structx overview` to understand the codebase
65
+ 4. **NEVER** read .ts files to explore/understand architecture — use StructX
66
+ 5. **ONLY** read .ts files when you know exactly what file+line to edit (from StructX output)
67
+ 6. **ALWAYS** run `structx ingest .` after making code changes
68
+ 7. **ALWAYS** run impact analysis before modifying existing functions
@@ -1,41 +1,70 @@
1
- # StructX — AI Agent Instructions
1
+ # StructX — Code Intelligence Graph (MANDATORY)
2
2
 
3
3
  This project uses **StructX**, a graph-powered code intelligence tool for TypeScript.
4
- StructX maintains a function-level knowledge graph of the codebase that you should use
5
- instead of reading raw source files when answering code questions.
4
+ StructX maintains a knowledge graph of the codebase including functions, types, routes,
5
+ constants, and file summaries. **You MUST use StructX as your primary source of codebase
6
+ understanding. Do NOT read raw source files to learn about the codebase.**
6
7
 
7
- ## Rules
8
+ ## Mandatory Workflow
8
9
 
9
- 1. **On session start:** Run `npx structx status` to check if the graph is initialized.
10
- If not initialized, run `npx structx setup .` to bootstrap (init + ingest + analyze).
10
+ ### Step 1: Initialize (ALWAYS do this first)
11
+ Run `npx structx status` to check the graph state.
12
+ - If it says "not initialized", run `npx structx setup .`
13
+ - If Functions/Types/Routes counts are 0, run `npx structx setup .`
14
+ - **Do NOT proceed to any code task until StructX is initialized and populated.**
11
15
 
12
- 2. **Before answering code questions:** Run `npx structx ask "your question" --repo .`
13
- instead of reading raw files. The graph provides function signatures, purposes,
14
- relationships, and semantic metadata that raw file reads miss.
16
+ ### Step 2: Understand the codebase via StructX (NEVER skip this)
17
+ Before writing ANY code, you MUST query StructX to understand the codebase:
18
+ ```
19
+ npx structx overview --repo .
20
+ npx structx ask "what types and interfaces exist?" --repo .
21
+ npx structx ask "what routes/endpoints exist?" --repo .
22
+ npx structx ask "how does <relevant feature> work?" --repo .
23
+ ```
24
+ **You are FORBIDDEN from reading .ts source files to understand the codebase architecture,
25
+ discover what functions exist, learn about types, or understand how features work.
26
+ StructX provides all of this. Use it.**
15
27
 
16
- 3. **After making code changes:** Run `npx structx ingest .` to update the function graph
17
- with your changes.
28
+ ### Step 3: Read source files ONLY for editing
29
+ You may ONLY use raw file reads when you have ALREADY queried StructX and now need to
30
+ see the exact code at a specific location to make an edit. The workflow is:
31
+ 1. Ask StructX what exists and where it is
32
+ 2. StructX tells you the file path and line numbers
33
+ 3. THEN read that specific file to make your edit
18
34
 
19
- 4. **After ingestion queues new functions:** Run `npx structx analyze . --yes` to enrich
20
- newly discovered or changed functions with semantic metadata.
35
+ **Reading source files to "explore" or "understand" the codebase is PROHIBITED.
36
+ That is what StructX is for.**
21
37
 
22
- 5. **For impact analysis:** Before modifying a function, run
23
- `npx structx ask "what breaks if I change <functionName>" --repo .`
24
- to understand downstream effects.
38
+ ### Step 4: After making changes
39
+ After editing any TypeScript files:
40
+ ```
41
+ npx structx ingest .
42
+ npx structx analyze . --yes
43
+ ```
44
+
45
+ ### Step 5: Impact analysis before modifying existing code
46
+ Before changing any existing function, type, or route:
47
+ ```
48
+ npx structx ask "what breaks if I change <name>?" --repo .
49
+ ```
25
50
 
26
51
  ## Available Commands
27
52
 
28
53
  | Command | Description |
29
54
  |---------|-------------|
30
- | `npx structx status` | Check if graph is initialized and view stats |
31
- | `npx structx setup .` | One-step bootstrap (init + ingest + analyze) |
55
+ | `npx structx status` | Check graph state ALWAYS run first |
56
+ | `npx structx setup .` | Full bootstrap (init + ingest + analyze) |
57
+ | `npx structx overview --repo .` | Full codebase summary in one shot |
58
+ | `npx structx ask "<question>" --repo .` | Query the knowledge graph |
32
59
  | `npx structx ingest .` | Re-parse codebase after changes |
33
- | `npx structx analyze . --yes` | Run semantic analysis on new/changed functions |
34
- | `npx structx ask "question" --repo .` | Query the function graph |
60
+ | `npx structx analyze . --yes` | Run semantic analysis on new/changed entities |
35
61
 
36
- ## When to Use StructX vs Raw File Reads
62
+ ## Rules Summary
37
63
 
38
- - **Use StructX** for: understanding function purposes, finding callers/callees,
39
- impact analysis, discovering related functions, understanding code architecture.
40
- - **Use raw file reads** for: viewing exact implementation details, making edits,
41
- reading config files, non-TypeScript files.
64
+ 1. **ALWAYS** run `structx status` at session start
65
+ 2. **ALWAYS** run `structx setup .` if not initialized
66
+ 3. **ALWAYS** use `structx ask` or `structx overview` to understand the codebase
67
+ 4. **NEVER** read .ts files to explore/understand architecture — use StructX
68
+ 5. **ONLY** read .ts files when you know exactly what file+line to edit (from StructX output)
69
+ 6. **ALWAYS** run `structx ingest .` after making code changes
70
+ 7. **ALWAYS** run impact analysis before modifying existing functions
@@ -1 +1 @@
1
- {"version":3,"file":"answerer.d.ts","sourceRoot":"","sources":["../../src/query/answerer.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAWD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC,CAiCvB"}
1
+ {"version":3,"file":"answerer.d.ts","sourceRoot":"","sources":["../../src/query/answerer.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAeD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,YAAY,CAAC,CAiCvB"}
@@ -8,12 +8,16 @@ const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
8
8
  const tokens_1 = require("../utils/tokens");
9
9
  const SYSTEM_PROMPT = `You are a code intelligence assistant. You answer developer questions about a TypeScript codebase using structured context retrieved from a code graph database.
10
10
 
11
+ The context may include functions, types (interfaces/type aliases/enums), HTTP routes/endpoints, file summaries, and constants extracted from the codebase.
12
+
11
13
  Rules:
12
14
  - Answer based ONLY on the provided context
13
15
  - Be concise and specific
14
- - Reference function names and file locations when relevant
16
+ - Reference function names, type names, route paths, and file locations when relevant
15
17
  - If the context doesn't contain enough information, say so clearly
16
- - Do not make up information not present in the context`;
18
+ - Do not make up information not present in the context
19
+ - When describing routes, include the HTTP method, path, and handler details
20
+ - When describing types, include the full definition when available`;
17
21
  async function generateAnswer(question, context, model, apiKey) {
18
22
  const client = new sdk_1.default({ apiKey });
19
23
  const startTime = Date.now();
@@ -1 +1 @@
1
- {"version":3,"file":"answerer.js","sourceRoot":"","sources":["../../src/query/answerer.ts"],"names":[],"mappings":";;;;;AAoBA,wCAsCC;AA1DD,4DAA0C;AAC1C,4CAA+C;AAU/C,MAAM,aAAa,GAAG;;;;;;;wDAOkC,CAAC;AAElD,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,OAAe,EACf,KAAa,EACb,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,aAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,KAAK;QACL,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,GAAG,OAAO,iBAAiB,QAAQ,EAAE;aAC/C;SACF;KACF,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IAE9C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO;SAC5B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI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K,MAAM,CAAC;SACtC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAE,KAAa,CAAC,IAAI,CAAC;SACjC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,YAAY,IAAI,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,EAAE,aAAa,IAAI,CAAC,CAAC;IAExD,OAAO;QACL,MAAM;QACN,WAAW;QACX,YAAY;QACZ,IAAI,EAAE,IAAA,qBAAY,EAAC,KAAK,EAAE,WAAW,EAAE,YAAY,CAAC;QACpD,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -1,10 +1,15 @@
1
- export type QueryStrategy = 'direct' | 'relationship' | 'semantic' | 'domain' | 'impact';
1
+ export type QueryStrategy = 'direct' | 'relationship' | 'semantic' | 'domain' | 'impact' | 'route' | 'type' | 'file' | 'list' | 'pattern';
2
2
  export interface ClassificationResult {
3
3
  strategy: QueryStrategy;
4
4
  functionName: string | null;
5
5
  keywords: string[];
6
6
  domain: string | null;
7
7
  direction: 'callers' | 'callees' | null;
8
+ typeName: string | null;
9
+ filePath: string | null;
10
+ routePath: string | null;
11
+ routeMethod: string | null;
12
+ listEntity: string | null;
8
13
  }
9
14
  export declare function classifyQuestion(question: string, model: string, apiKey: string): Promise<ClassificationResult>;
10
15
  //# sourceMappingURL=classifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/query/classifier.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;CACzC;AAoBD,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC,CAoC/B"}
1
+ {"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/query/classifier.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1I,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACxC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AA8BD,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC,CA8C/B"}
@@ -13,14 +13,24 @@ Categories:
13
13
  3. "semantic" - Question asks about a concept, topic, or behavior (e.g., "How is authentication handled?")
14
14
  4. "domain" - Question asks about a category of functions (e.g., "Show all database operations")
15
15
  5. "impact" - Question asks about what would be affected by changes (e.g., "What breaks if I change validateEmail?")
16
+ 6. "route" - Question asks about HTTP routes/endpoints (e.g., "What does the /api/users endpoint do?", "What routes exist?")
17
+ 7. "type" - Question asks about a type, interface, or enum (e.g., "What is the User type?", "Show me the Request interface")
18
+ 8. "file" - Question asks about a specific file or its contents (e.g., "What does auth.ts do?", "What's in the config file?")
19
+ 9. "list" - Question asks to enumerate/list entities (e.g., "List all routes", "What functions exist?", "Show all types")
20
+ 10. "pattern" - Question asks about patterns or cross-cutting concerns spanning multiple entities (e.g., "How does the login flow work?", "How are errors handled?")
16
21
 
17
22
  Respond ONLY with JSON, no markdown:
18
23
  {
19
- "strategy": "direct|relationship|semantic|domain|impact",
24
+ "strategy": "direct|relationship|semantic|domain|impact|route|type|file|list|pattern",
20
25
  "function_name": "extracted function name or null",
21
26
  "keywords": ["relevant", "search", "terms"],
22
27
  "domain": "authentication|database|validation|routing|middleware|utility|logging|session|crypto|ui|api|config|testing|other or null",
23
- "direction": "callers|callees|null"
28
+ "direction": "callers|callees|null",
29
+ "type_name": "extracted type/interface/enum name or null",
30
+ "file_path": "extracted file path or null",
31
+ "route_path": "extracted route path like /api/users or null",
32
+ "route_method": "GET|POST|PUT|DELETE|PATCH or null",
33
+ "list_entity": "functions|routes|types|files|constants or null"
24
34
  }`;
25
35
  async function classifyQuestion(question, model, apiKey) {
26
36
  const client = new sdk_1.default({ apiKey });
@@ -44,6 +54,11 @@ async function classifyQuestion(question, model, apiKey) {
44
54
  keywords: parsed.keywords || [],
45
55
  domain: parsed.domain || null,
46
56
  direction: parsed.direction || null,
57
+ typeName: parsed.type_name || null,
58
+ filePath: parsed.file_path || null,
59
+ routePath: parsed.route_path || null,
60
+ routeMethod: parsed.route_method || null,
61
+ listEntity: parsed.list_entity || null,
47
62
  };
48
63
  }
49
64
  catch {
@@ -54,6 +69,11 @@ async function classifyQuestion(question, model, apiKey) {
54
69
  keywords: question.split(/\s+/).filter(w => w.length > 3),
55
70
  domain: null,
56
71
  direction: null,
72
+ typeName: null,
73
+ filePath: null,
74
+ routePath: null,
75
+ routeMethod: null,
76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AE,gBAAgB,EAAqB,MAAM,aAAa,CAAC;AAGvE,wBAAgB,YAAY,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA+BlF"}
1
+ {"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../src/query/context-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAsF,MAAM,aAAa,CAAC;AAGxI,wBAAgB,YAAY,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CA8DlF"}