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.
- package/README.md +72 -0
- package/dist/cli.js +260 -211
- package/dist/cli.js.map +1 -1
- package/dist/db/connection.js +28 -1
- package/dist/db/connection.js.map +1 -1
- package/dist/db/queries.d.ts +144 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +282 -6
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +59 -0
- package/dist/ingest/constant-extractor.d.ts +11 -0
- package/dist/ingest/constant-extractor.d.ts.map +1 -0
- package/dist/ingest/constant-extractor.js +38 -0
- package/dist/ingest/constant-extractor.js.map +1 -0
- package/dist/ingest/file-metadata.d.ts +13 -0
- package/dist/ingest/file-metadata.d.ts.map +1 -0
- package/dist/ingest/file-metadata.js +55 -0
- package/dist/ingest/file-metadata.js.map +1 -0
- package/dist/ingest/ingester.d.ts +15 -0
- package/dist/ingest/ingester.d.ts.map +1 -0
- package/dist/ingest/ingester.js +217 -0
- package/dist/ingest/ingester.js.map +1 -0
- package/dist/ingest/parser.d.ts +12 -0
- package/dist/ingest/parser.d.ts.map +1 -1
- package/dist/ingest/parser.js +48 -0
- package/dist/ingest/parser.js.map +1 -1
- package/dist/ingest/route-extractor.d.ts +12 -0
- package/dist/ingest/route-extractor.d.ts.map +1 -0
- package/dist/ingest/route-extractor.js +64 -0
- package/dist/ingest/route-extractor.js.map +1 -0
- package/dist/ingest/type-extractor.d.ts +11 -0
- package/dist/ingest/type-extractor.d.ts.map +1 -0
- package/dist/ingest/type-extractor.js +47 -0
- package/dist/ingest/type-extractor.js.map +1 -0
- package/dist/instructions/claude.md +54 -25
- package/dist/instructions/codex.md +70 -0
- package/dist/instructions/copilot.md +57 -26
- package/dist/instructions/cursor.md +54 -25
- package/dist/instructions/generic.md +54 -25
- package/dist/query/answerer.d.ts.map +1 -1
- package/dist/query/answerer.js +6 -2
- package/dist/query/answerer.js.map +1 -1
- package/dist/query/classifier.d.ts +6 -1
- package/dist/query/classifier.d.ts.map +1 -1
- package/dist/query/classifier.js +22 -2
- package/dist/query/classifier.js.map +1 -1
- package/dist/query/context-builder.d.ts.map +1 -1
- package/dist/query/context-builder.js +152 -6
- package/dist/query/context-builder.js.map +1 -1
- package/dist/query/retriever.d.ts +44 -0
- package/dist/query/retriever.d.ts.map +1 -1
- package/dist/query/retriever.js +211 -14
- package/dist/query/retriever.js.map +1 -1
- package/dist/semantic/analyzer.d.ts +10 -0
- package/dist/semantic/analyzer.d.ts.map +1 -1
- package/dist/semantic/analyzer.js +147 -1
- package/dist/semantic/analyzer.js.map +1 -1
- package/dist/semantic/prompt.d.ts +21 -0
- package/dist/semantic/prompt.d.ts.map +1 -1
- package/dist/semantic/prompt.js +63 -0
- package/dist/semantic/prompt.js.map +1 -1
- 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
|
|
5
|
-
|
|
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
|
-
##
|
|
8
|
+
## Mandatory Workflow
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
35
|
+
**Reading source files to "explore" or "understand" the codebase is PROHIBITED.
|
|
36
|
+
That is what StructX is for.**
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
##
|
|
62
|
+
## Rules Summary
|
|
35
63
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
5
|
-
|
|
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
|
-
##
|
|
8
|
+
## Mandatory Workflow
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
35
|
+
**Reading source files to "explore" or "understand" the codebase is PROHIBITED.
|
|
36
|
+
That is what StructX is for.**
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
29
|
-
- `npx structx setup .` —
|
|
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
|
|
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
|
-
##
|
|
60
|
+
## Rules Summary
|
|
35
61
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 —
|
|
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
|
|
5
|
-
|
|
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
|
-
##
|
|
8
|
+
## Mandatory Workflow
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
35
|
+
**Reading source files to "explore" or "understand" the codebase is PROHIBITED.
|
|
36
|
+
That is what StructX is for.**
|
|
21
37
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
31
|
-
| `npx structx setup .` |
|
|
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
|
|
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
|
-
##
|
|
62
|
+
## Rules Summary
|
|
37
63
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
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"}
|
package/dist/query/answerer.js
CHANGED
|
@@ -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":";;;;;
|
|
1
|
+
{"version":3,"file":"answerer.js","sourceRoot":"","sources":["../../src/query/answerer.ts"],"names":[],"mappings":";;;;;AAwBA,wCAsCC;AA9DD,4DAA0C;AAC1C,4CAA+C;AAU/C,MAAM,aAAa,GAAG;;;;;;;;;;;oEAW8C,CAAC;AAE9D,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,KAAK,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;
|
|
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"}
|
package/dist/query/classifier.js
CHANGED
|
@@ -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
|
+
listEntity: null,
|
|
57
77
|
};
|
|
58
78
|
}
|
|
59
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/query/classifier.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/query/classifier.ts"],"names":[],"mappings":";;;;;AA6CA,4CAkDC;AA/FD,4DAA0C;AAiB1C,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B5B,CAAC;AAEI,KAAK,UAAU,gBAAgB,CACpC,QAAgB,EAChB,KAAa,EACb,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,aAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,KAAK;QACL,UAAU,EAAE,GAAG;QACf,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,qBAAqB,kBAAkB,QAAQ,GAAG,EAAE;SACjF;KACF,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO;SAC1B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;SACtC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAE,KAAa,CAAC,IAAI,CAAC;SACjC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,UAAU;YACvC,YAAY,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;YAC1C,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,IAAI;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YACnC,QAAQ,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YAClC,QAAQ,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;YAClC,SAAS,EAAE,MAAM,CAAC,UAAU,IAAI,IAAI;YACpC,WAAW,EAAE,MAAM,CAAC,YAAY,IAAI,IAAI;YACxC,UAAU,EAAE,MAAM,CAAC,WAAW,IAAI,IAAI;SACvC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,8BAA8B;QAC9B,OAAO;YACL,QAAQ,EAAE,UAAU;YACpB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YACzD,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,IAAI;SACjB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../src/query/context-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,
|
|
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"}
|