dsh-spec-collab 0.3.1 → 0.4.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/CHANGELOG.md +14 -0
- package/README.md +11 -12
- package/lib/client.js +845 -624
- package/lib/index.js +61 -58
- package/lib/types/client/index.d.ts +2 -3
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/sidebar-anchor.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/review-runtime.d.ts +42 -3
- package/lib/types/review-runtime.d.ts.map +1 -1
- package/package.json +22 -16
- package/src/client/index.ts +2 -4
- package/src/client/sidebar-anchor.ts +2 -0
- package/src/index.ts +4 -4
- package/src/review-runtime.ts +63 -29
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
3
|
-
import Schema from "schemastery";
|
|
3
|
+
import Schema from "@deepseek-ai/schemastery";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { closeSync, copyFileSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
@@ -2452,31 +2452,25 @@ function errorMessage(error) {
|
|
|
2452
2452
|
}
|
|
2453
2453
|
//#endregion
|
|
2454
2454
|
//#region src/review-runtime.ts
|
|
2455
|
-
function request(payload) {
|
|
2456
|
-
return {
|
|
2457
|
-
rpcId: `spec-collab-${crypto.randomUUID()}`,
|
|
2458
|
-
payload
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
function failure(error) {
|
|
2462
|
-
return /* @__PURE__ */ new Error(`${error.code}: ${error.message}`);
|
|
2463
|
-
}
|
|
2464
2455
|
const FOLLOW_UP_METADATA = "\n\n<!-- dsh-spec-collab-follow-up:";
|
|
2465
2456
|
var DshReviewCoordinator = class {
|
|
2466
|
-
|
|
2457
|
+
host;
|
|
2467
2458
|
contexts;
|
|
2468
2459
|
prompts;
|
|
2469
2460
|
stageSessions = /* @__PURE__ */ new Map();
|
|
2470
|
-
|
|
2471
|
-
|
|
2461
|
+
lifetime = new AbortController();
|
|
2462
|
+
constructor(host, contexts = new ReviewContextCatalog(), prompts = {}) {
|
|
2463
|
+
this.host = host;
|
|
2472
2464
|
this.contexts = contexts;
|
|
2473
2465
|
this.prompts = resolveReviewPrompts(prompts);
|
|
2474
2466
|
}
|
|
2467
|
+
dispose() {
|
|
2468
|
+
this.lifetime.abort();
|
|
2469
|
+
this.stageSessions.clear();
|
|
2470
|
+
}
|
|
2475
2471
|
async reviewWorkspaces() {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
return listed.result.value.items.map((item) => ({
|
|
2479
|
-
workspaceId: item.workspaceId,
|
|
2472
|
+
return this.host.workspaceRegistry.list().map((item) => ({
|
|
2473
|
+
workspaceId: item.id,
|
|
2480
2474
|
title: item.title,
|
|
2481
2475
|
path: item.path
|
|
2482
2476
|
}));
|
|
@@ -2501,45 +2495,64 @@ var DshReviewCoordinator = class {
|
|
|
2501
2495
|
});
|
|
2502
2496
|
}
|
|
2503
2497
|
async conversation(sessionId) {
|
|
2504
|
-
const
|
|
2505
|
-
if (!history.result.ok) throw failure(history.result.error);
|
|
2498
|
+
const events = await this.conversationEvents(sessionId);
|
|
2506
2499
|
const rows = [];
|
|
2507
2500
|
let skippedOrchestrationPrompt = false;
|
|
2508
|
-
for (const entry of
|
|
2509
|
-
if (entry.
|
|
2510
|
-
if (entry.
|
|
2501
|
+
for (const entry of events) {
|
|
2502
|
+
if (entry.type !== "user/message" && entry.type !== "assistant/message") continue;
|
|
2503
|
+
if (entry.type === "user/message" && !skippedOrchestrationPrompt) {
|
|
2511
2504
|
skippedOrchestrationPrompt = true;
|
|
2512
2505
|
continue;
|
|
2513
2506
|
}
|
|
2514
|
-
const value = entry.
|
|
2507
|
+
const value = entry.data;
|
|
2515
2508
|
const message = isObject(value) && "message" in value ? value.message : value;
|
|
2516
2509
|
let messageText = collectText(isObject(message) && "content" in message ? message.content : message).join("\n").trim();
|
|
2517
|
-
if (entry.
|
|
2510
|
+
if (entry.type === "user/message") {
|
|
2518
2511
|
const followUp = storedFollowUp(messageText) ?? extractPromptValue(messageText, this.prompts.followUp.trim(), "CONTENT") ?? extractPromptValue(messageText, DEFAULT_REVIEW_PROMPTS.followUp, "CONTENT");
|
|
2519
2512
|
if (followUp === void 0) continue;
|
|
2520
2513
|
messageText = followUp.trim();
|
|
2521
2514
|
}
|
|
2522
2515
|
if (messageText !== "") rows.push({
|
|
2523
|
-
role: entry.
|
|
2516
|
+
role: entry.type === "user/message" ? "user" : "assistant",
|
|
2524
2517
|
text: messageText
|
|
2525
2518
|
});
|
|
2526
2519
|
}
|
|
2527
2520
|
return rows;
|
|
2528
2521
|
}
|
|
2522
|
+
async conversationEvents(sessionId) {
|
|
2523
|
+
const controller = this.host.sessionController;
|
|
2524
|
+
if (controller.events !== void 0) {
|
|
2525
|
+
const pages = [];
|
|
2526
|
+
let throughSeq;
|
|
2527
|
+
let beforeSeq;
|
|
2528
|
+
for (;;) {
|
|
2529
|
+
this.lifetime.signal.throwIfAborted();
|
|
2530
|
+
const page = await controller.events({
|
|
2531
|
+
address: {
|
|
2532
|
+
kind: "session",
|
|
2533
|
+
sessionId
|
|
2534
|
+
},
|
|
2535
|
+
maxMessages: 100,
|
|
2536
|
+
...throughSeq === void 0 ? {} : { throughSeq },
|
|
2537
|
+
...beforeSeq === void 0 ? {} : { beforeSeq }
|
|
2538
|
+
}, this.lifetime.signal);
|
|
2539
|
+
throughSeq ??= page.cursor;
|
|
2540
|
+
pages.push(page.records.map((record) => record.event));
|
|
2541
|
+
if (!page.hasMore) return pages.reverse().flat();
|
|
2542
|
+
const firstSeq = page.records[0]?.event.seq;
|
|
2543
|
+
if (firstSeq === void 0 || !Number.isSafeInteger(firstSeq) || firstSeq < 0 || beforeSeq !== void 0 && firstSeq >= beforeSeq) throw new Error("history pagination did not advance");
|
|
2544
|
+
beforeSeq = firstSeq;
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
if (controller.inspect !== void 0) return (await controller.inspect(sessionId, this.lifetime.signal)).events;
|
|
2548
|
+
throw new Error("DSH Session history API is unavailable");
|
|
2549
|
+
}
|
|
2529
2550
|
async followUp(sessionId, text) {
|
|
2530
2551
|
const content = text.trim();
|
|
2531
2552
|
if (content === "") throw new Error("追问内容不能为空");
|
|
2532
2553
|
const metadata = Buffer.from(content, "utf8").toString("base64url");
|
|
2533
2554
|
const promptText = `${renderPrompt(this.prompts.followUp, { CONTENT: content }).trim()}${FOLLOW_UP_METADATA}${metadata} -->`;
|
|
2534
|
-
|
|
2535
|
-
sessionId,
|
|
2536
|
-
mode: "queue",
|
|
2537
|
-
content: [{
|
|
2538
|
-
type: "text",
|
|
2539
|
-
text: promptText
|
|
2540
|
-
}]
|
|
2541
|
-
}));
|
|
2542
|
-
if (!prompted.result.ok) throw failure(prompted.result.error);
|
|
2555
|
+
await this.promptExisting(sessionId, promptText);
|
|
2543
2556
|
}
|
|
2544
2557
|
async inStageSession(requirement, existingSessionId, continuation, launch) {
|
|
2545
2558
|
const key = `${requirement.id}:${requirement.stage}:${requirement.stageCycle}`;
|
|
@@ -2573,43 +2586,30 @@ var DshReviewCoordinator = class {
|
|
|
2573
2586
|
}
|
|
2574
2587
|
}
|
|
2575
2588
|
async promptExisting(sessionId, promptText) {
|
|
2576
|
-
|
|
2589
|
+
await this.host.sessionController.prompt({
|
|
2590
|
+
requestId: `spec-collab-${crypto.randomUUID()}`,
|
|
2577
2591
|
sessionId,
|
|
2578
2592
|
mode: "queue",
|
|
2579
2593
|
content: [{
|
|
2580
2594
|
type: "text",
|
|
2581
2595
|
text: promptText
|
|
2582
2596
|
}]
|
|
2583
|
-
})
|
|
2584
|
-
if (!prompted.result.ok) throw failure(prompted.result.error);
|
|
2597
|
+
}, this.lifetime.signal);
|
|
2585
2598
|
}
|
|
2586
2599
|
async launch(title, promptText, workspaceId, agentPreset) {
|
|
2587
2600
|
if (agentPreset !== void 0) {
|
|
2588
|
-
const
|
|
2589
|
-
if (!presets.result.ok) throw failure(presets.result.error);
|
|
2590
|
-
const preset = presets.result.value.presets.find((item) => item.id === agentPreset);
|
|
2601
|
+
const preset = (await this.host.agentPresets.list()).find((item) => item.id === agentPreset);
|
|
2591
2602
|
if (preset === void 0 || preset.broken !== void 0) throw new Error("agent preset is unavailable");
|
|
2592
2603
|
}
|
|
2593
|
-
const
|
|
2604
|
+
const { sessionId } = await this.host.sessionController.create({
|
|
2594
2605
|
workspaceId,
|
|
2595
2606
|
...agentPreset === void 0 ? {} : { agentPreset }
|
|
2596
|
-
})
|
|
2597
|
-
|
|
2598
|
-
const sessionId = created.result.value.sessionId;
|
|
2599
|
-
const renamed = await this.api.sessions.rename(request({
|
|
2607
|
+
});
|
|
2608
|
+
await this.host.sessionController.rename({
|
|
2600
2609
|
sessionId,
|
|
2601
2610
|
title
|
|
2602
|
-
})
|
|
2603
|
-
|
|
2604
|
-
const prompted = await this.api.sessions.prompt(request({
|
|
2605
|
-
sessionId,
|
|
2606
|
-
mode: "queue",
|
|
2607
|
-
content: [{
|
|
2608
|
-
type: "text",
|
|
2609
|
-
text: promptText.replaceAll("{{SESSION_ID}}", sessionId)
|
|
2610
|
-
}]
|
|
2611
|
-
}));
|
|
2612
|
-
if (!prompted.result.ok) throw failure(prompted.result.error);
|
|
2611
|
+
});
|
|
2612
|
+
await this.promptExisting(sessionId, promptText.replaceAll("{{SESSION_ID}}", sessionId));
|
|
2613
2613
|
return sessionId;
|
|
2614
2614
|
}
|
|
2615
2615
|
async resolveWorkspace(workspaceId) {
|
|
@@ -3519,7 +3519,9 @@ function allSpecTools(engine) {
|
|
|
3519
3519
|
const name = "spec-collab";
|
|
3520
3520
|
const inject = [
|
|
3521
3521
|
"webServer",
|
|
3522
|
-
"
|
|
3522
|
+
"sessionController",
|
|
3523
|
+
"workspaceRegistry",
|
|
3524
|
+
"agentPresets",
|
|
3523
3525
|
"tools",
|
|
3524
3526
|
"systemPrompt"
|
|
3525
3527
|
];
|
|
@@ -3557,8 +3559,9 @@ function apply(ctx, config = {}) {
|
|
|
3557
3559
|
const contexts = new ReviewContextCatalog(config);
|
|
3558
3560
|
const prompts = resolveReviewPrompts(config.prompts);
|
|
3559
3561
|
const engine = new CollaborationEngine(join(dataRoot, "collaboration-v3.json"), new GitRequirementStore(config.repositoryPath ?? join(dataRoot, "repository")), { legacyPath: join(dataRoot, "collaboration-v2.json") });
|
|
3560
|
-
const coordinator = new DshReviewCoordinator(ctx
|
|
3562
|
+
const coordinator = new DshReviewCoordinator(ctx, contexts, prompts);
|
|
3561
3563
|
engine.setCoordinator(coordinator);
|
|
3564
|
+
ctx.effect(() => () => coordinator.dispose(), "spec-collab: review lifetime");
|
|
3562
3565
|
ctx.effect(() => {
|
|
3563
3566
|
const disposers = makeRoutes(engine, coordinator).map((route) => ctx.webServer.register(route));
|
|
3564
3567
|
return () => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare
|
|
3
|
-
export declare function apply(ctx: ClientContext): void;
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
export declare function apply(ctx: Context): void;
|
|
4
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CASxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-anchor.d.ts","sourceRoot":"","sources":["../../../src/client/sidebar-anchor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAA;CAC9B;AAMD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"sidebar-anchor.d.ts","sourceRoot":"","sources":["../../../src/client/sidebar-anchor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,iBAAiB,CAAA;IAC1B,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAA;CAC9B;AAMD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS,CAQ/E"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import Schema from 'schemastery';
|
|
2
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
3
3
|
import { DEFAULT_REVIEW_PROMPTS, resolveReviewPrompts, type ReviewPromptConfig } from './prompts.ts';
|
|
4
4
|
import { type ReviewContextConfig } from './review-context.ts';
|
|
5
5
|
export { DEFAULT_REVIEW_PROMPTS, resolveReviewPrompts };
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,MAAM,MAAM,0BAA0B,CAAA;AAM7C,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEpG,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAIpF,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,CAAA;AACvD,YAAY,EAAE,kBAAkB,EAAE,CAAA;AAElC,eAAO,MAAM,IAAI,gBAAgB,CAAA;AACjC,eAAO,MAAM,MAAM,UAAmG,CAAA;AACtH,MAAM,WAAW,MAAO,SAAQ,mBAAmB;IAAG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAAE;AAUhI,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,CAoBd,CAAA;AAEpB,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAc7D"}
|
|
@@ -1,14 +1,51 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SessionController, SessionPromptRequest } from '@deepseek-ai/dsh-api-session-controller';
|
|
2
|
+
import type { AgentPresetRegistry } from '@deepseek-ai/dsh-agent-preset-registry';
|
|
3
|
+
import type { WorkspaceRegistry } from '@deepseek-ai/dsh-workspace';
|
|
2
4
|
import type { AiCoordinator } from './engine.ts';
|
|
3
5
|
import type { AiReviewRun, CommentThread, RequirementView, ReviewWorkspaceSummary } from './protocol.ts';
|
|
4
6
|
import { type ReviewPromptConfig } from './prompts.ts';
|
|
5
7
|
import { ReviewContextCatalog } from './review-context.ts';
|
|
8
|
+
interface ReviewHistoryEvent {
|
|
9
|
+
type: string;
|
|
10
|
+
data: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface ReviewHistoryPage {
|
|
13
|
+
cursor: number;
|
|
14
|
+
records: readonly {
|
|
15
|
+
type: 'event';
|
|
16
|
+
event: ReviewHistoryEvent & {
|
|
17
|
+
seq: number;
|
|
18
|
+
};
|
|
19
|
+
}[];
|
|
20
|
+
hasMore: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ReviewHistoryReader {
|
|
23
|
+
events?(request: {
|
|
24
|
+
address: {
|
|
25
|
+
kind: 'session';
|
|
26
|
+
sessionId: SessionPromptRequest['sessionId'];
|
|
27
|
+
};
|
|
28
|
+
maxMessages: number;
|
|
29
|
+
throughSeq?: number;
|
|
30
|
+
beforeSeq?: number;
|
|
31
|
+
}, signal: AbortSignal): Promise<ReviewHistoryPage>;
|
|
32
|
+
inspect?(sessionId: SessionPromptRequest['sessionId'], signal: AbortSignal): Promise<{
|
|
33
|
+
events: readonly ReviewHistoryEvent[];
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export interface DshReviewHost {
|
|
37
|
+
sessionController: Pick<SessionController, 'create' | 'rename' | 'prompt'> & ReviewHistoryReader;
|
|
38
|
+
workspaceRegistry: Pick<WorkspaceRegistry, 'list'>;
|
|
39
|
+
agentPresets: Pick<AgentPresetRegistry, 'list'>;
|
|
40
|
+
}
|
|
6
41
|
export declare class DshReviewCoordinator implements AiCoordinator {
|
|
7
|
-
private readonly
|
|
42
|
+
private readonly host;
|
|
8
43
|
private readonly contexts;
|
|
9
44
|
private readonly prompts;
|
|
10
45
|
private readonly stageSessions;
|
|
11
|
-
|
|
46
|
+
private readonly lifetime;
|
|
47
|
+
constructor(host: DshReviewHost, contexts?: ReviewContextCatalog, prompts?: ReviewPromptConfig);
|
|
48
|
+
dispose(): void;
|
|
12
49
|
reviewWorkspaces(): Promise<ReviewWorkspaceSummary[]>;
|
|
13
50
|
assertWorkspaceAvailable(workspaceId: string): Promise<void>;
|
|
14
51
|
requestReview(input: {
|
|
@@ -25,6 +62,7 @@ export declare class DshReviewCoordinator implements AiCoordinator {
|
|
|
25
62
|
role: 'user' | 'assistant';
|
|
26
63
|
text: string;
|
|
27
64
|
}>>;
|
|
65
|
+
private conversationEvents;
|
|
28
66
|
followUp(sessionId: string, text: string): Promise<void>;
|
|
29
67
|
private inStageSession;
|
|
30
68
|
private rememberStageSession;
|
|
@@ -32,4 +70,5 @@ export declare class DshReviewCoordinator implements AiCoordinator {
|
|
|
32
70
|
private launch;
|
|
33
71
|
private resolveWorkspace;
|
|
34
72
|
}
|
|
73
|
+
export {};
|
|
35
74
|
//# sourceMappingURL=review-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"review-runtime.d.ts","sourceRoot":"","sources":["../../src/review-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"review-runtime.d.ts","sourceRoot":"","sources":["../../src/review-runtime.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-spec-collab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "AI-assisted requirement clarification and Git-backed Spec co-creation for DeepSeek Harness, ending at a human-confirmed Ready Spec.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -36,10 +36,6 @@
|
|
|
36
36
|
"patch": "./cordis.patch.yml"
|
|
37
37
|
},
|
|
38
38
|
"client": {
|
|
39
|
-
"inject": [
|
|
40
|
-
"@deepseek-ai/dsh-client-runtime",
|
|
41
|
-
"@deepseek-ai/dsh-client-connection"
|
|
42
|
-
],
|
|
43
39
|
"platform": "web"
|
|
44
40
|
}
|
|
45
41
|
},
|
|
@@ -70,37 +66,47 @@
|
|
|
70
66
|
"lightningcss": "^1.32.0",
|
|
71
67
|
"markdown-it": "^14.1.0",
|
|
72
68
|
"prosemirror-inputrules": "^1.5.0",
|
|
73
|
-
"schemastery": "
|
|
69
|
+
"@deepseek-ai/schemastery": "~3.18.5 || ~3.19.0"
|
|
74
70
|
},
|
|
75
71
|
"devDependencies": {
|
|
76
72
|
"@axe-core/playwright": "^4.10.0",
|
|
77
|
-
"@deepseek-ai/cordis": "
|
|
78
|
-
"@deepseek-ai/dsh-
|
|
79
|
-
"@deepseek-ai/dsh-
|
|
80
|
-
"@deepseek-ai/dsh-
|
|
81
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
82
|
-
"@deepseek-ai/dsh-llm": "
|
|
83
|
-
"@deepseek-ai/dsh-system-prompt": "
|
|
84
|
-
"@deepseek-ai/dsh-tools": "
|
|
73
|
+
"@deepseek-ai/cordis": "~4.1.0",
|
|
74
|
+
"@deepseek-ai/dsh-agent-preset-registry": "0.2.2-rc.1",
|
|
75
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.1",
|
|
76
|
+
"@deepseek-ai/dsh-app-boot": "0.2.2-rc.1",
|
|
77
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.1",
|
|
78
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
|
|
79
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-workspace": "0.2.2-rc.1",
|
|
85
82
|
"@playwright/test": "^1.55.0",
|
|
86
83
|
"@types/markdown-it": "^14.1.2",
|
|
87
84
|
"@types/node": "^22.20.0",
|
|
88
85
|
"@types/react": "~18.3.1",
|
|
89
86
|
"@types/react-dom": "^18.3.5",
|
|
87
|
+
"@types/semver": "^7.7.1",
|
|
90
88
|
"jsdom": "^25.0.0",
|
|
91
89
|
"react": "^18.3.1",
|
|
92
90
|
"react-dom": "^18.3.1",
|
|
91
|
+
"semver": "^7.8.5",
|
|
93
92
|
"tsdown": "0.22.2",
|
|
94
93
|
"typescript": "~5.7.2",
|
|
95
94
|
"vitest": "^3.0.0"
|
|
96
95
|
},
|
|
97
96
|
"peerDependencies": {
|
|
98
|
-
"@deepseek-ai/
|
|
97
|
+
"@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
|
|
98
|
+
"@deepseek-ai/dsh-agent-preset-registry": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
99
|
+
"@deepseek-ai/dsh-api-session-controller": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
100
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
101
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
102
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
103
|
+
"@deepseek-ai/dsh-workspace": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0",
|
|
99
104
|
"react": "^18.2.0",
|
|
100
105
|
"react-dom": "^18.2.0"
|
|
101
106
|
},
|
|
102
107
|
"engines": {
|
|
103
|
-
"node": ">=20"
|
|
108
|
+
"node": ">=20",
|
|
109
|
+
"dsh": ">=0.2.1-rc.5 <0.2.2-0 || >=0.2.2-rc.1 <0.2.3-0"
|
|
104
110
|
},
|
|
105
111
|
"packageManager": "pnpm@9.9.0",
|
|
106
112
|
"license": "Apache-2.0"
|
package/src/client/index.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
2
2
|
import { SpecApi } from './api.ts'
|
|
3
3
|
import { mountSidebarEntry, mountWorkbench } from './mount.tsx'
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
export function apply(ctx: ClientContext): void {
|
|
5
|
+
export function apply(ctx: Context): void {
|
|
8
6
|
const api = new SpecApi()
|
|
9
7
|
const disposers: Array<() => void> = []
|
|
10
8
|
try {
|
|
@@ -10,6 +10,8 @@ function exactTextButton(document: Document, text: string): HTMLButtonElement |
|
|
|
10
10
|
export function findSidebarAnchor(document: Document): SidebarAnchor | undefined {
|
|
11
11
|
const skillCenter = document.querySelector<HTMLButtonElement>('button[aria-label="技能中心"]') ?? exactTextButton(document, '技能中心')
|
|
12
12
|
if (skillCenter !== undefined && skillCenter !== null) return { element: skillCenter, placement: 'after' }
|
|
13
|
+
const plugins = document.querySelector<HTMLButtonElement>('button[aria-label="插件"], button[aria-label="Plugins"]') ?? exactTextButton(document, '插件') ?? exactTextButton(document, 'Plugins')
|
|
14
|
+
if (plugins !== undefined && plugins !== null) return { element: plugins, placement: 'after' }
|
|
13
15
|
const settings = document.querySelector<HTMLButtonElement>('button[aria-label="设置"]') ?? exactTextButton(document, '设置')
|
|
14
16
|
if (settings !== undefined && settings !== null) return { element: settings, placement: 'before' }
|
|
15
17
|
return undefined
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { homedir } from 'node:os'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import type { Context } from '@deepseek-ai/cordis'
|
|
4
|
-
import Schema from 'schemastery'
|
|
5
|
-
import type {} from '@deepseek-ai/dsh-host-apiproxy'
|
|
4
|
+
import Schema from '@deepseek-ai/schemastery'
|
|
6
5
|
import type {} from '@deepseek-ai/dsh-host-webserver'
|
|
7
6
|
import type {} from '@deepseek-ai/dsh-system-prompt'
|
|
8
7
|
import type {} from '@deepseek-ai/dsh-tools'
|
|
@@ -18,7 +17,7 @@ export { DEFAULT_REVIEW_PROMPTS, resolveReviewPrompts }
|
|
|
18
17
|
export type { ReviewPromptConfig }
|
|
19
18
|
|
|
20
19
|
export const name = 'spec-collab'
|
|
21
|
-
export const inject = ['webServer', '
|
|
20
|
+
export const inject = ['webServer', 'sessionController', 'workspaceRegistry', 'agentPresets', 'tools', 'systemPrompt']
|
|
22
21
|
export interface Config extends ReviewContextConfig { dataRoot?: string; repositoryPath?: string; prompts?: ReviewPromptConfig }
|
|
23
22
|
|
|
24
23
|
const stringList = () => Schema.array(Schema.string()).default([])
|
|
@@ -56,8 +55,9 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
56
55
|
const contexts = new ReviewContextCatalog(config)
|
|
57
56
|
const prompts = resolveReviewPrompts(config.prompts)
|
|
58
57
|
const engine = new CollaborationEngine(join(dataRoot, 'collaboration-v3.json'), new GitRequirementStore(config.repositoryPath ?? join(dataRoot, 'repository')), { legacyPath: join(dataRoot, 'collaboration-v2.json') })
|
|
59
|
-
const coordinator = new DshReviewCoordinator(ctx
|
|
58
|
+
const coordinator = new DshReviewCoordinator(ctx, contexts, prompts)
|
|
60
59
|
engine.setCoordinator(coordinator)
|
|
60
|
+
ctx.effect(() => () => coordinator.dispose(), 'spec-collab: review lifetime')
|
|
61
61
|
ctx.effect(() => { const disposers = makeRoutes(engine, coordinator).map(route => ctx.webServer.register(route)); return () => { for (const dispose of disposers) dispose() } }, 'spec-collab: routes')
|
|
62
62
|
ctx.effect(() => { const disposers = allSpecTools(engine).map(tool => ctx.tools.register(tool)); return () => { for (const dispose of disposers) dispose() } }, 'spec-collab: tools')
|
|
63
63
|
ctx.effect(() => ctx.systemPrompt.section({
|
package/src/review-runtime.ts
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SessionController, SessionPromptRequest } from '@deepseek-ai/dsh-api-session-controller'
|
|
2
|
+
import type { AgentPresetRegistry } from '@deepseek-ai/dsh-agent-preset-registry'
|
|
3
|
+
import type { WorkspaceId, WorkspaceRegistry } from '@deepseek-ai/dsh-workspace'
|
|
2
4
|
import type { AiCoordinator } from './engine.ts'
|
|
3
5
|
import type { AiReviewRun, CommentThread, RequirementView, ReviewWorkspaceSummary } from './protocol.ts'
|
|
4
6
|
import { DEFAULT_REVIEW_PROMPTS, extractPromptValue, renderPrompt, resolveReviewPrompts, type ResolvedReviewPrompts, type ReviewPromptConfig } from './prompts.ts'
|
|
5
7
|
import { ReviewContextCatalog, reviewContextPrompt } from './review-context.ts'
|
|
6
8
|
import { readWorkspaceSnapshot } from './workspace-context.ts'
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
interface ReviewHistoryEvent { type: string; data: unknown }
|
|
11
|
+
interface ReviewHistoryPage {
|
|
12
|
+
cursor: number
|
|
13
|
+
records: readonly { type: 'event'; event: ReviewHistoryEvent & { seq: number } }[]
|
|
14
|
+
hasMore: boolean
|
|
15
|
+
}
|
|
16
|
+
interface ReviewHistoryReader {
|
|
17
|
+
events?(request: { address: { kind: 'session'; sessionId: SessionPromptRequest['sessionId'] }; maxMessages: number; throughSeq?: number; beforeSeq?: number }, signal: AbortSignal): Promise<ReviewHistoryPage>
|
|
18
|
+
inspect?(sessionId: SessionPromptRequest['sessionId'], signal: AbortSignal): Promise<{ events: readonly ReviewHistoryEvent[] }>
|
|
19
|
+
}
|
|
20
|
+
export interface DshReviewHost {
|
|
21
|
+
sessionController: Pick<SessionController, 'create' | 'rename' | 'prompt'> & ReviewHistoryReader
|
|
22
|
+
workspaceRegistry: Pick<WorkspaceRegistry, 'list'>
|
|
23
|
+
agentPresets: Pick<AgentPresetRegistry, 'list'>
|
|
24
|
+
}
|
|
10
25
|
const FOLLOW_UP_METADATA = '\n\n<!-- dsh-spec-collab-follow-up:'
|
|
11
26
|
|
|
12
27
|
export class DshReviewCoordinator implements AiCoordinator {
|
|
13
28
|
private readonly prompts: ResolvedReviewPrompts
|
|
14
29
|
private readonly stageSessions = new Map<string, Promise<string>>()
|
|
15
|
-
|
|
30
|
+
private readonly lifetime = new AbortController()
|
|
31
|
+
constructor(private readonly host: DshReviewHost, private readonly contexts = new ReviewContextCatalog(), prompts: ReviewPromptConfig = {}) {
|
|
16
32
|
this.prompts = resolveReviewPrompts(prompts)
|
|
17
33
|
}
|
|
34
|
+
dispose(): void { this.lifetime.abort(); this.stageSessions.clear() }
|
|
18
35
|
async reviewWorkspaces(): Promise<ReviewWorkspaceSummary[]> {
|
|
19
|
-
|
|
20
|
-
if (!listed.result.ok) throw failure(listed.result.error)
|
|
21
|
-
return listed.result.value.items.map(item => ({ workspaceId: item.workspaceId, title: item.title, path: item.path }))
|
|
36
|
+
return this.host.workspaceRegistry.list().map(item => ({ workspaceId: item.id, title: item.title, path: item.path }))
|
|
22
37
|
}
|
|
23
38
|
async assertWorkspaceAvailable(workspaceId: string): Promise<void> {
|
|
24
39
|
await this.resolveWorkspace(workspaceId)
|
|
@@ -40,35 +55,57 @@ export class DshReviewCoordinator implements AiCoordinator {
|
|
|
40
55
|
})
|
|
41
56
|
}
|
|
42
57
|
async conversation(sessionId: string): Promise<Array<{ role: 'user' | 'assistant'; text: string }>> {
|
|
43
|
-
const
|
|
44
|
-
if (!history.result.ok) throw failure(history.result.error)
|
|
58
|
+
const events = await this.conversationEvents(sessionId as SessionPromptRequest['sessionId'])
|
|
45
59
|
const rows: Array<{ role: 'user' | 'assistant'; text: string }> = []
|
|
46
60
|
let skippedOrchestrationPrompt = false
|
|
47
|
-
for (const entry of
|
|
48
|
-
if (entry.
|
|
49
|
-
if (entry.
|
|
50
|
-
const value = entry.
|
|
61
|
+
for (const entry of events) {
|
|
62
|
+
if (entry.type !== 'user/message' && entry.type !== 'assistant/message') continue
|
|
63
|
+
if (entry.type === 'user/message' && !skippedOrchestrationPrompt) { skippedOrchestrationPrompt = true; continue }
|
|
64
|
+
const value = entry.data as unknown
|
|
51
65
|
const message = isObject(value) && 'message' in value ? value.message : value
|
|
52
66
|
const content = isObject(message) && 'content' in message ? message.content : message
|
|
53
67
|
let messageText = collectText(content).join('\n').trim()
|
|
54
|
-
if (entry.
|
|
68
|
+
if (entry.type === 'user/message') {
|
|
55
69
|
const followUp = storedFollowUp(messageText)
|
|
56
70
|
?? extractPromptValue(messageText, this.prompts.followUp.trim(), 'CONTENT')
|
|
57
71
|
?? extractPromptValue(messageText, DEFAULT_REVIEW_PROMPTS.followUp, 'CONTENT')
|
|
58
72
|
if (followUp === undefined) continue
|
|
59
73
|
messageText = followUp.trim()
|
|
60
74
|
}
|
|
61
|
-
if (messageText !== '') rows.push({ role: entry.
|
|
75
|
+
if (messageText !== '') rows.push({ role: entry.type === 'user/message' ? 'user' : 'assistant', text: messageText })
|
|
62
76
|
}
|
|
63
77
|
return rows
|
|
64
78
|
}
|
|
79
|
+
private async conversationEvents(sessionId: SessionPromptRequest['sessionId']): Promise<readonly ReviewHistoryEvent[]> {
|
|
80
|
+
const controller = this.host.sessionController
|
|
81
|
+
if (controller.events !== undefined) {
|
|
82
|
+
const pages: ReviewHistoryEvent[][] = []
|
|
83
|
+
let throughSeq: number | undefined
|
|
84
|
+
let beforeSeq: number | undefined
|
|
85
|
+
for (;;) {
|
|
86
|
+
this.lifetime.signal.throwIfAborted()
|
|
87
|
+
const page = await controller.events({
|
|
88
|
+
address: { kind: 'session', sessionId }, maxMessages: 100,
|
|
89
|
+
...(throughSeq === undefined ? {} : { throughSeq }),
|
|
90
|
+
...(beforeSeq === undefined ? {} : { beforeSeq }),
|
|
91
|
+
}, this.lifetime.signal)
|
|
92
|
+
throughSeq ??= page.cursor
|
|
93
|
+
pages.push(page.records.map(record => record.event))
|
|
94
|
+
if (!page.hasMore) return pages.reverse().flat()
|
|
95
|
+
const firstSeq = page.records[0]?.event.seq
|
|
96
|
+
if (firstSeq === undefined || !Number.isSafeInteger(firstSeq) || firstSeq < 0 || (beforeSeq !== undefined && firstSeq >= beforeSeq)) throw new Error('history pagination did not advance')
|
|
97
|
+
beforeSeq = firstSeq
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (controller.inspect !== undefined) return (await controller.inspect(sessionId, this.lifetime.signal)).events
|
|
101
|
+
throw new Error('DSH Session history API is unavailable')
|
|
102
|
+
}
|
|
65
103
|
async followUp(sessionId: string, text: string): Promise<void> {
|
|
66
104
|
const content = text.trim()
|
|
67
105
|
if (content === '') throw new Error('追问内容不能为空')
|
|
68
106
|
const metadata = Buffer.from(content, 'utf8').toString('base64url')
|
|
69
107
|
const promptText = `${renderPrompt(this.prompts.followUp, { CONTENT: content }).trim()}${FOLLOW_UP_METADATA}${metadata} -->`
|
|
70
|
-
|
|
71
|
-
if (!prompted.result.ok) throw failure(prompted.result.error)
|
|
108
|
+
await this.promptExisting(sessionId, promptText)
|
|
72
109
|
}
|
|
73
110
|
private async inStageSession(requirement: RequirementView, existingSessionId: string | undefined, continuation: string, launch: () => Promise<string>): Promise<string> {
|
|
74
111
|
const key = `${requirement.id}:${requirement.stage}:${requirement.stageCycle}`
|
|
@@ -83,23 +120,20 @@ export class DshReviewCoordinator implements AiCoordinator {
|
|
|
83
120
|
}
|
|
84
121
|
private rememberStageSession(key: string, session: Promise<string>): void { this.stageSessions.delete(key); this.stageSessions.set(key, session); while (this.stageSessions.size > 100) { const oldest = this.stageSessions.keys().next().value as string | undefined; if (oldest === undefined) break; this.stageSessions.delete(oldest) } }
|
|
85
122
|
private async promptExisting(sessionId: string, promptText: string): Promise<void> {
|
|
86
|
-
|
|
87
|
-
|
|
123
|
+
await this.host.sessionController.prompt({
|
|
124
|
+
requestId: `spec-collab-${crypto.randomUUID()}` as SessionPromptRequest['requestId'],
|
|
125
|
+
sessionId: sessionId as SessionPromptRequest['sessionId'],
|
|
126
|
+
mode: 'queue', content: [{ type: 'text', text: promptText }],
|
|
127
|
+
}, this.lifetime.signal)
|
|
88
128
|
}
|
|
89
129
|
private async launch(title: string, promptText: string, workspaceId: string, agentPreset?: string): Promise<string> {
|
|
90
130
|
if (agentPreset !== undefined) {
|
|
91
|
-
const
|
|
92
|
-
if (!presets.result.ok) throw failure(presets.result.error)
|
|
93
|
-
const preset = presets.result.value.presets.find(item => item.id === agentPreset)
|
|
131
|
+
const preset = (await this.host.agentPresets.list()).find(item => item.id === agentPreset)
|
|
94
132
|
if (preset === undefined || preset.broken !== undefined) throw new Error('agent preset is unavailable')
|
|
95
133
|
}
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const renamed = await this.api.sessions.rename(request({ sessionId, title }))
|
|
100
|
-
if (!renamed.result.ok) throw failure(renamed.result.error)
|
|
101
|
-
const prompted = await this.api.sessions.prompt(request({ sessionId, mode: 'queue' as const, content: [{ type: 'text' as const, text: promptText.replaceAll('{{SESSION_ID}}', sessionId) }] }))
|
|
102
|
-
if (!prompted.result.ok) throw failure(prompted.result.error)
|
|
134
|
+
const { sessionId } = await this.host.sessionController.create({ workspaceId: workspaceId as WorkspaceId, ...(agentPreset === undefined ? {} : { agentPreset }) })
|
|
135
|
+
await this.host.sessionController.rename({ sessionId, title })
|
|
136
|
+
await this.promptExisting(sessionId, promptText.replaceAll('{{SESSION_ID}}', sessionId))
|
|
103
137
|
return sessionId
|
|
104
138
|
}
|
|
105
139
|
private async resolveWorkspace(workspaceId: string): Promise<ReviewWorkspaceSummary> {
|