Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"onCommand:deepseekHarness.fixWithDeepSeek",
"onCommand:deepseekHarness.sendProblem",
"onCommand:deepseekHarness.restart",
"onCommand:deepseekHarness.reconnect",
"onCommand:deepseekHarness.connectExistingRuntime",
"onCommand:deepseekHarness.startManagedRuntime",
"onCommand:deepseekHarness.managePlugins",
"onCommand:deepseekHarness.configureApiKey",
"onCommand:deepseekHarness.clearApiKey"
Expand Down Expand Up @@ -86,9 +89,21 @@
},
{
"command": "deepseekHarness.restart",
"title": "DeepSeek Harness: Reconnect / Restart Runtime",
"title": "DeepSeek Harness: Restart Runtime",
"icon": "$(debug-restart)"
},
{
"command": "deepseekHarness.reconnect",
"title": "DeepSeek Harness: Reconnect"
},
{
"command": "deepseekHarness.connectExistingRuntime",
"title": "DeepSeek Harness: Connect to Existing Runtime"
},
{
"command": "deepseekHarness.startManagedRuntime",
"title": "DeepSeek Harness: Start Managed Runtime"
},
{
"command": "deepseekHarness.managePlugins",
"title": "DeepSeek Harness: Manage Runtime Plugins",
Expand Down Expand Up @@ -199,7 +214,7 @@
"type": "boolean",
"scope": "resource",
"default": true,
"description": "Reuse a healthy official DSH Web runtime on 127.0.0.1:3080 when no custom executable or arguments are configured."
"description": "Look for an existing DSH Web runtime on 127.0.0.1:3080 when no custom executable or arguments are configured. Authenticated runtimes prompt you to connect with their launch URL or start a separate managed runtime."
},
"deepseekHarness.autonomousDebugging": {
"type": "boolean",
Expand Down Expand Up @@ -228,17 +243,20 @@
"publish:marketplace": "vsce publish --readme-path README.marketplace.md"
},
"devDependencies": {
"@modelcontextprotocol/sdk": "1.30.0",
"@types/node": "^22.20.0",
"@types/vscode": "^1.100.0",
"@types/ws": "^8.18.1",
"@vscode/vsce": "^3.6.0",
"@modelcontextprotocol/sdk": "1.30.0",
"diff": "^9.0.0",
"dompurify": "^3.4.15",
"esbuild": "^0.25.12",
"jsdom": "^27.4.0",
"katex": "^0.18.7",
"marked": "^18.0.12",
"typescript": "^6.0.3",
"vitest": "^4.1.8",
"ws": "^8.21.3",
"zod": "^3.25.76"
}
}
22 changes: 22 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/collaboration-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function effectivePlanMode(plan: PlanModeState): boolean {
}

export function planModeWithCommandAvailability(plan: PlanModeState, available: boolean): PlanModeState {
return available && !plan.available ? { ...plan, available: true } : plan
return { ...plan, available }
}

export function planModeCommand(mode: 'normal' | 'plan'): '/plan' | '/plan off' {
Expand Down
46 changes: 42 additions & 4 deletions src/conversation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { withoutIdeContext } from './ide-context.js'
import type { ImageMediaType } from './dsh-client.js'
import { presentToolCall, presentToolResult } from './tool-presentation.js'
import type { AssistantAttempt, AssistantStreamUpdate } from './dsh-assistant-stream.js'

export type ConversationRole = 'user' | 'assistant' | 'tool' | 'command' | 'notice'

Expand Down Expand Up @@ -67,6 +69,7 @@ export interface DshEvent {
seq: number
time: number
data: unknown
surfaceOp?: unknown
}

interface EventData {
Expand Down Expand Up @@ -143,20 +146,48 @@ export class ConversationProjector {
private readonly orderedIds: string[] = []
private readonly byId = new Map<string, ConversationMessage>()
private readonly hiddenCommandIds = new Set<string>()
private liveAttempt: (AssistantAttempt & { message?: ConversationMessage }) | undefined

reset(entries: readonly (DshEvent | { event: DshEvent; view?: unknown })[]): void {
reset(entries: readonly (DshEvent | { event: DshEvent; view?: unknown })[], preserveLive = false): void {
const live = preserveLive ? this.liveAttempt : undefined
this.liveAttempt = undefined
this.orderedIds.length = 0
this.byId.clear()
this.hiddenCommandIds.clear()
for (const entry of entries) {
if ('event' in entry) this.apply(entry.event, entry.view)
else this.apply(entry)
}
this.liveAttempt = live
}

/** A process-local prefix is not history; retry/abandonment must be able to discard it. */
applyStream(update: AssistantStreamUpdate): void {
if (update.kind === 'start') { this.liveAttempt = { ...update }; return }
const active = this.liveAttempt
if (active?.attemptId !== update.attemptId) return
if (update.kind === 'end') { this.liveAttempt = undefined; return }
const chunk = update.chunk
const current = active.message
const images = chunk.type === 'block-end' ? imageContent(chunk.block) : []
const text = chunk.type === 'text-delta' && typeof chunk.text === 'string' ? chunk.text : ''
if (text === '' && images.length === 0) return
const next: ConversationMessage = {
id: `assistant-live:${active.attemptId}`, role: 'assistant', streaming: true,
text: `${current?.text ?? ''}${text}`,
...(current?.images === undefined && images.length === 0 ? {} : { images: mergeImages(current?.images, images) }),
}
if (text !== '') appendAssistantStream(current, next, text)
else inheritAssistantStream(current, next)
active.message = next
}

apply(event: DshEvent, view?: unknown): void {
const data = record(event.data)
if (data === undefined) return
if ((event.type === 'assistant/message' || event.type === 'assistant/attempt')
&& this.liveAttempt?.turn === data.turn && this.liveAttempt?.step === data.step
&& (event.type === 'assistant/attempt' || event.surfaceOp === 'append')) this.liveAttempt = undefined

if (event.type === 'user/message') {
const source = record(data.source)
Expand Down Expand Up @@ -221,7 +252,7 @@ export class ConversationProjector {
text: name,
detail: 'Running…',
streaming: true,
callView: toolView(view, 'call'),
callView: toolView(view, 'call') ?? presentToolCall(name, data.arguments),
...(typeof data.arguments === 'string' ? { rawInput: data.arguments } : {}),
})
return
Expand Down Expand Up @@ -249,7 +280,7 @@ export class ConversationProjector {
failed,
...(current?.callView === undefined ? {} : { callView: current.callView }),
...(current?.rawInput === undefined ? {} : { rawInput: current.rawInput }),
resultView: toolView(view, 'result'),
resultView: toolView(view, 'result') ?? presentToolResult(current?.text ?? '', current?.rawInput, event, failed),
...(rawResult === '' ? {} : { rawResult }),
...(images.length > 0 ? { images } : {}),
})
Expand Down Expand Up @@ -300,13 +331,20 @@ export class ConversationProjector {
}

messages(): ConversationMessage[] {
return this.orderedIds.flatMap(id => {
const messages = this.orderedIds.flatMap(id => {
const value = this.byId.get(id)
if (value === undefined) return []
const copy = { ...value }
inheritAssistantStream(value, copy)
return [copy]
})
const live = this.liveAttempt?.message
if (live !== undefined) {
const copy = { ...live }
inheritAssistantStream(live, copy)
messages.push(copy)
}
return messages
}

private set(id: string, message: ConversationMessage): void {
Expand Down
Loading
Loading