create-merlin-brain 3.11.0 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/bin/install.cjs +156 -32
  2. package/bin/runtime-adapters.cjs +396 -0
  3. package/dist/server/api/types.d.ts +7 -0
  4. package/dist/server/api/types.d.ts.map +1 -1
  5. package/dist/server/cost/tracker.d.ts +38 -2
  6. package/dist/server/cost/tracker.d.ts.map +1 -1
  7. package/dist/server/cost/tracker.js +87 -15
  8. package/dist/server/cost/tracker.js.map +1 -1
  9. package/dist/server/server.d.ts.map +1 -1
  10. package/dist/server/server.js +74 -30
  11. package/dist/server/server.js.map +1 -1
  12. package/dist/server/tools/__tests__/augmentation.test.d.ts +8 -0
  13. package/dist/server/tools/__tests__/augmentation.test.d.ts.map +1 -0
  14. package/dist/server/tools/__tests__/augmentation.test.js +76 -0
  15. package/dist/server/tools/__tests__/augmentation.test.js.map +1 -0
  16. package/dist/server/tools/__tests__/route-helpers.test.d.ts +5 -0
  17. package/dist/server/tools/__tests__/route-helpers.test.d.ts.map +1 -0
  18. package/dist/server/tools/__tests__/route-helpers.test.js +49 -0
  19. package/dist/server/tools/__tests__/route-helpers.test.js.map +1 -0
  20. package/dist/server/tools/adaptive.js +1 -1
  21. package/dist/server/tools/adaptive.js.map +1 -1
  22. package/dist/server/tools/agent-spawn.d.ts +25 -0
  23. package/dist/server/tools/agent-spawn.d.ts.map +1 -0
  24. package/dist/server/tools/agent-spawn.js +95 -0
  25. package/dist/server/tools/agent-spawn.js.map +1 -0
  26. package/dist/server/tools/agents-index.js +3 -3
  27. package/dist/server/tools/agents-index.js.map +1 -1
  28. package/dist/server/tools/agents.js +5 -5
  29. package/dist/server/tools/agents.js.map +1 -1
  30. package/dist/server/tools/augmentation.d.ts +45 -0
  31. package/dist/server/tools/augmentation.d.ts.map +1 -0
  32. package/dist/server/tools/augmentation.js +167 -0
  33. package/dist/server/tools/augmentation.js.map +1 -0
  34. package/dist/server/tools/behaviors.js +4 -4
  35. package/dist/server/tools/behaviors.js.map +1 -1
  36. package/dist/server/tools/context.js +7 -7
  37. package/dist/server/tools/context.js.map +1 -1
  38. package/dist/server/tools/cost.d.ts +3 -1
  39. package/dist/server/tools/cost.d.ts.map +1 -1
  40. package/dist/server/tools/cost.js +66 -13
  41. package/dist/server/tools/cost.js.map +1 -1
  42. package/dist/server/tools/discoveries.js +6 -6
  43. package/dist/server/tools/discoveries.js.map +1 -1
  44. package/dist/server/tools/index.d.ts +4 -0
  45. package/dist/server/tools/index.d.ts.map +1 -1
  46. package/dist/server/tools/index.js +4 -0
  47. package/dist/server/tools/index.js.map +1 -1
  48. package/dist/server/tools/learning.d.ts +12 -0
  49. package/dist/server/tools/learning.d.ts.map +1 -0
  50. package/dist/server/tools/learning.js +269 -0
  51. package/dist/server/tools/learning.js.map +1 -0
  52. package/dist/server/tools/project.js +7 -7
  53. package/dist/server/tools/project.js.map +1 -1
  54. package/dist/server/tools/promote.d.ts +11 -0
  55. package/dist/server/tools/promote.d.ts.map +1 -0
  56. package/dist/server/tools/promote.js +315 -0
  57. package/dist/server/tools/promote.js.map +1 -0
  58. package/dist/server/tools/route-helpers.d.ts +45 -0
  59. package/dist/server/tools/route-helpers.d.ts.map +1 -0
  60. package/dist/server/tools/route-helpers.js +93 -0
  61. package/dist/server/tools/route-helpers.js.map +1 -0
  62. package/dist/server/tools/route.d.ts +4 -3
  63. package/dist/server/tools/route.d.ts.map +1 -1
  64. package/dist/server/tools/route.js +80 -284
  65. package/dist/server/tools/route.js.map +1 -1
  66. package/dist/server/tools/session-restore.d.ts +18 -0
  67. package/dist/server/tools/session-restore.d.ts.map +1 -0
  68. package/dist/server/tools/session-restore.js +154 -0
  69. package/dist/server/tools/session-restore.js.map +1 -0
  70. package/dist/server/tools/session-search.d.ts +16 -0
  71. package/dist/server/tools/session-search.d.ts.map +1 -0
  72. package/dist/server/tools/session-search.js +240 -0
  73. package/dist/server/tools/session-search.js.map +1 -0
  74. package/dist/server/tools/sights-index.js +2 -2
  75. package/dist/server/tools/sights-index.js.map +1 -1
  76. package/dist/server/tools/smart-route.d.ts.map +1 -1
  77. package/dist/server/tools/smart-route.js +4 -5
  78. package/dist/server/tools/smart-route.js.map +1 -1
  79. package/dist/server/tools/verification.js +1 -1
  80. package/dist/server/tools/verification.js.map +1 -1
  81. package/files/agents/code-organization-supervisor.md +1 -0
  82. package/files/agents/context-guardian.md +1 -0
  83. package/files/agents/docs-keeper.md +1 -0
  84. package/files/agents/dry-refactor.md +1 -0
  85. package/files/agents/elite-code-refactorer.md +1 -0
  86. package/files/agents/hardening-guard.md +1 -0
  87. package/files/agents/implementation-dev.md +1 -0
  88. package/files/agents/merlin-access-control-reviewer.md +248 -0
  89. package/files/agents/merlin-codebase-mapper.md +1 -1
  90. package/files/agents/merlin-dependency-auditor.md +216 -0
  91. package/files/agents/merlin-executor.md +1 -0
  92. package/files/agents/merlin-input-validator.md +247 -0
  93. package/files/agents/merlin-reviewer.md +1 -0
  94. package/files/agents/merlin-sast-reviewer.md +182 -0
  95. package/files/agents/merlin-secret-scanner.md +203 -0
  96. package/files/agents/tests-qa.md +1 -0
  97. package/files/commands/merlin/execute-phase.md +94 -197
  98. package/files/commands/merlin/execute-plan.md +116 -180
  99. package/files/commands/merlin/health.md +385 -0
  100. package/files/commands/merlin/loop-recipes.md +93 -36
  101. package/files/commands/merlin/optimize-prompts.md +158 -0
  102. package/files/commands/merlin/profiles.md +215 -0
  103. package/files/commands/merlin/promote.md +176 -0
  104. package/files/commands/merlin/quick.md +229 -0
  105. package/files/commands/merlin/resume-work.md +27 -1
  106. package/files/commands/merlin/route.md +43 -1
  107. package/files/commands/merlin/sandbox.md +359 -0
  108. package/files/commands/merlin/usage.md +55 -0
  109. package/files/docker/Dockerfile.merlin +20 -0
  110. package/files/docker/docker-compose.merlin.yml +23 -0
  111. package/files/hook-templates/auto-commit.sh +64 -0
  112. package/files/hook-templates/auto-format.sh +95 -0
  113. package/files/hook-templates/auto-test.sh +117 -0
  114. package/files/hook-templates/branch-protection.sh +72 -0
  115. package/files/hook-templates/changelog-reminder.sh +76 -0
  116. package/files/hook-templates/complexity-check.sh +112 -0
  117. package/files/hook-templates/import-audit.sh +83 -0
  118. package/files/hook-templates/license-header.sh +84 -0
  119. package/files/hook-templates/pr-description.sh +100 -0
  120. package/files/hook-templates/todo-tracker.sh +80 -0
  121. package/files/hooks/check-file-size.sh +17 -4
  122. package/files/hooks/config-change.sh +44 -16
  123. package/files/hooks/instructions-loaded.sh +22 -5
  124. package/files/hooks/notify-desktop.sh +157 -0
  125. package/files/hooks/notify-webhook.sh +141 -0
  126. package/files/hooks/pre-edit-sights-check.sh +76 -9
  127. package/files/hooks/security-scanner.sh +153 -0
  128. package/files/hooks/session-end-memory-sync.sh +97 -0
  129. package/files/hooks/session-end.sh +274 -1
  130. package/files/hooks/session-start.sh +19 -6
  131. package/files/hooks/smart-approve.sh +270 -0
  132. package/files/hooks/teammate-idle-verify.sh +87 -12
  133. package/files/hooks/worktree-create.sh +20 -3
  134. package/files/hooks/worktree-remove.sh +21 -3
  135. package/files/merlin/references/plan-format.md +37 -9
  136. package/files/merlin/sandbox.json +9 -0
  137. package/files/merlin/security.json +11 -0
  138. package/files/merlin/templates/ci/docs-update.yml +81 -0
  139. package/files/merlin/templates/ci/pr-review.yml +50 -0
  140. package/files/merlin/templates/ci/security-audit.yml +74 -0
  141. package/files/merlin/templates/config.json +9 -1
  142. package/files/rules/api-rules.md +30 -0
  143. package/files/rules/frontend-rules.md +25 -0
  144. package/files/rules/hooks-rules.md +36 -0
  145. package/files/rules/mcp-rules.md +30 -0
  146. package/files/rules/worker-rules.md +29 -0
  147. package/package.json +5 -2
