@c3-oss/prosa 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/prosa.js +140 -123
- package/dist/bin/prosa.js.map +1 -1
- package/dist/cli/main.js +140 -123
- package/dist/cli/main.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -84,7 +84,8 @@ declare function getText(bundle: Bundle, objectId: ObjectId): Promise<string>;
|
|
|
84
84
|
declare function getJson<T = unknown>(bundle: Bundle, objectId: ObjectId): Promise<T>;
|
|
85
85
|
declare function getObjectMeta(bundle: Bundle, objectId: ObjectId): ObjectMeta | null;
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
declare const SOURCE_TOOLS: readonly ["cursor", "codex", "claude", "gemini"];
|
|
88
|
+
type SourceTool = (typeof SOURCE_TOOLS)[number];
|
|
88
89
|
type Confidence = 'high' | 'medium' | 'low';
|
|
89
90
|
type MessageRole = 'system_prompt' | 'developer' | 'user' | 'assistant' | 'tool' | 'operational';
|
|
90
91
|
type CanonicalToolType = 'shell' | 'read_file' | 'write_file' | 'edit_file' | 'search_file' | 'web_search' | 'mcp' | 'subagent' | 'patch' | 'other';
|
package/dist/index.js
CHANGED
|
@@ -1006,6 +1006,11 @@ async function fileExists(filePath) {
|
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
|
+
// src/core/limits.ts
|
|
1010
|
+
function clampLimit(value, opts) {
|
|
1011
|
+
return Math.max(opts.min ?? 1, Math.min(opts.max, value ?? opts.fallback));
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1009
1014
|
// src/services/sessions.ts
|
|
1010
1015
|
function sessionFilterWhere(filters) {
|
|
1011
1016
|
const conds = [];
|
|
@@ -1029,7 +1034,7 @@ function sessionFilterWhere(filters) {
|
|
|
1029
1034
|
}
|
|
1030
1035
|
function listSessions(bundle, filters = {}) {
|
|
1031
1036
|
const { where, params } = sessionFilterWhere(filters);
|
|
1032
|
-
const limit =
|
|
1037
|
+
const limit = clampLimit(filters.limit, { max: 1e3, fallback: 50 });
|
|
1033
1038
|
const sql = `
|
|
1034
1039
|
SELECT s.session_id,
|
|
1035
1040
|
s.source_tool,
|
|
@@ -1105,6 +1110,9 @@ function getSession(bundle, sessionId2) {
|
|
|
1105
1110
|
import { existsSync } from "fs";
|
|
1106
1111
|
import { createRequire } from "module";
|
|
1107
1112
|
|
|
1113
|
+
// src/core/errors.ts
|
|
1114
|
+
var getErrorMessage = (err) => err instanceof Error ? err.message : String(err);
|
|
1115
|
+
|
|
1108
1116
|
// src/services/indexing.ts
|
|
1109
1117
|
import { mkdir as mkdir3, rm, writeFile as writeFile4 } from "fs/promises";
|
|
1110
1118
|
import path4 from "path";
|
|
@@ -1203,7 +1211,7 @@ function rebuildFts5Index(bundle) {
|
|
|
1203
1211
|
status: "failed",
|
|
1204
1212
|
sourceDocCount: countSearchDocs(bundle),
|
|
1205
1213
|
indexedDocCount: countFts5Docs(bundle),
|
|
1206
|
-
errorMessage:
|
|
1214
|
+
errorMessage: getErrorMessage(error)
|
|
1207
1215
|
});
|
|
1208
1216
|
throw error;
|
|
1209
1217
|
}
|
|
@@ -1276,7 +1284,7 @@ async function rebuildTantivyIndex(bundle) {
|
|
|
1276
1284
|
status: "failed",
|
|
1277
1285
|
sourceDocCount: countSearchDocs(bundle),
|
|
1278
1286
|
indexedDocCount: 0,
|
|
1279
|
-
errorMessage:
|
|
1287
|
+
errorMessage: getErrorMessage(error)
|
|
1280
1288
|
});
|
|
1281
1289
|
throw error;
|
|
1282
1290
|
}
|
|
@@ -1329,7 +1337,7 @@ function searchFullText(bundle, options) {
|
|
|
1329
1337
|
if (options.engine === "tantivy") {
|
|
1330
1338
|
return searchTantivy(bundle, options);
|
|
1331
1339
|
}
|
|
1332
|
-
const limit =
|
|
1340
|
+
const limit = clampLimit(options.limit, { max: 500, fallback: 50 });
|
|
1333
1341
|
const sql = `
|
|
1334
1342
|
SELECT d.doc_id,
|
|
1335
1343
|
d.entity_type,
|
|
@@ -1360,7 +1368,7 @@ function searchTantivy(bundle, options) {
|
|
|
1360
1368
|
`tantivy index is ${status?.status ?? "missing"}; run \`prosa index tantivy\` first`
|
|
1361
1369
|
);
|
|
1362
1370
|
}
|
|
1363
|
-
const limit =
|
|
1371
|
+
const limit = clampLimit(options.limit, { max: 500, fallback: 50 });
|
|
1364
1372
|
const queryText = options.query.trim();
|
|
1365
1373
|
if (!queryText) return [];
|
|
1366
1374
|
const tantivy = requireTantivy();
|
|
@@ -1394,9 +1402,7 @@ function requireTantivy() {
|
|
|
1394
1402
|
try {
|
|
1395
1403
|
return require2("@oxdev03/node-tantivy-binding");
|
|
1396
1404
|
} catch (error) {
|
|
1397
|
-
throw new Error(
|
|
1398
|
-
`tantivy engine is unavailable: ${error instanceof Error ? error.message : String(error)}`
|
|
1399
|
-
);
|
|
1405
|
+
throw new Error(`tantivy engine is unavailable: ${getErrorMessage(error)}`);
|
|
1400
1406
|
}
|
|
1401
1407
|
}
|
|
1402
1408
|
function getStoredText(doc, field) {
|
|
@@ -1518,7 +1524,7 @@ async function compileClaude(bundle, root, options = {}) {
|
|
|
1518
1524
|
);
|
|
1519
1525
|
await recordError(bundle, batch.batch_id, {
|
|
1520
1526
|
kind: "claude_file_failed",
|
|
1521
|
-
message:
|
|
1527
|
+
message: getErrorMessage(error),
|
|
1522
1528
|
payload: { path: file.filePath }
|
|
1523
1529
|
});
|
|
1524
1530
|
}
|
|
@@ -2480,7 +2486,7 @@ async function compileCodex(bundle, root, options = {}) {
|
|
|
2480
2486
|
);
|
|
2481
2487
|
await recordError(bundle, batch.batch_id, {
|
|
2482
2488
|
kind: "codex_file_failed",
|
|
2483
|
-
message:
|
|
2489
|
+
message: getErrorMessage(error),
|
|
2484
2490
|
payload: { path: filePath }
|
|
2485
2491
|
});
|
|
2486
2492
|
}
|
|
@@ -3633,7 +3639,7 @@ async function compileCursor(bundle, root, options = {}) {
|
|
|
3633
3639
|
);
|
|
3634
3640
|
await recordError(bundle, batch.batch_id, {
|
|
3635
3641
|
kind: "cursor_store_failed",
|
|
3636
|
-
message:
|
|
3642
|
+
message: getErrorMessage(error),
|
|
3637
3643
|
payload: { path: store.filePath }
|
|
3638
3644
|
});
|
|
3639
3645
|
}
|
|
@@ -4356,7 +4362,7 @@ async function compileGemini(bundle, root, options = {}) {
|
|
|
4356
4362
|
);
|
|
4357
4363
|
await recordError(bundle, batch.batch_id, {
|
|
4358
4364
|
kind: "gemini_file_failed",
|
|
4359
|
-
message:
|
|
4365
|
+
message: getErrorMessage(error),
|
|
4360
4366
|
payload: { path: file.filePath }
|
|
4361
4367
|
});
|
|
4362
4368
|
}
|
|
@@ -5139,7 +5145,7 @@ async function attachSqlite(connection, dbPath) {
|
|
|
5139
5145
|
await connection.run(`ATTACH ${sqlString(dbPath)} AS prosa (TYPE sqlite)`);
|
|
5140
5146
|
} catch (error) {
|
|
5141
5147
|
throw new Error(
|
|
5142
|
-
`DuckDB could not attach prosa.sqlite via the sqlite extension: ${
|
|
5148
|
+
`DuckDB could not attach prosa.sqlite via the sqlite extension: ${getErrorMessage(error)}`
|
|
5143
5149
|
);
|
|
5144
5150
|
}
|
|
5145
5151
|
}
|
|
@@ -5170,7 +5176,7 @@ function sqlString(value) {
|
|
|
5170
5176
|
return `'${value.replace(/'/g, "''")}'`;
|
|
5171
5177
|
}
|
|
5172
5178
|
function isMissingParquetError(error) {
|
|
5173
|
-
const message =
|
|
5179
|
+
const message = getErrorMessage(error);
|
|
5174
5180
|
return /No files found|does not exist|not found/i.test(message) && /\.parquet/i.test(message);
|
|
5175
5181
|
}
|
|
5176
5182
|
|
|
@@ -5266,7 +5272,7 @@ async function runCompileImports(options) {
|
|
|
5266
5272
|
tantivy = { indexedDocCount: status.indexed_doc_count };
|
|
5267
5273
|
options.onTantivyComplete?.(tantivy);
|
|
5268
5274
|
} catch (error) {
|
|
5269
|
-
tantivyError =
|
|
5275
|
+
tantivyError = getErrorMessage(error);
|
|
5270
5276
|
logger?.error({ err: error }, "tantivy rebuild failed; SQLite data is intact");
|
|
5271
5277
|
}
|
|
5272
5278
|
}
|