@mfdaves/okf-mcp 0.9.0 → 0.12.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +176 -19
  3. package/bin/okf-mcp.js +6 -1
  4. package/okf/okf-mcp/policies/authoring-safety.md +11 -1
  5. package/package.json +17 -5
  6. package/server.json +2 -2
  7. package/src/assets.js +165 -73
  8. package/src/authoring/candidates.js +391 -0
  9. package/src/authoring/git-preflight.js +225 -0
  10. package/src/authoring/git-publish.js +776 -0
  11. package/src/authoring/live.js +789 -0
  12. package/src/authoring/paths.js +112 -0
  13. package/src/authoring/policy-hook.js +221 -0
  14. package/src/authoring/proposal-policy.js +137 -0
  15. package/src/authoring/receipts.js +329 -0
  16. package/src/authoring/render.js +38 -0
  17. package/src/authoring/shared.js +75 -0
  18. package/src/authoring/staging.js +216 -0
  19. package/src/authoring.js +386 -287
  20. package/src/cache/files.js +147 -0
  21. package/src/cache/lock.js +201 -0
  22. package/src/cache/paths.js +197 -0
  23. package/src/cache/store.js +703 -0
  24. package/src/catalog-text.js +19 -0
  25. package/src/cli.js +184 -151
  26. package/src/computation.js +99 -61
  27. package/src/context/assemble.js +567 -0
  28. package/src/context/cli-options.js +88 -0
  29. package/src/context/score.js +234 -0
  30. package/src/context/sections.js +274 -0
  31. package/src/embed/interface.js +160 -0
  32. package/src/embed/openai.js +715 -0
  33. package/src/embed/prepare.js +182 -0
  34. package/src/embed/units.js +96 -0
  35. package/src/git-source.js +112 -52
  36. package/src/graph.js +95 -37
  37. package/src/http-server.js +36 -17
  38. package/src/index.js +15 -0
  39. package/src/indexer/assemble.js +566 -0
  40. package/src/indexer/build.js +290 -0
  41. package/src/indexer/cache.js +81 -0
  42. package/src/indexer/edges.js +430 -0
  43. package/src/indexer/index.js +44 -0
  44. package/src/indexer/paths.js +178 -0
  45. package/src/indexer/resolve.js +282 -0
  46. package/src/indexer/update.js +720 -0
  47. package/src/indexer.js +3 -1068
  48. package/src/live-authoring.js +4 -2329
  49. package/src/markdown.js +21 -16
  50. package/src/mcp/registry.js +328 -0
  51. package/src/mcp/resources.js +45 -0
  52. package/src/mcp/server.js +472 -0
  53. package/src/mcp/tools/catalog.js +244 -0
  54. package/src/mcp/tools/computation.js +83 -0
  55. package/src/mcp/tools/context.js +133 -0
  56. package/src/mcp/tools/graph.js +167 -0
  57. package/src/mcp/tools/live-authoring.js +316 -0
  58. package/src/mcp/tools/migration.js +86 -0
  59. package/src/mcp/tools/producers.js +79 -0
  60. package/src/mcp/tools/proposals.js +213 -0
  61. package/src/mcp/tools/provenance.js +87 -0
  62. package/src/mcp/tools/remote.js +79 -0
  63. package/src/mcp/tools/search.js +242 -0
  64. package/src/mcp-server.js +3 -1611
  65. package/src/migration.js +431 -253
  66. package/src/parser.js +245 -130
  67. package/src/plugins.js +71 -48
  68. package/src/policy/write-policy.js +713 -0
  69. package/src/producer-publisher.js +195 -77
  70. package/src/producers.js +265 -101
  71. package/src/project.js +277 -93
  72. package/src/remote.js +96 -61
  73. package/src/search/cli-options.js +107 -0
  74. package/src/search/confidence.js +61 -0
  75. package/src/search/dense.js +304 -0
  76. package/src/search/embedding-cli.js +57 -0
  77. package/src/search/embedding-config.js +217 -0
  78. package/src/search/fusion.js +249 -0
  79. package/src/search/hybrid.js +526 -0
  80. package/src/search/languages.js +200 -0
  81. package/src/search/lexical.js +695 -0
  82. package/src/search/query.js +620 -0
  83. package/src/search/stem/among.js +43 -0
  84. package/src/search/stem/base-stemmer.js +311 -0
  85. package/src/search/stem/en-regions.js +456 -0
  86. package/src/search/stem/en-suffixes.js +664 -0
  87. package/src/search/stem/en-tables.js +176 -0
  88. package/src/search/stem/en.js +238 -0
  89. package/src/search/stem/it-regions.js +459 -0
  90. package/src/search/stem/it-suffixes.js +471 -0
  91. package/src/search/stem/it-tables.js +257 -0
  92. package/src/search/stem/it.js +155 -0
  93. package/src/search-index.js +2 -81
  94. package/src/search.js +2 -252
  95. package/src/store.js +134 -81
  96. package/src/v02.js +301 -105
  97. package/src/validation.js +24 -20
