kontexta 4.6.4 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/bundle/standalone/CHANGELOG.md +15 -0
  2. package/bundle/standalone/apps/web/.next/BUILD_ID +1 -1
  3. package/bundle/standalone/apps/web/.next/app-build-manifest.json +50 -50
  4. package/bundle/standalone/apps/web/.next/app-path-routes-manifest.json +13 -13
  5. package/bundle/standalone/apps/web/.next/build-manifest.json +2 -2
  6. package/bundle/standalone/apps/web/.next/prerender-manifest.json +13 -13
  7. package/bundle/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/bundle/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  9. package/bundle/standalone/apps/web/.next/server/app/_not-found.rsc +1 -1
  10. package/bundle/standalone/apps/web/.next/server/app/api/about/route_client-reference-manifest.js +1 -1
  11. package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  12. package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  13. package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route_client-reference-manifest.js +1 -1
  14. package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  15. package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route_client-reference-manifest.js +1 -1
  16. package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route_client-reference-manifest.js +1 -1
  17. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route_client-reference-manifest.js +1 -1
  18. package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route_client-reference-manifest.js +1 -1
  19. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route_client-reference-manifest.js +1 -1
  20. package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route_client-reference-manifest.js +1 -1
  21. package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route_client-reference-manifest.js +1 -1
  22. package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route_client-reference-manifest.js +1 -1
  23. package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route_client-reference-manifest.js +1 -1
  24. package/bundle/standalone/apps/web/.next/server/app/api/clip/route_client-reference-manifest.js +1 -1
  25. package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route_client-reference-manifest.js +1 -1
  26. package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route_client-reference-manifest.js +1 -1
  27. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route_client-reference-manifest.js +1 -1
  28. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route_client-reference-manifest.js +1 -1
  29. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route_client-reference-manifest.js +1 -1
  30. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route_client-reference-manifest.js +1 -1
  31. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route_client-reference-manifest.js +1 -1
  32. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route_client-reference-manifest.js +1 -1
  33. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route_client-reference-manifest.js +1 -1
  34. package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route_client-reference-manifest.js +1 -1
  35. package/bundle/standalone/apps/web/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
  36. package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route_client-reference-manifest.js +1 -1
  37. package/bundle/standalone/apps/web/.next/server/app/api/folders/route_client-reference-manifest.js +1 -1
  38. package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route_client-reference-manifest.js +1 -1
  39. package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route_client-reference-manifest.js +1 -1
  40. package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route_client-reference-manifest.js +1 -1
  41. package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route_client-reference-manifest.js +1 -1
  42. package/bundle/standalone/apps/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
  43. package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js +1 -1
  44. package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route_client-reference-manifest.js +1 -1
  45. package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js +1 -1
  46. package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route_client-reference-manifest.js +1 -1
  47. package/bundle/standalone/apps/web/.next/server/app/api/profile/route_client-reference-manifest.js +1 -1
  48. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route_client-reference-manifest.js +1 -1
  49. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route_client-reference-manifest.js +1 -1
  50. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route_client-reference-manifest.js +1 -1
  51. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route_client-reference-manifest.js +1 -1
  52. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route_client-reference-manifest.js +1 -1
  53. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
  54. package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route_client-reference-manifest.js +1 -1
  55. package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route_client-reference-manifest.js +1 -1
  56. package/bundle/standalone/apps/web/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
  57. package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route_client-reference-manifest.js +1 -1
  58. package/bundle/standalone/apps/web/.next/server/app/api/publish/route_client-reference-manifest.js +1 -1
  59. package/bundle/standalone/apps/web/.next/server/app/api/refresh/route_client-reference-manifest.js +1 -1
  60. package/bundle/standalone/apps/web/.next/server/app/api/reindex/route_client-reference-manifest.js +1 -1
  61. package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route_client-reference-manifest.js +1 -1
  62. package/bundle/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
  63. package/bundle/standalone/apps/web/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
  64. package/bundle/standalone/apps/web/.next/server/app/api/version-check/route_client-reference-manifest.js +1 -1
  65. package/bundle/standalone/apps/web/.next/server/app/api/welcome/route_client-reference-manifest.js +1 -1
  66. package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route_client-reference-manifest.js +1 -1
  67. package/bundle/standalone/apps/web/.next/server/app/calendar/page_client-reference-manifest.js +1 -1
  68. package/bundle/standalone/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
  69. package/bundle/standalone/apps/web/.next/server/app/page.js +2 -2
  70. package/bundle/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  71. package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page_client-reference-manifest.js +1 -1
  72. package/bundle/standalone/apps/web/.next/server/app/preview/motifs.html +2 -2
  73. package/bundle/standalone/apps/web/.next/server/app/preview/motifs.rsc +1 -1
  74. package/bundle/standalone/apps/web/.next/server/app-paths-manifest.json +13 -13
  75. package/bundle/standalone/apps/web/.next/server/pages/404.html +1 -1
  76. package/bundle/standalone/apps/web/.next/server/pages/500.html +1 -1
  77. package/bundle/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  78. package/bundle/standalone/apps/web/.next/static/chunks/app/{page-13de59eac88531ec.js → page-eccc7438c998fcce.js} +1 -1
  79. package/bundle/standalone/apps/web/package.json +4 -4
  80. package/bundle/standalone/apps/web/src/lib/mcp-tools.json +104 -103
  81. package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-block.md +90 -90
  82. package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js +12 -12
  83. package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js.map +1 -1
  84. package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js +63 -63
  85. package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js.map +1 -1
  86. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-commit-upgrades-tool.js +1 -1
  87. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-commit-upgrades-tool.js.map +1 -1
  88. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-housekeep-tool.js +1 -1
  89. package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-tools.js +4 -4
  90. package/bundle/standalone/node_modules/kontexta-mcp/package.json +1 -1
  91. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js +3 -3
  92. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js.map +1 -1
  93. package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-block.md +90 -90
  94. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/exploration.d.ts.map +1 -1
  95. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/exploration.js +8 -1
  96. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/exploration.js.map +1 -1
  97. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/read-only-investigation.d.ts.map +1 -1
  98. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/read-only-investigation.js +6 -0
  99. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/read-only-investigation.js.map +1 -1
  100. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js +2 -2
  101. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js.map +1 -1
  102. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.d.ts.map +1 -1
  103. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js +8 -2
  104. package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js.map +1 -1
  105. package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.d.ts.map +1 -1
  106. package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.js +10 -2
  107. package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.js.map +1 -1
  108. package/bundle/standalone/node_modules/kxta-core/dist/project-map/index.js +1 -1
  109. package/bundle/standalone/node_modules/kxta-core/package.json +1 -1
  110. package/bundle/standalone/node_modules/kxta-publish/package.json +2 -2
  111. package/bundle/standalone/package.json +1 -1
  112. package/package.json +1 -1
  113. /package/bundle/standalone/apps/web/.next/static/{MXXlMwjGdgGdSqB6SehZ3 → DWDlM7S8dTnMlrhKW9K_X}/_buildManifest.js +0 -0
  114. /package/bundle/standalone/apps/web/.next/static/{MXXlMwjGdgGdSqB6SehZ3 → DWDlM7S8dTnMlrhKW9K_X}/_ssgManifest.js +0 -0
@@ -240,7 +240,7 @@ function loadProfileInstructions() {
240
240
  return [header, "", profileBlock, "", calendarBlock, freshness].filter(Boolean).join("\n");
241
241
  }
242
242
  const server = new McpServer({ name: "kontexta", version: pkgVersion }, { instructions: loadProfileInstructions() });
