@mfdaves/okf-mcp 0.6.0 → 0.8.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.
package/src/mcp-server.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ const fs = require("node:fs");
3
4
  const path = require("path");
4
5
  const {
5
6
  McpServer,
@@ -14,6 +15,7 @@ const {
14
15
  conceptSignals,
15
16
  conceptSummary,
16
17
  loadProjectBundles,
18
+ recoverConceptLocator,
17
19
  resolveConcept,
18
20
  validateIndex,
19
21
  } = require("./indexer");
@@ -22,7 +24,11 @@ const { MAX_QUERY_CHARACTERS, MAX_QUERY_TERMS } = require("./search-index");
22
24
  const { exportGraph, findPaths, getGraph, getNeighbors, getSubgraph, graphSummary } = require("./graph");
23
25
  const { fetchGitHubBundle, fetchRemoteBundles, sanitizeRemoteId } = require("./remote");
24
26
  const { ConceptAuthoringService } = require("./authoring");
25
- const { LiveAuthoringService, MAX_CHANGES } = require("./live-authoring");
27
+ const {
28
+ LiveAuthoringService,
29
+ MAX_CHANGES,
30
+ MAX_COMMIT_MESSAGE_BYTES,
31
+ } = require("./live-authoring");
26
32
  const { FileConceptStore } = require("./store");
27
33
  const { loadProjectConfig } = require("./project");
28
34
  const {
@@ -39,9 +45,15 @@ const packageMetadata = require("../package.json");
39
45
  const MAX_MCP_MESSAGE_BYTES = 1024 * 1024;
40
46
 
41
47
  class ToolExecutionError extends Error {
42
- constructor(message) {
48
+ constructor(message, code, details) {
43
49
  super(message);
44
50
  this.name = "ToolExecutionError";
51
+ if (typeof code === "string" && code) {
52
+ this.code = code;
53
+ }
54
+ if (details !== undefined) {
55
+ this.details = details;
56
+ }
45
57
  }
46
58
  }
47
59
 
@@ -117,6 +129,10 @@ function objectParameter(description, extra) {
117
129
  }, extra || {});
118
130
  }
119
131
 
132
+ function detailParameter(description) {
133
+ return stringParameter(description, { enum: ["compact", "full"], default: "compact" });
134
+ }
135
+
120
136
  function relationParameter(description) {
121
137
  return {
122
138
  type: "object",
@@ -147,11 +163,11 @@ function collectionPatchParameter(description, item) {
147
163
  type: "object",
148
164
  description,
149
165
  additionalProperties: false,
166
+ minProperties: 1,
150
167
  properties: {
151
168
  add: { type: "array", items: item },
152
169
  remove: { type: "array", items: item },
153
170
  },
154
- anyOf: [{ required: ["add"] }, { required: ["remove"] }],
155
171
  };
156
172
  }
157
173
 
@@ -184,6 +200,7 @@ const LIVE_CREATE_CHANGE = {
184
200
  const LIVE_UPDATE_CHANGE = {
185
201
  type: "object",
186
202
  additionalProperties: false,
203
+ minProperties: 3,
187
204
  properties: {
188
205
  op: { type: "string", const: "update", description: "Update an existing concept in place." },
189
206
  uri: nonEmptyStringParameter("Canonical or compatible URI of the existing concept."),
@@ -206,19 +223,100 @@ const LIVE_UPDATE_CHANGE = {
206
223
  removeMetadataKeys: stringArrayParameter("Extension frontmatter keys to remove; managed fields are rejected.", { nonEmptyItems: true }),
207
224
  },
208
225
  required: ["op", "uri"],
209
- anyOf: [
210
- { required: ["title"] },
211
- { required: ["description"] },
212
- { required: ["body"] },
213
- { required: ["tags"] },
214
- { required: ["sources"] },
215
- { required: ["relations"] },
216
- { required: ["metadata"] },
217
- { required: ["removeMetadataKeys"] },
218
- ],
219
226
  };
220
227
 
221
- function defineTool(description, annotations, properties, required, schemaExtras) {
228
+ const LIVE_CHANGES_DESCRIPTION = [
229
+ `One through ${MAX_CHANGES} concept create or update operations handled as one batch.`,
230
+ "Create grammar: { op: 'create', type, title, path?, description?, body?, tags?: string[], sources?: (string | structured source object)[], relations?: { type, target, label?, description? }[], metadata?: object }.",
231
+ "Update grammar: { op: 'update', uri, title?, description?, body?, tags?: { add?: string[], remove?: string[] }, sources?: { add?: (string | source object)[], remove?: (string | { id } | { resource })[] }, relations?: { add?: relation[], remove?: relation[] }, metadata?, removeMetadataKeys? }; relation = { type, target, label?, description? }; include at least one update field.",
232
+ ].join(" ");
233
+
234
+ const LIVE_CHANGE_TOOL_PROPERTIES = {
235
+ bundle: nonEmptyStringParameter("Writable bundle id; optional when exactly one local root is configured."),
236
+ detail: detailParameter("Receipt detail level; compact removes repeated planning fields while full preserves the v0.7 receipt layout."),
237
+ message: stringParameter("Optional Git commit summary when automatic commits are enabled.", {
238
+ maxLength: MAX_COMMIT_MESSAGE_BYTES,
239
+ }),
240
+ changes: {
241
+ type: "array",
242
+ description: LIVE_CHANGES_DESCRIPTION,
243
+ minItems: 1,
244
+ maxItems: MAX_CHANGES,
245
+ items: { oneOf: [LIVE_CREATE_CHANGE, LIVE_UPDATE_CHANGE] },
246
+ },
247
+ };
248
+
249
+ const LIVE_CHANGE_EFFECTS_OUTPUT = {
250
+ type: "object",
251
+ description: "Compact structured summary of the fields changed by this operation.",
252
+ additionalProperties: true,
253
+ properties: {
254
+ changedFields: stringArrayParameter("Substantive concept fields changed, excluding server-managed generation provenance."),
255
+ bodyChanged: optionalBooleanParameter("Whether the Markdown body changed."),
256
+ tags: objectParameter("Tags added and removed by the operation."),
257
+ sources: objectParameter("Sources added and removed by the operation."),
258
+ relations: objectParameter("Added, removed, and updated relation values as structured { type, target, label?, description? } objects."),
259
+ metadata: objectParameter("Metadata fields set and removed by the operation."),
260
+ },
261
+ };
262
+
263
+ const LIVE_CHANGE_SUMMARY_OUTPUT = {
264
+ type: "object",
265
+ description: "Compact receipt for one validated or applied concept operation.",
266
+ additionalProperties: true,
267
+ properties: {
268
+ op: stringParameter("Operation kind."),
269
+ bundle: stringParameter("Target bundle id."),
270
+ path: stringParameter("Bundle-relative concept path."),
271
+ absolutePath: stringParameter("Absolute target concept filename."),
272
+ uri: stringParameter("Canonical concept URI."),
273
+ title: stringParameter("Resulting concept title."),
274
+ baseRevision: {
275
+ description: "Source revision before the operation; null for creates.",
276
+ oneOf: [{ type: "string" }, { type: "null" }],
277
+ },
278
+ candidateRevision: stringParameter("Revision of the validated candidate bytes."),
279
+ effects: LIVE_CHANGE_EFFECTS_OUTPUT,
280
+ },
281
+ };
282
+
283
+ const LIVE_CHANGE_OUTPUT_PROPERTIES = {
284
+ status: stringParameter("Validation or application outcome."),
285
+ readyToApply: optionalBooleanParameter("Whether policy, graph, revision, and configured Git preconditions currently allow apply."),
286
+ filesChanged: optionalBooleanParameter("Whether filesystem changes remain when the request returns."),
287
+ snapshot: objectParameter("Full-receipt time-of-check metadata for this planning result."),
288
+ preconditions: objectParameter("Full-receipt revision and Git preconditions checked for the batch."),
289
+ generated: objectParameter("Server-owned generation actor and timestamp."),
290
+ target: objectParameter("Absolute bundle, repository, and affected-file locations."),
291
+ durability: objectParameter("Working-tree and automatic-commit durability state."),
292
+ changes: {
293
+ type: "array",
294
+ description: "Compact operation receipts.",
295
+ items: LIVE_CHANGE_SUMMARY_OUTPUT,
296
+ },
297
+ validation: objectParameter("Complete future-graph validation result."),
298
+ git: objectParameter("Git policy and commit result."),
299
+ };
300
+
301
+ const LIVE_VALIDATE_OUTPUT = {
302
+ type: "object",
303
+ description: "Read-only validation receipt for a structured concept batch.",
304
+ additionalProperties: true,
305
+ properties: Object.assign({
306
+ valid: optionalBooleanParameter("Whether authoring policy and the complete future graph are valid, independent of transient Git readiness."),
307
+ }, LIVE_CHANGE_OUTPUT_PROPERTIES),
308
+ };
309
+
310
+ const LIVE_APPLY_OUTPUT = {
311
+ type: "object",
312
+ description: "Application, target, durability, and validation receipt for a structured concept batch.",
313
+ additionalProperties: true,
314
+ properties: Object.assign({
315
+ applied: optionalBooleanParameter("Whether the complete batch was applied."),
316
+ }, LIVE_CHANGE_OUTPUT_PROPERTIES),
317
+ };
318
+
319
+ function defineTool(description, annotations, properties, required, schemaExtras, outputSchema) {
222
320
  return {
223
321
  description,
224
322
  annotations,
@@ -229,6 +327,7 @@ function defineTool(description, annotations, properties, required, schemaExtras
229
327
  ...(required && required.length ? { required } : {}),
230
328
  ...(schemaExtras || {}),
231
329
  },
330
+ ...(outputSchema ? { outputSchema } : {}),
232
331
  };
233
332
  }
234
333
 
@@ -245,6 +344,7 @@ const TOOL_DEFINITIONS = {
245
344
  bundle: nonEmptyStringParameter("Limit results to this bundle id."),
246
345
  type: nonEmptyStringParameter("Limit results to this exact concept type."),
247
346
  tag: nonEmptyStringParameter("Limit results to concepts containing this tag."),
347
+ detail: detailParameter("Compact returns only URI, title, type, and description; full includes navigation metadata and signals."),
248
348
  limit: integerParameter("Maximum number of concepts to return.", 1, 250, 25),
249
349
  offset: integerParameter("Number of matching concepts to skip before returning results.", 0, undefined, 0),
250
350
  },
@@ -291,6 +391,7 @@ const TOOL_DEFINITIONS = {
291
391
  attestationReady: optionalBooleanParameter("Require static Attested Computation readiness."),
292
392
  generatedBy: nonEmptyStringParameter("Limit results to this generator actor."),
293
393
  verifiedBy: nonEmptyStringParameter("Limit results to concepts verified by this actor."),
394
+ detail: detailParameter("Compact returns only URI, title, type, and description; full includes ranking, navigation metadata, and signals."),
294
395
  limit: integerParameter("Maximum number of concepts to return.", 1, 250, 25),
295
396
  offset: integerParameter("Number of matching concepts to skip before returning results.", 0, undefined, 0),
296
397
  },
@@ -514,21 +615,21 @@ const TOOL_DEFINITIONS = {
514
615
  },
515
616
  ["proposalId"],
516
617
  ),
618
+ okf_validate_changes: defineTool(
619
+ "Validate a complete structured concept create or update batch without changing files.",
620
+ READ_ONLY,
621
+ LIVE_CHANGE_TOOL_PROPERTIES,
622
+ ["changes"],
623
+ undefined,
624
+ LIVE_VALIDATE_OUTPUT,
625
+ ),
517
626
  okf_apply_changes: defineTool(
518
- "Validate and atomically apply one or more structured concept creates or updates to one local bundle.",
627
+ "Validate and apply one or more structured concept creates or updates to one local bundle as one batch.",
519
628
  DESTRUCTIVE_WRITE,
520
- {
521
- bundle: nonEmptyStringParameter("Writable bundle id; optional when exactly one local root is configured."),
522
- message: stringParameter("Optional Git commit summary when automatic commits are enabled."),
523
- changes: {
524
- type: "array",
525
- description: "One through 100 concept create or update operations applied as one batch.",
526
- minItems: 1,
527
- maxItems: MAX_CHANGES,
528
- items: { oneOf: [LIVE_CREATE_CHANGE, LIVE_UPDATE_CHANGE] },
529
- },
530
- },
629
+ LIVE_CHANGE_TOOL_PROPERTIES,
531
630
  ["changes"],
631
+ undefined,
632
+ LIVE_APPLY_OUTPUT,
532
633
  ),
533
634
  get_graph: defineTool(
534
635
  "Return a bounded set of OKF graph nodes and edges with optional concept filters.",
@@ -632,6 +733,7 @@ const COMPUTATION_AUTHORING_TOOL_NAMES = new Set([
632
733
  "okf_propose_attested_computation",
633
734
  ]);
634
735
  const LIVE_WRITE_TOOL_NAMES = new Set([
736
+ "okf_validate_changes",
635
737
  "okf_apply_changes",
636
738
  ]);
637
739
  const RUNTIME_REMOTE_TOOL_NAMES = new Set([
@@ -647,12 +749,54 @@ function jsonContent(value, options) {
647
749
  },
648
750
  ],
649
751
  };
752
+ if (options && options.structured) {
753
+ result.structuredContent = value;
754
+ }
650
755
  if (options && options.isError) {
651
756
  result.isError = true;
652
757
  }
653
758
  return result;
654
759
  }
655
760
 
761
+ function liveRequest(args) {
762
+ const input = Object.assign({}, args || {});
763
+ const detail = input.detail || "compact";
764
+ delete input.detail;
765
+ return { input, detail };
766
+ }
767
+
768
+ function projectLiveReceipt(receipt, detail) {
769
+ if (detail === "full") return receipt;
770
+ const compact = structuredClone(receipt);
771
+ const preconditionGit = compact.preconditions && compact.preconditions.git;
772
+ if (preconditionGit || compact.git) {
773
+ compact.git = Object.assign({}, preconditionGit || {}, compact.git || {});
774
+ }
775
+ delete compact.snapshot;
776
+ delete compact.preconditions;
777
+ if (compact.target) delete compact.target.absolutePaths;
778
+ if (compact.durability) delete compact.durability.filesChanged;
779
+ (compact.changes || []).forEach((change) => {
780
+ delete change.bundle;
781
+ const effects = change.effects;
782
+ if (!effects) return;
783
+ ["beforeRevision", "afterRevision", "bytesBefore", "bytesAfter"].forEach((key) => delete effects[key]);
784
+ if (effects.bodyChanged === false) delete effects.bodyChanged;
785
+ ["tags", "sources", "relations", "metadata"].forEach((name) => {
786
+ const group = effects[name];
787
+ if (!group) return;
788
+ Object.keys(group).forEach((key) => {
789
+ const list = group[key];
790
+ if (!list || !Array.isArray(list.values)) return;
791
+ if (!list.omitted) delete list.omitted;
792
+ if (!list.values.length && !list.omitted) delete group[key];
793
+ });
794
+ if (!Object.keys(group).length) delete effects[name];
795
+ });
796
+ });
797
+ return compact;
798
+ }
799
+
656
800
  function toolEnabled(state, name) {
657
801
  if (PROJECT_HELPER_TOOL_NAMES.has(name)) {
658
802
  return Boolean(state && state.authoringService);
@@ -696,7 +840,7 @@ function canonicalResourceUri(uri) {
696
840
  }
697
841
  }
698
842
 
699
- function publicBundles(index) {
843
+ function publicBundles(index, options) {
700
844
  return index.bundles.map((bundle) => {
701
845
  const documentCount = index.documents.filter((doc) => doc.bundle === bundle.id).length;
702
846
  const conceptCount = index.concepts.filter((doc) => doc.bundle === bundle.id).length;
@@ -720,12 +864,17 @@ function publicBundles(index) {
720
864
  exclude: bundle.exclude || [],
721
865
  };
722
866
  }
723
- const root = index.project && index.project.root
724
- ? path.relative(index.project.root, bundle.root).replace(/\\/g, "/") || "."
867
+ const absoluteRoot = path.resolve(bundle.root);
868
+ const projectRoot = index.project && index.project.root
869
+ ? path.resolve(index.project.root)
870
+ : null;
871
+ const root = projectRoot
872
+ ? path.relative(projectRoot, absoluteRoot).replace(/\\/g, "/") || "."
725
873
  : "<configured>";
726
874
  return {
727
875
  id: bundle.id,
728
876
  root,
877
+ ...((options && options.includeAbsolutePaths) ? { absoluteRoot, projectRoot } : {}),
729
878
  documentCount,
730
879
  conceptCount,
731
880
  assetCount,
@@ -755,7 +904,7 @@ function readResource(index, uri) {
755
904
  }
756
905
 
757
906
  function listConcepts(index, args) {
758
- const options = Object.assign({}, args || {});
907
+ const options = Object.assign({ detail: "compact" }, args || {});
759
908
  if (options.type && !options.types) {
760
909
  options.types = [options.type];
761
910
  }
@@ -765,15 +914,27 @@ function listConcepts(index, args) {
765
914
  return searchConcepts(index, options);
766
915
  }
767
916
 
768
- function getConcept(index, args, repositoryMappings) {
769
- const locator = args && (args.id || args.uri)
917
+ function conceptLocator(args) {
918
+ return args && (args.id || args.uri)
770
919
  ? (args.id || args.uri)
771
920
  : args && args.bundle && args.path
772
921
  ? `okf://${args.bundle}/${args.path}`
773
922
  : null;
923
+ }
924
+
925
+ function getConcept(index, args, repositoryMappings) {
926
+ const locator = conceptLocator(args);
774
927
  const doc = resolveConcept(index, locator);
775
928
  if (!doc) {
776
- throw new ToolExecutionError(`Unknown OKF concept URI or ID: ${locator || "<missing>"}`);
929
+ const recovery = recoverConceptLocator(index, locator, {
930
+ bundle: args && args.bundle,
931
+ limit: 5,
932
+ });
933
+ throw new ToolExecutionError(
934
+ `Unknown OKF concept URI or ID: ${locator || "<missing>"}`,
935
+ recovery.status === "ambiguous" ? "concept_locator_ambiguous" : "concept_not_found",
936
+ { recovery },
937
+ );
777
938
  }
778
939
  if (!doc.valid || doc.reserved) {
779
940
  throw new ToolExecutionError(`Locator is not a valid OKF concept: ${locator}`);
@@ -798,6 +959,18 @@ function getConcept(index, args, repositoryMappings) {
798
959
  });
799
960
  }
800
961
 
962
+ function conceptIndexIsStale(index, args) {
963
+ const doc = resolveConcept(index, conceptLocator(args));
964
+ if (!doc) return true;
965
+ const bundle = (index.bundles || []).find((entry) => entry.id === doc.bundle);
966
+ if (!bundle || bundle.remote) return false;
967
+ try {
968
+ return !fs.lstatSync(doc.absolutePath).isFile();
969
+ } catch (_error) {
970
+ return true;
971
+ }
972
+ }
973
+
801
974
  function listTypes(index) {
802
975
  const counts = {};
803
976
  index.concepts.forEach((doc) => {
@@ -877,7 +1050,11 @@ async function expectedToolOperation(operation, options) {
877
1050
  if (programmingError) {
878
1051
  throw error;
879
1052
  }
880
- throw new ToolExecutionError(error && error.message ? error.message : String(error));
1053
+ throw new ToolExecutionError(
1054
+ error && error.message ? error.message : String(error),
1055
+ error && error.code,
1056
+ error && error.details,
1057
+ );
881
1058
  }
882
1059
  }
883
1060
 
@@ -894,14 +1071,17 @@ async function callTool(state, name, args) {
894
1071
  try {
895
1072
  switch (name) {
896
1073
  case "list_bundles":
897
- return jsonContent(publicBundles(index));
1074
+ return jsonContent(publicBundles(index, {
1075
+ includeAbsolutePaths: Boolean(state.allowWrite),
1076
+ }));
898
1077
  case "list_concepts":
899
1078
  return jsonContent(listConcepts(index, args));
900
1079
  case "get_concept":
901
- return jsonContent(getConcept(index, args, state.repositoryMappings));
1080
+ if (conceptIndexIsStale(index, args)) rebuildStateIndex(state);
1081
+ return jsonContent(getConcept(state.index, args, state.repositoryMappings));
902
1082
  case "search_concepts":
903
1083
  return jsonContent(await expectedToolOperation(
904
- () => searchConcepts(index, args),
1084
+ () => searchConcepts(index, Object.assign({ detail: "compact" }, args)),
905
1085
  { translateTypeError: true },
906
1086
  ));
907
1087
  case "list_types":
@@ -1043,17 +1223,34 @@ async function callTool(state, name, args) {
1043
1223
  return jsonContent(await expectedToolOperation(
1044
1224
  () => requireAuthoring(state).rejectProposal(args),
1045
1225
  ));
1226
+ case "okf_validate_changes": {
1227
+ const request = liveRequest(args);
1228
+ const result = await expectedToolOperation(
1229
+ () => requireLiveAuthoring(state).validateChanges(request.input, {
1230
+ additionalBundles: state.remoteBundles,
1231
+ }),
1232
+ { translateTypeError: true },
1233
+ );
1234
+ if (result.applied || result.filesChanged) {
1235
+ rebuildStateIndex(state);
1236
+ }
1237
+ return jsonContent(projectLiveReceipt(result, request.detail), { structured: true });
1238
+ }
1046
1239
  case "okf_apply_changes": {
1240
+ const request = liveRequest(args);
1047
1241
  const result = await expectedToolOperation(
1048
- () => requireLiveAuthoring(state).applyChanges(args, {
1242
+ () => requireLiveAuthoring(state).applyChanges(request.input, {
1049
1243
  additionalBundles: state.remoteBundles,
1050
1244
  }),
1051
1245
  { translateTypeError: true },
1052
1246
  );
1053
- if (result.applied) {
1247
+ if (result.applied || result.filesChanged) {
1054
1248
  rebuildStateIndex(state);
1055
1249
  }
1056
- return jsonContent(result, { isError: result.applied === false });
1250
+ return jsonContent(projectLiveReceipt(result, request.detail), {
1251
+ structured: true,
1252
+ isError: result.applied === false,
1253
+ });
1057
1254
  }
1058
1255
  case "get_graph":
1059
1256
  return jsonContent(getGraph(index, args));
@@ -1094,11 +1291,14 @@ async function callTool(state, name, args) {
1094
1291
  if (!(error instanceof ToolExecutionError)) {
1095
1292
  throw error;
1096
1293
  }
1097
- return jsonContent({
1294
+ const failure = {
1098
1295
  error: "Tool execution failed",
1099
1296
  tool: name,
1100
1297
  message: error.message,
1101
- }, { isError: true });
1298
+ ...(error.code ? { code: error.code } : {}),
1299
+ ...(error.details !== undefined ? { details: error.details } : {}),
1300
+ };
1301
+ return jsonContent(failure, { isError: true, structured: true });
1102
1302
  }
1103
1303
  }
1104
1304
 
@@ -1274,6 +1474,9 @@ function registerMcpInterface(state) {
1274
1474
  description: definition.description,
1275
1475
  annotations: definition.annotations,
1276
1476
  inputSchema: fromJsonSchema(definition.inputSchema),
1477
+ ...(definition.outputSchema
1478
+ ? { outputSchema: fromJsonSchema(definition.outputSchema) }
1479
+ : {}),
1277
1480
  },
1278
1481
  async (args) => {
1279
1482
  const current = pendingToolCall.then(async () => {
package/src/search.js CHANGED
@@ -5,10 +5,26 @@ const { normalizeV02Signals } = require("./v02");
5
5
  const { resolveConcept } = require("./indexer");
6
6
  const { normalizeSearchQuery, prepareSearchIndex } = require("./search-index");
7
7
 
8
+ const MAX_COMPACT_TEXT = 500;
9
+
8
10
  function lower(value) {
9
11
  return String(value || "").toLowerCase();
10
12
  }
11
13
 
14
+ function compactText(value) {
15
+ const text = String(value || "");
16
+ return text.length > MAX_COMPACT_TEXT ? `${text.slice(0, MAX_COMPACT_TEXT - 1)}…` : text;
17
+ }
18
+
19
+ function compactConceptSummary(doc) {
20
+ return {
21
+ uri: doc.uri,
22
+ title: compactText(doc.title),
23
+ type: compactText(doc.type),
24
+ description: compactText(doc.description),
25
+ };
26
+ }
27
+
12
28
  function asArray(value) {
13
29
  if (value === undefined || value === null) {
14
30
  return [];
@@ -205,6 +221,9 @@ function searchConcepts(index, options) {
205
221
  results.sort((a, b) => compareDocs(a.doc, b.doc));
206
222
  }
207
223
  const page = results.slice(offset, offset + limit).map((entry) => {
224
+ if (config.detail === "compact") {
225
+ return compactConceptSummary(entry.doc);
226
+ }
208
227
  const summary = conceptSummary(entry.doc);
209
228
  if (config.asOf) {
210
229
  const signals = signalsForDoc(entry.doc, config.asOf);