@pmaddire/gcie 0.1.2
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/AGENT.md +256 -0
- package/AGENT_USAGE.md +231 -0
- package/ARCHITECTURE.md +151 -0
- package/CLAUDE.md +69 -0
- package/DEBUGGING_PLAYBOOK.md +160 -0
- package/KNOWLEDGE_INDEX.md +154 -0
- package/POTENTIAL_UPDATES +130 -0
- package/PROJECT.md +141 -0
- package/README.md +371 -0
- package/REPO_DIGITAL_TWIN.md +98 -0
- package/ROADMAP.md +301 -0
- package/SETUP_ANY_REPO.md +85 -0
- package/bin/gcie-init.js +20 -0
- package/bin/gcie.js +45 -0
- package/cli/__init__.py +1 -0
- package/cli/app.py +163 -0
- package/cli/commands/__init__.py +1 -0
- package/cli/commands/cache.py +35 -0
- package/cli/commands/context.py +2426 -0
- package/cli/commands/context_slices.py +617 -0
- package/cli/commands/debug.py +24 -0
- package/cli/commands/index.py +17 -0
- package/cli/commands/query.py +20 -0
- package/cli/commands/setup.py +73 -0
- package/config/__init__.py +1 -0
- package/config/scanner_config.py +82 -0
- package/context/__init__.py +1 -0
- package/context/architecture_bootstrap.py +170 -0
- package/context/architecture_index.py +185 -0
- package/context/architecture_parser.py +170 -0
- package/context/architecture_slicer.py +308 -0
- package/context/context_router.py +70 -0
- package/context/fallback_evaluator.py +21 -0
- package/coverage_integration/__init__.py +1 -0
- package/coverage_integration/coverage_loader.py +55 -0
- package/debugging/__init__.py +12 -0
- package/debugging/bug_localizer.py +81 -0
- package/debugging/execution_path_analyzer.py +42 -0
- package/embeddings/__init__.py +6 -0
- package/embeddings/encoder.py +45 -0
- package/embeddings/faiss_index.py +72 -0
- package/git_integration/__init__.py +1 -0
- package/git_integration/git_miner.py +78 -0
- package/graphs/__init__.py +17 -0
- package/graphs/call_graph.py +70 -0
- package/graphs/code_graph.py +81 -0
- package/graphs/execution_graph.py +35 -0
- package/graphs/git_graph.py +43 -0
- package/graphs/graph_store.py +25 -0
- package/graphs/node_factory.py +21 -0
- package/graphs/test_graph.py +65 -0
- package/graphs/validators.py +28 -0
- package/graphs/variable_graph.py +51 -0
- package/knowledge_index/__init__.py +1 -0
- package/knowledge_index/index_builder.py +60 -0
- package/knowledge_index/models.py +35 -0
- package/knowledge_index/query_api.py +38 -0
- package/knowledge_index/store.py +23 -0
- package/llm_context/__init__.py +6 -0
- package/llm_context/context_builder.py +67 -0
- package/llm_context/snippet_selector.py +57 -0
- package/package.json +14 -0
- package/parser/__init__.py +18 -0
- package/parser/ast_parser.py +216 -0
- package/parser/call_resolver.py +52 -0
- package/parser/models.py +75 -0
- package/parser/tree_sitter_adapter.py +56 -0
- package/parser/variable_extractor.py +31 -0
- package/retrieval/__init__.py +17 -0
- package/retrieval/cache.py +22 -0
- package/retrieval/hybrid_retriever.py +249 -0
- package/retrieval/query_parser.py +38 -0
- package/retrieval/ranking.py +43 -0
- package/retrieval/semantic_retriever.py +39 -0
- package/retrieval/symbolic_retriever.py +80 -0
- package/scanner/__init__.py +5 -0
- package/scanner/file_filters.py +37 -0
- package/scanner/models.py +44 -0
- package/scanner/repository_scanner.py +55 -0
- package/scripts/bootstrap_from_github.ps1 +41 -0
- package/tracing/__init__.py +1 -0
- package/tracing/runtime_tracer.py +60 -0
package/AGENT.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# AGENT.md
|
|
2
|
+
|
|
3
|
+
Agent Operating Instructions for GraphCode Intelligence Engine (GCIE)
|
|
4
|
+
|
|
5
|
+
This file provides persistent architectural context for coding agents working on this repository.
|
|
6
|
+
|
|
7
|
+
Agents must read this file before performing any development tasks.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
PROJECT NAME
|
|
12
|
+
|
|
13
|
+
GraphCode Intelligence Engine (GCIE)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
PROJECT PURPOSE
|
|
18
|
+
|
|
19
|
+
GCIE is a graph-based code intelligence system designed to drastically reduce LLM token usage when working with large codebases.
|
|
20
|
+
|
|
21
|
+
Instead of sending entire files to an LLM, GCIE retrieves only the minimal execution-relevant code required to answer a query.
|
|
22
|
+
|
|
23
|
+
Example query:
|
|
24
|
+
|
|
25
|
+
"Why is variable diff exploding?"
|
|
26
|
+
|
|
27
|
+
GCIE should return only the relevant execution path and functions responsible for modifying the variable.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
HIGH LEVEL ARCHITECTURE
|
|
32
|
+
|
|
33
|
+
The system constructs multiple graphs representing the codebase.
|
|
34
|
+
|
|
35
|
+
These graphs are combined into a unified knowledge graph used for symbolic and semantic retrieval.
|
|
36
|
+
|
|
37
|
+
Graph types include:
|
|
38
|
+
|
|
39
|
+
1. Code Structure Graph
|
|
40
|
+
2. Call Graph
|
|
41
|
+
3. Variable Dependency Graph
|
|
42
|
+
4. Execution Trace Graph
|
|
43
|
+
5. Git History Graph
|
|
44
|
+
6. Test Coverage Graph
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
SYSTEM COMPONENTS
|
|
49
|
+
|
|
50
|
+
parser/
|
|
51
|
+
|
|
52
|
+
Parses repository source code using AST.
|
|
53
|
+
|
|
54
|
+
Responsible for extracting:
|
|
55
|
+
|
|
56
|
+
functions
|
|
57
|
+
classes
|
|
58
|
+
variables
|
|
59
|
+
imports
|
|
60
|
+
assignments
|
|
61
|
+
function calls
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
graphs/
|
|
66
|
+
|
|
67
|
+
Responsible for building graph representations.
|
|
68
|
+
|
|
69
|
+
Graph modules include:
|
|
70
|
+
|
|
71
|
+
code_graph.py
|
|
72
|
+
call_graph.py
|
|
73
|
+
variable_graph.py
|
|
74
|
+
execution_graph.py
|
|
75
|
+
git_graph.py
|
|
76
|
+
test_graph.py
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
retrieval/
|
|
81
|
+
|
|
82
|
+
Responsible for retrieving relevant code based on queries.
|
|
83
|
+
|
|
84
|
+
Includes:
|
|
85
|
+
|
|
86
|
+
symbolic_retriever.py
|
|
87
|
+
semantic_retriever.py
|
|
88
|
+
hybrid_retriever.py
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
embeddings/
|
|
93
|
+
|
|
94
|
+
Responsible for embedding code for semantic search.
|
|
95
|
+
|
|
96
|
+
Uses SentenceTransformers.
|
|
97
|
+
|
|
98
|
+
Embeddings stored in FAISS vector index.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
debugging/
|
|
103
|
+
|
|
104
|
+
Contains logic for automated bug localization.
|
|
105
|
+
|
|
106
|
+
Includes:
|
|
107
|
+
|
|
108
|
+
bug_localizer.py
|
|
109
|
+
execution_path_analyzer.py
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
llm_context/
|
|
114
|
+
|
|
115
|
+
Builds minimal code context for LLM prompts.
|
|
116
|
+
|
|
117
|
+
Responsible for formatting retrieved code snippets.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
cli/
|
|
122
|
+
|
|
123
|
+
CLI interface for interacting with GCIE.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
CORE DESIGN PRINCIPLES
|
|
128
|
+
|
|
129
|
+
Minimal Context Retrieval
|
|
130
|
+
|
|
131
|
+
The system should always aim to return the smallest possible code context required to answer a query.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
Graph First Retrieval
|
|
136
|
+
|
|
137
|
+
Symbolic graph traversal should be performed before semantic search.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
Hybrid Ranking
|
|
142
|
+
|
|
143
|
+
Final results should combine:
|
|
144
|
+
|
|
145
|
+
symbolic retrieval
|
|
146
|
+
semantic similarity
|
|
147
|
+
git recency weighting
|
|
148
|
+
test coverage weighting
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
GRAPH DATA MODEL
|
|
153
|
+
|
|
154
|
+
Nodes may represent:
|
|
155
|
+
|
|
156
|
+
files
|
|
157
|
+
classes
|
|
158
|
+
functions
|
|
159
|
+
variables
|
|
160
|
+
commits
|
|
161
|
+
tests
|
|
162
|
+
|
|
163
|
+
Edges may represent:
|
|
164
|
+
|
|
165
|
+
CALLS
|
|
166
|
+
IMPORTS
|
|
167
|
+
DEFINES
|
|
168
|
+
MODIFIES
|
|
169
|
+
READS
|
|
170
|
+
WRITES
|
|
171
|
+
EXECUTES
|
|
172
|
+
CHANGED_IN
|
|
173
|
+
COVERED_BY
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
QUERY PIPELINE
|
|
178
|
+
|
|
179
|
+
When a query is received:
|
|
180
|
+
|
|
181
|
+
1. Extract relevant symbols (variables/functions)
|
|
182
|
+
2. Perform symbolic graph traversal
|
|
183
|
+
3. Retrieve execution paths
|
|
184
|
+
4. Rank candidates with embeddings
|
|
185
|
+
5. Apply git and coverage weighting
|
|
186
|
+
6. Return minimal code snippets
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
BUG LOCALIZATION STRATEGY
|
|
191
|
+
|
|
192
|
+
When debugging queries are received:
|
|
193
|
+
|
|
194
|
+
1. Identify target variable or function
|
|
195
|
+
2. Find functions modifying that symbol
|
|
196
|
+
3. Trace upstream execution paths
|
|
197
|
+
4. Prioritize recently modified code
|
|
198
|
+
5. Prioritize code with low test coverage
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
DEVELOPMENT WORKFLOW
|
|
203
|
+
|
|
204
|
+
This repository uses the Get Shit Done (GSD) workflow.
|
|
205
|
+
|
|
206
|
+
Agents must follow the process:
|
|
207
|
+
|
|
208
|
+
1. Create project specification
|
|
209
|
+
2. Generate roadmap
|
|
210
|
+
3. Plan phases
|
|
211
|
+
4. Execute atomic tasks
|
|
212
|
+
5. Verify outputs
|
|
213
|
+
|
|
214
|
+
Agents must not implement large features in a single step.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
IMPLEMENTATION RULES
|
|
219
|
+
|
|
220
|
+
Agents must:
|
|
221
|
+
|
|
222
|
+
write modular code
|
|
223
|
+
|
|
224
|
+
use Python type hints
|
|
225
|
+
|
|
226
|
+
write docstrings
|
|
227
|
+
|
|
228
|
+
verify features before continuing
|
|
229
|
+
|
|
230
|
+
follow phased development
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
PERFORMANCE GOALS
|
|
235
|
+
|
|
236
|
+
The system should aim to reduce LLM prompt context size by at least 10x compared to naive full-repository prompts.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
FUTURE EXTENSIONS
|
|
241
|
+
|
|
242
|
+
Possible future improvements include:
|
|
243
|
+
|
|
244
|
+
cross-language support using Tree-sitter
|
|
245
|
+
|
|
246
|
+
persistent graph database using Neo4j
|
|
247
|
+
|
|
248
|
+
IDE integration
|
|
249
|
+
|
|
250
|
+
LLM agent integration
|
|
251
|
+
|
|
252
|
+
execution-aware debugging agents
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
END OF AGENT MEMORY FILE
|
package/AGENT_USAGE.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# GCIE Agent Usage (Portable Default)
|
|
2
|
+
|
|
3
|
+
This file is designed to be dropped into any repository and used immediately.
|
|
4
|
+
|
|
5
|
+
## Goal
|
|
6
|
+
|
|
7
|
+
Retrieve the smallest useful context while preserving edit safety.
|
|
8
|
+
|
|
9
|
+
Priority order:
|
|
10
|
+
1. accuracy (must-have coverage)
|
|
11
|
+
2. full-hit reliability
|
|
12
|
+
3. token efficiency
|
|
13
|
+
|
|
14
|
+
## Quick Start (Any Repo)
|
|
15
|
+
|
|
16
|
+
1. Identify must-have context categories for the task:
|
|
17
|
+
- implementation file(s)
|
|
18
|
+
- wiring/orchestration file(s)
|
|
19
|
+
- validation surface when risk is non-trivial
|
|
20
|
+
- this may be a test, spec, schema, contract, migration, config, or CLI surface depending on the repo
|
|
21
|
+
|
|
22
|
+
2. Run one primary retrieval with a file-first, symbol-heavy query:
|
|
23
|
+
```powershell
|
|
24
|
+
gcie.cmd context <path> "<file-first symbol-heavy query>" --intent <edit|debug|refactor|explore> --budget <shape budget>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
3. Check must-have coverage.
|
|
28
|
+
|
|
29
|
+
4. If one must-have file is missing, run targeted gap-fill for only that file.
|
|
30
|
+
|
|
31
|
+
5. Stop immediately when must-have coverage is complete.
|
|
32
|
+
|
|
33
|
+
## Retrieval Modes (Adaptive Router)
|
|
34
|
+
|
|
35
|
+
Use three modes and choose by task family:
|
|
36
|
+
|
|
37
|
+
1. `plain-context-first` (default for most tasks)
|
|
38
|
+
2. `slicer-first` (for hard routed architecture or multi-hop families)
|
|
39
|
+
3. `direct-file-check` (verification and fast gap closure)
|
|
40
|
+
|
|
41
|
+
Plain-context command:
|
|
42
|
+
```powershell
|
|
43
|
+
gcie.cmd context <path> "<query>" --intent <edit|debug|refactor|explore> --budget <shape budget>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Slicer-first command:
|
|
47
|
+
```powershell
|
|
48
|
+
gcie.cmd context-slices <path> "<query>" --intent <edit|debug|refactor|explore>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Direct-file-check command:
|
|
52
|
+
```powershell
|
|
53
|
+
rg -n "<symbol1|symbol2|symbol3>" <likely files or subtree>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Mode-switch rule:
|
|
57
|
+
- start with `plain-context-first` unless setup calibration proved another mode is better for that family
|
|
58
|
+
- use `slicer-first` only for families where routing/architecture slices repeatedly outperform plain context
|
|
59
|
+
- use `direct-file-check` whenever must-have coverage is uncertain or one file remains missing
|
|
60
|
+
- do not keep retrying the same mode indefinitely; switch after one weak result
|
|
61
|
+
|
|
62
|
+
Portable starter policy:
|
|
63
|
+
- default all families to `plain-context-first`
|
|
64
|
+
- after first 10-20 tasks, promote individual families to `slicer-first` only if benchmarked better
|
|
65
|
+
- keep a family on plain-context if slicer is more expensive with no accuracy gain
|
|
66
|
+
|
|
67
|
+
## Architecture Tracking (Portable, In-Repo)
|
|
68
|
+
|
|
69
|
+
To make slicer mode adapt as the repo changes, keep architecture tracking inside the repo where GCIE runs.
|
|
70
|
+
|
|
71
|
+
Track these files under `.gcie/`:
|
|
72
|
+
- `.gcie/architecture.md`
|
|
73
|
+
- `.gcie/architecture_index.json`
|
|
74
|
+
- `.gcie/context_config.json`
|
|
75
|
+
|
|
76
|
+
How to keep it adaptive:
|
|
77
|
+
1. Bootstrap from user docs once (read-only):
|
|
78
|
+
- `ARCHITECTURE.md`, `README.md`, `PROJECT.md`, `docs/architecture.md`, `docs/system_design.md`
|
|
79
|
+
2. Use `.gcie/architecture.md` as GCIE-owned working architecture map.
|
|
80
|
+
3. Refresh `.gcie/architecture.md` and `.gcie/architecture_index.json` when structural changes happen:
|
|
81
|
+
- new subsystem
|
|
82
|
+
- major module split/merge
|
|
83
|
+
- interface/boundary change
|
|
84
|
+
- dependency-direction change
|
|
85
|
+
- active work-area shift
|
|
86
|
+
4. Do not overwrite user-owned docs unless explicitly asked.
|
|
87
|
+
|
|
88
|
+
Architecture confidence rule:
|
|
89
|
+
- if architecture slice confidence is low or required mappings are stale/missing, fallback to plain `context` automatically
|
|
90
|
+
- record fallback reason in `.gcie/context_config.json` when bypassing slicer mode
|
|
91
|
+
|
|
92
|
+
## Portable Defaults (Task-Shape Based)
|
|
93
|
+
|
|
94
|
+
Use these as a starting point in new repos.
|
|
95
|
+
|
|
96
|
+
Primary pass budgets:
|
|
97
|
+
- `auto`: simple same-layer or strong single-file lookup
|
|
98
|
+
- `900`: same-family two-file lookup, frontend-local component lookup
|
|
99
|
+
- `1100`: backend/config pair, same-layer backend pair
|
|
100
|
+
- `1150`: cross-layer UI/API flow
|
|
101
|
+
- `1300-1400`: explicit multi-hop chain (3+ linked files)
|
|
102
|
+
|
|
103
|
+
Gap-fill budgets:
|
|
104
|
+
- missing general implementation/wiring file: `900`
|
|
105
|
+
- missing small orchestration or entry file: `500`
|
|
106
|
+
|
|
107
|
+
Scope rule:
|
|
108
|
+
- use the smallest path scope that still contains the expected files
|
|
109
|
+
- use repo root (`.`) only for true cross-layer or backend orchestration recovery
|
|
110
|
+
- if explicit targets cluster in one subtree, broad repo-root retrieval is often worse than subtree retrieval
|
|
111
|
+
|
|
112
|
+
## Query Construction (Portable)
|
|
113
|
+
|
|
114
|
+
Use this pattern:
|
|
115
|
+
|
|
116
|
+
`<file-a> <file-b> <function/component> <state-or-arg> <route/flag> <config-key>`
|
|
117
|
+
|
|
118
|
+
Guidelines:
|
|
119
|
+
- include explicit file paths when known
|
|
120
|
+
- include 2 to 6 distinctive symbols
|
|
121
|
+
- include a caller or entry anchor when the target is indirect
|
|
122
|
+
- avoid vague summaries and long laundry-list queries
|
|
123
|
+
|
|
124
|
+
## Adaptive Loop (When Retrieval Is Weak)
|
|
125
|
+
|
|
126
|
+
Treat retrieval as weak if any are true:
|
|
127
|
+
- missing implementation or wiring category
|
|
128
|
+
- generic entry/support files dominate
|
|
129
|
+
- only tiny snippets from the target file appear, with no useful implementation body
|
|
130
|
+
- expected cross-layer endpoint is missing
|
|
131
|
+
|
|
132
|
+
Adapt in this order, one change at a time:
|
|
133
|
+
|
|
134
|
+
1. Query upgrade:
|
|
135
|
+
- add explicit file paths
|
|
136
|
+
- add missing symbols such as functions, props, routes, flags, or keys
|
|
137
|
+
- add caller or entry anchor
|
|
138
|
+
|
|
139
|
+
2. Scope correction:
|
|
140
|
+
- noisy root results: move to subtree scope
|
|
141
|
+
- missing cross-layer or backend anchor: use a targeted root query for that file
|
|
142
|
+
|
|
143
|
+
3. Budget bump:
|
|
144
|
+
- raise one rung only, roughly `+100` to `+250`
|
|
145
|
+
|
|
146
|
+
4. Targeted gap-fill:
|
|
147
|
+
- fetch only the missing must-have file(s)
|
|
148
|
+
|
|
149
|
+
5. Decompose chain, only if needed:
|
|
150
|
+
- for 4+ hops, split into adjacent 2-3 file hops
|
|
151
|
+
|
|
152
|
+
## Safe Efficiency Mode
|
|
153
|
+
|
|
154
|
+
Use only after stable coverage is achieved.
|
|
155
|
+
|
|
156
|
+
Rules:
|
|
157
|
+
- do not lower primary budgets for known hard shapes
|
|
158
|
+
- for a single missing file, try `800` before `900` only if the first pass already found same-family context
|
|
159
|
+
- if `800` misses, immediately retry the stable default
|
|
160
|
+
- if any miss persists, revert that task family to stable settings
|
|
161
|
+
|
|
162
|
+
Note:
|
|
163
|
+
- `800` is an experimental efficiency step-down, not a portable default truth
|
|
164
|
+
- keep it only if it preserves full must-have coverage in the current repo
|
|
165
|
+
|
|
166
|
+
## Verification Rule
|
|
167
|
+
|
|
168
|
+
Always verify with a quick local symbol check before editing:
|
|
169
|
+
|
|
170
|
+
```powershell
|
|
171
|
+
rg -n "symbol1|symbol2|symbol3" <likely files>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
GCIE is a context compressor, not the final truth gate.
|
|
175
|
+
|
|
176
|
+
If one required file is still missing after retrieval, do direct-file-check first, then run one targeted GCIE call only for that file.
|
|
177
|
+
|
|
178
|
+
## Portable Stop Rule
|
|
179
|
+
|
|
180
|
+
Stop retrieval when all must-have categories are covered:
|
|
181
|
+
- implementation
|
|
182
|
+
- wiring/orchestration
|
|
183
|
+
- validation surface, when risk justifies it
|
|
184
|
+
|
|
185
|
+
Do not continue increasing budgets after sufficiency is reached.
|
|
186
|
+
|
|
187
|
+
## First 5 Tasks Calibration (Minimal)
|
|
188
|
+
|
|
189
|
+
For a new repo, track these fields for the first 5 tasks:
|
|
190
|
+
- task shape
|
|
191
|
+
- primary budget
|
|
192
|
+
- gap-fill used (Y/N)
|
|
193
|
+
- must-have full-hit (Y/N)
|
|
194
|
+
- total tokens
|
|
195
|
+
|
|
196
|
+
If a miss pattern repeats 2+ times in one task family:
|
|
197
|
+
- add one local override for that family only
|
|
198
|
+
- keep all other families on portable defaults
|
|
199
|
+
|
|
200
|
+
Update necessity rule:
|
|
201
|
+
- explicit workflow updates are optional, not required for baseline operation
|
|
202
|
+
- if results are stable, keep using portable defaults without changes
|
|
203
|
+
- add or update a local override only when the same miss pattern repeats 2-3 times
|
|
204
|
+
|
|
205
|
+
## Optional Appendix: Repo-Specific Overrides (Example)
|
|
206
|
+
|
|
207
|
+
These are examples from one mixed-layer repo and are not universal defaults.
|
|
208
|
+
|
|
209
|
+
1. `cross_layer_ui_api` override:
|
|
210
|
+
```powershell
|
|
211
|
+
gcie.cmd context frontend "src/App.jsx src/main.jsx <symbols>" --intent edit --budget 900
|
|
212
|
+
gcie.cmd context . "app.py start_convert selected_theme selectedTheme no_ai" --intent edit --budget 900
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
2. Stage 3/4 planner-builder pair override (`Plan_slides.py` + `Build_pptx.py`):
|
|
216
|
+
```powershell
|
|
217
|
+
gcie.cmd context . "Plan_slides.py content_slides section_divider figure_slides table_slide" --intent <intent> --budget 900
|
|
218
|
+
gcie.cmd context . "Build_pptx.py build_pptx render_eq_png apply_theme THEME_CHOICES" --intent <intent> --budget 900
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
3. Stage 1/2 with `main.py` override:
|
|
222
|
+
```powershell
|
|
223
|
+
gcie.cmd context . "Analyze_pdf_structure.py Extract_pdf_content.py extract_pages split_into_sections extract_images enrich_with_ai" --intent explore --budget 1100
|
|
224
|
+
gcie.cmd context . "main.py Stage 1 Stage 2 extract_pages enrich_with_ai" --intent explore --budget 500
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
4. Guardrail example:
|
|
228
|
+
- keep the stable workflow for families that regress under split retrieval
|
|
229
|
+
- example: `llm_client.py + Analyze_pdf_structure.py + Extract_pdf_content.py` in one benchmarked repo
|
|
230
|
+
|
|
231
|
+
If this appendix does not match your repo, ignore it and use only the portable sections above.
|
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# ARCHITECTURE.md
|
|
2
|
+
|
|
3
|
+
GraphCode Intelligence Engine (GCIE) Architecture
|
|
4
|
+
|
|
5
|
+
This document describes the architecture of the GCIE system.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
SYSTEM PURPOSE
|
|
10
|
+
|
|
11
|
+
GCIE is a graph-based code intelligence engine that retrieves minimal execution-relevant code context for LLM workflows.
|
|
12
|
+
|
|
13
|
+
The system reduces token usage by retrieving only relevant code paths rather than entire files.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
CORE SUBSYSTEMS
|
|
18
|
+
|
|
19
|
+
The system consists of five primary subsystems.
|
|
20
|
+
|
|
21
|
+
1. Code Parser
|
|
22
|
+
2. Graph Builder
|
|
23
|
+
3. Knowledge Index
|
|
24
|
+
4. Retrieval Engine
|
|
25
|
+
5. LLM Context Builder
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
ARCHITECTURE DIAGRAM
|
|
30
|
+
|
|
31
|
+
Repository
|
|
32
|
+
↓
|
|
33
|
+
Repository Scanner
|
|
34
|
+
↓
|
|
35
|
+
AST Parser
|
|
36
|
+
↓
|
|
37
|
+
Symbol Extractor
|
|
38
|
+
↓
|
|
39
|
+
Graph Builders
|
|
40
|
+
↓
|
|
41
|
+
Unified Knowledge Graph
|
|
42
|
+
↓
|
|
43
|
+
Knowledge Index
|
|
44
|
+
↓
|
|
45
|
+
Retrieval Engine
|
|
46
|
+
↓
|
|
47
|
+
LLM Context Builder
|
|
48
|
+
↓
|
|
49
|
+
CLI Interface
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
GRAPH SYSTEM
|
|
54
|
+
|
|
55
|
+
The graph system builds multiple graphs representing the codebase.
|
|
56
|
+
|
|
57
|
+
Code Structure Graph
|
|
58
|
+
|
|
59
|
+
Represents relationships between files, classes, and functions.
|
|
60
|
+
|
|
61
|
+
Call Graph
|
|
62
|
+
|
|
63
|
+
Represents which functions call other functions.
|
|
64
|
+
|
|
65
|
+
Variable Dependency Graph
|
|
66
|
+
|
|
67
|
+
Represents read/write relationships between functions and variables.
|
|
68
|
+
|
|
69
|
+
Execution Trace Graph
|
|
70
|
+
|
|
71
|
+
Represents runtime execution paths captured via tracing.
|
|
72
|
+
|
|
73
|
+
Git History Graph
|
|
74
|
+
|
|
75
|
+
Represents relationships between commits and code elements.
|
|
76
|
+
|
|
77
|
+
Test Coverage Graph
|
|
78
|
+
|
|
79
|
+
Represents relationships between tests and executed code.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
KNOWLEDGE INDEX
|
|
84
|
+
|
|
85
|
+
The Knowledge Index is a structured metadata index of the codebase.
|
|
86
|
+
|
|
87
|
+
It stores:
|
|
88
|
+
|
|
89
|
+
function metadata
|
|
90
|
+
class metadata
|
|
91
|
+
file metadata
|
|
92
|
+
variable metadata
|
|
93
|
+
dependency metadata
|
|
94
|
+
|
|
95
|
+
The Knowledge Index allows fast queries such as:
|
|
96
|
+
|
|
97
|
+
Which functions modify variable X
|
|
98
|
+
|
|
99
|
+
Which modules depend on module Y
|
|
100
|
+
|
|
101
|
+
Which functions call function Z
|
|
102
|
+
|
|
103
|
+
These queries can be answered without calling an LLM.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
RETRIEVAL PIPELINE
|
|
108
|
+
|
|
109
|
+
Query
|
|
110
|
+
↓
|
|
111
|
+
Symbol Extraction
|
|
112
|
+
↓
|
|
113
|
+
Knowledge Index Query
|
|
114
|
+
↓
|
|
115
|
+
Graph Traversal
|
|
116
|
+
↓
|
|
117
|
+
Semantic Ranking
|
|
118
|
+
↓
|
|
119
|
+
Context Builder
|
|
120
|
+
↓
|
|
121
|
+
LLM
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
TOKEN REDUCTION STRATEGY
|
|
126
|
+
|
|
127
|
+
Token usage is reduced by:
|
|
128
|
+
|
|
129
|
+
1. Graph-based symbolic retrieval
|
|
130
|
+
2. Knowledge index filtering
|
|
131
|
+
3. Semantic ranking
|
|
132
|
+
4. Minimal context packaging
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
EXPECTED TOKEN SAVINGS
|
|
137
|
+
|
|
138
|
+
Typical context sizes:
|
|
139
|
+
|
|
140
|
+
Naive repo prompt:
|
|
141
|
+
20k tokens
|
|
142
|
+
|
|
143
|
+
Vector RAG:
|
|
144
|
+
3k tokens
|
|
145
|
+
|
|
146
|
+
GCIE graph retrieval:
|
|
147
|
+
300–800 tokens
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
END ARCHITECTURE
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
Before making any code change, run:
|
|
4
|
+
|
|
5
|
+
gcie.cmd context-slices . "<task>" --intent <edit|debug|refactor|explore>
|
|
6
|
+
|
|
7
|
+
Use only the returned snippets as working context.
|
|
8
|
+
If the context seems insufficient, add a pin or increase budgets.
|
|
9
|
+
|
|
10
|
+
## Tested Usage Playbook (updated 2026-03-25)
|
|
11
|
+
|
|
12
|
+
### 1) Command form
|
|
13
|
+
|
|
14
|
+
On this machine, use:
|
|
15
|
+
|
|
16
|
+
gcie.cmd context-slices . "<task>" --intent <edit|debug|refactor|explore> [--profile recall|low] [--pin <path>] [--include-tests]
|
|
17
|
+
|
|
18
|
+
(`gcie` PowerShell shim can be blocked by execution policy; `gcie.cmd` works.)
|
|
19
|
+
|
|
20
|
+
### 2) Profiles
|
|
21
|
+
|
|
22
|
+
- `--profile recall` (default): higher recall, still strong savings.
|
|
23
|
+
- `--profile low`: aggressive budgets, cheaper but can miss files.
|
|
24
|
+
|
|
25
|
+
Profile defaults:
|
|
26
|
+
- recall: stage-a 400, stage-b 800, max-total 1200, pin-budget 300
|
|
27
|
+
- low: stage-a 300, stage-b 600, max-total 800, pin-budget 200
|
|
28
|
+
|
|
29
|
+
### 3) Tests only when needed
|
|
30
|
+
|
|
31
|
+
Do not pull tests unless you are writing/updating tests or touching risky logic:
|
|
32
|
+
- Add `--include-tests` only when necessary.
|
|
33
|
+
|
|
34
|
+
### 4) File pinning for must-have wiring files
|
|
35
|
+
|
|
36
|
+
If a required file is still missing (commonly `frontend/src/App.jsx`), pin it directly:
|
|
37
|
+
|
|
38
|
+
- `gcie.cmd context-slices . "<task wiring keywords>" --pin frontend/src/App.jsx --pin-budget 300 --intent edit`
|
|
39
|
+
|
|
40
|
+
### 5) Token gate
|
|
41
|
+
|
|
42
|
+
Default max output is `--max-total 1200` tokens for medium tasks.
|
|
43
|
+
If required files are still missing, the tool can exceed this limit to surface more context.
|
|
44
|
+
|
|
45
|
+
### 6) Query strategy
|
|
46
|
+
|
|
47
|
+
Use explicit nouns from the code, not abstract issue summaries:
|
|
48
|
+
|
|
49
|
+
- Better: "api export endpoint doc_type session_id markdown"
|
|
50
|
+
- Better: "Canvas.test.jsx and Canvas.jsx for no architecture nodes generated"
|
|
51
|
+
- Better: "refinement rename subsystem patch persisted session outputs"
|
|
52
|
+
|
|
53
|
+
Include filenames or function/prop names where possible.
|
|
54
|
+
|
|
55
|
+
### 7) Known command behavior
|
|
56
|
+
|
|
57
|
+
- `gcie.cmd context-slices` works for repo paths and uses path-scoped slices.
|
|
58
|
+
- `gcie.cmd query` / `gcie.cmd debug` can fail on directory path `.` in this environment; avoid them for whole-repo lookup.
|
|
59
|
+
- Reindex after major changes: `gcie.cmd index .`
|
|
60
|
+
|
|
61
|
+
### 8) Sufficiency gate (required before edits)
|
|
62
|
+
|
|
63
|
+
Context is sufficient only when results include all of:
|
|
64
|
+
|
|
65
|
+
- Primary implementation file(s)
|
|
66
|
+
- UI/handler wiring file(s) (often `frontend/src/App.jsx`)
|
|
67
|
+
- At least one relevant test file (only when `--include-tests` is used)
|
|
68
|
+
|
|
69
|
+
If any are missing, add pins and/or raise budgets before editing.
|