243
- server.tool("refresh_session_context", "Re-read the session context (profile, upcoming events within 7d, conflicts, freshness nudge) as it stands NOW. Call this when the user just edited their profile or added/moved calendar events and you want the current picture instead of the snapshot taken at session start. Read-only; no side effects. Returns the same block Kontexta sent as MCP instructions at session start.", {}, async () => ({
243
+ server.tool("admin.refresh_session_context", "Re-read the session context (profile, upcoming events within 7d, conflicts, freshness nudge) as it stands NOW. Call this when the user just edited their profile or added/moved calendar events and you want the current picture instead of the snapshot taken at session start. Read-only; no side effects. Returns the same block Kontexta sent as MCP instructions at session start.", {}, async () => ({
244
244
  content: [{ type: "text", text: loadProfileInstructions() ?? "(no session context available)" }],
245
245
  }));
246
246
  const handsRegistry = new HandsRegistry(server);
@@ -298,7 +298,7 @@ process.on("SIGTERM", () => { if (!_shutdownInFlight) {
298
298
  // because it will be removed in Task 15. Auto-wrap covers all current and future tools.
299
299
  const _origServerTool = server.tool.bind(server);
300
300
  server.tool = function (name, ...rest) {
301
- if (name === "journal_append") {
301
+ if (name === "journal.append") {
302
302
  return _origServerTool(name, ...rest);
303
303
  }
304
304
  const handler = rest[rest.length - 1];
@@ -309,7 +309,7 @@ server.tool = function (name, ...rest) {
309
309
  };
310
310
  // Legacy journal_append tool — excluded from wrapHandler (line 223) so it
311
311
  // does NOT get the journal-backlog envelope injected. Kept for backward-compat.
312
- server.tool("journal_append", "Append a timestamped text entry to today's daily journal file in the Knowledge Base. Creates the file if it doesn't already exist. Both calls on the same calendar day return the same file_id. Returns { file_id }.", {
312
+ server.tool("journal.append", "Append a timestamped text entry to today's daily journal file in the Knowledge Base. Creates the file if it doesn't already exist. Both calls on the same calendar day return the same file_id. Returns { file_id }.", {
313
313
  text: z.string().describe("Text to append to today's journal entry"),
314
314
  project_id: z.number().optional().describe("Optional project ID context"),
315
315
  }, async ({ text }) => {
@@ -357,7 +357,7 @@ server.tool("journal_append", "Append a timestamped text entry to today's daily
357
357
  };
358
358
  }
359
359
  });
360
- server.tool("create_file", "Create a new markdown, mermaid, or HTML file in the knowledge base or project. This operation writes a new file to disk and adds it to the local SQLite FTS5 index. Destination can be 'knowledge' (global KB), 'project' (reference file inside a project repo), or 'kontexta' (internal Kontexta schema file). If destination is 'project' or 'kontexta', project_id is strictly required. If destination is 'knowledge', 'kind' is strictly required — pick 'dictionary' (authoritative source-of-truth) or 'note' (informational snapshot); see the kind param for the rubric. No external auth required. Rate limits do not apply (local operation). Returns the created file metadata including its new ID, path, and estimated tokens. If the destination directory does not exist, it will be created automatically. Use this tool to instantiate new contextual documents or notes. To modify an existing file, use 'update_file' instead. Parameters: 'destination' dictates required fields; if 'project' or 'kontexta', 'project_id' must be a valid integer; if 'knowledge', 'kind' must be 'dictionary' or 'note'. 'tags' and 'folder' are optional. Pass format='mmd' to create a Mermaid diagram file (.mmd) or format='html' for HTML reports; defaults to 'md'.", {
360
+ server.tool("files.create", "Create a new markdown, mermaid, or HTML file in the knowledge base or project. This operation writes a new file to disk and adds it to the local SQLite FTS5 index. Destination can be 'knowledge' (global KB), 'project' (reference file inside a project repo), or 'kontexta' (internal Kontexta schema file). If destination is 'project' or 'kontexta', project_id is strictly required. If destination is 'knowledge', 'kind' is strictly required — pick 'dictionary' (authoritative source-of-truth) or 'note' (informational snapshot); see the kind param for the rubric. No external auth required. Rate limits do not apply (local operation). Returns the created file metadata including its new ID, path, and estimated tokens. If the destination directory does not exist, it will be created automatically. Use this tool to instantiate new contextual documents or notes. To modify an existing file, use 'files.update' instead. Parameters: 'destination' dictates required fields; if 'project' or 'kontexta', 'project_id' must be a valid integer; if 'knowledge', 'kind' must be 'dictionary' or 'note'. 'tags' and 'folder' are optional. Pass format='mmd' to create a Mermaid diagram file (.mmd) or format='html' for HTML reports; defaults to 'md'.", {
361
361
  title: z.string().describe("Title of the file"),
362
362
  content: z.string().describe("Content of the file"),
363
363
  destination: z.enum(["knowledge", "project", "kontexta"]).describe("Destination type"),
@@ -389,22 +389,22 @@ server.tool("create_file", "Create a new markdown, mermaid, or HTML file in the
389
389
  content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
390
390
  };
391
391
  });
392
- server.tool("add_report_resource", "Write an image or other binary resource into the shared reports/resources/ folder. Returns { filename, size, src, url } — embed the report's <img>/<a> tags with `src` exactly as given (e.g. `<img src=\"resources/chart.png\">`); it is the only form that resolves correctly both in the dashboard viewer and in PDF/PNG export. Do not use `url` inside report HTML — it only works in the dashboard. Bytes are passed base64-encoded.", {
392
+ server.tool("resources.add_report", "Write an image or other binary resource into the shared reports/resources/ folder. Returns { filename, size, src, url } — embed the report's <img>/<a> tags with `src` exactly as given (e.g. `<img src=\"resources/chart.png\">`); it is the only form that resolves correctly both in the dashboard viewer and in PDF/PNG export. Do not use `url` inside report HTML — it only works in the dashboard. Bytes are passed base64-encoded.", {
393
393
  filename: z.string().describe("Requested filename with extension"),
394
394
  bytes_base64: z.string().describe("Base64-encoded file bytes"),
395
395
  }, async ({ filename, bytes_base64 }) => {
396
396
  const info = writeResource(dataDir, filename, Buffer.from(bytes_base64, "base64"));
397
397
  return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
398
398
  });
399
- server.tool("list_report_resources", "List all files currently stored under reports/resources/. Returns filename, size in bytes, and served URL.", {}, async () => {
399
+ server.tool("resources.list_reports", "List all files currently stored under reports/resources/. Returns filename, size in bytes, and served URL.", {}, async () => {
400
400
  const items = listResources(dataDir);
401
401
  return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
402
402
  });
403
- server.tool("delete_report_resource", "Delete a file from reports/resources/. No-op if it doesn't exist.", { filename: z.string().describe("Filename (relative) of the resource to delete from reports/resources/.") }, async ({ filename }) => {
403
+ server.tool("resources.delete_report", "Delete a file from reports/resources/. No-op if it doesn't exist.", { filename: z.string().describe("Filename (relative) of the resource to delete from reports/resources/.") }, async ({ filename }) => {
404
404
  deleteResource(dataDir, filename);
405
405
  return { content: [{ type: "text", text: JSON.stringify({ ok: true, filename }, null, 2) }] };
406
406
  });
407
- server.tool("export_report", "Export an existing HTML report as PDF or PNG. Returns { url } for the web-served download (requires an authenticated dashboard request) by default. Set inline_bytes=true to render in-process and get { bytes_base64 } instead — only available when running via the full `kontexta` CLI, not the standalone kontexta-mcp package; falls back to { url } with a note if unavailable.", {
407
+ server.tool("resources.export_report", "Export an existing HTML report as PDF or PNG. Returns { url } for the web-served download (requires an authenticated dashboard request) by default. Set inline_bytes=true to render in-process and get { bytes_base64 } instead — only available when running via the full `kontexta` CLI, not the standalone kontexta-mcp package; falls back to { url } with a note if unavailable.", {
408
408
  id: z.number().describe("File ID of the HTML report to export."),
409
409
  format: z.enum(["pdf", "png"]).default("pdf").describe("Output format: 'pdf' or 'png'."),
410
410
  inline_bytes: z.boolean().optional().default(false).describe("If true, render in-process and return raw bytes (base64). Only available in the full kontexta CLI bundle; falls back to {url} otherwise."),
@@ -427,7 +427,7 @@ server.tool("export_report", "Export an existing HTML report as PDF or PNG. Retu
427
427
  return { content: [{ type: "text", text: JSON.stringify({ url, note: `inline_bytes unavailable in this install: ${e?.message ?? String(e)}` }, null, 2) }] };
428
428
  }
429
429
  });
430
- server.tool("read_file", "Read one file's full body and metadata by ID. Read-only; no side effects, auth, or rate limits. Returns title, path, content, tags, est_tokens (so you can budget context before opening more files), and timestamps. Throws if the ID is unknown. Use for a single known file. Prefer `describe_file` to inspect without paying body tokens; `read_files` for batches; `read_file_lines`/`read_section` for partial reads; `read_file_by_path` when you only have the absolute path.", {
430
+ server.tool("files.read", "Read one file's full body and metadata by ID. Read-only; no side effects, auth, or rate limits. Returns title, path, content, tags, est_tokens (so you can budget context before opening more files), and timestamps. Throws if the ID is unknown. Use for a single known file. Prefer `files.describe` to inspect without paying body tokens; `files.read_many` for batches; `files.read_lines`/`files.read_section` for partial reads; `files.read_by_path` when you only have the absolute path.", {
431
431
  id: z.number().describe("File ID"),
432
432
  }, async ({ id }) => {
433
433
  const result = readFile(id);
@@ -435,7 +435,7 @@ server.tool("read_file", "Read one file's full body and metadata by ID. Read-onl
435
435
  content: [{ type: "text", text: JSON.stringify(annotateTokens(result), null, 2) }],
436
436
  };
437
437
  });
438
- server.tool("read_files", "Batch read up to 200 files by ID in one call. Returns per-file annotated records, an aggregate `total_est_tokens`, and an isolated `errors[]` (one bad ID does NOT abort the batch). Read-only; no side effects, auth, or rate limits. Use instead of looping `read_file` to halve round-trips and get the combined token cost upfront. For >200 IDs, page yourself.", {
438
+ server.tool("files.read_many", "Batch read up to 200 files by ID in one call. Returns per-file annotated records, an aggregate `total_est_tokens`, and an isolated `errors[]` (one bad ID does NOT abort the batch). Read-only; no side effects, auth, or rate limits. Use instead of looping `files.read` to halve round-trips and get the combined token cost upfront. For >200 IDs, page yourself.", {
439
439
  ids: z.array(z.number()).min(1).max(200).describe("File IDs to read (max 200 per call)"),
440
440
  }, async ({ ids }) => {
441
441
  const files = [];
@@ -455,7 +455,7 @@ server.tool("read_files", "Batch read up to 200 files by ID in one call. Returns
455
455
  content: [{ type: "text", text: JSON.stringify({ files, total_est_tokens, error_count: errors.length, errors }, null, 2) }],
456
456
  };
457
457
  });
458
- server.tool("describe_file", "Return everything ABOUT a file without pulling its content (no token cost from the body). Tags, size, est_tokens, history depth, related-file ids, backlinks, project, folder, last edited. Operates locally with no auth or rate limits. Use this when you'd otherwise chain read_file + list_tags + get_history + find_related just to decide whether to actually read the file. Parameters: 'id' must be a valid integer file ID.", {
458
+ server.tool("files.describe", "Return everything ABOUT a file without pulling its content (no token cost from the body). Tags, size, est_tokens, history depth, related-file ids, backlinks, project, folder, last edited. Operates locally with no auth or rate limits. Use this when you'd otherwise chain files.read + tags.list + files.get_history + files.find_related just to decide whether to actually read the file. Parameters: 'id' must be a valid integer file ID.", {
459
459
  id: z.number().describe("File ID"),
460
460
  }, async ({ id }) => {
461
461
  try {
@@ -575,7 +575,7 @@ server.tool("describe_file", "Return everything ABOUT a file without pulling its
575
575
  };
576
576
  }
577
577
  });
578
- server.tool("read_file_lines", "Return a 1-indexed inclusive line slice of a file. Out-of-range bounds clamp silently to the file's actual length; `to < from` throws. Read-only; no side effects, auth, or rate limits. Returns the snippet plus its size_bytes and est_tokens. Use to inspect a stack-trace region or a chunk of a large file without pulling the whole body. Prefer `read_section` if you know the heading, `grep_in_file` if you know a pattern but not the line number.", {
578
+ server.tool("files.read_lines", "Return a 1-indexed inclusive line slice of a file. Out-of-range bounds clamp silently to the file's actual length; `to < from` throws. Read-only; no side effects, auth, or rate limits. Returns the snippet plus its size_bytes and est_tokens. Use to inspect a stack-trace region or a chunk of a large file without pulling the whole body. Prefer `read_section` if you know the heading, `grep_in_file` if you know a pattern but not the line number.", {
579
579
  id: z.number().describe("File ID"),
580
580
  from: z.number().int().positive().describe("First line (1-indexed, inclusive)"),
581
581
  to: z.number().int().positive().describe("Last line (1-indexed, inclusive)"),
@@ -613,7 +613,7 @@ server.tool("read_file_lines", "Return a 1-indexed inclusive line slice of a fil
613
613
  };
614
614
  }
615
615
  });
616
- server.tool("grep_in_file", "Match a JS regex against one file's lines and return matched lines with line numbers (capped: default 100, max 500). Catches what FTS misses: URLs, hyphenated terms, code identifiers. Read-only; no side effects, auth, or rate limits. Invalid regex throws `invalid regex`. Returns `{matches, match_count, truncated}`. Use after `read_file_outline` when you know the file but need a specific reference; for cross-file regex use `regex_search`; for keyword/concept search use `search`.", {
616
+ server.tool("files.grep", "Match a JS regex against one file's lines and return matched lines with line numbers (capped: default 100, max 500). Catches what FTS misses: URLs, hyphenated terms, code identifiers. Read-only; no side effects, auth, or rate limits. Invalid regex throws `invalid regex`. Returns `{matches, match_count, truncated}`. Use after `files.read_outline` when you know the file but need a specific reference; for cross-file regex use `files.regex_search`; for keyword/concept search use `files.search`.", {
617
617
  id: z.number().describe("File ID"),
618
618
  pattern: z.string().describe("Pattern to match. Treated as a JavaScript RegExp source."),
619
619
  case_insensitive: z.boolean().optional().describe("Add the 'i' flag (default false)"),
@@ -661,10 +661,10 @@ server.tool("grep_in_file", "Match a JS regex against one file's lines and retur
661
661
  };
662
662
  }
663
663
  });
664
- server.tool("regex_search", "Match a JS regex against the body of every file in scope (project, KB, or all) and return per-file hits with line numbers. Slower than FTS `search` because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Read-only; no side effects, auth, or rate limits. Capped at 500 files / 10 hits per file by default; the response reports `files_truncated` and per-file truncation so the agent can re-scope. `project_id: null` = KB only; omit = everywhere; `kind` narrows to one content class. Invalid regex throws.", {
664
+ server.tool("files.regex_search", "Match a JS regex against the body of every file in scope (project, KB, or all) and return per-file hits with line numbers. Slower than FTS `search` because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Read-only; no side effects, auth, or rate limits. Capped at 500 files / 10 hits per file by default; the response reports `files_truncated` and per-file truncation so the agent can re-scope. `project_id: null` = KB only; omit = everywhere; `kind` narrows to one content class. Invalid regex throws.", {
665
665
  pattern: z.string().describe("JavaScript RegExp source"),
666
666
  project_id: z.number().nullable().optional().describe("Scope to one project, null for KB-only, omit for everything"),
667
- case_insensitive: z.boolean().optional(),
667
+ case_insensitive: z.boolean().optional().describe("If true, match pattern case-insensitively (RegExp 'i' flag). Default false."),
668
668
  max_files: z.number().int().positive().max(2000).optional().describe("Cap on files scanned (default 500)"),
669
669
  max_matches_per_file: z.number().int().positive().max(100).optional().describe("Per-file hit cap (default 10)"),
670
670
  kind: z.enum(["dictionary", "note", "journal", "project"]).optional()
@@ -745,7 +745,7 @@ server.tool("regex_search", "Match a JS regex against the body of every file in
745
745
  };
746
746
  }
747
747
  });
748
- server.tool("update_file", "Update the entire content of an existing file by its ID. This replaces the file's content on disk and triggers an FTS5 re-index. Returns the updated file metadata including new estimated token counts. Operates locally with no external auth or rate limits. If you only need to modify a single section without replacing the entire file, use 'update_file_section' instead to save context budget. Parameters: 'id' must be a valid integer file ID. 'content' is the complete markdown string that will replace the file.", {
748
+ server.tool("files.update", "Update the entire content of an existing file by its ID. This replaces the file's content on disk and triggers an FTS5 re-index. Returns the updated file metadata including new estimated token counts. Operates locally with no external auth or rate limits. If you only need to modify a single section without replacing the entire file, use 'files.update_section' instead to save context budget. Parameters: 'id' must be a valid integer file ID. 'content' is the complete markdown string that will replace the file.", {
749
749
  id: z.number().describe("File ID"),
750
750
  content: z.string().describe("New content"),
751
751
  }, async ({ id, content }) => {
@@ -754,7 +754,7 @@ server.tool("update_file", "Update the entire content of an existing file by its
754
754
  content: [{ type: "text", text: JSON.stringify(annotateTokens(result), null, 2) }],
755
755
  };
756
756
  });
757
- server.tool("delete_file", "DESTRUCTIVE. Permanently delete one file by ID. KB files are unlinked from disk AND removed from the FTS5 index; project reference files only have their index entry removed (the file on disk is left alone so the watcher does not fight your editor). Not idempotent — deleting an unknown ID throws. No external auth or rate limits. Returns `{success: true}`. Use only when the file is truly obsolete; to deprioritise without losing data, untag (`remove_tags`) or unfavorite (`set_favorite`) instead. Bulk variant: `delete_files`.", {
757
+ server.tool("files.delete", "DESTRUCTIVE. Permanently delete one file by ID. KB files are unlinked from disk AND removed from the FTS5 index; project reference files only have their index entry removed (the file on disk is left alone so the watcher does not fight your editor). Not idempotent — deleting an unknown ID throws. No external auth or rate limits. Returns `{success: true}`. Use only when the file is truly obsolete; to deprioritise without losing data, untag (`tags.remove`) or unfavorite (`tags.set_favorite`) instead. Bulk variant: `files.delete_many`.", {
758
758
  id: z.number().describe("File ID"),
759
759
  }, async ({ id }) => {
760
760
  await deleteFile(id, dataDir);
@@ -762,7 +762,7 @@ server.tool("delete_file", "DESTRUCTIVE. Permanently delete one file by ID. KB f
762
762
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
763
763
  };
764
764
  });
765
- server.tool("list_files", "List file metadata with optional filters (project_id, tag, favorite, folder, untagged, kind) and pagination. Read-only; no side effects, auth, or rate limits. Each row is annotated with tags, est_tokens, size_bytes, and content_class; the response includes `total_est_tokens` so you can budget before reading bodies. `project_id: null` returns ONLY Knowledge Base files; omit the field to span everything; `kind` narrows to one content class. Use to browse known structure; for keyword/content lookup use `search`; for a denser whole-vault dump use `project_map`.", {
765
+ server.tool("files.list", "List file metadata with optional filters (project_id, tag, favorite, folder, untagged, kind) and pagination. Read-only; no side effects, auth, or rate limits. Each row is annotated with tags, est_tokens, size_bytes, and content_class; the response includes `total_est_tokens` so you can budget before reading bodies. `project_id: null` returns ONLY Knowledge Base files; omit the field to span everything; `kind` narrows to one content class. Use to browse known structure; for keyword/content lookup use `search`; for a denser whole-vault dump use `project_map`.", {
766
766
  project_id: z.number().nullable().optional().describe("Filter by project ID. Pass null to list ONLY Knowledge Base files (project_id IS NULL)."),
767
767
  tag: z.string().optional().describe("Filter by tag name"),
768
768
  favorite: z.boolean().optional().describe("Filter by favorite status"),
@@ -797,7 +797,7 @@ server.tool("list_files", "List file metadata with optional filters (project_id,
797
797
  content: [{ type: "text", text: JSON.stringify({ files: annotated, total_est_tokens }, null, 2) }],
798
798
  };
799
799
  });
800
- server.tool("search", "Full-text (SQLite FTS5) keyword search across files. Returns ranked matches with inline match_excerpt and title_highlight (no follow-up `read_file` needed for snippets) plus tags, est_tokens, size_bytes, content_class, and aggregate `total_est_tokens`. Read-only; no side effects, auth, or rate limits. Ordering: dictionary hits sort above everything else for the same query (dictionary-wins on conflict), then BM25 rank. FTS is tokenised: it WILL miss URLs, hyphenated terms, and partial substrings — fall back to `regex_search` for those. `project_id: null` searches only the KB; omit the field to span everything; `tags[]` requires ALL listed tags to match; `kind` narrows to one content class. For prompt-ready bundled bodies use `bundle_search`.", {
800
+ server.tool("files.search", "Full-text (SQLite FTS5) keyword search across files. Returns ranked matches with inline match_excerpt and title_highlight (no follow-up `read_file` needed for snippets) plus tags, est_tokens, size_bytes, content_class, and aggregate `total_est_tokens`. Read-only; no side effects, auth, or rate limits. Ordering: dictionary hits sort above everything else for the same query (dictionary-wins on conflict), then BM25 rank. FTS is tokenised: it WILL miss URLs, hyphenated terms, and partial substrings — fall back to `files.regex_search` for those. `project_id: null` searches only the KB; omit the field to span everything; `tags[]` requires ALL listed tags to match; `kind` narrows to one content class. For prompt-ready bundled bodies use `files.bundle_search`.", {
801
801
  query: z.string().describe("Search query"),
802
802
  project_id: z.number().nullable().optional().describe("Filter by project ID. Pass null to search ONLY Knowledge Base files."),
803
803
  tags: z.array(z.string()).optional().describe("Filter by tags (all must match)"),
@@ -830,7 +830,7 @@ server.tool("search", "Full-text (SQLite FTS5) keyword search across files. Retu
830
830
  content: [{ type: "text", text: JSON.stringify({ matches: annotated, total_est_tokens }, null, 2) }],
831
831
  };
832
832
  });
833
- server.tool("bundle_search", "Run an FTS search and concatenate matched bodies into a single prompt-ready bundle (XML `<document>` blocks or markdown headers + fences) capped at `max_tokens`. Files are added in rank order (dictionary-wins first, then BM25) until the next would exceed the budget; the rest go to `skipped[]`. Read-only; no side effects, auth, or rate limits. Use instead of `search` + N×`read_file` when you need several related files as one context blob. Defaults: format=xml, max_tokens=50000. `project_id: null` = KB only; `tags[]` requires ALL to match; `kind` narrows to one content class.", {
833
+ server.tool("files.bundle_search", "Run an FTS search and concatenate matched bodies into a single prompt-ready bundle (XML `<document>` blocks or markdown headers + fences) capped at `max_tokens`. Files are added in rank order (dictionary-wins first, then BM25) until the next would exceed the budget; the rest go to `skipped[]`. Read-only; no side effects, auth, or rate limits. Use instead of `files.search` + N×`files.read` when you need several related files as one context blob. Defaults: format=xml, max_tokens=50000. `project_id: null` = KB only; `tags[]` requires ALL to match; `kind` narrows to one content class.", {
834
834
  query: z.string().describe("Full-text search query"),
835
835
  project_id: z.number().nullable().optional().describe("Filter by project ID. Pass null to bundle ONLY Knowledge Base files."),
836
836
  tags: z.array(z.string()).optional().describe("Filter by tags (all must match)"),
@@ -865,7 +865,7 @@ server.tool("bundle_search", "Run an FTS search and concatenate matched bodies i
865
865
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
866
866
  };
867
867
  });
868
- server.tool("add_tags", "Append tags to ONE file. Additive — existing tags are preserved; re-adding an existing tag is a no-op (idempotent per tag). New tag names auto-create rows in the global `tags` table. Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`; throws if file_id is unknown. Use to label a single file. To tag every file matching a query in one call use `tag_search_results`; to remove tags use `remove_tags`.", {
868
+ server.tool("tags.add", "Append tags to ONE file. Additive — existing tags are preserved; re-adding an existing tag is a no-op (idempotent per tag). New tag names auto-create rows in the global `tags` table. Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`; throws if file_id is unknown. Use to label a single file. To tag every file matching a query in one call use `tag_search_results`; to remove tags use `remove_tags`.", {
869
869
  file_id: z.number().describe("File ID"),
870
870
  tags: z.array(z.string()).describe("Array of tag names to add"),
871
871
  }, async ({ file_id, tags }) => {
@@ -874,7 +874,7 @@ server.tool("add_tags", "Append tags to ONE file. Additive — existing tags are
874
874
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
875
875
  };
876
876
  });
877
- server.tool("remove_tags", "Detach one or more tag IDs from ONE file. Destructive on the link only — does NOT delete the file or the global tag definition (orphan tags survive in `list_tags`). Idempotent: removing an already-absent tag is a no-op. No external auth or rate limits. Returns `{success: true}`. Note: takes tag IDs (integers), not names — fetch them via `list_tags`. To remove ALL tags from many files via a query, see `tag_search_results` (additive only) — there is no bulk-untag-by-query tool.", {
877
+ server.tool("tags.remove", "Detach one or more tag IDs from ONE file. Destructive on the link only — does NOT delete the file or the global tag definition (orphan tags survive in `list_tags`). Idempotent: removing an already-absent tag is a no-op. No external auth or rate limits. Returns `{success: true}`. Note: takes tag IDs (integers), not names — fetch them via `list_tags`. To remove ALL tags from many files via a query, see `tag_search_results` (additive only) — there is no bulk-untag-by-query tool.", {
878
878
  file_id: z.number().describe("File ID"),
879
879
  tag_ids: z.array(z.number()).describe("Array of tag IDs to remove"),
880
880
  }, async ({ file_id, tag_ids }) => {
@@ -883,7 +883,7 @@ server.tool("remove_tags", "Detach one or more tag IDs from ONE file. Destructiv
883
883
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
884
884
  };
885
885
  });
886
- server.tool("set_favorite", "Set or clear the favorite flag on one file (idempotent — re-setting the same value is a no-op; not a toggle, you pass the desired state). Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`. Use to curate quick-access pins; `list_files`/`search`/`bundle_search` accept `favorite: true` to filter to the pinned set.", {
886
+ server.tool("tags.set_favorite", "Set or clear the favorite flag on one file (idempotent — re-setting the same value is a no-op; not a toggle, you pass the desired state). Persists to local SQLite. No external auth or rate limits. Returns `{success: true}`. Use to curate quick-access pins; `list_files`/`search`/`bundle_search` accept `favorite: true` to filter to the pinned set.", {
887
887
  file_id: z.number().describe("File ID"),
888
888
  favorite: z.boolean().describe("Favorite status"),
889
889
  }, async ({ file_id, favorite }) => {
@@ -892,13 +892,13 @@ server.tool("set_favorite", "Set or clear the favorite flag on one file (idempot
892
892
  content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }],
893
893
  };
894
894
  });
895
- server.tool("list_tags", "List every tag in the global SQLite database with id, name, and applied count. Read-only; no side effects, auth, or rate limits. Returns the entire taxonomy (not paginated). Use to discover existing labels before tagging (so you reuse rather than fork) or to find tag IDs to feed into `remove_tags`. For tags on a specific file, use `describe_file`.", {}, async () => {
895
+ server.tool("tags.list", "List every tag in the global SQLite database with id, name, and applied count. Read-only; no side effects, auth, or rate limits. Returns the entire taxonomy (not paginated). Use to discover existing labels before tagging (so you reuse rather than fork) or to find tag IDs to feed into `remove_tags`. For tags on a specific file, use `describe_file`.", {}, async () => {
896
896
  const result = listTags();
897
897
  return {
898
898
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
899
899
  };
900
900
  });
901
- server.tool("list_projects", "List every registered project with id, name, absolute path, and a derived `has_hands` flag (true when the path exists on disk AND contains a `kontexta.json`). Read-only; no side effects, auth, or rate limits. Use to find the project_id to pass to scoped tools (`search`, `list_files`, `commit_backup`, `refresh_index`, etc.). To register a new project use `register_project`; to inspect its Hands tools use `list_hands`.", {}, async () => {
901
+ server.tool("projects.list", "List every registered project with id, name, absolute path, and a derived `has_hands` flag (true when the path exists on disk AND contains a `kontexta.json`). Read-only; no side effects, auth, or rate limits. Use to find the project_id to pass to scoped tools (`search`, `list_files`, `commit_backup`, `refresh_index`, etc.). To register a new project use `register_project`; to inspect its Hands tools use `list_hands`.", {}, async () => {
902
902
  const result = listProjects();
903
903
  const augmented = result.map((p) => {
904
904
  const has_hands = !!(p.path && existsSync(p.path) && existsSync(`${p.path}/kontexta.json`));
@@ -918,7 +918,7 @@ server.tool("list_projects", "List every registered project with id, name, absol
918
918
  content: [{ type: "text", text: JSON.stringify(augmented, null, 2) }],
919
919
  };
920
920
  });
921
- server.tool("register_project", `Register a new project and link it to the Kontexta knowledge system.
921
+ server.tool("projects.register", `Register a new project and link it to the Kontexta knowledge system.
922
922
 
923
923
  SIDE EFFECTS: Writes project metadata to disk (persisted in the Kontexta data directory). Scans the project root recursively to discover and index all markdown files into the local database. Registers any kontexta.json-declared Hands tools found in the project root. This operation is idempotent — re-registering an existing project updates its metadata without data loss.
924
924
 
@@ -982,7 +982,7 @@ ERROR CONDITIONS: Returns isError=true if path is missing or unresolvable. Scan
982
982
  recommendationReason =
983
983
  `Your project's agent instructions file is out of date — it still references kontexta workflow rules from an older release. ` +
984
984
  `Files needing an update: ${versions}. Latest rules version is v${RULE_BLOCK_VERSION}. ` +
985
- `Run onboard_agent to refresh the kontexta rules block in-place (your existing project content is preserved).`;
985
+ `Run admin.onboard_agent to refresh the kontexta rules block in-place (your existing project content is preserved).`;
986
986
  }
987
987
  else {
988
988
  recommendationReason =
@@ -994,27 +994,27 @@ ERROR CONDITIONS: Returns isError=true if path is missing or unresolvable. Scan
994
994
  `No AI agent instructions file (e.g. CLAUDE.md, AGENTS.md, GEMINI.md, ANTIGRAVITY.md, .cursor/rules, .continue/rules, .aider/kontexta.md) was found in this project. ` +
995
995
  `These files are how coding agents (Claude Code, Codex, Cursor, Gemini, Aider, etc.) load project-specific context at the start of every session. ` +
996
996
  `Without one, your agent won't know this project is registered with kontexta and will skip the search/read/journal workflow — wasting tokens re-reading files it could have looked up. ` +
997
- `Run onboard_agent with target_agent set to your coding tool to scaffold the right file (CLAUDE.md for Claude Code, .aider/kontexta.md for Aider, etc.) pre-populated with kontexta workflow rules.`;
997
+ `Run admin.onboard_agent with target_agent set to your coding tool to scaffold the right file (CLAUDE.md for Claude Code, .aider/kontexta.md for Aider, etc.) pre-populated with kontexta workflow rules.`;
998
998
  }
999
999
  const needsOnboarding = outdated.length > 0 || detected.length === 0;
1000
1000
  const recommendation = detected.length > 0
1001
1001
  ? {
1002
- kind: "onboard_agent",
1002
+ kind: "admin.onboard_agent",
1003
1003
  mode: "update",
1004
1004
  reason: recommendationReason,
1005
1005
  target_files: detected,
1006
- next_tool: "onboard_agent",
1006
+ next_tool: "admin.onboard_agent",
1007
1007
  next_args: { project_id: project.id },
1008
1008
  prompt: outdated.length > 0
1009
1009
  ? `Update the kontexta rules block in ${detected.join(", ")} to v${RULE_BLOCK_VERSION} now? (Your existing project-specific content above/below the rules block will be left untouched.)`
1010
1010
  : null,
1011
1011
  }
1012
1012
  : {
1013
- kind: "onboard_agent",
1013
+ kind: "admin.onboard_agent",
1014
1014
  mode: "create",
1015
1015
  reason: recommendationReason,
1016
1016
  target_files: [],
1017
- next_tool: "onboard_agent",
1017
+ next_tool: "admin.onboard_agent",
1018
1018
  next_args: {
1019
1019
  project_id: project.id,
1020
1020
  target_agent: "<pass your agent: claude-code | codex | gemini | antigravity | cursor | continue | aider | cline | copilot>",
@@ -1051,7 +1051,7 @@ ERROR CONDITIONS: Returns isError=true if path is missing or unresolvable. Scan
1051
1051
  };
1052
1052
  }
1053
1053
  });
1054
- server.tool("onboard_agent", `Write or update the kontexta workflow rules block in a project's agent context file(s). Idempotent — uses fenced markers + version to skip no-op writes.
1054
+ server.tool("admin.onboard_agent", `Write or update the kontexta workflow rules block in a project's agent context file(s). Idempotent — uses fenced markers + version to skip no-op writes.
1055
1055
 
1056
1056
  MANDATORY: This tool modifies project configuration files. You MUST seek explicit user consent before calling this tool. Set 'confirm: true' only after the user has agreed.
1057
1057
 
@@ -1115,7 +1115,7 @@ RETURNS: { written: [{ path, action: created|updated|skipped, version }], skippe
1115
1115
  };
1116
1116
  }
1117
1117
  });
1118
- server.tool("transfer_agent_context", `COPY existing agent context files (CLAUDE.md, AGENTS.md, .cursor/rules/*.mdc, etc.) from a project's repo into Kontexta's per-project knowledge base so they're indexed by FTS5 and can be git-synced through Kontexta's own backup engine.
1118
+ server.tool("admin.transfer_agent_context", `COPY existing agent context files (CLAUDE.md, AGENTS.md, .cursor/rules/*.mdc, etc.) from a project's repo into Kontexta's per-project knowledge base so they're indexed by FTS5 and can be git-synced through Kontexta's own backup engine.
1119
1119
 
1120
1120
  This tool ONLY COPIES. It never deletes or modifies the originals in your repo. After a successful transfer, the response includes the list of source paths so the user can manually remove them if desired. No tool argument, no flag, and no code path in this tool ever calls a destructive filesystem operation against \`project.path\`.
1121
1121
 
@@ -1250,7 +1250,7 @@ IDEMPOTENT: re-running with the same files copies nothing if the content is unch
1250
1250
  };
1251
1251
  }
1252
1252
  });
1253
- server.tool("commit_backup", "SIDE-EFFECTFUL — TOUCHES THE NETWORK. Sync the project's KB data into its git backup directory, create a commit, and `git push` to `origin`. AUTH: relies on the local user's git credentials (SSH agent, credential helper, etc.) — there is no in-server auth. Kontexta does not rate-limit, but the remote may. Idempotent in steady state: a no-op commit is skipped, but the push still runs. Throws if the project has no configured backup repo or if push fails (network, auth, conflict). Returns `{success, copied_files_count, copied_paths}`. Use after a batch of KB writes to get changes off-machine.", {
1253
+ server.tool("admin.commit_backup", "SIDE-EFFECTFUL — TOUCHES THE NETWORK. Sync the project's KB data into its git backup directory, create a commit, and `git push` to `origin`. AUTH: relies on the local user's git credentials (SSH agent, credential helper, etc.) — there is no in-server auth. Kontexta does not rate-limit, but the remote may. Idempotent in steady state: a no-op commit is skipped, but the push still runs. Throws if the project has no configured backup repo or if push fails (network, auth, conflict). Returns `{success, copied_files_count, copied_paths}`. Use after a batch of KB writes to get changes off-machine.", {
1254
1254
  project_id: z.number().describe("Project ID"),
1255
1255
  }, async ({ project_id }) => {
1256
1256
  try {
@@ -1275,7 +1275,7 @@ server.tool("commit_backup", "SIDE-EFFECTFUL — TOUCHES THE NETWORK. Sync the p
1275
1275
  };
1276
1276
  }
1277
1277
  });
1278
- server.tool("clip_url", "SIDE-EFFECTFUL — fetches an EXTERNAL URL and writes a NEW KB file. Downloads the page, extracts the main article via Readability, converts to markdown, and saves it under `knowledge/urlclips/`. Auto-classified as content_class='dictionary' (clipped external references are treated as authoritative reference material). NOT idempotent / no de-dup — re-clipping the same URL creates a second file. AUTH: anonymous by default; pass `headers` (e.g. `{Cookie: 'session=...'}` or `{Authorization: 'Bearer ...'}`) to clip behind logins. Kontexta does not rate-limit but the upstream may throttle. On auth-required pages returns isError with `code: AUTH_REQUIRED`, optional `login_url`, and a hint to retry with `headers`. Returns `{file_id, path, title, source}`. Use to ingest external docs into the KB.", {
1278
+ server.tool("resources.clip_url", "SIDE-EFFECTFUL — fetches an EXTERNAL URL and writes a NEW KB file. Downloads the page, extracts the main article via Readability, converts to markdown, and saves it under `knowledge/urlclips/`. Auto-classified as content_class='dictionary' (clipped external references are treated as authoritative reference material). NOT idempotent / no de-dup — re-clipping the same URL creates a second file. AUTH: anonymous by default; pass `headers` (e.g. `{Cookie: 'session=...'}` or `{Authorization: 'Bearer ...'}`) to clip behind logins. Kontexta does not rate-limit but the upstream may throttle. On auth-required pages returns isError with `code: AUTH_REQUIRED`, optional `login_url`, and a hint to retry with `headers`. Returns `{file_id, path, title, source}`. Use to ingest external docs into the KB.", {
1279
1279
  url: z.string().url().describe("The URL to clip"),
1280
1280
  title: z.string().optional().describe("Optional title override (defaults to the page's <title>)"),
1281
1281
  headers: z
@@ -1329,7 +1329,7 @@ function repoDirForFile(file) {
1329
1329
  }
1330
1330
  return dataDir;
1331
1331
  }
1332
- server.tool("get_history", "Return the git commit history for one file (newest first), each entry with hash, message, date, and author. Reads the file's owning repo: the project's git repo for project files, the KB backup repo for KB files. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, history}`; an empty array means the file has not been committed yet. Use to understand a file's evolution before editing or restoring. Pair with `get_diff` to see exact line changes; use `restore_file` to roll back.", {
1332
+ server.tool("files.get_history", "Return the git commit history for one file (newest first), each entry with hash, message, date, and author. Reads the file's owning repo: the project's git repo for project files, the KB backup repo for KB files. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, history}`; an empty array means the file has not been committed yet. Use to understand a file's evolution before editing or restoring. Pair with `get_diff` to see exact line changes; use `restore_file` to roll back.", {
1333
1333
  file_id: z.number().describe("ID of the file"),
1334
1334
  }, async ({ file_id }) => {
1335
1335
  const file = readFile(file_id);
@@ -1343,7 +1343,7 @@ server.tool("get_history", "Return the git commit history for one file (newest f
1343
1343
  ],
1344
1344
  };
1345
1345
  });
1346
- server.tool("get_diff", "Return the unified diff of one file between two commit hashes (typically obtained from `get_history` for the same file). Read-only; no side effects, auth, or rate limits. Order matters — `commit_a` is treated as the earlier side; reversing the args inverts the diff. Throws if either hash is unknown to the file's repo. Use after `get_history` to see WHAT changed, not just THAT it changed.", {
1346
+ server.tool("files.get_diff", "Return the unified diff of one file between two commit hashes (typically obtained from `get_history` for the same file). Read-only; no side effects, auth, or rate limits. Order matters — `commit_a` is treated as the earlier side; reversing the args inverts the diff. Throws if either hash is unknown to the file's repo. Use after `get_history` to see WHAT changed, not just THAT it changed.", {
1347
1347
  file_id: z.number().describe("ID of the file"),
1348
1348
  commit_a: z.string().describe("Earlier commit hash (from get_history)"),
1349
1349
  commit_b: z.string().describe("Later commit hash (from get_history)"),
@@ -1359,7 +1359,7 @@ server.tool("get_diff", "Return the unified diff of one file between two commit
1359
1359
  ],
1360
1360
  };
1361
1361
  });
1362
- server.tool("restore_file", "DESTRUCTIVE. Overwrite a file's current on-disk content with the version recorded at a specific git commit, then re-index FTS. The hash MUST come from `get_history` for THIS file (foreign hashes throw). The current uncommitted content is lost unless it was already committed elsewhere. The file watcher may also pick up the change before this returns. No external auth or rate limits. Returns `{file_id, path, hash, success, message}`. Use only to undo accidental edits or recover a known-good version.", {
1362
+ server.tool("files.restore", "DESTRUCTIVE. Overwrite a file's current on-disk content with the version recorded at a specific git commit, then re-index FTS. The hash MUST come from `get_history` for THIS file (foreign hashes throw). The current uncommitted content is lost unless it was already committed elsewhere. The file watcher may also pick up the change before this returns. No external auth or rate limits. Returns `{file_id, path, hash, success, message}`. Use only to undo accidental edits or recover a known-good version.", {
1363
1363
  file_id: z.number().describe("ID of the file"),
1364
1364
  hash: z.string().describe("Commit hash to restore from (from get_history)"),
1365
1365
  }, async ({ file_id, hash }) => {
@@ -1388,7 +1388,7 @@ server.tool("restore_file", "DESTRUCTIVE. Overwrite a file's current on-disk con
1388
1388
  };
1389
1389
  }
1390
1390
  });
1391
- server.tool("read_file_outline", "Return a flat list of markdown headings for one file (level, text, line, byteStart, byteEnd). Read-only; no side effects, auth, or rate limits. Use as a cheap probe before `read_section` or `update_file_section` so you don't spend tokens on the full body just to learn what sections exist. Empty outline means the file has no markdown headings (it may still have content — fall back to `read_file` or `read_file_lines`).", {
1391
+ server.tool("files.read_outline", "Return a flat list of markdown headings for one file (level, text, line, byteStart, byteEnd). Read-only; no side effects, auth, or rate limits. Use as a cheap probe before `read_section` or `update_file_section` so you don't spend tokens on the full body just to learn what sections exist. Empty outline means the file has no markdown headings (it may still have content — fall back to `read_file` or `read_file_lines`).", {
1392
1392
  file_id: z.number().describe("File ID"),
1393
1393
  }, async ({ file_id }) => {
1394
1394
  try {
@@ -1416,7 +1416,7 @@ server.tool("read_file_outline", "Return a flat list of markdown headings for on
1416
1416
  };
1417
1417
  }
1418
1418
  });
1419
- server.tool("read_section", "Return the body of ONE heading (the heading line itself is excluded) plus level, line, size_bytes, and est_tokens. Heading match is case-insensitive but exact-string after trim — fuzzy / partial matches do NOT resolve. Returns isError if the heading is absent. Read-only; no side effects, auth, or rate limits. Pair with `read_file_outline` when you are unsure which headings exist; for non-heading line ranges use `read_file_lines`.", {
1419
+ server.tool("files.read_section", "Return the body of ONE heading (the heading line itself is excluded) plus level, line, size_bytes, and est_tokens. Heading match is case-insensitive but exact-string after trim — fuzzy / partial matches do NOT resolve. Returns isError if the heading is absent. Read-only; no side effects, auth, or rate limits. Pair with `read_file_outline` when you are unsure which headings exist; for non-heading line ranges use `read_file_lines`.", {
1420
1420
  file_id: z.number().describe("File ID"),
1421
1421
  heading: z.string().describe("Heading text to extract (case-insensitive)"),
1422
1422
  }, async ({ file_id, heading }) => {
@@ -1456,7 +1456,7 @@ server.tool("read_section", "Return the body of ONE heading (the heading line it
1456
1456
  };
1457
1457
  }
1458
1458
  });
1459
- server.tool("update_file_section", "Surgical write — replace the body of ONE heading without touching siblings. The heading line itself is preserved verbatim; only its body is rewritten. Persists via the same path as `update_file` (writes to disk → FTS reindex → git commit). Throws if the heading does not exist (this tool will NOT create a new section — append the section text via `update_file` first). Heading match is case-insensitive exact-string. No external auth or rate limits. Returns the updated file metadata. Use to make targeted edits without re-sending the whole body; for full-file replacement use `update_file`.", {
1459
+ server.tool("files.update_section", "Surgical write — replace the body of ONE heading without touching siblings. The heading line itself is preserved verbatim; only its body is rewritten. Persists via the same path as `update_file` (writes to disk → FTS reindex → git commit). Throws if the heading does not exist (this tool will NOT create a new section — append the section text via `update_file` first). Heading match is case-insensitive exact-string. No external auth or rate limits. Returns the updated file metadata. Use to make targeted edits without re-sending the whole body; for full-file replacement use `update_file`.", {
1460
1460
  file_id: z.number().describe("File ID"),
1461
1461
  heading: z.string().describe("Heading whose body to replace (case-insensitive)"),
1462
1462
  content: z.string().describe("New body content (heading line is preserved automatically)"),
@@ -1501,7 +1501,7 @@ function validateFolderName(name) {
1501
1501
  throw new Error("name must not contain '..' segments");
1502
1502
  }
1503
1503
  }
1504
- server.tool("list_folders", "List folder paths under a project root (or the Knowledge Base when `project_id` is null/omitted). Returns `{folders: string[], base_path}` where `folders` are RELATIVE to `base_path`. Read-only; no side effects, auth, or rate limits. Throws if `project_id` references an unknown project. Use to discover where to drop a new file via `create_file`'s `folder` argument or to navigate vault structure; to actually create one use `create_folder`.", {
1504
+ server.tool("folders.list", "List folder paths under a project root (or the Knowledge Base when `project_id` is null/omitted). Returns `{folders: string[], base_path}` where `folders` are RELATIVE to `base_path`. Read-only; no side effects, auth, or rate limits. Throws if `project_id` references an unknown project. Use to discover where to drop a new file via `create_file`'s `folder` argument or to navigate vault structure; to actually create one use `create_folder`.", {
1505
1505
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to list KB folders."),
1506
1506
  }, async ({ project_id }) => {
1507
1507
  try {
@@ -1519,7 +1519,7 @@ server.tool("list_folders", "List folder paths under a project root (or the Know
1519
1519
  };
1520
1520
  }
1521
1521
  });
1522
- server.tool("create_folder", "Create a folder under a project root or the KB. Idempotent — creating an existing folder succeeds. Nested paths like `notes/inbox` create intermediates. REJECTS: empty names, null bytes, leading path separators, and any segment equal to `..` (the call returns isError, no folder is touched). Side effect: a directory is mkdir'd on disk; no DB rows are written until a file lands inside. No external auth or rate limits. Returns `{path, base_path}`.", {
1522
+ server.tool("folders.create", "Create a folder under a project root or the KB. Idempotent — creating an existing folder succeeds. Nested paths like `notes/inbox` create intermediates. REJECTS: empty names, null bytes, leading path separators, and any segment equal to `..` (the call returns isError, no folder is touched). Side effect: a directory is mkdir'd on disk; no DB rows are written until a file lands inside. No external auth or rate limits. Returns `{path, base_path}`.", {
1523
1523
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to create the folder under the KB."),
1524
1524
  name: z.string().describe("Folder name (relative; supports nested paths via '/')"),
1525
1525
  }, async ({ project_id, name }) => {
@@ -1538,7 +1538,7 @@ server.tool("create_folder", "Create a folder under a project root or the KB. Id
1538
1538
  };
1539
1539
  }
1540
1540
  });
1541
- server.tool("delete_folder", "DESTRUCTIVE — recursively delete a folder under the KB AND every file inside it (disk + FTS rows). REFUSES (returns isError) when `project_id` is supplied: deleting inside a registered project would race the file watcher and re-ingest the contents — remove project content via your editor instead. Same name validation as `create_folder`. Not recoverable from Kontexta after the call (only the git backup, if configured, retains it). No external auth or rate limits. Returns `{success: true}`.", {
1541
+ server.tool("folders.delete", "DESTRUCTIVE — recursively delete a folder under the KB AND every file inside it (disk + FTS rows). REFUSES (returns isError) when `project_id` is supplied: deleting inside a registered project would race the file watcher and re-ingest the contents — remove project content via your editor instead. Same name validation as `create_folder`. Not recoverable from Kontexta after the call (only the git backup, if configured, retains it). No external auth or rate limits. Returns `{success: true}`.", {
1542
1542
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to delete from the KB. Project IDs are rejected."),
1543
1543
  name: z.string().describe("Folder name (relative)"),
1544
1544
  }, async ({ project_id, name }) => {
@@ -1579,7 +1579,7 @@ server.tool("delete_folder", "DESTRUCTIVE — recursively delete a folder under
1579
1579
  };
1580
1580
  }
1581
1581
  });
1582
- server.tool("move_file", "Move/rename a file. Destination 'new_path' must be absolute and resolve INSIDE the file's owning project or global knowledge directory. Cross-project moves are rejected. Alternative: pass `kind='dictionary'|'note'` (with no `new_path`) to move a KB file into the mirrored path in the other class tree — subfolder path is preserved. Operates locally with no auth or limits.", {
1582
+ server.tool("files.move", "Move/rename a file. Destination 'new_path' must be absolute and resolve INSIDE the file's owning project or global knowledge directory. Cross-project moves are rejected. Alternative: pass `kind='dictionary'|'note'` (with no `new_path`) to move a KB file into the mirrored path in the other class tree — subfolder path is preserved. Operates locally with no auth or limits.", {
1583
1583
  file_id: z.number().describe("File ID"),
1584
1584
  new_path: z.string().optional().describe("Absolute destination path"),
1585
1585
  kind: z.enum(["dictionary", "note"]).optional()
@@ -1672,7 +1672,7 @@ server.tool("move_file", "Move/rename a file. Destination 'new_path' must be abs
1672
1672
  };
1673
1673
  }
1674
1674
  });
1675
- server.tool("find_related", "Find other files sharing tags with the given file, ranked by `shared_tag_count` descending. Read-only; no side effects, auth, or rate limits. Returns annotated file rows with `shared_tag_count` and `shared_tags`. Empty result means the file has no tags or no other file shares them — try `search`/`regex_search` for content-based discovery, or `suggest_tags` to bootstrap labels first. `kind` narrows to one content class. Default limit 10.", {
1675
+ server.tool("files.find_related", "Find other files sharing tags with the given file, ranked by `shared_tag_count` descending. Read-only; no side effects, auth, or rate limits. Returns annotated file rows with `shared_tag_count` and `shared_tags`. Empty result means the file has no tags or no other file shares them — try `files.search`/`files.regex_search` for content-based discovery, or `tags.suggest` to bootstrap labels first. `kind` narrows to one content class. Default limit 10.", {
1676
1676
  file_id: z.number().describe("ID of the file to find relations for"),
1677
1677
  limit: z.number().optional().describe("Maximum number of related files to return (default 10)"),
1678
1678
  kind: z.enum(["dictionary", "note", "journal", "project"]).optional()
@@ -1695,7 +1695,7 @@ server.tool("find_related", "Find other files sharing tags with the given file,
1695
1695
  ],
1696
1696
  };
1697
1697
  });
1698
- server.tool("create_files", "Batch variant of `create_file` — create up to 200 markdown, mermaid, or HTML files in one call. Each item follows the same rules: `project_id` required if `destination` is `project`/`kontexta`; `kind` ('dictionary' or 'note') required if `destination` is `knowledge`. SIDE EFFECTS: writes new files to disk and inserts FTS5 rows; missing folders are mkdir'd. Per-item failures are isolated to `errors[]` and the rest of the batch still commits — partial success is the norm, always inspect `error_count`. No external auth or rate limits. Returns `{created_count, error_count, created, errors}`. Use for bulk ingestion; for >200 items, page yourself. Pass format='mmd' on an item to create a Mermaid diagram file (.mmd) or 'html' for HTML reports; defaults to 'md'.", {
1698
+ server.tool("files.create_many", "Batch variant of `files.create` — create up to 200 markdown, mermaid, or HTML files in one call. Each item follows the same rules: `project_id` required if `destination` is `project`/`kontexta`; `kind` ('dictionary' or 'note') required if `destination` is `knowledge`. SIDE EFFECTS: writes new files to disk and inserts FTS5 rows; missing folders are mkdir'd. Per-item failures are isolated to `errors[]` and the rest of the batch still commits — partial success is the norm, always inspect `error_count`. No external auth or rate limits. Returns `{created_count, error_count, created, errors}`. Use for bulk ingestion; for >200 items, page yourself. Pass format='mmd' on an item to create a Mermaid diagram file (.mmd) or 'html' for HTML reports; defaults to 'md'.", {
1699
1699
  files: z
1700
1700
  .array(z.object({
1701
1701
  title: z.string().describe("File title."),
@@ -1706,7 +1706,7 @@ server.tool("create_files", "Batch variant of `create_file` — create up to 200
1706
1706
  tags: z.array(z.string()).optional().describe("Tags to apply to this file."),
1707
1707
  format: z.enum(["md", "mmd", "html"]).optional().describe("File format: 'md' (default), 'mmd' (Mermaid diagram), or 'html' (report)."),
1708
1708
  kind: z.enum(["dictionary", "note"]).optional()
1709
- .describe("REQUIRED per-item for destination='knowledge'. See create_file for the dictionary/note rubric."),
1709
+ .describe("REQUIRED per-item for destination='knowledge'. See files.create for the dictionary/note rubric."),
1710
1710
  }))
1711
1711
  .min(1)
1712
1712
  .max(200)
@@ -1750,7 +1750,7 @@ server.tool("create_files", "Batch variant of `create_file` — create up to 200
1750
1750
  ],
1751
1751
  };
1752
1752
  });
1753
- server.tool("delete_files", "DESTRUCTIVE batch — delete up to 500 files by ID in one call. Same physical-deletion rules as `delete_file` (KB files unlinked from disk; project reference files only de-indexed). Per-ID failures isolated to `errors[]`; the batch keeps going — partial success is the norm. Not idempotent — unknown IDs surface as per-item errors. No external auth or rate limits. Returns `{deleted_count, error_count, deleted, errors}`. To preview the set before deleting, run `list_files` with the same filter and confirm the IDs.", {
1753
+ server.tool("files.delete_many", "DESTRUCTIVE batch — delete up to 500 files by ID in one call. Same physical-deletion rules as `files.delete` (KB files unlinked from disk; project reference files only de-indexed). Per-ID failures isolated to `errors[]`; the batch keeps going — partial success is the norm. Not idempotent — unknown IDs surface as per-item errors. No external auth or rate limits. Returns `{deleted_count, error_count, deleted, errors}`. To preview the set before deleting, run `files.list` with the same filter and confirm the IDs.", {
1754
1754
  ids: z.array(z.number()).min(1).max(500).describe("File IDs to delete (max 500 per call)"),
1755
1755
  }, async ({ ids }) => {
1756
1756
  const deleted = [];
@@ -1773,7 +1773,7 @@ server.tool("delete_files", "DESTRUCTIVE batch — delete up to 500 files by ID
1773
1773
  ],
1774
1774
  };
1775
1775
  });
1776
- server.tool("tag_search_results", "Bulk-tag — run an FTS `search` and append `add_tags` to every matching file in one call. Side effect: each match gets `addTags` applied (additive, idempotent per tag); the matched files themselves are NOT modified beyond their tag links. Per-file failures isolated to `errors[]`. No external auth or rate limits. There is NO dry-run flag, so ALWAYS run `search` with the same query first to verify the match set before tagging. The `tags[]` filter requires existing tags to ALL match (it scopes the search; it does not control which tags get added). Returns `{matched_count, tagged_count, tags_applied, tagged_ids, errors}`.", {
1776
+ server.tool("tags.search", "Bulk-tag — run an FTS `search` and append `add_tags` to every matching file in one call. Side effect: each match gets `addTags` applied (additive, idempotent per tag); the matched files themselves are NOT modified beyond their tag links. Per-file failures isolated to `errors[]`. No external auth or rate limits. There is NO dry-run flag, so ALWAYS run `files.search` with the same query first to verify the match set before tagging. The `tags[]` filter requires existing tags to ALL match (it scopes the search; it does not control which tags get added). Returns `{matched_count, tagged_count, tags_applied, tagged_ids, errors}`.", {
1777
1777
  query: z.string().describe("Full-text search query"),
1778
1778
  add_tags: z.array(z.string()).min(1).describe("Tags to add to every matching file"),
1779
1779
  project_id: z.number().nullable().optional().describe("Scope search to a specific project. Pass null for KB-only results."),
@@ -1823,7 +1823,7 @@ server.tool("tag_search_results", "Bulk-tag — run an FTS `search` and append `
1823
1823
  ],
1824
1824
  };
1825
1825
  });
1826
- server.tool("read_file_by_path", "Look up a file by its absolute on-disk path and return the same shape as `read_file`. The path must EXACTLY match what Kontexta indexed — no symlink resolution, no path normalisation beyond what the OS does, no trailing-slash tolerance. Returns isError if no row matches (the file may exist on disk but not be indexed — try `refresh_index`). Read-only; no side effects, auth, or rate limits. Use when an agent has a path from its working directory but no file ID; if you have the ID, prefer `read_file`.", {
1826
+ server.tool("files.read_by_path", "Look up a file by its absolute on-disk path and return the same shape as `files.read`. The path must EXACTLY match what Kontexta indexed — no symlink resolution, no path normalisation beyond what the OS does, no trailing-slash tolerance. Returns isError if no row matches (the file may exist on disk but not be indexed — try `projects.refresh_index`). Read-only; no side effects, auth, or rate limits. Use when an agent has a path from its working directory but no file ID; if you have the ID, prefer `files.read`.", {
1827
1827
  path: z.string().describe("Absolute path on disk (must match the path stored in Kontexta)"),
1828
1828
  }, async ({ path }) => {
1829
1829
  try {
@@ -1856,7 +1856,7 @@ server.tool("read_file_by_path", "Look up a file by its absolute on-disk path an
1856
1856
  };
1857
1857
  }
1858
1858
  });
1859
- server.tool("stats", "Aggregate counts for a scope: `file_count`, `untagged_count`, `favorite_count`, `top_tags`. With `project_id` omitted (everything), also returns `by_project` breakdown. `include_token_total: true` stat()s every matching file on disk to compute a body-size estimate — measurably slower on large vaults; default false. `project_id: null` = KB only; omit = all. Read-only; no side effects, auth, or rate limits. Use as a cheap dashboard or to spot untagged content for cleanup; for live disk-vs-index drift use `diff_against_disk`.", {
1859
+ server.tool("admin.stats", "Aggregate counts for a scope: `file_count`, `untagged_count`, `favorite_count`, `top_tags`. With `project_id` omitted (everything), also returns `by_project` breakdown. `include_token_total: true` stat()s every matching file on disk to compute a body-size estimate — measurably slower on large vaults; default false. `project_id: null` = KB only; omit = all. Read-only; no side effects, auth, or rate limits. Use as a cheap dashboard or to spot untagged content for cleanup; for live disk-vs-index drift use `files.diff_against_disk`.", {
1860
1860
  project_id: z.number().nullable().optional().describe("Filter to a single project. Pass null for KB-only. Omit for everything."),
1861
1861
  top_tags: z.number().int().positive().max(100).optional().describe("How many top tags to return (default 10)"),
1862
1862
  include_token_total: z.boolean().optional().describe("If true, stat every matching file on disk to compute total est_tokens. Default false (cheap)."),
@@ -1945,7 +1945,7 @@ server.tool("stats", "Aggregate counts for a scope: `file_count`, `untagged_coun
1945
1945
  };
1946
1946
  }
1947
1947
  });
1948
- server.tool("suggest_tags", "Propose tags for a file by mining the existing tag corpus via FTS — picks distinctive terms from the file (≥4 chars, stopword-filtered) and returns tags applied to other files that score high on those terms. No LLM, no network. Already-applied tags are excluded so the suggestions are net-new. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, existing_tags, suggestions: [{tag, score, sources}]}`. Empty suggestions = no distinctive terms or no overlap with the existing taxonomy yet — bootstrap with `add_tags` first. Default limit 10, max 50. Suggestions are NOT auto-applied.", {
1948
+ server.tool("tags.suggest", "Propose tags for a file by mining the existing tag corpus via FTS — picks distinctive terms from the file (≥4 chars, stopword-filtered) and returns tags applied to other files that score high on those terms. No LLM, no network. Already-applied tags are excluded so the suggestions are net-new. Read-only; no side effects, auth, or rate limits. Returns `{file_id, path, existing_tags, suggestions: [{tag, score, sources}]}`. Empty suggestions = no distinctive terms or no overlap with the existing taxonomy yet — bootstrap with `tags.add` first. Default limit 10, max 50. Suggestions are NOT auto-applied.", {
1949
1949
  file_id: z.number().describe("File ID to suggest tags for"),
1950
1950
  limit: z.number().int().positive().max(50).optional().describe("Max suggestions to return (default 10)"),
1951
1951
  }, async ({ file_id, limit }) => {
@@ -2025,7 +2025,7 @@ server.tool("suggest_tags", "Propose tags for a file by mining the existing tag
2025
2025
  };
2026
2026
  }
2027
2027
  });
2028
- server.tool("diff_against_disk", "Diagnose drift between one file's disk content and its FTS index. Status is one of `in_sync`, `diverged`, `disk_unreadable`, or `no_index_row`. On divergence returns sizes, line counts, the first divergent line number, and the disk vs index sample for that line — NOT a full diff (use `get_diff` for full diffs between commits). Read-only; no side effects, auth, or rate limits. Use when search results look stale; if status is `diverged` or `no_index_row`, run `refresh_index` to fix.", {
2028
+ server.tool("files.diff_against_disk", "Diagnose drift between one file's disk content and its FTS index. Status is one of `in_sync`, `diverged`, `disk_unreadable`, or `no_index_row`. On divergence returns sizes, line counts, the first divergent line number, and the disk vs index sample for that line — NOT a full diff (use `files.get_diff` for full diffs between commits). Read-only; no side effects, auth, or rate limits. Use when search results look stale; if status is `diverged` or `no_index_row`, run `projects.refresh_index` to fix.", {
2029
2029
  file_id: z.number().describe("File ID"),
2030
2030
  }, async ({ file_id }) => {
2031
2031
  try {
@@ -2132,7 +2132,7 @@ server.tool("diff_against_disk", "Diagnose drift between one file's disk content
2132
2132
  };
2133
2133
  }
2134
2134
  });
2135
- server.tool("refresh_index", "Reconcile the FTS index against disk. For a project (`project_id` set), re-runs `discoverFiles`. For the KB (`project_id` null/omitted), walks `knowledge/`, ingests new .md files, reindexes any whose content hash drifted, and PRUNES rows for files no longer on disk. SIDE-EFFECTFUL: writes/updates/deletes file and FTS rows (the prune is destructive on stale index rows but never deletes files from disk). Idempotent — running twice is a near no-op. Skips files >5MB and standard junk dirs (`node_modules`, `.git`, `dist`, `build`, etc.). No external auth or rate limits. Returns `{scope, newly_indexed, refreshed, pruned}`. Use after editing files outside Kontexta, or when `diff_against_disk` reports drift.", {
2135
+ server.tool("projects.refresh_index", "Reconcile the FTS index against disk. For a project (`project_id` set), re-runs `discoverFiles`. For the KB (`project_id` null/omitted), walks `knowledge/`, ingests new .md files, reindexes any whose content hash drifted, and PRUNES rows for files no longer on disk. SIDE-EFFECTFUL: writes/updates/deletes file and FTS rows (the prune is destructive on stale index rows but never deletes files from disk). Idempotent — running twice is a near no-op. Skips files >5MB and standard junk dirs (`node_modules`, `.git`, `dist`, `build`, etc.). No external auth or rate limits. Returns `{scope, newly_indexed, refreshed, pruned}`. Use after editing files outside Kontexta, or when `files.diff_against_disk` reports drift.", {
2136
2136
  project_id: z.number().nullable().optional().describe("Project ID. Pass null or omit to reindex the Knowledge Base."),
2137
2137
  }, async ({ project_id }) => {
2138
2138
  try {
@@ -2153,7 +2153,7 @@ server.tool("refresh_index", "Reconcile the FTS index against disk. For a projec
2153
2153
  };
2154
2154
  }
2155
2155
  });
2156
- server.tool("whats_new", "List files created or modified since a checkpoint. `since` accepts ISO-8601 (`2025-01-15T00:00:00Z`) or relative durations (`1h`, `7d`, `2w`); invalid formats throw. Read-only; no side effects, auth, or rate limits. Returns annotated rows plus aggregate `total_est_tokens` so you can decide what to read next. CAVEAT: hard-deleted files are NOT surfaced — only mtime-driven changes. Defaults: include_tags=true, limit=200. `project_id: null` = KB only; omit = everything. Use at session start to catch up.", {
2156
+ server.tool("admin.whats_new", "List files created or modified since a checkpoint. `since` accepts ISO-8601 (`2025-01-15T00:00:00Z`) or relative durations (`1h`, `7d`, `2w`); invalid formats throw. Read-only; no side effects, auth, or rate limits. Returns annotated rows plus aggregate `total_est_tokens` so you can decide what to read next. CAVEAT: hard-deleted files are NOT surfaced — only mtime-driven changes. Defaults: include_tags=true, limit=200. `project_id: null` = KB only; omit = everything. Use at session start to catch up.", {
2157
2157
  since: z.string().describe("ISO 8601 timestamp or relative duration (e.g. \"1h\", \"7d\", \"2w\")."),
2158
2158
  project_id: z.number().nullable().optional().describe("Filter to a single project. Pass null for knowledge-base-only files. Omit for all."),
2159
2159
  include_tags: z.boolean().optional().describe("Attach tags[] to each file. Default true."),
@@ -2192,7 +2192,7 @@ server.tool("whats_new", "List files created or modified since a checkpoint. `si
2192
2192
  };
2193
2193
  }
2194
2194
  });
2195
- server.tool("project_map", "Return a compact indented outline of folders, file titles, tags, and IDs in a single dense block — substantially fewer tokens than the equivalent `list_files` JSON for the same scope. Read-only; no side effects, auth, or rate limits. Capped at `max_lines` (default 5000); the response reports `est_tokens` and emits a `warning` field if it exceeds `KONTEXTA_PROJECT_TOKEN_WARN`. `project_id: null` = KB only; omit = everything. Defaults: include_tags=true, show_titles=true. Use to orient yourself in an unfamiliar vault or project; for keyword lookup use `search`.", {
2195
+ server.tool("projects.map", "Return a compact indented outline of folders, file titles, tags, and IDs in a single dense block — substantially fewer tokens than the equivalent `files.list` JSON for the same scope. Read-only; no side effects, auth, or rate limits. Capped at `max_lines` (default 5000); the response reports `est_tokens` and emits a `warning` field if it exceeds `KONTEXTA_PROJECT_TOKEN_WARN`. `project_id: null` = KB only; omit = everything. Defaults: include_tags=true, show_titles=true. Use to orient yourself in an unfamiliar vault or project; for keyword lookup use `files.search`.", {
2196
2196
  project_id: z.number().nullable().optional().describe("Restrict to a single project. Pass null for knowledge-base-only files. Omit for everything."),
2197
2197
  include_tags: z.boolean().optional().describe("Append #tags inline. Default true. Set false to shrink the outline."),
2198
2198
  show_titles: z.boolean().optional().describe("Show file titles instead of filenames. Default true."),
@@ -2271,18 +2271,18 @@ server.resource("File Content", new ResourceTemplate("kontexta://files/{id}", {
2271
2271
  ],
2272
2272
  };
2273
2273
  });
2274
- server.tool("list_hands", "List every Hands command tool currently registered, with project scope, tool name, danger level, confirmation flag, and description. Hands tools come from per-project `kontexta.json` files loaded at register time. Read-only; no side effects, auth, or rate limits. Use to discover what side-effectful project commands the agent is permitted to run; for the `kontexta.json` schema see `describe_hands_schema`; reload after editing one with `reload_hands`.", {}, async () => {
2274
+ server.tool("hands.list", "List every Hands command tool currently registered, with project scope, tool name, danger level, confirmation flag, and description. Hands tools come from per-project `kontexta.json` files loaded at register time. Read-only; no side effects, auth, or rate limits. Use to discover what side-effectful project commands the agent is permitted to run; for the `kontexta.json` schema see `hands.describe_schema`; reload after editing one with `hands.reload`.", {}, async () => {
2275
2275
  const items = handsRegistry.list();
2276
2276
  return { content: [{ type: "text", text: JSON.stringify({ hands: items }, null, 2) }] };
2277
2277
  });
2278
- server.tool("reload_hands", "Re-scan every registered project's `kontexta.json` and rebuild the live Hands tool registry — newly-declared tools become callable immediately, removed tools disappear from `tools/list`. SIDE EFFECT is on the running MCP session's tool inventory only (no disk writes). Idempotent. No external auth or rate limits. Takes no parameters. Returns per-project load results (counts of registered/disabled tools and any validation warnings). Use after editing a `kontexta.json` mid-session; for the schema see `describe_hands_schema`.", {}, async () => {
2278
+ server.tool("hands.reload", "Re-scan every registered project's `kontexta.json` and rebuild the live Hands tool registry — newly-declared tools become callable immediately, removed tools disappear from `tools/list`. SIDE EFFECT is on the running MCP session's tool inventory only (no disk writes). Idempotent. No external auth or rate limits. Takes no parameters. Returns per-project load results (counts of registered/disabled tools and any validation warnings). Use after editing a `kontexta.json` mid-session; for the schema see `hands.describe_schema`.", {}, async () => {
2279
2279
  const projects = listProjects()
2280
2280
  .filter((p) => p.path && existsSync(p.path))
2281
2281
  .map((p) => ({ name: p.name, root: p.path }));
2282
2282
  const r = handsRegistry.reloadAll(projects);
2283
2283
  return { content: [{ type: "text", text: JSON.stringify(r, null, 2) }] };
2284
2284
  });
2285
- server.tool("confirm_hand", "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.", { token: z.string().describe("The approval token from the pending response") }, async ({ token }) => {
2285
+ server.tool("hands.confirm", "Approve and EXECUTE a previously-issued Hands invocation by its single-use approval token. The token is returned by any confirm-required Hands tool; tokens expire after 60 seconds and CANNOT be reused. Side effect equals whatever the underlying Hand does — this can be highly destructive (running arbitrary shell commands, modifying files, etc.), so only call when the user has authorised the pending action. The token IS the auth (no external auth, no rate limits). Invalid, expired, or already-consumed tokens return an inert text response, NOT an error.", { token: z.string().describe("The approval token from the pending response") }, async ({ token }) => {
2286
2286
  const pending = handsRegistry.getConfirmStore().consume(token);
2287
2287
  if (!pending) {
2288
2288
  return { content: [{ type: "text", text: "Token invalid, expired, or already consumed." }] };
@@ -2295,8 +2295,8 @@ server.tool("confirm_hand", "Approve and EXECUTE a previously-issued Hands invoc
2295
2295
  return { content: [{ type: "text", text: `Execution failed after approval: ${e?.message ?? e}` }] };
2296
2296
  }
2297
2297
  });
2298
- server.tool("describe_hands_schema", "Return the complete authoring reference for `kontexta.json`: JSON schema, validation rules, security guarantees, limitations, and an annotated example. Static document — does not read any project file or DB row. Read-only; no side effects, auth, or rate limits. Takes no parameters. Use when helping a user write or fix a `kontexta.json`; to see the loaded tools themselves use `list_hands`; to apply edits use `reload_hands`.", {}, async () => ({ content: [{ type: "text", text: buildSchemaDoc() }] }));
2299
- server.tool("get_profile", "Return the user profile stored in the Knowledge Base. The profile helps AI agents understand the user's context, role, preferences, and goals. Read-only; no side effects, auth, or rate limits. Returns existence status, full content, list of missing required sections, and a hint for new users. Use at session start to understand who you're working with.", {}, async () => {
2298
+ server.tool("hands.describe_schema", "Return the complete authoring reference for `kontexta.json`: JSON schema, validation rules, security guarantees, limitations, and an annotated example. Static document — does not read any project file or DB row. Read-only; no side effects, auth, or rate limits. Takes no parameters. Use when helping a user write or fix a `kontexta.json`; to see the loaded tools themselves use `hands.list`; to apply edits use `hands.reload`.", {}, async () => ({ content: [{ type: "text", text: buildSchemaDoc() }] }));
2299
+ server.tool("admin.get_profile", "Return the user profile stored in the Knowledge Base. The profile helps AI agents understand the user's context, role, preferences, and goals. Read-only; no side effects, auth, or rate limits. Returns existence status, full content, list of missing required sections, and a hint for new users. Use at session start to understand who you're working with.", {}, async () => {
2300
2300
  const result = handleGetProfile(dataDir);
2301
2301
  return {
2302
2302
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],