ctxr-cli 0.29.0 → 0.31.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 (117) hide show
  1. package/README.md +43 -0
  2. package/dist/commands/land.d.ts.map +1 -1
  3. package/dist/commands/land.js +3 -18
  4. package/dist/commands/land.js.map +1 -1
  5. package/dist/commands/serve.d.ts.map +1 -1
  6. package/dist/commands/serve.js +10 -2
  7. package/dist/commands/serve.js.map +1 -1
  8. package/dist/config/defaults.d.ts +2 -0
  9. package/dist/config/defaults.d.ts.map +1 -1
  10. package/dist/config/defaults.js +2 -0
  11. package/dist/config/defaults.js.map +1 -1
  12. package/dist/config/schema.d.ts +39 -0
  13. package/dist/config/schema.d.ts.map +1 -1
  14. package/dist/config/schema.js +57 -8
  15. package/dist/config/schema.js.map +1 -1
  16. package/dist/core/browse/approve.d.ts +3 -0
  17. package/dist/core/browse/approve.d.ts.map +1 -1
  18. package/dist/core/browse/approve.js.map +1 -1
  19. package/dist/core/browse/page-url.d.ts +15 -0
  20. package/dist/core/browse/page-url.d.ts.map +1 -1
  21. package/dist/core/browse/page-url.js +8 -1
  22. package/dist/core/browse/page-url.js.map +1 -1
  23. package/dist/core/forge/credentials.d.ts +12 -1
  24. package/dist/core/forge/credentials.d.ts.map +1 -1
  25. package/dist/core/forge/credentials.js +25 -1
  26. package/dist/core/forge/credentials.js.map +1 -1
  27. package/dist/core/forge/github.d.ts +9 -0
  28. package/dist/core/forge/github.d.ts.map +1 -1
  29. package/dist/core/forge/github.js +6 -0
  30. package/dist/core/forge/github.js.map +1 -1
  31. package/dist/core/mcp/drafts.d.ts +30 -0
  32. package/dist/core/mcp/drafts.d.ts.map +1 -0
  33. package/dist/core/mcp/drafts.js +52 -0
  34. package/dist/core/mcp/drafts.js.map +1 -0
  35. package/dist/core/mcp/http.d.ts +40 -0
  36. package/dist/core/mcp/http.d.ts.map +1 -0
  37. package/dist/core/mcp/http.js +90 -0
  38. package/dist/core/mcp/http.js.map +1 -0
  39. package/dist/core/mcp/jsonrpc.d.ts +73 -0
  40. package/dist/core/mcp/jsonrpc.d.ts.map +1 -0
  41. package/dist/core/mcp/jsonrpc.js +149 -0
  42. package/dist/core/mcp/jsonrpc.js.map +1 -0
  43. package/dist/core/mcp/members.d.ts +11 -0
  44. package/dist/core/mcp/members.d.ts.map +1 -0
  45. package/dist/core/mcp/members.js +21 -0
  46. package/dist/core/mcp/members.js.map +1 -0
  47. package/dist/core/mcp/oauth.d.ts +99 -0
  48. package/dist/core/mcp/oauth.d.ts.map +1 -0
  49. package/dist/core/mcp/oauth.js +454 -0
  50. package/dist/core/mcp/oauth.js.map +1 -0
  51. package/dist/core/mcp/pages.d.ts +3 -0
  52. package/dist/core/mcp/pages.d.ts.map +1 -0
  53. package/dist/core/mcp/pages.js +41 -0
  54. package/dist/core/mcp/pages.js.map +1 -0
  55. package/dist/core/mcp/ripgrep.d.ts +48 -0
  56. package/dist/core/mcp/ripgrep.d.ts.map +1 -0
  57. package/dist/core/mcp/ripgrep.js +98 -0
  58. package/dist/core/mcp/ripgrep.js.map +1 -0
  59. package/dist/core/mcp/rwlock.d.ts +16 -0
  60. package/dist/core/mcp/rwlock.d.ts.map +1 -0
  61. package/dist/core/mcp/rwlock.js +59 -0
  62. package/dist/core/mcp/rwlock.js.map +1 -0
  63. package/dist/core/mcp/sessions.d.ts +84 -0
  64. package/dist/core/mcp/sessions.d.ts.map +1 -0
  65. package/dist/core/mcp/sessions.js +154 -0
  66. package/dist/core/mcp/sessions.js.map +1 -0
  67. package/dist/core/mcp/surface.d.ts +42 -0
  68. package/dist/core/mcp/surface.d.ts.map +1 -0
  69. package/dist/core/mcp/surface.js +141 -0
  70. package/dist/core/mcp/surface.js.map +1 -0
  71. package/dist/core/mcp/sync.d.ts +91 -0
  72. package/dist/core/mcp/sync.d.ts.map +1 -0
  73. package/dist/core/mcp/sync.js +218 -0
  74. package/dist/core/mcp/sync.js.map +1 -0
  75. package/dist/core/mcp/tools/capture.d.ts +64 -0
  76. package/dist/core/mcp/tools/capture.d.ts.map +1 -0
  77. package/dist/core/mcp/tools/capture.js +182 -0
  78. package/dist/core/mcp/tools/capture.js.map +1 -0
  79. package/dist/core/mcp/tools/edit.d.ts +79 -0
  80. package/dist/core/mcp/tools/edit.d.ts.map +1 -0
  81. package/dist/core/mcp/tools/edit.js +212 -0
  82. package/dist/core/mcp/tools/edit.js.map +1 -0
  83. package/dist/core/mcp/tools/files.d.ts +163 -0
  84. package/dist/core/mcp/tools/files.d.ts.map +1 -0
  85. package/dist/core/mcp/tools/files.js +265 -0
  86. package/dist/core/mcp/tools/files.js.map +1 -0
  87. package/dist/core/mcp/tools/find.d.ts +82 -0
  88. package/dist/core/mcp/tools/find.d.ts.map +1 -0
  89. package/dist/core/mcp/tools/find.js +136 -0
  90. package/dist/core/mcp/tools/find.js.map +1 -0
  91. package/dist/core/mcp/tools/gather.d.ts +88 -0
  92. package/dist/core/mcp/tools/gather.d.ts.map +1 -0
  93. package/dist/core/mcp/tools/gather.js +123 -0
  94. package/dist/core/mcp/tools/gather.js.map +1 -0
  95. package/dist/core/mcp/tools/index.d.ts +21 -0
  96. package/dist/core/mcp/tools/index.d.ts.map +1 -0
  97. package/dist/core/mcp/tools/index.js +129 -0
  98. package/dist/core/mcp/tools/index.js.map +1 -0
  99. package/dist/core/skills.d.ts +18 -2
  100. package/dist/core/skills.d.ts.map +1 -1
  101. package/dist/core/skills.js +51 -5
  102. package/dist/core/skills.js.map +1 -1
  103. package/dist/version.d.ts +1 -1
  104. package/dist/version.js +1 -1
  105. package/package.json +1 -1
  106. package/templates/mcp/Edit.md +7 -0
  107. package/templates/mcp/Glob.md +5 -0
  108. package/templates/mcp/Grep.md +10 -0
  109. package/templates/mcp/Read.md +7 -0
  110. package/templates/mcp/Write.md +7 -0
  111. package/templates/mcp/capture.md +9 -0
  112. package/templates/mcp/consent.html +40 -0
  113. package/templates/mcp/find.md +9 -0
  114. package/templates/mcp/gather.md +5 -0
  115. package/templates/mcp/server-instructions.md +17 -0
  116. package/templates/skills/ctxr-circleback/sweep.mjs +229 -0
  117. package/templates/skills/ctxr-circleback.md +70 -0