@@ -1 +1 @@
1
- {"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../../src/server/cost/tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,wDAAwD;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K,CAAC,eAAe,GAAM,CAAC,CAAC;IAC7B,KAAK,CAAC,kBAAkB,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8CpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CAs4FxC;AAED,gDAAgD;AAChD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAoCjD"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkDpE,0CAA0C;AAC1C,wBAAgB,YAAY,IAAI,SAAS,CAi7FxC;AAED,gDAAgD;AAChD,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAoCjD"}
@@ -25,6 +25,10 @@ import { registerLiteTools, getOrInitLiteClient, enhanceFromCloud } from './tool
25
25
  import { registerConfigSyncTools } from './tools/config-sync.js';
26
26
  import { registerSightsIndexTools } from './tools/sights-index.js';
27
27
  import { registerAgentsIndexTools } from './tools/agents-index.js';
28
+ import { registerSessionRestoreTools } from './tools/session-restore.js';
29
+ import { registerSessionSearchTools } from './tools/session-search.js';
30
+ import { registerPromoteTools } from './tools/promote.js';
31
+ import { registerLearningTools } from './tools/learning.js';
28
32
  import { registerAutoTeachTools, assessContextConfidence, buildTeachBackPrompt } from './tools/auto-teach.js';
29
33
  import { registerSmartRouteTools } from './tools/smart-route.js';
30
34
  import { wrapResponse, getStats, getCompactStats, formatSaveNotification, markSessionStatusShown } from './stats.js';
@@ -48,7 +52,7 @@ export function createServer() {
48
52
  name: 'merlin',
49
53
  version: VERSION,
50
54
  description: 'Merlin Brain. MANDATORY BOOT: Call merlin_get_selected_repo then merlin_get_project_status BEFORE responding to user. Call merlin_get_context before every file edit. Never run claude --agent via Bash — use Skill("merlin:route") instead.',
51
- });
55
+ }); // pluginTrustMessage: future MCP SDK field for trust display
52
56
  const client = getClient();
