Skip to content

Commit 5840c31

Browse files
tae2089claude
andcommitted
refactor: remove Apache AGE, rename agestore → pgstore
- Remove AGE extension dependency and execute_cypher MCP tool - Remove CLI query command (Cypher) - Rename agestore → pgstore (plain PostgreSQL + pgvector) - Docker: apache/age → pgvector/pgvector:pg16 - 18 MCP tools (back from 19, removed execute_cypher) Architecture simplified: SQLite (local) — GORM + FTS5 PostgreSQL (team) — GORM + tsvector + pgvector No graph DB needed — GORM + Go BFS handles all analysis Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7f61e6d commit 5840c31

9 files changed

Lines changed: 169 additions & 374 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ services:
1313
timeout: 5s
1414
retries: 10
1515

16-
age:
17-
image: apache/age
16+
pgvector:
17+
image: pgvector/pgvector:pg16
1818
environment:
1919
POSTGRES_USER: ccg
2020
POSTGRES_PASSWORD: ccg

internal/cli/build.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
"github.com/imtaebin/code-context-graph/internal/model"
1313
"github.com/imtaebin/code-context-graph/internal/parse"
14-
"github.com/imtaebin/code-context-graph/internal/store/agestore"
14+
"github.com/imtaebin/code-context-graph/internal/store/pgstore"
1515
)
1616

