@shrkcrft/mcp-server 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (189) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -0
  4. package/dist/server/columnar-format.d.ts +34 -0
  5. package/dist/server/columnar-format.d.ts.map +1 -0
  6. package/dist/server/columnar-format.js +95 -0
  7. package/dist/server/create-mcp-server.d.ts +3 -0
  8. package/dist/server/create-mcp-server.d.ts.map +1 -1
  9. package/dist/server/create-mcp-server.js +24 -9
  10. package/dist/server/fit-array-to-budget.d.ts +24 -0
  11. package/dist/server/fit-array-to-budget.d.ts.map +1 -0
  12. package/dist/server/fit-array-to-budget.js +60 -0
  13. package/dist/server/serialize-tool-data.d.ts +15 -0
  14. package/dist/server/serialize-tool-data.d.ts.map +1 -0
  15. package/dist/server/serialize-tool-data.js +22 -0
  16. package/dist/server/tool-definition.d.ts +15 -0
  17. package/dist/server/tool-definition.d.ts.map +1 -1
  18. package/dist/server/tool-input-validators.d.ts.map +1 -1
  19. package/dist/server/tool-input-validators.js +43 -0
  20. package/dist/tools/agent-brief.tool.d.ts.map +1 -1
  21. package/dist/tools/agent-brief.tool.js +20 -0
  22. package/dist/tools/align-cache.tool.d.ts +11 -0
  23. package/dist/tools/align-cache.tool.d.ts.map +1 -0
  24. package/dist/tools/align-cache.tool.js +76 -0
  25. package/dist/tools/all-tools.d.ts.map +1 -1
  26. package/dist/tools/all-tools.js +72 -7
  27. package/dist/tools/architecture-map.tool.d.ts.map +1 -1
  28. package/dist/tools/architecture-map.tool.js +4 -2
  29. package/dist/tools/code-find-usages.tool.d.ts +16 -0
  30. package/dist/tools/code-find-usages.tool.d.ts.map +1 -0
  31. package/dist/tools/code-find-usages.tool.js +180 -0
  32. package/dist/tools/command-catalog.tool.d.ts.map +1 -1
  33. package/dist/tools/command-catalog.tool.js +11 -7
  34. package/dist/tools/compress-context.tool.d.ts +8 -0
  35. package/dist/tools/compress-context.tool.d.ts.map +1 -0
  36. package/dist/tools/compress-context.tool.js +81 -0
  37. package/dist/tools/dashboard-summary.tool.d.ts.map +1 -1
  38. package/dist/tools/dashboard-summary.tool.js +2 -4
  39. package/dist/tools/delegate-task.tool.d.ts +3 -0
  40. package/dist/tools/delegate-task.tool.d.ts.map +1 -0
  41. package/dist/tools/delegate-task.tool.js +94 -0
  42. package/dist/tools/deps-audit.tool.d.ts +10 -0
  43. package/dist/tools/deps-audit.tool.d.ts.map +1 -0
  44. package/dist/tools/deps-audit.tool.js +251 -0
  45. package/dist/tools/diff-check.tool.d.ts +15 -0
  46. package/dist/tools/diff-check.tool.d.ts.map +1 -0
  47. package/dist/tools/diff-check.tool.js +157 -0
  48. package/dist/tools/file-advice.tool.d.ts +22 -0
  49. package/dist/tools/file-advice.tool.d.ts.map +1 -0
  50. package/dist/tools/file-advice.tool.js +88 -0
  51. package/dist/tools/get-api-surface-diff.tool.d.ts +3 -0
  52. package/dist/tools/get-api-surface-diff.tool.d.ts.map +1 -0
  53. package/dist/tools/get-api-surface-diff.tool.js +60 -0
  54. package/dist/tools/get-arch-violations.tool.d.ts +3 -0
  55. package/dist/tools/get-arch-violations.tool.d.ts.map +1 -0
  56. package/dist/tools/get-arch-violations.tool.js +30 -0
  57. package/dist/tools/get-code-intelligence-state.tool.d.ts +11 -0
  58. package/dist/tools/get-code-intelligence-state.tool.d.ts.map +1 -0
  59. package/dist/tools/get-code-intelligence-state.tool.js +60 -0
  60. package/dist/tools/get-context-pack.tool.d.ts +3 -0
  61. package/dist/tools/get-context-pack.tool.d.ts.map +1 -0
  62. package/dist/tools/get-context-pack.tool.js +40 -0
  63. package/dist/tools/get-framework-entities.tool.d.ts +3 -0
  64. package/dist/tools/get-framework-entities.tool.d.ts.map +1 -0
  65. package/dist/tools/get-framework-entities.tool.js +68 -0
  66. package/dist/tools/get-graph-callers.tool.d.ts +3 -0
  67. package/dist/tools/get-graph-callers.tool.d.ts.map +1 -0
  68. package/dist/tools/get-graph-callers.tool.js +94 -0
  69. package/dist/tools/get-graph-context.tool.d.ts +3 -0
  70. package/dist/tools/get-graph-context.tool.d.ts.map +1 -0
  71. package/dist/tools/get-graph-context.tool.js +125 -0
  72. package/dist/tools/get-graph-cycles.tool.d.ts +10 -0
  73. package/dist/tools/get-graph-cycles.tool.d.ts.map +1 -0
  74. package/dist/tools/get-graph-cycles.tool.js +58 -0
  75. package/dist/tools/get-graph-deps.tool.d.ts +12 -0
  76. package/dist/tools/get-graph-deps.tool.d.ts.map +1 -0
  77. package/dist/tools/get-graph-deps.tool.js +80 -0
  78. package/dist/tools/get-graph-hubs.tool.d.ts +3 -0
  79. package/dist/tools/get-graph-hubs.tool.d.ts.map +1 -0
  80. package/dist/tools/get-graph-hubs.tool.js +61 -0
  81. package/dist/tools/get-graph-impact-analysis.tool.d.ts +3 -0
  82. package/dist/tools/get-graph-impact-analysis.tool.d.ts.map +1 -0
  83. package/dist/tools/get-graph-impact-analysis.tool.js +44 -0
  84. package/dist/tools/get-graph-impact.tool.d.ts +3 -0
  85. package/dist/tools/get-graph-impact.tool.d.ts.map +1 -0
  86. package/dist/tools/get-graph-impact.tool.js +150 -0
  87. package/dist/tools/get-graph-path.tool.d.ts +3 -0
  88. package/dist/tools/get-graph-path.tool.d.ts.map +1 -0
  89. package/dist/tools/get-graph-path.tool.js +144 -0
  90. package/dist/tools/get-graph-search.tool.d.ts +3 -0
  91. package/dist/tools/get-graph-search.tool.d.ts.map +1 -0
  92. package/dist/tools/get-graph-search.tool.js +95 -0
  93. package/dist/tools/get-graph-status.tool.d.ts +11 -0
  94. package/dist/tools/get-graph-status.tool.d.ts.map +1 -0
  95. package/dist/tools/get-graph-status.tool.js +55 -0
  96. package/dist/tools/get-graph-unresolved.tool.d.ts +11 -0
  97. package/dist/tools/get-graph-unresolved.tool.d.ts.map +1 -0
  98. package/dist/tools/get-graph-unresolved.tool.js +85 -0
  99. package/dist/tools/get-impact-baseline.tool.d.ts +9 -0
  100. package/dist/tools/get-impact-baseline.tool.d.ts.map +1 -0
  101. package/dist/tools/get-impact-baseline.tool.js +65 -0
  102. package/dist/tools/get-intent-benchmark-run.tool.d.ts +12 -0
  103. package/dist/tools/get-intent-benchmark-run.tool.d.ts.map +1 -0
  104. package/dist/tools/get-intent-benchmark-run.tool.js +55 -0
  105. package/dist/tools/get-knowledge-graph.tool.d.ts +7 -0
  106. package/dist/tools/get-knowledge-graph.tool.d.ts.map +1 -1
  107. package/dist/tools/get-knowledge-graph.tool.js +62 -3
  108. package/dist/tools/get-migrations.tool.d.ts +3 -0
  109. package/dist/tools/get-migrations.tool.d.ts.map +1 -0
  110. package/dist/tools/get-migrations.tool.js +70 -0
  111. package/dist/tools/get-pattern-registry.tool.d.ts +8 -0
  112. package/dist/tools/get-pattern-registry.tool.d.ts.map +1 -0
  113. package/dist/tools/get-pattern-registry.tool.js +40 -0
  114. package/dist/tools/get-quality-gate.tool.d.ts +3 -0
  115. package/dist/tools/get-quality-gate.tool.d.ts.map +1 -0
  116. package/dist/tools/get-quality-gate.tool.js +27 -0
  117. package/dist/tools/get-relevant-context.tool.d.ts.map +1 -1
  118. package/dist/tools/get-relevant-context.tool.js +30 -6
  119. package/dist/tools/get-rules-for-file.tool.d.ts +3 -0
  120. package/dist/tools/get-rules-for-file.tool.d.ts.map +1 -0
  121. package/dist/tools/get-rules-for-file.tool.js +54 -0
  122. package/dist/tools/get-structural-rewrite-plan.tool.d.ts +3 -0
  123. package/dist/tools/get-structural-rewrite-plan.tool.d.ts.map +1 -0
  124. package/dist/tools/get-structural-rewrite-plan.tool.js +46 -0
  125. package/dist/tools/get-structural-search.tool.d.ts +3 -0
  126. package/dist/tools/get-structural-search.tool.d.ts.map +1 -0
  127. package/dist/tools/get-structural-search.tool.js +35 -0
  128. package/dist/tools/get-task-packet.tool.d.ts.map +1 -1
  129. package/dist/tools/get-task-packet.tool.js +26 -22
  130. package/dist/tools/graph-staleness.d.ts +34 -0
  131. package/dist/tools/graph-staleness.d.ts.map +1 -0
  132. package/dist/tools/graph-staleness.js +36 -0
  133. package/dist/tools/list-boundary-rules.tool.d.ts.map +1 -1
  134. package/dist/tools/list-boundary-rules.tool.js +20 -16
  135. package/dist/tools/list-knowledge.tool.d.ts.map +1 -1
  136. package/dist/tools/list-knowledge.tool.js +14 -13
  137. package/dist/tools/list-packs.tool.d.ts.map +1 -1
  138. package/dist/tools/list-packs.tool.js +19 -15
  139. package/dist/tools/list-path-conventions.tool.d.ts.map +1 -1
  140. package/dist/tools/list-path-conventions.tool.js +19 -15
  141. package/dist/tools/list-pipelines.tool.d.ts.map +1 -1
  142. package/dist/tools/list-pipelines.tool.js +18 -14
  143. package/dist/tools/list-presets.tool.d.ts.map +1 -1
  144. package/dist/tools/list-presets.tool.js +25 -21
  145. package/dist/tools/list-rules.tool.d.ts.map +1 -1
  146. package/dist/tools/list-rules.tool.js +18 -14
  147. package/dist/tools/list-templates.tool.d.ts.map +1 -1
  148. package/dist/tools/list-templates.tool.js +18 -14
  149. package/dist/tools/plan-quality-review.tool.d.ts +21 -0
  150. package/dist/tools/plan-quality-review.tool.d.ts.map +1 -0
  151. package/dist/tools/plan-quality-review.tool.js +294 -0
  152. package/dist/tools/primary-tools.d.ts +24 -0
  153. package/dist/tools/primary-tools.d.ts.map +1 -0
  154. package/dist/tools/primary-tools.js +86 -0
  155. package/dist/tools/r19-extras.tool.js +1 -1
  156. package/dist/tools/r32-profiles.tool.d.ts +0 -3
  157. package/dist/tools/r32-profiles.tool.d.ts.map +1 -1
  158. package/dist/tools/r32-profiles.tool.js +3 -54
  159. package/dist/tools/retrieve-original.tool.d.ts +9 -0
  160. package/dist/tools/retrieve-original.tool.d.ts.map +1 -0
  161. package/dist/tools/retrieve-original.tool.js +47 -0
  162. package/dist/tools/runtime-reports.tool.d.ts.map +1 -1
  163. package/dist/tools/runtime-reports.tool.js +1 -3
  164. package/dist/tools/safety-audit.tool.d.ts.map +1 -1
  165. package/dist/tools/safety-audit.tool.js +1 -4
  166. package/dist/tools/search-knowledge.tool.d.ts.map +1 -1
  167. package/dist/tools/search-knowledge.tool.js +17 -13
  168. package/dist/tools/search.tool.d.ts.map +1 -1
  169. package/dist/tools/search.tool.js +11 -8
  170. package/dist/tools/smart-context-bundle.tool.d.ts +17 -0
  171. package/dist/tools/smart-context-bundle.tool.d.ts.map +1 -0
  172. package/dist/tools/smart-context-bundle.tool.js +110 -0
  173. package/dist/tools/smart-context-feed.tool.d.ts +17 -0
  174. package/dist/tools/smart-context-feed.tool.d.ts.map +1 -0
  175. package/dist/tools/smart-context-feed.tool.js +138 -0
  176. package/dist/tools/start-here.tool.js +2 -2
  177. package/package.json +28 -16
  178. package/dist/tools/r22-extras.tool.d.ts +0 -4
  179. package/dist/tools/r22-extras.tool.d.ts.map +0 -1
  180. package/dist/tools/r22-extras.tool.js +0 -42
  181. package/dist/tools/r26-ingest.tool.d.ts +0 -10
  182. package/dist/tools/r26-ingest.tool.d.ts.map +0 -1
  183. package/dist/tools/r26-ingest.tool.js +0 -174
  184. package/dist/tools/r28-plugin-lifecycle.tool.d.ts +0 -4
  185. package/dist/tools/r28-plugin-lifecycle.tool.d.ts.map +0 -1
  186. package/dist/tools/r28-plugin-lifecycle.tool.js +0 -94
  187. package/dist/tools/r34-search-unified.tool.d.ts +0 -3
  188. package/dist/tools/r34-search-unified.tool.d.ts.map +0 -1
  189. package/dist/tools/r34-search-unified.tool.js +0 -38
