dsh-deeptutor 0.1.5 → 0.1.6
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/lib/index.js +29 -14
- package/package.json +1 -1
- package/src/index.ts +28 -13
package/lib/index.js
CHANGED
|
@@ -158,7 +158,7 @@ export function apply(ctx) {
|
|
|
158
158
|
},
|
|
159
159
|
top_k: {
|
|
160
160
|
type: "number",
|
|
161
|
-
description: "Number of hits to return, default 5",
|
|
161
|
+
description: "Number of hits to return, default 5 (applied locally to the CLI search result; the deeptutor CLI has no --top-k flag)",
|
|
162
162
|
},
|
|
163
163
|
max_chars: {
|
|
164
164
|
type: "number",
|
|
@@ -215,7 +215,8 @@ export function apply(ctx) {
|
|
|
215
215
|
console.log(`[deeptutor] kb ${args.action} HTTP failed, falling back to CLI: ${err?.message}`);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
// CLI fallback (local or SSH)
|
|
218
|
+
// CLI fallback (local or SSH). NOTE: `kb search` has no --top-k flag
|
|
219
|
+
// (verified on deeptutor CLI 1.5.x); top_k is applied locally below.
|
|
219
220
|
let argv;
|
|
220
221
|
if (args.action === "list") {
|
|
221
222
|
argv = ["kb", "list", "--format", "json"];
|
|
@@ -234,8 +235,6 @@ export function apply(ctx) {
|
|
|
234
235
|
"--mode",
|
|
235
236
|
args.mode ?? "hybrid",
|
|
236
237
|
];
|
|
237
|
-
if (args.top_k)
|
|
238
|
-
argv.push("--top-k", String(args.top_k));
|
|
239
238
|
}
|
|
240
239
|
const { stdout, stderr, code, killed } = await runCli(argv, {
|
|
241
240
|
signal: exec.signal,
|
|
@@ -250,16 +249,32 @@ export function apply(ctx) {
|
|
|
250
249
|
let body = stdout.trim() || "(empty result)";
|
|
251
250
|
if (args.action === "search") {
|
|
252
251
|
try {
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
252
|
+
const parsed = JSON.parse(stdout);
|
|
253
|
+
const fmtHit = (s, i) => {
|
|
254
|
+
const text = s.text ?? s.content ?? s.snippet ?? JSON.stringify(s);
|
|
255
|
+
const src = s.source ?? s.doc_name ?? s.file ?? "";
|
|
256
|
+
const title = s.title ? ` title: ${s.title}` : "";
|
|
257
|
+
const score = typeof s.score === "number" ? ` score: ${s.score}` : "";
|
|
258
|
+
return `[${i + 1}]${src ? ` source: ${src}` : ""}${title}${score}\n${typeof text === "string" ? text : JSON.stringify(text)}`;
|
|
259
|
+
};
|
|
260
|
+
// Current deeptutor CLI (1.5.x) returns an object
|
|
261
|
+
// { query, answer, content, sources, provider }; older builds
|
|
262
|
+
// returned a bare array of hits. Accept both.
|
|
263
|
+
if (Array.isArray(parsed)) {
|
|
264
|
+
const hits = args.top_k ? parsed.slice(0, args.top_k) : parsed;
|
|
265
|
+
body = `${hits.length} hits:\n\n` + hits.map(fmtHit).join("\n\n");
|
|
266
|
+
}
|
|
267
|
+
else if (parsed && typeof parsed === "object") {
|
|
268
|
+
const parts = [];
|
|
269
|
+
if (parsed.query)
|
|
270
|
+
parts.push(`Query: ${parsed.query}`);
|
|
271
|
+
if (typeof parsed.answer === "string" && parsed.answer.trim())
|
|
272
|
+
parts.push(`Answer: ${parsed.answer.trim()}`);
|
|
273
|
+
const sources = Array.isArray(parsed.sources) ? parsed.sources : [];
|
|
274
|
+
const hits = args.top_k ? sources.slice(0, args.top_k) : sources;
|
|
275
|
+
parts.push(`${hits.length} hits:`);
|
|
276
|
+
parts.push(hits.map(fmtHit).join("\n\n"));
|
|
277
|
+
body = parts.join("\n\n");
|
|
263
278
|
}
|
|
264
279
|
}
|
|
265
280
|
catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-deeptutor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "DeepTutor bridge bundle for DeepSeek Harness: learning capabilities, knowledge bases, and note archiving (HTTP/WS first, CLI fallback; auto-adapts local/remote deployment).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
package/src/index.ts
CHANGED
|
@@ -200,7 +200,8 @@ export function apply(ctx: Context) {
|
|
|
200
200
|
},
|
|
201
201
|
top_k: {
|
|
202
202
|
type: "number",
|
|
203
|
-
description:
|
|
203
|
+
description:
|
|
204
|
+
"Number of hits to return, default 5 (applied locally to the CLI search result; the deeptutor CLI has no --top-k flag)",
|
|
204
205
|
},
|
|
205
206
|
max_chars: {
|
|
206
207
|
type: "number",
|
|
@@ -267,7 +268,8 @@ export function apply(ctx: Context) {
|
|
|
267
268
|
);
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
// CLI fallback (local or SSH)
|
|
271
|
+
// CLI fallback (local or SSH). NOTE: `kb search` has no --top-k flag
|
|
272
|
+
// (verified on deeptutor CLI 1.5.x); top_k is applied locally below.
|
|
271
273
|
let argv: string[];
|
|
272
274
|
if (args.action === "list") {
|
|
273
275
|
argv = ["kb", "list", "--format", "json"];
|
|
@@ -284,7 +286,6 @@ export function apply(ctx: Context) {
|
|
|
284
286
|
"--mode",
|
|
285
287
|
args.mode ?? "hybrid",
|
|
286
288
|
];
|
|
287
|
-
if (args.top_k) argv.push("--top-k", String(args.top_k));
|
|
288
289
|
}
|
|
289
290
|
const { stdout, stderr, code, killed } = await runCli(argv, {
|
|
290
291
|
signal: exec.signal,
|
|
@@ -300,16 +301,30 @@ export function apply(ctx: Context) {
|
|
|
300
301
|
let body = stdout.trim() || "(empty result)";
|
|
301
302
|
if (args.action === "search") {
|
|
302
303
|
try {
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
const parsed = JSON.parse(stdout);
|
|
305
|
+
const fmtHit = (s: any, i: number) => {
|
|
306
|
+
const text = s.text ?? s.content ?? s.snippet ?? JSON.stringify(s);
|
|
307
|
+
const src = s.source ?? s.doc_name ?? s.file ?? "";
|
|
308
|
+
const title = s.title ? ` title: ${s.title}` : "";
|
|
309
|
+
const score = typeof s.score === "number" ? ` score: ${s.score}` : "";
|
|
310
|
+
return `[${i + 1}]${src ? ` source: ${src}` : ""}${title}${score}\n${typeof text === "string" ? text : JSON.stringify(text)}`;
|
|
311
|
+
};
|
|
312
|
+
// Current deeptutor CLI (1.5.x) returns an object
|
|
313
|
+
// { query, answer, content, sources, provider }; older builds
|
|
314
|
+
// returned a bare array of hits. Accept both.
|
|
315
|
+
if (Array.isArray(parsed)) {
|
|
316
|
+
const hits = args.top_k ? parsed.slice(0, args.top_k) : parsed;
|
|
317
|
+
body = `${hits.length} hits:\n\n` + hits.map(fmtHit).join("\n\n");
|
|
318
|
+
} else if (parsed && typeof parsed === "object") {
|
|
319
|
+
const parts: string[] = [];
|
|
320
|
+
if (parsed.query) parts.push(`Query: ${parsed.query}`);
|
|
321
|
+
if (typeof parsed.answer === "string" && parsed.answer.trim())
|
|
322
|
+
parts.push(`Answer: ${parsed.answer.trim()}`);
|
|
323
|
+
const sources = Array.isArray(parsed.sources) ? parsed.sources : [];
|
|
324
|
+
const hits = args.top_k ? sources.slice(0, args.top_k) : sources;
|
|
325
|
+
parts.push(`${hits.length} hits:`);
|
|
326
|
+
parts.push(hits.map(fmtHit).join("\n\n"));
|
|
327
|
+
body = parts.join("\n\n");
|
|
313
328
|
}
|
|
314
329
|
} catch {
|
|
315
330
|
/* non-JSON output returned as-is */
|