@kb-labs/mind-entry 2.93.0 → 2.96.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 (98) hide show
  1. package/README.md +19 -208
  2. package/dist/cli/commands/ask.d.ts +31 -0
  3. package/dist/cli/commands/ask.js +88 -0
  4. package/dist/cli/commands/ask.js.map +1 -0
  5. package/dist/cli/commands/drop.d.ts +10 -0
  6. package/dist/cli/commands/drop.js +90 -0
  7. package/dist/cli/commands/drop.js.map +1 -0
  8. package/dist/cli/commands/explore.d.ts +26 -0
  9. package/dist/cli/commands/explore.js +96 -0
  10. package/dist/cli/commands/explore.js.map +1 -0
  11. package/dist/cli/commands/index.d.ts +11 -0
  12. package/dist/cli/commands/index.js +96 -0
  13. package/dist/cli/commands/index.js.map +1 -0
  14. package/dist/cli/commands/reindex.d.ts +11 -0
  15. package/dist/cli/commands/reindex.js +71 -0
  16. package/dist/cli/commands/reindex.js.map +1 -0
  17. package/dist/cli/commands/search.d.ts +25 -0
  18. package/dist/cli/commands/search.js +94 -0
  19. package/dist/cli/commands/search.js.map +1 -0
  20. package/dist/cli/commands/status.d.ts +17 -0
  21. package/dist/cli/commands/status.js +89 -0
  22. package/dist/cli/commands/status.js.map +1 -0
  23. package/dist/cli/commands/sync-add.d.ts +11 -0
  24. package/dist/cli/commands/sync-add.js +74 -0
  25. package/dist/cli/commands/sync-add.js.map +1 -0
  26. package/dist/cli/commands/sync-delete.d.ts +11 -0
  27. package/dist/cli/commands/sync-delete.js +90 -0
  28. package/dist/cli/commands/sync-delete.js.map +1 -0
  29. package/dist/cli/commands/sync-list.d.ts +13 -0
  30. package/dist/cli/commands/sync-list.js +80 -0
  31. package/dist/cli/commands/sync-list.js.map +1 -0
  32. package/dist/cli/commands/sync-status.d.ts +8 -0
  33. package/dist/cli/commands/sync-status.js +71 -0
  34. package/dist/cli/commands/sync-status.js.map +1 -0
  35. package/dist/cli/commands/sync-update.d.ts +11 -0
  36. package/dist/cli/commands/sync-update.js +74 -0
  37. package/dist/cli/commands/sync-update.js.map +1 -0
  38. package/dist/index.d.ts +2 -596
  39. package/dist/index.js +208 -1449
  40. package/dist/index.js.map +1 -1
  41. package/dist/manifest.d.ts +206 -0
  42. package/dist/manifest.js +261 -0
  43. package/dist/manifest.js.map +1 -0
  44. package/dist/rest/handlers/drop.d.ts +12 -0
  45. package/dist/rest/handlers/drop.js +59 -0
  46. package/dist/rest/handlers/drop.js.map +1 -0
  47. package/dist/rest/handlers/explore.d.ts +30 -0
  48. package/dist/rest/handlers/explore.js +59 -0
  49. package/dist/rest/handlers/explore.js.map +1 -0
  50. package/dist/rest/handlers/health.d.ts +11 -0
  51. package/dist/rest/handlers/health.js +58 -0
  52. package/dist/rest/handlers/health.js.map +1 -0
  53. package/dist/rest/handlers/index.d.ts +15 -0
  54. package/dist/rest/handlers/index.js +59 -0
  55. package/dist/rest/handlers/index.js.map +1 -0
  56. package/dist/rest/handlers/query.d.ts +36 -0
  57. package/dist/rest/handlers/query.js +59 -0
  58. package/dist/rest/handlers/query.js.map +1 -0
  59. package/dist/rest/handlers/reindex.d.ts +14 -0
  60. package/dist/rest/handlers/reindex.js +59 -0
  61. package/dist/rest/handlers/reindex.js.map +1 -0
  62. package/dist/rest/handlers/search.d.ts +31 -0
  63. package/dist/rest/handlers/search.js +59 -0
  64. package/dist/rest/handlers/search.js.map +1 -0
  65. package/dist/rest/handlers/status.d.ts +19 -0
  66. package/dist/rest/handlers/status.js +58 -0
  67. package/dist/rest/handlers/status.js.map +1 -0
  68. package/dist/rest/handlers/sync-add.d.ts +14 -0
  69. package/dist/rest/handlers/sync-add.js +59 -0
  70. package/dist/rest/handlers/sync-add.js.map +1 -0
  71. package/dist/rest/handlers/sync-delete.d.ts +14 -0
  72. package/dist/rest/handlers/sync-delete.js +59 -0
  73. package/dist/rest/handlers/sync-delete.js.map +1 -0
  74. package/dist/rest/handlers/sync-list.d.ts +15 -0
  75. package/dist/rest/handlers/sync-list.js +58 -0
  76. package/dist/rest/handlers/sync-list.js.map +1 -0
  77. package/dist/rest/handlers/sync-status.d.ts +14 -0
  78. package/dist/rest/handlers/sync-status.js +58 -0
  79. package/dist/rest/handlers/sync-status.js.map +1 -0
  80. package/dist/rest/handlers/sync-update.d.ts +14 -0
  81. package/dist/rest/handlers/sync-update.js +59 -0
  82. package/dist/rest/handlers/sync-update.js.map +1 -0
  83. package/package.json +15 -19
  84. package/dist/cli/commands/init.d.ts +0 -24
  85. package/dist/cli/commands/init.js +0 -115
  86. package/dist/cli/commands/init.js.map +0 -1
  87. package/dist/cli/commands/rag-index.d.ts +0 -20
  88. package/dist/cli/commands/rag-index.js +0 -364
  89. package/dist/cli/commands/rag-index.js.map +0 -1
  90. package/dist/cli/commands/rag-query.d.ts +0 -25
  91. package/dist/cli/commands/rag-query.js +0 -670
  92. package/dist/cli/commands/rag-query.js.map +0 -1
  93. package/dist/cli/commands/verify.d.ts +0 -15
  94. package/dist/cli/commands/verify.js +0 -92
  95. package/dist/cli/commands/verify.js.map +0 -1
  96. package/dist/manifest.v3.d.ts +0 -52
  97. package/dist/manifest.v3.js +0 -182
  98. package/dist/manifest.v3.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,1501 +1,260 @@
1
- import { combinePermissions, kbPlatformPreset, defineCommand, useConfig as useConfig$1, usePlatform, useLoader, useLLM, useEnv } from '@kb-labs/sdk';
2
- import { readFile } from 'fs/promises';
3
- import * as path2 from 'path';
4
- import { join } from 'path';
5
- import { loadManifest, MindEngine } from '@kb-labs/mind-engine';
6
- import { createHash } from 'crypto';
7
- import { isAgentError, createAgentQueryOrchestrator } from '@kb-labs/mind-orchestrator';
8
- import { defaultMindSyncConfig } from '@kb-labs/mind-contracts';
9
- import { z } from 'zod';
10
- import { initMindStructure } from '@kb-labs/mind-indexer';
11
- import { promises } from 'fs';
1
+ import { combinePermissions, kbPlatformPreset, defineCommandFlags } from '@kb-labs/sdk';
2
+ import { MIND_ROUTES, indexFlags, searchFlags, askFlags, exploreFlags, reindexFlags, dropFlags, syncPathsFlags, syncDeleteFlags, syncListFlags, statusFlags, MIND_BASE_PATH } from '@kb-labs/mind-contracts';
12
3
 
