@dudamel/mcp-context 0.1.0 → 2026.917.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.
Files changed (48) hide show
  1. package/dist/annotations.test.d.ts +2 -0
  2. package/dist/annotations.test.d.ts.map +1 -0
  3. package/dist/cache-dir.d.ts +14 -0
  4. package/dist/cache-dir.d.ts.map +1 -0
  5. package/dist/cache-dir.test.d.ts +2 -0
  6. package/dist/cache-dir.test.d.ts.map +1 -0
  7. package/dist/context-backend.d.ts +36 -0
  8. package/dist/context-backend.d.ts.map +1 -0
  9. package/dist/context-client.d.ts +5 -2
  10. package/dist/context-client.d.ts.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1645 -3
  14. package/dist/mirror-backend.d.ts +61 -0
  15. package/dist/mirror-backend.d.ts.map +1 -0
  16. package/dist/mirror-backend.test.d.ts +2 -0
  17. package/dist/mirror-backend.test.d.ts.map +1 -0
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/stdio-server.d.ts +12 -0
  20. package/dist/stdio-server.d.ts.map +1 -1
  21. package/dist/stdio-server.js +1700 -36
  22. package/dist/tools/instructions.d.ts +2 -2
  23. package/dist/tools/instructions.d.ts.map +1 -1
  24. package/dist/tools/navigate.d.ts +4 -4
  25. package/dist/tools/navigate.d.ts.map +1 -1
  26. package/dist/tools/read.d.ts +7 -7
  27. package/dist/tools/read.d.ts.map +1 -1
  28. package/dist/tools/search.d.ts +3 -3
  29. package/dist/tools/search.d.ts.map +1 -1
  30. package/dist/types.d.ts +37 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/package.json +5 -3
  33. package/dist/context-client.js +0 -118
  34. package/dist/context-client.js.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/server.js +0 -90
  37. package/dist/server.js.map +0 -1
  38. package/dist/stdio-server.js.map +0 -1
  39. package/dist/tools/instructions.js +0 -40
  40. package/dist/tools/instructions.js.map +0 -1
  41. package/dist/tools/navigate.js +0 -121
  42. package/dist/tools/navigate.js.map +0 -1
  43. package/dist/tools/read.js +0 -352
  44. package/dist/tools/read.js.map +0 -1
  45. package/dist/tools/search.js +0 -103
  46. package/dist/tools/search.js.map +0 -1
  47. package/dist/types.js +0 -2
  48. package/dist/types.js.map +0 -1