@@ -0,0 +1,65 @@
1
+ import { diffImpactReports, ImpactReportStore, } from '@shrkcrft/impact-engine';
2
+ /**
3
+ * Read-only MCP mirror of `shrk impact baseline show`. Returns the
4
+ * frozen baseline + the most recent run + the delta between them.
5
+ * When either side is missing the response carries a structured hint
6
+ * pointing at the command that fills the gap.
7
+ */
8
+ export const getImpactBaselineTool = {
9
+ name: 'get_impact_baseline',
10
+ description: 'Return the impact baseline + latest impact run + delta. Read-only mirror of `shrk impact baseline show`.',
11
+ cliCommand: 'impact baseline show',
12
+ inputSchema: {
13
+ type: 'object',
14
+ properties: {},
15
+ additionalProperties: false,
16
+ },
17
+ handler(_input, ctx) {
18
+ const store = new ImpactReportStore(ctx.inspection.projectRoot);
19
+ const baseline = store.readBaseline();
20
+ const last = store.read();
21
+ if (!baseline && !last) {
22
+ return {
23
+ data: {
24
+ schema: 'sharkcraft.impact-baseline/v1',
25
+ state: 'missing-both',
26
+ baseline: null,
27
+ last: null,
28
+ nextCommands: ['shrk impact --via-graph <target>', 'shrk impact baseline write'],
29
+ },
30
+ };
31
+ }
32
+ if (!baseline) {
33
+ return {
34
+ data: {
35
+ schema: 'sharkcraft.impact-baseline/v1',
36
+ state: 'missing-baseline',
37
+ baseline: null,
38
+ last,
39
+ nextCommands: ['shrk impact baseline write'],
40
+ },
41
+ };
42
+ }
43
+ if (!last) {
44
+ return {
45
+ data: {
46
+ schema: 'sharkcraft.impact-baseline/v1',
47
+ state: 'missing-last',
48
+ baseline,
49
+ last: null,
50
+ nextCommands: ['shrk impact --via-graph <target>'],
51
+ },
52
+ };
53
+ }
54
+ const delta = diffImpactReports(baseline, last);
55
+ return {
56
+ data: {
57
+ schema: 'sharkcraft.impact-baseline/v1',
58
+ state: 'present',
59
+ baseline,
60
+ last,
61
+ delta,
62
+ },
63
+ };
64
+ },
65
+ };
@@ -0,0 +1,12 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ /**
3
+ * Read-only MCP surface for the intent-classifier benchmark. Returns
4
+ * the latest persisted run + a hint about the source fixture so the
5
+ * agent can correlate misses against the labelled cases.
6
+ *
7
+ * When no run is on disk but a fixture is present, the tool reports
8
+ * `state: 'fixture-only'` and points at `shrk context benchmark` so
9
+ * the run can be created without an additional turn of guessing.
10
+ */
11
+ export declare const getIntentBenchmarkRunTool: IToolDefinition;
12
+ //# sourceMappingURL=get-intent-benchmark-run.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-intent-benchmark-run.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-intent-benchmark-run.tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,EAAE,eA6CvC,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { loadIntentBenchmark, readBenchmarkRun, } from '@shrkcrft/context-planner';
2
+ /**
3
+ * Read-only MCP surface for the intent-classifier benchmark. Returns
4
+ * the latest persisted run + a hint about the source fixture so the
5
+ * agent can correlate misses against the labelled cases.
6
+ *
7
+ * When no run is on disk but a fixture is present, the tool reports
8
+ * `state: 'fixture-only'` and points at `shrk context benchmark` so
9
+ * the run can be created without an additional turn of guessing.
10
+ */
11
+ export const getIntentBenchmarkRunTool = {
12
+ name: 'get_intent_benchmark_run',
13
+ description: 'Return the most recent intent-classifier benchmark run. Read-only mirror of `shrk context benchmark`.',
14
+ cliCommand: 'context benchmark',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {},
18
+ additionalProperties: false,
19
+ },
20
+ handler(_input, ctx) {
21
+ const root = ctx.inspection.projectRoot;
22
+ const fixture = loadIntentBenchmark(root);
23
+ const run = readBenchmarkRun(root);
24
+ if (!fixture && !run) {
25
+ return {
26
+ data: {
27
+ schema: 'sharkcraft.intent-benchmark/v1',
28
+ state: 'missing',
29
+ fixture: null,
30
+ run: null,
31
+ nextCommands: ['shrk context benchmark seed', 'shrk context benchmark'],
32
+ },
33
+ };
34
+ }
35
+ if (!run) {
36
+ return {
37
+ data: {
38
+ schema: 'sharkcraft.intent-benchmark/v1',
39
+ state: 'fixture-only',
40
+ fixtureCaseCount: fixture?.cases.length ?? 0,
41
+ run: null,
42
+ nextCommands: ['shrk context benchmark'],
43
+ },
44
+ };
45
+ }
46
+ return {
47
+ data: {
48
+ schema: 'sharkcraft.intent-benchmark/v1',
49
+ state: 'present',
50
+ fixtureCaseCount: fixture?.cases.length ?? run.total,
51
+ run,
52
+ },
53
+ };
54
+ },
55
+ };
@@ -1,3 +1,10 @@
1
1
  import type { IToolDefinition } from '../server/tool-definition.js';
