@eclipse-docks/extension-rag-system 0.7.130 → 0.7.132

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/dist/api.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as createIndexValuesFromArray, l as euclideanDistance, m as embeddingService, n as searchWorkspaceDocuments, o as documentIndexService, s as cosineSimilarity, t as ragService, u as getIndexValueArray } from "./rag-service-Cymd0ECr.js";
2
- import { i as registerRAGCommands, n as integrateRAGWithAI, r as ragPromptEnhancer, t as createRAGToolExecutor } from "./rag-integration-U1AB0yh6.js";
1
+ import { c as createIndexValuesFromArray, l as euclideanDistance, m as embeddingService, n as searchWorkspaceDocuments, o as documentIndexService, s as cosineSimilarity, t as ragService, u as getIndexValueArray } from "./rag-service-BXPQTm_G.js";
2
+ import { i as registerRAGCommands, n as integrateRAGWithAI, r as ragPromptEnhancer, t as createRAGToolExecutor } from "./rag-integration-BPga10kB.js";
3
3
  //#region src/utils/context-scopes.ts
4
4
  function createEditorScope(openFiles) {
5
5
  return { includePaths: openFiles };
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","names":[],"sources":["../src/utils/context-scopes.ts"],"sourcesContent":["import { DocumentSearchScope } from '../document-index-service';\nimport { IndexedDocument } from '../document-index-service';\n\nexport interface ContextScopeProvider {\n getScope(): DocumentSearchScope | null;\n getName(): string;\n}\n\nexport class PathBasedScope implements ContextScopeProvider {\n constructor(\n private includePaths: string[],\n private excludePaths: string[] = [],\n private name: string = 'Path-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n includePaths: this.includePaths,\n excludePaths: this.excludePaths\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class PatternBasedScope implements ContextScopeProvider {\n constructor(\n private pattern: string | RegExp,\n private name: string = 'Pattern-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n pathPattern: this.pattern\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class TagBasedScope implements ContextScopeProvider {\n constructor(\n private tags: string[],\n private name: string = 'Tag-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n tags: this.tags\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class CustomScope implements ContextScopeProvider {\n constructor(\n private scope: DocumentSearchScope,\n private name: string = 'Custom scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return this.scope;\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport function createEditorScope(openFiles: string[]): DocumentSearchScope {\n return {\n includePaths: openFiles\n };\n}\n\nexport function createDirectoryScope(directoryPath: string, recursive: boolean = true): DocumentSearchScope {\n const pattern = recursive \n ? `^${directoryPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/.*`\n : `^${directoryPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/[^/]+$`;\n return {\n pathPattern: new RegExp(pattern)\n };\n}\n\nexport function createFileTypeScope(fileTypes: string[]): DocumentSearchScope {\n const pattern = `\\\\.(${fileTypes.join('|')})$`;\n return {\n pathPattern: new RegExp(pattern)\n };\n}\n\nexport function combineScopes(...scopes: (DocumentSearchScope | null)[]): DocumentSearchScope | null {\n const validScopes = scopes.filter((s): s is DocumentSearchScope => s !== null);\n if (validScopes.length === 0) {\n return null;\n }\n if (validScopes.length === 1) {\n return validScopes[0];\n }\n\n const combined: DocumentSearchScope = {};\n \n const allIncludePaths: string[] = [];\n const allExcludePaths: string[] = [];\n const allTags: string[] = [];\n const allMetadataFilters: Array<(doc: IndexedDocument) => boolean> = [];\n\n for (const scope of validScopes) {\n if (scope.includePaths) {\n allIncludePaths.push(...scope.includePaths);\n }\n if (scope.excludePaths) {\n allExcludePaths.push(...scope.excludePaths);\n }\n if (scope.tags) {\n allTags.push(...scope.tags);\n }\n if (scope.metadataFilter) {\n allMetadataFilters.push(scope.metadataFilter);\n }\n if (scope.pathPattern) {\n const existingPattern = combined.pathPattern;\n if (existingPattern) {\n const newPattern = scope.pathPattern instanceof RegExp \n ? scope.pathPattern \n : new RegExp(scope.pathPattern);\n combined.pathPattern = new RegExp(`(${existingPattern instanceof RegExp ? existingPattern.source : existingPattern})|(${newPattern.source})`);\n } else {\n combined.pathPattern = scope.pathPattern;\n }\n }\n }\n\n if (allIncludePaths.length > 0) {\n combined.includePaths = [...new Set(allIncludePaths)];\n }\n if (allExcludePaths.length > 0) {\n combined.excludePaths = [...new Set(allExcludePaths)];\n }\n if (allTags.length > 0) {\n combined.tags = [...new Set(allTags)];\n }\n if (allMetadataFilters.length > 0) {\n combined.metadataFilter = (doc: IndexedDocument) => {\n return allMetadataFilters.every(filter => filter(doc));\n };\n }\n\n return combined;\n}\n\n"],"mappings":";;;AA4EA,SAAgB,kBAAkB,WAA0C;AACxE,QAAO,EACH,cAAc,WACjB;;AAGL,SAAgB,qBAAqB,eAAuB,YAAqB,MAA2B;CACxG,MAAM,UAAU,YACV,IAAI,cAAc,QAAQ,uBAAuB,OAAO,CAAC,OACzD,IAAI,cAAc,QAAQ,uBAAuB,OAAO,CAAC;AAC/D,QAAO,EACH,aAAa,IAAI,OAAO,QAAQ,EACnC;;AAGL,SAAgB,oBAAoB,WAA0C;CAC1E,MAAM,UAAU,OAAO,UAAU,KAAK,IAAI,CAAC;AAC3C,QAAO,EACH,aAAa,IAAI,OAAO,QAAQ,EACnC;;AAGL,SAAgB,cAAc,GAAG,QAAoE;CACjG,MAAM,cAAc,OAAO,QAAQ,MAAgC,MAAM,KAAK;AAC9E,KAAI,YAAY,WAAW,EACvB,QAAO;AAEX,KAAI,YAAY,WAAW,EACvB,QAAO,YAAY;CAGvB,MAAM,WAAgC,EAAE;CAExC,MAAM,kBAA4B,EAAE;CACpC,MAAM,kBAA4B,EAAE;CACpC,MAAM,UAAoB,EAAE;CAC5B,MAAM,qBAA+D,EAAE;AAEvE,MAAK,MAAM,SAAS,aAAa;AAC7B,MAAI,MAAM,aACN,iBAAgB,KAAK,GAAG,MAAM,aAAa;AAE/C,MAAI,MAAM,aACN,iBAAgB,KAAK,GAAG,MAAM,aAAa;AAE/C,MAAI,MAAM,KACN,SAAQ,KAAK,GAAG,MAAM,KAAK;AAE/B,MAAI,MAAM,eACN,oBAAmB,KAAK,MAAM,eAAe;AAEjD,MAAI,MAAM,aAAa;GACnB,MAAM,kBAAkB,SAAS;AACjC,OAAI,iBAAiB;IACjB,MAAM,aAAa,MAAM,uBAAuB,SAC1C,MAAM,cACN,IAAI,OAAO,MAAM,YAAY;AACnC,aAAS,cAAc,IAAI,OAAO,IAAI,2BAA2B,SAAS,gBAAgB,SAAS,gBAAgB,KAAK,WAAW,OAAO,GAAG;SAE7I,UAAS,cAAc,MAAM;;;AAKzC,KAAI,gBAAgB,SAAS,EACzB,UAAS,eAAe,CAAC,GAAG,IAAI,IAAI,gBAAgB,CAAC;AAEzD,KAAI,gBAAgB,SAAS,EACzB,UAAS,eAAe,CAAC,GAAG,IAAI,IAAI,gBAAgB,CAAC;AAEzD,KAAI,QAAQ,SAAS,EACjB,UAAS,OAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,CAAC;AAEzC,KAAI,mBAAmB,SAAS,EAC5B,UAAS,kBAAkB,QAAyB;AAChD,SAAO,mBAAmB,OAAM,WAAU,OAAO,IAAI,CAAC;;AAI9D,QAAO"}
1
+ {"version":3,"file":"api.js","names":[],"sources":["../src/utils/context-scopes.ts"],"sourcesContent":["import { DocumentSearchScope } from '../document-index-service';\nimport { IndexedDocument } from '../document-index-service';\n\nexport interface ContextScopeProvider {\n getScope(): DocumentSearchScope | null;\n getName(): string;\n}\n\nexport class PathBasedScope implements ContextScopeProvider {\n constructor(\n private includePaths: string[],\n private excludePaths: string[] = [],\n private name: string = 'Path-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n includePaths: this.includePaths,\n excludePaths: this.excludePaths\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class PatternBasedScope implements ContextScopeProvider {\n constructor(\n private pattern: string | RegExp,\n private name: string = 'Pattern-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n pathPattern: this.pattern\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class TagBasedScope implements ContextScopeProvider {\n constructor(\n private tags: string[],\n private name: string = 'Tag-based scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return {\n tags: this.tags\n };\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport class CustomScope implements ContextScopeProvider {\n constructor(\n private scope: DocumentSearchScope,\n private name: string = 'Custom scope'\n ) {}\n\n getScope(): DocumentSearchScope {\n return this.scope;\n }\n\n getName(): string {\n return this.name;\n }\n}\n\nexport function createEditorScope(openFiles: string[]): DocumentSearchScope {\n return {\n includePaths: openFiles\n };\n}\n\nexport function createDirectoryScope(directoryPath: string, recursive: boolean = true): DocumentSearchScope {\n const pattern = recursive \n ? `^${directoryPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/.*`\n : `^${directoryPath.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}/[^/]+$`;\n return {\n pathPattern: new RegExp(pattern)\n };\n}\n\nexport function createFileTypeScope(fileTypes: string[]): DocumentSearchScope {\n const pattern = `\\\\.(${fileTypes.join('|')})$`;\n return {\n pathPattern: new RegExp(pattern)\n };\n}\n\nexport function combineScopes(...scopes: (DocumentSearchScope | null)[]): DocumentSearchScope | null {\n const validScopes = scopes.filter((s): s is DocumentSearchScope => s !== null);\n if (validScopes.length === 0) {\n return null;\n }\n if (validScopes.length === 1) {\n return validScopes[0];\n }\n\n const combined: DocumentSearchScope = {};\n \n const allIncludePaths: string[] = [];\n const allExcludePaths: string[] = [];\n const allTags: string[] = [];\n const allMetadataFilters: Array<(doc: IndexedDocument) => boolean> = [];\n\n for (const scope of validScopes) {\n if (scope.includePaths) {\n allIncludePaths.push(...scope.includePaths);\n }\n if (scope.excludePaths) {\n allExcludePaths.push(...scope.excludePaths);\n }\n if (scope.tags) {\n allTags.push(...scope.tags);\n }\n if (scope.metadataFilter) {\n allMetadataFilters.push(scope.metadataFilter);\n }\n if (scope.pathPattern) {\n const existingPattern = combined.pathPattern;\n if (existingPattern) {\n const newPattern = scope.pathPattern instanceof RegExp \n ? scope.pathPattern \n : new RegExp(scope.pathPattern);\n combined.pathPattern = new RegExp(`(${existingPattern instanceof RegExp ? existingPattern.source : existingPattern})|(${newPattern.source})`);\n } else {\n combined.pathPattern = scope.pathPattern;\n }\n }\n }\n\n if (allIncludePaths.length > 0) {\n combined.includePaths = [...new Set(allIncludePaths)];\n }\n if (allExcludePaths.length > 0) {\n combined.excludePaths = [...new Set(allExcludePaths)];\n }\n if (allTags.length > 0) {\n combined.tags = [...new Set(allTags)];\n }\n if (allMetadataFilters.length > 0) {\n combined.metadataFilter = (doc: IndexedDocument) => {\n return allMetadataFilters.every(filter => filter(doc));\n };\n }\n\n return combined;\n}\n\n"],"mappings":";;;AA4EA,SAAgB,kBAAkB,WAA0C;CACxE,OAAO,EACH,cAAc,UAClB;AACJ;AAEA,SAAgB,qBAAqB,eAAuB,YAAqB,MAA2B;CACxG,MAAM,UAAU,YACV,IAAI,cAAc,QAAQ,uBAAuB,MAAM,EAAE,OACzD,IAAI,cAAc,QAAQ,uBAAuB,MAAM,EAAE;CAC/D,OAAO,EACH,aAAa,IAAI,OAAO,OAAO,EACnC;AACJ;AAEA,SAAgB,oBAAoB,WAA0C;CAC1E,MAAM,UAAU,OAAO,UAAU,KAAK,GAAG,EAAE;CAC3C,OAAO,EACH,aAAa,IAAI,OAAO,OAAO,EACnC;AACJ;AAEA,SAAgB,cAAc,GAAG,QAAoE;CACjG,MAAM,cAAc,OAAO,QAAQ,MAAgC,MAAM,IAAI;CAC7E,IAAI,YAAY,WAAW,GACvB,OAAO;CAEX,IAAI,YAAY,WAAW,GACvB,OAAO,YAAY;CAGvB,MAAM,WAAgC,CAAC;CAEvC,MAAM,kBAA4B,CAAC;CACnC,MAAM,kBAA4B,CAAC;CACnC,MAAM,UAAoB,CAAC;CAC3B,MAAM,qBAA+D,CAAC;CAEtE,KAAK,MAAM,SAAS,aAAa;EAC7B,IAAI,MAAM,cACN,gBAAgB,KAAK,GAAG,MAAM,YAAY;EAE9C,IAAI,MAAM,cACN,gBAAgB,KAAK,GAAG,MAAM,YAAY;EAE9C,IAAI,MAAM,MACN,QAAQ,KAAK,GAAG,MAAM,IAAI;EAE9B,IAAI,MAAM,gBACN,mBAAmB,KAAK,MAAM,cAAc;EAEhD,IAAI,MAAM,aAAa;GACnB,MAAM,kBAAkB,SAAS;GACjC,IAAI,iBAAiB;IACjB,MAAM,aAAa,MAAM,uBAAuB,SAC1C,MAAM,cACN,IAAI,OAAO,MAAM,WAAW;IAClC,SAAS,cAAc,IAAI,OAAO,IAAI,2BAA2B,SAAS,gBAAgB,SAAS,gBAAgB,KAAK,WAAW,OAAO,EAAE;GAChJ,OACI,SAAS,cAAc,MAAM;EAErC;CACJ;CAEA,IAAI,gBAAgB,SAAS,GACzB,SAAS,eAAe,CAAC,GAAG,IAAI,IAAI,eAAe,CAAC;CAExD,IAAI,gBAAgB,SAAS,GACzB,SAAS,eAAe,CAAC,GAAG,IAAI,IAAI,eAAe,CAAC;CAExD,IAAI,QAAQ,SAAS,GACjB,SAAS,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC;CAExC,IAAI,mBAAmB,SAAS,GAC5B,SAAS,kBAAkB,QAAyB;EAChD,OAAO,mBAAmB,OAAM,WAAU,OAAO,GAAG,CAAC;CACzD;CAGJ,OAAO;AACX"}
@@ -8,4 +8,4 @@ var i18n_de_default = {
8
8
  //#endregion
9
9
  export { EXT_RAG_SYSTEM_DESC, EXT_RAG_SYSTEM_NAME, i18n_de_default as default };
10
10
 
11
- //# sourceMappingURL=i18n.de-C4Oy9SoE.js.map
11
+ //# sourceMappingURL=i18n.de-BlIlaOdb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.de-C4Oy9SoE.js","names":[],"sources":["../src/i18n.de.json"],"sourcesContent":["{\n \"EXT_RAG_SYSTEM_NAME\": \"RAG-System\",\n \"EXT_RAG_SYSTEM_DESC\": \"Retrieval-Augmented Generation System für Dokumentenindizierung, Suche und Abruf\"\n}\n"],"mappings":""}
1
+ {"version":3,"file":"i18n.de-BlIlaOdb.js","names":[],"sources":["../src/i18n.de.json"],"sourcesContent":["{\n \"EXT_RAG_SYSTEM_NAME\": \"RAG-System\",\n \"EXT_RAG_SYSTEM_DESC\": \"Retrieval-Augmented Generation System für Dokumentenindizierung, Suche und Abruf\"\n}\n"],"mappings":""}
@@ -8,4 +8,4 @@ var i18n_en_default = {
8
8
  //#endregion
9
9
  export { EXT_RAG_SYSTEM_DESC, EXT_RAG_SYSTEM_NAME, i18n_en_default as default };
10
10
 
11
- //# sourceMappingURL=i18n.en-BGbyrXax.js.map
11
+ //# sourceMappingURL=i18n.en-gnDJyJge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.en-BGbyrXax.js","names":[],"sources":["../src/i18n.en.json"],"sourcesContent":["{\n \"EXT_RAG_SYSTEM_NAME\": \"RAG System\",\n \"EXT_RAG_SYSTEM_DESC\": \"Retrieval-Augmented Generation system for document indexing, search and retrieval\"\n}\n"],"mappings":""}
1
+ {"version":3,"file":"i18n.en-gnDJyJge.js","names":[],"sources":["../src/i18n.en.json"],"sourcesContent":["{\n \"EXT_RAG_SYSTEM_NAME\": \"RAG System\",\n \"EXT_RAG_SYSTEM_DESC\": \"Retrieval-Augmented Generation system for document indexing, search and retrieval\"\n}\n"],"mappings":""}
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { extensionRegistry, i18n } from "@eclipse-docks/core";
2
2
  import pkg from "../package.json";
3
3
  //#region src/index.ts
4
- var t = await i18n(/* @__PURE__ */ Object.assign({
5
- "./i18n.de.json": () => import("./i18n.de-C4Oy9SoE.js"),
6
- "./i18n.en.json": () => import("./i18n.en-BGbyrXax.js")
4
+ var t = await i18n(/* #__PURE__ */ Object.assign({
5
+ "./i18n.de.json": () => import("./i18n.de-BlIlaOdb.js"),
6
+ "./i18n.en.json": () => import("./i18n.en-gnDJyJge.js")
7
7
  }), true);
8
8
  extensionRegistry.registerExtension({
9
9
  id: pkg.name,
10
10
  name: t.EXT_RAG_SYSTEM_NAME,
11
11
  description: t.EXT_RAG_SYSTEM_DESC,
12
- loader: () => import("./rag-system-extension-tTT5Pglo.js"),
12
+ loader: () => import("./rag-system-extension-BW-FSxET.js"),
13
13
  icon: "database",
14
14
  experimental: true,
15
15
  dependencies: ["@eclipse-docks/extension-ai-system", "@eclipse-docks/extension-in-browser-ml"]
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry, i18n } from '@eclipse-docks/core';\nimport pkg from '../package.json';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_RAG_SYSTEM_NAME,\n description: t.EXT_RAG_SYSTEM_DESC,\n loader: () => import(\"./rag-system-extension\"),\n icon: \"database\",\n experimental: true,\n dependencies: [\"@eclipse-docks/extension-ai-system\", \"@eclipse-docks/extension-in-browser-ml\"],\n});\n"],"mappings":";;;AAGA,IAAM,IAAI,MAAM,KAAK,uBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,CAAgC,EAAE,KAAK;AAE5D,kBAAkB,kBAAkB;CAClC,IAAI,IAAI;CACR,MAAM,EAAE;CACR,aAAa,EAAE;CACf,cAAc,OAAO;CACrB,MAAM;CACN,cAAc;CACd,cAAc,CAAC,sCAAsC,yCAAA;CACtD,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { extensionRegistry, i18n } from '@eclipse-docks/core';\nimport pkg from '../package.json';\n\nconst t = await i18n(import.meta.glob('./i18n*.json'), true);\n\nextensionRegistry.registerExtension({\n id: pkg.name,\n name: t.EXT_RAG_SYSTEM_NAME,\n description: t.EXT_RAG_SYSTEM_DESC,\n loader: () => import(\"./rag-system-extension\"),\n icon: \"database\",\n experimental: true,\n dependencies: [\"@eclipse-docks/extension-ai-system\", \"@eclipse-docks/extension-in-browser-ml\"],\n});\n"],"mappings":";;;AAGA,IAAM,IAAI,MAAM,KAAK,uBAAA,OAAA;CAAA,wBAAA,OAAA;CAAA,wBAAA,OAAA;AAAA,CAAA,GAAkC,IAAI;AAE3D,kBAAkB,kBAAkB;CAClC,IAAI,IAAI;CACR,MAAM,EAAE;CACR,aAAa,EAAE;CACf,cAAc,OAAO;CACrB,MAAM;CACN,cAAc;CACd,cAAc,CAAC,sCAAsC,wCAAwC;AAC/F,CAAC"}
@@ -1,4 +1,4 @@
1
- import { a as getWorkspacePath, f as SEARCH_CONFIG, i as SnippetExtractor, n as searchWorkspaceDocuments, o as documentIndexService, r as RAGResultFormatter, t as ragService } from "./rag-service-Cymd0ECr.js";
1
+ import { a as getWorkspacePath, f as SEARCH_CONFIG, i as SnippetExtractor, n as searchWorkspaceDocuments, o as documentIndexService, r as RAGResultFormatter, t as ragService } from "./rag-service-BXPQTm_G.js";
2
2
  import { createLogger, registerAll, rootContext } from "@eclipse-docks/core";
3
3
  import { aiService } from "@eclipse-docks/extension-ai-system/api";
4
4
  //#region src/rag-integration.ts
@@ -31,16 +31,17 @@ function createRAGToolExecutor() {
31
31
  const fileType = params.fileType;
32
32
  const filePath = params.filePath;
33
33
  const fileName = params.fileName;
34
+ const documentSearchScope = params.includePaths || params.excludePaths || params.pathPattern ? {
35
+ includePaths: params.includePaths,
36
+ excludePaths: params.excludePaths,
37
+ pathPattern: params.pathPattern
38
+ } : void 0;
34
39
  const results = await searchWorkspaceDocuments(query, {
35
40
  limit,
36
41
  fileType,
37
42
  filePath,
38
43
  fileName,
39
- documentSearchScope: params.includePaths || params.excludePaths || params.pathPattern ? {
40
- includePaths: params.includePaths,
41
- excludePaths: params.excludePaths,
42
- pathPattern: params.pathPattern
43
- } : void 0
44
+ documentSearchScope
44
45
  });
45
46
  return {
46
47
  results: resultFormatter.formatSearchResults(results),
@@ -170,4 +171,4 @@ rootContext.put("ragService", ragService);
170
171
  //#endregion
171
172
  export { registerRAGCommands as i, integrateRAGWithAI as n, ragPromptEnhancer as r, createRAGToolExecutor as t };
172
173
 
173
- //# sourceMappingURL=rag-integration-U1AB0yh6.js.map
174
+ //# sourceMappingURL=rag-integration-BPga10kB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rag-integration-U1AB0yh6.js","names":[],"sources":["../src/rag-integration.ts"],"sourcesContent":["import { ragService, searchWorkspaceDocuments } from './rag-service';\nimport { DocumentSearchScope } from './document-index-service';\nimport { documentIndexService } from './document-index-service';\nimport { getWorkspacePath } from './utils/workspace-utils';\nimport { rootContext } from '@eclipse-docks/core';\nimport { SEARCH_CONFIG } from './utils/constants';\nimport { RAGResultFormatter } from './services/rag-result-formatter';\nimport { SnippetExtractor } from './utils/snippet-extractor';\nimport { aiService } from '@eclipse-docks/extension-ai-system/api';\nimport { commandRegistry, registerAll } from '@eclipse-docks/core';\nimport type { ExecutionContext } from '@eclipse-docks/core';\nimport type { PromptEnhancer, ToolDefinition } from '@eclipse-docks/extension-ai-system/api';\nimport { createLogger } from '@eclipse-docks/core';\n\nconst logger = createLogger('RAGIntegration');\nconst resultFormatter = new RAGResultFormatter(new SnippetExtractor());\n\nexport const ragPromptEnhancer: PromptEnhancer = {\n priority: 10,\n async enhance(prompt: string, context: ExecutionContext): Promise<string> {\n try {\n const stats = await documentIndexService.getStats();\n if (stats.totalDocuments === 0) {\n return prompt;\n }\n\n const instruction = `IMPORTANT: When a user mentions a specific file name or path:\n1. ALWAYS first check if the file is indexed using rag.checindexed with the file path\n2. If indexed: Use rag.search-documents with filePath parameter to get relevant content from the indexed document\n3. If not indexed: Read the file directly using file commands (cat_file, ls, etc.)\n\nNEVER use filePath or fileName parameters in rag.search-documents without first verifying the file is indexed with rag.checindexed. If you use a non-indexed file path/name, the search will return no results.\n\nFor general searches (not specific files), use rag.search-documents with just the query parameter to search across all indexed documents. This is more efficient than reading files one by one.`;\n\n return `${prompt}\\n\\n${instruction}`;\n } catch (error) {\n logger.warn(`RAG enhancement failed: ${error}`);\n return prompt;\n }\n }\n};\n\nexport function createRAGToolExecutor() {\n return async (toolName: string, params: any): Promise<any> => {\n if (toolName === 'search_workspace_documents') {\n const query = params.query || '';\n const limit = Math.min(params.limit || SEARCH_CONFIG.DEFAULT_LIMIT, SEARCH_CONFIG.MAX_LIMIT);\n const fileType = params.fileType;\n const filePath = params.filePath;\n const fileName = params.fileName;\n\n const documentSearchScope: DocumentSearchScope | undefined = \n (params.includePaths || params.excludePaths || params.pathPattern)\n ? {\n includePaths: params.includePaths,\n excludePaths: params.excludePaths,\n pathPattern: params.pathPattern\n }\n : undefined;\n\n const results = await searchWorkspaceDocuments(query, {\n limit,\n fileType,\n filePath,\n fileName,\n documentSearchScope\n });\n\n return {\n results: resultFormatter.formatSearchResults(results),\n total: results.length\n };\n }\n\n throw new Error(`Unknown RAG tool: ${toolName}`);\n };\n}\n\nexport function registerRAGCommands() {\n registerAll({\n command: {\n id: 'rag.search-documents',\n name: 'Search Workspace Documents (RAG)',\n description: 'Search indexed workspace documents for relevant content. IMPORTANT: Only use filePath or fileName if you have already verified the file is indexed using rag.checindexed. If the file is not indexed, this will return no results.',\n parameters: [\n {\n name: 'query',\n description: 'Search query (optional if filePath or fileName is provided)',\n required: false\n },\n {\n name: 'limit',\n description: 'Maximum number of results',\n required: false\n },\n {\n name: 'fileType',\n description: 'Filter by file type',\n required: false\n },\n {\n name: 'filePath',\n description: 'Exact file path to search (relative to workspace root). Only use if you verified the file is indexed with rag.checindexed.',\n required: false\n },\n {\n name: 'fileName',\n description: 'File name to search for (partial match supported). Only use if you verified the file is indexed with rag.checindexed.',\n required: false\n }\n ]\n },\n handler: {\n canExecute: () => true,\n execute: async (context) => {\n const query = context.params?.query || '';\n const limit = context.params?.limit \n ? Math.min(parseInt(context.params.limit), SEARCH_CONFIG.MAX_LIMIT)\n : SEARCH_CONFIG.DEFAULT_LIMIT;\n const fileType = context.params?.fileType;\n const filePath = context.params?.filePath;\n const fileName = context.params?.fileName;\n\n if (!query && !filePath && !fileName) {\n throw new Error('Either query, filePath, or fileName parameter must be provided');\n }\n\n const results = await searchWorkspaceDocuments(query, {\n limit,\n fileType,\n filePath,\n fileName\n });\n\n if ((filePath || fileName) && results.length === 0) {\n return {\n query: query || (filePath ? `filePath: ${filePath}` : `fileName: ${fileName}`),\n results: [],\n warning: `No indexed document found for ${filePath ? `file path \"${filePath}\"` : `file name \"${fileName}\"`}. The file may not be indexed. Use rag.checindexed to verify if a file is indexed before searching.`\n };\n }\n\n return {\n query: query || (filePath ? `filePath: ${filePath}` : fileName ? `fileName: ${fileName}` : ''),\n results: resultFormatter.formatCommandResults(results)\n };\n }\n }\n });\n\n registerAll({\n command: {\n id: 'rag.checindexed',\n name: 'Check if File is Indexed',\n description: 'Check if a specific file is indexed in the document index. Use this to determine if you should use RAG search or read the file directly.',\n parameters: [\n {\n name: 'filePath',\n description: 'The file path to check (relative to workspace root)',\n required: true\n }\n ]\n },\n handler: {\n canExecute: () => true,\n execute: async (context) => {\n const filePath = context.params?.filePath;\n if (!filePath) {\n throw new Error('File path parameter required');\n }\n\n const workspaceResult = await getWorkspacePath();\n if (!workspaceResult) {\n return { indexed: false, reason: 'No workspace connected' };\n }\n\n const { workspacePath } = workspaceResult;\n const document = await documentIndexService.getDocumentByPath(workspacePath, filePath);\n\n if (document) {\n return {\n indexed: true,\n filePath: document.filePath,\n fileName: document.fileName,\n fileType: document.fileType,\n indexedAt: new Date(document.indexedAt).toISOString(),\n size: document.metadata.size\n };\n }\n\n return {\n indexed: false,\n filePath,\n reason: 'File not found in document index'\n };\n }\n }\n });\n}\n\nexport function integrateRAGWithAI() {\n try {\n registerRAGCommands();\n \n const promptBuilder = (aiService as any).promptBuilder;\n if (promptBuilder && typeof promptBuilder.addEnhancer === 'function') {\n promptBuilder.addEnhancer(ragPromptEnhancer);\n logger.info('RAG prompt enhancer and commands registered - AI will be instructed to use RAG before reading files');\n } else {\n logger.warn('AI service prompt builder not available yet, will retry');\n setTimeout(() => integrateRAGWithAI(), 1000);\n }\n } catch (error) {\n logger.warn(`Failed to integrate RAG with AI: ${error}`);\n }\n}\n\nrootContext.put('ragService', ragService);\n\n"],"mappings":";;;;AAcA,IAAM,SAAS,aAAa,iBAAiB;AAC7C,IAAM,kBAAkB,IAAI,mBAAmB,IAAI,kBAAkB,CAAC;AAEtE,IAAa,oBAAoC;CAC7C,UAAU;CACV,MAAM,QAAQ,QAAgB,SAA4C;AACtE,MAAI;AAEA,QADc,MAAM,qBAAqB,UAAU,EACzC,mBAAmB,EACzB,QAAO;AAYX,UAAO,GAAG,OAAO;;;;;;;;WACZ,OAAO;AACZ,UAAO,KAAK,2BAA2B,QAAQ;AAC/C,UAAO;;;CAGlB;AAED,SAAgB,wBAAwB;AACpC,QAAO,OAAO,UAAkB,WAA8B;AAC1D,MAAI,aAAa,8BAA8B;GAC3C,MAAM,QAAQ,OAAO,SAAS;GAC9B,MAAM,QAAQ,KAAK,IAAI,OAAO,SAAS,cAAc,eAAe,cAAc,UAAU;GAC5F,MAAM,WAAW,OAAO;GACxB,MAAM,WAAW,OAAO;GACxB,MAAM,WAAW,OAAO;GAWxB,MAAM,UAAU,MAAM,yBAAyB,OAAO;IAClD;IACA;IACA;IACA;IACA,qBAbC,OAAO,gBAAgB,OAAO,gBAAgB,OAAO,cAChD;KACE,cAAc,OAAO;KACrB,cAAc,OAAO;KACrB,aAAa,OAAO;KACvB,GACC,KAAA;IAQT,CAAC;AAEF,UAAO;IACH,SAAS,gBAAgB,oBAAoB,QAAQ;IACrD,OAAO,QAAQ;IAClB;;AAGL,QAAM,IAAI,MAAM,qBAAqB,WAAW;;;AAIxD,SAAgB,sBAAsB;AAClC,aAAY;EACR,SAAS;GACL,IAAI;GACJ,MAAM;GACN,aAAa;GACb,YAAY;IACR;KACI,MAAM;KACN,aAAa;KACb,UAA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AAC,gBACD,QAAO;KAAE,SAAS;KAAO,QAAQ;KAA0B;IAG/D,MAAM,EAAE,kBAAkB;IAC1B,MAAM,WAAW,MAAM,qBAAqB,kBAAkB,eAAe,SAAS;AAEtF,QAAI,SACA,QAAO;KACH,SAAS;KACT,UAAU,SAAS;KACnB,UAAU,SAAS;KACnB,UAAU,SAAS;KACnB,WAAW,IAAI,KAAK,SAAS,UAAU,CAAC,aAAa;KACrD,MAAM,SAAS,SAAS;KAC3B;AAGL,WAAO;KACH,SAAS;KACT;KACA,QAAQ;KACX;;GAER;EACJ,CAAC;;AAGN,SAAgB,qBAAqB;AACjC,KAAI;AACA,uBAAqB;EAErB,MAAM,gBAAiB,UAAkB;AACzC,MAAI,iBAAiB,OAAO,cAAc,gBAAgB,YAAY;AAClE,iBAAc,YAAY,kBAAkB;AAC5C,UAAO,KAAK,sGAAsG;SAC/G;AACH,UAAO,KAAK,0DAA0D;AACtE,oBAAiB,oBAAoB,EAAE,IAAK;;UAE3C,OAAO;AACZ,SAAO,KAAK,oCAAoC,QAAQ;;;AAIhE,YAAY,IAAI,cAAc,WAAW"}
1
+ {"version":3,"file":"rag-integration-BPga10kB.js","names":[],"sources":["../src/rag-integration.ts"],"sourcesContent":["import { ragService, searchWorkspaceDocuments } from './rag-service';\nimport { DocumentSearchScope } from './document-index-service';\nimport { documentIndexService } from './document-index-service';\nimport { getWorkspacePath } from './utils/workspace-utils';\nimport { rootContext } from '@eclipse-docks/core';\nimport { SEARCH_CONFIG } from './utils/constants';\nimport { RAGResultFormatter } from './services/rag-result-formatter';\nimport { SnippetExtractor } from './utils/snippet-extractor';\nimport { aiService } from '@eclipse-docks/extension-ai-system/api';\nimport { commandRegistry, registerAll } from '@eclipse-docks/core';\nimport type { ExecutionContext } from '@eclipse-docks/core';\nimport type { PromptEnhancer, ToolDefinition } from '@eclipse-docks/extension-ai-system/api';\nimport { createLogger } from '@eclipse-docks/core';\n\nconst logger = createLogger('RAGIntegration');\nconst resultFormatter = new RAGResultFormatter(new SnippetExtractor());\n\nexport const ragPromptEnhancer: PromptEnhancer = {\n priority: 10,\n async enhance(prompt: string, context: ExecutionContext): Promise<string> {\n try {\n const stats = await documentIndexService.getStats();\n if (stats.totalDocuments === 0) {\n return prompt;\n }\n\n const instruction = `IMPORTANT: When a user mentions a specific file name or path:\n1. ALWAYS first check if the file is indexed using rag.checindexed with the file path\n2. If indexed: Use rag.search-documents with filePath parameter to get relevant content from the indexed document\n3. If not indexed: Read the file directly using file commands (cat_file, ls, etc.)\n\nNEVER use filePath or fileName parameters in rag.search-documents without first verifying the file is indexed with rag.checindexed. If you use a non-indexed file path/name, the search will return no results.\n\nFor general searches (not specific files), use rag.search-documents with just the query parameter to search across all indexed documents. This is more efficient than reading files one by one.`;\n\n return `${prompt}\\n\\n${instruction}`;\n } catch (error) {\n logger.warn(`RAG enhancement failed: ${error}`);\n return prompt;\n }\n }\n};\n\nexport function createRAGToolExecutor() {\n return async (toolName: string, params: any): Promise<any> => {\n if (toolName === 'search_workspace_documents') {\n const query = params.query || '';\n const limit = Math.min(params.limit || SEARCH_CONFIG.DEFAULT_LIMIT, SEARCH_CONFIG.MAX_LIMIT);\n const fileType = params.fileType;\n const filePath = params.filePath;\n const fileName = params.fileName;\n\n const documentSearchScope: DocumentSearchScope | undefined = \n (params.includePaths || params.excludePaths || params.pathPattern)\n ? {\n includePaths: params.includePaths,\n excludePaths: params.excludePaths,\n pathPattern: params.pathPattern\n }\n : undefined;\n\n const results = await searchWorkspaceDocuments(query, {\n limit,\n fileType,\n filePath,\n fileName,\n documentSearchScope\n });\n\n return {\n results: resultFormatter.formatSearchResults(results),\n total: results.length\n };\n }\n\n throw new Error(`Unknown RAG tool: ${toolName}`);\n };\n}\n\nexport function registerRAGCommands() {\n registerAll({\n command: {\n id: 'rag.search-documents',\n name: 'Search Workspace Documents (RAG)',\n description: 'Search indexed workspace documents for relevant content. IMPORTANT: Only use filePath or fileName if you have already verified the file is indexed using rag.checindexed. If the file is not indexed, this will return no results.',\n parameters: [\n {\n name: 'query',\n description: 'Search query (optional if filePath or fileName is provided)',\n required: false\n },\n {\n name: 'limit',\n description: 'Maximum number of results',\n required: false\n },\n {\n name: 'fileType',\n description: 'Filter by file type',\n required: false\n },\n {\n name: 'filePath',\n description: 'Exact file path to search (relative to workspace root). Only use if you verified the file is indexed with rag.checindexed.',\n required: false\n },\n {\n name: 'fileName',\n description: 'File name to search for (partial match supported). Only use if you verified the file is indexed with rag.checindexed.',\n required: false\n }\n ]\n },\n handler: {\n canExecute: () => true,\n execute: async (context) => {\n const query = context.params?.query || '';\n const limit = context.params?.limit \n ? Math.min(parseInt(context.params.limit), SEARCH_CONFIG.MAX_LIMIT)\n : SEARCH_CONFIG.DEFAULT_LIMIT;\n const fileType = context.params?.fileType;\n const filePath = context.params?.filePath;\n const fileName = context.params?.fileName;\n\n if (!query && !filePath && !fileName) {\n throw new Error('Either query, filePath, or fileName parameter must be provided');\n }\n\n const results = await searchWorkspaceDocuments(query, {\n limit,\n fileType,\n filePath,\n fileName\n });\n\n if ((filePath || fileName) && results.length === 0) {\n return {\n query: query || (filePath ? `filePath: ${filePath}` : `fileName: ${fileName}`),\n results: [],\n warning: `No indexed document found for ${filePath ? `file path \"${filePath}\"` : `file name \"${fileName}\"`}. The file may not be indexed. Use rag.checindexed to verify if a file is indexed before searching.`\n };\n }\n\n return {\n query: query || (filePath ? `filePath: ${filePath}` : fileName ? `fileName: ${fileName}` : ''),\n results: resultFormatter.formatCommandResults(results)\n };\n }\n }\n });\n\n registerAll({\n command: {\n id: 'rag.checindexed',\n name: 'Check if File is Indexed',\n description: 'Check if a specific file is indexed in the document index. Use this to determine if you should use RAG search or read the file directly.',\n parameters: [\n {\n name: 'filePath',\n description: 'The file path to check (relative to workspace root)',\n required: true\n }\n ]\n },\n handler: {\n canExecute: () => true,\n execute: async (context) => {\n const filePath = context.params?.filePath;\n if (!filePath) {\n throw new Error('File path parameter required');\n }\n\n const workspaceResult = await getWorkspacePath();\n if (!workspaceResult) {\n return { indexed: false, reason: 'No workspace connected' };\n }\n\n const { workspacePath } = workspaceResult;\n const document = await documentIndexService.getDocumentByPath(workspacePath, filePath);\n\n if (document) {\n return {\n indexed: true,\n filePath: document.filePath,\n fileName: document.fileName,\n fileType: document.fileType,\n indexedAt: new Date(document.indexedAt).toISOString(),\n size: document.metadata.size\n };\n }\n\n return {\n indexed: false,\n filePath,\n reason: 'File not found in document index'\n };\n }\n }\n });\n}\n\nexport function integrateRAGWithAI() {\n try {\n registerRAGCommands();\n \n const promptBuilder = (aiService as any).promptBuilder;\n if (promptBuilder && typeof promptBuilder.addEnhancer === 'function') {\n promptBuilder.addEnhancer(ragPromptEnhancer);\n logger.info('RAG prompt enhancer and commands registered - AI will be instructed to use RAG before reading files');\n } else {\n logger.warn('AI service prompt builder not available yet, will retry');\n setTimeout(() => integrateRAGWithAI(), 1000);\n }\n } catch (error) {\n logger.warn(`Failed to integrate RAG with AI: ${error}`);\n }\n}\n\nrootContext.put('ragService', ragService);\n\n"],"mappings":";;;;AAcA,IAAM,SAAS,aAAa,gBAAgB;AAC5C,IAAM,kBAAkB,IAAI,mBAAmB,IAAI,iBAAiB,CAAC;AAErE,IAAa,oBAAoC;CAC7C,UAAU;CACV,MAAM,QAAQ,QAAgB,SAA4C;EACtE,IAAI;GAEA,KAAI,MADgB,qBAAqB,SAAS,EAAA,CACxC,mBAAmB,GACzB,OAAO;GAYX,OAAO,GAAG,OAAO;;;;;;;;EACrB,SAAS,OAAO;GACZ,OAAO,KAAK,2BAA2B,OAAO;GAC9C,OAAO;EACX;CACJ;AACJ;AAEA,SAAgB,wBAAwB;CACpC,OAAO,OAAO,UAAkB,WAA8B;EAC1D,IAAI,aAAa,8BAA8B;GAC3C,MAAM,QAAQ,OAAO,SAAS;GAC9B,MAAM,QAAQ,KAAK,IAAI,OAAO,SAAS,cAAc,eAAe,cAAc,SAAS;GAC3F,MAAM,WAAW,OAAO;GACxB,MAAM,WAAW,OAAO;GACxB,MAAM,WAAW,OAA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WithAI } from "./rag-integration-BPga10kB.js";
2
+ export { integrateRAGWithAI };
@@ -378,8 +378,10 @@ var PDFJSExtractor = class {
378
378
  const pageSeparator = options.pageSeparator || "\n\n";
379
379
  for (let pageNum = 1; pageNum <= numPages; pageNum++) {
380
380
  const pageText = (await (await pdf.getPage(pageNum)).getTextContent()).items.map((item) => item.str).join(" ");
381
- if (pageText.trim()) if (includePageNumbers) textParts.push(`[Page ${pageNum}]\n${pageText}`);
382
- else textParts.push(pageText);
381
+ if (pageText.trim()) {
382
+ if (includePageNumbers) textParts.push(`[Page ${pageNum}]\n${pageText}`);
383
+ else textParts.push(pageText);
384
+ }
383
385
  }
384
386
  const extractedText = textParts.join(pageSeparator);
385
387
  if (!extractedText || extractedText.trim().length === 0) throw new Error("PDF appears to contain no extractable text (may be image-based or scanned)");
@@ -567,7 +569,7 @@ var DocumentIndexService = class {
567
569
  constructor() {
568
570
  this.sampleVectors = [];
569
571
  this.isInitialized = false;
570
- this.DEFAULT_MAX_FILE_SIZE = 5 * 1024 * 1024;
572
+ this.DEFAULT_MAX_FILE_SIZE = 5242880;
571
573
  this.chunker = new DocumentChunker();
572
574
  this.documentExtractor = new DocumentExtractor();
573
575
  this.DEFAULT_INDEXABLE_TYPES = [
@@ -797,7 +799,7 @@ var DocumentIndexService = class {
797
799
  const existingDoc = existing ? existing.toJSON() : null;
798
800
  const existingTags = existingDoc?.metadata.tags || [];
799
801
  const newTags = options.tags || [];
800
- const mergedTags = [...new Set([...existingTags, ...newTags])];
802
+ const mergedTags = [.../* @__PURE__ */ new Set([...existingTags, ...newTags])];
801
803
  const tagsChanged = mergedTags.length !== existingTags.length || newTags.some((tag) => !existingTags.includes(tag));
802
804
  if (existingDoc && existingDoc.contentHash === contentHash && !tagsChanged) {
803
805
  logger$2.debug(`Document already indexed and unchanged: ${id}`);
@@ -975,7 +977,7 @@ var DocumentIndexService = class {
975
977
  const id = this.generateDocumentId(workspacePath, filePath);
976
978
  const existingTags = (await this.getDocument(id))?.metadata.tags || [];
977
979
  const newTags = options.tags || [];
978
- const mergedTags = [...new Set([...existingTags, ...newTags])];
980
+ const mergedTags = [.../* @__PURE__ */ new Set([...existingTags, ...newTags])];
979
981
  await this.deleteDocument(id);
980
982
  return this.indexDocument(file, {
981
983
  ...options,
@@ -1170,7 +1172,7 @@ var DocumentIndexService = class {
1170
1172
  const newTags = [...options.tags || [], ...contextTags];
1171
1173
  if (existingDoc) {
1172
1174
  const existingTags = existingDoc.metadata.tags || [];
1173
- const mergedTags = [...new Set([...existingTags, ...newTags])];
1175
+ const mergedTags = [.../* @__PURE__ */ new Set([...existingTags, ...newTags])];
1174
1176
  if (mergedTags.length !== existingTags.length || newTags.some((tag) => !existingTags.includes(tag))) {
1175
1177
  await this.updateDocumentMetadata(existingDoc.id, { metadata: {
1176
1178
  ...existingDoc.metadata,
@@ -1555,11 +1557,13 @@ var RAGService = class {
1555
1557
  if (chunkText.trim().length > 0) matchedSnippets = [chunkText.trim()];
1556
1558
  else matchedSnippets = snippetExtractor.extractSnippets(document.content, queryTerms, 15);
1557
1559
  } else matchedSnippets = snippetExtractor.extractSnippets(document.content, queryTerms, 15);
1558
- if (matchedSnippets.length === 0 && queryLower.length > 0) if (chunkStartOffset !== void 0 && chunkEndOffset !== void 0) {
1559
- const chunkText = document.content.substring(Math.max(0, chunkStartOffset), Math.min(document.content.length, chunkEndOffset));
1560
- if (chunkText.trim().length > 0) matchedSnippets = [chunkText.trim()];
1561
- else matchedSnippets = snippetExtractor.extractSnippets(document.content, [queryLower], 10);
1562
- } else matchedSnippets = snippetExtractor.extractSnippets(document.content, [queryLower], 10);
1560
+ if (matchedSnippets.length === 0 && queryLower.length > 0) {
1561
+ if (chunkStartOffset !== void 0 && chunkEndOffset !== void 0) {
1562
+ const chunkText = document.content.substring(Math.max(0, chunkStartOffset), Math.min(document.content.length, chunkEndOffset));
1563
+ if (chunkText.trim().length > 0) matchedSnippets = [chunkText.trim()];
1564
+ else matchedSnippets = snippetExtractor.extractSnippets(document.content, [queryLower], 10);
1565
+ } else matchedSnippets = snippetExtractor.extractSnippets(document.content, [queryLower], 10);
1566
+ }
1563
1567
  results.push({
1564
1568
  document,
1565
1569
  relevance,
@@ -1649,4 +1653,4 @@ async function searchWorkspaceDocuments(query, options = {}) {
1649
1653
  //#endregion
1650
1654
  export { getWorkspacePath as a, createIndexValuesFromArray as c, CONTENT_PREVIEW_LENGTHS as d, SEARCH_CONFIG as f, SnippetExtractor as i, euclideanDistance as l, embeddingService as m, searchWorkspaceDocuments as n, documentIndexService as o, SNIPPET_LENGTHS as p, RAGResultFormatter as r, cosineSimilarity as s, ragService as t, getIndexValueArray as u };
1651
1655
 
1652
- //# sourceMappingURL=rag-service-Cymd0ECr.js.map
1656
+ //# sourceMappingURL=rag-service-BXPQTm_G.js.map