@@ -0,0 +1,61 @@
1
+ import type { GrepRequest, FindRequest } from './context-client.js';
2
+ import type { ContextBackend, ContextHttpBackend } from './context-backend.js';
3
+ import type { DirectoryCatalog, FileReadResponse, GrepHit, LocalCacheConfig, ReadCsvResponse, ReadSectionResponse, ReadYamlResponse, SearchResult, StatResponse, TailResponse, TreeResponse } from './types.js';
4
+ /**
5
+ * Read-only local mirror of the VFS (proxy mode, `cache: local`). Answers tool
6
+ * calls from an on-disk copy using the same @dudamel/vfs-search primitives the
7
+ * context-server runs (so results are byte-identical), and falls back to the HTTP
8
+ * client for anything not yet mirrored. The mirror is kept fresh by polling
9
+ * `GET /manifest` and diffing per-file content hashes — downloading only what
10
+ * changed, deleting what's gone. Stale-while-revalidate: a poll never blocks a
11
+ * tool call; the current mirror is served while a refresh runs in the background.
12
+ */
13
+ export declare class MirrorContextBackend implements ContextBackend {
14
+ private readonly http;
15
+ private readonly mirrorDir;
16
+ private readonly statePath;
17
+ private readonly ttlMs;
18
+ private readonly maxBytes;
19
+ /** entry path -> applied digest (files materialized on disk). */
20
+ private readonly applied;
21
+ /** entries that contain an un-mirrorable file (>1 MiB) — always served via HTTP for parity. */
22
+ private readonly proxyOnly;
23
+ private lastManifest;
24
+ private lastManifestAt;
25
+ private refreshing;
26
+ private disabled;
27
+ constructor(http: ContextHttpBackend, cache: LocalCacheConfig);
28
+ private loadState;
29
+ private saveState;
30
+ /** Synchronously bring the mirror up to date (pre-warm; also used by tests). */
31
+ warm(): Promise<void>;
32
+ /** Kick off a background refresh if the manifest is stale. Never blocks. */
33
+ private ensureFresh;
34
+ private refresh;
35
+ private refreshEntry;
36
+ private markProxyOnly;
37
+ /** Fetch one file over HTTP and write it into the mirror atomically. */
38
+ private downloadFile;
39
+ /** Top-level entry name for a VFS path ("src/foo/bar.md" -> "src"). */
40
+ private entryOf;
41
+ /** Can this path be answered from the mirror? (undefined = whole-VFS op). */
42
+ private canServe;
43
+ /** Whole-VFS reads (unscoped grep/find) need every current entry mirrored. */
44
+ private fullyWarm;
45
+ grep(req: GrepRequest): Promise<SearchResult<GrepHit>>;
46
+ find(req: FindRequest): Promise<SearchResult<string>>;
47
+ stat(path: string): Promise<StatResponse>;
48
+ tree(path?: string, maxDepth?: number): Promise<TreeResponse>;
49
+ tail(path: string, lines?: number): Promise<TailResponse>;
50
+ readSection(path: string, heading?: string): Promise<ReadSectionResponse>;
51
+ readYaml(path: string, keyPath?: string): Promise<ReadYamlResponse>;
52
+ readCsv(path: string, opts?: {
53
+ filterColumn?: string;
54
+ filterValue?: string;
55
+ columns?: string[];
56
+ maxRows?: number;
57
+ }): Promise<ReadCsvResponse>;
58
+ readFile(vfsPath: string): Promise<FileReadResponse>;
59
+ readDirectoryCatalog(dirPath: string): Promise<DirectoryCatalog>;
60
+ }
61
+ //# sourceMappingURL=mirror-backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirror-backend.d.ts","sourceRoot":"","sources":["../src/mirror-backend.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EAEhB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,YAAY,CAAC;AAiBpB;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ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AE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAMzD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAMzE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMnE,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3F,OAAO,CAAC,eAAe,CAAC;IAMrB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkBpD,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAUvE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mirror-backend.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mirror-backend.test.d.ts","sourceRoot":"","sources":["../src/mirror-backend.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAiEnD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA8BtF"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoEnD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAoCtF"}
@@ -11,6 +11,18 @@
11
11
  *
12
12
  * 2. Direct (internal, inside the compose network):
13
13
  * DUDAMEL_CONTEXT_SERVER_URL — defaults to http://context-server:3001
14
+ *
15
+ * Local cache (proxy mode only — off by default):
16
+ * DUDAMEL_CONTEXT_CACHE=local — keep a read-only on-disk mirror of the VFS
17
+ * and answer tool calls from it (grep/read/…
18
+ * become local instead of a round-trip). Falls
19
+ * back to HTTP for anything not yet mirrored.
20
+ * DUDAMEL_CONTEXT_CACHE_DIR — mirror location (default: XDG cache home,
21
+ * keyed by API URL + agent; OS temp as last resort).
22
+ * DUDAMEL_CONTEXT_CACHE_TTL_SECONDS — manifest re-check interval (default 60).
23
+ * DUDAMEL_CONTEXT_CACHE_MAX_BYTES — total mirror size cap (default 512 MiB;
24
+ * a larger VFS disables the cache).
25
+ * Ignored in direct mode (in-cluster the context-server is one hop away).
14
26
  */
15
27
  export {};
16
28
  //# sourceMappingURL=stdio-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stdio-server.d.ts","sourceRoot":"","sources":["../src/stdio-server.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
1
+ {"version":3,"file":"stdio-server.d.ts","sourceRoot":"","sources":["../src/stdio-server.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}