diff --git a/internal/cli/commands/hook.go b/internal/cli/commands/hook.go index f0a5b37..3c9275f 100644 --- a/internal/cli/commands/hook.go +++ b/internal/cli/commands/hook.go @@ -68,7 +68,7 @@ var hookPreToolCmd = &cobra.Command{ isLeaTool = true } else { // Fallback: check if the tool name matches one of our MCP tools - leaTools := []string{"impact", "flow", "neighbors", "violations", "symbols"} + leaTools := []string{"impact", "flow", "neighbors", "violations", "symbols", "view_symbol_ast", "trace_execution_path"} for _, t := range leaTools { if lowerName == t || strings.HasSuffix(lowerName, "__"+t) || strings.HasSuffix(lowerName, "/"+t) { isLeaTool = true @@ -115,7 +115,8 @@ var hookPreToolCmd = &cobra.Command{ dbPath := filepath.Join(leaDir, "graph.db") store, err := sqlite.NewStore(dbPath) if err != nil { - os.Exit(0) + fmt.Fprintf(os.Stderr, "Error opening store: %v\n", err) + os.Exit(2) } defer func() { _ = store.Close() }() diff --git a/internal/mcp/install/install.go b/internal/mcp/install/install.go index 9ddb7af..fcdfca5 100644 --- a/internal/mcp/install/install.go +++ b/internal/mcp/install/install.go @@ -663,13 +663,16 @@ func writeTOML(path string, v map[string]any) error { // writeInstructions writes the global Pizen ecosystem instructions file. func writeInstructions(path string) error { - content := `# PizenLabs Ecosystem — Dual-Tool Orchestration + content := `# MANDATORY WORKSPACE TOOL SELECTION RULES -CRITICAL: For code-related queries, ALWAYS run pizen-lynx (via search or resolve) -first to discover the exact Symbol ID. DO NOT guess the code structure. +This repository utilizes custom AST-aware and graph-indexed tools (search_graph, resolve_symbol, view_symbol_ast, trace_execution_path). These are highly optimized for PizenLabs' internal architecture. -Once the Symbol ID is retrieved, immediately pass it to pizen-lea (via impact, -flow, or neighbors) to map structural reasoning and blast radius. +## 1. Tool Priority Queue (Strict Compliance) +1. **FIRST PRIORITY (Structure & Lookups):** Always invoke search_graph and view_symbol_ast directly when searching for code, analyzing failing tests, or viewing context. +2. **LAST RESORT (Fallback Only):** You may only use generic fallback tools (like codebase-memory-mcp_*, grep, or glob) if and only if the primary tools yield zero results. + +## 2. Enforcement +Before executing any tool call, verify that you are leveraging the custom AST-aware commands first. Guessing file paths via generic tools before attempting a structured lookup is penalized. ` return os.WriteFile(path, []byte(content), 0644) } @@ -683,13 +686,16 @@ func writeInstructionsFile(t target) error { return err } path := filepath.Join(t.ConfigDir, t.InstructionFile) - content := `# PizenLabs Ecosystem — Dual-Tool Orchestration + content := `# MANDATORY WORKSPACE TOOL SELECTION RULES + +This repository utilizes custom AST-aware and graph-indexed tools (search_graph, resolve_symbol, view_symbol_ast, trace_execution_path). These are highly optimized for PizenLabs' internal architecture. -CRITICAL: For code-related queries, ALWAYS run pizen-lynx (via search or resolve) -first to discover the exact Symbol ID. DO NOT guess the code structure. +## 1. Tool Priority Queue (Strict Compliance) +1. **FIRST PRIORITY (Structure & Lookups):** Always invoke search_graph and view_symbol_ast directly when searching for code, analyzing failing tests, or viewing context. +2. **LAST RESORT (Fallback Only):** You may only use generic fallback tools (like codebase-memory-mcp_*, grep, or glob) if and only if the primary tools yield zero results. -Once the Symbol ID is retrieved, immediately pass it to pizen-lea (via impact, -flow, or neighbors) to map structural reasoning and blast radius. +## 2. Enforcement +Before executing any tool call, verify that you are leveraging the custom AST-aware commands first. Guessing file paths via generic tools before attempting a structured lookup is penalized. ` return os.WriteFile(path, []byte(content), 0644) } diff --git a/internal/mcp/server.go b/internal/mcp/server.go index 1d30100..0aaa03c 100644 --- a/internal/mcp/server.go +++ b/internal/mcp/server.go @@ -30,7 +30,7 @@ type Server struct { // Tool Arguments // ----------------------------------------------------------------------------- -// GetSymbolContextArgs defines the input for the get_symbol_context tool. +// GetSymbolContextArgs defines the input for the view_symbol_ast tool. type GetSymbolContextArgs struct { SymbolID string `json:"symbol_id" jsonschema:"description=The unique symbol ID (e.g. func:path:name)"` } @@ -132,7 +132,7 @@ func (s *Server) registerTools(server *mcp_golang.Server) error { // registerGetSymbolContextTool registers the symbol context compiler tool. func (s *Server) registerGetSymbolContextTool(server *mcp_golang.Server) error { return server.RegisterTool( - "get_symbol_context", + "view_symbol_ast", "Generates AI-optimized markdown context for a symbol", func( ctx context.Context,