2
+ /**
3
+ * The knowledge graph is the largest single payload shrk emits — hundreds of
4
+ * homogeneous node/edge objects. `format:"table"` returns the same data in
5
+ * columnar form (schema hoisted once, keys deduped) which is still valid JSON
6
+ * but a fraction of the tokens. `format:"json"` (default) keeps the explicit
7
+ * node/edge arrays for back-compat.
8
+ */
2
9
  export declare const getKnowledgeGraphTool: IToolDefinition;
3
10
  //# sourceMappingURL=get-knowledge-graph.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-knowledge-graph.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-knowledge-graph.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,eAAO,MAAM,qBAAqB,EAAE,eASnC,CAAC"}
1
+ {"version":3,"file":"get-knowledge-graph.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-knowledge-graph.tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIpE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,eA8DnC,CAAC"}
@@ -1,10 +1,69 @@
1
1
  import { buildKnowledgeGraph } from '@shrkcrft/inspector';
2
+ import { compactArrayToColumnar, estimateTokens } from '@shrkcrft/compress';
3
+ import { wantsTable } from "../server/columnar-format.js";
4
+ import { fitArrayToBudget } from "../server/fit-array-to-budget.js";
5
+ /**
6
+ * The knowledge graph is the largest single payload shrk emits — hundreds of
7
+ * homogeneous node/edge objects. `format:"table"` returns the same data in
8
+ * columnar form (schema hoisted once, keys deduped) which is still valid JSON
9
+ * but a fraction of the tokens. `format:"json"` (default) keeps the explicit
10
+ * node/edge arrays for back-compat.
11
+ */
2
12
  export const getKnowledgeGraphTool = {
3
13
  name: 'get_knowledge_graph',
4
- description: 'Return the full SharkCraft knowledge graph: nodes (knowledge/rules/paths/templates/pipelines/presets/packs/boundaries) and edges (related-template, preset-references, pipeline-step-references, …). Read-only.',
5
- inputSchema: { type: 'object', properties: {}, additionalProperties: false },
6
- async handler(_input, ctx) {
14
+ description: 'Return the full SharkCraft knowledge graph: nodes (knowledge/rules/paths/templates/pipelines/presets/packs/boundaries) and edges (related-template, preset-references, pipeline-step-references, …). Pass `format:"table"` for a token-efficient columnar encoding (still valid JSON) — recommended for large graphs. Read-only.',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ format: {
19
+ type: 'string',
20
+ enum: ['json', 'table'],
21
+ description: 'json (default): explicit node/edge object arrays. table: columnar encoding (schema hoisted, keys deduped) — fewer tokens for large graphs.',
22
+ },
23
+ maxTokens: {
24
+ type: 'integer',
25
+ minimum: 1,
26
+ description: 'Token budget for the table. When set and the lossless columnar form still exceeds it, falls back to the lossy SmartCrusher row-sampler (representative rows kept; full original cached — retrieve via the returned ccrKey).',
27
+ },
28
+ },
29
+ additionalProperties: false,
30
+ },
31
+ async handler(input, ctx) {
7
32
  const graph = buildKnowledgeGraph(ctx.inspection);
33
+ const asTable = wantsTable(input);
34
+ const maxTokens = typeof input.maxTokens === 'number' && input.maxTokens > 0 ? Math.floor(input.maxTokens) : undefined;
35
+ const nodesTable = asTable ? compactArrayToColumnar(graph.nodes) : null;
36
+ const edgesTable = asTable ? compactArrayToColumnar(graph.edges) : null;
37
+ // Only advertise `table` when at least one array actually compacted — a tiny
38
+ // graph (e.g. edges:[]) stays the plain JSON form rather than a mislabelled
39
+ // "table" whose fields are bare arrays.
40
+ if (nodesTable || edgesTable) {
41
+ // P5.2: with no budget, keep the lossless columnar form (unchanged). With
42
+ // a budget, fit each array — sampling + CCR when it's still over.
43
+ const nodes = maxTokens
44
+ ? fitArrayToBudget(graph.nodes, maxTokens, ctx.ccrStore)
45
+ : { value: nodesTable ?? graph.nodes };
46
+ const edges = maxTokens
47
+ ? fitArrayToBudget(graph.edges, maxTokens, ctx.ccrStore)
48
+ : { value: edgesTable ?? graph.edges };
49
+ const ccrKeys = [nodes.ccrKey, edges.ccrKey].filter((k) => Boolean(k));
50
+ const before = estimateTokens(JSON.stringify({ nodes: graph.nodes, edges: graph.edges }));
51
+ const after = estimateTokens(JSON.stringify({ nodes: nodes.value, edges: edges.value }));
52
+ return {
53
+ data: {
54
+ format: 'table',
55
+ legend: 'Columnar tables: _table.cols are column names; each _table.rows[i] is one record aligned to cols; _table.absent lists [row,col] positions whose key was absent. Reconstruct objects by zipping cols with each row, skipping absent positions. If a column appears in _table.dict, its row cells are integer indices into dict[<col>] (deref to the real value). A field may be a plain array when it was too small to compact. A _table.sample block means rows were dropped to fit a budget — retrieve the full original via ccrKey.',
56
+ nodes: nodes.value,
57
+ edges: edges.value,
58
+ tokenEstimate: { before, after, saved: Math.max(0, before - after) },
59
+ ...(ccrKeys.length > 0
60
+ ? { ccrKeys, retrieveWith: `retrieve_original { "key": "${ccrKeys[0]}" }` }
61
+ : {}),
62
+ },
63
+ };
64
+ }
65
+ // Default (and tiny-graph) path: the original bare `{ nodes, edges }` shape,
66
+ // byte-identical to pre-compression clients (no extra `format` key).
8
67
  return { data: { nodes: graph.nodes, edges: graph.edges } };
9
68
  },