13
- // src/manifest.v3.ts
14
- var pluginPermissions = combinePermissions().with(kbPlatformPreset).withEnv([
15
- "NODE_ENV",
16
- "OPENAI_API_KEY",
17
- "QDRANT_URL",
18
- "QDRANT_API_KEY",
19
- "EMBEDDING_PROVIDER",
20
- "VECTOR_STORE_TYPE",
21
- "KB_SKIP_DEDUPLICATION",
22
- "NO_COLOR"
23
- ]).withFs({
4
+ // src/manifest.ts
5
+ var pluginPermissions = combinePermissions().with(kbPlatformPreset).withFs({
24
6
  mode: "readWrite",
25
- allow: [
26
- ".kb/mind/**",
27
- // Mind index data
28
- ".kb/cache/**"
29
- // Cache directory
30
- ]
31
- }).withFs({
32
- mode: "read",
33
- allow: [
34
- "package.json",
35
- "**/package.json",
36
- "config/**",
37
- "**/*.ts",
38
- "**/*.tsx",
39
- "**/*.js",
40
- "**/*.jsx",
41
- "**/*.md"
42
- ]
43
- }).withNetwork({
44
- fetch: [
45
- "https://api.openai.com/*",
46
- // OpenAI embeddings/LLM
47
- "http://localhost:6333/*",
48
- // Qdrant vector store (local)
49
- "http://127.0.0.1:6333/*",
50
- "https://*.qdrant.io/*"
51
- // Qdrant cloud
52
- ]
7
+ // Distinct from old `@kb-labs/mind` (.kb/mind/**) so the two coexist
8
+ // during development; renamed to .kb/mind/** at the Phase 6 swap.
9
+ allow: [".kb/mind/**"]
53
10
  }).withPlatform({
54
11
  llm: true,
55
- // LLM for query orchestration
56
12
  embeddings: true,
57
- // Embedding generation
58
13
  vectorStore: { collections: ["mind:"] },
59
- // Vector DB with mind: namespace
60
- cache: true,
61
- // State caching
62
- analytics: true,
63
- // Analytics tracking
64
- storage: true
65
- // Artifact storage
14
+ cache: ["mind:"],
15
+ storage: true,
16
+ analytics: true
66
17
  }).withQuotas({
67
- timeoutMs: 12e5,
68
- // 20 minutes for indexing
69
- memoryMb: 4096,
70
- // 4GB for large codebases
71
- cpuMs: 6e5
72
- // 10 minutes CPU time
18
+ timeoutMs: 6e5,
19
+ memoryMb: 512
73
20
  }).build();
74
21
  var manifest = {
75
22
  schema: "kb.plugin/3",
76
23
  id: "@kb-labs/mind",
77
24
  version: "0.1.0",
25
+ configSection: "mind",
78
26
  display: {
79
- name: "Mind",
80
- description: "AI-powered code search and RAG system for semantic codebase understanding.",
81
- tags: ["search", "rag", "ai", "semantic", "mind-index"]
27
+ name: "Mind (RAG)",
28
+ description: "Retrieval-augmented knowledge engine \u2014 index and query your codebase and docs",
29
+ tags: ["rag", "search", "embeddings", "ai", "mind"]
82
30
  },
83
- // Configuration section in kb.config.json
84
- configSection: "mind",
85
- // Platform requirements
86
31
  platform: {
87
- requires: ["llm", "embeddings", "vectorStore", "cache", "storage"],
88
- optional: ["analytics", "logger"]
32
+ requires: ["cache", "storage"],
33
+ optional: ["llm", "embeddings", "vectorStore", "analytics"]
89
34
  },
90
- // ✅ PERMISSIONS DEFINED ONCE FOR ENTIRE PLUGIN (Manifest-First)
91
- // All commands, routes, and actions inherit these permissions
92
35
  permissions: pluginPermissions,
93
- // CLI commands (V3 structure with cli wrapper)
94
36
  cli: {
37
+ groupMeta: [{ path: "mind", describe: "Mind \u2014 RAG index & search" }],
95
38
  commands: [
96
39
  {
97
- id: "mind:init",
98
- group: "mind",
99
- describe: "Initialize mind workspace",
100
- handler: "./cli/commands/init.js#default",
101
- handlerPath: "./cli/commands/init.js"
40
+ path: "mind index",
41
+ category: "Index",
42
+ operationType: "mutate",
43
+ describe: "Build or refresh a Mind index from source files.",
44
+ handler: "./cli/commands/index.js#default",
45
+ flags: defineCommandFlags(indexFlags.schema),
46
+ examples: ["kb mind index", "kb mind index --index code --scope src/"]
47
+ },
48
+ {
49
+ path: "mind search",
50
+ category: "Query",
51
+ operationType: "read",
52
+ describe: "Semantic + keyword search over a Mind index.",
53
+ handler: "./cli/commands/search.js#default",
54
+ flags: defineCommandFlags(searchFlags.schema),
55
+ examples: [
56
+ 'kb mind search --text "how does login work"',
57
+ 'kb mind search --text "ClassName" --index code --agent'
58
+ ]
102
59
  },
103
60
  {
104
- id: "mind:verify",
105
- group: "mind",
106
- describe: "Verify workspace consistency",
107
- handler: "./cli/commands/verify.js#default",
108
- handlerPath: "./cli/commands/verify.js"
61
+ path: "mind ask",
62
+ category: "Query",
63
+ operationType: "read",
64
+ describe: "Ask a question and get a grounded answer with citations.",
65
+ handler: "./cli/commands/ask.js#default",
66
+ flags: defineCommandFlags(askFlags.schema),
67
+ examples: [
68
+ 'kb mind ask --text "how does auth work" --index code',
69
+ 'kb mind ask --text "billing flow" --mode thinking --agent'
70
+ ]
109
71
  },
110
72
  {
111
- id: "mind:rag-index",
112
- group: "mind",
113
- describe: "Build Mind indexes",
114
- handler: "./cli/commands/rag-index.js#default",
115
- handlerPath: "./cli/commands/rag-index.js"
73
+ path: "mind explore",
74
+ category: "Query",
75
+ operationType: "read",
76
+ describe: "Task-orientation map \u2014 where to start and how involved a task looks.",
77
+ handler: "./cli/commands/explore.js#default",
78
+ flags: defineCommandFlags(exploreFlags.schema),
79
+ examples: [
80
+ 'kb mind explore --task "add rate limiting to the gateway" --index code',
81
+ 'kb mind explore --task "where is auth handled" --format json'
82
+ ]
116
83
  },
117
84
  {
118
- id: "mind:rag-query",
119
- group: "mind",
120
- describe: "Run semantic RAG query",
121
- handler: "./cli/commands/rag-query.js#default",
122
- handlerPath: "./cli/commands/rag-query.js"
85
+ path: "mind reindex",
86
+ category: "Index",
87
+ operationType: "mutate",
88
+ describe: "Rebuild an index from source files.",
89
+ handler: "./cli/commands/reindex.js#default",
90
+ flags: defineCommandFlags(reindexFlags.schema),
91
+ examples: ["kb mind reindex --index code --full"]
123
92
  },
124
- // Sync commands (5 separate commands instead of subcommands)
125
93
  {
126
- id: "mind:sync-add",
127
- group: "mind",
128
- describe: "Add document to sync",
94
+ path: "mind drop",
95
+ category: "Index",
96
+ operationType: "mutate",
97
+ describe: "Drop an entire index (all vectors + manifest).",
98
+ handler: "./cli/commands/drop.js#default",
99
+ flags: defineCommandFlags(dropFlags.schema),
100
+ examples: ["kb mind drop --index kbrt --yes"]
101
+ },
102
+ {
103
+ path: "mind sync add",
104
+ category: "Sync",
105
+ operationType: "mutate",
106
+ describe: "Add documents to an index (incremental).",
129
107
  handler: "./cli/commands/sync-add.js#default",
130
- handlerPath: "./cli/commands/sync-add.js"
108
+ flags: defineCommandFlags(syncPathsFlags.schema),
109
+ examples: ["kb mind sync add src/new.ts --index code"]
131
110
  },
132
111
  {
133
- id: "mind:sync-update",
134
- group: "mind",
135
- describe: "Update synced document",
112
+ path: "mind sync update",
113
+ category: "Sync",
114
+ operationType: "mutate",
115
+ describe: "Re-index updated documents (incremental).",
136
116
  handler: "./cli/commands/sync-update.js#default",
137
- handlerPath: "./cli/commands/sync-update.js"
117
+ flags: defineCommandFlags(syncPathsFlags.schema),
118
+ examples: ["kb mind sync update src/auth.ts --index code"]
138
119
  },
139
120
  {
140
- id: "mind:sync-delete",
141
- group: "mind",
142
- describe: "Delete synced document",
121
+ path: "mind sync delete",
122
+ category: "Sync",
123
+ operationType: "mutate",
124
+ describe: "Remove documents from an index (incremental).",
143
125
  handler: "./cli/commands/sync-delete.js#default",
144
- handlerPath: "./cli/commands/sync-delete.js"
126
+ flags: defineCommandFlags(syncDeleteFlags.schema),
127
+ examples: ["kb mind sync delete src/old.ts --index code"]
145
128
  },
146
129
  {
147
- id: "mind:sync-list",
148
- group: "mind",
149
- describe: "List synced documents",
130
+ path: "mind sync list",
131
+ category: "Sync",
132
+ operationType: "read",
133
+ describe: "List documents synced into an index.",
150
134
  handler: "./cli/commands/sync-list.js#default",
151
- handlerPath: "./cli/commands/sync-list.js"
135
+ flags: defineCommandFlags(syncListFlags.schema),
136
+ examples: ["kb mind sync list --index code"]
152
137
  },
153
138
  {
154
- id: "mind:sync-status",
155
- group: "mind",
156
- describe: "Show sync status",
139
+ // Leaf must be unique across the group tree: `mind status` already
140
+ // uses leaf `status`, so the sync variant uses `health`.
141
+ path: "mind sync health",
142
+ category: "Sync",
143
+ operationType: "read",
144
+ describe: "Show sync health for an index.",
157
145
  handler: "./cli/commands/sync-status.js#default",
158
- handlerPath: "./cli/commands/sync-status.js"
146
+ flags: defineCommandFlags(syncListFlags.schema),
147
+ examples: ["kb mind sync health --index code"]
148
+ },
149
+ {
150
+ path: "mind status",
151
+ category: "Index",
152
+ operationType: "read",
153
+ describe: "Show Mind index status.",
154
+ handler: "./cli/commands/status.js#default",
155
+ flags: defineCommandFlags(statusFlags.schema),
156
+ examples: ["kb mind status", "kb mind status --index code"]
159
157
  }
160
158
  ]
161
159
  },
162
- // Scheduled jobs (inherit permissions from manifest)
163
- actions: [
164
- {
165
- id: "auto-index",
166
- handler: "./handlers/auto-index.js#run",
167
- schedule: "0 * * * *",
168
- // Every hour
169
- description: "Automatically index Mind RAG database",
170
- enabled: false
171
- // Disabled by default
172
- }
173
- ],
174
- // Artifacts
175
- artifacts: [
176
- {
177
- id: "mind.index.json",
178
- pathTemplate: ".kb/mind/index/index.json",
179
- description: "Mind RAG index metadata."
180
- },
181
- {
182
- id: "mind.cache.json",
183
- pathTemplate: ".kb/cache/mind-*.json",
184
- description: "Mind query cache files."
185
- }
186
- ]
187
- };
188
- var MIND_PRODUCT_ID = "mind";
189
- async function createMindRuntime(options) {
190
- const config = await resolveConfig(options.cwd, options.config);
191
- const platform = options.platform ?? usePlatform();
192
- const service = {
193
- index: async (scopeId) => {
194
- const scope = resolveScope(config, scopeId);
195
- const engine = createEngine(config, scope, options.cwd, options.runtime, platform, options.onProgress);
196
- await engine.init();
197
- const stats = await engine.index(resolveSources(config, scope), {
198
- scope,
199
- workspaceRoot: options.cwd
200
- });
201
- return stats;
202
- },
203
- query: async (queryOptions) => {
204
- if (queryOptions.productId && queryOptions.productId !== MIND_PRODUCT_ID) {
205
- throw new Error(`Unsupported productId "${queryOptions.productId}". Expected "${MIND_PRODUCT_ID}".`);
206
- }
207
- const scope = resolveScope(config, queryOptions.scopeId);
208
- const sources = resolveSources(config, scope);
209
- const engine = createEngine(config, scope, options.cwd, options.runtime, platform, options.onProgress);
210
- await engine.init();
211
- const result = await engine.query(
212
- {
213
- text: queryOptions.text,
214
- intent: queryOptions.intent ?? "summary",
215
- limit: queryOptions.limit,
216
- profileId: queryOptions.profileId,
217
- metadata: queryOptions.metadata
218
- },
219
- {
220
- scope,
221
- sources,
222
- workspaceRoot: options.cwd,
223
- limit: queryOptions.limit,
224
- profile: queryOptions.profileId ? { id: queryOptions.profileId } : void 0
225
- }
226
- );
227
- return result;
228
- }
229
- };
230
- return {
231
- service,
232
- config
233
- };
234
- }
235
- function createEngine(config, scope, cwd, runtime, platform, onProgress) {
236
- const engineConfig = resolveEngineConfig(config, scope);
237
- return new MindEngine(
238
- {
239
- id: engineConfig.id,
240
- type: engineConfig.type,
241
- options: {
242
- ...engineConfig.options ?? {},
243
- _runtime: runtime,
244
- platform: platform ?? void 0,
245
- onProgress
246
- }
247
- },
248
- {
249
- workspaceRoot: cwd
250
- }
251
- );
252
- }
253
- function resolveSources(config, scope) {
254
- if (!scope.sourceIds?.length) {
255
- return config.sources;
256
- }
257
- const selected = config.sources.filter((source) => scope.sourceIds.includes(source.id));
258
- if (!selected.length) {
259
- throw new Error(`Scope "${scope.id}" does not reference existing sources.`);
260
- }
261
- return selected;
262
- }
263
- function resolveScope(config, scopeId) {
264
- const scope = config.scopes.find((item) => item.id === scopeId);
265
- if (!scope) {
266
- throw new Error(`Scope "${scopeId}" is not defined in mind.scopes.`);
267
- }
268
- return scope;
269
- }
270
- function resolveEngineConfig(config, scope) {
271
- const engineId = scope.defaultEngine ?? config.defaults?.fallbackEngineId ?? config.engines[0]?.id;
272
- if (!engineId) {
273
- throw new Error("No engines configured in mind config.");
274
- }
275
- const engine = config.engines.find((item) => item.id === engineId);
276
- if (!engine) {
277
- throw new Error(`Engine "${engineId}" referenced by scope "${scope.id}" does not exist.`);
278
- }
279
- return engine;
280
- }
281
- async function resolveConfig(cwd, provided) {
282
- if (provided) {
283
- return normalizeConfig(provided);
284
- }
285
- const configPath = await findConfigPath(cwd);
286
- const raw = JSON.parse(await readFile(configPath, "utf8"));
287
- return normalizeConfig(raw);
288
- }
289
- async function findConfigPath(cwd) {
290
- const candidates = [
291
- path2.resolve(cwd, ".kb/kb.config.json"),
292
- path2.resolve(cwd, "kb.config.json")
293
- ];
294
- for (const candidate of candidates) {
295
- try {
296
- await readFile(candidate, "utf8");
297
- return candidate;
298
- } catch {
299
- }
300
- }
301
- throw new Error("No kb.config.json found. Expected .kb/kb.config.json or kb.config.json.");
302
- }
303
- function normalizeConfig(raw) {
304
- const data = raw;
305
- if (Array.isArray(data.profiles) && data.profiles.length > 0) {
306
- const profile = data.profiles.find((p) => p.id === "default") ?? data.profiles[0];
307
- const products = profile?.products;
308
- const mindConfig = products?.[MIND_PRODUCT_ID];
309
- if (!mindConfig) {
310
- throw new Error("Config does not contain profiles[].products.mind section.");
311
- }
312
- return validateConfig(mindConfig);
313
- }
314
- if (data.mind && typeof data.mind === "object") {
315
- return validateConfig(data.mind);
316
- }
317
- return validateConfig(data);
318
- }
319
- function validateConfig(config) {
320
- if (!Array.isArray(config.sources) || !Array.isArray(config.scopes) || !Array.isArray(config.engines)) {
321
- throw new Error("Invalid mind config: required arrays sources/scopes/engines are missing.");
322
- }
323
- return config;
324
- }
325
- var globalOrchestrator = null;
326
- function getAdapterName(service, fallback) {
327
- if (!service || typeof service !== "object") {
328
- return fallback;
329
- }
330
- const s = service;
331
- const name = s.constructor?.name || s.name || s.id;
332
- if (name && name !== "Object" && name !== "Function") {
333
- return name;
334
- }
335
- return fallback;
336
- }
337
- async function runRagIndex(options) {
338
- const platform = options.platform ?? usePlatform();
339
- const adapters = {
340
- vectorStore: getAdapterName(platform?.vectorStore, "LocalVectorStore (fallback)"),
341
- embeddings: getAdapterName(platform?.embeddings, "DeterministicEmbeddings (fallback)"),
342
- storage: getAdapterName(platform?.storage, "MemoryStorage (fallback)"),
343
- llm: getAdapterName(platform?.llm, "LocalStubLLM (fallback)"),
344
- cache: getAdapterName(platform?.cache, "MemoryCache (fallback)")
345
- };
346
- let effectiveConfig = options.config;
347
- if (options.include || options.exclude) {
348
- let mindConfig = effectiveConfig;
349
- if (mindConfig?.sources && Array.isArray(mindConfig.sources)) {
350
- mindConfig = { ...mindConfig };
351
- mindConfig.sources = mindConfig.sources.map((source) => {
352
- const overriddenSource = { ...source };
353
- if (options.include) {
354
- overriddenSource.paths = [options.include];
355
- }
356
- if (options.exclude) {
357
- overriddenSource.exclude = options.exclude.split(",").map((s) => s.trim());
358
- }
359
- return overriddenSource;
360
- });
361
- effectiveConfig = mindConfig;
362
- }
363
- }
364
- const runtime = await createMindRuntime({
365
- cwd: options.cwd,
366
- config: effectiveConfig,
367
- runtime: "runtime" in options ? options.runtime : void 0,
368
- platform: options.platform
369
- });
370
- const allScopeIds = runtime.config.scopes?.map((scope) => scope.id) ?? [];
371
- if (!allScopeIds.length) {
372
- throw new Error("No mind scopes found. Update kb.config.json first.");
373
- }
374
- const scopeIds = options.scopeId ? allScopeIds.filter((scopeId) => scopeId === options.scopeId) : allScopeIds;
375
- if (!scopeIds.length) {
376
- throw new Error(
377
- `Scope "${options.scopeId}" is not defined in mind.scopes.`
378
- );
379
- }
380
- const originalSkipDedup = process.env.KB_SKIP_DEDUPLICATION;
381
- if (options.skipDeduplication) {
382
- process.env.KB_SKIP_DEDUPLICATION = "true";
383
- }
384
- const aggregatedStats = {
385
- filesDiscovered: 0,
386
- filesProcessed: 0,
387
- filesSkipped: 0,
388
- chunksStored: 0,
389
- chunksUpdated: 0,
390
- chunksSkipped: 0,
391
- errorCount: 0,
392
- durationMs: 0,
393
- deletedFiles: 0,
394
- deletedChunks: 0,
395
- invalidChunks: 0
396
- };
397
- try {
398
- for (const scopeId of scopeIds) {
399
- const scopeStats = await runtime.service.index(scopeId);
400
- if (scopeStats) {
401
- aggregatedStats.filesDiscovered += scopeStats.filesDiscovered;
402
- aggregatedStats.filesProcessed += scopeStats.filesProcessed;
403
- aggregatedStats.filesSkipped += scopeStats.filesSkipped;
404
- aggregatedStats.chunksStored += scopeStats.chunksStored;
405
- aggregatedStats.chunksUpdated += scopeStats.chunksUpdated;
406
- aggregatedStats.chunksSkipped += scopeStats.chunksSkipped;
407
- aggregatedStats.errorCount += scopeStats.errorCount;
408
- aggregatedStats.durationMs += scopeStats.durationMs;
409
- aggregatedStats.deletedFiles = (aggregatedStats.deletedFiles ?? 0) + (scopeStats.deletedFiles ?? 0);
410
- aggregatedStats.deletedChunks = (aggregatedStats.deletedChunks ?? 0) + (scopeStats.deletedChunks ?? 0);
411
- aggregatedStats.invalidChunks = (aggregatedStats.invalidChunks ?? 0) + (scopeStats.invalidChunks ?? 0);
412
- }
413
- }
414
- } finally {
415
- if (originalSkipDedup === void 0) {
416
- delete process.env.KB_SKIP_DEDUPLICATION;
417
- } else {
418
- process.env.KB_SKIP_DEDUPLICATION = originalSkipDedup;
419
- }
420
- }
421
- if (globalOrchestrator) {
422
- await globalOrchestrator.invalidateCache(scopeIds);
423
- }
424
- return { scopeIds, adapters, stats: aggregatedStats };
425
- }
426
- async function runRagQuery(options) {
427
- const onProgressEvent = options.onProgress ? (event) => {
428
- try {
429
- const stageMap = {
430
- "using_reasoning_engine": "Using reasoning engine",
431
- "reasoning_completed": "Reasoning completed",
432
- "analyzing_query_complexity": "Analyzing query complexity",
433
- "query_is_simple": "Query is simple",
434
- "planning_query": "Planning query",
435
- "query_plan_generated": "Query plan generated",
436
- "executing_subqueries": "Executing subqueries",
437
- "subqueries_completed": "Subqueries completed",
438
- "synthesizing_context": "Synthesizing context",
439
- "context_synthesis_completed": "Context synthesis completed",
440
- "generating_embedding": "Generating embeddings",
441
- "performing_hybrid_search": "Performing hybrid search",
442
- "searching_vector_store": "Searching vector store",
443
- "search_completed": "Search completed",
444
- "applying_popularity_boost": "Applying popularity boost",
445
- "applying_query_pattern_boost": "Applying query pattern boost",
446
- "re_ranking_results": "Re-ranking results",
447
- "re_ranking_completed": "Re-ranking completed",
448
- "compression_applied": "Compression applied",
449
- "saving_query_history": "Saving query history"
450
- };
451
- const humanReadableStage = stageMap[event.stage] || event.stage;
452
- let enhancedDetails = event.details;
453
- if (event.metadata) {
454
- if (event.metadata.subqueries && Array.isArray(event.metadata.subqueries)) {
455
- const subqueryList = event.metadata.subqueries.slice(0, 3).join(", ");
456
- const count = event.metadata.subqueries.length;
457
- enhancedDetails = `${count} subqueries: ${subqueryList}${count > 3 ? "..." : ""}`;
458
- } else if (typeof event.metadata.resultCount === "number") {
459
- enhancedDetails = `${event.metadata.resultCount} results`;
460
- } else if (typeof event.metadata.chunkCount === "number") {
461
- enhancedDetails = `${event.metadata.chunkCount} chunks`;
462
- }
463
- }
464
- if (options.onProgress) {
465
- options.onProgress(humanReadableStage, enhancedDetails);
466
- }
467
- } catch (error) {
468
- }
469
- } : void 0;
470
- const originalRuntime = options.runtime;
471
- const wrappedRuntime = originalRuntime ? {
472
- ...originalRuntime,
473
- log: (level, message, meta) => {
474
- if (level === "info" || level === "debug") {
475
- return;
476
- }
477
- if (originalRuntime.log && (level === "warn" || level === "error")) {
478
- originalRuntime.log(level, message, meta);
479
- }
480
- }
481
- } : void 0;
482
- const runtime = await createMindRuntime({
483
- cwd: options.cwd,
484
- config: options.config,
485
- runtime: wrappedRuntime,
486
- onProgress: onProgressEvent,
487
- platform: options.platform
488
- });
489
- options.onProgress?.("Initializing Mind runtime");
490
- const defaultScopeId = runtime.config.scopes?.[0]?.id;
491
- const scopeId = options.scopeId ?? defaultScopeId;
492
- if (!scopeId) {
493
- throw new Error(
494
- "No mind scopes configured. Provide at least one scope in kb.config.json."
495
- );
496
- }
497
- options.onProgress?.("Preparing query", `scope: ${scopeId}`);
498
- options.onProgress?.("Searching Mind index");
499
- const result = await runtime.service.query({
500
- productId: MIND_PRODUCT_ID,
501
- intent: options.intent ?? "summary",
502
- scopeId,
503
- text: options.text,
504
- limit: options.limit,
505
- profileId: options.profileId
506
- });
507
- options.onProgress?.("Processing results", `${result.chunks.length} chunks found`);
508
- return {
509
- scopeId,
510
- result
511
- };
512
- }
513
- async function runAgentRagQuery(options) {
514
- const platformBroker = options.platform?.cache ? {
515
- get: (key) => options.platform.cache.get(key),
516
- set: (key, value, ttl) => options.platform.cache.set(key, value, ttl),
517
- delete: (key) => options.platform.cache.delete(key)
518
- } : void 0;
519
- const ragLlm = useLLM({
520
- execution: {
521
- cache: {
522
- mode: "prefer",
523
- scope: "segments"
160
+ rest: {
161
+ basePath: MIND_BASE_PATH,
162
+ routes: [
163
+ {
164
+ method: "POST",
165
+ path: MIND_ROUTES.INDEX,
166
+ handler: "./rest/handlers/index.js#default",
167
+ input: { zod: "@kb-labs/mind-contracts#IndexRequestSchema" },
168
+ output: { zod: "@kb-labs/mind-contracts#IndexResponseSchema" },
169
+ timeoutMs: 6e5
524
170
  },
525
- stream: {
526
- mode: "prefer",
527
- fallbackToComplete: true
528
- }
529
- }
530
- });
531
- globalOrchestrator = createAgentQueryOrchestrator({
532
- llm: ragLlm,
533
- // Fresh LLM with analytics wrapper + cache/stream policy
534
- broker: options.broker ?? platformBroker,
535
- // Pass broker for persistent caching
536
- analyticsAdapter: options.platform?.analytics ?? null,
537
- config: {
538
- mode: options.mode ?? "auto",
539
- autoDetectComplexity: true
540
- }
541
- });
542
- const orchestrator = globalOrchestrator;
543
- const runtime = await createMindRuntime({
544
- cwd: options.cwd,
545
- config: options.config,
546
- runtime: options.runtime,
547
- platform: options.platform
548
- });
549
- const defaultScopeId = runtime.config.scopes?.[0]?.id;
550
- const scopeId = options.scopeId ?? defaultScopeId;
551
- if (!scopeId) {
552
- return {
553
- error: {
554
- code: "KNOWLEDGE_SCOPE_NOT_FOUND",
555
- message: "No mind scopes configured. Provide at least one scope in kb.config.json.",
556
- recoverable: false
171
+ {
172
+ method: "POST",
173
+ path: MIND_ROUTES.SEARCH,
174
+ handler: "./rest/handlers/search.js#default",
175
+ input: { zod: "@kb-labs/mind-contracts#SearchRequestSchema" },
176
+ output: { zod: "@kb-labs/mind-contracts#SearchResponseSchema" }
557
177
  },
558
- meta: {
559
- schemaVersion: "agent-response-v1",
560
- requestId: `rq-${Date.now()}`,
561
- mode: options.mode ?? "auto",
562
- timingMs: 0,
563
- cached: false
564
- }
565
- };
566
- }
567
- const cacheContext = await resolveCacheContext({
568
- cwd: options.cwd,
569
- scopeId,
570
- config: runtime.config,
571
- providedIndexRevision: options.indexRevision,
572
- providedEngineConfigHash: options.engineConfigHash,
573
- providedSourcesDigest: options.sourcesDigest
574
- });
575
- const queryFn = async (queryOptions) => {
576
- const result = await runtime.service.query({
577
- productId: MIND_PRODUCT_ID,
578
- intent: queryOptions.intent ?? "search",
579
- scopeId,
580
- text: queryOptions.text,
581
- limit: queryOptions.limit,
582
- // Pass adaptive weights via metadata for mind-engine to use
583
- metadata: {
584
- agentMode: true,
585
- consumer: "agent",
586
- mode: options.mode ?? "auto",
587
- ...queryOptions.vectorWeight !== void 0 && queryOptions.keywordWeight !== void 0 ? {
588
- vectorWeight: queryOptions.vectorWeight,
589
- keywordWeight: queryOptions.keywordWeight
590
- } : {}
591
- }
592
- });
593
- return {
594
- chunks: result.chunks,
595
- metadata: result.metadata ?? {}
596
- };
597
- };
598
- return orchestrator.query(
599
- {
600
- cwd: options.cwd,
601
- scopeId,
602
- text: options.text,
603
- mode: options.mode,
604
- indexRevision: cacheContext.indexRevision,
605
- engineConfigHash: cacheContext.engineConfigHash,
606
- sourcesDigest: cacheContext.sourcesDigest,
607
- debug: options.debug
608
- },
609
- queryFn
610
- );
611
- }
612
- async function resolveCacheContext(options) {
613
- const manifestContext = await readCacheContextFromManifest(options.cwd, options.config, options.scopeId);
614
- const indexRevision = options.providedIndexRevision ?? manifestContext.indexRevision;
615
- const engineConfigHash = options.providedEngineConfigHash ?? manifestContext.engineConfigHash ?? computeEngineConfigHash(options.config, options.scopeId);
616
- const sourcesDigest = options.providedSourcesDigest ?? manifestContext.sourcesDigest;
617
- return {
618
- indexRevision,
619
- engineConfigHash,
620
- sourcesDigest
621
- };
622
- }
623
- function computeEngineConfigHash(config, scopeId) {
624
- const scope = config.scopes?.find((item) => item?.id === scopeId);
625
- const engineId = scope?.defaultEngine ?? config.defaults?.fallbackEngineId ?? config.engines?.[0]?.id;
626
- const engine = config.engines?.find((item) => item?.id === engineId);
627
- if (!engine) {
628
- return void 0;
629
- }
630
- const sanitized = {
631
- id: engine.id,
632
- type: engine.type,
633
- options: sanitizeEngineOptionsForHash(engine.options ?? {})
634
- };
635
- return createHash("sha256").update(stableStringify(sanitized)).digest("hex");
636
- }
637
- async function readCacheContextFromManifest(cwd, config, scopeId) {
638
- const scope = config.scopes?.find((item) => item?.id === scopeId);
639
- const engineId = scope?.defaultEngine ?? config.defaults?.fallbackEngineId ?? config.engines?.[0]?.id;
640
- const engine = config.engines?.find((item) => item?.id === engineId);
641
- const configuredIndexDir = typeof engine?.options?.indexDir === "string" ? engine.options.indexDir : ".kb/mind/rag";
642
- const candidatePaths = [
643
- path2.resolve(cwd, configuredIndexDir, scopeId, "manifest.json"),
644
- path2.resolve(cwd, configuredIndexDir, "manifest.json"),
645
- path2.resolve(cwd, ".kb/mind/indexes", scopeId, "manifest.json"),
646
- path2.resolve(cwd, ".kb/mind/rag", scopeId, "manifest.json")
647
- ];
648
- for (const manifestPath of candidatePaths) {
649
- try {
650
- const manifest2 = await loadManifest(manifestPath);
651
- const indexRevision = manifest2.indexRevision;
652
- const engineConfigHash = manifest2.engineConfigHash;
653
- const sourcesDigest = manifest2.sourcesDigest;
654
- if (typeof indexRevision !== "string" || indexRevision.length === 0) {
655
- throw new Error("missing indexRevision");
656
- }
657
- if (typeof engineConfigHash !== "string" || engineConfigHash.length === 0) {
658
- throw new Error("missing engineConfigHash");
659
- }
660
- if (typeof sourcesDigest !== "string" || sourcesDigest.length === 0) {
661
- throw new Error("missing sourcesDigest");
662
- }
663
- return {
664
- found: true,
665
- indexRevision,
666
- engineConfigHash,
667
- sourcesDigest
668
- };
669
- } catch (error) {
670
- const code = error?.code;
671
- if (code === "ENOENT") {
672
- continue;
178
+ {
179
+ method: "POST",
180
+ path: MIND_ROUTES.QUERY,
181
+ handler: "./rest/handlers/query.js#default",
182
+ input: { zod: "@kb-labs/mind-contracts#QueryRequestSchema" },
183
+ output: { zod: "@kb-labs/mind-contracts#AgentResponseSchema" },
184
+ timeoutMs: 12e4
185
+ },
186
+ {
187
+ method: "POST",
188
+ path: MIND_ROUTES.EXPLORE,
189
+ handler: "./rest/handlers/explore.js#default",
190
+ input: { zod: "@kb-labs/mind-contracts#ExploreRequestSchema" },
191
+ output: { zod: "@kb-labs/mind-contracts#ExploreResponseSchema" },
192
+ timeoutMs: 12e4
193
+ },
194
+ {
195
+ method: "DELETE",
196
+ path: MIND_ROUTES.DROP,
197
+ handler: "./rest/handlers/drop.js#default",
198
+ input: { zod: "@kb-labs/mind-contracts#DropRequestSchema" },
199
+ output: { zod: "@kb-labs/mind-contracts#DropResponseSchema" }
200
+ },
201
+ {
202
+ method: "GET",
203
+ path: MIND_ROUTES.STATUS,
204
+ handler: "./rest/handlers/status.js#default",
205
+ output: { zod: "@kb-labs/mind-contracts#StatusResponseSchema" }
206
+ },
207
+ {
208
+ method: "GET",
209
+ path: MIND_ROUTES.HEALTH,
210
+ handler: "./rest/handlers/health.js#default",
211
+ output: { zod: "@kb-labs/mind-contracts#HealthResponseSchema" }
212
+ },
213
+ {
214
+ method: "POST",
215
+ path: MIND_ROUTES.REINDEX,
216
+ handler: "./rest/handlers/reindex.js#default",
217
+ input: { zod: "@kb-labs/mind-contracts#ReindexRequestSchema" },
218
+ output: { zod: "@kb-labs/mind-contracts#IndexResponseSchema" },
219
+ timeoutMs: 6e5
220
+ },
221
+ {
222
+ method: "POST",
223
+ path: MIND_ROUTES.SYNC_ADD,
224
+ handler: "./rest/handlers/sync-add.js#default",
225
+ input: { zod: "@kb-labs/mind-contracts#SyncAddRequestSchema" },
226
+ output: { zod: "@kb-labs/mind-contracts#SyncResponseSchema" }
227
+ },
228
+ {
229
+ method: "POST",
230
+ path: MIND_ROUTES.SYNC_UPDATE,
231
+ handler: "./rest/handlers/sync-update.js#default",
232
+ input: { zod: "@kb-labs/mind-contracts#SyncUpdateRequestSchema" },
233
+ output: { zod: "@kb-labs/mind-contracts#SyncResponseSchema" }
234
+ },
235
+ {
236
+ method: "POST",
237
+ path: MIND_ROUTES.SYNC_DELETE,
238
+ handler: "./rest/handlers/sync-delete.js#default",
239
+ input: { zod: "@kb-labs/mind-contracts#SyncDeleteRequestSchema" },
240
+ output: { zod: "@kb-labs/mind-contracts#SyncResponseSchema" }
241
+ },
242
+ {
243
+ method: "GET",
244
+ path: MIND_ROUTES.SYNC_LIST,
245
+ handler: "./rest/handlers/sync-list.js#default",
246
+ output: { zod: "@kb-labs/mind-contracts#SyncListResponseSchema" }
247
+ },
248
+ {
249
+ method: "GET",
250
+ path: MIND_ROUTES.SYNC_STATUS,
251
+ handler: "./rest/handlers/sync-status.js#default",
252
+ output: { zod: "@kb-labs/mind-contracts#SyncStatusResponseSchema" }
673
253
  }
674
- const message = error instanceof Error ? error.message : String(error);
675
- throw new Error(`Invalid index manifest at ${manifestPath}: ${message}`);
676
- }
677
- }
678
- return { found: false };
679
- }
680
- function sanitizeEngineOptionsForHash(options) {
681
- const {
682
- _runtime: _runtimeIgnored,
683
- onProgress: _onProgressIgnored,
684
- platform: _platformIgnored,
685
- ...rest
686
- } = options;
687
- return rest;
688
- }
689
- function stableStringify(value) {
690
- return JSON.stringify(sortObjectDeep(value));
691
- }
692
- function sortObjectDeep(value) {
693
- if (Array.isArray(value)) {
694
- return value.map(sortObjectDeep);
695
- }
696
- if (value && typeof value === "object") {
697
- const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, val]) => [key, sortObjectDeep(val)]);
698
- return Object.fromEntries(entries);
699
- }
700
- return value;
701
- }
702
- function useConfig(ctx) {
703
- if (!ctx.config) {
704
- throw new Error("Mind configuration not found in context. Ensure ctx.config is loaded.");
705
- }
706
- const config = ctx.config;
707
- if (!config.sources || !Array.isArray(config.sources)) {
708
- throw new Error("Invalid mind config: missing or invalid sources");
709
- }
710
- if (!config.scopes || !Array.isArray(config.scopes)) {
711
- throw new Error("Invalid mind config: missing or invalid scopes");
712
- }
713
- if (!config.engines || !Array.isArray(config.engines)) {
714
- throw new Error("Invalid mind config: missing or invalid engines");
715
- }
716
- return config;
717
- }
718
- function tryUseConfig(ctx) {
719
- try {
720
- return useConfig(ctx);
721
- } catch {
722
- return null;
723
- }
724
- }
725
- function useSyncConfig(ctx) {
726
- const config = useConfig(ctx);
727
- if (!config.sync) {
728
- return { ...defaultMindSyncConfig };
729
- }
730
- return config.sync;
731
- }
732
-
733
- // src/infra/analytics/events.ts
734
- var ANALYTICS_PREFIX = {
735
- QUERY: "mind.query",
736
- FEED: "mind.feed",
737
- UPDATE: "mind.update",
738
- INIT: "mind.init",
739
- PACK: "mind.pack",
740
- VERIFY: "mind.verify"
741
- };
742
- var ANALYTICS_SUFFIX = {
743
- STARTED: "started",
744
- FINISHED: "finished"
745
- };
746
- var ANALYTICS_EVENTS = {
747
- // Query events
748
- QUERY_STARTED: `${ANALYTICS_PREFIX.QUERY}.${ANALYTICS_SUFFIX.STARTED}`,
749
- QUERY_FINISHED: `${ANALYTICS_PREFIX.QUERY}.${ANALYTICS_SUFFIX.FINISHED}`,
750
- // Feed events
751
- FEED_STARTED: `${ANALYTICS_PREFIX.FEED}.${ANALYTICS_SUFFIX.STARTED}`,
752
- FEED_FINISHED: `${ANALYTICS_PREFIX.FEED}.${ANALYTICS_SUFFIX.FINISHED}`,
753
- // Update events
754
- UPDATE_STARTED: `${ANALYTICS_PREFIX.UPDATE}.${ANALYTICS_SUFFIX.STARTED}`,
755
- UPDATE_FINISHED: `${ANALYTICS_PREFIX.UPDATE}.${ANALYTICS_SUFFIX.FINISHED}`,
756
- // Init events
757
- INIT_STARTED: `${ANALYTICS_PREFIX.INIT}.${ANALYTICS_SUFFIX.STARTED}`,
758
- INIT_FINISHED: `${ANALYTICS_PREFIX.INIT}.${ANALYTICS_SUFFIX.FINISHED}`,
759
- // Pack events
760
- PACK_STARTED: `${ANALYTICS_PREFIX.PACK}.${ANALYTICS_SUFFIX.STARTED}`,
761
- PACK_FINISHED: `${ANALYTICS_PREFIX.PACK}.${ANALYTICS_SUFFIX.FINISHED}`,
762
- // Verify events
763
- VERIFY_STARTED: `${ANALYTICS_PREFIX.VERIFY}.${ANALYTICS_SUFFIX.STARTED}`,
764
- VERIFY_FINISHED: `${ANALYTICS_PREFIX.VERIFY}.${ANALYTICS_SUFFIX.FINISHED}`
765
- };
766
- var ANALYTICS_ACTOR = {
767
- type: "agent",
768
- id: "mind-cli"
769
- };
770
- var InitInputSchema = z.object({
771
- cwd: z.string().optional(),
772
- force: z.boolean().optional().default(false),
773
- json: z.boolean().optional().default(false),
774
- verbose: z.boolean().optional().default(false),
775
- quiet: z.boolean().optional().default(false)
776
- });
777
- var InitOutputSchema = z.object({
778
- ok: z.boolean(),
779
- mindDir: z.string(),
780
- cwd: z.string()
781
- });
782
- var UpdateInputSchema = z.object({
783
- cwd: z.string().optional(),
784
- since: z.string().optional(),
785
- timeBudget: z.number().optional(),
786
- json: z.boolean().optional().default(false),
787
- verbose: z.boolean().optional().default(false),
788
- quiet: z.boolean().optional().default(false)
789
- });
790
- var UpdateOutputSchema = z.object({
791
- ok: z.boolean(),
792
- updated: z.number(),
793
- duration: z.number()
794
- });
795
- var PackInputSchema = z.object({
796
- cwd: z.string().optional(),
797
- intent: z.string(),
798
- product: z.string().optional(),
799
- preset: z.string().optional(),
800
- budget: z.number().optional(),
801
- withBundle: z.boolean().optional().default(false),
802
- out: z.string().optional(),
803
- seed: z.number().optional(),
804
- json: z.boolean().optional().default(false),
805
- verbose: z.boolean().optional().default(false),
806
- quiet: z.boolean().optional().default(false)
807
- });
808
- var PackOutputSchema = z.object({
809
- ok: z.boolean(),
810
- packPath: z.string(),
811
- size: z.number()
812
- });
813
- var FeedInputSchema = z.object({
814
- cwd: z.string().optional(),
815
- intent: z.string().optional(),
816
- product: z.string().optional(),
817
- preset: z.string().optional(),
818
- budget: z.number().optional(),
819
- withBundle: z.boolean().optional().default(false),
820
- since: z.string().optional(),
821
- timeBudget: z.number().optional(),
822
- noUpdate: z.boolean().optional().default(false),
823
- out: z.string().optional(),
824
- seed: z.number().optional(),
825
- json: z.boolean().optional().default(false),
826
- verbose: z.boolean().optional().default(false),
827
- quiet: z.boolean().optional().default(false)
828
- });
829
- var FeedOutputSchema = z.object({
830
- ok: z.boolean(),
831
- packPath: z.string(),
832
- updated: z.number(),
833
- duration: z.number()
834
- });
835
- var QueryInputSchema = z.object({
836
- cwd: z.string().optional(),
837
- query: z.enum(["impact", "scope", "exports", "externals", "chain", "meta", "docs"]),
838
- file: z.string().optional(),
839
- path: z.string().optional(),
840
- scope: z.string().optional(),
841
- product: z.string().optional(),
842
- tag: z.string().optional(),
843
- type: z.string().optional(),
844
- filter: z.string().optional(),
845
- limit: z.number().optional().default(500),
846
- depth: z.number().optional().default(5),
847
- cacheMode: z.enum(["ci", "local"]).optional().default("local"),
848
- cacheTtl: z.number().optional().default(60),
849
- noCache: z.boolean().optional().default(false),
850
- paths: z.enum(["id", "absolute"]).optional().default("id"),
851
- aiMode: z.boolean().optional().default(false),
852
- toon: z.boolean().optional().default(false),
853
- toonSidecar: z.boolean().optional().default(false),
854
- json: z.boolean().optional().default(false),
855
- compact: z.boolean().optional().default(false),
856
- quiet: z.boolean().optional().default(false)
857
- });
858
- var QueryOutputSchema = z.object({
859
- ok: z.boolean(),
860
- query: z.string(),
861
- result: z.any(),
862
- toonPath: z.string().optional()
863
- });
864
- var VerifyInputSchema = z.object({
865
- cwd: z.string().optional(),
866
- json: z.boolean().optional().default(false),
867
- quiet: z.boolean().optional().default(false)
868
- });
869
- var VerifyOutputSchema = z.object({
870
- ok: z.boolean(),
871
- consistent: z.boolean(),
872
- errors: z.array(z.object({
873
- file: z.string(),
874
- message: z.string()
875
- }))
876
- });
877
- var colors = {
878
- red: (text) => `\x1B[31m${text}\x1B[0m`,
879
- green: (text) => `\x1B[32m${text}\x1B[0m`,
880
- yellow: (text) => `\x1B[33m${text}\x1B[0m`,
881
- blue: (text) => `\x1B[34m${text}\x1B[0m`,
882
- cyan: (text) => `\x1B[36m${text}\x1B[0m`,
883
- gray: (text) => `\x1B[90m${text}\x1B[0m`,
884
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
885
- dim: (text) => `\x1B[2m${text}\x1B[0m`
886
- };
887
- var safeColors = colors;
888
- var safeSymbols = {
889
- check: "\u2713",
890
- cross: "\u2717",
891
- arrow: "\u2192",
892
- bullet: "\u2022",
893
- info: "\u2139",
894
- warning: "\u26A0",
895
- error: "\u2717"
896
- };
897
- var TimingTracker = class {
898
- startTime;
899
- constructor() {
900
- this.startTime = Date.now();
901
- }
902
- getElapsed() {
903
- return Date.now() - this.startTime;
904
- }
905
- getElapsedMs() {
906
- return this.getElapsed();
254
+ ]
907
255
  }
908
256
  };
909
- function formatTiming(ms) {
910
- if (ms < 1e3) {
911
- return `${ms}ms`;
912
- }
913
- return `${(ms / 1e3).toFixed(1)}s`;
914
- }
915
- function box(textOrTitle, maybeLines = []) {
916
- const lines = Array.isArray(maybeLines) ? maybeLines : typeof maybeLines === "string" ? maybeLines.split("\n") : [];
917
- const rows = [textOrTitle, ...lines, ""];
918
- return rows.map((line) => line && line.length > 0 ? `\u2502 ${line}` : "\u2502").join("\n");
919
- }
920
- function keyValue(arg1, arg2) {
921
- const format = (key, value) => {
922
- const label = useEnv("NO_COLOR") ? key : colors.cyan(key);
923
- return `${label}: ${value}`;
924
- };
925
- if (typeof arg1 === "string" && arg2 !== void 0) {
926
- return format(arg1, arg2);
927
- }
928
- if (arg1 && typeof arg1 === "object") {
929
- return Object.entries(arg1).map(([key, value]) => format(key, value));
930
- }
931
- return "";
932
- }
933
- function createSpinner(text) {
934
- const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
935
- let frame = 0;
936
- const interval = setInterval(() => {
937
- process.stdout.write(`\r${frames[frame]} ${text}`);
938
- frame = (frame + 1) % frames.length;
939
- }, 100);
940
- return {
941
- stop: (finalText) => {
942
- clearInterval(interval);
943
- process.stdout.write(`\r${finalText || text}
944
- `);
945
- }
946
- };
947
- }
948
- var init_default = defineCommand({
949
- id: "mind:init",
950
- description: "Initialize mind workspace",
951
- // ❌ NO permissions here - they are in manifest.v3.ts!
952
- // Permissions are manifest-wide in V3
953
- handler: {
954
- async execute(ctx, input) {
955
- const startTime = Date.now();
956
- const { flags } = input;
957
- const cwd = flags.cwd || ctx.cwd;
958
- ctx.trace?.addEvent?.("mind.init.start", {
959
- cwd,
960
- command: "mind:init",
961
- force: flags.force
962
- });
963
- ctx.trace?.addEvent?.("mind.init.initializing", { cwd, force: flags.force });
964
- const mindDir = await initMindStructure({
965
- cwd,
966
- force: flags.force,
967
- log: (entry) => {
968
- const msg = typeof entry === "string" ? entry : entry.msg ?? "";
969
- if (!flags.quiet && !flags.json) {
970
- ctx.ui.info(`Init: ${msg}`);
971
- }
972
- ctx.trace?.addEvent?.("mind.init.step", { msg });
973
- }
974
- });
975
- ctx.trace?.addEvent?.("mind.init.complete", {
976
- mindDir,
977
- cwd
978
- });
979
- const artifacts = [];
980
- const artifactPatterns = [
981
- { name: "Index", pattern: "index.json", description: "Main Mind index" },
982
- { name: "API Index", pattern: "api-index.json", description: "API index" },
983
- { name: "Dependencies", pattern: "deps.json", description: "Dependencies graph" },
984
- { name: "Recent Diff", pattern: "recent-diff.json", description: "Recent changes diff" }
985
- ];
986
- for (const { name, pattern, description } of artifactPatterns) {
987
- const artifactPath = join(mindDir, pattern);
988
- try {
989
- const stats = await promises.stat(artifactPath);
990
- artifacts.push({
991
- name,
992
- path: artifactPath,
993
- size: stats.size,
994
- modified: stats.mtime,
995
- description
996
- });
997
- } catch {
998
- }
999
- }
1000
- ctx.trace?.addEvent?.("mind.init.artifacts", {
1001
- mindDir,
1002
- artifactsCount: artifacts.length
1003
- });
1004
- const timing = Date.now() - startTime;
1005
- if (flags.json) {
1006
- ctx.ui.info(JSON.stringify({
1007
- ok: true,
1008
- summary: {
1009
- Workspace: mindDir,
1010
- Status: "Initialized"
1011
- },
1012
- artifacts,
1013
- timingMs: timing,
1014
- data: {
1015
- mindDir,
1016
- cwd
1017
- }
1018
- }));
1019
- } else if (!flags.quiet) {
1020
- const artifactItems = [];
1021
- for (const artifact of artifacts) {
1022
- artifactItems.push(`\u2713 ${artifact.name}: ${artifact.description}`);
1023
- }
1024
- const sections = [
1025
- {
1026
- header: "Summary",
1027
- items: [
1028
- `Workspace: ${mindDir}`,
1029
- `Status: Initialized`
1030
- ]
1031
- }
1032
- ];
1033
- if (artifacts.length > 0) {
1034
- sections.push({
1035
- header: "Created Artifacts",
1036
- items: artifactItems
1037
- });
1038
- }
1039
- ctx.ui.success("Mind workspace initialized", {
1040
- title: "Mind Init",
1041
- sections,
1042
- timing
1043
- });
1044
- }
1045
- return {
1046
- exitCode: 0,
1047
- mindDir,
1048
- artifacts
1049
- };
1050
- }
1051
- }
1052
- });
1053
- var rag_index_default = defineCommand({
1054
- id: "mind:rag-index",
1055
- description: "Build Mind indexes",
1056
- handler: {
1057
- async execute(ctx, input) {
1058
- const startTime = Date.now();
1059
- const { flags } = input;
1060
- const mindConfig = await useConfig$1();
1061
- const cwd = flags.cwd || ctx.cwd;
1062
- const scopeId = flags.scope;
1063
- const include = flags.include;
1064
- const exclude = flags.exclude;
1065
- const skipDeduplication = flags.skipDeduplication;
1066
- const platform = usePlatform();
1067
- const loader = !flags.quiet && !flags.json ? useLoader("Building Mind RAG index...") : null;
1068
- loader?.start();
1069
- try {
1070
- const result = await runRagIndex({
1071
- cwd,
1072
- scopeId,
1073
- include,
1074
- exclude,
1075
- skipDeduplication,
1076
- config: mindConfig,
1077
- platform
1078
- });
1079
- const timing = Date.now() - startTime;
1080
- loader?.succeed(`Index built in ${(timing / 1e3).toFixed(1)}s`);
1081
- platform?.analytics?.track?.("mind.rag-index", {
1082
- scopeIds: result.scopeIds,
1083
- stats: result.stats
1084
- }).catch(() => {
1085
- });
1086
- if (flags.json) {
1087
- ctx.ui.json({
1088
- ok: true,
1089
- scopes: result.scopeIds,
1090
- stats: result.stats,
1091
- adapters: result.adapters,
1092
- timingMs: timing
1093
- });
1094
- } else if (!flags.quiet) {
1095
- const { stats } = result;
1096
- const percentage = stats.filesDiscovered > 0 ? (stats.filesProcessed / stats.filesDiscovered * 100).toFixed(1) : "0.0";
1097
- const chunksPerFile = stats.filesProcessed > 0 ? (stats.chunksStored / stats.filesProcessed).toFixed(2) : "0.00";
1098
- ctx.ui.success(
1099
- `Indexed ${stats.filesProcessed} files, ${stats.filesSkipped} skipped, ${stats.chunksStored} chunks, deleted ${stats.deletedFiles ?? 0} files/${stats.deletedChunks ?? 0} chunks`,
1100
- {
1101
- title: "Mind RAG Index",
1102
- sections: [
1103
- {
1104
- header: "Files",
1105
- items: [
1106
- `Discovered: ${stats.filesDiscovered}`,
1107
- `Processed: ${stats.filesProcessed} (${percentage}%)`,
1108
- `Skipped: ${stats.filesSkipped}`
1109
- ]
1110
- },
1111
- {
1112
- header: "Chunks",
1113
- items: [
1114
- `Stored: ${stats.chunksStored}`,
1115
- `Updated: ${stats.chunksUpdated}`,
1116
- `Skipped: ${stats.chunksSkipped}`,
1117
- `Rate: ${chunksPerFile}/file`
1118
- ]
1119
- },
1120
- {
1121
- header: "Cleanup",
1122
- items: [
1123
- `Deleted files: ${stats.deletedFiles ?? 0}`,
1124
- `Deleted chunks: ${stats.deletedChunks ?? 0}`,
1125
- `Invalid chunks: ${stats.invalidChunks ?? 0}`
1126
- ]
1127
- },
1128
- {
1129
- header: "Health",
1130
- items: [
1131
- `Errors: ${stats.errorCount}`
1132
- ]
1133
- }
1134
- ],
1135
- timing
1136
- }
1137
- );
1138
- }
1139
- return {
1140
- exitCode: 0,
1141
- ok: true,
1142
- scopes: result.scopeIds,
1143
- adapters: result.adapters
1144
- };
1145
- } catch (error) {
1146
- const timing = Date.now() - startTime;
1147
- const message = error instanceof Error ? error.message : String(error);
1148
- loader?.fail(`Index build failed: ${message}`);
1149
- if (flags.json) {
1150
- ctx.ui.info(JSON.stringify({
1151
- ok: false,
1152
- error: message,
1153
- timingMs: timing
1154
- }));
1155
- } else if (!flags.quiet) {
1156
- ctx.ui.error(`Index build failed: ${message}`);
1157
- }
1158
- platform?.analytics?.track?.("mind.rag-index", {
1159
- error: true,
1160
- errorMessage: message,
1161
- timingMs: timing
1162
- }).catch(() => {
1163
- });
1164
- return { exitCode: 1, ok: false };
1165
- }
1166
- }
1167
- }
1168
- });
1169
- var VALID_INTENTS = ["summary", "search", "similar", "nav"];
1170
- var VALID_MODES = ["instant", "auto", "thinking"];
1171
- var VALID_FORMATS = ["text", "json", "json-pretty"];
1172
- function isValidIntent(intent) {
1173
- return VALID_INTENTS.includes(intent);
1174
- }
1175
- function isValidMode(mode) {
1176
- return VALID_MODES.includes(mode);
1177
- }
1178
- function isValidFormat(format) {
1179
- return VALID_FORMATS.includes(format);
1180
- }
1181
- function truncateText(text, limit) {
1182
- if (text.length <= limit) {
1183
- return text;
1184
- }
1185
- return `${text.slice(0, limit - 3)}...`;
1186
- }
1187
- var rag_query_default = defineCommand({
1188
- id: "mind:rag-query",
1189
- description: "Run semantic RAG query on Mind index",
1190
- handler: {
1191
- async execute(ctx, input) {
1192
- const startTime = Date.now();
1193
- const { flags } = input;
1194
- const cwd = flags.cwd || ctx.cwd;
1195
- const scopeId = flags.scope;
1196
- const intent = flags.intent && isValidIntent(flags.intent) ? flags.intent : void 0;
1197
- const text = flags.text?.trim() || "";
1198
- const limit = flags.limit ? Math.max(1, flags.limit) : void 0;
1199
- const profileId = flags.profile;
1200
- const platform = usePlatform();
1201
- const mode = flags.mode && isValidMode(flags.mode) ? flags.mode : "auto";
1202
- let format = flags.format && isValidFormat(flags.format) ? flags.format : "text";
1203
- if (flags.json && format === "text") {
1204
- format = "json";
1205
- }
1206
- if (!text) {
1207
- if (flags.agent) {
1208
- console.log(JSON.stringify({
1209
- error: {
1210
- code: "INVALID_QUERY",
1211
- message: 'Provide --text "<query>" to run rag:query.',
1212
- recoverable: false
1213
- },
1214
- meta: {
1215
- schemaVersion: "agent-response-v1",
1216
- requestId: `rq-${Date.now()}`,
1217
- mode,
1218
- timingMs: 0,
1219
- cached: false
1220
- }
1221
- }));
1222
- ctx.trace?.addEvent?.("mind.rag-query.invalid", { reason: "missing-text" });
1223
- return { exitCode: 1, ok: false };
1224
- }
1225
- ctx.ui.error('Provide --text "<query>" to run rag:query.');
1226
- ctx.ui.info('Use: kb mind rag-query --text "your query"');
1227
- ctx.ui.info("Add --scope to search in specific scope");
1228
- ctx.ui.info("Add --intent to specify intent (summary, search, similar, nav)");
1229
- ctx.trace?.addEvent?.("mind.rag-query.invalid", { reason: "missing-text" });
1230
- return { exitCode: 1, ok: false };
1231
- }
1232
- if (flags.agent) {
1233
- try {
1234
- const result = await runAgentRagQuery({
1235
- cwd,
1236
- scopeId,
1237
- text,
1238
- mode,
1239
- debug: flags.debug,
1240
- broker: void 0,
1241
- // Gracefully falls back to in-memory
1242
- platform
1243
- // Pass platform for analytics adapter
1244
- });
1245
- platform?.analytics?.track?.("mind.rag-query", {
1246
- mode,
1247
- agent: true,
1248
- scopeId,
1249
- intent
1250
- }).catch(() => {
1251
- });
1252
- console.log(JSON.stringify(result));
1253
- if (isAgentError(result)) {
1254
- return { exitCode: 1, ok: false, result };
1255
- }
1256
- return { exitCode: 0, ok: true, result };
1257
- } catch (error) {
1258
- const message = error instanceof Error ? error.message : String(error);
1259
- console.log(JSON.stringify({
1260
- error: {
1261
- code: "ENGINE_ERROR",
1262
- message,
1263
- recoverable: true
1264
- },
1265
- meta: {
1266
- schemaVersion: "agent-response-v1",
1267
- requestId: `rq-${Date.now()}`,
1268
- mode,
1269
- timingMs: Date.now() - startTime,
1270
- cached: false
1271
- }
1272
- }));
1273
- ctx.trace?.addEvent?.("mind.rag-query.agent.error", { error: message });
1274
- return { exitCode: 1, ok: false };
1275
- }
1276
- }
1277
- if (!flags.quiet && format === "text") {
1278
- ctx.ui.info("Initializing Mind RAG query...");
1279
- }
1280
- const formatElapsedTime = (ms) => {
1281
- const seconds = Math.floor(ms / 1e3);
1282
- if (seconds < 60) {
1283
- return `${seconds}s`;
1284
- }
1285
- const minutes = Math.floor(seconds / 60);
1286
- const remainingSeconds = seconds % 60;
1287
- return `${minutes}m ${remainingSeconds}s`;
1288
- };
1289
- let currentStage = "Initializing";
1290
- let lastProgressTime = Date.now();
1291
- try {
1292
- const result = await runRagQuery({
1293
- cwd,
1294
- scopeId,
1295
- text,
1296
- intent,
1297
- limit,
1298
- profileId,
1299
- platform,
1300
- // Pass platform for analytics adapter
1301
- runtime: void 0,
1302
- // Runtime context not available in CLI
1303
- onProgress: (stage, details) => {
1304
- if (flags.quiet || format === "json" || format === "json-pretty") {
1305
- return;
1306
- }
1307
- currentStage = details ? `${stage}: ${details}` : stage;
1308
- const now = Date.now();
1309
- if (now - lastProgressTime >= 1e3) {
1310
- const elapsed = now - startTime;
1311
- const elapsedStr = formatElapsedTime(elapsed);
1312
- ctx.ui.info(`${currentStage} [${elapsedStr}]`);
1313
- lastProgressTime = now;
1314
- }
1315
- }
1316
- });
1317
- const timing = Date.now() - startTime;
1318
- ctx.trace?.addEvent?.("mind.rag-query.complete", {
1319
- mode,
1320
- scopeId,
1321
- chunks: result.result.chunks.length,
1322
- timingMs: timing
1323
- });
1324
- if (format === "json" || format === "json-pretty") {
1325
- if (result.result.metadata?.jsonResponse) {
1326
- const jsonResponse = result.result.metadata.jsonResponse;
1327
- if (format === "json-pretty") {
1328
- ctx.ui.info(JSON.stringify(jsonResponse, null, 2));
1329
- } else {
1330
- ctx.ui.info(JSON.stringify(jsonResponse));
1331
- }
1332
- } else {
1333
- ctx.ui.info(JSON.stringify({
1334
- ok: true,
1335
- scopeId: result.scopeId,
1336
- intent: result.result.query.intent,
1337
- chunks: result.result.chunks,
1338
- contextText: result.result.contextText
1339
- }));
1340
- }
1341
- } else if (!flags.quiet) {
1342
- const topChunk = result.result.chunks[0];
1343
- const sections = [
1344
- {
1345
- header: "Summary",
1346
- items: [
1347
- `Scope: ${result.scopeId}`,
1348
- `Intent: ${result.result.query.intent}`,
1349
- `Chunks returned: ${result.result.chunks.length}`
1350
- ]
1351
- }
1352
- ];
1353
- if (topChunk) {
1354
- sections.push({
1355
- header: "Top chunk",
1356
- items: [
1357
- `${topChunk.path} #${topChunk.span.startLine}-${topChunk.span.endLine}`,
1358
- truncateText(topChunk.text, 400)
1359
- ]
1360
- });
1361
- } else {
1362
- sections.push({
1363
- items: ["No matching chunks found."]
1364
- });
1365
- }
1366
- if (result.result.contextText && result.result.contextText.length > 0) {
1367
- const contextPreview = result.result.contextText.length > 2e3 ? result.result.contextText.substring(0, 2e3) + "..." : result.result.contextText;
1368
- sections.push({
1369
- header: `Synthesized context (${result.result.contextText.length} chars)`,
1370
- items: [contextPreview]
1371
- });
1372
- }
1373
- ctx.ui.success("Query completed", {
1374
- title: "Mind RAG Query",
1375
- sections,
1376
- timing
1377
- });
1378
- }
1379
- platform?.analytics?.track?.("mind.rag-query", {
1380
- mode,
1381
- agent: false,
1382
- scopeId,
1383
- intent
1384
- }).catch(() => {
1385
- });
1386
- return { exitCode: 0, ok: true, result };
1387
- } catch (error) {
1388
- const timing = Date.now() - startTime;
1389
- const message = error instanceof Error ? error.message : String(error);
1390
- ctx.trace?.addEvent?.("mind.rag-query.error", { error: message, timingMs: timing });
1391
- if (format === "json" || format === "json-pretty") {
1392
- ctx.ui.info(JSON.stringify({
1393
- ok: false,
1394
- error: message,
1395
- timingMs: timing
1396
- }));
1397
- } else if (!flags.quiet) {
1398
- ctx.ui.error(`Query failed: ${message}`);
1399
- }
1400
- platform?.analytics?.track?.("mind.rag-query", {
1401
- mode,
1402
- agent: false,
1403
- scopeId,
1404
- intent,
1405
- error: true
1406
- }).catch(() => {
1407
- });
1408
- return { exitCode: 1, ok: false };
1409
- }
1410
- }
1411
- }
1412
- });
1413
- var verify_default = defineCommand({
1414
- id: "mind:verify",
1415
- description: "Check Mind platform services readiness",
1416
- handler: {
1417
- async execute(ctx, input) {
1418
- const startTime = Date.now();
1419
- const { flags } = input;
1420
- ctx.trace?.addEvent?.("mind.verify.start", { command: "mind:verify" });
1421
- const platform = usePlatform();
1422
- const services = [];
1423
- if (!platform) {
1424
- const result2 = {
1425
- exitCode: 1,
1426
- ok: false,
1427
- services,
1428
- issues: ["platform context is missing"],
1429
- meta: { timingMs: Date.now() - startTime }
1430
- };
1431
- if (flags.json) {
1432
- ctx.ui.info(JSON.stringify(result2));
1433
- } else {
1434
- ctx.ui.error("Platform services are not available in this context");
1435
- }
1436
- ctx.trace?.addEvent?.("mind.verify.failed", { reason: "no-platform" });
1437
- return result2;
1438
- }
1439
- const check = (name, required, available, configured, message) => {
1440
- services.push({ service: name, required, available, configured, message });
1441
- };
1442
- const has = (key) => Boolean(platform[key]);
1443
- const isConfigured = (svc) => platform.isConfigured?.(svc) ?? has(svc);
1444
- check("vectorStore", true, has("vectorStore"), isConfigured("vectorStore"));
1445
- check("embeddings", true, has("embeddings"), isConfigured("embeddings"));
1446
- check("llm", false, has("llm"), isConfigured("llm"));
1447
- check("cache", false, has("cache"), true);
1448
- check("storage", false, has("storage"), true);
1449
- check("analytics", false, has("analytics"), true);
1450
- const requiredOk = services.filter((s) => s.required).every((s) => s.available && s.configured);
1451
- const issues = services.filter((s) => s.required && (!s.available || !s.configured)).map((s) => `${s.service} is missing or not configured`);
1452
- const timing = Date.now() - startTime;
1453
- ctx.trace?.addEvent?.("mind.verify.complete", { ok: requiredOk, issues: issues.length });
1454
- const result = {
1455
- exitCode: requiredOk ? 0 : 1,
1456
- ok: requiredOk,
1457
- services,
1458
- issues,
1459
- meta: { timingMs: timing }
1460
- };
1461
- if (flags.json) {
1462
- ctx.ui.info(JSON.stringify(result));
1463
- } else if (!flags.quiet) {
1464
- const sections = [
1465
- {
1466
- header: "Services",
1467
- items: services.map((s) => {
1468
- const status = s.available && s.configured ? "\u2713" : "\u26A0";
1469
- return `${status} ${s.service}: ${s.available ? "available" : "missing"}${s.configured ? "" : " (not configured)"}`;
1470
- })
1471
- }
1472
- ];
1473
- if (issues.length) {
1474
- sections.push({
1475
- header: "Issues",
1476
- items: issues.map((i) => `\u26A0 ${i}`)
1477
- });
1478
- }
1479
- if (requiredOk) {
1480
- ctx.ui.success("Mind platform services verified", {
1481
- title: "Mind Verify - Platform",
1482
- sections,
1483
- timing
1484
- });
1485
- } else {
1486
- ctx.ui.error("Mind platform services have issues");
1487
- ctx.ui.success("Verification Details", {
1488
- title: "Mind Verify - Platform",
1489
- sections,
1490
- timing
1491
- });
1492
- }
1493
- }
1494
- return result;
1495
- }
1496
- }
1497
- });
1498
257
 
1499
- export { ANALYTICS_ACTOR, ANALYTICS_EVENTS, ANALYTICS_PREFIX, ANALYTICS_SUFFIX, FeedInputSchema, FeedOutputSchema, InitInputSchema, InitOutputSchema, MIND_PRODUCT_ID, PackInputSchema, PackOutputSchema, QueryInputSchema, QueryOutputSchema, TimingTracker, UpdateInputSchema, UpdateOutputSchema, VerifyInputSchema, VerifyOutputSchema, box, colors, createMindRuntime, createSpinner, formatTiming, keyValue, manifest, runAgentRagQuery, init_default as runInitCommand, runRagIndex, rag_index_default as runRagIndexCommand, runRagQuery, rag_query_default as runRagQueryCommand, verify_default as runVerifyCommand, safeColors, safeSymbols, tryUseConfig, useConfig, useSyncConfig };
258
+ export { manifest };
1500
259
  //# sourceMappingURL=index.js.map
1501
260
  //# sourceMappingURL=index.js.map