@herjarsa/omo-meta-governor 0.13.1 → 0.14.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.
@@ -0,0 +1,100 @@
1
+ /**
2
+ * codegraph-tools — high-level wrappers around codegraph's sub-commands
3
+ * (node, callers, impact, files) for use in custom tools.
4
+ *
5
+ * codegraph is invoked via the `codegraph` CLI (not via MCP). Available
6
+ * sub-commands we wrap here:
7
+ * - codegraph node <symbol> → get source + callers of a symbol
8
+ * - codegraph callers <symbol> → list call sites of a symbol
9
+ * - codegraph impact <symbol> → full impact analysis (callers + tests + docs)
10
+ * - codegraph files → list indexed files
11
+ *
12
+ * v0.14.0 adds these on top of the v0.13.0 `omo_search` (which uses
13
+ * `codegraph explore`). Together they give the LLM a full codegraph
14
+ * toolkit: search, find, callers, impact, files.
15
+ *
16
+ * Design:
17
+ * - Pure CLI invocation via GraphRetrieval (which already handles
18
+ * timeout, error catching, and graceful degradation)
19
+ * - Each function returns null when the tool is unavailable — the
20
+ * caller decides what to do (e.g., suggest a fallback)
21
+ * - All functions take cwd + optional cli path override
22
+ */
23
+ import { type GraphRetrieval } from "./graph-retrieval";
24
+ export interface OmoFindResult {
25
+ /** The symbol that was searched */
26
+ symbol: string;
27
+ /** Source code of the definition (formatted) */
28
+ source: string | null;
29
+ /** List of call sites (file:line format) */
30
+ callers: Array<{
31
+ file: string;
32
+ line: number;
33
+ context: string;
34
+ }>;
35
+ /** True if the symbol was found */
36
+ found: boolean;
37
+ /** Tool that produced the result */
38
+ kind: "codegraph" | "graphify" | null;
39
+ /** Total time taken */
40
+ durationMs: number;
41
+ }
42
+ export interface OmoImpactResult {
43
+ /** The symbol being analyzed */
44
+ symbol: string;
45
+ /** Direct callers (file:line) */
46
+ directCallers: Array<{
47
+ file: string;
48
+ line: number;
49
+ context: string;
50
+ }>;
51
+ /** Transitive callers (if available from the tool) */
52
+ transitiveCallers: Array<{
53
+ file: string;
54
+ line: number;
55
+ context: string;
56
+ }>;
57
+ /** Test files affected (if available) */
58
+ testFiles: string[];
59
+ /** Documentation files affected (if available) */
60
+ docFiles: string[];
61
+ /** Total affected file count */
62
+ totalAffectedFiles: number;
63
+ /** Tool that produced the result */
64
+ kind: "codegraph" | "graphify" | null;
65
+ /** Total time taken */
66
+ durationMs: number;
67
+ /** Whether the analysis timed out */
68
+ timedOut: boolean;
69
+ }
70
+ export interface OmoFilesResult {
71
+ files: string[];
72
+ count: number;
73
+ kind: "codegraph" | "graphify" | null;
74
+ durationMs: number;
75
+ }
76
+ /**
77
+ * Default entry point: use the singleton GraphRetrieval.
78
+ * Tests can construct their own CodeGraphTools with a custom instance.
79
+ */
80
+ export declare class CodeGraphTools {
81
+ private retrieval;
82
+ constructor(retrieval?: GraphRetrieval);
83
+ /**
84
+ * Find a symbol's definition and direct callers.
85
+ * Uses `codegraph node <symbol>` for codegraph, `graphify query <symbol>` for graphify.
86
+ */
87
+ find(symbol: string, cwd: string, timeoutMs?: number): Promise<OmoFindResult>;
88
+ /**
89
+ * Analyze the impact of changing a symbol. Lists direct callers,
90
+ * transitive callers, and affected test/doc files.
91
+ * Uses `codegraph impact <symbol>` if available, else `codegraph callers`.
92
+ */
93
+ impact(symbol: string, cwd: string, timeoutMs?: number): Promise<OmoImpactResult>;
94
+ /**
95
+ * List indexed files. Uses `codegraph files`.
96
+ */
97
+ listFiles(cwd: string, timeoutMs?: number): Promise<OmoFilesResult>;
98
+ }
99
+ /** Returns the process-wide CodeGraphTools singleton. */
100
+ export declare function getDefaultCodeGraphTools(): CodeGraphTools;
@@ -22,6 +22,7 @@ import { type ToolContext, type ToolResult } from "@opencode-ai/plugin";
22
22
  import type { SqliteBackend } from "./sqlite-backend";