package/src/project.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
 
3
- const fs = require("fs");
4
- const path = require("path");
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
5
  const { parseFrontmatterYaml, splitFrontmatter } = require("./parser");
6
+ const { normalizeLanguages } = require("./search/languages");
7
+ const { parseWritePolicy } = require("./policy/write-policy");
8
+ const { normalizeEmbeddingConfig } = require("./search/embedding-config");
6
9
 
7
10
  const DEFAULT_RELATION_TYPES = [
8
11
  "depends_on",
@@ -106,8 +109,7 @@ function findOkfRoot(startDir) {
106
109
  if (fs.existsSync(indexPath) && fs.statSync(indexPath).isFile()) {
107
110
  try {
108
111
  const split = splitFrontmatter(fs.readFileSync(indexPath, "utf8"));
109
- if (split.frontmatter
110
- && Object.prototype.hasOwnProperty.call(split.frontmatter, "okf_version")) {
112
+ if (split.frontmatter && Object.hasOwn(split.frontmatter, "okf_version")) {
111
113
  return current;
112
114
  }
113
115
  } catch {
@@ -135,35 +137,45 @@ function normalizeBundles(config, configPath, errors) {
135
137
  const rootDir = path.dirname(path.resolve(configPath));
136
138
  const bundles = Array.isArray(config.bundles) ? config.bundles : [];
137
139
  if (!bundles.length) {
138
- errors.push({ code: "missing_bundles", message: "Project config must define at least one bundle." });
140
+ errors.push({
141
+ code: "missing_bundles",
142
+ message: "Project config must define at least one bundle.",
143
+ });
139
144
  }
140
145
  const seen = new Set();
141
- return bundles.map((bundle, index) => {
142
- if (typeof bundle === "string") {
143
- const id = configId(path.basename(bundle), `bundle-${index + 1}`);
146
+ return bundles
147
+ .map((bundle, index) => {
148
+ if (typeof bundle === "string") {
149
+ const id = configId(path.basename(bundle), `bundle-${index + 1}`);
150
+ if (seen.has(id)) {
151
+ errors.push({ code: "duplicate_bundle_id", bundle: id, message: "Duplicate bundle id." });
152
+ }
153
+ seen.add(id);
154
+ return {
155
+ id,
156
+ root: resolveProjectPath(rootDir, bundle, `bundles[${index}].root`, errors),
157
+ include: [],
158
+ exclude: [],
159
+ };
160
+ }
161
+ const id = configId(bundle?.id, `bundle-${index + 1}`);
144
162
  if (seen.has(id)) {
145
163
  errors.push({ code: "duplicate_bundle_id", bundle: id, message: "Duplicate bundle id." });
146
164
  }
147
165
  seen.add(id);
148
166
  return {
149
167
  id,
150
- root: resolveProjectPath(rootDir, bundle, `bundles[${index}].root`, errors),
151
- include: [],
152
- exclude: [],
168
+ root: resolveProjectPath(
169
+ rootDir,
170
+ (bundle && (bundle.root || bundle.path)) || ".",
171
+ `bundles[${index}].root`,
172
+ errors,
173
+ ),
174
+ include: Array.isArray(bundle.include) ? bundle.include : [],
175
+ exclude: Array.isArray(bundle.exclude) ? bundle.exclude : [],
153
176
  };
154
- }
155
- const id = configId(bundle && bundle.id, `bundle-${index + 1}`);
156
- if (seen.has(id)) {
157
- errors.push({ code: "duplicate_bundle_id", bundle: id, message: "Duplicate bundle id." });
158
- }
159
- seen.add(id);
160
- return {
161
- id,
162
- root: resolveProjectPath(rootDir, (bundle && (bundle.root || bundle.path)) || ".", `bundles[${index}].root`, errors),
163
- include: Array.isArray(bundle.include) ? bundle.include : [],
164
- exclude: Array.isArray(bundle.exclude) ? bundle.exclude : [],
165
- };
166
- }).filter((bundle) => bundle.root);
177
+ })
178
+ .filter((bundle) => bundle.root);
167
179
  }
168
180
 
169
181
  function validateRelationTypes(config, errors) {
@@ -173,7 +185,12 @@ function validateRelationTypes(config, errors) {
173
185
  }
174
186
  (config.relationTypes || []).forEach((type) => {
175
187
  if (!/^[A-Za-z0-9_.-]+$/.test(String(type))) {
176
- errors.push({ code: "invalid_relation_type_name", relationType: String(type), message: "Relation type names may contain only letters, numbers, underscores, dots, and hyphens." });
188
+ errors.push({
189
+ code: "invalid_relation_type_name",
190
+ relationType: String(type),
191
+ message:
192
+ "Relation type names may contain only letters, numbers, underscores, dots, and hyphens.",
193
+ });
177
194
  }
178
195
  });
179
196
  }
@@ -186,34 +203,62 @@ function validatePlugins(config, projectRoot, bundleIds, errors) {
186
203
  (config.plugins || []).forEach((plugin, index) => {
187
204
  const type = plugin && (plugin.type || plugin.name);
188
205
  if (!plugin || typeof plugin !== "object" || Array.isArray(plugin)) {
189
- errors.push({ code: "invalid_plugin", plugin: index, message: "Plugin entries must be objects." });
206
+ errors.push({
207
+ code: "invalid_plugin",
208
+ plugin: index,
209
+ message: "Plugin entries must be objects.",
210
+ });
190
211
  return;
191
212
  }
192
213
  if (!["filesystem", "json-spec"].includes(String(type))) {
193
- errors.push({ code: "unknown_plugin_type", plugin: plugin.name || index, pluginType: type || "", message: "Unknown generator plugin type." });
214
+ errors.push({
215
+ code: "unknown_plugin_type",
216
+ plugin: plugin.name || index,
217
+ pluginType: type || "",
218
+ message: "Unknown generator plugin type.",
219
+ });
194
220
  }
195
221
  if (!plugin.root) {
196
- errors.push({ code: "missing_plugin_root", plugin: plugin.name || index, message: "Plugin root is required." });
222
+ errors.push({
223
+ code: "missing_plugin_root",
224
+ plugin: plugin.name || index,
225
+ message: "Plugin root is required.",
226
+ });
197
227
  } else {
198
228
  resolveProjectPath(projectRoot, plugin.root, `plugins[${index}].root`, errors);
199
229
  }
200
230
  if (!plugin.output) {
201
- errors.push({ code: "missing_plugin_output", plugin: plugin.name || index, message: "Plugin output is required." });
231
+ errors.push({
232
+ code: "missing_plugin_output",
233
+ plugin: plugin.name || index,
234
+ message: "Plugin output is required.",
235
+ });
202
236
  } else {
203
237
  resolveProjectPath(projectRoot, plugin.output, `plugins[${index}].output`, errors);
204
238
  }
205
239
  if (plugin.bundle && !bundleIds.has(String(plugin.bundle))) {
206
- errors.push({ code: "unknown_plugin_bundle", plugin: plugin.name || index, bundle: String(plugin.bundle), message: "Plugin bundle does not exist in project bundles." });
240
+ errors.push({
241
+ code: "unknown_plugin_bundle",
242
+ plugin: plugin.name || index,
243
+ bundle: String(plugin.bundle),
244
+ message: "Plugin bundle does not exist in project bundles.",
245
+ });
207
246
  }
208
247
  if (plugin.destinationBundle && !bundleIds.has(String(plugin.destinationBundle))) {
209
- errors.push({ code: "unknown_plugin_destination_bundle", plugin: plugin.name || index, bundle: String(plugin.destinationBundle), message: "Plugin destinationBundle does not exist in project bundles." });
248
+ errors.push({
249
+ code: "unknown_plugin_destination_bundle",
250
+ plugin: plugin.name || index,
251
+ bundle: String(plugin.destinationBundle),
252
+ message: "Plugin destinationBundle does not exist in project bundles.",
253
+ });
210
254
  }
211
255
  });
212
256
  }
213
257
 
214
258
  function barePackageName(value) {
215
- return typeof value === "string"
216
- && /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(value);
259
+ return (
260
+ typeof value === "string" && /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(value)
261
+ );
217
262
  }
218
263
 
219
264
  function normalizeProducers(config, localBundleIds, errors) {
@@ -223,51 +268,147 @@ function normalizeProducers(config, localBundleIds, errors) {
223
268
  }
224
269
  const names = new Set();
225
270
  const bundles = new Set();
226
- return (config.producers || []).map((producer, index) => {
227
- const field = `producers[${index}]`;
228
- if (!producer || typeof producer !== "object" || Array.isArray(producer)) {
229
- errors.push({ code: "invalid_producer", producer: index, message: "Producer entries must be objects." });
230
- return null;
231
- }
232
- const allowed = new Set(["name", "type", "package", "bundle", "config"]);
233
- Object.keys(producer).filter((key) => !allowed.has(key)).forEach((key) => {
234
- errors.push({ code: "unknown_producer_field", producer: producer.name || index, field: `${field}.${key}`, message: `Unknown producer field: ${key}` });
271
+ return (config.producers || [])
272
+ .map((producer, index) => {
273
+ const field = `producers[${index}]`;
274
+ if (!producer || typeof producer !== "object" || Array.isArray(producer)) {
275
+ errors.push({
276
+ code: "invalid_producer",
277
+ producer: index,
278
+ message: "Producer entries must be objects.",
279
+ });
280
+ return null;
281
+ }
282
+ const allowed = new Set(["name", "type", "package", "bundle", "config"]);
283
+ Object.keys(producer)
284
+ .filter((key) => !allowed.has(key))
285
+ .forEach((key) => {
286
+ errors.push({
287
+ code: "unknown_producer_field",
288
+ producer: producer.name || index,
289
+ field: `${field}.${key}`,
290
+ message: `Unknown producer field: ${key}`,
291
+ });
292
+ });
293
+ const name = typeof producer.name === "string" ? producer.name.trim() : "";
294
+ const type = typeof producer.type === "string" ? producer.type.trim() : "";
295
+ const packageName = typeof producer.package === "string" ? producer.package.trim() : "";
296
+ const bundle = typeof producer.bundle === "string" ? producer.bundle.trim() : "";
297
+ if (!name || !/^[A-Za-z0-9_.-]+$/.test(name)) {
298
+ errors.push({
299
+ code: "invalid_producer_name",
300
+ producer: index,
301
+ field: `${field}.name`,
302
+ message:
303
+ "Producer name must contain only letters, numbers, underscores, dots, and hyphens.",
304
+ });
305
+ } else if (names.has(name)) {
306
+ errors.push({
307
+ code: "duplicate_producer_name",
308
+ producer: name,
309
+ message: "Producer names must be unique.",
310
+ });
311
+ }
312
+ if (name) names.add(name);
313
+ if (!type || !/^[A-Za-z0-9_.-]+$/.test(type)) {
314
+ errors.push({
315
+ code: "invalid_producer_type",
316
+ producer: name || index,
317
+ field: `${field}.type`,
318
+ message:
319
+ "Producer type must contain only letters, numbers, underscores, dots, and hyphens.",
320
+ });
321
+ }
322
+ if (!barePackageName(packageName)) {
323
+ errors.push({
324
+ code: "invalid_producer_package",
325
+ producer: name || index,
326
+ field: `${field}.package`,
327
+ message: "Producer package must be a bare npm package name without a subpath.",
328
+ });
329
+ }
330
+ if (!localBundleIds.has(bundle)) {
331
+ errors.push({
332
+ code: "unknown_producer_bundle",
333
+ producer: name || index,
334
+ bundle,
335
+ message: "Producer bundle must name a local project bundle.",
336
+ });
337
+ } else if (bundles.has(bundle)) {
338
+ errors.push({
339
+ code: "duplicate_producer_bundle",
340
+ producer: name || index,
341
+ bundle,
342
+ message: "Only one producer may manage a local bundle.",
343
+ });
344
+ }
345
+ if (bundle) bundles.add(bundle);
346
+ if (
347
+ producer.config !== undefined &&
348
+ (!producer.config || typeof producer.config !== "object" || Array.isArray(producer.config))
349
+ ) {
350
+ errors.push({
351
+ code: "invalid_producer_config",
352
+ producer: name || index,
353
+ field: `${field}.config`,
354
+ message: "Producer config must be an object.",
355
+ });
356
+ }
357
+ return {
358
+ name,
359
+ type,
360
+ package: packageName,
361
+ bundle,
362
+ config:
363
+ producer.config && typeof producer.config === "object" && !Array.isArray(producer.config)
364
+ ? producer.config
365
+ : {},
366
+ };
367
+ })
368
+ .filter(Boolean);
369
+ }
370
+
371
+ // `languages`: "auto" (default), "none", or the stemming language codes for
372
+ // lexical search (plan R-2); validated against the search language registry.
373
+ function normalizeLanguagesConfig(config, errors) {
374
+ if (config.languages === undefined || config.languages === null) {
375
+ return "auto";
376
+ }
377
+ const value = config.languages;
378
+ if (typeof value !== "string" && !Array.isArray(value)) {
379
+ errors.push({
380
+ code: "invalid_languages",
381
+ field: "languages",
382
+ message: 'languages must be "auto", "none", or an array of language codes.',
235
383
  });
236
- const name = typeof producer.name === "string" ? producer.name.trim() : "";
237
- const type = typeof producer.type === "string" ? producer.type.trim() : "";
238
- const packageName = typeof producer.package === "string" ? producer.package.trim() : "";
239
- const bundle = typeof producer.bundle === "string" ? producer.bundle.trim() : "";
240
- if (!name || !/^[A-Za-z0-9_.-]+$/.test(name)) {
241
- errors.push({ code: "invalid_producer_name", producer: index, field: `${field}.name`, message: "Producer name must contain only letters, numbers, underscores, dots, and hyphens." });
242
- } else if (names.has(name)) {
243
- errors.push({ code: "duplicate_producer_name", producer: name, message: "Producer names must be unique." });
244
- }
245
- if (name) names.add(name);
246
- if (!type || !/^[A-Za-z0-9_.-]+$/.test(type)) {
247
- errors.push({ code: "invalid_producer_type", producer: name || index, field: `${field}.type`, message: "Producer type must contain only letters, numbers, underscores, dots, and hyphens." });
248
- }
249
- if (!barePackageName(packageName)) {
250
- errors.push({ code: "invalid_producer_package", producer: name || index, field: `${field}.package`, message: "Producer package must be a bare npm package name without a subpath." });
251
- }
252
- if (!localBundleIds.has(bundle)) {
253
- errors.push({ code: "unknown_producer_bundle", producer: name || index, bundle, message: "Producer bundle must name a local project bundle." });
254
- } else if (bundles.has(bundle)) {
255
- errors.push({ code: "duplicate_producer_bundle", producer: name || index, bundle, message: "Only one producer may manage a local bundle." });
256
- }
257
- if (bundle) bundles.add(bundle);
258
- if (producer.config !== undefined && (!producer.config || typeof producer.config !== "object" || Array.isArray(producer.config))) {
259
- errors.push({ code: "invalid_producer_config", producer: name || index, field: `${field}.config`, message: "Producer config must be an object." });
260
- }
261
- return {
262
- name,
263
- type,
264
- package: packageName,
265
- bundle,
266
- config: producer.config && typeof producer.config === "object" && !Array.isArray(producer.config)
267
- ? producer.config
268
- : {},
269
- };
270
- }).filter(Boolean);
384
+ return "auto";
385
+ }
386
+ try {
387
+ return normalizeLanguages(value);
388
+ } catch (error) {
389
+ errors.push({ code: "invalid_languages", field: "languages", message: error.message });
390
+ return "auto";
391
+ }
392
+ }
393
+
394
+ // `autoFill` (R-1, 0.11.0-rc.2): under search mode auto, the any-term
395
+ // results follow the all-term hits when there are fewer than this many of
396
+ // them. An integer from 0 (fall back only when nothing matches every term)
397
+ // to 250; unset keeps the search default (3).
398
+ function normalizeAutoFillConfig(config, errors) {
399
+ if (config.autoFill === undefined || config.autoFill === null) {
400
+ return undefined;
401
+ }
402
+ const value = config.autoFill;
403
+ if (!Number.isSafeInteger(value) || value < 0 || value > 250) {
404
+ errors.push({
405
+ code: "invalid_auto_fill",
406
+ field: "autoFill",
407
+ message: "autoFill must be an integer between 0 and 250.",
408
+ });
409
+ return undefined;
410
+ }
411
+ return value;
271
412
  }
272
413
 
273
414
  function normalizeRemoteBundles(config, errors) {
@@ -278,32 +419,51 @@ function normalizeRemoteBundles(config, errors) {
278
419
  }
279
420
  const seen = new Set();
280
421
  return remotes.map((remote, index) => {
281
- const id = configId(remote && remote.id, `remote-${index + 1}`);
422
+ const id = configId(remote?.id, `remote-${index + 1}`);
282
423
  if (seen.has(id)) {
283
- errors.push({ code: "duplicate_remote_bundle_id", bundle: id, message: "Duplicate remote bundle id." });
424
+ errors.push({
425
+ code: "duplicate_remote_bundle_id",
426
+ bundle: id,
427
+ message: "Duplicate remote bundle id.",
428
+ });
284
429
  }
285
430
  seen.add(id);
286
- const provider = String((remote && remote.provider) || "github");
431
+ const provider = String(remote?.provider || "github");
287
432
  if (provider !== "github") {
288
- errors.push({ code: "unsupported_remote_provider", bundle: id, provider, message: "Only github remote bundles are supported." });
433
+ errors.push({
434
+ code: "unsupported_remote_provider",
435
+ bundle: id,
436
+ provider,
437
+ message: "Only github remote bundles are supported.",
438
+ });
289
439
  }
290
- if (!remote || !remote.url) {
291
- errors.push({ code: "missing_remote_url", bundle: id, message: "Remote bundle url is required." });
440
+ if (!remote?.url) {
441
+ errors.push({
442
+ code: "missing_remote_url",
443
+ bundle: id,
444
+ message: "Remote bundle url is required.",
445
+ });
292
446
  }
293
447
  return {
294
448
  id,
295
449
  provider,
296
- url: remote && remote.url ? String(remote.url) : "",
297
- include: Array.isArray(remote && remote.include) ? remote.include : [],
298
- exclude: Array.isArray(remote && remote.exclude) ? remote.exclude : [],
450
+ url: remote?.url ? String(remote.url) : "",
451
+ include: Array.isArray(remote?.include) ? remote.include : [],
452
+ exclude: Array.isArray(remote?.exclude) ? remote.exclude : [],
299
453
  };
300
454
  });
301
455
  }
302
456
 
457
+ // `writePolicy`: per-actor rules for live writes (plan W-1), parsed here so
458
+ // a malformed policy is a project error and no writable store starts on it.
459
+ function normalizeWritePolicyConfig(config, errors) {
460
+ const parsed = parseWritePolicy(config.writePolicy);
461
+ errors.push(...parsed.errors);
462
+ return parsed.policy;
463
+ }
464
+
303
465
  function loadProjectConfig(configPath) {
304
- const requestedPath = configPath
305
- ? path.resolve(configPath)
306
- : findProjectConfig(process.cwd());
466
+ const requestedPath = configPath ? path.resolve(configPath) : findProjectConfig(process.cwd());
307
467
  if (!requestedPath) {
308
468
  throw new Error("No okf.project.yaml or okf.project.json found. Pass --project or --bundle.");
309
469
  }
@@ -313,24 +473,44 @@ function loadProjectConfig(configPath) {
313
473
  if (!rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig)) {
314
474
  errors.push({ code: "invalid_project_config", message: "Project config must be an object." });
315
475
  }
316
- const config = (!rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig)) ? {} : rawConfig;
476
+ const config =
477
+ !rawConfig || typeof rawConfig !== "object" || Array.isArray(rawConfig) ? {} : rawConfig;
317
478
  validateRelationTypes(config, errors);
318
479
  if (config.strictLinks !== undefined && typeof config.strictLinks !== "boolean") {
319
- errors.push({ code: "invalid_strict_links", field: "strictLinks", message: "strictLinks must be a boolean." });
480
+ errors.push({
481
+ code: "invalid_strict_links",
482
+ field: "strictLinks",
483
+ message: "strictLinks must be a boolean.",
484
+ });
320
485
  }
321
- const relationTypes = new Set(DEFAULT_RELATION_TYPES.concat(Array.isArray(config.relationTypes) ? config.relationTypes.map(String) : []));
486
+ const relationTypes = new Set(
487
+ DEFAULT_RELATION_TYPES.concat(
488
+ Array.isArray(config.relationTypes) ? config.relationTypes.map(String) : [],
489
+ ),
490
+ );
322
491
  const bundles = normalizeBundles(config, resolvedPath, errors);
323
492
  const remoteBundles = normalizeRemoteBundles(config, errors);
324
493
  const localBundleIds = new Set(bundles.map((bundle) => bundle.id));
325
494
  const allBundleIds = new Set(bundles.map((bundle) => bundle.id));
326
495
  remoteBundles.forEach((bundle) => {
327
496
  if (allBundleIds.has(bundle.id)) {
328
- errors.push({ code: "duplicate_bundle_id", bundle: bundle.id, message: "Remote bundle id duplicates a local bundle id." });
497
+ errors.push({
498
+ code: "duplicate_bundle_id",
499
+ bundle: bundle.id,
500
+ message: "Remote bundle id duplicates a local bundle id.",
501
+ });
329
502
  }
330
503
  allBundleIds.add(bundle.id);
331
504
  });
332
505
  validatePlugins(config, path.dirname(resolvedPath), allBundleIds, errors);
333
506
  const producers = normalizeProducers(config, localBundleIds, errors);
507
+ const languages = normalizeLanguagesConfig(config, errors);
508
+ const autoFill = normalizeAutoFillConfig(config, errors);
509
+ const writePolicy = normalizeWritePolicyConfig(config, errors);
510
+ // Hybrid search (WP3c): embedder, cacheDir, fusion.alpha, embedUnits; null when off.
511
+ // WP3c-2: fusion.alpha may be "adaptive", with fusion.adaptive { low, mid, high }.
512
+ // WP3c-2: confidence.minSimilarity, the abstention similarity threshold.
513
+ const embedding = normalizeEmbeddingConfig(config, errors);
334
514
  return {
335
515
  path: resolvedPath,
336
516
  root: path.dirname(resolvedPath),
@@ -341,6 +521,10 @@ function loadProjectConfig(configPath) {
341
521
  plugins: Array.isArray(config.plugins) ? config.plugins : [],
342
522
  producers,
343
523
  strictLinks: Boolean(config.strictLinks),
524
+ languages,
525
+ autoFill,
526
+ writePolicy,
527
+ embedding,
344
528
  errors,
345
529
  raw: config,
346
530
  };