10
69
  };
@@ -0,0 +1,3 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ export declare const getMigrationsTool: IToolDefinition;
3
+ //# sourceMappingURL=get-migrations.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-migrations.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-migrations.tool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AA0BpE,eAAO,MAAM,iBAAiB,EAAE,eA+D/B,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
+ import * as nodePath from 'node:path';
3
+ import { findResumePoint } from '@shrkcrft/migrate';
4
+ export const getMigrationsTool = {
5
+ name: 'get_migrations',
6
+ description: 'Read-only: list `@shrkcrft/migrate` run state from `.sharkcraft/migrations/*.state.json`. Mirrors the dashboard Migrations panel. Pass `id` to fetch a single run; otherwise returns every saved state newest-first.',
7
+ cliCommand: 'migrate',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ id: { type: 'string' },
12
+ },
13
+ additionalProperties: false,
14
+ },
15
+ handler(input, ctx) {
16
+ const args = input;
17
+ const projectRoot = ctx.inspection.projectRoot;
18
+ const dir = nodePath.join(projectRoot, '.sharkcraft', 'migrations');
19
+ if (!existsSync(dir)) {
20
+ const payload = {
21
+ schema: 'sharkcraft.mcp-migrations/v1',
22
+ available: false,
23
+ total: 0,
24
+ migrations: [],
25
+ hint: 'no migrations have been run yet',
26
+ };
27
+ return { data: payload };
28
+ }
29
+ const rows = [];
30
+ let entries = [];
31
+ try {
32
+ entries = readdirSync(dir);
33
+ }
34
+ catch {
35
+ /* ignore */
36
+ }
37
+ for (const entry of entries) {
38
+ if (!entry.endsWith('.state.json'))
39
+ continue;
40
+ const abs = nodePath.join(dir, entry);
41
+ try {
42
+ const report = JSON.parse(readFileSync(abs, 'utf8'));
43
+ if (args.id && report.migration.id !== args.id)
44
+ continue;
45
+ const resumePoint = findResumePoint(report);
46
+ rows.push({
47
+ id: report.migration.id,
48
+ title: report.migration.title,
49
+ overall: report.overall,
50
+ dryRun: report.dryRun,
51
+ startedAt: report.startedAt,
52
+ totalDurationMs: report.totalDurationMs,
53
+ steps: report.steps,
54
+ ...(resumePoint !== undefined ? { resumePoint } : {}),
55
+ });
56
+ }
57
+ catch {
58
+ /* skip corrupt state */
59
+ }
60
+ }
61
+ rows.sort((a, b) => b.startedAt.localeCompare(a.startedAt));
62
+ const payload = {
63
+ schema: 'sharkcraft.mcp-migrations/v1',
64
+ available: true,
65
+ total: rows.length,
66
+ migrations: rows,
67
+ };
68
+ return { data: payload };
69
+ },
70
+ };
@@ -0,0 +1,8 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ /**
3
+ * Read-only MCP mirror of `shrk search-structural registry list`.
4
+ * Returns the full registry payload — the agent can pick a pattern by
5
+ * id and reference it in subsequent `get_structural_search` calls.
6
+ */
7
+ export declare const getPatternRegistryTool: IToolDefinition;
8
+ //# sourceMappingURL=get-pattern-registry.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-pattern-registry.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-pattern-registry.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,eAkCpC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { PatternRegistryStore } from '@shrkcrft/structural-search';
2
+ /**
3
+ * Read-only MCP mirror of `shrk search-structural registry list`.
4
+ * Returns the full registry payload — the agent can pick a pattern by
5
+ * id and reference it in subsequent `get_structural_search` calls.
6
+ */
7
+ export const getPatternRegistryTool = {
8
+ name: 'get_pattern_registry',
9
+ description: 'Return the persistent registry of reusable structural-search patterns. Read-only.',
10
+ cliCommand: 'search-structural registry list',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {},
14
+ additionalProperties: false,
15
+ },
16
+ handler(_input, ctx) {
17
+ const store = new PatternRegistryStore(ctx.inspection.projectRoot);
18
+ if (!store.exists()) {
19
+ return {
20
+ data: {
21
+ schema: 'sharkcraft.structural-pattern-registry/v1',
22
+ present: false,
23
+ path: store.absPath,
24
+ patterns: [],
25
+ nextCommands: ['shrk search-structural registry seed', 'shrk search-structural registry add'],
26
+ },
27
+ };
28
+ }
29
+ const reg = store.read();
30
+ return {
31
+ data: {
32
+ schema: reg.schema,
33
+ present: true,
34
+ path: store.absPath,
35
+ patterns: reg.patterns,
36
+ total: reg.patterns.length,
37
+ },
38
+ };
39
+ },
40
+ };
@@ -0,0 +1,3 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ export declare const getQualityGateTool: IToolDefinition;
3
+ //# sourceMappingURL=get-quality-gate.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-quality-gate.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-quality-gate.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQpE,eAAO,MAAM,kBAAkB,EAAE,eA0BhC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { runQualityGates } from '@shrkcrft/quality-gates';
2
+ export const getQualityGateTool = {
3
+ name: 'get_quality_gate',
4
+ description: 'Read-only: run the code-intelligence quality-gate aggregator (graph freshness, architecture, impact since `main`) and return the unified pass/fail report. The CI / pre-merge hook for AI-agent-authored changes.',
5
+ cliCommand: 'gate',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: {
9
+ sinceRef: { type: 'string' },
10
+ failOn: { type: 'array', items: { type: 'string', enum: ['high', 'critical'] } },
11
+ disable: { type: 'array', items: { type: 'string' } },
12
+ },
13
+ additionalProperties: false,
14
+ },
15
+ handler(input, ctx) {
16
+ const args = input;
17
+ const report = runQualityGates({
18
+ projectRoot: ctx.inspection.projectRoot,
19
+ impact: {
20
+ ...(args.sinceRef ? { sinceRef: args.sinceRef } : {}),
21
+ ...(args.failOn ? { failOn: args.failOn } : {}),
22
+ },
23
+ ...(args.disable ? { disable: args.disable } : {}),
24
+ });
25
+ return { data: report };
26
+ },
27
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"get-relevant-context.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-relevant-context.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAIpE,eAAO,MAAM,sBAAsB,EAAE,eAqDpC,CAAC"}
1
+ {"version":3,"file":"get-relevant-context.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-relevant-context.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKpE,eAAO,MAAM,sBAAsB,EAAE,eA6EpC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { buildContext } from '@shrkcrft/context';
2
2
  import { buildProjectOverview, renderOverviewText } from '@shrkcrft/inspector';
3
+ import { compressMarkdown } from '@shrkcrft/compress';
3
4
  export const getRelevantContextTool = {
4
5
  name: 'get_relevant_context',
5
6
  description: 'Build a token-budgeted, AI-ready context for a task — relevant rules/paths/templates/etc. **Prefer `prepare_agent_task` for first task grounding** (it returns this plus action hints + safety + next-command). Use this when you only need the context body. Read-only.',
@@ -17,6 +18,10 @@ export const getRelevantContextTool = {
17
18
  includeRules: { type: 'boolean' },
18
19
  includePaths: { type: 'boolean' },
19
20
  includeDocs: { type: 'boolean' },
21
+ compact: {
22
+ type: 'boolean',
23
+ description: 'When true, the markdown body is run through the deterministic markdown compressor (headers/leads/structure kept, prose thinned). Reversible: the original is cached and a `<<ccr:KEY>>` marker emitted — call retrieve_original to get it back.',
24
+ },
20
25
  },
21
26
  required: ['task'],
22
27
  additionalProperties: false,
@@ -37,18 +42,37 @@ export const getRelevantContextTool = {
37
42
  includeDocs: input.includeDocs,
38
43
  projectOverview: renderOverviewText(overview),
39
44
  });
45
+ const sections = result.sections.map((s) => ({
46
+ title: s.title,
47
+ tokens: s.tokens,
48
+ truncated: s.truncated ?? false,
49
+ entryIds: s.entryIds,
50
+ }));
51
+ if (input.compact === true) {
52
+ const c = compressMarkdown(result.body, ctx.ccrStore ? { store: ctx.ccrStore } : {});
53
+ return {
54
+ text: c.compressed,
55
+ data: {
56
+ totalTokens: result.totalTokens,
57
+ maxTokens: result.maxTokens,
58
+ omittedSections: result.omittedSections,
59
+ sections,
60
+ compaction: {
61
+ strategy: c.strategy,
62
+ tokensBefore: c.savings.before,
63
+ tokensAfter: c.savings.after,
64
+ ccrKey: c.ccrKey ?? null,
65
+ },
66
+ },
67
+ };
68
+ }
40
69
  return {
41
70
  text: result.body,
42
71
  data: {
43
72
  totalTokens: result.totalTokens,
44
73
  maxTokens: result.maxTokens,
45
74
  omittedSections: result.omittedSections,
46
- sections: result.sections.map((s) => ({
47
- title: s.title,
48
- tokens: s.tokens,
49
- truncated: s.truncated ?? false,
50
- entryIds: s.entryIds,
51
- })),
75
+ sections,
52
76
  },
53
77
  };
54
78
  },
