@elyracode/semantic-index 0.9.56 → 0.9.58
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/CHANGELOG.md +8 -0
- package/extensions/index.ts +53 -20
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.58] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
## [0.9.57] - 2026-11-10
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Tool failures were returned as normal results (`isError` on the return value is ignored) and the model saw them as successes; they now throw so the result is marked as an error
|
|
10
|
+
|
|
3
11
|
## [0.9.56] - 2026-11-01
|
|
4
12
|
|
|
5
13
|
## [0.9.55] - 2026-10-21
|
package/extensions/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
-
import type { ExtensionAPI } from "@elyracode/coding-agent";
|
|
4
|
+
import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
|
|
7
7
|
// ── Configuration ───────────────────────────────────────────────────────────
|
|
@@ -46,9 +46,41 @@ async function embed(config: EmbedConfig, inputs: string[]): Promise<number[][]>
|
|
|
46
46
|
// ── File discovery & chunking ───────────────────────────────────────────────
|
|
47
47
|
|
|
48
48
|
const SOURCE_EXTENSIONS = new Set([
|
|
49
|
-
"ts",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
49
|
+
"ts",
|
|
50
|
+
"tsx",
|
|
51
|
+
"js",
|
|
52
|
+
"jsx",
|
|
53
|
+
"mjs",
|
|
54
|
+
"cjs",
|
|
55
|
+
"php",
|
|
56
|
+
"py",
|
|
57
|
+
"rb",
|
|
58
|
+
"go",
|
|
59
|
+
"rs",
|
|
60
|
+
"java",
|
|
61
|
+
"kt",
|
|
62
|
+
"swift",
|
|
63
|
+
"c",
|
|
64
|
+
"h",
|
|
65
|
+
"cpp",
|
|
66
|
+
"hpp",
|
|
67
|
+
"cc",
|
|
68
|
+
"cs",
|
|
69
|
+
"scala",
|
|
70
|
+
"ex",
|
|
71
|
+
"exs",
|
|
72
|
+
"vue",
|
|
73
|
+
"svelte",
|
|
74
|
+
"css",
|
|
75
|
+
"scss",
|
|
76
|
+
"sql",
|
|
77
|
+
"sh",
|
|
78
|
+
"bash",
|
|
79
|
+
"md",
|
|
80
|
+
"json",
|
|
81
|
+
"yaml",
|
|
82
|
+
"yml",
|
|
83
|
+
"toml",
|
|
52
84
|
]);
|
|
53
85
|
|
|
54
86
|
const MAX_FILE_BYTES = 256 * 1024;
|
|
@@ -152,11 +184,7 @@ function cosineSimilarity(a: number[], b: number[]): number {
|
|
|
152
184
|
// ── Result helpers ──────────────────────────────────────────────────────────
|
|
153
185
|
|
|
154
186
|
function ok(text: string) {
|
|
155
|
-
return { content: [{ type: "text" as const, text }] };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function err(text: string) {
|
|
159
|
-
return { content: [{ type: "text" as const, text }], isError: true as const };
|
|
187
|
+
return { content: [{ type: "text" as const, text }], details: undefined };
|
|
160
188
|
}
|
|
161
189
|
|
|
162
190
|
// ── Extension ───────────────────────────────────────────────────────────────
|
|
@@ -177,17 +205,19 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
177
205
|
"Index the project's tracked source files for semantic search. Reads each file, splits it into chunks, embeds them via the configured embeddings endpoint, and stores the index locally at .elyra/semantic-index.json. Run this once per project, and again after large changes. Requires an embeddings endpoint (ELYRA_EMBED_BASE_URL / ELYRA_EMBED_MODEL / ELYRA_EMBED_API_KEY or OPENAI_API_KEY).",
|
|
178
206
|
parameters: Type.Object({
|
|
179
207
|
max_files: Type.Optional(
|
|
180
|
-
Type.Integer({
|
|
208
|
+
Type.Integer({
|
|
209
|
+
description: "Cap the number of files indexed (useful for very large repos). Default: no cap.",
|
|
210
|
+
}),
|
|
181
211
|
),
|
|
182
212
|
}),
|
|
183
213
|
promptSnippet: "Build a semantic index of the codebase",
|
|
184
|
-
async execute(_id, params) {
|
|
214
|
+
async execute(_id, params): Promise<AgentToolResult<undefined>> {
|
|
185
215
|
const config = getEmbedConfig();
|
|
186
216
|
const cwdNow = getCwd();
|
|
187
217
|
|
|
188
218
|
let files = listSourceFiles(cwdNow);
|
|
189
219
|
if (files.length === 0) {
|
|
190
|
-
|
|
220
|
+
throw new Error("No tracked source files found (is this a git repository?).");
|
|
191
221
|
}
|
|
192
222
|
if (params.max_files && params.max_files > 0) {
|
|
193
223
|
files = files.slice(0, params.max_files);
|
|
@@ -207,7 +237,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
207
237
|
}
|
|
208
238
|
|
|
209
239
|
if (chunks.length === 0) {
|
|
210
|
-
|
|
240
|
+
throw new Error("No content to index after chunking.");
|
|
211
241
|
}
|
|
212
242
|
|
|
213
243
|
// Embed in batches.
|
|
@@ -216,14 +246,17 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
216
246
|
try {
|
|
217
247
|
for (let i = 0; i < chunks.length; i += BATCH) {
|
|
218
248
|
const batch = chunks.slice(i, i + BATCH);
|
|
219
|
-
const vectors = await embed(
|
|
249
|
+
const vectors = await embed(
|
|
250
|
+
config,
|
|
251
|
+
batch.map((c) => c.text),
|
|
252
|
+
);
|
|
220
253
|
for (let j = 0; j < batch.length; j++) {
|
|
221
254
|
indexed.push({ ...batch[j], vector: vectors[j] });
|
|
222
255
|
}
|
|
223
256
|
}
|
|
224
257
|
} catch (error) {
|
|
225
258
|
const msg = error instanceof Error ? error.message : String(error);
|
|
226
|
-
|
|
259
|
+
throw new Error(`Failed to embed chunks: ${msg}`);
|
|
227
260
|
}
|
|
228
261
|
|
|
229
262
|
const index: IndexFile = {
|
|
@@ -236,7 +269,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
236
269
|
saveIndex(cwdNow, index);
|
|
237
270
|
} catch (error) {
|
|
238
271
|
const msg = error instanceof Error ? error.message : String(error);
|
|
239
|
-
|
|
272
|
+
throw new Error(`Failed to save index: ${msg}`);
|
|
240
273
|
}
|
|
241
274
|
|
|
242
275
|
return ok(
|
|
@@ -257,16 +290,16 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
257
290
|
limit: Type.Optional(Type.Integer({ description: "Number of results to return. Default 8, max 25." })),
|
|
258
291
|
}),
|
|
259
292
|
promptSnippet: "Search the codebase by meaning",
|
|
260
|
-
async execute(_id, params) {
|
|
293
|
+
async execute(_id, params): Promise<AgentToolResult<undefined>> {
|
|
261
294
|
const cwdNow = getCwd();
|
|
262
295
|
const index = loadIndex(cwdNow);
|
|
263
296
|
if (!index) {
|
|
264
|
-
|
|
297
|
+
throw new Error("No semantic index found. Run semantic_index_build first.");
|
|
265
298
|
}
|
|
266
299
|
|
|
267
300
|
const config = getEmbedConfig();
|
|
268
301
|
if (index.model !== config.model) {
|
|
269
|
-
|
|
302
|
+
throw new Error(
|
|
270
303
|
`Index was built with model "${index.model}" but the current model is "${config.model}". Rebuild with semantic_index_build.`,
|
|
271
304
|
);
|
|
272
305
|
}
|
|
@@ -276,7 +309,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
276
309
|
[queryVector] = await embed(config, [params.query]);
|
|
277
310
|
} catch (error) {
|
|
278
311
|
const msg = error instanceof Error ? error.message : String(error);
|
|
279
|
-
|
|
312
|
+
throw new Error(`Failed to embed query: ${msg}`);
|
|
280
313
|
}
|
|
281
314
|
|
|
282
315
|
const limit = Math.min(Math.max(params.limit ?? 8, 1), 25);
|
package/package.json
CHANGED