@@ -0,0 +1,163 @@
1
+ import type { StoreConfig } from '../../../config/schema.js';
2
+ import { type GrepParams } from '../ripgrep.js';
3
+ import type { WriteDeps } from '../sessions.js';
4
+ import type { Snapshot } from '../sync.js';
5
+ /**
6
+ * serve-the-store-over-mcp design.md D12 (remote-access spec, *`Read`,
7
+ * `Grep` and `Glob` give file-shaped access with Claude Code's parameters*):
8
+ * Claude Code's own file tools, by name and parameter, answering from the
9
+ * commit being served. Paths are store-relative (a leading `/` names the
10
+ * store root). What these tools may never read or return is one list, used
11
+ * both to refuse a named path and as ripgrep's exclusions.
12
+ */
13
+ export declare const READ_DEFAULT_LIMIT = 2000;
14
+ /** Everything these tools hide: the retrieval exclusions except the capture tier, plus configuration and `.git`. */
15
+ export declare function hiddenPrefixes(config: StoreConfig): string[];
16
+ /** A caller's path as a store-relative one; refused when it leaves the store or is hidden. `''` is the store root. */
17
+ export declare function resolveStorePath(input: string, config: StoreConfig): string;
18
+ /** What `Read` answers for, as one predicate: a note, a markdown capture, or the entry document. Grep and Glob return nothing else. */
19
+ export declare function readablePath(rel: string, config: StoreConfig): boolean;
20
+ export interface ReadArgs {
21
+ file_path: string;
22
+ offset?: number;
23
+ limit?: number;
24
+ }
25
+ export declare const READ_INPUT_SCHEMA: {
26
+ readonly type: 'object';
27
+ readonly properties: {
28
+ readonly file_path: {
29
+ readonly type: 'string';
30
+ readonly description: 'The file to read, relative to the store root (a leading / means the store root), e.g. "projects/kestrel.md".';
31
+ };
32
+ readonly offset: {
33
+ readonly type: 'number';
34
+ readonly description: 'The line number to start reading from. Only provide if the file is too large to read at once.';
35
+ };
36
+ readonly limit: {
37
+ readonly type: 'number';
38
+ readonly description: 'The number of lines to read. Only provide if the file is too large to read at once.';
39
+ };
40
+ };
41
+ readonly required: readonly ['file_path'];
42
+ };
43
+ export declare function parseReadArgs(args: Record<string, unknown>): ReadArgs;
44
+ export interface ReadResult {
45
+ file_path: string;
46
+ /** `cat -n` style: the line number, a tab, the line. */
47
+ content: string;
48
+ total_lines: number;
49
+ first_line: number;
50
+ last_line: number;
51
+ draft: boolean;
52
+ capture: boolean;
53
+ /** The note's page on the browsing surface, for citing; null for a capture or the entry document. */
54
+ url: string | null;
55
+ }
56
+ export declare function readTool(snapshot: Snapshot, write: WriteDeps, email: string, args: ReadArgs): Promise<ReadResult>;
57
+ export declare function renderRead(data: unknown): string;
58
+ export interface GrepArgs extends GrepParams {
59
+ head_limit?: number;
60
+ offset?: number;
61
+ }
62
+ export declare const GREP_INPUT_SCHEMA: {
63
+ readonly type: 'object';
64
+ readonly properties: {
65
+ readonly pattern: {
66
+ readonly type: 'string';
67
+ readonly description: 'The regular expression pattern to search for in file contents';
68
+ };
69
+ readonly path: {
70
+ readonly type: 'string';
71
+ readonly description: 'File or directory to search in, relative to the store root. Defaults to the whole store.';
72
+ };
73
+ readonly glob: {
74
+ readonly type: 'string';
75
+ readonly description: 'Glob pattern to filter files (e.g. "*.md", "projects/**/*.md")';
76
+ };
77
+ readonly type: {
78
+ readonly type: 'string';
79
+ readonly description: 'File type to search (e.g. md). More efficient than glob for standard file types.';
80
+ };
81
+ readonly output_mode: {
82
+ readonly type: 'string';
83
+ readonly enum: readonly ['content', 'files_with_matches', 'count'];
84
+ readonly description: 'Output mode: "content" shows matching lines, "files_with_matches" shows file paths (default), "count" shows match counts.';
85
+ };
86
+ readonly '-i': {
87
+ readonly type: 'boolean';
88
+ readonly description: 'Case insensitive search';
89
+ };
90
+ readonly '-n': {
91
+ readonly type: 'boolean';
92
+ readonly description: 'Show line numbers in output (content mode; defaults to true)';
93
+ };
94
+ readonly '-A': {
95
+ readonly type: 'number';
96
+ readonly description: 'Number of lines to show after each match (content mode)';
97
+ };
98
+ readonly '-B': {
99
+ readonly type: 'number';
100
+ readonly description: 'Number of lines to show before each match (content mode)';
101
+ };
102
+ readonly '-C': {
103
+ readonly type: 'number';
104
+ readonly description: 'Number of lines to show before and after each match (content mode)';
105
+ };
106
+ readonly context: {
107
+ readonly type: 'number';
108
+ readonly description: 'Alias for -C';
109
+ };
110
+ readonly multiline: {
111
+ readonly type: 'boolean';
112
+ readonly description: 'Enable multiline mode where . matches newlines and patterns can span lines';
113
+ };
114
+ readonly head_limit: {
115
+ readonly type: 'number';
116
+ readonly description: 'Limit output to the first N lines/entries';
117
+ };
118
+ readonly offset: {
119
+ readonly type: 'number';
120
+ readonly description: 'Skip the first N lines/entries before applying head_limit';
121
+ };
122
+ };
123
+ readonly required: readonly ['pattern'];
124
+ };
125
+ export declare function parseGrepArgs(args: Record<string, unknown>): GrepArgs;
126
+ export interface GrepResult {
127
+ output_mode: string;
128
+ lines: string[];
129
+ omitted: number;
130
+ /** Inbox files on session branches with an open pull request that match: captures awaiting approval. */
131
+ awaiting_approval: {
132
+ path: string;
133
+ branch: string;
134
+ lines: string[];
135
+ }[];
136
+ }
137
+ export declare function grepTool(snapshot: Snapshot, args: GrepArgs): Promise<GrepResult>;
138
+ export declare function renderGrep(data: unknown): string;
139
+ export interface GlobArgs {
140
+ pattern: string;
141
+ path?: string;
142
+ }
143
+ export declare const GLOB_INPUT_SCHEMA: {
144
+ readonly type: 'object';
145
+ readonly properties: {
146
+ readonly pattern: {
147
+ readonly type: 'string';
148
+ readonly description: 'The glob pattern to match files against, e.g. "**/*.md" or "projects/**/*.md"';
149
+ };
150
+ readonly path: {
151
+ readonly type: 'string';
152
+ readonly description: 'The directory to search in, relative to the store root. Defaults to the whole store.';
153
+ };
154
+ };
155
+ readonly required: readonly ['pattern'];
156
+ };
157
+ export declare function parseGlobArgs(args: Record<string, unknown>): GlobArgs;
158
+ export declare function globTool(snapshot: Snapshot, args: GlobArgs): Promise<{
159
+ files: string[];
160
+ omitted: number;
161
+ }>;
162
+ export declare function renderGlob(data: unknown): string;
163
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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E;;iBACvH,IAAI;qBAAI,IAAI,EAAE,QAAQ;qBAAE,WAAW,EAAE,sFAAsF;;;aAE7H,QAAQ,YAAG,SAAS;CACZ,CAAC;AAEX,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAIrE;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAOhH;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIhD"}
@@ -0,0 +1,265 @@
1
+ import { lstat, readFile, realpath } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { joinBaseUrl, noteRoute } from '../../browse/page-url.js';
4
+ import { isUnderAnyPrefix } from '../../fs/prefix.js';
5
+ import { admitsNotePath, excludedPrefixesFor } from '../../notes/list.js';
6
+ import { CONFIG_FILE_NAME } from '../../root.js';
7
+ import { draftVersion, findLocalDraft } from '../drafts.js';
8
+ import { ToolRefusal } from '../jsonrpc.js';
9
+ import { glob as ripgrepGlob, grep as ripgrepGrep } from '../ripgrep.js';
10
+ /**
11
+ * serve-the-store-over-mcp design.md D12 (remote-access spec, *`Read`,
12
+ * `Grep` and `Glob` give file-shaped access with Claude Code's parameters*):
13
+ * Claude Code's own file tools, by name and parameter, answering from the
14
+ * commit being served. Paths are store-relative (a leading `/` names the
15
+ * store root). What these tools may never read or return is one list, used
16
+ * both to refuse a named path and as ripgrep's exclusions.
17
+ */
18
+ export const READ_DEFAULT_LIMIT = 2000;
19
+ const READ_MAX_LINE_CHARS = 2000;
20
+ const GREP_MAX_LINES = 1000;
21
+ /** The store's entry document, readable though it is not a note. */
22
+ const ENTRY_DOCUMENT = 'AGENTS.md';
23
+ /** Everything these tools hide: the retrieval exclusions except the capture tier, plus configuration and `.git`. */
24
+ export function hiddenPrefixes(config) {
25
+ const captureRoot = config.ingest.capture_root.replace(/\/+$/, '');
26
+ return [...excludedPrefixesFor(config).filter((p) => p.replace(/\/+$/, '') !== captureRoot), CONFIG_FILE_NAME, '.git'];
27
+ }
28
+ /** A caller's path as a store-relative one; refused when it leaves the store or is hidden. `''` is the store root. */
29
+ export function resolveStorePath(input, config) {
30
+ const cleaned = input.trim().replace(/\\/g, '/');
31
+ const normalized = path.posix.normalize(`/${cleaned}`).replace(/^\/+/, '').replace(/\/+$/, '');
32
+ if (normalized === '..' || normalized.startsWith('../') || cleaned.split('/').includes('..')) {
33
+ throw new ToolRefusal('mcp.path_outside_store', `"${input}" is outside the store.`);
34
+ }
35
+ if (normalized !== '' && isUnderAnyPrefix(normalized, hiddenPrefixes(config))) {
36
+ throw new ToolRefusal('mcp.path_not_readable', `"${normalized}" is not something these tools read (configuration, derived files and tool-owned folders are not).`);
37
+ }
38
+ return normalized;
39
+ }
40
+ /** What `Read` answers for, as one predicate: a note, a markdown capture, or the entry document. Grep and Glob return nothing else. */
41
+ export function readablePath(rel, config) {
42
+ if (admitsNotePath(rel, config) || rel === ENTRY_DOCUMENT)
43
+ return true;
44
+ return rel.endsWith('.md') && isUnderAnyPrefix(rel, [config.ingest.capture_root]);
45
+ }
46
+ export const READ_INPUT_SCHEMA = {
47
+ type: 'object',
48
+ properties: {
49
+ file_path: { type: 'string', description: 'The file to read, relative to the store root (a leading / means the store root), e.g. "projects/kestrel.md".' },
50
+ offset: { type: 'number', description: 'The line number to start reading from. Only provide if the file is too large to read at once.' },
51
+ limit: { type: 'number', description: 'The number of lines to read. Only provide if the file is too large to read at once.' },
52
+ },
53
+ required: ['file_path'],
54
+ };
55
+ function positiveInteger(value, name) {
56
+ if (value === undefined || value === null)
57
+ return undefined;
58
+ if (typeof value !== 'number' || !Number.isInteger(value) || value < 0)
59
+ throw new ToolRefusal('mcp.invalid_arguments', `"${name}" must be a whole number.`);
60
+ return value;
61
+ }
62
+ export function parseReadArgs(args) {
63
+ if (typeof args.file_path !== 'string' || args.file_path.trim() === '')
64
+ throw new ToolRefusal('mcp.invalid_arguments', '"file_path" is required.');
65
+ return { file_path: args.file_path, offset: positiveInteger(args.offset, 'offset'), limit: positiveInteger(args.limit, 'limit') };
66
+ }
67
+ function numbered(text, offset, limit) {
68
+ const lines = text.split('\n');
69
+ if (lines.length > 0 && lines[lines.length - 1] === '')
70
+ lines.pop();
71
+ const first = Math.max(1, offset ?? 1);
72
+ const count = limit ?? READ_DEFAULT_LIMIT;
73
+ const slice = lines.slice(first - 1, first - 1 + count);
74
+ const content = slice
75
+ .map((line, i) => `${String(first + i).padStart(6)}\t${line.length > READ_MAX_LINE_CHARS ? `${line.slice(0, READ_MAX_LINE_CHARS)}… (line truncated)` : line}`)
76
+ .join('\n');
77
+ return { content, total: lines.length, first, last: first + slice.length - 1 };
78
+ }
79
+ export async function readTool(snapshot, write, email, args) {
80
+ const config = snapshot.store.config;
81
+ const rel = resolveStorePath(args.file_path, config);
82
+ const captureRoot = config.ingest.capture_root;
83
+ const isCapture = isUnderAnyPrefix(rel, [captureRoot]);
84
+ const admitted = admitsNotePath(rel, config);
85
+ const draft = admitted ? await findLocalDraft(write, email) : null;
86
+ const drafted = draft === null ? null : await draftVersion(write, draft, rel);
87
+ if (drafted !== null) {
88
+ const n = numbered(drafted, args.offset, args.limit);
89
+ return { file_path: rel, content: n.content, total_lines: n.total, first_line: n.first, last_line: n.last, draft: true, capture: false, url: null };
90
+ }
91
+ if (!admitted && !isCapture && rel !== ENTRY_DOCUMENT) {
92
+ throw new ToolRefusal('mcp.path_not_readable', `"${rel}" is not a note, a capture or the entry document, so it cannot be read here.`);
93
+ }
94
+ const absolute = path.join(snapshot.store.root, rel);
95
+ const info = await lstat(absolute).catch(() => null);
96
+ if (info === null || (!info.isFile() && !info.isSymbolicLink()))
97
+ throw new ToolRefusal('mcp.file_not_found', `"${rel}" does not exist in the store.`);
98
+ // A link is never followed: a committed symlink named like a note could otherwise read anything the server can.
99
+ if (info.isSymbolicLink())
100
+ throw new ToolRefusal('mcp.path_not_readable', `"${rel}" is a symbolic link, which these tools do not follow.`);
101
+ const real = await realpath(absolute);
102
+ const root = await realpath(snapshot.store.root);
103
+ if (path.relative(root, real).startsWith('..'))
104
+ throw new ToolRefusal('mcp.path_outside_store', `"${rel}" is outside the store.`);
105
+ const n = numbered(await readFile(absolute, 'utf8'), args.offset, args.limit);
106
+ const url = admitted ? joinBaseUrl(write.baseUrl, noteRoute(rel)) : null;
107
+ return { file_path: rel, content: n.content, total_lines: n.total, first_line: n.first, last_line: n.last, draft: false, capture: isCapture, url };
108
+ }
109
+ export function renderRead(data) {
110
+ const r = data;
111
+ const notes = [];
112
+ if (r.draft)
113
+ notes.push('This is your pending draft of this note (awaiting approval), not the version in the store.');
114
+ if (r.capture)
115
+ notes.push('This is a capture: raw material not yet filed into a note. Do not present it as what the store says.');
116
+ if (r.url !== null)
117
+ notes.push(`${r.file_path}, at ${r.url}. Include this link when you cite the note.`);
118
+ if (r.last_line < r.total_lines)
119
+ notes.push(`Showing lines ${r.first_line}–${r.last_line} of ${r.total_lines}.`);
120
+ return [...notes.map((n) => `[${n}]`), r.content].join('\n');
121
+ }
122
+ export const GREP_INPUT_SCHEMA = {
123
+ type: 'object',
124
+ properties: {
125
+ pattern: { type: 'string', description: 'The regular expression pattern to search for in file contents' },
126
+ path: { type: 'string', description: 'File or directory to search in, relative to the store root. Defaults to the whole store.' },
127
+ glob: { type: 'string', description: 'Glob pattern to filter files (e.g. "*.md", "projects/**/*.md")' },
128
+ type: { type: 'string', description: 'File type to search (e.g. md). More efficient than glob for standard file types.' },
129
+ output_mode: { type: 'string', enum: ['content', 'files_with_matches', 'count'], description: 'Output mode: "content" shows matching lines, "files_with_matches" shows file paths (default), "count" shows match counts.' },
130
+ '-i': { type: 'boolean', description: 'Case insensitive search' },
131
+ '-n': { type: 'boolean', description: 'Show line numbers in output (content mode; defaults to true)' },
132
+ '-A': { type: 'number', description: 'Number of lines to show after each match (content mode)' },
133
+ '-B': { type: 'number', description: 'Number of lines to show before each match (content mode)' },
134
+ '-C': { type: 'number', description: 'Number of lines to show before and after each match (content mode)' },
135
+ context: { type: 'number', description: 'Alias for -C' },
136
+ multiline: { type: 'boolean', description: 'Enable multiline mode where . matches newlines and patterns can span lines' },
137
+ head_limit: { type: 'number', description: 'Limit output to the first N lines/entries' },
138
+ offset: { type: 'number', description: 'Skip the first N lines/entries before applying head_limit' },
139
+ },
140
+ required: ['pattern'],
141
+ };
142
+ export function parseGrepArgs(args) {
143
+ const invalid = (message) => new ToolRefusal('mcp.invalid_arguments', message);
144
+ if (typeof args.pattern !== 'string' || args.pattern === '')
145
+ throw invalid('"pattern" is required.');
146
+ const out = { pattern: args.pattern };
147
+ for (const key of ['path', 'glob', 'type']) {
148
+ if (args[key] !== undefined && args[key] !== null) {
149
+ if (typeof args[key] !== 'string')
150
+ throw invalid(`"${key}" must be a string.`);
151
+ out[key] = args[key];
152
+ }
153
+ }
154
+ if (args.output_mode !== undefined && args.output_mode !== null) {
155
+ if (args.output_mode !== 'content' && args.output_mode !== 'files_with_matches' && args.output_mode !== 'count')
156
+ throw invalid('"output_mode" is content, files_with_matches or count.');
157
+ out.output_mode = args.output_mode;
158
+ }
159
+ for (const key of ['-i', '-n', 'multiline']) {
160
+ if (args[key] !== undefined && args[key] !== null) {
161
+ if (typeof args[key] !== 'boolean')
162
+ throw invalid(`"${key}" must be true or false.`);
163
+ out[key] = args[key];
164
+ }
165
+ }
166
+ for (const key of ['-A', '-B', '-C', 'context', 'head_limit', 'offset']) {
167
+ const value = positiveInteger(args[key], key);
168
+ if (value !== undefined)
169
+ out[key] = value;
170
+ }
171
+ return out;
172
+ }
173
+ export async function grepTool(snapshot, args) {
174
+ const config = snapshot.store.config;
175
+ const searchPath = args.path === undefined ? null : resolveStorePath(args.path, config) || null;
176
+ const outcome = await ripgrepGrep(snapshot.store.root, args, searchPath, hiddenPrefixes(config));
177
+ if (outcome.kind === 'error')
178
+ throw new ToolRefusal('mcp.search_failed', `The search could not run: ${outcome.message}.`);
179
+ // design.md D12: Grep returns only what Read would read, so it never prints a file Read refuses.
180
+ const entries = outcome.kind === 'ok' ? outcome.entries.filter((e) => e.path === null || readablePath(e.path, config)) : [];
181
+ const all = [];
182
+ for (const e of entries) {
183
+ if (e.path === null) {
184
+ if (all.length > 0 && all[all.length - 1] !== '--')
185
+ all.push(e.rest ?? '--');
186
+ }
187
+ else if (e.rest === null)
188
+ all.push(e.path);
189
+ else
190
+ all.push(`${e.path}${/^\d+[-]/.test(e.rest) ? '-' : ':'}${e.rest}`);
191
+ }
192
+ while (all[all.length - 1] === '--')
193
+ all.pop();
194
+ const start = args.offset ?? 0;
195
+ const limit = Math.min(args.head_limit ?? GREP_MAX_LINES, GREP_MAX_LINES);
196
+ const lines = all.slice(start, start + limit);
197
+ // design.md D12: the duplicate `find` reveals, revealed here too. JavaScript's engine stands in for ripgrep's
198
+ // over a handful of small files; a pattern it cannot compile simply matches none of them.
199
+ const awaiting = [];
200
+ let regex = null;
201
+ try {
202
+ regex = new RegExp(args.pattern, args['-i'] === true ? 'i' : '');
203
+ }
204
+ catch {
205
+ regex = null;
206
+ }
207
+ if (regex !== null) {
208
+ for (const capture of snapshot.pending) {
209
+ if (searchPath !== null && !isUnderAnyPrefix(capture.path, [searchPath]))
210
+ continue;
211
+ const matching = capture.text
212
+ .split('\n')
213
+ .map((line, i) => ({ line, n: i + 1 }))
214
+ .filter(({ line }) => regex.test(line))
215
+ .slice(0, 3)
216
+ .map(({ line, n }) => `${n}:${line}`);
217
+ if (matching.length > 0)
218
+ awaiting.push({ path: capture.path, branch: capture.branch, lines: matching });
219
+ }
220
+ }
221
+ return { output_mode: args.output_mode ?? 'files_with_matches', lines, omitted: Math.max(0, all.length - start - lines.length), awaiting_approval: awaiting };
222
+ }
223
+ export function renderGrep(data) {
224
+ const r = data;
225
+ const out = r.lines.length > 0 ? [...r.lines] : ['No matches found.'];
226
+ if (r.omitted > 0)
227
+ out.push(`[${r.omitted} more not shown; use offset or narrow the search]`);
228
+ if (r.awaiting_approval.length > 0) {
229
+ out.push('', '[Captures awaiting approval, not yet in the store:]');
230
+ for (const c of r.awaiting_approval)
231
+ out.push(...c.lines.map((l) => `${c.path} (awaiting approval):${l}`));
232
+ }
233
+ return out.join('\n');
234
+ }
235
+ export const GLOB_INPUT_SCHEMA = {
236
+ type: 'object',
237
+ properties: {
238
+ pattern: { type: 'string', description: 'The glob pattern to match files against, e.g. "**/*.md" or "projects/**/*.md"' },
239
+ path: { type: 'string', description: 'The directory to search in, relative to the store root. Defaults to the whole store.' },
240
+ },
241
+ required: ['pattern'],
242
+ };
243
+ export function parseGlobArgs(args) {
244
+ if (typeof args.pattern !== 'string' || args.pattern === '')
245
+ throw new ToolRefusal('mcp.invalid_arguments', '"pattern" is required.');
246
+ if (args.path !== undefined && args.path !== null && typeof args.path !== 'string')
247
+ throw new ToolRefusal('mcp.invalid_arguments', '"path" must be a string.');
248
+ return { pattern: args.pattern, ...(typeof args.path === 'string' ? { path: args.path } : {}) };
249
+ }
250
+ export async function globTool(snapshot, args) {
251
+ const config = snapshot.store.config;
252
+ const searchPath = args.path === undefined ? null : resolveStorePath(args.path, config) || null;
253
+ const outcome = await ripgrepGlob(snapshot.store.root, args.pattern, searchPath, hiddenPrefixes(config));
254
+ if (outcome.kind === 'error')
255
+ throw new ToolRefusal('mcp.search_failed', `The file listing could not run: ${outcome.message}.`);
256
+ const files = outcome.kind === 'ok' ? outcome.entries.map((e) => e.path).filter((p) => p !== null && readablePath(p, config)) : [];
257
+ return { files: files.slice(0, GREP_MAX_LINES), omitted: Math.max(0, files.length - GREP_MAX_LINES) };
258
+ }
259
+ export function renderGlob(data) {
260
+ const r = data;
261
+ if (r.files.length === 0)
262
+ return 'No files found';
263
+ return [...r.files, ...(r.omitted > 0 ? [`[${r.omitted} more not shown; narrow the pattern]`] : [])].join('\n');
264
+ }
265
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1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,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,sCAAsC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClH,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { Snapshot } from '../sync.js';
2
+ /**
3
+ * remote-access spec, *`find` stands in for a client's own content
4
+ * matching*; context-retrieval's bounded exception. Literal,
5
+ * case-insensitive substring matching over the notes the store's
6
+ * enumeration admits, in path order, with no score. Captures — inbox files
7
+ * on the default branch and on pending `capture/` branches — come back in
8
+ * `unfiled`, never among the notes (context-ingest's exception, design.md
9
+ * D6). With no text, the catalog as a map to pick selectors from.
10
+ */
11
+ export declare const MAX_LINES_PER_HIT = 3;
12
+ export declare const MAX_LINE_CHARS = 240;
13
+ export declare const DEFAULT_MAX_MATCHES = 25;
14
+ export declare const DEFAULT_MAX_MAP_NOTES = 500;
15
+ export declare const MAX_RESULTS = 1000;
16
+ export interface FindArgs {
17
+ text?: string;
18
+ under?: string;
19
+ max?: number;
20
+ }
21
+ export interface MatchingLine {
22
+ line: number;
23
+ text: string;
24
+ }
25
+ export interface NoteHit {
26
+ path: string;
27
+ gloss: string;
28
+ lines: MatchingLine[];
29
+ matching_lines: number;
30
+ url: string | null;
31
+ }
32
+ export interface UnfiledHit {
33
+ path: string;
34
+ lines: MatchingLine[];
35
+ matching_lines: number;
36
+ pending_merge: boolean;
37
+ branch: string | null;
38
+ }
39
+ export type FindResult = {
40
+ mode: 'match';
41
+ text: string;
42
+ notes: NoteHit[];
43
+ notes_omitted: number;
44
+ unfiled: UnfiledHit[];
45
+ unfiled_omitted: number;
46
+ } | {
47
+ mode: 'map';
48
+ sections: {
49
+ id: string;
50
+ notes: {
51
+ path: string;
52
+ gloss: string;
53
+ url: string | null;
54
+ }[];
55
+ }[];
56
+ notes_omitted: number;
57
+ };
58
+ /**
59
+ * Plain on purpose: type, description and required only. Some clients (Gemini) accept a narrow subset of JSON
60
+ * Schema and drop a tool whose schema uses more; every limit is enforced by `parseFindArgs` instead.
61
+ */
62
+ export declare const FIND_INPUT_SCHEMA: {
63
+ readonly type: 'object';
64
+ readonly properties: {
65
+ readonly text: {
66
+ readonly type: 'string';
67
+ readonly description: 'Literal text to look for, case-insensitive. Omit it to get the map of the store instead.';
68
+ };
69
+ readonly under: {
70
+ readonly type: 'string';
71
+ readonly description: 'Only look under this folder of the store, e.g. "projects/".';
72
+ };
73
+ readonly max: {
74
+ readonly type: 'integer';
75
+ readonly description: "How many notes to return (default 25 when matching, 500 for the map).";
76
+ };
77
+ };
78
+ };
79
+ export declare function parseFindArgs(args: Record<string, unknown>): FindArgs;
80
+ /** `baseUrl` is `serve.base_url` from the configuration `serve` loaded: links point at the browsing surface it answers. */
81
+ export declare function find(snapshot: Snapshot, args: FindArgs, baseUrl: string | undefined): Promise<FindResult>;
82
+ //# sourceMappingURL=find.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/core/mcp/tools/find.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,WAAW,OAAO,CAAC;AAGhC,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,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