1717
var skipDirs = map[string]bool{
@@ -175,30 +175,30 @@ func newBuildCmd(deps *Deps) *cobra.Command {
175175
}
176176

177177
// Sync to Apache AGE graph + pgvector if --graph flag is set
178-
if syncGraph && deps.AgeStore != nil {
178+
if syncGraph && deps.PGStore != nil {
179179
deps.Logger.Info("syncing to AGE graph")
180-
if err := deps.AgeStore.ClearGraph(ctx); err != nil {
180+
if err := deps.PGStore.ClearGraph(ctx); err != nil {
181181
deps.Logger.Warn("clear graph failed", "error", err)
182182
}
183-
if err := deps.AgeStore.SyncNodes(ctx, indexNodes); err != nil {
183+
if err := deps.PGStore.SyncNodes(ctx, indexNodes); err != nil {
184184
deps.Logger.Warn("sync nodes to AGE failed", "error", err)
185185
} else {
186186
var edges []model.Edge
187187
deps.DB.Find(&edges)
188-
if err := deps.AgeStore.SyncEdges(ctx, edges); err != nil {
188+
if err := deps.PGStore.SyncEdges(ctx, edges); err != nil {
189189
deps.Logger.Warn("sync edges to AGE failed", "error", err)
190190
} else {
191191
deps.Logger.Info("AGE graph synced", "nodes", len(indexNodes), "edges", len(edges))
192192
}
193193
}
194194

195195
// Sync pgvector documents for semantic search
196-
if err := deps.AgeStore.InitPGVector(ctx); err != nil {
196+
if err := deps.PGStore.InitPGVector(ctx); err != nil {
197197
deps.Logger.Warn("pgvector init failed", "error", err)
198198
} else {
199-
var pvDocs []agestore.PGVectorDocument
199+
var pvDocs []pgstore.PGVectorDocument
200200
for _, n := range indexNodes {
201-
pvDocs = append(pvDocs, agestore.PGVectorDocument{
201+
pvDocs = append(pvDocs, pgstore.PGVectorDocument{
202202
NodeID: n.ID,
203203
Content: buildContent(n),
204204
Metadata: map[string]string{
@@ -209,7 +209,7 @@ func newBuildCmd(deps *Deps) *cobra.Command {
209209
},
210210
})
211211
}
212-
if err := deps.AgeStore.SyncPGVectorDocuments(ctx, pvDocs); err != nil {
212+
if err := deps.PGStore.SyncPGVectorDocuments(ctx, pvDocs); err != nil {
213213
deps.Logger.Warn("pgvector sync failed", "error", err)
214214
} else {
215215
deps.Logger.Info("pgvector documents synced", "documents", len(pvDocs))

internal/cli/query.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

internal/cli/root.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"gorm.io/gorm"
1010

1111
"github.com/imtaebin/code-context-graph/internal/analysis/incremental"
12-
"github.com/imtaebin/code-context-graph/internal/store/agestore"
12+
"github.com/imtaebin/code-context-graph/internal/store/pgstore"
1313
"github.com/imtaebin/code-context-graph/internal/parse/treesitter"
1414
"github.com/imtaebin/code-context-graph/internal/store"
1515
"github.com/imtaebin/code-context-graph/internal/store/search"
@@ -24,7 +24,7 @@ type Deps struct {
2424
Walkers map[string]*treesitter.Walker
2525
Syncer *incremental.Syncer
2626
ServeFunc func(cfg ServeConfig) error
27-
AgeStore *agestore.Store
27+
PGStore *pgstore.Store
2828
}
2929

3030
// NewRootCmd creates the root cobra command with all subcommands attached.
@@ -72,7 +72,6 @@ func NewRootCmd(deps *Deps) *cobra.Command {
7272
newStatusCmd(deps),
7373
newSearchCmd(deps),
7474
newServeCmd(deps),
75-
newQueryCmd(deps),
7675
)
7776

7877
return rootCmd

internal/mcp/handlers.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,26 +1109,3 @@ func getBool(request mcp.CallToolRequest, name string, defaultVal bool) bool {
11091109
}
11101110
return defaultVal
11111111
}
1112-
1113-
func (h *handlers) executeCypher(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
1114-
log := h.logger()
1115-
1116-
cypher, err := request.RequireString("cypher")
1117-
if err != nil {
1118-
return mcp.NewToolResultError(fmt.Sprintf("missing parameter: %v", err)), nil
1119-
}
1120-
columns := request.GetInt("columns", 1)
1121-
1122-
log.Info("execute_cypher called", "cypher", cypher, "columns", columns)
1123-
1124-
if h.deps.AgeStore == nil {
1125-
return mcp.NewToolResultError("Apache AGE not configured — start with AGE_DSN environment variable"), nil
1126-
}
1127-
1128-
result, err := h.deps.AgeStore.ExecuteCypherJSON(ctx, cypher, columns)
1129-
if err != nil {
1130-
return mcp.NewToolResultError(fmt.Sprintf("cypher error: %v", err)), nil
1131-
}
1132-
1133-
return mcp.NewToolResultText(result), nil
1134-
}

internal/mcp/server.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/imtaebin/code-context-graph/internal/analysis/query"
2020
"github.com/imtaebin/code-context-graph/internal/model"
2121
"github.com/imtaebin/code-context-graph/internal/store"
22-
"github.com/imtaebin/code-context-graph/internal/store/agestore"
2322
storesearch "github.com/imtaebin/code-context-graph/internal/store/search"
2423
)
2524

@@ -89,7 +88,6 @@ type Deps struct {
8988
CoverageAnalyzer CoverageAnalyzer
9089
CommunityBuilder CommunityBuilder
9190
Incremental IncrementalSyncer
92-
AgeStore *agestore.Store
9391
}
9492

9593
func NewServer(deps *Deps) *server.MCPServer {
@@ -246,16 +244,9 @@ func NewServer(deps *Deps) *server.MCPServer {
246244
),
247245
Handler: h.findDeadCode,
248246
},
249-
server.ServerTool{
250-
Tool: mcp.NewTool("execute_cypher",
251-
mcp.WithDescription("Execute a Cypher query on the Apache AGE code graph. Use this for custom graph traversals, path finding, pattern matching, and impact analysis."),
252-
mcp.WithString("cypher", mcp.Description("Cypher query string (e.g. MATCH (n:Function)-[:CALLS]->(m) RETURN n, m)"), mcp.Required()),
253-
),
254-
Handler: h.executeCypher,
255-
},
256247
)
257248

258-
log.Info("MCP server created", "name", "code-context-graph", "version", "1.0.0", "tools", 19, "prompts", 5)
249+
log.Info("MCP server created", "name", "code-context-graph", "version", "1.0.0", "tools", 18, "prompts", 5)
259250

260251
p := &promptHandlers{deps: deps}
261252
srv.AddPrompts(

internal/mcp/server_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func TestMCPServer_ListTools(t *testing.T) {
3030
"get_community",
3131
"get_architecture_overview",
3232
"find_dead_code",
33-
"execute_cypher",
3433
}
3534

3635
if len(tools) != len(expected) {
@@ -55,13 +54,13 @@ func TestMCPServer_Start(t *testing.T) {
5554
var _ *server.MCPServer = srv
5655
}
5756

58-
func TestMCPServer_ListTools_19(t *testing.T) {
57+
func TestMCPServer_ListTools_18(t *testing.T) {
5958
deps := &Deps{}
6059
srv := NewServer(deps)
6160
tools := srv.ListTools()
6261

63-
if len(tools) != 19 {
64-
t.Fatalf("expected 19 tools, got %d", len(tools))
62+
if len(tools) != 18 {
63+
t.Fatalf("expected 18 tools, got %d", len(tools))
6564
}
6665
}
6766

0 commit comments

Comments
 (0)