@mka-rainmaker/ama 0.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.
Files changed (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/dist/analyzers/baseline/analyzer.d.ts +47 -0
  4. package/dist/analyzers/baseline/analyzer.d.ts.map +1 -0
  5. package/dist/analyzers/baseline/analyzer.js +84 -0
  6. package/dist/analyzers/baseline/analyzer.js.map +1 -0
  7. package/dist/analyzers/baseline/c.d.ts +12 -0
  8. package/dist/analyzers/baseline/c.d.ts.map +1 -0
  9. package/dist/analyzers/baseline/c.js +56 -0
  10. package/dist/analyzers/baseline/c.js.map +1 -0
  11. package/dist/analyzers/baseline/config.d.ts +21 -0
  12. package/dist/analyzers/baseline/config.d.ts.map +1 -0
  13. package/dist/analyzers/baseline/config.js +32 -0
  14. package/dist/analyzers/baseline/config.js.map +1 -0
  15. package/dist/analyzers/baseline/csharp.d.ts +9 -0
  16. package/dist/analyzers/baseline/csharp.d.ts.map +1 -0
  17. package/dist/analyzers/baseline/csharp.js +107 -0
  18. package/dist/analyzers/baseline/csharp.js.map +1 -0
  19. package/dist/analyzers/baseline/go.d.ts +11 -0
  20. package/dist/analyzers/baseline/go.d.ts.map +1 -0
  21. package/dist/analyzers/baseline/go.js +66 -0
  22. package/dist/analyzers/baseline/go.js.map +1 -0
  23. package/dist/analyzers/baseline/java.d.ts +9 -0
  24. package/dist/analyzers/baseline/java.d.ts.map +1 -0
  25. package/dist/analyzers/baseline/java.js +50 -0
  26. package/dist/analyzers/baseline/java.js.map +1 -0
  27. package/dist/analyzers/baseline/javascript.d.ts +10 -0
  28. package/dist/analyzers/baseline/javascript.d.ts.map +1 -0
  29. package/dist/analyzers/baseline/javascript.js +55 -0
  30. package/dist/analyzers/baseline/javascript.js.map +1 -0
  31. package/dist/analyzers/baseline/kotlin.d.ts +11 -0
  32. package/dist/analyzers/baseline/kotlin.d.ts.map +1 -0
  33. package/dist/analyzers/baseline/kotlin.js +67 -0
  34. package/dist/analyzers/baseline/kotlin.js.map +1 -0
  35. package/dist/analyzers/baseline/paths.d.ts +6 -0
  36. package/dist/analyzers/baseline/paths.d.ts.map +1 -0
  37. package/dist/analyzers/baseline/paths.js +17 -0
  38. package/dist/analyzers/baseline/paths.js.map +1 -0
  39. package/dist/analyzers/baseline/php.d.ts +11 -0
  40. package/dist/analyzers/baseline/php.d.ts.map +1 -0
  41. package/dist/analyzers/baseline/php.js +76 -0
  42. package/dist/analyzers/baseline/php.js.map +1 -0
  43. package/dist/analyzers/baseline/python.d.ts +10 -0
  44. package/dist/analyzers/baseline/python.d.ts.map +1 -0
  45. package/dist/analyzers/baseline/python.js +63 -0
  46. package/dist/analyzers/baseline/python.js.map +1 -0
  47. package/dist/analyzers/baseline/rust.d.ts +10 -0
  48. package/dist/analyzers/baseline/rust.d.ts.map +1 -0
  49. package/dist/analyzers/baseline/rust.js +45 -0
  50. package/dist/analyzers/baseline/rust.js.map +1 -0
  51. package/dist/analyzers/baseline/swift.d.ts +11 -0
  52. package/dist/analyzers/baseline/swift.d.ts.map +1 -0
  53. package/dist/analyzers/baseline/swift.js +19 -0
  54. package/dist/analyzers/baseline/swift.js.map +1 -0
  55. package/dist/analyzers/baseline/treesitter.d.ts +11 -0
  56. package/dist/analyzers/baseline/treesitter.d.ts.map +1 -0
  57. package/dist/analyzers/baseline/treesitter.js +87 -0
  58. package/dist/analyzers/baseline/treesitter.js.map +1 -0
  59. package/dist/analyzers/baseline/walk.d.ts +26 -0
  60. package/dist/analyzers/baseline/walk.d.ts.map +1 -0
  61. package/dist/analyzers/baseline/walk.js +76 -0
  62. package/dist/analyzers/baseline/walk.js.map +1 -0
  63. package/dist/analyzers/registry.d.ts +19 -0
  64. package/dist/analyzers/registry.d.ts.map +1 -0
  65. package/dist/analyzers/registry.js +43 -0
  66. package/dist/analyzers/registry.js.map +1 -0
  67. package/dist/analyzers/sfc/analyzer.d.ts +17 -0
  68. package/dist/analyzers/sfc/analyzer.d.ts.map +1 -0
  69. package/dist/analyzers/sfc/analyzer.js +141 -0
  70. package/dist/analyzers/sfc/analyzer.js.map +1 -0
  71. package/dist/analyzers/sidecar/analyzer.d.ts +29 -0
  72. package/dist/analyzers/sidecar/analyzer.d.ts.map +1 -0
  73. package/dist/analyzers/sidecar/analyzer.js +114 -0
  74. package/dist/analyzers/sidecar/analyzer.js.map +1 -0
  75. package/dist/analyzers/sidecar/protocol.d.ts +508 -0
  76. package/dist/analyzers/sidecar/protocol.d.ts.map +1 -0
  77. package/dist/analyzers/sidecar/protocol.js +102 -0
  78. package/dist/analyzers/sidecar/protocol.js.map +1 -0
  79. package/dist/analyzers/types.d.ts +46 -0
  80. package/dist/analyzers/types.d.ts.map +1 -0
  81. package/dist/analyzers/types.js +2 -0
  82. package/dist/analyzers/types.js.map +1 -0
  83. package/dist/analyzers/typescript/analyzer.d.ts +126 -0
  84. package/dist/analyzers/typescript/analyzer.d.ts.map +1 -0
  85. package/dist/analyzers/typescript/analyzer.js +1600 -0
  86. package/dist/analyzers/typescript/analyzer.js.map +1 -0
  87. package/dist/cli/commands/cycles.d.ts +6 -0
  88. package/dist/cli/commands/cycles.d.ts.map +1 -0
  89. package/dist/cli/commands/cycles.js +27 -0
  90. package/dist/cli/commands/cycles.js.map +1 -0
  91. package/dist/cli/commands/files.d.ts +6 -0
  92. package/dist/cli/commands/files.d.ts.map +1 -0
  93. package/dist/cli/commands/files.js +33 -0
  94. package/dist/cli/commands/files.js.map +1 -0
  95. package/dist/cli/commands/impact.d.ts +18 -0
  96. package/dist/cli/commands/impact.d.ts.map +1 -0
  97. package/dist/cli/commands/impact.js +113 -0
  98. package/dist/cli/commands/impact.js.map +1 -0
  99. package/dist/cli/commands/lifecycle.d.ts +5 -0
  100. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  101. package/dist/cli/commands/lifecycle.js +83 -0
  102. package/dist/cli/commands/lifecycle.js.map +1 -0
  103. package/dist/cli/commands/query.d.ts +31 -0
  104. package/dist/cli/commands/query.d.ts.map +1 -0
  105. package/dist/cli/commands/query.js +187 -0
  106. package/dist/cli/commands/query.js.map +1 -0
  107. package/dist/cli/commands/search.d.ts +21 -0
  108. package/dist/cli/commands/search.d.ts.map +1 -0
  109. package/dist/cli/commands/search.js +160 -0
  110. package/dist/cli/commands/search.js.map +1 -0
  111. package/dist/cli/commands/status.d.ts +6 -0
  112. package/dist/cli/commands/status.d.ts.map +1 -0
  113. package/dist/cli/commands/status.js +63 -0
  114. package/dist/cli/commands/status.js.map +1 -0
  115. package/dist/cli/commands/sync.d.ts +6 -0
  116. package/dist/cli/commands/sync.d.ts.map +1 -0
  117. package/dist/cli/commands/sync.js +57 -0
  118. package/dist/cli/commands/sync.js.map +1 -0
  119. package/dist/cli/emit.d.ts +9 -0
  120. package/dist/cli/emit.d.ts.map +1 -0
  121. package/dist/cli/emit.js +10 -0
  122. package/dist/cli/emit.js.map +1 -0
  123. package/dist/cli/index.d.ts +37 -0
  124. package/dist/cli/index.d.ts.map +1 -0
  125. package/dist/cli/index.js +128 -0
  126. package/dist/cli/index.js.map +1 -0
  127. package/dist/cli/paths.d.ts +7 -0
  128. package/dist/cli/paths.d.ts.map +1 -0
  129. package/dist/cli/paths.js +10 -0
  130. package/dist/cli/paths.js.map +1 -0
  131. package/dist/cli/query-runner.d.ts +13 -0
  132. package/dist/cli/query-runner.d.ts.map +1 -0
  133. package/dist/cli/query-runner.js +33 -0
  134. package/dist/cli/query-runner.js.map +1 -0
  135. package/dist/graph/dispatch.d.ts +17 -0
  136. package/dist/graph/dispatch.d.ts.map +1 -0
  137. package/dist/graph/dispatch.js +82 -0
  138. package/dist/graph/dispatch.js.map +1 -0
  139. package/dist/graph/id.d.ts +19 -0
  140. package/dist/graph/id.d.ts.map +1 -0
  141. package/dist/graph/id.js +17 -0
  142. package/dist/graph/id.js.map +1 -0
  143. package/dist/graph/index.d.ts +6 -0
  144. package/dist/graph/index.d.ts.map +1 -0
  145. package/dist/graph/index.js +4 -0
  146. package/dist/graph/index.js.map +1 -0
  147. package/dist/graph/types.d.ts +71 -0
  148. package/dist/graph/types.d.ts.map +1 -0
  149. package/dist/graph/types.js +52 -0
  150. package/dist/graph/types.js.map +1 -0
  151. package/dist/indexer/debouncer.d.ts +32 -0
  152. package/dist/indexer/debouncer.d.ts.map +1 -0
  153. package/dist/indexer/debouncer.js +81 -0
  154. package/dist/indexer/debouncer.js.map +1 -0
  155. package/dist/indexer/ignore.d.ts +55 -0
  156. package/dist/indexer/ignore.d.ts.map +1 -0
  157. package/dist/indexer/ignore.js +170 -0
  158. package/dist/indexer/ignore.js.map +1 -0
  159. package/dist/indexer/indexer.d.ts +112 -0
  160. package/dist/indexer/indexer.d.ts.map +1 -0
  161. package/dist/indexer/indexer.js +392 -0
  162. package/dist/indexer/indexer.js.map +1 -0
  163. package/dist/indexer/watcher.d.ts +50 -0
  164. package/dist/indexer/watcher.d.ts.map +1 -0
  165. package/dist/indexer/watcher.js +86 -0
  166. package/dist/indexer/watcher.js.map +1 -0
  167. package/dist/mcp/build-info.d.ts +16 -0
  168. package/dist/mcp/build-info.d.ts.map +1 -0
  169. package/dist/mcp/build-info.js +54 -0
  170. package/dist/mcp/build-info.js.map +1 -0
  171. package/dist/mcp/http.d.ts +18 -0
  172. package/dist/mcp/http.d.ts.map +1 -0
  173. package/dist/mcp/http.js +145 -0
  174. package/dist/mcp/http.js.map +1 -0
  175. package/dist/mcp/server.d.ts +22 -0
  176. package/dist/mcp/server.d.ts.map +1 -0
  177. package/dist/mcp/server.js +401 -0
  178. package/dist/mcp/server.js.map +1 -0
  179. package/dist/mcp/session.d.ts +155 -0
  180. package/dist/mcp/session.d.ts.map +1 -0
  181. package/dist/mcp/session.js +319 -0
  182. package/dist/mcp/session.js.map +1 -0
  183. package/dist/query/service.d.ts +329 -0
  184. package/dist/query/service.d.ts.map +1 -0
  185. package/dist/query/service.js +959 -0
  186. package/dist/query/service.js.map +1 -0
  187. package/dist/runtime/entrypoint.d.ts +11 -0
  188. package/dist/runtime/entrypoint.d.ts.map +1 -0
  189. package/dist/runtime/entrypoint.js +22 -0
  190. package/dist/runtime/entrypoint.js.map +1 -0
  191. package/dist/runtime/quiet-sqlite-warning.d.ts +14 -0
  192. package/dist/runtime/quiet-sqlite-warning.d.ts.map +1 -0
  193. package/dist/runtime/quiet-sqlite-warning.js +26 -0
  194. package/dist/runtime/quiet-sqlite-warning.js.map +1 -0
  195. package/dist/runtime/wasm-tier.d.ts +2 -0
  196. package/dist/runtime/wasm-tier.d.ts.map +1 -0
  197. package/dist/runtime/wasm-tier.js +54 -0
  198. package/dist/runtime/wasm-tier.js.map +1 -0
  199. package/dist/store/memory.d.ts +54 -0
  200. package/dist/store/memory.d.ts.map +1 -0
  201. package/dist/store/memory.js +210 -0
  202. package/dist/store/memory.js.map +1 -0
  203. package/dist/store/sqlite.d.ts +38 -0
  204. package/dist/store/sqlite.d.ts.map +1 -0
  205. package/dist/store/sqlite.js +298 -0
  206. package/dist/store/sqlite.js.map +1 -0
  207. package/dist/store/types.d.ts +76 -0
  208. package/dist/store/types.d.ts.map +1 -0
  209. package/dist/store/types.js +2 -0
  210. package/dist/store/types.js.map +1 -0
  211. package/package.json +59 -0
@@ -0,0 +1,155 @@
1
+ import type { ResolutionStats } from "../analyzers/types.js";
2
+ import type { GraphNode } from "../graph/index.js";
3
+ import type { IndexStats, Indexer, LanguageCoverage, SyncResult } from "../indexer/indexer.js";
4
+ import { type WatchSource } from "../indexer/watcher.js";
5
+ import type { EdgeNeighbor, Exploration, FileSkeleton, GraphSchema, NodeView, SearchOptions, SearchResult, Snippet } from "../query/service.js";
6
+ import { type ServerStamp } from "./build-info.js";
7
+ export type IndexStatus = {
8
+ indexed: false;
9
+ server: ServerStamp;
10
+ } | {
11
+ indexed: true;
12
+ root: string;
13
+ nodeCount: number;
14
+ edgeCount: number;
15
+ fileCount: number;
16
+ languages: LanguageCoverage[];
17
+ /** Call-resolution coverage (resolved vs total attributable call sites), when
18
+ * measured — an honest signal of how complete the call graph is. */
19
+ resolution?: ResolutionStats;
20
+ /** Edits the auto-syncer has queued but not yet re-indexed (0 if not watching). */
21
+ pendingSync: number;
22
+ /** Every indexed project (root + counts). The top-level root/counts above are the
23
+ * primary (last-indexed) project; this lists all of them for a multi-project
24
+ * session, so a caller can see what `projectPath` values are queryable. (ama-ont) */
25
+ projects: {
26
+ root: string;
27
+ nodeCount: number;
28
+ edgeCount: number;
29
+ fileCount: number;
30
+ }[];
31
+ /** Running-server build stamp, for detecting a stale server (see build-info). */
32
+ server: ServerStamp;
33
+ };
34
+ /**
35
+ * Stateful core behind the MCP tools. Holds the current index and routes the
36
+ * tool calls (index_repository, index_status, and the query tools) to the
37
+ * indexer and query service. Kept transport-free so it is unit-testable without
38
+ * standing up a stdio server.
39
+ */
40
+ export declare class AmaSession {
41
+ private readonly indexer;
42
+ /** All indexed projects, keyed by resolved root. The watcher/auto-sync and the
43
+ * `store`/`query`/`stats` fields track the *primary* (last-indexed) project; other
44
+ * projects are queryable snapshots reached via a `projectPath`. (ama-ont) */
45
+ private readonly projects;
46
+ private store?;
47
+ private query?;
48
+ private stats?;
49
+ private watcher?;
50
+ private debouncer?;
51
+ private needsCatchUp;
52
+ constructor(indexer?: Indexer);
53
+ indexRepository(root: string): Promise<IndexStats>;
54
+ /** Add (or replace) a project in the registry and make it the primary. Re-indexing
55
+ * the same root closes its old store; a different root is kept alongside, so several
56
+ * projects stay queryable at once via `projectPath`. (ama-ont) */
57
+ private register;
58
+ /**
59
+ * Open a persisted index for `root` without re-analyzing, falling back to a
60
+ * full {@link indexRepository} when there is nothing usable to reopen (e.g. the
61
+ * in-memory store, or a stale/incompatible DB). On reopen, drift is reconciled
62
+ * lazily on the first query (the connect-time catch-up). Used at server
63
+ * startup so a process restart reuses the persisted graph.
64
+ */
65
+ open(root: string): Promise<IndexStats>;
66
+ /** Release resources: stop watching and close every project's store. */
67
+ close(): void;
68
+ /**
69
+ * Arm a one-shot catch-up — typically on MCP reconnect, since files may have
70
+ * changed while disconnected. A no-op until something is indexed.
71
+ */
72
+ markForCatchUp(): void;
73
+ /**
74
+ * If armed, reconcile on-disk changes before serving (a size/mtime + hash
75
+ * diff via {@link sync}), then disarm. Returns what it reconciled, or
76
+ * undefined when nothing was armed. Called before each query so the first one
77
+ * after a reconnect sees a current graph.
78
+ */
79
+ catchUpIfNeeded(): Promise<SyncResult | undefined>;
80
+ /**
81
+ * Re-index a single file that changed on disk, updating the live graph in
82
+ * place (no full rebuild, same store, so existing queries keep working).
83
+ * Counts are refreshed; language coverage is unchanged by a single-file edit.
84
+ */
85
+ reindexFile(rel: string): Promise<IndexStats>;
86
+ /**
87
+ * Start watching the indexed root and auto-re-index files as they change,
88
+ * collapsing bursts of edits with a debounce window. Idempotent; requires a
89
+ * prior index. Pair with {@link unwatch} to stop.
90
+ */
91
+ watch(options?: {
92
+ windowMs?: number;
93
+ source?: WatchSource;
94
+ }): void;
95
+ /** Stop watching. Pending (un-synced) edits are dropped. */
96
+ unwatch(): void;
97
+ /**
98
+ * Manually reconcile files that changed on disk since the last index — a
99
+ * catch-up that does not need a live watcher. Returns what it re-indexed and
100
+ * removed, and refreshes the cached counts.
101
+ */
102
+ sync(): Promise<SyncResult>;
103
+ /**
104
+ * A warning to prepend to query results while edits sit in the auto-syncer's
105
+ * debounce window: those files' results are stale until the next re-index, so
106
+ * name them and steer the caller to read them directly. Undefined when there
107
+ * is nothing pending (the common case — no banner).
108
+ */
109
+ stalenessBanner(): string | undefined;
110
+ indexStatus(): IndexStatus;
111
+ /** Live per-language file coverage from the current store, in first-seen order. */
112
+ private coverage;
113
+ searchSymbol(query: string, opts?: SearchOptions, projectPath?: string): GraphNode[];
114
+ searchSymbolWithConfidence(query: string, opts?: SearchOptions, projectPath?: string): SearchResult;
115
+ searchCode(query: string, opts?: {
116
+ limit?: number;
117
+ }, projectPath?: string): GraphNode[];
118
+ searchCodeWithConfidence(query: string, opts?: {
119
+ limit?: number;
120
+ }, projectPath?: string): {
121
+ results: GraphNode[];
122
+ viaTerms: boolean;
123
+ };
124
+ findCallers(ref: string, projectPath?: string): EdgeNeighbor[];
125
+ findCallees(ref: string, projectPath?: string): EdgeNeighbor[];
126
+ findHandlers(ref: string, projectPath?: string): EdgeNeighbor[];
127
+ findRoutes(ref: string, projectPath?: string): EdgeNeighbor[];
128
+ findReferrers(ref: string, projectPath?: string): EdgeNeighbor[];
129
+ findOverrides(ref: string, projectPath?: string): EdgeNeighbor[];
130
+ findOverriddenBy(ref: string, projectPath?: string): EdgeNeighbor[];
131
+ circularImports(projectPath?: string): GraphNode[][];
132
+ findImplementations(ref: string, projectPath?: string): GraphNode[];
133
+ findInterfaces(ref: string, projectPath?: string): GraphNode[];
134
+ findImporters(ref: string, projectPath?: string): GraphNode[];
135
+ findImports(ref: string, projectPath?: string): GraphNode[];
136
+ findTypeUsers(ref: string, projectPath?: string): GraphNode[];
137
+ findTypesUsed(ref: string, projectPath?: string): GraphNode[];
138
+ findReturns(ref: string, projectPath?: string): GraphNode[];
139
+ getCodeSnippet(ref: string, projectPath?: string): Snippet | undefined;
140
+ node(ref: string, projectPath?: string): NodeView | undefined;
141
+ fileSkeleton(ref: string, projectPath?: string): FileSkeleton | undefined;
142
+ impactAnalysis(ref: string, maxDepth?: number, projectPath?: string): GraphNode[];
143
+ getGraphSchema(projectPath?: string): GraphSchema;
144
+ affected(files: string[], opts?: {
145
+ testsOnly?: boolean;
146
+ }, projectPath?: string): GraphNode[];
147
+ explore(question: string, opts?: {
148
+ limit?: number;
149
+ }, projectPath?: string): Exploration;
150
+ private requireQuery;
151
+ /** The indexed project a `projectPath` names: the one whose root equals the resolved
152
+ * path or contains it (longest root wins, for nested/monorepo layouts). (ama-ont) */
153
+ private projectFor;
154
+ }
155
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,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
3
+ import { createDefaultIndexer } from "../indexer/indexer.js";
4
+ import { FileWatcher } from "../indexer/watcher.js";
5
+ import { QueryService } from "../query/service.js";
6
+ import { serverStamp } from "./build-info.js";
7
+ /** Default quiet window before a burst of edits triggers a re-index. */
8
+ const DEFAULT_DEBOUNCE_MS = 200;
9
+ /**
10
+ * Stateful core behind the MCP tools. Holds the current index and routes the
11
+ * tool calls (index_repository, index_status, and the query tools) to the
12
+ * indexer and query service. Kept transport-free so it is unit-testable without
13
+ * standing up a stdio server.
14
+ */
15
+ export class AmaSession {
16
+ indexer;
17
+ /** All indexed projects, keyed by resolved root. The watcher/auto-sync and the
18
+ * `store`/`query`/`stats` fields track the *primary* (last-indexed) project; other
19
+ * projects are queryable snapshots reached via a `projectPath`. (ama-ont) */
20
+ projects = new Map();
21
+ store;
22
+ query;
23
+ stats;
24
+ watcher;
25
+ debouncer;
26
+ needsCatchUp = false;
27
+ constructor(indexer = createDefaultIndexer()) {
28
+ this.indexer = indexer;
29
+ }
30
+ async indexRepository(root) {
31
+ const abs = path.resolve(root);
32
+ const { store, stats } = await this.indexer.index(abs);
33
+ this.register(abs, { store, query: new QueryService(store, abs), stats });
34
+ this.needsCatchUp = false; // a fresh index is already current
35
+ return stats;
36
+ }
37
+ /** Add (or replace) a project in the registry and make it the primary. Re-indexing
38
+ * the same root closes its old store; a different root is kept alongside, so several
39
+ * projects stay queryable at once via `projectPath`. (ama-ont) */
40
+ register(abs, project) {
41
+ this.projects.get(abs)?.store.close();
42
+ this.projects.set(abs, project);
43
+ this.store = project.store;
44
+ this.query = project.query;
45
+ this.stats = project.stats;
46
+ }
47
+ /**
48
+ * Open a persisted index for `root` without re-analyzing, falling back to a
49
+ * full {@link indexRepository} when there is nothing usable to reopen (e.g. the
50
+ * in-memory store, or a stale/incompatible DB). On reopen, drift is reconciled
51
+ * lazily on the first query (the connect-time catch-up). Used at server
52
+ * startup so a process restart reuses the persisted graph.
53
+ */
54
+ async open(root) {
55
+ const abs = path.resolve(root);
56
+ const opened = await this.indexer.open(abs);
57
+ if (!opened)
58
+ return this.indexRepository(abs);
59
+ this.register(abs, {
60
+ store: opened.store,
61
+ query: new QueryService(opened.store, abs),
62
+ stats: opened.stats,
63
+ });
64
+ this.needsCatchUp = true; // reconcile anything that changed while we were down
65
+ return opened.stats;
66
+ }
67
+ /** Release resources: stop watching and close every project's store. */
68
+ close() {
69
+ this.unwatch();
70
+ for (const project of this.projects.values())
71
+ project.store.close();
72
+ this.projects.clear();
73
+ this.store = undefined;
74
+ this.query = undefined;
75
+ this.stats = undefined;
76
+ }
77
+ /**
78
+ * Arm a one-shot catch-up — typically on MCP reconnect, since files may have
79
+ * changed while disconnected. A no-op until something is indexed.
80
+ */
81
+ markForCatchUp() {
82
+ if (this.stats)
83
+ this.needsCatchUp = true;
84
+ }
85
+ /**
86
+ * If armed, reconcile on-disk changes before serving (a size/mtime + hash
87
+ * diff via {@link sync}), then disarm. Returns what it reconciled, or
88
+ * undefined when nothing was armed. Called before each query so the first one
89
+ * after a reconnect sees a current graph.
90
+ */
91
+ async catchUpIfNeeded() {
92
+ if (!this.needsCatchUp)
93
+ return undefined;
94
+ this.needsCatchUp = false;
95
+ return this.sync();
96
+ }
97
+ /**
98
+ * Re-index a single file that changed on disk, updating the live graph in
99
+ * place (no full rebuild, same store, so existing queries keep working).
100
+ * Counts are refreshed; language coverage is unchanged by a single-file edit.
101
+ */
102
+ async reindexFile(rel) {
103
+ if (!this.store || !this.stats) {
104
+ throw new Error("Nothing indexed yet — call index_repository first.");
105
+ }
106
+ await this.indexer.reindexFile(this.store, this.stats.root, rel);
107
+ this.stats = {
108
+ ...this.stats,
109
+ nodeCount: this.store.nodeCount,
110
+ edgeCount: this.store.edgeCount,
111
+ fileCount: this.store.allFiles().length,
112
+ };
113
+ return this.stats;
114
+ }
115
+ /**
116
+ * Start watching the indexed root and auto-re-index files as they change,
117
+ * collapsing bursts of edits with a debounce window. Idempotent; requires a
118
+ * prior index. Pair with {@link unwatch} to stop.
119
+ */
120
+ watch(options = {}) {
121
+ if (!this.store || !this.stats) {
122
+ throw new Error("Nothing indexed yet — call index_repository first.");
123
+ }
124
+ if (this.watcher)
125
+ return; // already watching
126
+ this.debouncer = new Debouncer((rel) => this.reindexFile(rel).then(() => undefined), options.windowMs ?? DEFAULT_DEBOUNCE_MS);
127
+ this.watcher = new FileWatcher(this.stats.root, (rel) => this.debouncer?.notify(rel), {
128
+ source: options.source,
129
+ });
130
+ this.watcher.start();
131
+ }
132
+ /** Stop watching. Pending (un-synced) edits are dropped. */
133
+ unwatch() {
134
+ this.watcher?.close();
135
+ this.watcher = undefined;
136
+ this.debouncer?.stop();
137
+ this.debouncer = undefined;
138
+ }
139
+ /**
140
+ * Manually reconcile files that changed on disk since the last index — a
141
+ * catch-up that does not need a live watcher. Returns what it re-indexed and
142
+ * removed, and refreshes the cached counts.
143
+ */
144
+ async sync() {
145
+ if (!this.store || !this.stats) {
146
+ throw new Error("Nothing indexed yet — call index_repository first.");
147
+ }
148
+ const result = await this.indexer.sync(this.store, this.stats.root);
149
+ this.stats = {
150
+ ...this.stats,
151
+ nodeCount: this.store.nodeCount,
152
+ edgeCount: this.store.edgeCount,
153
+ fileCount: this.store.allFiles().length,
154
+ };
155
+ return result;
156
+ }
157
+ /**
158
+ * A warning to prepend to query results while edits sit in the auto-syncer's
159
+ * debounce window: those files' results are stale until the next re-index, so
160
+ * name them and steer the caller to read them directly. Undefined when there
161
+ * is nothing pending (the common case — no banner).
162
+ */
163
+ stalenessBanner() {
164
+ const pending = this.debouncer?.pendingPaths() ?? [];
165
+ if (pending.length === 0)
166
+ return undefined;
167
+ const shown = pending.slice(0, 10);
168
+ const more = pending.length - shown.length;
169
+ const list = more > 0 ? `${shown.join(", ")}, and ${more} more` : shown.join(", ");
170
+ return (`⚠️ Ama: ${pending.length} file(s) changed and are pending re-index — results below ` +
171
+ `may be stale for: ${list}. For their current contents, read these files directly.`);
172
+ }
173
+ indexStatus() {
174
+ if (!this.stats)
175
+ return { indexed: false, server: serverStamp };
176
+ const { root, nodeCount, edgeCount, fileCount, resolution } = this.stats;
177
+ return {
178
+ indexed: true,
179
+ root,
180
+ nodeCount,
181
+ edgeCount,
182
+ fileCount,
183
+ // Recompute coverage live from the current files: a full index writes the
184
+ // cached `ama:coverage` metadata, but an incremental sync/reindex doesn't, so
185
+ // the cached per-language census drifts. Deriving it from the store each call
186
+ // keeps it correct on every path. (resolution still reflects the last full
187
+ // index — it's analysis metadata, not derivable from the store.) (ama-okg)
188
+ languages: this.coverage(),
189
+ ...(resolution ? { resolution } : {}),
190
+ pendingSync: this.debouncer?.pendingCount ?? 0,
191
+ projects: [...this.projects.entries()].map(([root, p]) => ({
192
+ root,
193
+ nodeCount: p.store.nodeCount,
194
+ edgeCount: p.store.edgeCount,
195
+ fileCount: p.store.allFiles().length,
196
+ })),
197
+ server: serverStamp,
198
+ };
199
+ }
200
+ /** Live per-language file coverage from the current store, in first-seen order. */
201
+ coverage() {
202
+ const counts = new Map();
203
+ for (const meta of this.store?.allFiles() ?? []) {
204
+ const lang = this.indexer.languageOf(meta.path);
205
+ if (!lang)
206
+ continue;
207
+ const entry = counts.get(lang.language);
208
+ if (entry)
209
+ entry.files++;
210
+ else
211
+ counts.set(lang.language, { tier: lang.tier, files: 1 });
212
+ }
213
+ return [...counts].map(([language, { tier, files }]) => ({ language, tier, files }));
214
+ }
215
+ searchSymbol(query, opts, projectPath) {
216
+ return this.requireQuery(projectPath).searchSymbol(query, opts);
217
+ }
218
+ searchSymbolWithConfidence(query, opts, projectPath) {
219
+ return this.requireQuery(projectPath).searchSymbolWithConfidence(query, opts);
220
+ }
221
+ searchCode(query, opts, projectPath) {
222
+ return this.requireQuery(projectPath).searchCode(query, opts);
223
+ }
224
+ searchCodeWithConfidence(query, opts, projectPath) {
225
+ return this.requireQuery(projectPath).searchCodeWithConfidence(query, opts);
226
+ }
227
+ findCallers(ref, projectPath) {
228
+ return this.requireQuery(projectPath).findCallers(ref);
229
+ }
230
+ findCallees(ref, projectPath) {
231
+ return this.requireQuery(projectPath).findCallees(ref);
232
+ }
233
+ findHandlers(ref, projectPath) {
234
+ return this.requireQuery(projectPath).findHandlers(ref);
235
+ }
236
+ findRoutes(ref, projectPath) {
237
+ return this.requireQuery(projectPath).findRoutes(ref);
238
+ }
239
+ findReferrers(ref, projectPath) {
240
+ return this.requireQuery(projectPath).findReferrers(ref);
241
+ }
242
+ findOverrides(ref, projectPath) {
243
+ return this.requireQuery(projectPath).findOverrides(ref);
244
+ }
245
+ findOverriddenBy(ref, projectPath) {
246
+ return this.requireQuery(projectPath).findOverriddenBy(ref);
247
+ }
248
+ circularImports(projectPath) {
249
+ return this.requireQuery(projectPath).circularImports();
250
+ }
251
+ findImplementations(ref, projectPath) {
252
+ return this.requireQuery(projectPath).findImplementations(ref);
253
+ }
254
+ findInterfaces(ref, projectPath) {
255
+ return this.requireQuery(projectPath).findInterfaces(ref);
256
+ }
257
+ findImporters(ref, projectPath) {
258
+ return this.requireQuery(projectPath).findImporters(ref);
259
+ }
260
+ findImports(ref, projectPath) {
261
+ return this.requireQuery(projectPath).findImports(ref);
262
+ }
263
+ findTypeUsers(ref, projectPath) {
264
+ return this.requireQuery(projectPath).findTypeUsers(ref);
265
+ }
266
+ findTypesUsed(ref, projectPath) {
267
+ return this.requireQuery(projectPath).findTypesUsed(ref);
268
+ }
269
+ findReturns(ref, projectPath) {
270
+ return this.requireQuery(projectPath).findReturns(ref);
271
+ }
272
+ getCodeSnippet(ref, projectPath) {
273
+ return this.requireQuery(projectPath).getCodeSnippet(ref);
274
+ }
275
+ node(ref, projectPath) {
276
+ return this.requireQuery(projectPath).node(ref);
277
+ }
278
+ fileSkeleton(ref, projectPath) {
279
+ return this.requireQuery(projectPath).fileSkeleton(ref);
280
+ }
281
+ impactAnalysis(ref, maxDepth, projectPath) {
282
+ return this.requireQuery(projectPath).impactAnalysis(ref, maxDepth);
283
+ }
284
+ getGraphSchema(projectPath) {
285
+ return this.requireQuery(projectPath).getGraphSchema();
286
+ }
287
+ affected(files, opts = {}, projectPath) {
288
+ return this.requireQuery(projectPath).affected(files, opts);
289
+ }
290
+ explore(question, opts = {}, projectPath) {
291
+ return this.requireQuery(projectPath).explore(question, opts);
292
+ }
293
+ requireQuery(projectPath) {
294
+ if (projectPath !== undefined)
295
+ return this.projectFor(projectPath).query;
296
+ if (!this.query) {
297
+ throw new Error("Nothing indexed yet — call index_repository first.");
298
+ }
299
+ return this.query;
300
+ }
301
+ /** The indexed project a `projectPath` names: the one whose root equals the resolved
302
+ * path or contains it (longest root wins, for nested/monorepo layouts). (ama-ont) */
303
+ projectFor(projectPath) {
304
+ const abs = path.resolve(projectPath);
305
+ let best;
306
+ let bestLen = -1;
307
+ for (const [root, project] of this.projects) {
308
+ if ((abs === root || abs.startsWith(`${root}${path.sep}`)) && root.length > bestLen) {
309
+ best = project;
310
+ bestLen = root.length;
311
+ }
312
+ }
313
+ if (!best) {
314
+ throw new Error(`No indexed project for ${abs}. Run index_repository on its root first (see index_status for the indexed projects).`);
315
+ }
316
+ return best;
317
+ }
318
+ }
319
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAYnD,OAAO,EAAoB,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,wEAAwE;AACxE,MAAM,mBAAmB,GAAG,GAAG,CAAC;AA+BhC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAYQ;IAX7B;;kFAE8E;IAC7D,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAA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