53
57
  // Tool loading tiers:
54
58
  // 1. Core tools (always loaded): get_context, search, find_files, get_brief, etc.
@@ -276,7 +280,7 @@ export function createServer() {
276
280
  // ============================================================
277
281
  // ── CORE tool: always loaded, used at every session start ──────────────
278
282
  // Tool: merlin_get_brief
279
- server.tool('merlin_get_brief', 'Get structured project brief at session start. Returns ~500-token summary covering product purpose, tech stack, architecture, active tasks, shipped APIs, and coding rules. Call after selecting a repo to orient yourself before coding, planning, or reviewing.', {
283
+ server.tool('merlin_get_brief', 'CALL AFTER merlin_get_selected_repo to orient yourself. Returns ~500-token project brief: product purpose, tech stack, architecture pattern, service map, active tasks (in-progress/pending/completed counts), shipped APIs you must not duplicate, and top coding rules. Use at session start, before planning a new feature, or when joining an unfamiliar project.', {
280
284
  repoUrl: z.string().optional().describe('GitHub URL of the repository (uses selected repo if omitted)'),
281
285
  }, async ({ repoUrl }) => {
282
286
  try {
@@ -407,7 +411,7 @@ export function createServer() {
407
411
  });
408
412
  // ── CORE tool: MANDATORY before every file edit or code modification ────
409
413
  // Tool: merlin_get_context
410
- server.tool('merlin_get_context', `MANDATORY before every file edit, code modification, or feature implementation. Call before EACH file you modify — not just once per session. Returns codebase conventions, relevant file locations, how-to guide, anti-patterns, and auto-apply behavior patterns for the given task. Without this, you WILL duplicate existing code or break established patterns. Re-call every few minutes — the codebase changes. Works in both cloud (Sights) and local Lite mode.`, {
414
+ server.tool('merlin_get_context', `MANDATORY before every file edit, code modification, or feature implementation. Call before EACH file you modify. Returns: codebase conventions, relevant file paths with exports, step-by-step how-to guide, anti-patterns to avoid, auto-apply behavior patterns, language-specific rules (TypeScript/Python/Go/etc.), and current project blockers. Without this you WILL duplicate existing code or violate established patterns. Re-call every few minutes — the codebase changes. Works in both cloud (Sights) and offline Lite mode.`, {
411
415
  task: z.string().describe('What you want to know or do (e.g., "how does profile creation work", "add authentication", "where is the payment logic")'),
412
416
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
413
417
  }, async ({ task, repoUrl }) => {
@@ -620,7 +624,7 @@ export function createServer() {
620
624
  });
621
625
  // ── CORE tool: always loaded, used before reading or modifying any file ─
622
626
  // Tool: merlin_find_files
623
- server.tool('merlin_find_files', 'Find files by purpose, description, or architectural layer (routes, services, models, utils, components, hooks, middleware, etc.). Returns file paths, exports, and what to modify for specific tasks. Call BEFORE creating new files to check if something similar already exists. ALWAYS re-fetch before editing — files may have changed. Use this to locate existing functions before adding duplicates.', {
627
+ server.tool('merlin_find_files', 'Find files by purpose, description, or architectural layer. Call BEFORE creating any new file to check if something similar already exists. Returns file paths, exports, dependencies, and which files to modify for a given task. Supports layer filters: routes, services, models, utils, components, hooks, middleware, config, tests. Always re-fetch before editing — files may have moved. Use to locate existing functions before adding duplicates.', {
624
628
  query: z.string().describe('What you are looking for (e.g., "authentication", "database models", "API routes", "payment handling")'),
625
629
  layer: z.string().optional().describe('Filter by layer (routes, services, models, utils, components, etc.)'),
626
630
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
@@ -713,7 +717,7 @@ export function createServer() {
713
717
  });
714
718
  // ── DEFERRED tool: loaded on-demand for style/rule questions ────────────
715
719
  // Tool: merlin_get_conventions
716
- server.tool('merlin_get_conventions', 'Get all coding conventions, anti-patterns, style rules, naming guidelines, and change guides for the repository. Use when reviewing code quality, enforcing standards, understanding what patterns to avoid, or learning how to make specific types of changes. Returns category-organized rules with examples and example files.', {
720
+ server.tool('merlin_get_conventions', 'Get ALL coding conventions, anti-patterns, style rules, naming guidelines, and step-by-step change guides for the codebase. Returns rules organized by category (naming, structure, error handling, testing, etc.) with code examples and example files. Use when reviewing code quality, auditing for style violations, understanding what patterns to avoid, or learning the full rulebook before a major refactor.', {
717
721
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
718
722
  }, async ({ repoUrl }) => {
719
723
  try {
@@ -809,7 +813,7 @@ export function createServer() {
809
813
  });
810
814
  // ── DEFERRED tool: loaded on-demand for onboarding/orientation ──────────
811
815
  // Tool: merlin_quickstart
812
- server.tool('merlin_quickstart', 'Get a 60-second overview and onboarding guide for the codebase. Returns the project quickstart document covering repo structure, entry points, dev commands, and key concepts. Use when first working with an unfamiliar repository, introducing a new team member, or needing a fast orientation without digging into code.', {
816
+ server.tool('merlin_quickstart', 'Get a 60-second onboarding guide for a new contributor or agent. Returns the project quickstart document: repo folder structure, entry points, development commands (install/build/test/run), environment setup, key concepts, and where to start. Use when first encountering an unfamiliar codebase, onboarding a new team member, or needing a fast orientation without reading the code.', {
813
817
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
814
818
  }, async ({ repoUrl }) => {
815
819
  try {
@@ -867,7 +871,7 @@ export function createServer() {
867
871
  });
868
872
  // ── CORE tool: always loaded, used for searching documentation ──────────
869
873
  // Tool: merlin_search
870
- server.tool('merlin_search', 'Search project documentation, wiki, and knowledge base by keyword or concept. Returns matching documentation sections, guides, and explanations that update in real-time as the team commits code. Use to find API docs, architecture notes, setup instructions, or any documented behavior. Complements merlin_get_context for targeted keyword search. Wiki updates in real-time always fetch fresh.', {
874
+ server.tool('merlin_search', 'Keyword search across project documentation, wiki, architecture notes, API docs, and knowledge base. Returns matching doc sections with real-time content from the latest commit. Use to find specific functions, API endpoints, configuration options, architecture decisions, or any documented behavior. Complement to merlin_get_context — use this for targeted keyword lookup when you know what you\'re searching for.', {
871
875
  query: z.string().describe('What you want to find (e.g., "profile creation flow", "authentication", "payment API")'),
872
876
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
873
877
  }, async ({ query, repoUrl }) => {
@@ -919,7 +923,7 @@ export function createServer() {
919
923
  });
920
924
  // ── DEFERRED tool: loaded on-demand for listing available Sights ─────────
921
925
  // Tool: merlin_list_repos
922
- server.tool('merlin_list_repos', 'List all repositories you have connected and analyzed on Merlin Sights. Returns repo names, GitHub URLs, analysis status (completed/pending/failed), and creation dates. Use to discover which Sights are available, find the URL for merlin_select_repo, or audit your connected repositories.', {}, async () => {
926
+ server.tool('merlin_list_repos', 'List all repositories you have connected and analyzed on Merlin Sights. Returns repo names, GitHub URLs, analysis status (ready/processing/queued/incomplete), and last-analyzed dates. Use to discover which Sights are available, find the correct URL for merlin_select_repo, or audit your connected repositories.', {}, async () => {
923
927
  try {
924
928
  const repos = await client.getRepositories();
925
929
  if (repos.length === 0) {
@@ -983,7 +987,7 @@ export function createServer() {
983
987
  });
984
988
  // ── CORE tool: always loaded, used to connect a specific repo ───────────
985
989
  // Tool: merlin_select_repo
986
- server.tool('merlin_select_repo', 'Explicitly select which Merlin Sight (analyzed repository) to use for this session. Overrides auto-detection from git remote. Call when auto-detection picks the wrong repo, when working on a repo with multiple remotes, or when the auto-detected repo is not connected to Sights. Takes a GitHub URL and sets it as the active Sight for all subsequent tool calls.', {
990
+ server.tool('merlin_select_repo', 'Explicitly select which Merlin Sight (analyzed repository) to use for this session. Overrides auto-detection from git remote. Call when: auto-detection picks the wrong repo, working with multiple remotes, the auto-detected repo is not in Sights, or you want to pin a specific Sight. Sets the active repository for ALL subsequent tool calls in this session.', {
987
991
  repoUrl: z.string().describe('GitHub URL of the repository to use (e.g., "github.com/user/repo" or full URL)'),
988
992
  projectDir: z.string().optional().describe('Local project directory path (helps when auto-detection fails). Get via Bash(pwd).'),
989
993
  }, async ({ repoUrl, projectDir }) => {
@@ -1074,7 +1078,7 @@ export function createServer() {
1074
1078
  });
1075
1079
  // ── CORE tool: MANDATORY first call at every session start ──────────────
1076
1080
  // Tool: merlin_get_selected_repo
1077
- server.tool('merlin_get_selected_repo', 'CALL THIS FIRST at every session start. Connects to Merlin Sights, auto-detects the current repository from git remote, returns repository info (name, URL, analysis status), available Sights list, and repo root path for file operations. Must be called before any other Merlin tool. Without this, context tools cannot resolve the correct codebase.', {}, async () => {
1081
+ server.tool('merlin_get_selected_repo', 'CALL THIS FIRST at every session start — required before all other Merlin tools. Connects to Merlin Sights, auto-detects the current repository from git remote, returns: repository name + URL, analysis status, available Sights list, absolute repo root path for Glob/file operations, and session stats. Without this call, context tools cannot resolve the correct codebase.', {}, async () => {
1078
1082
  // Mark session status as shown - this is the required first call
1079
1083
  markSessionStatusShown();
1080
1084
  recordToolCall('merlin_get_selected_repo');
@@ -1206,7 +1210,7 @@ export function createServer() {
1206
1210
  });
1207
1211
  // ── DEFERRED tool: loaded on-demand for polling analysis completion ──────
1208
1212
  if (hasCloudApi && !coreOnly) { // Tool: merlin_check_repo_status
1209
- server.tool('merlin_check_repo_status', 'Poll whether a repository analysis is complete after calling merlin_connect_repo. Returns status: pending, analyzing, completed, or failed, plus estimated time remaining. Use in a loop with 30-second intervals after connecting a new repo until status is "completed" before using context tools.', {
1213
+ server.tool('merlin_check_repo_status', 'Poll whether a repository analysis is complete after calling merlin_connect_repo. Returns status (pending/analyzing/completed/locked/failed) and next action. Use in a loop with 30-second intervals after connecting a new repo until "completed", then use merlin_get_context normally. Auto-unlocks locked repos if tokens are available.', {
1210
1214
  repoUrl: z.string().optional().describe('GitHub URL of the repository (uses selected repo if omitted)'),
1211
1215
  }, async ({ repoUrl }) => {
1212
1216
  try {
@@ -1309,7 +1313,7 @@ export function createServer() {
1309
1313
  } // end cloud: merlin_check_repo_status
1310
1314
  // ── DEFERRED tool: loaded on-demand for onboarding new repositories ──────
1311
1315
  // Tool: merlin_connect_repo
1312
- server.tool('merlin_connect_repo', 'Connect and submit a new GitHub repository to Merlin Sights for analysis and indexing. Use when working on a repo not yet in Sights — analysis takes 2-5 minutes. After connecting, poll with merlin_check_repo_status until completed, then use merlin_get_context and merlin_find_files as normal.', {
1316
+ server.tool('merlin_connect_repo', 'Submit a new GitHub repository to Merlin Sights for analysis and indexing. Use when working on a repo not yet connected to Sights — analysis takes 2-5 minutes. After connecting, poll merlin_check_repo_status until status is "completed", then use merlin_get_context and merlin_find_files normally. Also writes .merlin.json and updates CLAUDE.md in the local repo.', {
1313
1317
  repoUrl: z.string().describe('GitHub URL of the repository (e.g., "https://github.com/user/repo")'),
1314
1318
  branch: z.string().optional().default('main').describe('Branch to analyze (default: main)'),
1315
1319
  }, async ({ repoUrl, branch }) => {
@@ -1484,7 +1488,7 @@ export function createServer() {
1484
1488
  });
1485
1489
  // ── DEFERRED tool: loaded on-demand for change impact assessment ─────────
1486
1490
  // Tool: merlin_impact_analysis
1487
- server.tool('merlin_impact_analysis', 'Analyze what could break if you modify a specific file. Returns all dependent files, importers, and downstream consumers that may need updates. Use before refactoring, renaming exports, changing function signatures, or modifying shared utilities to prevent cascading breakage.', {
1491
+ server.tool('merlin_impact_analysis', 'Analyze what could break if you modify a specific file. Returns all dependent files, importers, and downstream consumers that need updates. Use before refactoring, renaming exports, changing function signatures, or modifying shared utilities prevents cascading breakage by showing the full dependency graph.', {
1488
1492
  filePath: z.string().describe('The file path you plan to modify (e.g., "src/services/user.ts")'),
1489
1493
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
1490
1494
  }, async ({ filePath, repoUrl }) => {
@@ -1515,7 +1519,7 @@ export function createServer() {
1515
1519
  });
1516
1520
  // ── DEFERRED tool: loaded on-demand for finding existing patterns ─────────
1517
1521
  if (hasCloudApi && !coreOnly) { // Tool: merlin_similar_code
1518
- server.tool('merlin_similar_code', 'Find similar existing implementations in the codebase before writing new code. Returns matching patterns, functions, or components already built that serve similar purposes. Use when implementing anything new — there is likely an existing pattern to follow or extend. Prevents duplicating code and enforces DRY principles.', {
1522
+ server.tool('merlin_similar_code', 'Find existing implementations in the codebase that match what you\'re about to build. Returns matching functions, components, or patterns already in production. Use before writing any new code prevents duplication, enforces DRY. Complements merlin_find_files with semantic similarity matching rather than layer/purpose filtering.', {
1519
1523
  description: z.string().describe('What you\'re trying to implement (e.g., "API endpoint with authentication", "database query with pagination", "React form with validation")'),
1520
1524
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
1521
1525
  }, async ({ description, repoUrl }) => {
@@ -1547,7 +1551,7 @@ export function createServer() {
1547
1551
  } // end cloud: merlin_similar_code
1548
1552
  // ── DEFERRED tool: loaded on-demand for getting real code patterns ────────
1549
1553
  if (hasCloudApi && !coreOnly) { // Tool: merlin_code_examples
1550
- server.tool('merlin_code_examples', 'Get real code examples extracted from this codebase for specific tasks. Returns actual patterns, templates, and snippets used in production. Use when you need to see how a pattern is really implemented (not just described) — e.g., "add endpoint", "add test", "error handling", "database query".', {
1554
+ server.tool('merlin_code_examples', 'Get real production code examples extracted from this codebase for a specific task type. Returns actual patterns, templates, and snippets. Use when you need to see how something is really implemented not just described — e.g., "add API endpoint", "write a test", "error handling pattern", "database query with pagination", "React form with validation".', {
1551
1555
  task: z.string().optional().describe('Specific task (e.g., "add endpoint", "add test", "error handling"). Leave empty for all examples.'),
1552
1556
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
1553
1557
  }, async ({ task, repoUrl }) => {
@@ -1579,7 +1583,7 @@ export function createServer() {
1579
1583
  } // end cloud: merlin_code_examples
1580
1584
  // ── DEFERRED tool: loaded on-demand for natural language codebase Q&A ──
1581
1585
  // Tool: merlin_ask
1582
- server.tool('merlin_ask', 'Ask any natural language question about the codebase and get an AI-generated answer with source citations. Uses semantic search and RAG to find relevant context across documentation, code, and conventions. Use when you need a direct answer with explanation rather than raw files — e.g., "how does authentication work?", "where is billing handled?", "where should I add a new API endpoint?", "why is X structured this way?".', {
1586
+ server.tool('merlin_ask', 'Ask a natural language question about the codebase and get an AI-generated answer with source citations. Uses semantic search + RAG across docs, code, conventions, and history. Use when you need a direct explanation rather than raw file paths — e.g., "how does authentication work?", "where is billing handled?", "where should I add a new API endpoint?", "why does X exist?". Returns answer with high/medium relevance sources.', {
1583
1587
  question: z.string().describe('Your question in natural language (e.g., "How does the payment flow work?", "Where is user validation handled?", "What patterns are used for error handling?")'),
1584
1588
  quick: z.boolean().optional().default(false).describe('If true, returns a faster but shorter answer without detailed sources'),
1585
1589
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
@@ -1648,7 +1652,7 @@ export function createServer() {
1648
1652
  // ============================================================
1649
1653
  // ── DEFERRED tool: loaded on-demand for persisting cross-session data ────
1650
1654
  // Tool: merlin_write_state
1651
- server.tool('merlin_write_state', 'Persist arbitrary state to Merlin cloud storage for cross-session and cross-agent memory. Use to save project artifacts (PROJECT.md, ROADMAP.md, STATE.md), planning data, decisions, agent outputs, or any data that needs to survive context resets. Supports optimistic locking via version parameter to prevent concurrent overwrites.', {
1655
+ server.tool('merlin_write_state', 'Persist arbitrary state to Merlin cloud storage for cross-session and cross-agent memory. Save project artifacts (PROJECT.md content, ROADMAP.md, STATE.md), decisions, agent outputs, or any data that must survive context resets or agent handoffs. Supports optimistic locking via version parameter to prevent concurrent overwrites.', {
1652
1656
  key: z.string().describe('State key (e.g., "project", "roadmap", "state", "phase_3")'),
1653
1657
  value: z.any().describe('The state data to store (will be JSON serialized)'),
1654
1658
  agentId: z.string().optional().describe('Agent identifier for tracking who wrote the state'),
@@ -1707,7 +1711,7 @@ export function createServer() {
1707
1711
  });
1708
1712
  // ── DEFERRED tool: loaded on-demand for restoring cross-session data ─────
1709
1713
  // Tool: merlin_read_state
1710
- server.tool('merlin_read_state', 'Read previously persisted state from Merlin cloud storage. Use to restore cross-session memory like PROJECT.md, ROADMAP.md, STATE.md, agent outputs, or any data saved with merlin_write_state. Returns the stored value and metadata (version, last updated, written by).', {
1714
+ server.tool('merlin_read_state', 'Read previously persisted state from Merlin cloud storage by key. Restores cross-session memory: PROJECT.md content, ROADMAP.md, STATE.md, agent outputs, or any data saved with merlin_write_state. Returns the stored value plus metadata (version number, last updated timestamp, written-by agent).', {
1711
1715
  key: z.string().describe('State key to read (e.g., "project", "roadmap", "state")'),
1712
1716
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
1713
1717
  }, async ({ key, repoUrl }) => {
@@ -1751,7 +1755,7 @@ export function createServer() {
1751
1755
  });
1752
1756
  // ── DEFERRED tool: loaded on-demand for auditing stored state ─────────────
1753
1757
  // Tool: merlin_list_state
1754
- server.tool('merlin_list_state', 'List all state keys stored in Merlin cloud for this repository. Returns key names, last-updated timestamps, and sizes. Use to discover what cross-session memory is available (PROJECT.md, ROADMAP.md, checkpoints, agent outputs, etc.) before reading specific keys with merlin_read_state.', {
1758
+ server.tool('merlin_list_state', 'List all state keys stored in Merlin cloud for this repository. Returns key names, last-updated timestamps, version numbers, and sizes. Use to discover what cross-session memory exists (PROJECT.md, ROADMAP.md, checkpoints, agent outputs, etc.) before calling merlin_read_state for specific keys.', {
1755
1759
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
1756
1760
  }, async ({ repoUrl }) => {
1757
1761
  try {
@@ -1797,7 +1801,7 @@ export function createServer() {
1797
1801
  });
1798
1802
  // ── DEFERRED tool: loaded on-demand for team activity logging ─────────────
1799
1803
  if (hasCloudApi && !coreOnly) { // Tool: merlin_log_activity
1800
- server.tool('merlin_log_activity', 'Log an activity event to the shared team timeline for audit trail and visibility. Use to record task completions, phase transitions, milestone achievements, decisions made, or any significant progress event. Events appear on the Merlin dashboard team timeline for coordination.', {
1804
+ server.tool('merlin_log_activity', 'Log an activity event to the shared team timeline for audit trail, progress visibility, and coordination. Records task completions, phase transitions, milestone achievements, decisions, or any significant event. Events appear on the Merlin dashboard. Use for team handoff visibility and autonomous loop tracking.', {
1801
1805
  eventType: z.string().describe('Event type (e.g., "phase_started", "task_completed", "blocker_hit", "decision_made")'),
1802
1806
  eventData: z.any().optional().describe('Additional event data (JSON object)'),
1803
1807
  agentId: z.string().describe('Agent identifier for tracking'),
@@ -1847,7 +1851,7 @@ export function createServer() {
1847
1851
  } // end cloud: merlin_log_activity
1848
1852
  // ── DEFERRED tool: loaded on-demand for syncing task state to cloud ───────
1849
1853
  if (hasCloudApi && !coreOnly) { // Tool: merlin_sync_task
1850
- server.tool('merlin_sync_task', 'Sync a task (create or update) to Merlin cloud for team visibility and cross-agent coordination. Use to track work items with status (pending/in_progress/completed/blocked), dependencies (blockedBy/blocks), phase, plan, and owner agent. Tasks appear on the Merlin dashboard and can be queried by other agents.', {
1854
+ server.tool('merlin_sync_task', 'Create or update a task in Merlin cloud for team visibility and cross-agent coordination. Track work items with status (pending/in_progress/completed/blocked), blockedBy/blocks dependencies, phase, plan, owner agent, and affected files. Tasks appear on the Merlin dashboard backlog and are queryable by all agents.', {
1851
1855
  title: z.string().describe('Task title'),
1852
1856
  status: z.enum(['pending', 'in_progress', 'completed', 'blocked', 'skipped']).optional().describe('Task status'),
1853
1857
  description: z.string().optional().describe('Task description'),
@@ -1915,7 +1919,7 @@ export function createServer() {
1915
1919
  } // end cloud: merlin_sync_task
1916
1920
  // ── DEFERRED tool: loaded on-demand for viewing cloud task state ──────────
1917
1921
  if (hasCloudApi && !coreOnly) { // Tool: merlin_get_tasks
1918
- server.tool('merlin_get_tasks', 'Retrieve tasks synced to Merlin cloud. Filter by status (pending/in_progress/completed/blocked), phase, or plan. Returns work items from all agents for team coordination and planning. Use to see what tasks exist before creating duplicates, check what others are working on, or audit overall progress.', {
1922
+ server.tool('merlin_get_tasks', 'Retrieve the team task backlog from Merlin cloud. Filter by status (pending/in_progress/completed/blocked), phase, or plan. Returns all work items across all agents. Use to audit what tasks exist before creating duplicates, check what others are working on, or get an overview of backlog progress.', {
1919
1923
  status: z.string().optional().describe('Filter by status (pending, in_progress, completed, blocked)'),
1920
1924
  phase: z.string().optional().describe('Filter by phase'),
1921
1925
  plan: z.string().optional().describe('Filter by plan'),
@@ -1979,7 +1983,7 @@ export function createServer() {
1979
1983
  } // end cloud: merlin_get_tasks
1980
1984
  // ── DEFERRED tool: loaded on-demand for escalating blockers to humans ────
1981
1985
  if (hasCloudApi && !coreOnly) { // Tool: merlin_report_blocker
1982
- server.tool('merlin_report_blocker', 'Report a blocker or impediment that requires human attention, decision, or external action. Creates a visible alert on the team dashboard with severity level and context. Use when you hit an auth requirement, need a human decision point, encounter a critical error you cannot resolve, or need clarification before proceeding. Types: human_verify, auth_required, clarification, decision_point, external, error.', {
1986
+ server.tool('merlin_report_blocker', 'Report a blocker requiring human attention, decision, or external action. Creates a visible alert on the team dashboard with severity level and full context. Use when: you need a human to verify something, auth credentials are required, a decision point is reached, or a critical unresolvable error is hit. Types: human_verify, auth_required, clarification, decision_point, external, error.', {
1983
1987
  title: z.string().describe('Brief description of the blocker'),
1984
1988
  blockerType: z.enum(['human_verify', 'auth_required', 'clarification', 'decision_point', 'external', 'error', 'other']).describe('Type of blocker'),
1985
1989
  description: z.string().optional().describe('Detailed description'),
@@ -2033,7 +2037,7 @@ export function createServer() {
2033
2037
  } // end cloud: merlin_report_blocker
2034
2038
  // ── DEFERRED tool: loaded on-demand for checking pending blockers ─────────
2035
2039
  if (hasCloudApi && !coreOnly) { // Tool: merlin_get_blockers
2036
- server.tool('merlin_get_blockers', 'Get open blockers or impediments awaiting resolution. Returns blockers reported by any agent with status, severity, type, and context. Check at session start or before starting work to see if there are critical issues or human-required decisions pending. Filter by status: open, resolved, or all.', {
2040
+ server.tool('merlin_get_blockers', 'Get open blockers or impediments awaiting resolution. Returns blockers reported by any agent: status, severity, type, and context. Use at session start or before beginning autonomous work to check for critical unresolved issues or pending human decisions. Filter by open, resolved, or all.', {
2037
2041
  status: z.string().optional().default('open').describe('Filter by status (open, resolved, all)'),
2038
2042
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
2039
2043
  }, async ({ status, repoUrl }) => {
@@ -2086,7 +2090,7 @@ export function createServer() {
2086
2090
  } // end cloud: merlin_get_blockers
2087
2091
  // ── DEFERRED tool: loaded on-demand for human-in-the-loop checkpoints ────
2088
2092
  if (hasCloudApi && !coreOnly) { // Tool: merlin_create_checkpoint
2089
- server.tool('merlin_create_checkpoint', 'Create a verification checkpoint that signals a human review is needed before work continues. Use for human_verify, auth_gate, decision_point, approval, or review situations. Includes a summary of what was built and a checklist of items for the human to verify. The checkpoint appears on the dashboard and can be resolved to resume work.', {
2093
+ server.tool('merlin_create_checkpoint', 'Create a human-review checkpoint before autonomous work continues. Signals that a human must verify, approve, or make a decision before proceeding. Includes what was built, a verification checklist, and resume context. Types: human_verify, auth_gate, decision_point, approval, review. Checkpoint appears on the dashboard and pauses the agent loop.', {
2090
2094
  title: z.string().describe('Checkpoint title'),
2091
2095
  checkpointType: z.enum(['human_verify', 'auth_gate', 'decision_point', 'approval', 'review']).describe('Type of checkpoint'),
2092
2096
  description: z.string().optional().describe('Detailed description'),
@@ -2146,7 +2150,7 @@ export function createServer() {
2146
2150
  } // end cloud: merlin_create_checkpoint
2147
2151
  // ── DEFERRED tool: loaded on-demand for team coordination overview ────────
2148
2152
  if (hasCloudApi && !coreOnly) { // Tool: merlin_get_team_state
2149
- server.tool('merlin_get_team_state', 'Get consolidated team coordination state: active agent sessions, pending human checkpoints, open blockers, task summary counts (pending/in-progress/completed), and saved planning artifacts. Use at session start to see what other agents are working on, what decisions are pending, and what state is available for resuming work.', {
2153
+ server.tool('merlin_get_team_state', 'Get consolidated team coordination snapshot: active agent sessions, pending human checkpoints, open blockers, task summary counts (pending/in-progress/completed), and saved planning artifacts. Use at session start to see what other agents are doing, what decisions are pending, and what state is ready to resume.', {
2150
2154
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
2151
2155
  }, async ({ repoUrl }) => {
2152
2156
  try {
@@ -2242,7 +2246,7 @@ export function createServer() {
2242
2246
  } // end cloud: merlin_get_team_state
2243
2247
  // ── DEFERRED tool: loaded on-demand for session lifecycle management ──────
2244
2248
  if (hasCloudApi && !coreOnly) { // Tool: merlin_update_session
2245
- server.tool('merlin_update_session', 'Update your current session status and progress metadata for team visibility and pause/resume support. Records current phase, plan, task, completion count, and health score. Use to mark your session as active/paused/completed and track progress so other agents or humans can see where you are in the workflow.', {
2249
+ server.tool('merlin_update_session', 'Update session status and progress metadata for team visibility and pause/resume coordination. Records current phase, plan, task, completion count, and pause reason. Use to mark session as active/paused/completed so other agents and humans can see progress. Supports autonomous loop handoff — call with resumeContext before pausing.', {
2246
2250
  sessionId: z.string().describe('Unique session identifier'),
2247
2251
  agentId: z.string().describe('Agent identifier'),
2248
2252
  status: z.enum(['active', 'paused', 'completed', 'abandoned']).optional().describe('Session status'),
@@ -2306,7 +2310,7 @@ export function createServer() {
2306
2310
  // CODING RULES
2307
2311
  // ============================================================
2308
2312
  if (hasCloudApi && !coreOnly) { // Tool: merlin_save_rule
2309
- server.tool('merlin_save_rule', 'Save a coding rule or preference to Merlin. Rules are returned with every context query and must be followed. Use when user expresses a preference that should persist.', {
2313
+ server.tool('merlin_save_rule', 'Save a project-level coding rule that persists across sessions and is returned with every context query. Use when a user expresses a preference that should always be followed — e.g., "max 400 lines per file", "always use async/await", "no console.log in production". Categorize as: file_size, testing, style, patterns, or custom.', {
2310
2314
  rule: z.string().describe('The rule to save (e.g., "max 400 lines per file", "always use async/await", "no console.log in production")'),
2311
2315
  category: z.enum(['file_size', 'testing', 'style', 'patterns', 'custom']).optional().default('custom').describe('Rule category for organization'),
2312
2316
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
@@ -2367,7 +2371,7 @@ export function createServer() {
2367
2371
  });
2368
2372
  } // end cloud: merlin_save_rule
2369
2373
  if (hasCloudApi && !coreOnly) { // Tool: merlin_get_rules
2370
- server.tool('merlin_get_rules', 'Get all coding rules for this project. Returns rules that must be followed when writing code.', {
2374
+ server.tool('merlin_get_rules', 'Get all project-level coding rules organized by category (file_size, testing, style, patterns, custom). These rules are injected into every context query. Use to audit existing rules before adding new ones, or to review what constraints the user has set.', {
2371
2375
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
2372
2376
  }, async ({ repoUrl }) => {
2373
2377
  try {
@@ -2416,7 +2420,7 @@ export function createServer() {
2416
2420
  });
2417
2421
  } // end cloud: merlin_get_rules
2418
2422
  if (hasCloudApi && !coreOnly) { // Tool: merlin_remove_rule
2419
- server.tool('merlin_remove_rule', 'Remove a coding rule from this project.', {
2423
+ server.tool('merlin_remove_rule', 'Remove a project-level coding rule by its exact text. Call merlin_get_rules first to see all current rules and find the exact text to remove.', {
2420
2424
  rule: z.string().describe('The exact rule text to remove'),
2421
2425
  repoUrl: z.string().optional().describe('GitHub URL of the repository (auto-detected from git if omitted)'),
2422
2426
  }, async ({ rule, repoUrl }) => {
@@ -2613,6 +2617,26 @@ export function createServer() {
2613
2617
  });
2614
2618
  } // end cloud: registerAgentsIndexTools
2615
2619
  // ============================================================
2620
+ if (!coreOnly) {
2621
+ // SESSION RESTORE - Read last session summary for continuity (local, no cloud needed)
2622
+ // ============================================================
2623
+ registerSessionRestoreTools({
2624
+ server,
2625
+ client,
2626
+ resolveRepoId,
2627
+ });
2628
+ } // end free: registerSessionRestoreTools
2629
+ // ============================================================
2630
+ if (!coreOnly) {
2631
+ // SESSION SEARCH - Keyword search across session history (local, no cloud needed)
2632
+ // ============================================================
2633
+ registerSessionSearchTools({
2634
+ server,
2635
+ client,
2636
+ resolveRepoId,
2637
+ });
2638
+ } // end free: registerSessionSearchTools
2639
+ // ============================================================
2616
2640
  if (!coreOnly) {
2617
2641
  // LITE MODE TOOLS - Local file-based context for small repos (always available)
2618
2642
  // ============================================================
@@ -2638,6 +2662,26 @@ export function createServer() {
2638
2662
  },
2639
2663
  });
2640
2664
  } // end cloud: registerConfigSyncTools
2665
+ // ============================================================
2666
+ if (hasCloudApi && !coreOnly) {
2667
+ // BEHAVIOR PROMOTION - Evolve learned behaviors into reusable skills
2668
+ // ============================================================
2669
+ registerPromoteTools({
2670
+ server,
2671
+ client,
2672
+ resolveRepoId,
2673
+ });
2674
+ } // end cloud: registerPromoteTools
2675
+ // ============================================================
2676
+ // PROMPT LEARNING ENGINE - RL-inspired agent effectiveness analysis
2677
+ // DEFERRED: loaded on-demand via /merlin:optimize-prompts
2678
+ // Works locally from outcomes.jsonl — no cloud API required
2679
+ // ============================================================
2680
+ registerLearningTools({
2681
+ server,
2682
+ client,
2683
+ resolveRepoId,
2684
+ });
2641
2685
  return server;
2642
2686
  }
2643
2687
  /** Start the MCP server with stdio transport */