@vheins/local-memory-mcp 0.8.44 → 0.8.45

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.
@@ -1,49 +1,3 @@
1
- // src/mcp/capabilities.ts
2
- import { fileURLToPath } from "url";
3
- import path from "path";
4
- var __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- var pkgVersion = "0.1.0";
6
- if ("0.8.44") {
7
- pkgVersion = "0.8.44";
8
- } else {
9
- let searchDir = __dirname;
10
- for (let i = 0; i < 5; i++) {
11
- const candidate = path.join(searchDir, "package.json");
12
- try {
13
- if (fs.existsSync(candidate)) {
14
- const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
15
- if (pkg.name === "@vheins/local-memory-mcp" && pkg.version) {
16
- pkgVersion = pkg.version;
17
- break;
18
- }
19
- }
20
- } catch {
21
- }
22
- searchDir = path.dirname(searchDir);
23
- }
24
- }
25
- var MCP_PROTOCOL_VERSION = "2025-03-26";
26
- var CAPABILITIES = {
27
- serverInfo: {
28
- name: "mcp-memory-local",
29
- version: pkgVersion
30
- },
31
- capabilities: {
32
- completions: {},
33
- logging: {},
34
- resources: {
35
- subscribe: true,
36
- listChanged: true
37
- },
38
- tools: {
39
- listChanged: false
40
- },
41
- prompts: {
42
- listChanged: true
43
- }
44
- }
45
- };
46
-
47
1
  // src/mcp/utils/logger.ts
48
2
  import fs from "fs";
49
3
  var LEVELS = {
@@ -185,6 +139,108 @@ function createFileSink(logDir, maxFiles = 5) {
185
139
  };
186
140
  }
187
141
 
142
+ // src/mcp/session.ts
143
+ import path from "path";
144
+ import { fileURLToPath } from "url";
145
+ function createSessionContext() {
146
+ return {
147
+ roots: [],
148
+ supportsRoots: false,
149
+ supportsSampling: false,
150
+ supportsSamplingTools: false,
151
+ supportsElicitation: false,
152
+ supportsElicitationForm: false,
153
+ supportsElicitationUrl: false
154
+ };
155
+ }
156
+ function updateSessionFromInitialize(session, params) {
157
+ const capabilities = params?.capabilities || {};
158
+ session.clientInfo = params?.clientInfo;
159
+ session.clientCapabilities = capabilities;
160
+ session.supportsRoots = Boolean(capabilities.roots);
161
+ session.supportsSampling = Boolean(capabilities.sampling);
162
+ const sampling = capabilities.sampling;
163
+ session.supportsSamplingTools = Boolean(sampling?.tools);
164
+ session.supportsElicitation = Boolean(capabilities.elicitation);
165
+ session.supportsElicitationForm = supportsElicitationMode(capabilities.elicitation, "form");
166
+ session.supportsElicitationUrl = supportsElicitationMode(capabilities.elicitation, "url");
167
+ }
168
+ function supportsElicitationMode(capability, mode) {
169
+ if (!capability || typeof capability !== "object") {
170
+ return false;
171
+ }
172
+ const cap = capability;
173
+ if (mode === "form") {
174
+ return Object.keys(cap).length === 0 || typeof cap.form === "object";
175
+ }
176
+ return typeof cap.url === "object";
177
+ }
178
+ function updateSessionRoots(session, roots) {
179
+ const normalized = normalizeRoots(roots);
180
+ const previous = JSON.stringify(session.roots);
181
+ const next = JSON.stringify(normalized);
182
+ session.roots = normalized;
183
+ return previous !== next;
184
+ }
185
+ function normalizeRoots(roots) {
186
+ if (!Array.isArray(roots)) return [];
187
+ const seen = /* @__PURE__ */ new Set();
188
+ const normalized = [];
189
+ for (const root of roots) {
190
+ if (!root || typeof root !== "object") continue;
191
+ const r = root;
192
+ const uri = typeof r.uri === "string" ? r.uri : void 0;
193
+ const name = typeof r.name === "string" ? r.name : void 0;
194
+ if (!uri || seen.has(uri)) continue;
195
+ seen.add(uri);
196
+ normalized.push({ uri, name });
197
+ }
198
+ return normalized;
199
+ }
200
+ function extractRootsFromResult(result) {
201
+ return normalizeRoots(result?.roots);
202
+ }
203
+ function getFilesystemRoots(session) {
204
+ if (!session) return [];
205
+ const resolved = [];
206
+ for (const root of session.roots) {
207
+ if (!root.uri.startsWith("file://")) continue;
208
+ try {
209
+ resolved.push(path.resolve(fileURLToPath(root.uri)));
210
+ } catch {
211
+ }
212
+ }
213
+ return resolved;
214
+ }
215
+ function isPathWithinRoots(targetPath, session) {
216
+ const roots = getFilesystemRoots(session);
217
+ if (roots.length === 0) return true;
218
+ const normalizedTarget = path.resolve(targetPath);
219
+ return roots.some((rootPath) => {
220
+ const relative = path.relative(rootPath, normalizedTarget);
221
+ return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
222
+ });
223
+ }
224
+ function findContainingRoot(targetPath, session) {
225
+ const roots = getFilesystemRoots(session);
226
+ if (roots.length === 0) return null;
227
+ const normalizedTarget = path.resolve(targetPath);
228
+ for (const rootPath of roots) {
229
+ const relative = path.relative(rootPath, normalizedTarget);
230
+ if (relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative)) {
231
+ return rootPath;
232
+ }
233
+ }
234
+ return null;
235
+ }
236
+ function inferRepoFromSession(session) {
237
+ const roots = getFilesystemRoots(session);
238
+ if (roots.length === 1) {
239
+ return path.basename(roots[0]);
240
+ }
241
+ return void 0;
242
+ }
243
+
188
244
  // src/mcp/storage/sqlite.ts
189
245
  import Database from "better-sqlite3";
190
246
  import path3 from "path";
@@ -2563,1008 +2619,1124 @@ var SQLiteStore = class _SQLiteStore {
2563
2619
  }
2564
2620
  };
2565
2621
 
2566
- // src/mcp/session.ts
2567
- import path4 from "path";
2622
+ // src/mcp/capabilities.ts
2568
2623
  import { fileURLToPath as fileURLToPath2 } from "url";