@@ -0,0 +1,3 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ export declare const getRulesForFileTool: IToolDefinition;
3
+ //# sourceMappingURL=get-rules-for-file.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-rules-for-file.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-rules-for-file.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMpE,eAAO,MAAM,mBAAmB,EAAE,eAqDjC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { RuleGraphQueryApi } from '@shrkcrft/rule-graph';
2
+ export const getRulesForFileTool = {
3
+ name: 'get_rules_for_file',
4
+ description: 'Read-only bridge query: return rules (boundary), path conventions, and templates that apply to the given file. Requires `shrk graph index` + `shrk rule-graph index`.',
5
+ cliCommand: 'rule-graph for',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: { file: { type: 'string' } },
9
+ required: ['file'],
10
+ additionalProperties: false,
11
+ },
12
+ handler(input, ctx) {
13
+ const file = (input.file ?? '').trim();
14
+ if (!file) {
15
+ return {
16
+ isError: true,
17
+ error: { code: 'invalid-input', message: 'file is required' },
18
+ };
19
+ }
20
+ const missing = RuleGraphQueryApi.missingDescription(ctx.inspection.projectRoot);
21
+ if (missing) {
22
+ const next = missing.includes('rule-graph') ? 'shrk rule-graph index' : 'shrk graph index';
23
+ return {
24
+ isError: true,
25
+ error: {
26
+ code: 'bridge-missing',
27
+ message: missing,
28
+ details: { nextCommand: next },
29
+ },
30
+ };
31
+ }
32
+ const api = RuleGraphQueryApi.fromStores(ctx.inspection.projectRoot);
33
+ const r = api.forFile(file);
34
+ if (!r) {
35
+ return {
36
+ isError: true,
37
+ error: { code: 'not-found', message: `No file node for "${file}".`, details: { file } },
38
+ };
39
+ }
40
+ return {
41
+ data: {
42
+ schema: 'sharkcraft.rule-graph-for-file/v1',
43
+ file: r.path,
44
+ rules: r.rules.map((h) => ({
45
+ id: h.target.id,
46
+ label: h.target.label,
47
+ severity: h.edge.data?.['severity'] ?? undefined,
48
+ })),
49
+ paths: r.paths.map((h) => ({ id: h.target.id, label: h.target.label })),
50
+ templates: r.templates.map((h) => ({ id: h.target.id, label: h.target.label })),
51
+ },
52
+ };
53
+ },
54
+ };
@@ -0,0 +1,3 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ export declare const getStructuralRewritePlanTool: IToolDefinition;
3
+ //# sourceMappingURL=get-structural-rewrite-plan.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-structural-rewrite-plan.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-structural-rewrite-plan.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAUpE,eAAO,MAAM,4BAA4B,EAAE,eA0C1C,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { planRewrite } from '@shrkcrft/structural-search';
2
+ export const getStructuralRewritePlanTool = {
3
+ // Tool name intentionally uses "codemod" rather than "rewrite" — the
4
+ // CLI ceremony tests forbid any MCP tool name containing the
5
+ // substring "write" so a future read of the catalog can't mistake a
6
+ // preview tool for a write surface. The plan is still read-only
7
+ // here; apply ceremony happens via `shrk search-structural ... --apply`.
8
+ name: 'get_structural_codemod_plan',
9
+ description: 'Preview a structural codemod as a per-file edit plan (`sharkcraft.structural-rewrite-plan/v1`). Read-only — apply ceremony stays on the CLI (`shrk search-structural ... --apply`). Useful for "what would this codemod do?" without touching disk.',
10
+ cliCommand: 'search-structural',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {
14
+ pattern: { type: 'object' },
15
+ recipe: { type: 'object' },
16
+ files: { type: 'array', items: { type: 'string' } },
17
+ perFileLimit: { type: 'number' },
18
+ fileLimit: { type: 'number' },
19
+ },
20
+ required: ['pattern', 'recipe'],
21
+ additionalProperties: false,
22
+ },
23
+ handler(input, ctx) {
24
+ const args = input;
25
+ const pattern = args.pattern;
26
+ const recipe = args.recipe;
27
+ if (!pattern || typeof pattern !== 'object' || !pattern.kind) {
28
+ return { isError: true, error: { code: 'invalid-input', message: 'pattern.kind is required' } };
29
+ }
30
+ if (!recipe || typeof recipe !== 'object' || !recipe.kind) {
31
+ return { isError: true, error: { code: 'invalid-input', message: 'recipe.kind is required' } };
32
+ }
33
+ const plan = planRewrite({
34
+ projectRoot: ctx.inspection.projectRoot,
35
+ pattern,
36
+ recipe,
37
+ ...(args.files ? { files: args.files } : {}),
38
+ ...(typeof args.perFileLimit === 'number' ? { perFileLimit: clamp(args.perFileLimit, 1, 1000) } : {}),
39
+ ...(typeof args.fileLimit === 'number' ? { fileLimit: clamp(args.fileLimit, 1, 50000) } : {}),
40
+ });
41
+ return { data: plan };
42
+ },
43
+ };
44
+ function clamp(n, lo, hi) {
45
+ return Math.max(lo, Math.min(hi, n));
46
+ }
@@ -0,0 +1,3 @@
1
+ import type { IToolDefinition } from '../server/tool-definition.js';
2
+ export declare const getStructuralSearchTool: IToolDefinition;
3
+ //# sourceMappingURL=get-structural-search.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-structural-search.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-structural-search.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAOpE,eAAO,MAAM,uBAAuB,EAAE,eA+BrC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { runSearch } from '@shrkcrft/structural-search';
2
+ export const getStructuralSearchTool = {
3
+ name: 'get_structural_search',
4
+ description: 'Run a declarative AST pattern over the project and return matches. Patterns are JSON of shape `{ kind: "CallExpression" | "ImportDeclaration" | "ClassDeclaration" | ..., ... }`. No executable predicates, no rewrites. Read-only.',
5
+ cliCommand: 'search-structural',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: {
9
+ pattern: { type: 'object' },
10
+ limit: { type: 'number' },
11
+ },
12
+ required: ['pattern'],
13
+ additionalProperties: false,
14
+ },
15
+ handler(input, ctx) {
16
+ const args = input;
17
+ const pat = args.pattern;
18
+ if (!pat || typeof pat !== 'object' || !pat.kind) {
19
+ return {
20
+ isError: true,
21
+ error: { code: 'invalid-input', message: 'pattern.kind is required' },
22
+ };
23
+ }
24
+ const limit = clamp(args.limit ?? 200, 1, 2000);
25
+ const result = runSearch({
26
+ projectRoot: ctx.inspection.projectRoot,
27
+ pattern: pat,
28
+ limit,
29
+ });
30
+ return { data: result };
31
+ },
32
+ };
33
+ function clamp(n, lo, hi) {
34
+ return Math.max(lo, Math.min(hi, n));
35
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"get-task-packet.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-task-packet.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,eAAO,MAAM,iBAAiB,EAAE,eA8C/B,CAAC"}
1
+ {"version":3,"file":"get-task-packet.tool.d.ts","sourceRoot":"","sources":["../../src/tools/get-task-packet.tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE,eAAO,MAAM,iBAAiB,EAAE,eAiD/B,CAAC"}