23
23
  import type { GraphRetrieval } from "./graph-retrieval";
24
24
  import type { MetricsCollector } from "./metrics";
25
+ import { type CodeGraphTools } from "./codegraph-tools";
25
26
  export interface OmoSearchDeps {
26
27
  graphRetrieval: GraphRetrieval;
27
28
  cwd: string;
@@ -73,3 +74,145 @@ export declare function buildOmoHealthTool(deps: OmoHealthDeps): {
73
74
  args: {};
74
75
  execute(args: Record<string, never>, context: ToolContext): Promise<ToolResult>;
75
76
  };
77
+ export interface OmoFindDeps {
78
+ codeGraph?: CodeGraphTools;
79
+ cwd: string;
80
+ }
81
+ /**
82
+ * Build the `omo_find` tool. Resolves a symbol to its source code location
83
+ * and lists direct call sites. Uses `codegraph node <symbol>` (with
84
+ * `graphify query <symbol>` as fallback when codegraph is unavailable).
85
+ */
86
+ export declare function buildOmoFindTool(deps: OmoFindDeps): {
87
+ description: string;
88
+ args: {
89
+ symbol: import("zod").ZodString;
90
+ };
91
+ execute(args: {
92
+ symbol: string;
93
+ }, context: ToolContext): Promise<ToolResult>;
94
+ };
95
+ export interface OmoImpactDeps {
96
+ codeGraph?: CodeGraphTools;
97
+ cwd: string;
98
+ }
99
+ /**
100
+ * Build the `omo_impact` tool. Lists all call sites of a symbol plus
101
+ * affected test and doc files. Uses `codegraph impact <symbol>` (falls
102
+ * back to `codegraph callers` when impact is unavailable).
103
+ */
104
+ export declare function buildOmoImpactTool(deps: OmoImpactDeps): {
105
+ description: string;
106
+ args: {
107
+ symbol: import("zod").ZodString;
108
+ };
109
+ execute(args: {
110
+ symbol: string;
111
+ }, context: ToolContext): Promise<ToolResult>;
112
+ };
113
+ export interface OmoRememberDeps {
114
+ }
115
+ /**
116
+ * Build the `omo_remember` tool. Persists a fact/observation/lesson to
117
+ * AgentMemory by instructing the LLM to call `agentmemory_memory_save`.
118
+ */
119
+ export declare function buildOmoRememberTool(deps: OmoRememberDeps): {
120
+ description: string;
121
+ args: {
122
+ content: import("zod").ZodString;
123
+ concepts: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
124
+ type: import("zod").ZodOptional<import("zod").ZodEnum<{
125
+ pattern: "pattern";
126
+ fact: "fact";
127
+ observation: "observation";
128
+ }>>;
129
+ };
130
+ execute(args: {
131
+ content: string;
132
+ concepts?: string[] | undefined;
133
+ type?: "pattern" | "fact" | "observation" | undefined;
134
+ }, context: ToolContext): Promise<ToolResult>;
135
+ };
136
+ export interface OmoRecallMcpDeps {
137
+ }
138
+ /**
139
+ * Build the `omo_recall_mcp` tool. Searches AgentMemory by sending a
140
+ * query to the LLM that triggers `agentmemory_memory_smart_search`.
141
+ *
142
+ * Note: prefer `omo_recall` (which queries SQLite FTS5 locally) for fast
143
+ * local recall. Use `omo_recall_mcp` when you specifically need to search
144
+ * AgentMemory's persistent cross-session memory.
145
+ */
146
+ export declare function buildOmoRecallMcpTool(deps: OmoRecallMcpDeps): {
147
+ description: string;
148
+ args: {
149
+ query: import("zod").ZodString;
150
+ limit: import("zod").ZodOptional<import("zod").ZodNumber>;
151
+ };
152
+ execute(args: {
153
+ query: string;
154
+ limit?: number | undefined;
155
+ }, context: ToolContext): Promise<ToolResult>;
156
+ };
157
+ export interface OmoRuleDeps {
158
+ }
159
+ /**
160
+ * Build the `omo_rule` tool. Saves a durable rule to Magic Context that
161
+ * persists across sessions. Categorized by type (PROJECT_RULES, ARCHITECTURE,
162
+ * CONSTRAINTS, CONFIG_VALUES, NAMING). Uses `ctx_memory(action="write")`.
163
+ */
164
+ export declare function buildOmoRuleTool(deps: OmoRuleDeps): {
165
+ description: string;
166
+ args: {
167
+ category: import("zod").ZodEnum<{
168
+ PROJECT_RULES: "PROJECT_RULES";
169
+ ARCHITECTURE: "ARCHITECTURE";
170
+ CONSTRAINTS: "CONSTRAINTS";
171
+ CONFIG_VALUES: "CONFIG_VALUES";
172
+ NAMING: "NAMING";
173
+ }>;
174
+ content: import("zod").ZodString;
175
+ };
176
+ execute(args: {
177
+ category: "PROJECT_RULES" | "ARCHITECTURE" | "CONSTRAINTS" | "CONFIG_VALUES" | "NAMING";
178
+ content: string;
179
+ }, context: ToolContext): Promise<ToolResult>;
180
+ };
181
+ export interface OmoHistoryDeps {
182
+ }
183
+ /**
184
+ * Build the `omo_history` tool. Searches git commit history and prior
185
+ * conversations via Magic Context. Uses `ctx_search` with sources=["git_commit", "message"].
186
+ */
187
+ export declare function buildOmoHistoryTool(deps: OmoHistoryDeps): {
188
+ description: string;
189
+ args: {
190
+ query: import("zod").ZodString;
191
+ sources: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
192
+ message: "message";
193
+ git_commit: "git_commit";
194
+ }>>>;
195
+ };
196
+ execute(args: {
197
+ query: string;
198
+ sources?: ("message" | "git_commit")[] | undefined;
199
+ }, context: ToolContext): Promise<ToolResult>;
200
+ };
201
+ export interface OmoNoteDeps {
202
+ }
203
+ /**
204
+ * Build the `omo_note` tool. Writes a session-scoped working note via
205
+ * Magic Context. Notes are for the current task only (ephemeral context).
206
+ * Uses `ctx_note(action="write")`.
207
+ */
208
+ export declare function buildOmoNoteTool(deps: OmoNoteDeps): {
209
+ description: string;
210
+ args: {
211
+ content: import("zod").ZodString;
212
+ surfaceCondition: import("zod").ZodOptional<import("zod").ZodString>;
213
+ };
214
+ execute(args: {
215
+ content: string;
216
+ surfaceCondition?: string | undefined;
217
+ }, context: ToolContext): Promise<ToolResult>;
218
+ };
@@ -88,6 +88,32 @@ export declare class GraphRetrieval {
88
88
  */
89
89
  invoke(projectDir: string, query: string, options?: InvokeOptions): Promise<GraphInvocationResult>;
90
90
  private spawnWithTimeout;
91
+ /**
92
+ * Get the source code and direct callers of a symbol.
93
+ * Runs `codegraph node <symbol> --project-path <cwd>`.
94
+ */
95
+ invokeNode(symbol: string, projectDir: string, options?: InvokeOptions): Promise<GraphInvocationResult>;
96
+ /**
97
+ * List all call sites of a symbol.
98
+ * Runs `codegraph callers <symbol> --project-path <cwd>`.
99
+ */
100
+ invokeCallers(symbol: string, projectDir: string, options?: InvokeOptions): Promise<GraphInvocationResult>;
101
+ /**
102
+ * Full impact analysis: direct callers, transitive callers,
103
+ * affected test files, affected doc files.
104
+ * Runs `codegraph impact <symbol> --project-path <cwd>`.
105
+ */
106
+ invokeImpact(symbol: string, projectDir: string, options?: InvokeOptions): Promise<GraphInvocationResult>;
107
+ /**
108
+ * List all indexed files.
109
+ * Runs `codegraph files --project-path <cwd>`.
110
+ */
111
+ invokeFiles(projectDir: string, options?: InvokeOptions): Promise<GraphInvocationResult>;
112
+ /**
113
+ * Run a codegraph sub-command and return the result.
114
+ * Returns null result if codegraph is not available.
115
+ */
116
+ private invokeCodegraphSubcommand;
91
117
  }
92
118
  /** Returns the process-wide singleton, creating it on first use. */
93
119
  export declare function getDefaultGraphRetrieval(): GraphRetrieval;