2569
- function createSessionContext() {
2570
- return {
2571
- roots: [],
2572
- supportsRoots: false,
2573
- supportsSampling: false,
2574
- supportsSamplingTools: false,
2575
- supportsElicitation: false,
2576
- supportsElicitationForm: false,
2577
- supportsElicitationUrl: false
2578
- };
2579
- }
2580
- function updateSessionFromInitialize(session, params) {
2581
- const capabilities = params?.capabilities || {};
2582
- session.clientInfo = params?.clientInfo;
2583
- session.clientCapabilities = capabilities;
2584
- session.supportsRoots = Boolean(capabilities.roots);
2585
- session.supportsSampling = Boolean(capabilities.sampling);
2586
- const sampling = capabilities.sampling;
2587
- session.supportsSamplingTools = Boolean(sampling?.tools);
2588
- session.supportsElicitation = Boolean(capabilities.elicitation);
2589
- session.supportsElicitationForm = supportsElicitationMode(capabilities.elicitation, "form");
2590
- session.supportsElicitationUrl = supportsElicitationMode(capabilities.elicitation, "url");
2591
- }
2592
- function supportsElicitationMode(capability, mode) {
2593
- if (!capability || typeof capability !== "object") {
2594
- return false;
2595
- }
2596
- const cap = capability;
2597
- if (mode === "form") {
2598
- return Object.keys(cap).length === 0 || typeof cap.form === "object";
2599
- }
2600
- return typeof cap.url === "object";
2601
- }
2602
- function updateSessionRoots(session, roots) {
2603
- const normalized = normalizeRoots(roots);
2604
- const previous = JSON.stringify(session.roots);
2605
- const next = JSON.stringify(normalized);
2606
- session.roots = normalized;
2607
- return previous !== next;
2608
- }
2609
- function normalizeRoots(roots) {
2610
- if (!Array.isArray(roots)) return [];
2611
- const seen = /* @__PURE__ */ new Set();
2612
- const normalized = [];
2613
- for (const root of roots) {
2614
- if (!root || typeof root !== "object") continue;
2615
- const r = root;
2616
- const uri = typeof r.uri === "string" ? r.uri : void 0;
2617
- const name = typeof r.name === "string" ? r.name : void 0;
2618
- if (!uri || seen.has(uri)) continue;
2619
- seen.add(uri);
2620
- normalized.push({ uri, name });
2621
- }
2622
- return normalized;
2623
- }
2624
- function extractRootsFromResult(result) {
2625
- return normalizeRoots(result?.roots);
2626
- }
2627
- function getFilesystemRoots(session) {
2628
- if (!session) return [];
2629
- const resolved = [];
2630
- for (const root of session.roots) {
2631
- if (!root.uri.startsWith("file://")) continue;
2624
+ import path4 from "path";
2625
+ var __dirname = path4.dirname(fileURLToPath2(import.meta.url));
2626
+ var pkgVersion = "0.1.0";
2627
+ if ("0.8.45") {
2628
+ pkgVersion = "0.8.45";
2629
+ } else {
2630
+ let searchDir = __dirname;
2631
+ for (let i = 0; i < 5; i++) {
2632
+ const candidate = path4.join(searchDir, "package.json");
2632
2633
  try {
2633
- resolved.push(path4.resolve(fileURLToPath2(root.uri)));
2634
+ if (fs.existsSync(candidate)) {
2635
+ const pkg = JSON.parse(fs.readFileSync(candidate, "utf8"));
2636
+ if (pkg.name === "@vheins/local-memory-mcp" && pkg.version) {
2637
+ pkgVersion = pkg.version;
2638
+ break;
2639
+ }
2640
+ }
2634
2641
  } catch {
2635
2642
  }
2643
+ searchDir = path4.dirname(searchDir);
2636
2644
  }
2637
- return resolved;
2638
- }
2639
- function isPathWithinRoots(targetPath, session) {
2640
- const roots = getFilesystemRoots(session);
2641
- if (roots.length === 0) return true;
2642
- const normalizedTarget = path4.resolve(targetPath);
2643
- return roots.some((rootPath) => {
2644
- const relative = path4.relative(rootPath, normalizedTarget);
2645
- return relative === "" || !relative.startsWith("..") && !path4.isAbsolute(relative);
2646
- });
2647
2645
  }
2648
- function findContainingRoot(targetPath, session) {
2649
- const roots = getFilesystemRoots(session);
2650
- if (roots.length === 0) return null;
2651
- const normalizedTarget = path4.resolve(targetPath);
2652
- for (const rootPath of roots) {
2653
- const relative = path4.relative(rootPath, normalizedTarget);
2654
- if (relative === "" || !relative.startsWith("..") && !path4.isAbsolute(relative)) {
2655
- return rootPath;
2646
+ var MCP_PROTOCOL_VERSION = "2025-03-26";
2647
+ var CAPABILITIES = {
2648
+ serverInfo: {
2649
+ name: "mcp-memory-local",
2650
+ version: pkgVersion
2651
+ },
2652
+ capabilities: {
2653
+ completions: {},
2654
+ logging: {},
2655
+ resources: {
2656
+ subscribe: true,
2657
+ listChanged: true
2658
+ },
2659
+ tools: {
2660
+ listChanged: false
2661
+ },
2662
+ prompts: {
2663
+ listChanged: true
2656
2664
  }
2657
2665
  }
2658
- return null;
2666
+ };
2667
+
2668
+ // src/mcp/utils/pagination.ts
2669
+ function encodeCursor(offset) {
2670
+ return Buffer.from(String(offset), "utf8").toString("base64");
2659
2671
  }
2660
- function inferRepoFromSession(session) {
2661
- const roots = getFilesystemRoots(session);
2662
- if (roots.length === 1) {
2663
- return path4.basename(roots[0]);
2672
+ function decodeCursor(cursor) {
2673
+ if (cursor === void 0 || cursor === null || cursor === "") {
2674
+ return 0;
2664
2675
  }
2665
- return void 0;
2676
+ if (typeof cursor !== "string" || cursor.trim() === "") {
2677
+ throw invalidPaginationParams("Invalid cursor");
2678
+ }
2679
+ let decoded;
2680
+ try {
2681
+ decoded = Buffer.from(cursor, "base64").toString("utf8");
2682
+ } catch {
2683
+ throw invalidPaginationParams("Invalid cursor");
2684
+ }
2685
+ if (!/^\d+$/.test(decoded)) {
2686
+ throw invalidPaginationParams("Invalid cursor");
2687
+ }
2688
+ const offset = Number.parseInt(decoded, 10);
2689
+ if (!Number.isFinite(offset) || offset < 0) {
2690
+ throw invalidPaginationParams("Invalid cursor");
2691
+ }
2692
+ return offset;
2693
+ }
2694
+ function invalidPaginationParams(message) {
2695
+ const error = new Error(message);
2696
+ error.code = -32602;
2697
+ return error;
2666
2698
  }
2667
2699
 
2668
- // src/mcp/tools/schemas.ts
2669
- import { z } from "zod";
2670
- var MemoryScopeSchema = z.object({
2671
- repo: z.string().min(1).transform(normalizeRepo),
2672
- branch: z.string().optional(),
2673
- folder: z.string().optional(),
2674
- language: z.string().optional()
2675
- });
2676
- var MemoryTypeSchema = z.enum([
2677
- "code_fact",
2678
- "decision",
2679
- "mistake",
2680
- "pattern",
2681
- "file_claim",
2682
- "task_archive"
2683
- ]);
2684
- var MemoryStoreSchema = z.object({
2685
- code: z.string().max(20).optional(),
2686
- type: MemoryTypeSchema,
2687
- title: z.string().min(3).max(255),
2688
- content: z.string().min(10),
2689
- importance: z.number().min(1).max(5),
2690
- agent: z.string().min(1),
2691
- role: z.string().optional().default("unknown"),
2692
- model: z.string().min(1),
2693
- scope: MemoryScopeSchema,
2694
- ttlDays: z.number().min(1).optional(),
2695
- supersedes: z.string().uuid().optional(),
2696
- tags: z.array(z.string()).optional(),
2697
- metadata: z.record(z.string(), z.any()).optional(),
2698
- is_global: z.boolean().default(false),
2699
- structured: z.boolean().default(false)
2700
- });
2701
- var MemoryUpdateSchema = z.object({
2702
- id: z.string().uuid(),
2703
- type: MemoryTypeSchema.optional(),
2704
- title: z.string().min(3).max(255).optional(),
2705
- content: z.string().min(10).optional(),
2706
- importance: z.number().min(1).max(5).optional(),
2707
- agent: z.string().optional(),
2708
- role: z.string().optional(),
2709
- status: z.enum(["active", "archived"]).optional(),
2710
- supersedes: z.string().uuid().optional(),
2711
- tags: z.array(z.string()).optional(),
2712
- metadata: z.record(z.string(), z.any()).optional(),
2713
- is_global: z.boolean().optional(),
2714
- completed_at: z.string().optional(),
2715
- structured: z.boolean().default(false)
2716
- }).refine(
2717
- (data) => data.type !== void 0 || data.content !== void 0 || data.title !== void 0 || data.importance !== void 0 || data.status !== void 0 || data.supersedes !== void 0 || data.tags !== void 0 || data.metadata !== void 0 || data.is_global !== void 0 || data.agent !== void 0 || data.role !== void 0 || data.completed_at !== void 0,
2718
- { message: "At least one field must be provided for update" }
2719
- );
2720
- var MemorySearchSchema = z.object({
2721
- query: z.string().min(3),
2722
- prompt: z.string().optional(),
2723
- repo: z.string().min(1).transform(normalizeRepo),
2724
- types: z.array(MemoryTypeSchema).optional(),
2725
- minImportance: z.number().min(1).max(5).optional(),
2726
- limit: z.number().min(1).max(100).default(5),
2727
- offset: z.number().min(0).default(0),
2728
- includeRecap: z.boolean().default(false),
2729
- current_file_path: z.string().optional(),
2730
- include_archived: z.boolean().default(false),
2731
- current_tags: z.array(z.string()).optional(),
2732
- scope: MemoryScopeSchema.partial().optional(),
2733
- structured: z.boolean().default(false)
2734
- });
2735
- var MemoryAcknowledgeSchema = z.object({
2736
- memory_id: z.string().uuid(),
2737
- status: z.enum(["used", "irrelevant", "contradictory"]),
2738
- application_context: z.string().min(10).optional(),
2739
- structured: z.boolean().default(false)
2740
- });
2741
- var MemoryRecapSchema = z.object({
2742
- repo: z.string().min(1).transform(normalizeRepo),
2743
- limit: z.number().min(1).max(50).default(20),
2744
- offset: z.number().min(0).default(0),
2745
- structured: z.boolean().default(false)
2746
- });
2747
- var MemoryDeleteSchema = z.object({
2748
- repo: z.string().min(1).transform(normalizeRepo).optional(),
2749
- id: z.string().uuid().optional(),
2750
- ids: z.array(z.string().uuid()).min(1).optional(),
2751
- structured: z.boolean().default(false)
2752
- }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
2753
- message: "Either 'id' or 'ids' must be provided for deletion"
2754
- });
2755
- var MemorySummarizeSchema = z.object({
2756
- repo: z.string().min(1).transform(normalizeRepo),
2757
- signals: z.array(z.string().max(200)).min(1),
2758
- structured: z.boolean().default(false)
2759
- });
2760
- var MemorySynthesizeSchema = z.object({
2761
- repo: z.string().min(1).transform(normalizeRepo).optional(),
2762
- objective: z.string().min(5),
2763
- current_file_path: z.string().optional(),
2764
- include_summary: z.boolean().default(true),
2765
- include_tasks: z.boolean().default(true),
2766
- use_tools: z.boolean().default(true),
2767
- max_iterations: z.number().int().min(1).max(5).default(3),
2768
- max_tokens: z.number().int().min(128).max(4e3).default(1200),
2769
- structured: z.boolean().default(false)
2770
- });
2771
- var TaskStatusSchema = z.enum(["backlog", "pending", "in_progress", "completed", "canceled", "blocked"]);
2772
- var TaskPrioritySchema = z.number().min(1).max(5);
2773
- var SingleTaskCreateSchema = z.object({
2774
- task_code: z.string().min(1),
2775
- phase: z.string().min(1),
2776
- title: z.string().min(3).max(100),
2777
- description: z.string().min(1),
2778
- status: TaskStatusSchema.default("backlog"),
2779
- priority: TaskPrioritySchema.default(3),
2780
- agent: z.string().optional(),
2781
- role: z.string().optional(),
2782
- doc_path: z.string().optional(),
2783
- tags: z.array(z.string()).optional(),
2784
- metadata: z.record(z.string(), z.any()).optional(),
2785
- parent_id: z.string().uuid().optional(),
2786
- depends_on: z.string().uuid().optional(),
2787
- est_tokens: z.number().int().min(0).optional()
2788
- });
2789
- var TaskCreateSchema = z.object({
2790
- repo: z.string().min(1).transform(normalizeRepo),
2791
- // Allow single task fields at top level (backward compatibility & single use)
2792
- task_code: z.string().min(1).optional(),
2793
- phase: z.string().min(1).optional(),
2794
- title: z.string().min(3).max(100).optional(),
2795
- description: z.string().min(1).optional(),
2796
- status: TaskStatusSchema.optional(),
2797
- priority: TaskPrioritySchema.optional(),
2798
- agent: z.string().optional(),
2799
- role: z.string().optional(),
2800
- doc_path: z.string().optional(),
2801
- tags: z.array(z.string()).optional(),
2802
- metadata: z.record(z.string(), z.any()).optional(),
2803
- parent_id: z.string().uuid().optional(),
2804
- depends_on: z.string().uuid().optional(),
2805
- est_tokens: z.number().int().min(0).optional(),
2806
- // Allow bulk tasks
2807
- tasks: z.array(SingleTaskCreateSchema).min(1).optional(),
2808
- structured: z.boolean().default(false)
2809
- }).refine(
2810
- (data) => {
2811
- if (data.tasks) return true;
2812
- return !!(data.task_code && data.phase && data.title && data.description);
2813
- },
2814
- { message: "Either 'tasks' array or single task fields (task_code, phase, title, description) must be provided" }
2815
- );
2816
- var TaskCreateInteractiveSchema = SingleTaskCreateSchema.partial().extend({
2817
- repo: z.string().min(1).transform(normalizeRepo).optional(),
2818
- structured: z.boolean().default(false)
2819
- });
2820
- var TaskUpdateSchema = z.object({
2821
- repo: z.string().min(1).transform(normalizeRepo),
2822
- id: z.string().uuid().optional(),
2823
- ids: z.array(z.string().uuid()).min(1).optional(),
2824
- task_code: z.string().optional(),
2825
- phase: z.string().optional(),
2826
- title: z.string().min(3).max(100).optional(),
2827
- description: z.string().optional(),
2828
- status: TaskStatusSchema.optional(),
2829
- priority: TaskPrioritySchema.optional(),
2830
- agent: z.string().min(1, "agent name is required").optional(),
2831
- role: z.string().min(1, "agent role is required").optional(),
2832
- model: z.string().optional(),
2833
- comment: z.string().min(1).optional(),
2834
- doc_path: z.string().optional(),
2835
- tags: z.array(z.string()).optional(),
2836
- metadata: z.record(z.string(), z.any()).optional(),
2837
- parent_id: z.string().uuid().optional(),
2838
- depends_on: z.string().uuid().optional(),
2839
- est_tokens: z.number().int().min(0).optional(),
2840
- force: z.boolean().optional(),
2841
- structured: z.boolean().default(false)
2842
- }).refine((data) => data.id !== void 0 || data.ids !== void 0 || data.task_code !== void 0, {
2843
- message: "Either 'id', 'ids', or 'task_code' must be provided for update"
2844
- }).refine((data) => Object.keys(data).length > 2, {
2845
- message: "At least one field besides repo and id/ids must be provided for update"
2846
- });
2847
- var TaskListSchema = z.object({
2848
- repo: z.string().min(1).transform(normalizeRepo),
2849
- status: z.string().optional(),
2850
- phase: z.string().optional(),
2851
- query: z.string().optional(),
2852
- limit: z.number().min(1).max(100).default(15),
2853
- offset: z.number().min(0).default(0),
2854
- structured: z.boolean().default(false)
2855
- });
2856
- var TaskSearchSchema = z.object({
2857
- repo: z.string().min(1).transform(normalizeRepo),
2858
- query: z.string().min(1),
2859
- status: z.string().optional(),
2860
- limit: z.number().min(1).max(100).default(10),
2861
- offset: z.number().min(0).default(0),
2862
- structured: z.boolean().default(false)
2863
- });
2864
- var TaskDeleteSchema = z.object({
2865
- repo: z.string().min(1).transform(normalizeRepo),
2866
- id: z.string().uuid().optional(),
2867
- ids: z.array(z.string().uuid()).min(1).optional(),
2868
- structured: z.boolean().default(false)
2869
- }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
2870
- message: "Either 'id' or 'ids' must be provided for deletion"
2871
- });
2872
- var MemoryDetailSchema = z.object({
2873
- id: z.string().uuid().optional(),
2874
- code: z.string().max(20).optional(),
2875
- structured: z.boolean().default(false)
2876
- }).refine((data) => data.id !== void 0 || data.code !== void 0, {
2877
- message: "Either id or code must be provided"
2878
- });
2879
- var TaskGetSchema = z.object({
2880
- repo: z.string().min(1).transform(normalizeRepo),
2881
- id: z.string().uuid().optional(),
2882
- task_code: z.string().optional(),
2883
- structured: z.boolean().default(false)
2884
- }).refine((data) => data.id !== void 0 || data.task_code !== void 0, {
2885
- message: "Either id or task_code must be provided"
2886
- });
2887
- var HandoffStatusSchema = z.enum(["pending", "accepted", "rejected", "expired"]);
2888
- var HandoffCreateSchema = z.object({
2889
- repo: z.string().min(1).transform(normalizeRepo),
2890
- from_agent: z.string().min(1),
2891
- to_agent: z.string().min(1).optional(),
2892
- task_id: z.string().uuid().optional(),
2893
- task_code: z.string().optional(),
2894
- summary: z.string().min(1),
2895
- context: z.record(z.string(), z.any()).optional(),
2896
- expires_at: z.string().optional(),
2897
- structured: z.boolean().default(false)
2898
- }).refine((data) => !(data.task_id && data.task_code), {
2899
- message: "Provide either task_id or task_code, not both"
2900
- });
2901
- var HandoffListSchema = z.object({
2902
- repo: z.string().min(1).transform(normalizeRepo),
2903
- status: HandoffStatusSchema.optional(),
2904
- from_agent: z.string().min(1).optional(),
2905
- to_agent: z.string().min(1).optional(),
2906
- limit: z.number().min(1).max(100).default(20),
2907
- offset: z.number().min(0).default(0),
2908
- structured: z.boolean().default(false)
2909
- });
2910
- var TaskClaimSchema = z.object({
2911
- repo: z.string().min(1).transform(normalizeRepo),
2912
- task_id: z.string().uuid().optional(),
2913
- task_code: z.string().optional(),
2914
- agent: z.string().min(1),
2915
- role: z.string().optional(),
2916
- metadata: z.record(z.string(), z.any()).optional(),
2917
- structured: z.boolean().default(false)
2918
- }).refine((data) => data.task_id !== void 0 || data.task_code !== void 0, {
2919
- message: "Either task_id or task_code must be provided"
2920
- }).refine((data) => !(data.task_id && data.task_code), {
2921
- message: "Provide either task_id or task_code, not both"
2922
- });
2923
- var StandardStoreSchema = z.object({
2924
- name: z.string().min(3).max(255),
2925
- content: z.string().min(10),
2926
- context: z.string().optional(),
2927
- version: z.string().optional(),
2928
- language: z.string().optional(),
2929
- stack: z.array(z.string()).optional(),
2930
- repo: z.string().optional(),
2931
- is_global: z.boolean().optional(),
2932
- tags: z.array(z.string()).optional(),
2933
- metadata: z.record(z.string(), z.any()).optional(),
2934
- agent: z.string().optional(),
2935
- model: z.string().optional(),
2936
- structured: z.boolean().default(false)
2937
- });
2938
- var StandardSearchSchema = z.object({
2939
- query: z.string().optional(),
2940
- stack: z.array(z.string()).optional(),
2941
- language: z.string().optional(),
2942
- version: z.string().optional(),
2943
- repo: z.string().optional(),
2944
- is_global: z.boolean().optional(),
2945
- limit: z.number().min(1).max(100).default(20),
2946
- offset: z.number().min(0).default(0),
2947
- structured: z.boolean().default(false)
2948
- });
2949
- var TOOL_DEFINITIONS = [
2950
- {
2951
- name: "memory-synthesize",
2952
- title: "Memory Synthesize",
2953
- description: "Use client sampling to synthesize a grounded answer from local memory and tasks. Best for project briefings, tradeoff summaries, and context-aware answers.",
2954
- annotations: {
2955
- readOnlyHint: true,
2956
- idempotentHint: true,
2957
- openWorldHint: false
2700
+ // src/mcp/utils/completion.ts
2701
+ var MAX_COMPLETION_VALUES = 100;
2702
+ function rankCompletionValues(candidates, input) {
2703
+ const unique = [...new Set(candidates.filter(Boolean))];
2704
+ const needle = input.trim().toLowerCase();
2705
+ if (!needle) {
2706
+ return unique.slice(0, MAX_COMPLETION_VALUES);
2707
+ }
2708
+ return unique.map((value) => ({ value, score: scoreCompletionValue(value, needle) })).filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score || a.value.localeCompare(b.value)).map((entry) => entry.value);
2709
+ }
2710
+ function scoreCompletionValue(value, needle) {
2711
+ const haystack = value.toLowerCase();
2712
+ if (haystack === needle) return 100;
2713
+ if (haystack.startsWith(needle)) return 75;
2714
+ if (haystack.includes(needle)) return 50;
2715
+ const compactNeedle = needle.replace(/[\s_-]+/g, "");
2716
+ const compactHaystack = haystack.replace(/[\s_-]+/g, "");
2717
+ if (compactNeedle && compactHaystack.includes(compactNeedle)) return 25;
2718
+ return 0;
2719
+ }
2720
+
2721
+ // src/mcp/resources/index.ts
2722
+ var DEFAULT_PAGE_SIZE = 25;
2723
+ var MAX_PAGE_SIZE = 100;
2724
+ function listResources(session, params) {
2725
+ const resources = [
2726
+ {
2727
+ uri: "repository://index",
2728
+ name: "Repository Index",
2729
+ title: "Repository Index",
2730
+ description: "List of all known repositories with memory/task counts and last activity",
2731
+ mimeType: "application/json",
2732
+ annotations: {
2733
+ audience: ["assistant"],
2734
+ priority: 1,
2735
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
2736
+ }
2958
2737
  },
2959
- execution: {
2960
- taskSupport: "optional"
2738
+ {
2739
+ uri: "session://roots",
2740
+ name: "Session Roots",
2741
+ title: "Session Roots",
2742
+ description: session?.roots.length ? "Active workspace roots provided by the MCP client" : "No active workspace roots were provided by the MCP client",
2743
+ mimeType: "application/json",
2744
+ size: Buffer.byteLength(JSON.stringify({ roots: session?.roots ?? [] }), "utf8"),
2745
+ annotations: {
2746
+ audience: ["assistant"],
2747
+ priority: 0.95,
2748
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
2749
+ }
2750
+ }
2751
+ ];
2752
+ return paginateEntries("resources", resources, params);
2753
+ }
2754
+ function listResourceTemplates(params) {
2755
+ const templates = [
2756
+ // ── Memory ──────────────────────────────────────────────────────────────
2757
+ {
2758
+ uriTemplate: "repository://{name}/memories",
2759
+ name: "Repository Memories",
2760
+ title: "Repository Memories",
2761
+ description: "All active memory entries for a specific repository",
2762
+ mimeType: "application/json",
2763
+ annotations: { audience: ["assistant"], priority: 0.85 }
2961
2764
  },
2962
- inputSchema: {
2963
- type: "object",
2964
- properties: {
2965
- repo: { type: "string", description: "Repository name. Optional when a single MCP root is active." },
2966
- objective: { type: "string", minLength: 5, description: "Question or synthesis objective." },
2967
- current_file_path: {
2968
- type: "string",
2969
- description: "Optional absolute file path for workspace-local grounding."
2970
- },
2971
- include_summary: { type: "boolean", default: true },
2972
- include_tasks: { type: "boolean", default: true },
2973
- use_tools: {
2974
- type: "boolean",
2975
- default: true,
2976
- description: "Allow the sampled model to call local memory/task tools during synthesis when the client supports sampling.tools."
2977
- },
2978
- max_iterations: { type: "number", minimum: 1, maximum: 5, default: 3 },
2979
- max_tokens: { type: "number", minimum: 128, maximum: 4e3, default: 1200 },
2980
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON results." }
2981
- },
2982
- required: ["objective"]
2765
+ {
2766
+ uriTemplate: "repository://{name}/memories?search={search}&type={type}&tag={tag}",
2767
+ name: "Filtered Repository Memories",
2768
+ title: "Filtered Repository Memories",
2769
+ description: "Filter or search memories within a repository by keyword, type, or tag",
2770
+ mimeType: "application/json",
2771
+ annotations: { audience: ["assistant"], priority: 0.8 }
2983
2772
  },
2984
- outputSchema: {
2985
- type: "object",
2986
- properties: {
2987
- repo: { type: "string" },
2988
- objective: { type: "string" },
2989
- answer: { type: "string" },
2990
- model: { type: "string" },
2991
- stopReason: { type: "string" },
2992
- iterations: { type: "number" },
2993
- toolCalls: { type: "number" }
2994
- },
2995
- required: ["repo", "objective", "answer", "iterations", "toolCalls"]
2996
- }
2997
- },
2998
- {
2999
- name: "task-create-interactive",
3000
- title: "Interactive Task Create",
3001
- description: "Create a task with MCP elicitation fallback for any missing required fields. Best when an agent knows a task is needed but still needs user confirmation for repo, title, or phase.",
3002
- annotations: {
3003
- readOnlyHint: false,
3004
- idempotentHint: false,
3005
- destructiveHint: false,
3006
- openWorldHint: false
2773
+ {
2774
+ uriTemplate: "memory://{id}",
2775
+ name: "Memory Detail",
2776
+ title: "Memory Detail",
2777
+ description: "Full content and statistics for a specific memory UUID",
2778
+ mimeType: "application/json",
2779
+ annotations: { audience: ["assistant"], priority: 0.75 }
3007
2780
  },
3008
- inputSchema: {
3009
- type: "object",
3010
- properties: {
3011
- repo: {
3012
- type: "string",
3013
- description: "Repository name. Optional when it can be inferred from MCP roots or elicited from the user."
3014
- },
3015
- task_code: { type: "string" },
3016
- phase: { type: "string" },
3017
- title: { type: "string", minLength: 3, maxLength: 100 },
3018
- description: { type: "string", minLength: 1 },
3019
- status: { type: "string", enum: ["backlog", "pending"], default: "backlog" },
3020
- priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
3021
- agent: { type: "string" },
3022
- role: { type: "string" },
3023
- doc_path: { type: "string" },
3024
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3025
- }
2781
+ // ── Tasks ────────────────────────────────────────────────────────────────
2782
+ {
2783
+ uriTemplate: "repository://{name}/tasks",
2784
+ name: "Repository Tasks",
2785
+ title: "Repository Tasks",
2786
+ description: "All active tasks for a specific repository",
2787
+ mimeType: "application/json",
2788
+ annotations: { audience: ["assistant"], priority: 0.9 }
2789
+ },
2790
+ {
2791
+ uriTemplate: "repository://{name}/tasks?status={status}&priority={priority}",
2792
+ name: "Filtered Repository Tasks",
2793
+ title: "Filtered Repository Tasks",
2794
+ description: "Filter tasks within a repository by status or priority level",
2795
+ mimeType: "application/json",
2796
+ annotations: { audience: ["assistant"], priority: 0.85 }
2797
+ },
2798
+ {
2799
+ uriTemplate: "task://{id}",
2800
+ name: "Task Detail",
2801
+ title: "Task Detail",
2802
+ description: "Full content and comments for a specific task UUID",
2803
+ mimeType: "application/json",
2804
+ annotations: { audience: ["assistant"], priority: 0.8 }
2805
+ },
2806
+ // ── Repository extras ────────────────────────────────────────────────────
2807
+ {
2808
+ uriTemplate: "repository://{name}/summary",
2809
+ name: "Repository Summary",
2810
+ title: "Repository Summary",
2811
+ description: "High-level architectural summary for a repository",
2812
+ mimeType: "text/plain",
2813
+ annotations: { audience: ["assistant"], priority: 0.95 }
3026
2814
  },
3027
- outputSchema: {
3028
- type: "object",
3029
- properties: {
3030
- repo: { type: "string" },
3031
- task_code: { type: "string" },
3032
- phase: { type: "string" },
3033
- title: { type: "string" },
3034
- status: { type: "string" },
3035
- priority: { type: "number" }
3036
- },
3037
- required: ["repo", "task_code", "phase", "title", "status", "priority"]
2815
+ {
2816
+ uriTemplate: "repository://{name}/actions",
2817
+ name: "Repository Actions",
2818
+ title: "Repository Actions",
2819
+ description: "Audit log of agent tool actions scoped to a repository",
2820
+ mimeType: "application/json",
2821
+ annotations: { audience: ["assistant"], priority: 0.6 }
2822
+ },
2823
+ // ── Action detail ────────────────────────────────────────────────────────
2824
+ {
2825
+ uriTemplate: "action://{id}",
2826
+ name: "Action Detail",
2827
+ title: "Action Detail",
2828
+ description: "Full details of a specific audit log entry by integer ID",
2829
+ mimeType: "application/json",
2830
+ annotations: { audience: ["assistant"], priority: 0.55 }
3038
2831
  }
3039
- },
3040
- {
3041
- name: "memory-detail",
3042
- title: "Memory Detail",
3043
- description: "Fetch full details of a specific memory by ID or short code. Use after memory-recap or memory-search when a pointer row is relevant and full content is needed.",
3044
- inputSchema: {
3045
- type: "object",
3046
- properties: {
3047
- id: { type: "string", format: "uuid", description: "Memory entry ID. Optional if code is provided." },
3048
- code: { type: "string", description: "Short memory code. Optional if id is provided." },
3049
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON details." }
3050
- }
2832
+ ];
2833
+ return paginateEntries("resourceTemplates", templates, params);
2834
+ }
2835
+ function completeResourceArgument(resourceUri, argumentName, argumentValue, _contextArguments, dataSources) {
2836
+ if (resourceUri === "repository://{name}/memories" || resourceUri === "repository://{name}/memories?search={search}&type={type}&tag={tag}" || resourceUri === "repository://{name}/tasks" || resourceUri === "repository://{name}/tasks?status={status}&priority={priority}" || resourceUri === "repository://{name}/summary" || resourceUri === "repository://{name}/actions") {
2837
+ if (argumentName === "name") {
2838
+ return rankCompletionValues(dataSources.repos, argumentValue);
3051
2839
  }
3052
- },
3053
- {
3054
- name: "task-detail",
3055
- title: "Task Detail",
3056
- description: "Fetch full details of a specific task by ID or task code. Use this when you have a task ID or code and need to read the full description and comments.",
3057
- inputSchema: {
3058
- type: "object",
3059
- properties: {
3060
- repo: { type: "string", description: "Repository name" },
3061
- id: { type: "string", format: "uuid", description: "Task ID (optional if task_code is provided)" },
3062
- task_code: { type: "string", description: "Task code (e.g. TASK-001) (optional if id is provided)" },
3063
- structured: {
3064
- type: "boolean",
3065
- default: false,
3066
- description: "If true, returns structured JSON without the text content details."
3067
- }
3068
- },
3069
- required: ["repo"]
2840
+ }
2841
+ if (resourceUri === "repository://{name}/memories?search={search}&type={type}&tag={tag}") {
2842
+ if (argumentName === "tag") {
2843
+ return rankCompletionValues(dataSources.tags, argumentValue);
3070
2844
  }
3071
- },
3072
- {
3073
- name: "memory-store",
3074
- title: "Memory Store",
3075
- description: "Store a new memory entry. Keep 'title' concise and human-readable; do not embed agent/role/date metadata in the title. Put auxiliary context into 'metadata'. Use 'tags' for tech-stack and 'is_global' for universal rules.",
3076
- annotations: {
3077
- readOnlyHint: false,
3078
- idempotentHint: false,
3079
- destructiveHint: false,
3080
- openWorldHint: false
3081
- },
3082
- inputSchema: {
3083
- type: "object",
3084
- properties: {
3085
- type: {
3086
- type: "string",
3087
- enum: [
3088
- "code_fact",
3089
- "decision",
3090
- "mistake",
3091
- "pattern",
3092
- "file_claim",
3093
- "task_archive"
3094
- ],
3095
- description: "Type of memory being stored"
3096
- },
3097
- title: {
3098
- type: "string",
3099
- minLength: 3,
3100
- maxLength: 100,
3101
- description: "Short human-readable title for the memory. Do not embed bracketed metadata like agent/role/date prefixes here."
3102
- },
3103
- content: {
3104
- type: "string",
3105
- minLength: 10,
3106
- description: "The memory content"
3107
- },
3108
- importance: {
3109
- type: "number",
3110
- minimum: 1,
3111
- maximum: 5,
3112
- description: "Importance score (1-5)"
3113
- },
3114
- agent: {
3115
- type: "string",
3116
- description: "Name of the agent creating this memory"
3117
- },
3118
- role: {
3119
- type: "string",
3120
- description: "Role of the agent creating this memory"
3121
- },
3122
- model: {
3123
- type: "string",
3124
- description: "AI model used by the agent"
3125
- },
3126
- scope: {
3127
- type: "object",
3128
- properties: {
3129
- repo: { type: "string", description: "Repository name" },
3130
- branch: { type: "string" },
3131
- folder: { type: "string" },
3132
- language: { type: "string" }
3133
- },
3134
- required: ["repo"]
3135
- },
3136
- tags: {
3137
- type: "array",
3138
- items: { type: "string" },
3139
- description: "Technology stack tags (e.g., ['filament', 'laravel'])"
3140
- },
3141
- metadata: {
3142
- type: "object",
3143
- description: "Structured metadata for non-title context such as source agent, claim fields, or timestamps"
3144
- },
3145
- is_global: {
3146
- type: "boolean",
3147
- description: "If true, this memory is shared across all repositories"
3148
- },
3149
- ttlDays: { type: "number", minimum: 1 },
3150
- supersedes: { type: "string", format: "uuid" },
3151
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the stored memory." }
3152
- },
3153
- required: ["type", "title", "content", "importance", "scope", "agent", "model"]
3154
- },
3155
- outputSchema: {
3156
- type: "object",
3157
- properties: {
3158
- success: { type: "boolean" },
3159
- id: { type: "string" },
3160
- code: { type: "string" },
3161
- repo: { type: "string" },
3162
- type: { type: "string" },
3163
- title: { type: "string" },
3164
- error: { type: "string" },
3165
- message: { type: "string" }
3166
- },
3167
- required: ["success"]
2845
+ }
2846
+ throw invalidCompletionParams(`Unknown resource template or argument: ${resourceUri} (${argumentName})`);
2847
+ }
2848
+ function readResource(uri, db, session) {
2849
+ logger.info("[Tool] resource.read", { uri });
2850
+ if (uri === "repository://index") {
2851
+ const repos = db.system.listRepoNavigation();
2852
+ const payload = JSON.stringify(repos, null, 2);
2853
+ return {
2854
+ contents: [
2855
+ {
2856
+ uri,
2857
+ mimeType: "application/json",
2858
+ text: payload,
2859
+ size: Buffer.byteLength(payload, "utf8"),
2860
+ annotations: {
2861
+ audience: ["assistant"],
2862
+ priority: 1,
2863
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
2864
+ }
2865
+ }
2866
+ ]
2867
+ };
2868
+ }
2869
+ if (uri === "session://roots") {
2870
+ const payload = JSON.stringify({ roots: session?.roots ?? [] }, null, 2);
2871
+ return {
2872
+ contents: [
2873
+ {
2874
+ uri,
2875
+ mimeType: "application/json",
2876
+ text: payload,
2877
+ size: Buffer.byteLength(payload, "utf8"),
2878
+ annotations: {
2879
+ audience: ["assistant"],
2880
+ priority: 0.95,
2881
+ lastModified: (/* @__PURE__ */ new Date()).toISOString()
2882
+ }
2883
+ }
2884
+ ]
2885
+ };
2886
+ }
2887
+ const memoryIdMatch = uri.match(/^memory:\/\/([0-9a-f-]{36})$/i);
2888
+ if (memoryIdMatch) {
2889
+ const id = memoryIdMatch[1];
2890
+ const entry = db.memories.getByIdWithStats(id);
2891
+ if (!entry) throw resourceNotFound(`Memory with ID ${id} not found.`, uri);
2892
+ const payload = JSON.stringify(entry, null, 2);
2893
+ return {
2894
+ contents: [
2895
+ {
2896
+ uri,
2897
+ mimeType: "application/json",
2898
+ text: payload,
2899
+ size: Buffer.byteLength(payload, "utf8"),
2900
+ annotations: {
2901
+ audience: ["assistant"],
2902
+ priority: 0.75,
2903
+ lastModified: entry.updated_at || entry.created_at
2904
+ }
2905
+ }
2906
+ ]
2907
+ };
2908
+ }
2909
+ const taskIdMatch = uri.match(/^task:\/\/([0-9a-f-]{36})$/i);
2910
+ if (taskIdMatch) {
2911
+ const id = taskIdMatch[1];
2912
+ const task = db.tasks.getTaskById(id);
2913
+ if (!task) throw resourceNotFound(`Task with ID ${id} not found.`, uri);
2914
+ const payload = JSON.stringify(task, null, 2);
2915
+ return {
2916
+ contents: [
2917
+ {
2918
+ uri,
2919
+ mimeType: "application/json",
2920
+ text: payload,
2921
+ size: Buffer.byteLength(payload, "utf8"),
2922
+ annotations: {
2923
+ audience: ["assistant"],
2924
+ priority: 0.8,
2925
+ lastModified: task.updated_at || task.created_at
2926
+ }
2927
+ }
2928
+ ]
2929
+ };
2930
+ }
2931
+ const repoBase = parseRepoUri(uri);
2932
+ if (repoBase) {
2933
+ const { name, path: repoPath, query } = repoBase;
2934
+ if (repoPath === "summary") {
2935
+ const summary = db.summaries.getSummary(name);
2936
+ const text = summary?.summary || `No summary available for repository: ${name}`;
2937
+ return {
2938
+ contents: [
2939
+ {
2940
+ uri,
2941
+ mimeType: "text/plain",
2942
+ text,
2943
+ size: Buffer.byteLength(text, "utf8"),
2944
+ annotations: {
2945
+ audience: ["assistant"],
2946
+ priority: 0.95,
2947
+ lastModified: summary?.updated_at || (/* @__PURE__ */ new Date()).toISOString()
2948
+ }
2949
+ }
2950
+ ]
2951
+ };
3168
2952
  }
3169
- },
3170
- {
3171
- name: "memory-acknowledge",
3172
- title: "Memory Acknowledge",
3173
- description: "Acknowledge the use of a memory or report its irrelevance/contradiction. Mandatory after using memory to generate code.",
3174
- annotations: {
3175
- readOnlyHint: false,
3176
- idempotentHint: false,
3177
- openWorldHint: false
3178
- },
3179
- inputSchema: {
3180
- type: "object",
3181
- properties: {
3182
- memory_id: { type: "string", format: "uuid" },
3183
- status: { type: "string", enum: ["used", "irrelevant", "contradictory"] },
3184
- application_context: { type: "string", minLength: 10 },
3185
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3186
- },
3187
- required: ["memory_id", "status"]
3188
- },
3189
- outputSchema: {
3190
- type: "object",
3191
- properties: {
3192
- success: { type: "boolean" },
3193
- id: { type: "string" },
3194
- status: { type: "string" }
3195
- },
3196
- required: ["success", "id", "status"]
2953
+ if (repoPath === "memories") {
2954
+ const search = query.get("search") || "";
2955
+ const type = query.get("type");
2956
+ const tag = query.get("tag");
2957
+ const result = db.memories.listMemoriesForDashboard({
2958
+ repo: name,
2959
+ type: type || void 0,
2960
+ tag: tag || void 0,
2961
+ search: search || void 0,
2962
+ limit: 50
2963
+ });
2964
+ const entries = result.items;
2965
+ const payload = JSON.stringify(entries, null, 2);
2966
+ return {
2967
+ contents: [
2968
+ {
2969
+ uri,
2970
+ mimeType: "application/json",
2971
+ text: payload,
2972
+ size: Buffer.byteLength(payload, "utf8"),
2973
+ annotations: {
2974
+ audience: ["assistant"],
2975
+ priority: 0.85,
2976
+ lastModified: deriveLastModifiedFromCollection(
2977
+ entries.map((e) => e.updated_at || e.created_at)
2978
+ )
2979
+ }
2980
+ }
2981
+ ]
2982
+ };
3197
2983
  }
3198
- },
3199
- {
3200
- name: "memory-update",
3201
- title: "Memory Update",
3202
- description: "Update an existing memory entry. Keep 'title' concise and move agent/role/date or claim context into 'metadata' instead of the title.",
3203
- annotations: {
3204
- readOnlyHint: false,
3205
- idempotentHint: false,
3206
- destructiveHint: false,
3207
- openWorldHint: false
3208
- },
3209
- inputSchema: {
3210
- type: "object",
3211
- properties: {
3212
- id: { type: "string", format: "uuid" },
3213
- type: {
3214
- type: "string",
3215
- enum: [
3216
- "code_fact",
3217
- "decision",
3218
- "mistake",
3219
- "pattern",
3220
- "file_claim",
3221
- "task_archive"
3222
- ]
3223
- },
3224
- title: { type: "string", minLength: 3, maxLength: 100 },
3225
- content: { type: "string", minLength: 10 },
3226
- importance: { type: "number", minimum: 1, maximum: 5 },
3227
- agent: { type: "string" },
3228
- role: { type: "string" },
3229
- status: { type: "string", enum: ["active", "archived"] },
3230
- supersedes: { type: "string", format: "uuid" },
3231
- tags: { type: "array", items: { type: "string" } },
3232
- metadata: { type: "object" },
3233
- is_global: { type: "boolean" },
3234
- completed_at: { type: "string" },
3235
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the updated memory." }
3236
- },
3237
- required: ["id"]
3238
- },
3239
- outputSchema: {
3240
- type: "object",
3241
- properties: {
3242
- success: { type: "boolean" },
3243
- id: { type: "string" },
3244
- repo: { type: "string" },
3245
- updatedFields: {
3246
- type: "array",
3247
- items: { type: "string" }
2984
+ if (repoPath === "tasks") {
2985
+ const status = query.get("status");
2986
+ const priority = query.get("priority");
2987
+ let tasks;
2988
+ if (status && status !== "all") {
2989
+ const statuses = status.split(",").map((s) => s.trim());
2990
+ tasks = db.tasks.getTasksByMultipleStatuses(name, statuses);
2991
+ } else {
2992
+ tasks = db.tasks.getTasksByMultipleStatuses(name, ["backlog", "pending", "in_progress", "blocked"]);
2993
+ }
2994
+ if (priority) {
2995
+ const p = Number(priority);
2996
+ if (!isNaN(p)) {
2997
+ tasks = tasks.filter((t) => t.priority === p);
2998
+ }
2999
+ }
3000
+ const payload = JSON.stringify(tasks, null, 2);
3001
+ return {
3002
+ contents: [
3003
+ {
3004
+ uri,
3005
+ mimeType: "application/json",
3006
+ text: payload,
3007
+ size: Buffer.byteLength(payload, "utf8"),
3008
+ annotations: {
3009
+ audience: ["assistant"],
3010
+ priority: 0.9,
3011
+ lastModified: deriveLastModifiedFromCollection(tasks.map((t) => t.updated_at))
3012
+ }
3013
+ }
3014
+ ]
3015
+ };
3016
+ }
3017
+ if (repoPath === "actions") {
3018
+ const actions = db.actions.getRecentActions(name, 100);
3019
+ const payload = JSON.stringify(actions, null, 2);
3020
+ return {
3021
+ contents: [
3022
+ {
3023
+ uri,
3024
+ mimeType: "application/json",
3025
+ text: payload,
3026
+ size: Buffer.byteLength(payload, "utf8"),
3027
+ annotations: {
3028
+ audience: ["assistant"],
3029
+ priority: 0.6,
3030
+ lastModified: deriveLastModifiedFromCollection(actions.map((a) => a.created_at))
3031
+ }
3032
+ }
3033
+ ]
3034
+ };
3035
+ }
3036
+ }
3037
+ const actionIdMatch = uri.match(/^action:\/\/(\d+)$/);
3038
+ if (actionIdMatch) {
3039
+ const id = Number(actionIdMatch[1]);
3040
+ const action = db.actions.getActionById(id);
3041
+ if (!action) throw resourceNotFound(`Action with ID ${id} not found.`, uri);
3042
+ const payload = JSON.stringify(action, null, 2);
3043
+ return {
3044
+ contents: [
3045
+ {
3046
+ uri,
3047
+ mimeType: "application/json",
3048
+ text: payload,
3049
+ size: Buffer.byteLength(payload, "utf8"),
3050
+ annotations: {
3051
+ audience: ["assistant"],
3052
+ priority: 0.55,
3053
+ lastModified: action.created_at
3054
+ }
3055
+ }
3056
+ ]
3057
+ };
3058
+ }
3059
+ throw resourceNotFound(`Unknown resource URI: ${uri}`, uri);
3060
+ }
3061
+ function parseRepoUri(uri) {
3062
+ const prefix = "repository://";
3063
+ if (!uri.startsWith(prefix)) return null;
3064
+ const rest = uri.slice(prefix.length);
3065
+ const queryStart = rest.indexOf("?");
3066
+ const withoutQuery = queryStart === -1 ? rest : rest.slice(0, queryStart);
3067
+ const queryString = queryStart === -1 ? "" : rest.slice(queryStart + 1);
3068
+ const slashIdx = withoutQuery.indexOf("/");
3069
+ if (slashIdx === -1) return null;
3070
+ const name = withoutQuery.slice(0, slashIdx);
3071
+ const path6 = withoutQuery.slice(slashIdx + 1);
3072
+ if (!name || !path6) return null;
3073
+ return { name, path: path6, query: new URLSearchParams(queryString) };
3074
+ }
3075
+ function paginateEntries(key, entries, params) {
3076
+ const limit = normalizeLimit(params?.limit);
3077
+ const offset = decodeCursor(params?.cursor);
3078
+ const sliced = entries.slice(offset, offset + limit);
3079
+ const nextOffset = offset + sliced.length;
3080
+ return {
3081
+ [key]: sliced,
3082
+ nextCursor: nextOffset < entries.length ? encodeCursor(nextOffset) : void 0
3083
+ };
3084
+ }
3085
+ function normalizeLimit(limit) {
3086
+ if (typeof limit !== "number" || !Number.isFinite(limit)) {
3087
+ return DEFAULT_PAGE_SIZE;
3088
+ }
3089
+ return Math.min(MAX_PAGE_SIZE, Math.max(1, Math.trunc(limit)));
3090
+ }
3091
+ function deriveLastModifiedFromCollection(values) {
3092
+ const normalized = values.filter((value) => typeof value === "string" && value.length > 0);
3093
+ return normalized.sort().at(-1) ?? (/* @__PURE__ */ new Date()).toISOString();
3094
+ }
3095
+ function resourceNotFound(message, uri) {
3096
+ const error = new Error(message);
3097
+ error.code = -32002;
3098
+ error.data = { uri };
3099
+ return error;
3100
+ }
3101
+ function invalidCompletionParams(message) {
3102
+ const error = new Error(message);
3103
+ error.code = -32602;
3104
+ return error;
3105
+ }
3106
+
3107
+ // src/mcp/prompts/loader.ts
3108
+ import fs4 from "fs";
3109
+ import path5 from "path";
3110
+ import { fileURLToPath as fileURLToPath3 } from "url";
3111
+ import matter from "gray-matter";
3112
+ var __filename = fileURLToPath3(import.meta.url);
3113
+ var __dirname2 = path5.dirname(__filename);
3114
+ function findPromptDir() {
3115
+ const candidates = [
3116
+ // Production if chunked into dist/
3117
+ "./prompts",
3118
+ // Production if inlined into dist/mcp/
3119
+ "../prompts",
3120
+ // Dev: /src/mcp/prompts/definitions (next to loader.ts)
3121
+ "./definitions"
3122
+ ].map((relPath) => path5.resolve(__dirname2, relPath));
3123
+ for (const dir of candidates) {
3124
+ if (fs4.existsSync(dir)) {
3125
+ const files = fs4.readdirSync(dir);
3126
+ if (files.some((f) => f.endsWith(".md"))) {
3127
+ return dir;
3128
+ }
3129
+ }
3130
+ }
3131
+ return path5.resolve(__dirname2, "./definitions");
3132
+ }
3133
+ var PROMPT_DIR = findPromptDir();
3134
+ function listPromptFiles() {
3135
+ if (!fs4.existsSync(PROMPT_DIR)) return [];
3136
+ return fs4.readdirSync(PROMPT_DIR).filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, "")).sort();
3137
+ }
3138
+ function loadPromptFromMarkdown(name) {
3139
+ const filePath = path5.join(PROMPT_DIR, `${name}.md`);
3140
+ if (!fs4.existsSync(filePath)) {
3141
+ throw new Error(`Prompt file not found: ${filePath}`);
3142
+ }
3143
+ const fileContent = fs4.readFileSync(filePath, "utf-8");
3144
+ const { data, content } = matter(fileContent);
3145
+ return {
3146
+ name: data.name || name,
3147
+ description: data.description || "",
3148
+ arguments: data.arguments || [],
3149
+ agent: data.agent,
3150
+ content: content.trim()
3151
+ };
3152
+ }
3153
+
3154
+ // src/mcp/prompts/registry.ts
3155
+ function createPromptDefinition(loaded) {
3156
+ return {
3157
+ name: loaded.name,
3158
+ description: loaded.description,
3159
+ arguments: loaded.arguments,
3160
+ agent: loaded.agent,
3161
+ messages: [
3162
+ {
3163
+ role: "user",
3164
+ content: {
3165
+ type: "text",
3166
+ text: loaded.content
3248
3167
  }
3249
- },
3250
- required: ["success", "id", "repo", "updatedFields"]
3168
+ }
3169
+ ]
3170
+ };
3171
+ }
3172
+ var PROMPTS = {};
3173
+ var promptFiles = listPromptFiles();
3174
+ for (const name of promptFiles) {
3175
+ try {
3176
+ PROMPTS[name] = createPromptDefinition(loadPromptFromMarkdown(name));
3177
+ } catch (e) {
3178
+ logger.warn(`Failed to load prompt ${name}: ${e}`);
3179
+ }
3180
+ }
3181
+ async function listPrompts(db, session, params) {
3182
+ const allPrompts = Object.values(PROMPTS).map((p) => ({
3183
+ name: p.name,
3184
+ description: p.description,
3185
+ arguments: p.arguments,
3186
+ metadata: p.agent ? { agent: p.agent } : void 0
3187
+ }));
3188
+ const rawLimit = typeof params?.limit === "number" && Number.isInteger(params?.limit) ? params.limit : 25;
3189
+ const limit = Math.max(1, Math.min(100, Math.trunc(rawLimit)));
3190
+ const offset = decodeCursor(params?.cursor);
3191
+ const sliced = allPrompts.slice(offset, offset + limit);
3192
+ const nextOffset = offset + sliced.length;
3193
+ return {
3194
+ prompts: sliced,
3195
+ nextCursor: nextOffset < allPrompts.length ? encodeCursor(nextOffset) : void 0
3196
+ };
3197
+ }
3198
+ async function getPrompt(name, args = {}, db, session) {
3199
+ const prompt = PROMPTS[name];
3200
+ if (!prompt) {
3201
+ throw new Error(`Prompt not found: ${name}`);
3202
+ }
3203
+ const inferredRepo = inferRepoFromSession(session);
3204
+ const messages = prompt.messages.map((m) => {
3205
+ let text = m.content.text;
3206
+ for (const [key, value] of Object.entries(args)) {
3207
+ text = text.replace(new RegExp(`\\{{${key}\\}}`, "g"), value);
3251
3208
  }
3209
+ text = text.replace(/{{current_repo}}/g, inferredRepo || "unknown-repo");
3210
+ return {
3211
+ ...m,
3212
+ content: {
3213
+ ...m.content,
3214
+ text
3215
+ }
3216
+ };
3217
+ });
3218
+ return {
3219
+ description: prompt.description,
3220
+ messages,
3221
+ metadata: prompt.agent ? { agent: prompt.agent } : void 0
3222
+ };
3223
+ }
3224
+ async function completePromptArgument(name, argName, value, contextArguments, dataSources) {
3225
+ void name;
3226
+ void contextArguments;
3227
+ if (argName === "task_id") {
3228
+ const values = dataSources.tasks.map((t) => t.id);
3229
+ return rankCompletionValues(values, value);
3230
+ }
3231
+ return [];
3232
+ }
3233
+
3234
+ // src/mcp/tools/schemas.ts
3235
+ import { z } from "zod";
3236
+ var MemoryScopeSchema = z.object({
3237
+ repo: z.string().min(1).transform(normalizeRepo),
3238
+ branch: z.string().optional(),
3239
+ folder: z.string().optional(),
3240
+ language: z.string().optional()
3241
+ });
3242
+ var MemoryTypeSchema = z.enum([
3243
+ "code_fact",
3244
+ "decision",
3245
+ "mistake",
3246
+ "pattern",
3247
+ "file_claim",
3248
+ "task_archive"
3249
+ ]);
3250
+ var MemoryStoreSchema = z.object({
3251
+ code: z.string().max(20).optional(),
3252
+ type: MemoryTypeSchema,
3253
+ title: z.string().min(3).max(255),
3254
+ content: z.string().min(10),
3255
+ importance: z.number().min(1).max(5),
3256
+ agent: z.string().min(1),
3257
+ role: z.string().optional().default("unknown"),
3258
+ model: z.string().min(1),
3259
+ scope: MemoryScopeSchema,
3260
+ ttlDays: z.number().min(1).optional(),
3261
+ supersedes: z.string().uuid().optional(),
3262
+ tags: z.array(z.string()).optional(),
3263
+ metadata: z.record(z.string(), z.any()).optional(),
3264
+ is_global: z.boolean().default(false),
3265
+ structured: z.boolean().default(false)
3266
+ });
3267
+ var MemoryUpdateSchema = z.object({
3268
+ id: z.string().uuid(),
3269
+ type: MemoryTypeSchema.optional(),
3270
+ title: z.string().min(3).max(255).optional(),
3271
+ content: z.string().min(10).optional(),
3272
+ importance: z.number().min(1).max(5).optional(),
3273
+ agent: z.string().optional(),
3274
+ role: z.string().optional(),
3275
+ status: z.enum(["active", "archived"]).optional(),
3276
+ supersedes: z.string().uuid().optional(),
3277
+ tags: z.array(z.string()).optional(),
3278
+ metadata: z.record(z.string(), z.any()).optional(),
3279
+ is_global: z.boolean().optional(),
3280
+ completed_at: z.string().optional(),
3281
+ structured: z.boolean().default(false)
3282
+ }).refine(
3283
+ (data) => data.type !== void 0 || data.content !== void 0 || data.title !== void 0 || data.importance !== void 0 || data.status !== void 0 || data.supersedes !== void 0 || data.tags !== void 0 || data.metadata !== void 0 || data.is_global !== void 0 || data.agent !== void 0 || data.role !== void 0 || data.completed_at !== void 0,
3284
+ { message: "At least one field must be provided for update" }
3285
+ );
3286
+ var MemorySearchSchema = z.object({
3287
+ query: z.string().min(3),
3288
+ prompt: z.string().optional(),
3289
+ repo: z.string().min(1).transform(normalizeRepo),
3290
+ types: z.array(MemoryTypeSchema).optional(),
3291
+ minImportance: z.number().min(1).max(5).optional(),
3292
+ limit: z.number().min(1).max(100).default(5),
3293
+ offset: z.number().min(0).default(0),
3294
+ includeRecap: z.boolean().default(false),
3295
+ current_file_path: z.string().optional(),
3296
+ include_archived: z.boolean().default(false),
3297
+ current_tags: z.array(z.string()).optional(),
3298
+ scope: MemoryScopeSchema.partial().optional(),
3299
+ structured: z.boolean().default(false)
3300
+ });
3301
+ var MemoryAcknowledgeSchema = z.object({
3302
+ memory_id: z.string().uuid(),
3303
+ status: z.enum(["used", "irrelevant", "contradictory"]),
3304
+ application_context: z.string().min(10).optional(),
3305
+ structured: z.boolean().default(false)
3306
+ });
3307
+ var MemoryRecapSchema = z.object({
3308
+ repo: z.string().min(1).transform(normalizeRepo),
3309
+ limit: z.number().min(1).max(50).default(20),
3310
+ offset: z.number().min(0).default(0),
3311
+ structured: z.boolean().default(false)
3312
+ });
3313
+ var MemoryDeleteSchema = z.object({
3314
+ repo: z.string().min(1).transform(normalizeRepo).optional(),
3315
+ id: z.string().uuid().optional(),
3316
+ ids: z.array(z.string().uuid()).min(1).optional(),
3317
+ structured: z.boolean().default(false)
3318
+ }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
3319
+ message: "Either 'id' or 'ids' must be provided for deletion"
3320
+ });
3321
+ var MemorySummarizeSchema = z.object({
3322
+ repo: z.string().min(1).transform(normalizeRepo),
3323
+ signals: z.array(z.string().max(200)).min(1),
3324
+ structured: z.boolean().default(false)
3325
+ });
3326
+ var MemorySynthesizeSchema = z.object({
3327
+ repo: z.string().min(1).transform(normalizeRepo).optional(),
3328
+ objective: z.string().min(5),
3329
+ current_file_path: z.string().optional(),
3330
+ include_summary: z.boolean().default(true),
3331
+ include_tasks: z.boolean().default(true),
3332
+ use_tools: z.boolean().default(true),
3333
+ max_iterations: z.number().int().min(1).max(5).default(3),
3334
+ max_tokens: z.number().int().min(128).max(4e3).default(1200),
3335
+ structured: z.boolean().default(false)
3336
+ });
3337
+ var TaskStatusSchema = z.enum(["backlog", "pending", "in_progress", "completed", "canceled", "blocked"]);
3338
+ var TaskPrioritySchema = z.number().min(1).max(5);
3339
+ var SingleTaskCreateSchema = z.object({
3340
+ task_code: z.string().min(1),
3341
+ phase: z.string().min(1),
3342
+ title: z.string().min(3).max(100),
3343
+ description: z.string().min(1),
3344
+ status: TaskStatusSchema.default("backlog"),
3345
+ priority: TaskPrioritySchema.default(3),
3346
+ agent: z.string().optional(),
3347
+ role: z.string().optional(),
3348
+ doc_path: z.string().optional(),
3349
+ tags: z.array(z.string()).optional(),
3350
+ metadata: z.record(z.string(), z.any()).optional(),
3351
+ parent_id: z.string().uuid().optional(),
3352
+ depends_on: z.string().uuid().optional(),
3353
+ est_tokens: z.number().int().min(0).optional()
3354
+ });
3355
+ var TaskCreateSchema = z.object({
3356
+ repo: z.string().min(1).transform(normalizeRepo),
3357
+ // Allow single task fields at top level (backward compatibility & single use)
3358
+ task_code: z.string().min(1).optional(),
3359
+ phase: z.string().min(1).optional(),
3360
+ title: z.string().min(3).max(100).optional(),
3361
+ description: z.string().min(1).optional(),
3362
+ status: TaskStatusSchema.optional(),
3363
+ priority: TaskPrioritySchema.optional(),
3364
+ agent: z.string().optional(),
3365
+ role: z.string().optional(),
3366
+ doc_path: z.string().optional(),
3367
+ tags: z.array(z.string()).optional(),
3368
+ metadata: z.record(z.string(), z.any()).optional(),
3369
+ parent_id: z.string().uuid().optional(),
3370
+ depends_on: z.string().uuid().optional(),
3371
+ est_tokens: z.number().int().min(0).optional(),
3372
+ // Allow bulk tasks
3373
+ tasks: z.array(SingleTaskCreateSchema).min(1).optional(),
3374
+ structured: z.boolean().default(false)
3375
+ }).refine(
3376
+ (data) => {
3377
+ if (data.tasks) return true;
3378
+ return !!(data.task_code && data.phase && data.title && data.description);
3252
3379
  },
3380
+ { message: "Either 'tasks' array or single task fields (task_code, phase, title, description) must be provided" }
3381
+ );
3382
+ var TaskCreateInteractiveSchema = SingleTaskCreateSchema.partial().extend({
3383
+ repo: z.string().min(1).transform(normalizeRepo).optional(),
3384
+ structured: z.boolean().default(false)
3385
+ });
3386
+ var TaskUpdateSchema = z.object({
3387
+ repo: z.string().min(1).transform(normalizeRepo),
3388
+ id: z.string().uuid().optional(),
3389
+ ids: z.array(z.string().uuid()).min(1).optional(),
3390
+ task_code: z.string().optional(),
3391
+ phase: z.string().optional(),
3392
+ title: z.string().min(3).max(100).optional(),
3393
+ description: z.string().optional(),
3394
+ status: TaskStatusSchema.optional(),
3395
+ priority: TaskPrioritySchema.optional(),
3396
+ agent: z.string().min(1, "agent name is required").optional(),
3397
+ role: z.string().min(1, "agent role is required").optional(),
3398
+ model: z.string().optional(),
3399
+ comment: z.string().min(1).optional(),
3400
+ doc_path: z.string().optional(),
3401
+ tags: z.array(z.string()).optional(),
3402
+ metadata: z.record(z.string(), z.any()).optional(),
3403
+ parent_id: z.string().uuid().optional(),
3404
+ depends_on: z.string().uuid().optional(),
3405
+ est_tokens: z.number().int().min(0).optional(),
3406
+ force: z.boolean().optional(),
3407
+ structured: z.boolean().default(false)
3408
+ }).refine((data) => data.id !== void 0 || data.ids !== void 0 || data.task_code !== void 0, {
3409
+ message: "Either 'id', 'ids', or 'task_code' must be provided for update"
3410
+ }).refine((data) => Object.keys(data).length > 2, {
3411
+ message: "At least one field besides repo and id/ids must be provided for update"
3412
+ });
3413
+ var TaskListSchema = z.object({
3414
+ repo: z.string().min(1).transform(normalizeRepo),
3415
+ status: z.string().optional(),
3416
+ phase: z.string().optional(),
3417
+ query: z.string().optional(),
3418
+ limit: z.number().min(1).max(100).default(15),
3419
+ offset: z.number().min(0).default(0),
3420
+ structured: z.boolean().default(false)
3421
+ });
3422
+ var TaskSearchSchema = z.object({
3423
+ repo: z.string().min(1).transform(normalizeRepo),
3424
+ query: z.string().min(1),
3425
+ status: z.string().optional(),
3426
+ limit: z.number().min(1).max(100).default(10),
3427
+ offset: z.number().min(0).default(0),
3428
+ structured: z.boolean().default(false)
3429
+ });
3430
+ var TaskDeleteSchema = z.object({
3431
+ repo: z.string().min(1).transform(normalizeRepo),
3432
+ id: z.string().uuid().optional(),
3433
+ ids: z.array(z.string().uuid()).min(1).optional(),
3434
+ structured: z.boolean().default(false)
3435
+ }).refine((data) => data.id !== void 0 || data.ids !== void 0, {
3436
+ message: "Either 'id' or 'ids' must be provided for deletion"
3437
+ });
3438
+ var MemoryDetailSchema = z.object({
3439
+ id: z.string().uuid().optional(),
3440
+ code: z.string().max(20).optional(),
3441
+ structured: z.boolean().default(false)
3442
+ }).refine((data) => data.id !== void 0 || data.code !== void 0, {
3443
+ message: "Either id or code must be provided"
3444
+ });
3445
+ var TaskGetSchema = z.object({
3446
+ repo: z.string().min(1).transform(normalizeRepo),
3447
+ id: z.string().uuid().optional(),
3448
+ task_code: z.string().optional(),
3449
+ structured: z.boolean().default(false)
3450
+ }).refine((data) => data.id !== void 0 || data.task_code !== void 0, {
3451
+ message: "Either id or task_code must be provided"
3452
+ });
3453
+ var HandoffStatusSchema = z.enum(["pending", "accepted", "rejected", "expired"]);
3454
+ var HandoffCreateSchema = z.object({
3455
+ repo: z.string().min(1).transform(normalizeRepo),
3456
+ from_agent: z.string().min(1),
3457
+ to_agent: z.string().min(1).optional(),
3458
+ task_id: z.string().uuid().optional(),
3459
+ task_code: z.string().optional(),
3460
+ summary: z.string().min(1),
3461
+ context: z.record(z.string(), z.any()).optional(),
3462
+ expires_at: z.string().optional(),
3463
+ structured: z.boolean().default(false)
3464
+ }).refine((data) => !(data.task_id && data.task_code), {
3465
+ message: "Provide either task_id or task_code, not both"
3466
+ });
3467
+ var HandoffListSchema = z.object({
3468
+ repo: z.string().min(1).transform(normalizeRepo),
3469
+ status: HandoffStatusSchema.optional(),
3470
+ from_agent: z.string().min(1).optional(),
3471
+ to_agent: z.string().min(1).optional(),
3472
+ limit: z.number().min(1).max(100).default(20),
3473
+ offset: z.number().min(0).default(0),
3474
+ structured: z.boolean().default(false)
3475
+ });
3476
+ var TaskClaimSchema = z.object({
3477
+ repo: z.string().min(1).transform(normalizeRepo),
3478
+ task_id: z.string().uuid().optional(),
3479
+ task_code: z.string().optional(),
3480
+ agent: z.string().min(1),
3481
+ role: z.string().optional(),
3482
+ metadata: z.record(z.string(), z.any()).optional(),
3483
+ structured: z.boolean().default(false)
3484
+ }).refine((data) => data.task_id !== void 0 || data.task_code !== void 0, {
3485
+ message: "Either task_id or task_code must be provided"
3486
+ }).refine((data) => !(data.task_id && data.task_code), {
3487
+ message: "Provide either task_id or task_code, not both"
3488
+ });
3489
+ var StandardStoreSchema = z.object({
3490
+ name: z.string().min(3).max(255),
3491
+ content: z.string().min(10),
3492
+ context: z.string().optional(),
3493
+ version: z.string().optional(),
3494
+ language: z.string().optional(),
3495
+ stack: z.array(z.string()).optional(),
3496
+ repo: z.string().optional(),
3497
+ is_global: z.boolean().optional(),
3498
+ tags: z.array(z.string()).optional(),
3499
+ metadata: z.record(z.string(), z.any()).optional(),
3500
+ agent: z.string().optional(),
3501
+ model: z.string().optional(),
3502
+ structured: z.boolean().default(false)
3503
+ });
3504
+ var StandardSearchSchema = z.object({
3505
+ query: z.string().optional(),
3506
+ stack: z.array(z.string()).optional(),
3507
+ language: z.string().optional(),
3508
+ version: z.string().optional(),
3509
+ repo: z.string().optional(),
3510
+ is_global: z.boolean().optional(),
3511
+ limit: z.number().min(1).max(100).default(20),
3512
+ offset: z.number().min(0).default(0),
3513
+ structured: z.boolean().default(false)
3514
+ });
3515
+ var TOOL_DEFINITIONS = [
3253
3516
  {
3254
- name: "memory-search",
3255
- title: "Memory Search",
3256
- description: "NAVIGATION LAYER: Returns a pointer table of matching memory IDs only. Returns columns [id, title, type, importance] \u2014 NO content. Retrieve full memory via memory-detail. Use 'current_tags' to find tech-stack specific knowledge from other projects.",
3517
+ name: "memory-synthesize",
3518
+ title: "Memory Synthesize",
3519
+ description: "Use client sampling to synthesize a grounded answer from local memory and tasks. Best for project briefings, tradeoff summaries, and context-aware answers.",
3257
3520
  annotations: {
3258
3521
  readOnlyHint: true,
3259
3522
  idempotentHint: true,
3260
3523
  openWorldHint: false
3261
3524
  },
3262
- inputSchema: {
3263
- type: "object",
3264
- properties: {
3265
- query: { type: "string", minLength: 3 },
3266
- prompt: { type: "string" },
3267
- repo: { type: "string" },
3268
- current_tags: {
3269
- type: "array",
3270
- items: { type: "string" },
3271
- description: "Active tech stack tags (e.g., ['filament', 'react'])"
3272
- },
3273
- types: {
3274
- type: "array",
3275
- items: {
3276
- type: "string",
3277
- enum: [
3278
- "code_fact",
3279
- "decision",
3280
- "mistake",
3281
- "pattern",
3282
- "file_claim",
3283
- "task_archive"
3284
- ]
3285
- }
3286
- },
3287
- minImportance: { type: "number", minimum: 1, maximum: 5 },
3288
- limit: { type: "number", minimum: 1, maximum: 100, default: 5 },
3289
- offset: { type: "number", minimum: 0, default: 0 },
3290
- includeRecap: { type: "boolean", default: false },
3291
- current_file_path: { type: "string" },
3292
- include_archived: { type: "boolean", default: false },
3293
- scope: {
3294
- type: "object",
3295
- properties: {
3296
- repo: { type: "string" },
3297
- branch: { type: "string" },
3298
- folder: { type: "string" },
3299
- language: { type: "string" }
3300
- }
3301
- },
3302
- structured: {
3303
- type: "boolean",
3304
- default: false,
3305
- description: "If true, returns structured JSON without the text content summary."
3306
- }
3307
- },
3308
- required: ["query", "repo"]
3309
- },
3310
- outputSchema: {
3311
- type: "object",
3312
- properties: {
3313
- schema: { type: "string", enum: ["memory-search"] },
3314
- query: { type: "string" },
3315
- count: { type: "number", description: "Number of rows returned" },
3316
- total: { type: "number", description: "Total matching memories" },
3317
- offset: { type: "number" },
3318
- limit: { type: "number" },
3319
- results: {
3320
- type: "object",
3321
- properties: {
3322
- columns: {
3323
- type: "array",
3324
- items: { type: "string" },
3325
- description: "Column names: [id, title, type, importance]"
3326
- },
3327
- rows: {
3328
- type: "array",
3329
- items: { type: "array" },
3330
- description: "Each row: [id, title, type, importance]. Fetch full content via memory-detail"
3331
- }
3332
- },
3333
- required: ["columns", "rows"]
3334
- }
3335
- },
3336
- required: ["schema", "query", "count", "total", "offset", "limit", "results"]
3337
- }
3338
- },
3339
- {
3340
- name: "memory-summarize",
3341
- title: "Memory Summarize",
3342
- description: "Update the summary for a repository",
3343
- annotations: {
3344
- readOnlyHint: false,
3345
- idempotentHint: false,
3346
- openWorldHint: false
3525
+ execution: {
3526
+ taskSupport: "optional"
3347
3527
  },
3348
3528
  inputSchema: {
3349
3529
  type: "object",
3350
3530
  properties: {
3351
- repo: { type: "string", description: "Repository name" },
3352
- signals: {
3353
- type: "array",
3354
- items: { type: "string", maxLength: 200 },
3355
- minItems: 1,
3356
- description: "High-level signals to include in summary"
3531
+ repo: { type: "string", description: "Repository name. Optional when a single MCP root is active." },
3532
+ objective: { type: "string", minLength: 5, description: "Question or synthesis objective." },
3533
+ current_file_path: {
3534
+ type: "string",
3535
+ description: "Optional absolute file path for workspace-local grounding."
3536
+ },
3537
+ include_summary: { type: "boolean", default: true },
3538
+ include_tasks: { type: "boolean", default: true },
3539
+ use_tools: {
3540
+ type: "boolean",
3541
+ default: true,
3542
+ description: "Allow the sampled model to call local memory/task tools during synthesis when the client supports sampling.tools."
3357
3543
  },
3358
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the summary." }
3544
+ max_iterations: { type: "number", minimum: 1, maximum: 5, default: 3 },
3545
+ max_tokens: { type: "number", minimum: 128, maximum: 4e3, default: 1200 },
3546
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON results." }
3359
3547
  },
3360
- required: ["repo", "signals"]
3548
+ required: ["objective"]
3361
3549
  },
3362
3550
  outputSchema: {
3363
3551
  type: "object",
3364
3552
  properties: {
3365
- success: { type: "boolean" },
3366
3553
  repo: { type: "string" },
3367
- summary: { type: "string" },
3368
- signalCount: { type: "number" }
3554
+ objective: { type: "string" },
3555
+ answer: { type: "string" },
3556
+ model: { type: "string" },
3557
+ stopReason: { type: "string" },
3558
+ iterations: { type: "number" },
3559
+ toolCalls: { type: "number" }
3369
3560
  },
3370
- required: ["success", "repo", "summary", "signalCount"]
3561
+ required: ["repo", "objective", "answer", "iterations", "toolCalls"]
3371
3562
  }
3372
3563
  },
3373
3564
  {
3374
- name: "memory-delete",
3375
- title: "Memory Delete",
3376
- description: "Soft-delete one or more memory entries. Supports single 'id' or bulk 'ids'.",
3565
+ name: "task-create-interactive",
3566
+ title: "Interactive Task Create",
3567
+ description: "Create a task with MCP elicitation fallback for any missing required fields. Best when an agent knows a task is needed but still needs user confirmation for repo, title, or phase.",
3377
3568
  annotations: {
3378
3569
  readOnlyHint: false,
3379
3570
  idempotentHint: false,
3380
- destructiveHint: true,
3571
+ destructiveHint: false,
3381
3572
  openWorldHint: false
3382
3573
  },
3383
3574
  inputSchema: {
3384
3575
  type: "object",
3385
3576
  properties: {
3386
- repo: { type: "string", description: "Repository name (optional for single id)" },
3387
- id: { type: "string", format: "uuid", description: "Memory entry ID to delete" },
3388
- ids: {
3389
- type: "array",
3390
- items: { type: "string", format: "uuid" },
3391
- minItems: 1,
3392
- description: "Array of memory IDs to delete"
3577
+ repo: {
3578
+ type: "string",
3579
+ description: "Repository name. Optional when it can be inferred from MCP roots or elicited from the user."
3393
3580
  },
3581
+ task_code: { type: "string" },
3582
+ phase: { type: "string" },
3583
+ title: { type: "string", minLength: 3, maxLength: 100 },
3584
+ description: { type: "string", minLength: 1 },
3585
+ status: { type: "string", enum: ["backlog", "pending"], default: "backlog" },
3586
+ priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
3587
+ agent: { type: "string" },
3588
+ role: { type: "string" },
3589
+ doc_path: { type: "string" },
3394
3590
  structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3395
3591
  }
3396
3592
  },
3397
3593
  outputSchema: {
3398
3594
  type: "object",
3399
3595
  properties: {
3400
- success: { type: "boolean" },
3401
- id: { type: "string" },
3402
- ids: { type: "array", items: { type: "string" } },
3403
3596
  repo: { type: "string" },
3404
- deletedCount: { type: "number" }
3597
+ task_code: { type: "string" },
3598
+ phase: { type: "string" },
3599
+ title: { type: "string" },
3600
+ status: { type: "string" },
3601
+ priority: { type: "number" }
3405
3602
  },
3406
- required: ["success"]
3603
+ required: ["repo", "task_code", "phase", "title", "status", "priority"]
3407
3604
  }
3408
3605
  },
3409
3606
  {
3410
- name: "memory-recap",
3411
- title: "Memory Recap",
3412
- description: "AGGREGATED OVERVIEW LAYER: Returns stats (counts by type) and a pointer table of top memories [id, code, title, type, importance]. NO content. Use for orientation only \u2014 retrieve full memory via memory-detail.",
3413
- annotations: {
3414
- readOnlyHint: true,
3415
- idempotentHint: true,
3416
- openWorldHint: false
3417
- },
3607
+ name: "memory-detail",
3608
+ title: "Memory Detail",
3609
+ description: "Fetch full details of a specific memory by ID or short code. Use after memory-recap or memory-search when a pointer row is relevant and full content is needed.",
3418
3610
  inputSchema: {
3419
3611
  type: "object",
3420
3612
  properties: {
3421
- repo: { type: "string", description: "Repository name (required)" },
3422
- limit: {
3423
- type: "number",
3424
- minimum: 1,
3425
- maximum: 50,
3426
- default: 20,
3427
- description: "Maximum number of top memories to return in the pointer table"
3428
- },
3429
- offset: {
3430
- type: "number",
3431
- minimum: 0,
3432
- default: 0,
3433
- description: "Number of memories to skip for pagination (optional, default 0)"
3434
- },
3613
+ id: { type: "string", format: "uuid", description: "Memory entry ID. Optional if code is provided." },
3614
+ code: { type: "string", description: "Short memory code. Optional if id is provided." },
3615
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON details." }
3616
+ }
3617
+ }
3618
+ },
3619
+ {
3620
+ name: "task-detail",
3621
+ title: "Task Detail",
3622
+ description: "Fetch full details of a specific task by ID or task code. Use this when you have a task ID or code and need to read the full description and comments.",
3623
+ inputSchema: {
3624
+ type: "object",
3625
+ properties: {
3626
+ repo: { type: "string", description: "Repository name" },
3627
+ id: { type: "string", format: "uuid", description: "Task ID (optional if task_code is provided)" },
3628
+ task_code: { type: "string", description: "Task code (e.g. TASK-001) (optional if id is provided)" },
3435
3629
  structured: {
3436
3630
  type: "boolean",
3437
3631
  default: false,
3438
- description: "If true, returns structured JSON without the text content summary."
3632
+ description: "If true, returns structured JSON without the text content details."
3439
3633
  }
3440
3634
  },
3441
3635
  required: ["repo"]
3442
- },
3443
- outputSchema: {
3444
- type: "object",
3445
- properties: {
3446
- schema: { type: "string", enum: ["memory-recap"] },
3447
- repo: { type: "string" },
3448
- count: { type: "number", description: "Number of rows in the top pointer table" },
3449
- total: { type: "number", description: "Total active memories in repo" },
3450
- offset: { type: "number" },
3451
- limit: { type: "number" },
3452
- stats: {
3453
- type: "object",
3454
- properties: {
3455
- byType: {
3456
- type: "object",
3457
- description: "Count of active memories per type (e.g. { decision: 3, code_fact: 7 })"
3458
- }
3459
- },
3460
- required: ["byType"]
3461
- },
3462
- top: {
3463
- type: "object",
3464
- properties: {
3465
- columns: {
3466
- type: "array",
3467
- items: { type: "string" },
3468
- description: "Column names: [id, code, title, type, importance]"
3469
- },
3470
- rows: {
3471
- type: "array",
3472
- items: { type: "array" },
3473
- description: "Each row: [id, code, title, type, importance]. Fetch full content via memory-detail"
3474
- }
3475
- },
3476
- required: ["columns", "rows"]
3477
- }
3478
- },
3479
- required: ["schema", "repo", "count", "total", "offset", "limit", "stats", "top"]
3480
3636
  }
3481
3637
  },
3482
3638
  {
3483
- name: "task-create",
3484
- title: "Task Create",
3485
- description: "Register one or more new tasks in a repository. task_code must be unique within the repository. Supports single task object or an array of tasks for bulk creation.",
3639
+ name: "memory-store",
3640
+ title: "Memory Store",
3641
+ description: "Store a new memory entry. Keep 'title' concise and human-readable; do not embed agent/role/date metadata in the title. Put auxiliary context into 'metadata'. Use 'tags' for tech-stack and 'is_global' for universal rules.",
3486
3642
  annotations: {
3487
3643
  readOnlyHint: false,
3488
3644
  idempotentHint: false,
3645
+ destructiveHint: false,
3489
3646
  openWorldHint: false
3490
3647
  },
3491
3648
  inputSchema: {
3492
3649
  type: "object",
3493
3650
  properties: {
3494
- repo: { type: "string", description: "Repository name" },
3495
- task_code: { type: "string", description: "Unique task code (e.g. TASK-001) (Required for single task)" },
3496
- phase: { type: "string", description: "Project phase (Required for single task)" },
3651
+ type: {
3652
+ type: "string",
3653
+ enum: [
3654
+ "code_fact",
3655
+ "decision",
3656
+ "mistake",
3657
+ "pattern",
3658
+ "file_claim",
3659
+ "task_archive"
3660
+ ],
3661
+ description: "Type of memory being stored"
3662
+ },
3497
3663
  title: {
3498
3664
  type: "string",
3499
3665
  minLength: 3,
3500
3666
  maxLength: 100,
3501
- description: "Task objective (Required for single task)"
3667
+ description: "Short human-readable title for the memory. Do not embed bracketed metadata like agent/role/date prefixes here."
3502
3668
  },
3503
- description: { type: "string", description: "Detailed description (Required for single task)" },
3504
- status: {
3669
+ content: {
3505
3670
  type: "string",
3506
- enum: ["backlog", "pending"],
3507
- default: "backlog",
3508
- description: "New tasks MUST start in 'backlog' if there are already 10 pending tasks. Otherwise can start in 'pending'."
3671
+ minLength: 10,
3672
+ description: "The memory content"
3509
3673
  },
3510
- priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
3511
- agent: { type: "string" },
3512
- role: { type: "string" },
3513
- doc_path: { type: "string" },
3514
- tags: { type: "array", items: { type: "string" } },
3515
- metadata: { type: "object" },
3516
- parent_id: { type: "string", format: "uuid" },
3517
- depends_on: { type: "string", format: "uuid" },
3518
- est_tokens: { type: "number", minimum: 0, description: "Estimated tokens budget for this task" },
3519
- tasks: {
3520
- type: "array",
3521
- items: {
3522
- type: "object",
3523
- properties: {
3524
- task_code: { type: "string" },
3525
- phase: { type: "string" },
3526
- title: { type: "string", minLength: 3, maxLength: 100 },
3527
- description: { type: "string" },
3528
- status: { type: "string", enum: ["backlog", "pending"], default: "backlog" },
3529
- priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
3530
- agent: { type: "string" },
3531
- role: { type: "string" },
3532
- doc_path: { type: "string" },
3533
- tags: { type: "array", items: { type: "string" } },
3534
- metadata: { type: "object" },
3535
- parent_id: { type: "string", format: "uuid" },
3536
- depends_on: { type: "string", format: "uuid" },
3537
- est_tokens: { type: "number", minimum: 0 }
3538
- },
3539
- required: ["task_code", "phase", "title", "description"]
3674
+ importance: {
3675
+ type: "number",
3676
+ minimum: 1,
3677
+ maximum: 5,
3678
+ description: "Importance score (1-5)"
3679
+ },
3680
+ agent: {
3681
+ type: "string",
3682
+ description: "Name of the agent creating this memory"
3683
+ },
3684
+ role: {
3685
+ type: "string",
3686
+ description: "Role of the agent creating this memory"
3687
+ },
3688
+ model: {
3689
+ type: "string",
3690
+ description: "AI model used by the agent"
3691
+ },
3692
+ scope: {
3693
+ type: "object",
3694
+ properties: {
3695
+ repo: { type: "string", description: "Repository name" },
3696
+ branch: { type: "string" },
3697
+ folder: { type: "string" },
3698
+ language: { type: "string" }
3540
3699
  },
3541
- description: "Array of tasks for bulk creation"
3700
+ required: ["repo"]
3542
3701
  },
3543
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3702
+ tags: {
3703
+ type: "array",
3704
+ items: { type: "string" },
3705
+ description: "Technology stack tags (e.g., ['filament', 'laravel'])"
3706
+ },
3707
+ metadata: {
3708
+ type: "object",
3709
+ description: "Structured metadata for non-title context such as source agent, claim fields, or timestamps"
3710
+ },
3711
+ is_global: {
3712
+ type: "boolean",
3713
+ description: "If true, this memory is shared across all repositories"
3714
+ },
3715
+ ttlDays: { type: "number", minimum: 1 },
3716
+ supersedes: { type: "string", format: "uuid" },
3717
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the stored memory." }
3544
3718
  },
3545
- required: ["repo"]
3719
+ required: ["type", "title", "content", "importance", "scope", "agent", "model"]
3546
3720
  },
3547
3721
  outputSchema: {
3548
3722
  type: "object",
3549
3723
  properties: {
3550
3724
  success: { type: "boolean" },
3551
3725
  id: { type: "string" },
3552
- task_code: { type: "string" },
3726
+ code: { type: "string" },
3553
3727
  repo: { type: "string" },
3554
- phase: { type: "string" },
3728
+ type: { type: "string" },
3555
3729
  title: { type: "string" },
3556
- status: { type: "string" },
3557
- priority: { type: "number" },
3558
- createdCount: { type: "number" },
3559
- taskCodes: { type: "array", items: { type: "string" } }
3730
+ error: { type: "string" },
3731
+ message: { type: "string" }
3560
3732
  },
3561
- required: ["success", "repo"]
3733
+ required: ["success"]
3562
3734
  }
3563
3735
  },
3564
3736
  {
3565
- name: "task-update",
3566
- title: "Task Update",
3567
- description: "Update one or more tasks. Supports single update via 'id' or bulk update via 'ids'. Provide only the fields that need to be changed. MANDATORY WORKFLOW: You cannot move a task from 'pending' or 'blocked' directly to 'completed'. You MUST move it to 'in_progress' first. When changing status to 'completed', include 'est_tokens' with the estimated total tokens actually used for the task.",
3737
+ name: "memory-acknowledge",
3738
+ title: "Memory Acknowledge",
3739
+ description: "Acknowledge the use of a memory or report its irrelevance/contradiction. Mandatory after using memory to generate code.",
3568
3740
  annotations: {
3569
3741
  readOnlyHint: false,
3570
3742
  idempotentHint: false,
@@ -3573,98 +3745,81 @@ var TOOL_DEFINITIONS = [
3573
3745
  inputSchema: {
3574
3746
  type: "object",
3575
3747
  properties: {
3576
- repo: { type: "string", description: "Repository name" },
3577
- id: { type: "string", format: "uuid", description: "Task ID (for single update)" },
3578
- ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk update)" },
3579
- task_code: { type: "string" },
3580
- phase: { type: "string" },
3581
- title: { type: "string", minLength: 3, maxLength: 100 },
3582
- description: { type: "string" },
3583
- status: {
3584
- type: "string",
3585
- enum: ["backlog", "pending", "in_progress", "completed", "canceled", "blocked"],
3586
- description: "New status. Transitions from 'backlog', 'pending' or 'blocked' to 'completed' are NOT allowed."
3587
- },
3588
- priority: { type: "number", minimum: 1, maximum: 5 },
3589
- agent: { type: "string" },
3590
- role: { type: "string" },
3591
- model: { type: "string" },
3592
- comment: {
3593
- type: "string",
3594
- description: "REQUIRED when changing task status. Explain WHY the status is changing (e.g., 'Starting implementation', 'Blocked by missing API docs', 'Verified fix')."
3595
- },
3596
- doc_path: { type: "string" },
3597
- tags: { type: "array", items: { type: "string" } },
3598
- metadata: { type: "object" },
3599
- parent_id: { type: "string", format: "uuid" },
3600
- depends_on: { type: "string", format: "uuid" },
3601
- est_tokens: {
3602
- type: "number",
3603
- minimum: 0,
3604
- description: "Estimated total tokens actually used for this task. Required when status changes to 'completed'."
3605
- },
3606
- force: {
3607
- type: "boolean",
3608
- description: "If true, bypasses status transition validation (e.g. pending -> completed)."
3609
- },
3748
+ memory_id: { type: "string", format: "uuid" },
3749
+ status: { type: "string", enum: ["used", "irrelevant", "contradictory"] },
3750
+ application_context: { type: "string", minLength: 10 },
3610
3751
  structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3611
3752
  },
3612
- required: ["repo"]
3753
+ required: ["memory_id", "status"]
3613
3754
  },
3614
3755
  outputSchema: {
3615
3756
  type: "object",
3616
3757
  properties: {
3617
3758
  success: { type: "boolean" },
3618
3759
  id: { type: "string" },
3619
- ids: { type: "array", items: { type: "string" } },
3620
- repo: { type: "string" },
3621
- status: { type: "string" },
3622
- archivedToMemory: { type: "boolean" },
3623
- updatedFields: {
3624
- type: "array",
3625
- items: { type: "string" }
3626
- },
3627
- updatedCount: { type: "number" }
3760
+ status: { type: "string" }
3628
3761
  },
3629
- required: ["success", "repo"]
3762
+ required: ["success", "id", "status"]
3630
3763
  }
3631
3764
  },
3632
3765
  {
3633
- name: "task-delete",
3634
- title: "Task Delete",
3635
- description: "Delete one or more tasks from a repository. Supports single 'id' or bulk 'ids'.",
3766
+ name: "memory-update",
3767
+ title: "Memory Update",
3768
+ description: "Update an existing memory entry. Keep 'title' concise and move agent/role/date or claim context into 'metadata' instead of the title.",
3636
3769
  annotations: {
3637
3770
  readOnlyHint: false,
3638
3771
  idempotentHint: false,
3639
- destructiveHint: true,
3772
+ destructiveHint: false,
3640
3773
  openWorldHint: false
3641
3774
  },
3642
3775
  inputSchema: {
3643
3776
  type: "object",
3644
3777
  properties: {
3645
- repo: { type: "string", description: "Repository name" },
3646
- id: { type: "string", format: "uuid", description: "Task ID (for single deletion)" },
3647
- ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk deletion)" },
3648
- structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3778
+ id: { type: "string", format: "uuid" },
3779
+ type: {
3780
+ type: "string",
3781
+ enum: [
3782
+ "code_fact",
3783
+ "decision",
3784
+ "mistake",
3785
+ "pattern",
3786
+ "file_claim",
3787
+ "task_archive"
3788
+ ]
3789
+ },
3790
+ title: { type: "string", minLength: 3, maxLength: 100 },
3791
+ content: { type: "string", minLength: 10 },
3792
+ importance: { type: "number", minimum: 1, maximum: 5 },
3793
+ agent: { type: "string" },
3794
+ role: { type: "string" },
3795
+ status: { type: "string", enum: ["active", "archived"] },
3796
+ supersedes: { type: "string", format: "uuid" },
3797
+ tags: { type: "array", items: { type: "string" } },
3798
+ metadata: { type: "object" },
3799
+ is_global: { type: "boolean" },
3800
+ completed_at: { type: "string" },
3801
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the updated memory." }
3649
3802
  },
3650
- required: ["repo"]
3803
+ required: ["id"]
3651
3804
  },
3652
3805
  outputSchema: {
3653
3806
  type: "object",
3654
3807
  properties: {
3655
3808
  success: { type: "boolean" },
3656
3809
  id: { type: "string" },
3657
- ids: { type: "array", items: { type: "string" } },
3658
3810
  repo: { type: "string" },
3659
- deletedCount: { type: "number" }
3811
+ updatedFields: {
3812
+ type: "array",
3813
+ items: { type: "string" }
3814
+ }
3660
3815
  },
3661
- required: ["success", "repo"]
3816
+ required: ["success", "id", "repo", "updatedFields"]
3662
3817
  }
3663
3818
  },
3664
3819
  {
3665
- name: "task-list",
3666
- title: "Task List",
3667
- description: "PRIMARY navigation and search tool for tasks. Returns a compact tabular list of tasks (id, task_code, title, status, priority, updated_at, comments_count). Defaults to in_progress and pending tasks. Use 'query' to filter by code, title, or description. Use 'status' (comma-separated) for specific filters. AGENTS: call this once at start, pick ONE task, then call task-detail.",
3820
+ name: "memory-search",
3821
+ title: "Memory Search",
3822
+ description: "NAVIGATION LAYER: Returns a pointer table of matching memory IDs only. Returns columns [id, title, type, importance] \u2014 NO content. Retrieve full memory via memory-detail. Use 'current_tags' to find tech-stack specific knowledge from other projects.",
3668
3823
  annotations: {
3669
3824
  readOnlyHint: true,
3670
3825
  idempotentHint: true,
@@ -3673,35 +3828,42 @@ var TOOL_DEFINITIONS = [
3673
3828
  inputSchema: {
3674
3829
  type: "object",
3675
3830
  properties: {
3676
- repo: {
3677
- type: "string",
3678
- description: "Repository name"
3679
- },
3680
- status: {
3681
- type: "string",
3682
- default: "in_progress,pending",
3683
- description: "Comma-separated status filter (backlog, pending, in_progress, completed, canceled, blocked). Defaults to 'in_progress,pending'."
3684
- },
3685
- phase: {
3686
- type: "string",
3687
- description: "Filter by phase (e.g., 'research', 'implementation')"
3688
- },
3689
- query: {
3690
- type: "string",
3691
- description: "Search keyword matching task code, title, or description"
3831
+ query: { type: "string", minLength: 3 },
3832
+ prompt: { type: "string" },
3833
+ repo: { type: "string" },
3834
+ current_tags: {
3835
+ type: "array",
3836
+ items: { type: "string" },
3837
+ description: "Active tech stack tags (e.g., ['filament', 'react'])"
3692
3838
  },
3693
- limit: {
3694
- type: "number",
3695
- minimum: 1,
3696
- maximum: 100,
3697
- default: 5,
3698
- description: "Maximum rows to return (default 5)"
3839
+ types: {
3840
+ type: "array",
3841
+ items: {
3842
+ type: "string",
3843
+ enum: [
3844
+ "code_fact",
3845
+ "decision",
3846
+ "mistake",
3847
+ "pattern",
3848
+ "file_claim",
3849
+ "task_archive"
3850
+ ]
3851
+ }
3699
3852
  },
3700
- offset: {
3701
- type: "number",
3702
- minimum: 0,
3703
- default: 0,
3704
- description: "Offset for pagination"
3853
+ minImportance: { type: "number", minimum: 1, maximum: 5 },
3854
+ limit: { type: "number", minimum: 1, maximum: 100, default: 5 },
3855
+ offset: { type: "number", minimum: 0, default: 0 },
3856
+ includeRecap: { type: "boolean", default: false },
3857
+ current_file_path: { type: "string" },
3858
+ include_archived: { type: "boolean", default: false },
3859
+ scope: {
3860
+ type: "object",
3861
+ properties: {
3862
+ repo: { type: "string" },
3863
+ branch: { type: "string" },
3864
+ folder: { type: "string" },
3865
+ language: { type: "string" }
3866
+ }
3705
3867
  },
3706
3868
  structured: {
3707
3869
  type: "boolean",
@@ -3709,84 +3871,111 @@ var TOOL_DEFINITIONS = [
3709
3871
  description: "If true, returns structured JSON without the text content summary."
3710
3872
  }
3711
3873
  },
3712
- required: ["repo"]
3874
+ required: ["query", "repo"]
3713
3875
  },
3714
3876
  outputSchema: {
3715
3877
  type: "object",
3716
3878
  properties: {
3717
- schema: { type: "string", enum: ["task-list"] },
3718
- tasks: {
3879
+ schema: { type: "string", enum: ["memory-search"] },
3880
+ query: { type: "string" },
3881
+ count: { type: "number", description: "Number of rows returned" },
3882
+ total: { type: "number", description: "Total matching memories" },
3883
+ offset: { type: "number" },
3884
+ limit: { type: "number" },
3885
+ results: {
3719
3886
  type: "object",
3720
3887
  properties: {
3721
3888
  columns: {
3722
3889
  type: "array",
3723
3890
  items: { type: "string" },
3724
- description: "Column names in order: id, task_code, title, status, priority, updated_at, comments_count"
3891
+ description: "Column names: [id, title, type, importance]"
3725
3892
  },
3726
3893
  rows: {
3727
3894
  type: "array",
3728
3895
  items: { type: "array" },
3729
- description: "Each row: [id, task_code, title, status, priority, updated_at, comments_count]. Use task-detail to fetch full task."
3896
+ description: "Each row: [id, title, type, importance]. Fetch full content via memory-detail"
3730
3897
  }
3731
3898
  },
3732
3899
  required: ["columns", "rows"]
3733
- },
3734
- count: { type: "number" },
3735
- offset: { type: "number" }
3900
+ }
3736
3901
  },
3737
- required: ["schema", "tasks", "count"]
3902
+ required: ["schema", "query", "count", "total", "offset", "limit", "results"]
3738
3903
  }
3739
3904
  },
3740
3905
  {
3741
- name: "handoff-create",
3742
- title: "Handoff Create",
3743
- description: "Create a handoff record when work needs context transfer between agents. Optionally link it to a task by task_id or task_code, and put machine-readable details in context.",
3906
+ name: "memory-summarize",
3907
+ title: "Memory Summarize",
3908
+ description: "Update the summary for a repository",
3744
3909
  annotations: {
3745
3910
  readOnlyHint: false,
3746
3911
  idempotentHint: false,
3747
- destructiveHint: false,
3748
3912
  openWorldHint: false
3749
3913
  },
3750
3914
  inputSchema: {
3751
3915
  type: "object",
3752
3916
  properties: {
3753
3917
  repo: { type: "string", description: "Repository name" },
3754
- from_agent: { type: "string", description: "Agent creating the handoff" },
3755
- to_agent: { type: "string", description: "Optional target agent" },
3756
- task_id: { type: "string", format: "uuid", description: "Optional task id to associate" },
3757
- task_code: { type: "string", description: "Optional task code to associate" },
3758
- summary: { type: "string", minLength: 1, description: "Concise human-readable transfer summary" },
3759
- context: {
3760
- type: "object",
3761
- description: "Structured handoff context, such as changed files, blockers, verification status, and next steps"
3918
+ signals: {
3919
+ type: "array",
3920
+ items: { type: "string", maxLength: 200 },
3921
+ minItems: 1,
3922
+ description: "High-level signals to include in summary"
3762
3923
  },
3763
- expires_at: { type: "string", description: "Optional expiration timestamp" },
3764
- structured: { type: "boolean", default: false }
3924
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON of the summary." }
3765
3925
  },
3766
- required: ["repo", "from_agent", "summary"]
3926
+ required: ["repo", "signals"]
3927
+ },
3928
+ outputSchema: {
3929
+ type: "object",
3930
+ properties: {
3931
+ success: { type: "boolean" },
3932
+ repo: { type: "string" },
3933
+ summary: { type: "string" },
3934
+ signalCount: { type: "number" }
3935
+ },
3936
+ required: ["success", "repo", "summary", "signalCount"]
3937
+ }
3938
+ },
3939
+ {
3940
+ name: "memory-delete",
3941
+ title: "Memory Delete",
3942
+ description: "Soft-delete one or more memory entries. Supports single 'id' or bulk 'ids'.",
3943
+ annotations: {
3944
+ readOnlyHint: false,
3945
+ idempotentHint: false,
3946
+ destructiveHint: true,
3947
+ openWorldHint: false
3948
+ },
3949
+ inputSchema: {
3950
+ type: "object",
3951
+ properties: {
3952
+ repo: { type: "string", description: "Repository name (optional for single id)" },
3953
+ id: { type: "string", format: "uuid", description: "Memory entry ID to delete" },
3954
+ ids: {
3955
+ type: "array",
3956
+ items: { type: "string", format: "uuid" },
3957
+ minItems: 1,
3958
+ description: "Array of memory IDs to delete"
3959
+ },
3960
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3961
+ }
3767
3962
  },
3768
3963
  outputSchema: {
3769
3964
  type: "object",
3770
3965
  properties: {
3966
+ success: { type: "boolean" },
3771
3967
  id: { type: "string" },
3968
+ ids: { type: "array", items: { type: "string" } },
3772
3969
  repo: { type: "string" },
3773
- from_agent: { type: "string" },
3774
- to_agent: { type: "string", nullable: true },
3775
- task_id: { type: "string", nullable: true },
3776
- summary: { type: "string" },
3777
- context: { type: "object" },
3778
- status: { type: "string", enum: ["pending", "accepted", "rejected", "expired"] },
3779
- created_at: { type: "string" },
3780
- updated_at: { type: "string" },
3781
- expires_at: { type: "string", nullable: true }
3970
+ deletedCount: { type: "number" }
3782
3971
  },
3783
- required: ["id", "repo", "from_agent", "summary", "context", "status", "created_at", "updated_at"]
3972
+ required: ["success"]
3784
3973
  }
3785
3974
  },
3786
3975
  {
3787
- name: "handoff-list",
3788
- title: "Handoff List",
3789
- description: "Navigation layer for handoff queues. List repository handoffs with optional status and agent filters, then inspect selected rows before acting.",
3976
+ name: "memory-recap",
3977
+ title: "Memory Recap",
3978
+ description: "AGGREGATED OVERVIEW LAYER: Returns stats (counts by type) and a pointer table of top memories [id, code, title, type, importance]. NO content. Use for orientation only \u2014 retrieve full memory via memory-detail.",
3790
3979
  annotations: {
3791
3980
  readOnlyHint: true,
3792
3981
  idempotentHint: true,
@@ -3795,806 +3984,632 @@ var TOOL_DEFINITIONS = [
3795
3984
  inputSchema: {
3796
3985
  type: "object",
3797
3986
  properties: {
3798
- repo: { type: "string", description: "Repository name" },
3799
- status: { type: "string", enum: ["pending", "accepted", "rejected", "expired"] },
3800
- from_agent: { type: "string" },
3801
- to_agent: { type: "string" },
3802
- limit: { type: "number", minimum: 1, maximum: 100, default: 20 },
3803
- offset: { type: "number", minimum: 0, default: 0 },
3804
- structured: { type: "boolean", default: false }
3987
+ repo: { type: "string", description: "Repository name (required)" },
3988
+ limit: {
3989
+ type: "number",
3990
+ minimum: 1,
3991
+ maximum: 50,
3992
+ default: 20,
3993
+ description: "Maximum number of top memories to return in the pointer table"
3994
+ },
3995
+ offset: {
3996
+ type: "number",
3997
+ minimum: 0,
3998
+ default: 0,
3999
+ description: "Number of memories to skip for pagination (optional, default 0)"
4000
+ },
4001
+ structured: {
4002
+ type: "boolean",
4003
+ default: false,
4004
+ description: "If true, returns structured JSON without the text content summary."
4005
+ }
3805
4006
  },
3806
4007
  required: ["repo"]
3807
4008
  },
3808
4009
  outputSchema: {
3809
4010
  type: "object",
3810
4011
  properties: {
3811
- schema: { type: "string", enum: ["handoff-list"] },
3812
- handoffs: {
4012
+ schema: { type: "string", enum: ["memory-recap"] },
4013
+ repo: { type: "string" },
4014
+ count: { type: "number", description: "Number of rows in the top pointer table" },
4015
+ total: { type: "number", description: "Total active memories in repo" },
4016
+ offset: { type: "number" },
4017
+ limit: { type: "number" },
4018
+ stats: {
4019
+ type: "object",
4020
+ properties: {
4021
+ byType: {
4022
+ type: "object",
4023
+ description: "Count of active memories per type (e.g. { decision: 3, code_fact: 7 })"
4024
+ }
4025
+ },
4026
+ required: ["byType"]
4027
+ },
4028
+ top: {
3813
4029
  type: "object",
3814
4030
  properties: {
3815
4031
  columns: {
3816
4032
  type: "array",
3817
4033
  items: { type: "string" },
3818
- description: "Column names: [id, from_agent, to_agent, task_id, status, created_at, summary]"
4034
+ description: "Column names: [id, code, title, type, importance]"
3819
4035
  },
3820
4036
  rows: {
3821
4037
  type: "array",
3822
4038
  items: { type: "array" },
3823
- description: "Each row: [id, from_agent, to_agent, task_id, status, created_at, summary]"
4039
+ description: "Each row: [id, code, title, type, importance]. Fetch full content via memory-detail"
3824
4040
  }
3825
4041
  },
3826
4042
  required: ["columns", "rows"]
3827
- },
3828
- count: { type: "number" },
3829
- offset: { type: "number" }
4043
+ }
3830
4044
  },
3831
- required: ["schema", "handoffs", "count", "offset"]
4045
+ required: ["schema", "repo", "count", "total", "offset", "limit", "stats", "top"]
3832
4046
  }
3833
4047
  },
3834
4048
  {
3835
- name: "task-claim",
3836
- title: "Task Claim",
3837
- description: "Claim task ownership for an agent using the dedicated claims table. Use this before taking work from task-list; provide either task_id or task_code.",
4049
+ name: "task-create",
4050
+ title: "Task Create",
4051
+ description: "Register one or more new tasks in a repository. task_code must be unique within the repository. Supports single task object or an array of tasks for bulk creation.",
3838
4052
  annotations: {
3839
4053
  readOnlyHint: false,
3840
4054
  idempotentHint: false,
3841
- destructiveHint: false,
3842
4055
  openWorldHint: false
3843
4056
  },
3844
4057
  inputSchema: {
3845
4058
  type: "object",
3846
4059
  properties: {
3847
4060
  repo: { type: "string", description: "Repository name" },
3848
- task_id: { type: "string", format: "uuid", description: "Task id to claim. Optional if task_code is provided." },
3849
- task_code: { type: "string", description: "Task code to claim. Optional if task_id is provided." },
3850
- agent: { type: "string", description: "Claiming agent name" },
3851
- role: { type: "string", description: "Claiming agent role" },
3852
- metadata: { type: "object", description: "Optional claim metadata" },
3853
- structured: { type: "boolean", default: false }
4061
+ task_code: { type: "string", description: "Unique task code (e.g. TASK-001) (Required for single task)" },
4062
+ phase: { type: "string", description: "Project phase (Required for single task)" },
4063
+ title: {
4064
+ type: "string",
4065
+ minLength: 3,
4066
+ maxLength: 100,
4067
+ description: "Task objective (Required for single task)"
4068
+ },
4069
+ description: { type: "string", description: "Detailed description (Required for single task)" },
4070
+ status: {
4071
+ type: "string",
4072
+ enum: ["backlog", "pending"],
4073
+ default: "backlog",
4074
+ description: "New tasks MUST start in 'backlog' if there are already 10 pending tasks. Otherwise can start in 'pending'."
4075
+ },
4076
+ priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
4077
+ agent: { type: "string" },
4078
+ role: { type: "string" },
4079
+ doc_path: { type: "string" },
4080
+ tags: { type: "array", items: { type: "string" } },
4081
+ metadata: { type: "object" },
4082
+ parent_id: { type: "string", format: "uuid" },
4083
+ depends_on: { type: "string", format: "uuid" },
4084
+ est_tokens: { type: "number", minimum: 0, description: "Estimated tokens budget for this task" },
4085
+ tasks: {
4086
+ type: "array",
4087
+ items: {
4088
+ type: "object",
4089
+ properties: {
4090
+ task_code: { type: "string" },
4091
+ phase: { type: "string" },
4092
+ title: { type: "string", minLength: 3, maxLength: 100 },
4093
+ description: { type: "string" },
4094
+ status: { type: "string", enum: ["backlog", "pending"], default: "backlog" },
4095
+ priority: { type: "number", minimum: 1, maximum: 5, default: 3 },
4096
+ agent: { type: "string" },
4097
+ role: { type: "string" },
4098
+ doc_path: { type: "string" },
4099
+ tags: { type: "array", items: { type: "string" } },
4100
+ metadata: { type: "object" },
4101
+ parent_id: { type: "string", format: "uuid" },
4102
+ depends_on: { type: "string", format: "uuid" },
4103
+ est_tokens: { type: "number", minimum: 0 }
4104
+ },
4105
+ required: ["task_code", "phase", "title", "description"]
4106
+ },
4107
+ description: "Array of tasks for bulk creation"
4108
+ },
4109
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3854
4110
  },
3855
- required: ["repo", "agent"]
4111
+ required: ["repo"]
3856
4112
  },
3857
4113
  outputSchema: {
3858
4114
  type: "object",
3859
4115
  properties: {
4116
+ success: { type: "boolean" },
3860
4117
  id: { type: "string" },
4118
+ task_code: { type: "string" },
3861
4119
  repo: { type: "string" },
3862
- task_id: { type: "string" },
3863
- task_code: { type: "string", nullable: true },
3864
- agent: { type: "string" },
3865
- role: { type: "string" },
3866
- claimed_at: { type: "string" },
3867
- released_at: { type: "string", nullable: true },
3868
- metadata: { type: "object" }
4120
+ phase: { type: "string" },
4121
+ title: { type: "string" },
4122
+ status: { type: "string" },
4123
+ priority: { type: "number" },
4124
+ createdCount: { type: "number" },
4125
+ taskCodes: { type: "array", items: { type: "string" } }
3869
4126
  },
3870
- required: ["id", "repo", "task_id", "agent", "role", "claimed_at", "metadata"]
4127
+ required: ["success", "repo"]
3871
4128
  }
3872
4129
  },
3873
4130
  {
3874
- name: "standard-store",
3875
- title: "Standard Store",
3876
- description: "Store one atomic coding standard. Use for durable implementation rules with explicit context, stack/language filters, and repo/global scope.",
4131
+ name: "task-update",
4132
+ title: "Task Update",
4133
+ description: "Update one or more tasks. Supports single update via 'id' or bulk update via 'ids'. Provide only the fields that need to be changed. MANDATORY WORKFLOW: You cannot move a task from 'pending' or 'blocked' directly to 'completed'. You MUST move it to 'in_progress' first. When changing status to 'completed', include 'est_tokens' with the estimated total tokens actually used for the task.",
3877
4134
  annotations: {
3878
4135
  readOnlyHint: false,
3879
4136
  idempotentHint: false,
3880
- destructiveHint: false,
3881
4137
  openWorldHint: false
3882
4138
  },
3883
4139
  inputSchema: {
3884
4140
  type: "object",
3885
4141
  properties: {
3886
- name: { type: "string", minLength: 3, maxLength: 255, description: "Human-readable standard name" },
3887
- content: { type: "string", minLength: 10, description: "One atomic, actionable standard written as concise Markdown" },
3888
- context: { type: "string", description: "Context or category (e.g., 'error-handling', 'security')" },
3889
- version: { type: "string", description: "Version of the standard (e.g., '1.0.0')" },
3890
- language: { type: "string", description: "Programming language (e.g., 'typescript', 'python')" },
3891
- stack: {
3892
- type: "array",
3893
- items: { type: "string" },
3894
- description: "Technology stack (e.g., ['react', 'nextjs'])"
4142
+ repo: { type: "string", description: "Repository name" },
4143
+ id: { type: "string", format: "uuid", description: "Task ID (for single update)" },
4144
+ ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk update)" },
4145
+ task_code: { type: "string" },
4146
+ phase: { type: "string" },
4147
+ title: { type: "string", minLength: 3, maxLength: 100 },
4148
+ description: { type: "string" },
4149
+ status: {
4150
+ type: "string",
4151
+ enum: ["backlog", "pending", "in_progress", "completed", "canceled", "blocked"],
4152
+ description: "New status. Transitions from 'backlog', 'pending' or 'blocked' to 'completed' are NOT allowed."
3895
4153
  },
3896
- repo: { type: "string", description: "Repository name for repo-specific standards. Omit only for global standards." },
3897
- is_global: { type: "boolean", description: "Whether standard applies globally or repo-specific" },
3898
- tags: {
3899
- type: "array",
3900
- items: { type: "string" },
3901
- description: "Tags for categorization"
4154
+ priority: { type: "number", minimum: 1, maximum: 5 },
4155
+ agent: { type: "string" },
4156
+ role: { type: "string" },
4157
+ model: { type: "string" },
4158
+ comment: {
4159
+ type: "string",
4160
+ description: "REQUIRED when changing task status. Explain WHY the status is changing (e.g., 'Starting implementation', 'Blocked by missing API docs', 'Verified fix')."
3902
4161
  },
3903
- metadata: {
3904
- type: "object",
3905
- description: "Additional metadata"
4162
+ doc_path: { type: "string" },
4163
+ tags: { type: "array", items: { type: "string" } },
4164
+ metadata: { type: "object" },
4165
+ parent_id: { type: "string", format: "uuid" },
4166
+ depends_on: { type: "string", format: "uuid" },
4167
+ est_tokens: {
4168
+ type: "number",
4169
+ minimum: 0,
4170
+ description: "Estimated total tokens actually used for this task. Required when status changes to 'completed'."
3906
4171
  },
3907
- agent: { type: "string", description: "Agent creating the standard" },
3908
- model: { type: "string", description: "AI model used" },
3909
- structured: { type: "boolean", default: false }
4172
+ force: {
4173
+ type: "boolean",
4174
+ description: "If true, bypasses status transition validation (e.g. pending -> completed)."
4175
+ },
4176
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3910
4177
  },
3911
- required: ["name", "content"]
3912
- },
3913
- outputSchema: {
3914
- type: "object",
3915
- properties: {
3916
- success: { type: "boolean" },
3917
- standard: {
3918
- type: "object",
3919
- properties: {
3920
- id: { type: "string" },
3921
- title: { type: "string" },
3922
- content: { type: "string" },
3923
- context: { type: "string" },
3924
- version: { type: "string" },
3925
- language: { type: "string", nullable: true },
3926
- stack: { type: "array", items: { type: "string" } },
3927
- is_global: { type: "boolean" },
3928
- repo: { type: "string", nullable: true },
3929
- tags: { type: "array", items: { type: "string" } },
3930
- metadata: { type: "object" },
3931
- created_at: { type: "string" },
3932
- updated_at: { type: "string" },
3933
- agent: { type: "string" },
3934
- model: { type: "string" }
3935
- },
3936
- required: [
3937
- "id",
3938
- "title",
3939
- "content",
3940
- "context",
3941
- "version",
3942
- "stack",
3943
- "is_global",
3944
- "tags",
3945
- "metadata",
3946
- "created_at",
3947
- "updated_at",
3948
- "agent",
3949
- "model"
3950
- ]
4178
+ required: ["repo"]
4179
+ },
4180
+ outputSchema: {
4181
+ type: "object",
4182
+ properties: {
4183
+ success: { type: "boolean" },
4184
+ id: { type: "string" },
4185
+ ids: { type: "array", items: { type: "string" } },
4186
+ repo: { type: "string" },
4187
+ status: { type: "string" },
4188
+ archivedToMemory: { type: "boolean" },
4189
+ updatedFields: {
4190
+ type: "array",
4191
+ items: { type: "string" }
3951
4192
  },
3952
- message: { type: "string" }
4193
+ updatedCount: { type: "number" }
3953
4194
  },
3954
- required: ["success", "standard", "message"]
4195
+ required: ["success", "repo"]
3955
4196
  }
3956
4197
  },
3957
4198
  {
3958
- name: "standard-search",
3959
- title: "Standard Search",
3960
- description: "Navigation and lookup layer for coding standards. Query by text, stack, language, version, repo, and global scope before applying or creating standards.",
4199
+ name: "task-delete",
4200
+ title: "Task Delete",
4201
+ description: "Delete one or more tasks from a repository. Supports single 'id' or bulk 'ids'.",
3961
4202
  annotations: {
3962
- readOnlyHint: true,
3963
- idempotentHint: true,
4203
+ readOnlyHint: false,
4204
+ idempotentHint: false,
4205
+ destructiveHint: true,
3964
4206
  openWorldHint: false
3965
4207
  },
3966
4208
  inputSchema: {
3967
4209
  type: "object",
3968
4210
  properties: {
3969
- query: { type: "string", description: "Search query (optional, searches title/content)" },
3970
- stack: {
3971
- type: "array",
3972
- items: { type: "string" },
3973
- description: "Technology stack to filter by (e.g., ['react', 'nextjs'])"
3974
- },
3975
- language: { type: "string", description: "Programming language filter" },
3976
- version: { type: "string", description: "Version filter" },
3977
- repo: { type: "string", description: "Repository filter (optional)" },
3978
- is_global: { type: "boolean", description: "Filter by global/repo-specific" },
3979
- limit: { type: "number", minimum: 1, maximum: 100, default: 20 },
3980
- offset: { type: "number", minimum: 0, default: 0 },
3981
- structured: { type: "boolean", default: false }
4211
+ repo: { type: "string", description: "Repository name" },
4212
+ id: { type: "string", format: "uuid", description: "Task ID (for single deletion)" },
4213
+ ids: { type: "array", items: { type: "string", format: "uuid" }, description: "Task IDs (for bulk deletion)" },
4214
+ structured: { type: "boolean", default: false, description: "If true, returns structured JSON result." }
3982
4215
  },
3983
- required: []
4216
+ required: ["repo"]
3984
4217
  },
3985
4218
  outputSchema: {
3986
4219
  type: "object",
3987
4220
  properties: {
3988
4221
  success: { type: "boolean" },
3989
- standards: {
3990
- type: "array",
3991
- items: {
3992
- type: "object",
3993
- properties: {
3994
- id: { type: "string" },
3995
- title: { type: "string" },
3996
- content: { type: "string" },
3997
- context: { type: "string" },
3998
- version: { type: "string" },
3999
- language: { type: "string", nullable: true },
4000
- stack: { type: "array", items: { type: "string" } },
4001
- is_global: { type: "boolean" },
4002
- repo: { type: "string", nullable: true },
4003
- tags: { type: "array", items: { type: "string" } },
4004
- metadata: { type: "object" },
4005
- created_at: { type: "string" },
4006
- updated_at: { type: "string" },
4007
- agent: { type: "string" },
4008
- model: { type: "string" }
4009
- }
4010
- },
4011
- description: "Matching coding standards"
4012
- },
4013
- count: { type: "number", description: "Number of results returned" },
4014
- message: { type: "string" }
4015
- },
4016
- required: ["success", "standards", "count", "message"]
4017
- }
4018
- }
4019
- ];
4020
-
4021
- // src/mcp/utils/pagination.ts
4022
- function encodeCursor(offset) {
4023
- return Buffer.from(String(offset), "utf8").toString("base64");
4024
- }
4025
- function decodeCursor(cursor) {
4026
- if (cursor === void 0 || cursor === null || cursor === "") {
4027
- return 0;
4028
- }
4029
- if (typeof cursor !== "string" || cursor.trim() === "") {
4030
- throw invalidPaginationParams("Invalid cursor");
4031
- }
4032
- let decoded;
4033
- try {
4034
- decoded = Buffer.from(cursor, "base64").toString("utf8");
4035
- } catch {
4036
- throw invalidPaginationParams("Invalid cursor");
4037
- }
4038
- if (!/^\d+$/.test(decoded)) {
4039
- throw invalidPaginationParams("Invalid cursor");
4040
- }
4041
- const offset = Number.parseInt(decoded, 10);
4042
- if (!Number.isFinite(offset) || offset < 0) {
4043
- throw invalidPaginationParams("Invalid cursor");
4044
- }
4045
- return offset;
4046
- }
4047
- function invalidPaginationParams(message) {
4048
- const error = new Error(message);
4049
- error.code = -32602;
4050
- return error;
4051
- }
4052
-
4053
- // src/mcp/utils/completion.ts
4054
- var MAX_COMPLETION_VALUES = 100;
4055
- function rankCompletionValues(candidates, input) {
4056
- const unique = [...new Set(candidates.filter(Boolean))];
4057
- const needle = input.trim().toLowerCase();
4058
- if (!needle) {
4059
- return unique.slice(0, MAX_COMPLETION_VALUES);
4060
- }
4061
- return unique.map((value) => ({ value, score: scoreCompletionValue(value, needle) })).filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score || a.value.localeCompare(b.value)).map((entry) => entry.value);
4062
- }
4063
- function scoreCompletionValue(value, needle) {
4064
- const haystack = value.toLowerCase();
4065
- if (haystack === needle) return 100;
4066
- if (haystack.startsWith(needle)) return 75;
4067
- if (haystack.includes(needle)) return 50;
4068
- const compactNeedle = needle.replace(/[\s_-]+/g, "");
4069
- const compactHaystack = haystack.replace(/[\s_-]+/g, "");
4070
- if (compactNeedle && compactHaystack.includes(compactNeedle)) return 25;
4071
- return 0;
4072
- }
4073
-
4074
- // src/mcp/resources/index.ts
4075
- var DEFAULT_PAGE_SIZE = 25;
4076
- var MAX_PAGE_SIZE = 100;
4077
- function listResources(session, params) {
4078
- const resources = [
4079
- {
4080
- uri: "repository://index",
4081
- name: "Repository Index",
4082
- title: "Repository Index",
4083
- description: "List of all known repositories with memory/task counts and last activity",
4084
- mimeType: "application/json",
4085
- annotations: {
4086
- audience: ["assistant"],
4087
- priority: 1,
4088
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
4089
- }
4090
- },
4091
- {
4092
- uri: "session://roots",
4093
- name: "Session Roots",
4094
- title: "Session Roots",
4095
- description: session?.roots.length ? "Active workspace roots provided by the MCP client" : "No active workspace roots were provided by the MCP client",
4096
- mimeType: "application/json",
4097
- size: Buffer.byteLength(JSON.stringify({ roots: session?.roots ?? [] }), "utf8"),
4098
- annotations: {
4099
- audience: ["assistant"],
4100
- priority: 0.95,
4101
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
4102
- }
4103
- }
4104
- ];
4105
- return paginateEntries("resources", resources, params);
4106
- }
4107
- function listResourceTemplates(params) {
4108
- const templates = [
4109
- // ── Memory ──────────────────────────────────────────────────────────────
4110
- {
4111
- uriTemplate: "repository://{name}/memories",
4112
- name: "Repository Memories",
4113
- title: "Repository Memories",
4114
- description: "All active memory entries for a specific repository",
4115
- mimeType: "application/json",
4116
- annotations: { audience: ["assistant"], priority: 0.85 }
4117
- },
4118
- {
4119
- uriTemplate: "repository://{name}/memories?search={search}&type={type}&tag={tag}",
4120
- name: "Filtered Repository Memories",
4121
- title: "Filtered Repository Memories",
4122
- description: "Filter or search memories within a repository by keyword, type, or tag",
4123
- mimeType: "application/json",
4124
- annotations: { audience: ["assistant"], priority: 0.8 }
4125
- },
4126
- {
4127
- uriTemplate: "memory://{id}",
4128
- name: "Memory Detail",
4129
- title: "Memory Detail",
4130
- description: "Full content and statistics for a specific memory UUID",
4131
- mimeType: "application/json",
4132
- annotations: { audience: ["assistant"], priority: 0.75 }
4133
- },
4134
- // ── Tasks ────────────────────────────────────────────────────────────────
4135
- {
4136
- uriTemplate: "repository://{name}/tasks",
4137
- name: "Repository Tasks",
4138
- title: "Repository Tasks",
4139
- description: "All active tasks for a specific repository",
4140
- mimeType: "application/json",
4141
- annotations: { audience: ["assistant"], priority: 0.9 }
4142
- },
4143
- {
4144
- uriTemplate: "repository://{name}/tasks?status={status}&priority={priority}",
4145
- name: "Filtered Repository Tasks",
4146
- title: "Filtered Repository Tasks",
4147
- description: "Filter tasks within a repository by status or priority level",
4148
- mimeType: "application/json",
4149
- annotations: { audience: ["assistant"], priority: 0.85 }
4150
- },
4151
- {
4152
- uriTemplate: "task://{id}",
4153
- name: "Task Detail",
4154
- title: "Task Detail",
4155
- description: "Full content and comments for a specific task UUID",
4156
- mimeType: "application/json",
4157
- annotations: { audience: ["assistant"], priority: 0.8 }
4158
- },
4159
- // ── Repository extras ────────────────────────────────────────────────────
4160
- {
4161
- uriTemplate: "repository://{name}/summary",
4162
- name: "Repository Summary",
4163
- title: "Repository Summary",
4164
- description: "High-level architectural summary for a repository",
4165
- mimeType: "text/plain",
4166
- annotations: { audience: ["assistant"], priority: 0.95 }
4167
- },
4168
- {
4169
- uriTemplate: "repository://{name}/actions",
4170
- name: "Repository Actions",
4171
- title: "Repository Actions",
4172
- description: "Audit log of agent tool actions scoped to a repository",
4173
- mimeType: "application/json",
4174
- annotations: { audience: ["assistant"], priority: 0.6 }
4175
- },
4176
- // ── Action detail ────────────────────────────────────────────────────────
4177
- {
4178
- uriTemplate: "action://{id}",
4179
- name: "Action Detail",
4180
- title: "Action Detail",
4181
- description: "Full details of a specific audit log entry by integer ID",
4182
- mimeType: "application/json",
4183
- annotations: { audience: ["assistant"], priority: 0.55 }
4184
- }
4185
- ];
4186
- return paginateEntries("resourceTemplates", templates, params);
4187
- }
4188
- function completeResourceArgument(resourceUri, argumentName, argumentValue, _contextArguments, dataSources) {
4189
- if (resourceUri === "repository://{name}/memories" || resourceUri === "repository://{name}/memories?search={search}&type={type}&tag={tag}" || resourceUri === "repository://{name}/tasks" || resourceUri === "repository://{name}/tasks?status={status}&priority={priority}" || resourceUri === "repository://{name}/summary" || resourceUri === "repository://{name}/actions") {
4190
- if (argumentName === "name") {
4191
- return rankCompletionValues(dataSources.repos, argumentValue);
4192
- }
4193
- }
4194
- if (resourceUri === "repository://{name}/memories?search={search}&type={type}&tag={tag}") {
4195
- if (argumentName === "tag") {
4196
- return rankCompletionValues(dataSources.tags, argumentValue);
4222
+ id: { type: "string" },
4223
+ ids: { type: "array", items: { type: "string" } },
4224
+ repo: { type: "string" },
4225
+ deletedCount: { type: "number" }
4226
+ },
4227
+ required: ["success", "repo"]
4197
4228
  }
4198
- }
4199
- throw invalidCompletionParams(`Unknown resource template or argument: ${resourceUri} (${argumentName})`);
4200
- }
4201
- function readResource(uri, db, session) {
4202
- logger.info("[Tool] resource.read", { uri });
4203
- if (uri === "repository://index") {
4204
- const repos = db.system.listRepoNavigation();
4205
- const payload = JSON.stringify(repos, null, 2);
4206
- return {
4207
- contents: [
4208
- {
4209
- uri,
4210
- mimeType: "application/json",
4211
- text: payload,
4212
- size: Buffer.byteLength(payload, "utf8"),
4213
- annotations: {
4214
- audience: ["assistant"],
4215
- priority: 1,
4216
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
4217
- }
4218
- }
4219
- ]
4220
- };
4221
- }
4222
- if (uri === "session://roots") {
4223
- const payload = JSON.stringify({ roots: session?.roots ?? [] }, null, 2);
4224
- return {
4225
- contents: [
4226
- {
4227
- uri,
4228
- mimeType: "application/json",
4229
- text: payload,
4230
- size: Buffer.byteLength(payload, "utf8"),
4231
- annotations: {
4232
- audience: ["assistant"],
4233
- priority: 0.95,
4234
- lastModified: (/* @__PURE__ */ new Date()).toISOString()
4235
- }
4236
- }
4237
- ]
4238
- };
4239
- }
4240
- const memoryIdMatch = uri.match(/^memory:\/\/([0-9a-f-]{36})$/i);
4241
- if (memoryIdMatch) {
4242
- const id = memoryIdMatch[1];
4243
- const entry = db.memories.getByIdWithStats(id);
4244
- if (!entry) throw resourceNotFound(`Memory with ID ${id} not found.`, uri);
4245
- const payload = JSON.stringify(entry, null, 2);
4246
- return {
4247
- contents: [
4248
- {
4249
- uri,
4250
- mimeType: "application/json",
4251
- text: payload,
4252
- size: Buffer.byteLength(payload, "utf8"),
4253
- annotations: {
4254
- audience: ["assistant"],
4255
- priority: 0.75,
4256
- lastModified: entry.updated_at || entry.created_at
4257
- }
4258
- }
4259
- ]
4260
- };
4261
- }
4262
- const taskIdMatch = uri.match(/^task:\/\/([0-9a-f-]{36})$/i);
4263
- if (taskIdMatch) {
4264
- const id = taskIdMatch[1];
4265
- const task = db.tasks.getTaskById(id);
4266
- if (!task) throw resourceNotFound(`Task with ID ${id} not found.`, uri);
4267
- const payload = JSON.stringify(task, null, 2);
4268
- return {
4269
- contents: [
4270
- {
4271
- uri,
4272
- mimeType: "application/json",
4273
- text: payload,
4274
- size: Buffer.byteLength(payload, "utf8"),
4275
- annotations: {
4276
- audience: ["assistant"],
4277
- priority: 0.8,
4278
- lastModified: task.updated_at || task.created_at
4279
- }
4229
+ },
4230
+ {
4231
+ name: "task-list",
4232
+ title: "Task List",
4233
+ description: "PRIMARY navigation and search tool for tasks. Returns a compact tabular list of tasks (id, task_code, title, status, priority, updated_at, comments_count). Defaults to in_progress and pending tasks. Use 'query' to filter by code, title, or description. Use 'status' (comma-separated) for specific filters. AGENTS: call this once at start, pick ONE task, then call task-detail.",
4234
+ annotations: {
4235
+ readOnlyHint: true,
4236
+ idempotentHint: true,
4237
+ openWorldHint: false
4238
+ },
4239
+ inputSchema: {
4240
+ type: "object",
4241
+ properties: {
4242
+ repo: {
4243
+ type: "string",
4244
+ description: "Repository name"
4245
+ },
4246
+ status: {
4247
+ type: "string",
4248
+ default: "in_progress,pending",
4249
+ description: "Comma-separated status filter (backlog, pending, in_progress, completed, canceled, blocked). Defaults to 'in_progress,pending'."
4250
+ },
4251
+ phase: {
4252
+ type: "string",
4253
+ description: "Filter by phase (e.g., 'research', 'implementation')"
4254
+ },
4255
+ query: {
4256
+ type: "string",
4257
+ description: "Search keyword matching task code, title, or description"
4258
+ },
4259
+ limit: {
4260
+ type: "number",
4261
+ minimum: 1,
4262
+ maximum: 100,
4263
+ default: 5,
4264
+ description: "Maximum rows to return (default 5)"
4265
+ },
4266
+ offset: {
4267
+ type: "number",
4268
+ minimum: 0,
4269
+ default: 0,
4270
+ description: "Offset for pagination"
4271
+ },
4272
+ structured: {
4273
+ type: "boolean",
4274
+ default: false,
4275
+ description: "If true, returns structured JSON without the text content summary."
4280
4276
  }
4281
- ]
4282
- };
4283
- }
4284
- const repoBase = parseRepoUri(uri);
4285
- if (repoBase) {
4286
- const { name, path: repoPath, query } = repoBase;
4287
- if (repoPath === "summary") {
4288
- const summary = db.summaries.getSummary(name);
4289
- const text = summary?.summary || `No summary available for repository: ${name}`;
4290
- return {
4291
- contents: [
4292
- {
4293
- uri,
4294
- mimeType: "text/plain",
4295
- text,
4296
- size: Buffer.byteLength(text, "utf8"),
4297
- annotations: {
4298
- audience: ["assistant"],
4299
- priority: 0.95,
4300
- lastModified: summary?.updated_at || (/* @__PURE__ */ new Date()).toISOString()
4277
+ },
4278
+ required: ["repo"]
4279
+ },
4280
+ outputSchema: {
4281
+ type: "object",
4282
+ properties: {
4283
+ schema: { type: "string", enum: ["task-list"] },
4284
+ tasks: {
4285
+ type: "object",
4286
+ properties: {
4287
+ columns: {
4288
+ type: "array",
4289
+ items: { type: "string" },
4290
+ description: "Column names in order: id, task_code, title, status, priority, updated_at, comments_count"
4291
+ },
4292
+ rows: {
4293
+ type: "array",
4294
+ items: { type: "array" },
4295
+ description: "Each row: [id, task_code, title, status, priority, updated_at, comments_count]. Use task-detail to fetch full task."
4301
4296
  }
4302
- }
4303
- ]
4304
- };
4297
+ },
4298
+ required: ["columns", "rows"]
4299
+ },
4300
+ count: { type: "number" },
4301
+ offset: { type: "number" }
4302
+ },
4303
+ required: ["schema", "tasks", "count"]
4305
4304
  }
4306
- if (repoPath === "memories") {
4307
- const search = query.get("search") || "";
4308
- const type = query.get("type");
4309
- const tag = query.get("tag");
4310
- const result = db.memories.listMemoriesForDashboard({
4311
- repo: name,
4312
- type: type || void 0,
4313
- tag: tag || void 0,
4314
- search: search || void 0,
4315
- limit: 50
4316
- });
4317
- const entries = result.items;
4318
- const payload = JSON.stringify(entries, null, 2);
4319
- return {
4320
- contents: [
4321
- {
4322
- uri,
4323
- mimeType: "application/json",
4324
- text: payload,
4325
- size: Buffer.byteLength(payload, "utf8"),
4326
- annotations: {
4327
- audience: ["assistant"],
4328
- priority: 0.85,
4329
- lastModified: deriveLastModifiedFromCollection(
4330
- entries.map((e) => e.updated_at || e.created_at)
4331
- )
4332
- }
4333
- }
4334
- ]
4335
- };
4305
+ },
4306
+ {
4307
+ name: "handoff-create",
4308
+ title: "Handoff Create",
4309
+ description: "Create a handoff record when work needs context transfer between agents. Optionally link it to a task by task_id or task_code, and put machine-readable details in context.",
4310
+ annotations: {
4311
+ readOnlyHint: false,
4312
+ idempotentHint: false,
4313
+ destructiveHint: false,
4314
+ openWorldHint: false
4315
+ },
4316
+ inputSchema: {
4317
+ type: "object",
4318
+ properties: {
4319
+ repo: { type: "string", description: "Repository name" },
4320
+ from_agent: { type: "string", description: "Agent creating the handoff" },
4321
+ to_agent: { type: "string", description: "Optional target agent" },
4322
+ task_id: { type: "string", format: "uuid", description: "Optional task id to associate" },
4323
+ task_code: { type: "string", description: "Optional task code to associate" },
4324
+ summary: { type: "string", minLength: 1, description: "Concise human-readable transfer summary" },
4325
+ context: {
4326
+ type: "object",
4327
+ description: "Structured handoff context, such as changed files, blockers, verification status, and next steps"
4328
+ },
4329
+ expires_at: { type: "string", description: "Optional expiration timestamp" },
4330
+ structured: { type: "boolean", default: false }
4331
+ },
4332
+ required: ["repo", "from_agent", "summary"]
4333
+ },
4334
+ outputSchema: {
4335
+ type: "object",
4336
+ properties: {
4337
+ id: { type: "string" },
4338
+ repo: { type: "string" },
4339
+ from_agent: { type: "string" },
4340
+ to_agent: { type: "string", nullable: true },
4341
+ task_id: { type: "string", nullable: true },
4342
+ summary: { type: "string" },
4343
+ context: { type: "object" },
4344
+ status: { type: "string", enum: ["pending", "accepted", "rejected", "expired"] },
4345
+ created_at: { type: "string" },
4346
+ updated_at: { type: "string" },
4347
+ expires_at: { type: "string", nullable: true }
4348
+ },
4349
+ required: ["id", "repo", "from_agent", "summary", "context", "status", "created_at", "updated_at"]
4336
4350
  }
4337
- if (repoPath === "tasks") {
4338
- const status = query.get("status");
4339
- const priority = query.get("priority");
4340
- let tasks;
4341
- if (status && status !== "all") {
4342
- const statuses = status.split(",").map((s) => s.trim());
4343
- tasks = db.tasks.getTasksByMultipleStatuses(name, statuses);
4344
- } else {
4345
- tasks = db.tasks.getTasksByMultipleStatuses(name, ["backlog", "pending", "in_progress", "blocked"]);
4346
- }
4347
- if (priority) {
4348
- const p = Number(priority);
4349
- if (!isNaN(p)) {
4350
- tasks = tasks.filter((t) => t.priority === p);
4351
- }
4352
- }
4353
- const payload = JSON.stringify(tasks, null, 2);
4354
- return {
4355
- contents: [
4356
- {
4357
- uri,
4358
- mimeType: "application/json",
4359
- text: payload,
4360
- size: Buffer.byteLength(payload, "utf8"),
4361
- annotations: {
4362
- audience: ["assistant"],
4363
- priority: 0.9,
4364
- lastModified: deriveLastModifiedFromCollection(tasks.map((t) => t.updated_at))
4351
+ },
4352
+ {
4353
+ name: "handoff-list",
4354
+ title: "Handoff List",
4355
+ description: "Navigation layer for handoff queues. List repository handoffs with optional status and agent filters, then inspect selected rows before acting.",
4356
+ annotations: {
4357
+ readOnlyHint: true,
4358
+ idempotentHint: true,
4359
+ openWorldHint: false
4360
+ },
4361
+ inputSchema: {
4362
+ type: "object",
4363
+ properties: {
4364
+ repo: { type: "string", description: "Repository name" },
4365
+ status: { type: "string", enum: ["pending", "accepted", "rejected", "expired"] },
4366
+ from_agent: { type: "string" },
4367
+ to_agent: { type: "string" },
4368
+ limit: { type: "number", minimum: 1, maximum: 100, default: 20 },
4369
+ offset: { type: "number", minimum: 0, default: 0 },
4370
+ structured: { type: "boolean", default: false }
4371
+ },
4372
+ required: ["repo"]
4373
+ },
4374
+ outputSchema: {
4375
+ type: "object",
4376
+ properties: {
4377
+ schema: { type: "string", enum: ["handoff-list"] },
4378
+ handoffs: {
4379
+ type: "object",
4380
+ properties: {
4381
+ columns: {
4382
+ type: "array",
4383
+ items: { type: "string" },
4384
+ description: "Column names: [id, from_agent, to_agent, task_id, status, created_at, summary]"
4385
+ },
4386
+ rows: {
4387
+ type: "array",
4388
+ items: { type: "array" },
4389
+ description: "Each row: [id, from_agent, to_agent, task_id, status, created_at, summary]"
4365
4390
  }
4366
- }
4367
- ]
4368
- };
4391
+ },
4392
+ required: ["columns", "rows"]
4393
+ },
4394
+ count: { type: "number" },
4395
+ offset: { type: "number" }
4396
+ },
4397
+ required: ["schema", "handoffs", "count", "offset"]
4369
4398
  }
4370
- if (repoPath === "actions") {
4371
- const actions = db.actions.getRecentActions(name, 100);
4372
- const payload = JSON.stringify(actions, null, 2);
4373
- return {
4374
- contents: [
4375
- {
4376
- uri,
4377
- mimeType: "application/json",
4378
- text: payload,
4379
- size: Buffer.byteLength(payload, "utf8"),
4380
- annotations: {
4381
- audience: ["assistant"],
4382
- priority: 0.6,
4383
- lastModified: deriveLastModifiedFromCollection(actions.map((a) => a.created_at))
4384
- }
4385
- }
4386
- ]
4387
- };
4399
+ },
4400
+ {
4401
+ name: "task-claim",
4402
+ title: "Task Claim",
4403
+ description: "Claim task ownership for an agent using the dedicated claims table. Use this before taking work from task-list; provide either task_id or task_code.",
4404
+ annotations: {
4405
+ readOnlyHint: false,
4406
+ idempotentHint: false,
4407
+ destructiveHint: false,
4408
+ openWorldHint: false
4409
+ },
4410
+ inputSchema: {
4411
+ type: "object",
4412
+ properties: {
4413
+ repo: { type: "string", description: "Repository name" },
4414
+ task_id: { type: "string", format: "uuid", description: "Task id to claim. Optional if task_code is provided." },
4415
+ task_code: { type: "string", description: "Task code to claim. Optional if task_id is provided." },
4416
+ agent: { type: "string", description: "Claiming agent name" },
4417
+ role: { type: "string", description: "Claiming agent role" },
4418
+ metadata: { type: "object", description: "Optional claim metadata" },
4419
+ structured: { type: "boolean", default: false }
4420
+ },
4421
+ required: ["repo", "agent"]
4422
+ },
4423
+ outputSchema: {
4424
+ type: "object",
4425
+ properties: {
4426
+ id: { type: "string" },
4427
+ repo: { type: "string" },
4428
+ task_id: { type: "string" },
4429
+ task_code: { type: "string", nullable: true },
4430
+ agent: { type: "string" },
4431
+ role: { type: "string" },
4432
+ claimed_at: { type: "string" },
4433
+ released_at: { type: "string", nullable: true },
4434
+ metadata: { type: "object" }
4435
+ },
4436
+ required: ["id", "repo", "task_id", "agent", "role", "claimed_at", "metadata"]
4388
4437
  }
4389
- }
4390
- const actionIdMatch = uri.match(/^action:\/\/(\d+)$/);
4391
- if (actionIdMatch) {
4392
- const id = Number(actionIdMatch[1]);
4393
- const action = db.actions.getActionById(id);
4394
- if (!action) throw resourceNotFound(`Action with ID ${id} not found.`, uri);
4395
- const payload = JSON.stringify(action, null, 2);
4396
- return {
4397
- contents: [
4398
- {
4399
- uri,
4400
- mimeType: "application/json",
4401
- text: payload,
4402
- size: Buffer.byteLength(payload, "utf8"),
4403
- annotations: {
4404
- audience: ["assistant"],
4405
- priority: 0.55,
4406
- lastModified: action.created_at
4407
- }
4408
- }
4409
- ]
4410
- };
4411
- }
4412
- throw resourceNotFound(`Unknown resource URI: ${uri}`, uri);
4413
- }
4414
- function parseRepoUri(uri) {
4415
- const prefix = "repository://";
4416
- if (!uri.startsWith(prefix)) return null;
4417
- const rest = uri.slice(prefix.length);
4418
- const queryStart = rest.indexOf("?");
4419
- const withoutQuery = queryStart === -1 ? rest : rest.slice(0, queryStart);
4420
- const queryString = queryStart === -1 ? "" : rest.slice(queryStart + 1);
4421
- const slashIdx = withoutQuery.indexOf("/");
4422
- if (slashIdx === -1) return null;
4423
- const name = withoutQuery.slice(0, slashIdx);
4424
- const path6 = withoutQuery.slice(slashIdx + 1);
4425
- if (!name || !path6) return null;
4426
- return { name, path: path6, query: new URLSearchParams(queryString) };
4427
- }
4428
- function paginateEntries(key, entries, params) {
4429
- const limit = normalizeLimit(params?.limit);
4430
- const offset = decodeCursor(params?.cursor);
4431
- const sliced = entries.slice(offset, offset + limit);
4432
- const nextOffset = offset + sliced.length;
4433
- return {
4434
- [key]: sliced,
4435
- nextCursor: nextOffset < entries.length ? encodeCursor(nextOffset) : void 0
4436
- };
4437
- }
4438
- function normalizeLimit(limit) {
4439
- if (typeof limit !== "number" || !Number.isFinite(limit)) {
4440
- return DEFAULT_PAGE_SIZE;
4441
- }
4442
- return Math.min(MAX_PAGE_SIZE, Math.max(1, Math.trunc(limit)));
4443
- }
4444
- function deriveLastModifiedFromCollection(values) {
4445
- const normalized = values.filter((value) => typeof value === "string" && value.length > 0);
4446
- return normalized.sort().at(-1) ?? (/* @__PURE__ */ new Date()).toISOString();
4447
- }
4448
- function resourceNotFound(message, uri) {
4449
- const error = new Error(message);
4450
- error.code = -32002;
4451
- error.data = { uri };
4452
- return error;
4453
- }
4454
- function invalidCompletionParams(message) {
4455
- const error = new Error(message);
4456
- error.code = -32602;
4457
- return error;
4458
- }
4459
-
4460
- // src/mcp/prompts/loader.ts
4461
- import fs4 from "fs";
4462
- import path5 from "path";
4463
- import { fileURLToPath as fileURLToPath3 } from "url";
4464
- import matter from "gray-matter";
4465
- var __filename = fileURLToPath3(import.meta.url);
4466
- var __dirname2 = path5.dirname(__filename);
4467
- function findPromptDir() {
4468
- const candidates = [
4469
- // Production if chunked into dist/
4470
- "./prompts",
4471
- // Production if inlined into dist/mcp/
4472
- "../prompts",
4473
- // Dev: /src/mcp/prompts/definitions (next to loader.ts)
4474
- "./definitions"
4475
- ].map((relPath) => path5.resolve(__dirname2, relPath));
4476
- for (const dir of candidates) {
4477
- if (fs4.existsSync(dir)) {
4478
- const files = fs4.readdirSync(dir);
4479
- if (files.some((f) => f.endsWith(".md"))) {
4480
- return dir;
4481
- }
4438
+ },
4439
+ {
4440
+ name: "standard-store",
4441
+ title: "Standard Store",
4442
+ description: "Store one atomic coding standard. Use for durable implementation rules with explicit context, stack/language filters, and repo/global scope.",
4443
+ annotations: {
4444
+ readOnlyHint: false,
4445
+ idempotentHint: false,
4446
+ destructiveHint: false,
4447
+ openWorldHint: false
4448
+ },
4449
+ inputSchema: {
4450
+ type: "object",
4451
+ properties: {
4452
+ name: { type: "string", minLength: 3, maxLength: 255, description: "Human-readable standard name" },
4453
+ content: { type: "string", minLength: 10, description: "One atomic, actionable standard written as concise Markdown" },
4454
+ context: { type: "string", description: "Context or category (e.g., 'error-handling', 'security')" },
4455
+ version: { type: "string", description: "Version of the standard (e.g., '1.0.0')" },
4456
+ language: { type: "string", description: "Programming language (e.g., 'typescript', 'python')" },
4457
+ stack: {
4458
+ type: "array",
4459
+ items: { type: "string" },
4460
+ description: "Technology stack (e.g., ['react', 'nextjs'])"
4461
+ },
4462
+ repo: { type: "string", description: "Repository name for repo-specific standards. Omit only for global standards." },
4463
+ is_global: { type: "boolean", description: "Whether standard applies globally or repo-specific" },
4464
+ tags: {
4465
+ type: "array",
4466
+ items: { type: "string" },
4467
+ description: "Tags for categorization"
4468
+ },
4469
+ metadata: {
4470
+ type: "object",
4471
+ description: "Additional metadata"
4472
+ },
4473
+ agent: { type: "string", description: "Agent creating the standard" },
4474
+ model: { type: "string", description: "AI model used" },
4475
+ structured: { type: "boolean", default: false }
4476
+ },
4477
+ required: ["name", "content"]
4478
+ },
4479
+ outputSchema: {
4480
+ type: "object",
4481
+ properties: {
4482
+ success: { type: "boolean" },
4483
+ standard: {
4484
+ type: "object",
4485
+ properties: {
4486
+ id: { type: "string" },
4487
+ title: { type: "string" },
4488
+ content: { type: "string" },
4489
+ context: { type: "string" },
4490
+ version: { type: "string" },
4491
+ language: { type: "string", nullable: true },
4492
+ stack: { type: "array", items: { type: "string" } },
4493
+ is_global: { type: "boolean" },
4494
+ repo: { type: "string", nullable: true },
4495
+ tags: { type: "array", items: { type: "string" } },
4496
+ metadata: { type: "object" },
4497
+ created_at: { type: "string" },
4498
+ updated_at: { type: "string" },
4499
+ agent: { type: "string" },
4500
+ model: { type: "string" }
4501
+ },
4502
+ required: [
4503
+ "id",
4504
+ "title",
4505
+ "content",
4506
+ "context",
4507
+ "version",
4508
+ "stack",
4509
+ "is_global",
4510
+ "tags",
4511
+ "metadata",
4512
+ "created_at",
4513
+ "updated_at",
4514
+ "agent",
4515
+ "model"
4516
+ ]
4517
+ },
4518
+ message: { type: "string" }
4519
+ },
4520
+ required: ["success", "standard", "message"]
4482
4521
  }
4483
- }
4484
- return path5.resolve(__dirname2, "./definitions");
4485
- }
4486
- var PROMPT_DIR = findPromptDir();
4487
- function listPromptFiles() {
4488
- if (!fs4.existsSync(PROMPT_DIR)) return [];
4489
- return fs4.readdirSync(PROMPT_DIR).filter((file) => file.endsWith(".md")).map((file) => file.replace(/\.md$/, "")).sort();
4490
- }
4491
- function loadPromptFromMarkdown(name) {
4492
- const filePath = path5.join(PROMPT_DIR, `${name}.md`);
4493
- if (!fs4.existsSync(filePath)) {
4494
- throw new Error(`Prompt file not found: ${filePath}`);
4495
- }
4496
- const fileContent = fs4.readFileSync(filePath, "utf-8");
4497
- const { data, content } = matter(fileContent);
4498
- return {
4499
- name: data.name || name,
4500
- description: data.description || "",
4501
- arguments: data.arguments || [],
4502
- agent: data.agent,
4503
- content: content.trim()
4504
- };
4505
- }
4506
-
4507
- // src/mcp/prompts/registry.ts
4508
- function createPromptDefinition(loaded) {
4509
- return {
4510
- name: loaded.name,
4511
- description: loaded.description,
4512
- arguments: loaded.arguments,
4513
- agent: loaded.agent,
4514
- messages: [
4515
- {
4516
- role: "user",
4517
- content: {
4518
- type: "text",
4519
- text: loaded.content
4520
- }
4521
- }
4522
- ]
4523
- };
4524
- }
4525
- var PROMPTS = {};
4526
- var promptFiles = listPromptFiles();
4527
- for (const name of promptFiles) {
4528
- try {
4529
- PROMPTS[name] = createPromptDefinition(loadPromptFromMarkdown(name));
4530
- } catch (e) {
4531
- logger.warn(`Failed to load prompt ${name}: ${e}`);
4532
- }
4533
- }
4534
- async function listPrompts(db, session, params) {
4535
- const allPrompts = Object.values(PROMPTS).map((p) => ({
4536
- name: p.name,
4537
- description: p.description,
4538
- arguments: p.arguments,
4539
- metadata: p.agent ? { agent: p.agent } : void 0
4540
- }));
4541
- const rawLimit = typeof params?.limit === "number" && Number.isInteger(params?.limit) ? params.limit : 25;
4542
- const limit = Math.max(1, Math.min(100, Math.trunc(rawLimit)));
4543
- const offset = decodeCursor(params?.cursor);
4544
- const sliced = allPrompts.slice(offset, offset + limit);
4545
- const nextOffset = offset + sliced.length;
4546
- return {
4547
- prompts: sliced,
4548
- nextCursor: nextOffset < allPrompts.length ? encodeCursor(nextOffset) : void 0
4549
- };
4550
- }
4551
- async function getPrompt(name, args = {}, db, session) {
4552
- const prompt = PROMPTS[name];
4553
- if (!prompt) {
4554
- throw new Error(`Prompt not found: ${name}`);
4555
- }
4556
- const inferredRepo = inferRepoFromSession(session);
4557
- const messages = prompt.messages.map((m) => {
4558
- let text = m.content.text;
4559
- for (const [key, value] of Object.entries(args)) {
4560
- text = text.replace(new RegExp(`\\{{${key}\\}}`, "g"), value);
4522
+ },
4523
+ {
4524
+ name: "standard-search",
4525
+ title: "Standard Search",
4526
+ description: "Navigation and lookup layer for coding standards. Query by text, stack, language, version, repo, and global scope before applying or creating standards.",
4527
+ annotations: {
4528
+ readOnlyHint: true,
4529
+ idempotentHint: true,
4530
+ openWorldHint: false
4531
+ },
4532
+ inputSchema: {
4533
+ type: "object",
4534
+ properties: {
4535
+ query: { type: "string", description: "Search query (optional, searches title/content)" },
4536
+ stack: {
4537
+ type: "array",
4538
+ items: { type: "string" },
4539
+ description: "Technology stack to filter by (e.g., ['react', 'nextjs'])"
4540
+ },
4541
+ language: { type: "string", description: "Programming language filter" },
4542
+ version: { type: "string", description: "Version filter" },
4543
+ repo: { type: "string", description: "Repository filter (optional)" },
4544
+ is_global: { type: "boolean", description: "Filter by global/repo-specific" },
4545
+ limit: { type: "number", minimum: 1, maximum: 100, default: 20 },
4546
+ offset: { type: "number", minimum: 0, default: 0 },
4547
+ structured: { type: "boolean", default: false }
4548
+ },
4549
+ required: []
4550
+ },
4551
+ outputSchema: {
4552
+ type: "object",
4553
+ properties: {
4554
+ success: { type: "boolean" },
4555
+ standards: {
4556
+ type: "array",
4557
+ items: {
4558
+ type: "object",
4559
+ properties: {
4560
+ id: { type: "string" },
4561
+ title: { type: "string" },
4562
+ content: { type: "string" },
4563
+ context: { type: "string" },
4564
+ version: { type: "string" },
4565
+ language: { type: "string", nullable: true },
4566
+ stack: { type: "array", items: { type: "string" } },
4567
+ is_global: { type: "boolean" },
4568
+ repo: { type: "string", nullable: true },
4569
+ tags: { type: "array", items: { type: "string" } },
4570
+ metadata: { type: "object" },
4571
+ created_at: { type: "string" },
4572
+ updated_at: { type: "string" },
4573
+ agent: { type: "string" },
4574
+ model: { type: "string" }
4575
+ }
4576
+ },
4577
+ description: "Matching coding standards"
4578
+ },
4579
+ count: { type: "number", description: "Number of results returned" },
4580
+ message: { type: "string" }
4581
+ },
4582
+ required: ["success", "standards", "count", "message"]
4561
4583
  }
4562
- text = text.replace(/{{current_repo}}/g, inferredRepo || "unknown-repo");
4563
- return {
4564
- ...m,
4565
- content: {
4566
- ...m.content,
4567
- text
4568
- }
4569
- };
4570
- });
4571
- return {
4572
- description: prompt.description,
4573
- messages,
4574
- metadata: prompt.agent ? { agent: prompt.agent } : void 0
4575
- };
4576
- }
4577
- async function completePromptArgument(name, argName, value, contextArguments, dataSources) {
4578
- void name;
4579
- void contextArguments;
4580
- if (argName === "task_id") {
4581
- const values = dataSources.tasks.map((t) => t.id);
4582
- return rankCompletionValues(values, value);
4583
4584
  }
4584
- return [];
4585
- }
4585
+ ];
4586
4586
 
4587
4587
  export {
4588
- MCP_PROTOCOL_VERSION,
4589
- CAPABILITIES,
4590
4588
  logger,
4591
4589
  setLogLevel,
4592
4590
  getLogLevel,
4593
4591
  addLogSink,
4594
4592
  LOG_LEVEL_VALUES,
4595
4593
  createFileSink,
4594
+ encodeCursor,
4595
+ decodeCursor,
4596
+ listResources,
4597
+ listResourceTemplates,
4598
+ completeResourceArgument,
4599
+ readResource,
4600
+ createSessionContext,
4601
+ updateSessionFromInitialize,
4602
+ updateSessionRoots,
4603
+ extractRootsFromResult,
4604
+ getFilesystemRoots,
4605
+ isPathWithinRoots,
4606
+ findContainingRoot,
4607
+ inferRepoFromSession,
4608
+ PROMPTS,
4609
+ listPrompts,
4610
+ getPrompt,
4611
+ completePromptArgument,
4596
4612
  normalizeRepo,
4597
- SQLiteStore,
4598
4613
  MemoryStoreSchema,
4599
4614
  MemoryUpdateSchema,
4600
4615
  MemorySearchSchema,
@@ -4616,22 +4631,7 @@ export {
4616
4631
  StandardStoreSchema,
4617
4632
  StandardSearchSchema,
4618
4633
  TOOL_DEFINITIONS,
4619
- encodeCursor,
4620
- decodeCursor,
4621
- listResources,
4622
- listResourceTemplates,
4623
- completeResourceArgument,
4624
- readResource,
4625
- createSessionContext,
4626
- updateSessionFromInitialize,
4627
- updateSessionRoots,
4628
- extractRootsFromResult,
4629
- getFilesystemRoots,
4630
- isPathWithinRoots,
4631
- findContainingRoot,
4632
- inferRepoFromSession,
4633
- PROMPTS,
4634
- listPrompts,
4635
- getPrompt,
4636
- completePromptArgument
4634
+ SQLiteStore,
4635
+ MCP_PROTOCOL_VERSION,
4636
+ CAPABILITIES
4637
4637
  };