DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
chore: remove packages .js extname
hairyfa41b216fb281
diff --git a/packages/dsh-tauri-panel-extension/src/host/apply.ts b/packages/dsh-tauri-panel-extension/src/host/apply.tsindex 67270ff8..2b37f56e 100644--- a/packages/dsh-tauri-panel-extension/src/host/apply.ts+++ b/packages/dsh-tauri-panel-extension/src/host/apply.ts@@ -12,16 +12,16 @@*/import type { Context } from '@deepseek-ai/cordis'-import type { PanelExtensionHost } from './types/index.js'+import type { PanelExtensionHost } from './types'import { existsSync } from 'node:fs'import { fileURLToPath } from 'node:url'import { dirname, join } from 'pathe'-import { PLUGIN_NAME } from '../shared/constants.js'-import { providerHooks } from './hooks/index.js'-import { mountPanelExtensionRoutes } from './routes/index.js'-import { agentSkillRoots } from './service/agents.js'-import { argvProfile, profileDir } from './service/profile.js'-import { loadState } from './storage/index.js'+import { PLUGIN_NAME } from '../shared/constants'+import { providerHooks } from './hooks'+import { mountPanelExtensionRoutes } from './routes'+import { agentSkillRoots } from './service/agents'+import { argvProfile, profileDir } from './service/profile'+import { loadState } from './storage'export const name = PLUGIN_NAMEdiff --git a/packages/dsh-tauri-panel-extension/src/index.ts b/packages/dsh-tauri-panel-extension/src/index.tsindex 210a609f..8d8c4e21 100644--- a/packages/dsh-tauri-panel-extension/src/index.ts+++ b/packages/dsh-tauri-panel-extension/src/index.ts@@ -12,14 +12,14 @@* - client/ Browser half(API 调用 + 设置页三个 tab)。*/-import { PLUGIN_NAME } from './shared/constants.js'+import { PLUGIN_NAME } from './shared/constants'/** 插件名(诊断元数据,与导出的 name 一致)。 */export const name = PLUGIN_NAMEexport const inject = ['webServer', 'skills', 'connection']-export { apply, loadFilesystemSkillPlugin, packagedSkillsDir } from './host/apply.js'-export type { Config } from './host/apply.js'-export { providerHooks } from './host/hooks/index.js'-export type { ProviderLifecycleHooks } from './host/hooks/index.js'+export { apply, loadFilesystemSkillPlugin, packagedSkillsDir } from './host/apply'+export type { Config } from './host/apply'+export { providerHooks } from './host/hooks'+export type { ProviderLifecycleHooks } from './host/hooks'diff --git a/packages/dsh-tauri-panel-scheduler/src/host/apply.ts b/packages/dsh-tauri-panel-scheduler/src/host/apply.tsindex 0981d9d1..82ae9814 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/apply.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/apply.ts@@ -9,15 +9,15 @@* 卸载时统一释放定时器与路由。*/-import type { HostContext } from './types/index.js'-import { SCHEDULER_TICK_MS } from './constants/index.js'-import { createSchedulerHooks } from './hooks/index.js'-import { buildRoutes } from './routes/index.js'-import { recoverInterruptedRuns } from './service/manager.js'-import { SchedulerEngine } from './service/scheduler.js'-import { createToolSet } from './tools/index.js'+import type { HostContext } from './types'+import { SCHEDULER_TICK_MS } from './constants'+import { createSchedulerHooks } from './hooks'+import { buildRoutes } from './routes'+import { recoverInterruptedRuns } from './service/manager'+import { SchedulerEngine } from './service/scheduler'+import { createToolSet } from './tools'-export type { SchedulerLifecycleHooks } from './hooks/index.js'+export type { SchedulerLifecycleHooks } from './hooks'/** 可选配置。 */export interface Config {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/routes/index.ts b/packages/dsh-tauri-panel-scheduler/src/host/routes/index.tsindex 19b22172..ec724a0b 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/routes/index.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/routes/index.ts@@ -6,12 +6,12 @@* 并全部经 withConnectionAuth 做 DSH 连接信任边界校验。*/-import type { SchedulerEngine } from '../service/scheduler.js'-import type { HostContext, JsonBody, RouteResult } from '../types/index.js'+import type { SchedulerEngine } from '../service/scheduler'+import type { HostContext, JsonBody, RouteResult } from '../types'import { routeHandler, withConnectionAuth } from 'dsh-tauri'-import { SCHEDULER_API_PREFIX } from '../../shared/constants.js'-import { createTask, deleteRun, deleteTask, listRuns, listTasks, recoverInterruptedRuns, setTaskEnabled, updateTask } from '../service/manager.js'-import { collectSchedulerOptions } from '../service/options.js'+import { SCHEDULER_API_PREFIX } from '../../shared/constants'+import { createTask, deleteRun, deleteTask, listRuns, listTasks, recoverInterruptedRuns, setTaskEnabled, updateTask } from '../service/manager'+import { collectSchedulerOptions } from '../service/options'/** 从 URL 或 body 提取参数(统一字符串化)。 */function stringParam(body: JsonBody, url: URL, key: string): string {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/executor.test.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/executor.test.tsindex 1588f929..04d3b1f2 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/executor.test.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/executor.test.ts@@ -1,5 +1,5 @@import { describe, expect, it, vi } from 'vitest'-import { loadSchedulerRuntimeModules, unattendedToolGuardReason } from './executor.js'+import { loadSchedulerRuntimeModules, unattendedToolGuardReason } from './executor'describe('loadSchedulerRuntimeModules', () => {it('resolves DSH-owned modules through the platform loader', async () => {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/executor.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/executor.tsindex 3812d870..f121945f 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/executor.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/executor.ts@@ -18,16 +18,16 @@ import type { ModelSelection } from '@deepseek-ai/dsh-agent'import type {} from '@deepseek-ai/dsh-agent-default-model'import type {} from '@deepseek-ai/dsh-agent-presets'import type { ToolExecution } from '@deepseek-ai/dsh-tools'-import type { HostContext, RunTrigger, SchedulerTask } from '../types/index.js'-import type { PermissionPresetService } from './permission-presets.js'+import type { HostContext, RunTrigger, SchedulerTask } from '../types'+import type { PermissionPresetService } from './permission-presets'import { randomUUID } from 'node:crypto'import { mkdir } from 'node:fs/promises'import { homedir } from 'node:os'import process from 'node:process'import { join } from 'pathe'-import { RUNS_HISTORY_LIMIT } from '../constants/index.js'-import { loadState, saveRuns, withStateLock } from '../storage/index.js'-import { schedulerSessionTitle } from './run-title.js'+import { RUNS_HISTORY_LIMIT } from '../constants'+import { loadState, saveRuns, withStateLock } from '../storage'+import { schedulerSessionTitle } from './run-title'/** 单次执行结果(scheduler.ts / 路由消费)。 */export interface ExecuteOutcome {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/manager.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/manager.tsindex 53c85624..8b6276ba 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/manager.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/manager.ts@@ -5,11 +5,11 @@* 供 HTTP 路由与 agent 工具复用,避免两处逻辑漂移。*/-import type { SchedulerRun, SchedulerSchedule, SchedulerTask } from '../types/index.js'+import type { SchedulerRun, SchedulerSchedule, SchedulerTask } from '../types'import { randomUUID } from 'node:crypto'-import { NAME_MAX_LENGTH, PROMPT_MAX_LENGTH } from '../constants/index.js'-import { loadState, saveRuns, saveTasks, withStateLock } from '../storage/index.js'-import { localTimeZone, nextOccurrence, validateSchedule } from './schedule.js'+import { NAME_MAX_LENGTH, PROMPT_MAX_LENGTH } from '../constants'+import { loadState, saveRuns, saveTasks, withStateLock } from '../storage'+import { localTimeZone, nextOccurrence, validateSchedule } from './schedule'/** 任务创建入参。 */export interface TaskInput {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/options.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/options.tsindex 420cb920..7b1a1e41 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/options.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/options.ts@@ -9,7 +9,7 @@* 能力探测约定:所有可选服务「探测后调用」,缺失即返回空,绝不断言存在。*/-import type { HostContext, ModelCatalogFailure, ModelOption, PermissionOption, SchedulerOptions } from '../types/index.js'+import type { HostContext, ModelCatalogFailure, ModelOption, PermissionOption, SchedulerOptions } from '../types'/** 收集工作区列表:遍历 workspaceRegistry 的记录(id + path)。无法枚举时返回空数组。 */async function collectWorkspaces(ctx: HostContext): Promise<SchedulerOptions['workspaces']> {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/schedule.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/schedule.tsindex 1ffd878e..34c861bd 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/schedule.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/schedule.ts@@ -7,7 +7,7 @@* (schedule.timeZone 仅作展示记录,执行统一用宿主本地钟面时间)。返回 ms 时间戳。*/-import type { SchedulerSchedule, Weekday } from '../types/index.js'+import type { SchedulerSchedule, Weekday } from '../types'import { parseCronExpression } from 'cron-schedule'const MINUTE_MS = 60 * 1000diff --git a/packages/dsh-tauri-panel-scheduler/src/host/service/scheduler.ts b/packages/dsh-tauri-panel-scheduler/src/host/service/scheduler.tsindex 6533548f..8c631df2 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/service/scheduler.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/service/scheduler.ts@@ -9,12 +9,12 @@*/import type { Hookable } from 'hookable'-import type { SchedulerLifecycleHooks } from '../hooks/index.js'-import type { HostContext, SchedulerTask } from '../types/index.js'-import { MAX_CONCURRENT_RUNS } from '../constants/index.js'-import { loadState, saveTasks, withStateLock } from '../storage/index.js'-import { executeTask } from './executor.js'-import { nextOccurrence } from './schedule.js'+import type { SchedulerLifecycleHooks } from '../hooks'+import type { HostContext, SchedulerTask } from '../types'+import { MAX_CONCURRENT_RUNS } from '../constants'+import { loadState, saveTasks, withStateLock } from '../storage'+import { executeTask } from './executor'+import { nextOccurrence } from './schedule'/** 调度引擎:持有运行中任务集合,暴露 tick() 供 apply 的定时器驱动。 */export class SchedulerEngine {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/storage/index.ts b/packages/dsh-tauri-panel-scheduler/src/host/storage/index.tsindex cbf889d2..f3f9c2a5 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/storage/index.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/storage/index.ts@@ -6,14 +6,14 @@* 同步读面(loadState)保留给路由与调度引擎启动路径。*/-import type { SchedulerRun, SchedulerState, SchedulerTask } from '../types/index.js'+import type { SchedulerRun, SchedulerState, SchedulerTask } from '../types'import { existsSync, readFileSync } from 'node:fs'import { homedir } from 'node:os'import process from 'node:process'import { createAtomicFsStorage } from 'dsh-tauri'import { join } from 'pathe'-import { RUNS_HISTORY_LIMIT, RUNS_KEY, SCHEDULER_STATE_DIRECTORY, TASKS_KEY } from '../constants/index.js'-import { validateSchedule } from '../service/schedule.js'+import { RUNS_HISTORY_LIMIT, RUNS_KEY, SCHEDULER_STATE_DIRECTORY, TASKS_KEY } from '../constants'+import { validateSchedule } from '../service/schedule'/** 插件状态目录(默认 `$DSH_HOME/dsh-tauri-panel-scheduler`)。 */export function schedulerStateDir(dshHome: string | undefined = process.env.DSH_HOME): string {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/tools/index.ts b/packages/dsh-tauri-panel-scheduler/src/host/tools/index.tsindex 23392533..53b644bc 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/tools/index.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/tools/index.ts@@ -6,8 +6,8 @@* 创建/管理定时任务(「通过 Chat 创建」入口)。*/-import type { SchedulerEngine } from '../service/scheduler.js'-import { createTask, deleteTask, listTasks, setTaskEnabled } from '../service/manager.js'+import type { SchedulerEngine } from '../service/scheduler'+import { createTask, deleteTask, listTasks, setTaskEnabled } from '../service/manager'/** 文本渲染助手。 */function textBlock(text: string): Array<{ type: 'text', text: string }> {diff --git a/packages/dsh-tauri-panel-scheduler/src/host/types/index.ts b/packages/dsh-tauri-panel-scheduler/src/host/types/index.tsindex c9293a57..ddb2d459 100644--- a/packages/dsh-tauri-panel-scheduler/src/host/types/index.ts+++ b/packages/dsh-tauri-panel-scheduler/src/host/types/index.ts@@ -5,7 +5,7 @@* 共用的线协议形状:client 侧另有视图投影(client/types/),本文件保持纯数据模型。*/-import type { SCHEDULE_KINDS, WEEKDAYS } from '../../shared/constants.js'+import type { SCHEDULE_KINDS, WEEKDAYS } from '../../shared/constants'/** 宿主根上下文(Cordis 注入能力;插件侧以 any 消费,类型由 dsh 生态 declare module 增强)。 */export type HostContext = anydiff --git a/packages/dsh-tauri-panel-scheduler/src/index.ts b/packages/dsh-tauri-panel-scheduler/src/index.tsindex 6f87dc69..21a5c176 100644--- a/packages/dsh-tauri-panel-scheduler/src/index.ts+++ b/packages/dsh-tauri-panel-scheduler/src/index.ts@@ -18,7 +18,7 @@* history/options)。*/-import { SCHEDULER_API_PREFIX, SCHEDULER_PLUGIN_NAME } from './shared/constants.js'+import { SCHEDULER_API_PREFIX, SCHEDULER_PLUGIN_NAME } from './shared/constants'/** 插件名(诊断元数据,与导出的 name 一致)。 */export const name = SCHEDULER_PLUGIN_NAME@@ -46,14 +46,14 @@ export const inject = [/** API 路由前缀(客户端同源 fetch)。 */export const API_PREFIX = SCHEDULER_API_PREFIX-export { apply } from './host/apply.js'-export type { Config } from './host/apply.js'-export { createSchedulerHooks } from './host/hooks/index.js'-export type { SchedulerLifecycleHooks } from './host/hooks/index.js'-export { buildRoutes } from './host/routes/index.js'-export { executeTask } from './host/service/executor.js'-export { localTimeZone, nextOccurrence, parseTimeToMinutes, validateSchedule } from './host/service/schedule.js'-export { SchedulerEngine } from './host/service/scheduler.js'-export { createToolSet } from './host/tools/index.js'-export type { SchedulerOptions, SchedulerRun, SchedulerSchedule, SchedulerTask } from './host/types/index.js'-export { SCHEDULE_KINDS, SCHEDULER_API_PREFIX, WEEKDAYS, WORKDAY_SET } from './shared/constants.js'+export { apply } from './host/apply'+export type { Config } from './host/apply'+export { createSchedulerHooks } from './host/hooks'+export type { SchedulerLifecycleHooks } from './host/hooks'+export { buildRoutes } from './host/routes'+export { executeTask } from './host/service/executor'+export { localTimeZone, nextOccurrence, parseTimeToMinutes, validateSchedule } from './host/service/schedule'+export { SchedulerEngine } from './host/service/scheduler'+export { createToolSet } from './host/tools'+export type { SchedulerOptions, SchedulerRun, SchedulerSchedule, SchedulerTask } from './host/types'+export { SCHEDULE_KINDS, SCHEDULER_API_PREFIX, WEEKDAYS, WORKDAY_SET } from './shared/constants'diff --git a/packages/dsh-tauri-rightclick/src/index.ts b/packages/dsh-tauri-rightclick/src/index.tsindex f1ae7b5f..74ba6eec 100644--- a/packages/dsh-tauri-rightclick/src/index.ts+++ b/packages/dsh-tauri-rightclick/src/index.ts@@ -10,14 +10,14 @@* 路由只接受同源 JSON POST(isSameOriginJsonRequest 校验)。*/-import type { HostContext, HostRoute } from './types.js'+import type { HostContext, HostRoute } from './types'import { isSameOriginJsonRequest, openDirectory, openUrl, readJsonBody, respond, safeWebUrl, withConnectionAuth } from 'dsh-tauri'import {OPEN_PATH_ROUTE,OPEN_URL_ROUTE,RIGHTCLICK_API_PREFIX,RIGHTCLICK_PLUGIN_NAME,-} from './constants.js'+} from './constants'/** 插件名(诊断元数据,与导出的 name 一致)。 */export const name = RIGHTCLICK_PLUGIN_NAMEdiff --git a/packages/dsh-tauri-session/src/host/apply.ts b/packages/dsh-tauri-session/src/host/apply.tsindex 92081c3c..520fbef3 100644--- a/packages/dsh-tauri-session/src/host/apply.ts+++ b/packages/dsh-tauri-session/src/host/apply.ts@@ -4,35 +4,25 @@* 由 archive.ts 在业务操作内触发,见 host/hooks.ts。*/-import type { HostContext, PluginConfig } from './types/index.js'-import { homedir } from 'node:os'-import process from 'node:process'-import { join } from 'pathe'-import { SESSION_PLUGIN_NAME } from '../shared/constants.js'-import { buildRoutes } from './routes/index.js'-import { migrateLegacyArchive } from './service/archive.js'--function resolveDshHome(config: PluginConfig): string {- return typeof config.dshHome === 'string' && config.dshHome ? config.dshHome : process.env.DSH_HOME ?? join(homedir(), '.dsh')-}+import type { HostContext, PluginConfig } from './types'+import { SESSION_PLUGIN_NAME } from '../shared/constants'+import { buildRoutes } from './routes'+import { migrateLegacyArchive } from './service/archive'/*** 插件体:迁移旧版归档 + 注册 HTTP 路由。* @param ctx - 宿主根上下文(注入 webServer/sessions/workspaceRegistry)。- * @param config - 插件行配置(dshHome 等,仅用于旧版归档迁移路径)。+ * @param config - 插件行配置(保留;存储路径由 storage 单例按 DSH_HOME 解析)。*/-export function apply(ctx: HostContext, config: PluginConfig = {}): void {- const cfg = config ?? {}- const dshHome = resolveDshHome(cfg)-+export function apply(ctx: HostContext, _config: PluginConfig = {}): void {// 旧版自持归档一次性迁入宿主集合(幂等:文件不存在或为空则直接跳过)。ctx.effect(() => {- void migrateLegacyArchive(ctx, dshHome)+ void migrateLegacyArchive(ctx)}, `${SESSION_PLUGIN_NAME}: migrate legacy archive`)// HTTP 路由注册(客户端经此调用 archived/archive/unarchive/delete/clear)。ctx.effect(() => {- const disposers = buildRoutes(ctx, dshHome).map(route => ctx.webServer.register(route))+ const disposers = buildRoutes(ctx).map(route => ctx.webServer.register(route))return () => {for (const dispose of disposers)dispose()diff --git a/packages/dsh-tauri-session/src/host/routes/index.ts b/packages/dsh-tauri-session/src/host/routes/index.tsindex 176a4378..416d6c2a 100644--- a/packages/dsh-tauri-session/src/host/routes/index.ts+++ b/packages/dsh-tauri-session/src/host/routes/index.ts@@ -8,9 +8,9 @@* `$DSH_HOME/sessions/...` 内有界解析该会话的数据目录后交给系统文件管理器。*/-import type { HostContext } from '../types/index.js'+import type { HostContext } from '../types'import { openDirectory, routeHandler, withConnectionAuth } from 'dsh-tauri'-import { SESSION_API_PREFIX, SESSION_PLUGIN_NAME } from '../../shared/constants.js'+import { SESSION_API_PREFIX, SESSION_PLUGIN_NAME } from '../../shared/constants'import {archiveSession,archiveWorkspace,@@ -19,11 +19,11 @@ import {permanentlyDeleteSelected,permanentlyDeleteSession,unarchiveSession,-} from '../service/archive.js'-import { locateSessionDataDir } from '../service/session-files.js'+} from '../service/archive'+import { locateSessionDataDir } from '../service/session-files'/** 构建路由列表。 */-export function buildRoutes(ctx: HostContext, dshHome: string): any[] {+export function buildRoutes(ctx: HostContext): any[] {const routes = [{kind: 'exact',@@ -37,7 +37,7 @@ export function buildRoutes(ctx: HostContext, dshHome: string): any[] {const sessionId = typeof body?.sessionId === 'string' ? body.sessionId : ''if (!sessionId)return [400, { ok: false, error: 'invalid-session-id' }]- const directory = locateSessionDataDir(dshHome, sessionId)+ const directory = locateSessionDataDir(sessionId)if (!directory)return [400, { ok: false, error: 'session-directory-not-found' }]if (!openDirectory(directory))@@ -63,17 +63,17 @@ export function buildRoutes(ctx: HostContext, dshHome: string): any[] {{kind: 'exact',path: `${SESSION_API_PREFIX}/delete`,- handler: routeHandler(async body => [200, await permanentlyDeleteSession(ctx, dshHome, body)], { mutate: true }),+ handler: routeHandler(async body => [200, await permanentlyDeleteSession(ctx, body)], { mutate: true }),},{kind: 'exact',path: `${SESSION_API_PREFIX}/delete-workspace`,- handler: routeHandler(async body => [200, await permanentlyDeleteSelected(ctx, dshHome, body)], { mutate: true }),+ handler: routeHandler(async body => [200, await permanentlyDeleteSelected(ctx, body)], { mutate: true }),},{kind: 'exact',path: `${SESSION_API_PREFIX}/clear`,- handler: routeHandler(async () => [200, await permanentlyDeleteAll(ctx, dshHome)], { mutate: true }),+ handler: routeHandler(async () => [200, await permanentlyDeleteAll(ctx)], { mutate: true }),},]return routes.map(route => ({diff --git a/packages/dsh-tauri-session/src/host/service/archive.ts b/packages/dsh-tauri-session/src/host/service/archive.tsindex bb2b60b2..2795bf91 100644--- a/packages/dsh-tauri-session/src/host/service/archive.ts+++ b/packages/dsh-tauri-session/src/host/service/archive.ts@@ -10,16 +10,16 @@* 也不允许并发删除在记账与归档集合之间交错。*/-import type { ArchivedListPayload, ArchiveDocument, HostContext } from '../types/index.js'+import type { ArchivedListPayload, ArchiveDocument, HostContext } from '../types'import type {RegistryArchiveSurface,-} from './registry.js'+} from './registry'import { rmSync } from 'node:fs'import { join } from 'pathe'-import { SESSION_PLUGIN_NAME } from '../../shared/constants.js'-import { SESSION_ARCHIVE_FILE } from '../constants/index.js'-import { archiveHooks } from '../hooks/index.js'-import { loadArchive, saveArchive, sessionStateDir } from '../storage/index.js'+import { SESSION_PLUGIN_NAME } from '../../shared/constants'+import { SESSION_ARCHIVE_FILE } from '../constants'+import { archiveHooks } from '../hooks'+import { sessionStateDir, storage } from '../storage'import {registryArchiveSurface,removeArchivedSessionsFromRegistry,@@ -28,12 +28,12 @@ import {requireArchiveSession,requireDeletionSurfaces,restoreSessionWorkspaceAccounting,-} from './registry.js'+} from './registry'import {findSession,removeSessionDataDir,sessionCwd,-} from './session-files.js'+} from './session-files'/** 组装 GET /archived 的载荷:宿主归档集合 id + 每个会话的创建元数据(读 host session header)。 */export function buildArchivedPayload(ctx: HostContext): ArchivedListPayload {@@ -101,8 +101,21 @@ export async function unarchiveSession(ctx: HostContext, body: Record<string, un* 归档集合。迁移成功的记录从旧文件中移除;仍失败的(如会话已不存在)保留在旧* 文件中,下次启动幂等重试 —— 绝不因单次失败丢弃用户数据。*/-export async function migrateLegacyArchive(ctx: HostContext, dshHome: string): Promise<void> {- const legacy = await loadArchive(dshHome)+export async function migrateLegacyArchive(ctx: HostContext): Promise<void> {+ let legacy: ArchiveDocument = {}+ try {+ const parsed = await storage.getItem<ArchiveDocument>(SESSION_ARCHIVE_FILE)+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {+ const out: ArchiveDocument = {}+ for (const [key, value] of Object.entries(parsed as Record<string, unknown>)) {+ const record = value as Partial<{ sessionId: string, archivedAt: number }>+ if (typeof key === 'string' && typeof record?.sessionId === 'string' && key === record.sessionId)+ out[key] = record as ArchiveDocument[string]+ }+ legacy = out+ }+ }+ catch { /* 文件缺失/损坏按空归档处理。 */ }const sessionIds = Object.keys(legacy)if (sessionIds.length === 0)return@@ -129,14 +142,14 @@ export async function migrateLegacyArchive(ctx: HostContext, dshHome: string): P}try {if (failed.length === 0) {- rmSync(join(sessionStateDir(dshHome), SESSION_ARCHIVE_FILE), { force: true })+ rmSync(join(sessionStateDir(), SESSION_ARCHIVE_FILE), { force: true })}else {// 只保留未迁移成功的记录,避免下次启动重复迁移已成功的会话。const remaining: ArchiveDocument = {}for (const sessionId of failed)remaining[sessionId] = legacy[sessionId]- await saveArchive(remaining, dshHome)+ await storage.setItem(SESSION_ARCHIVE_FILE, `${JSON.stringify(remaining, null, 2)}\n`)}}catch {@@ -149,7 +162,7 @@ export async function migrateLegacyArchive(ctx: HostContext, dshHome: string): P* 彻底删除一批归档会话——删除事务的核心实现(见文件头的事务顺序)。* 所有 id 共用一次预检、一次注册表事务,杜绝逐会话部分删除。*/-async function permanentlyDeleteSessions(ctx: HostContext, dshHome: string, rawIds: readonly string[]): Promise<{ ok: true }> {+async function permanentlyDeleteSessions(ctx: HostContext, rawIds: readonly string[]): Promise<{ ok: true }> {const ids = [...new Set(rawIds.map(String).filter(Boolean))]if (ids.length === 0)throw new Error('缺少 sessionIds')@@ -163,7 +176,7 @@ async function permanentlyDeleteSessions(ctx: HostContext, dshHome: string, rawIlet removed = 0for (const sessionId of ids) {try {- if (removeSessionDataDir(dshHome, sessionId))+ if (removeSessionDataDir(sessionId))removed += 1}catch (error) {@@ -186,24 +199,24 @@ async function permanentlyDeleteSessions(ctx: HostContext, dshHome: string, rawI}/** 彻底删除一个归档会话(成员校验 + 物理删除 + 记账更新)。 */-export async function permanentlyDeleteSession(ctx: HostContext, dshHome: string, body: Record<string, unknown>): Promise<{ ok: true }> {+export async function permanentlyDeleteSession(ctx: HostContext, body: Record<string, unknown>): Promise<{ ok: true }> {const sessionId = String(body.sessionId ?? '')if (!sessionId)throw new Error('缺少 sessionId')- return permanentlyDeleteSessions(ctx, dshHome, [sessionId])+ return permanentlyDeleteSessions(ctx, [sessionId])}/** 彻底删除指定归档会话(先物理删除全部,再批量更新记账)。 */-export async function permanentlyDeleteSelected(ctx: HostContext, dshHome: string, body: Record<string, unknown>): Promise<{ ok: true }> {+export async function permanentlyDeleteSelected(ctx: HostContext, body: Record<string, unknown>): Promise<{ ok: true }> {const rawIds = body.sessionIdsif (!Array.isArray(rawIds) || rawIds.length === 0)throw new Error('缺少 sessionIds')- return permanentlyDeleteSessions(ctx, dshHome, rawIds as string[])+ return permanentlyDeleteSessions(ctx, rawIds as string[])}/** 彻底删除全部已归档会话(先物理删除全部,再批量更新记账)。 */-export async function permanentlyDeleteAll(ctx: HostContext, dshHome: string): Promise<{ ok: true }> {+export async function permanentlyDeleteAll(ctx: HostContext): Promise<{ ok: true }> {const registry = ctx.workspaceRegistry as { archivedSessionIds?: readonly string[] } | undefinedconst ids = [...(registry?.archivedSessionIds ?? [])]- return permanentlyDeleteSessions(ctx, dshHome, ids)+ return permanentlyDeleteSessions(ctx, ids)}diff --git a/packages/dsh-tauri-session/src/host/service/registry.ts b/packages/dsh-tauri-session/src/host/service/registry.tsindex 9d7b976f..ae15d2a1 100644--- a/packages/dsh-tauri-session/src/host/service/registry.ts+++ b/packages/dsh-tauri-session/src/host/service/registry.ts@@ -14,8 +14,8 @@* 保证失败可整体重试。*/-import type { HostContext, SessionLike } from '../types/index.js'-import { findSession, sessionCwd } from './session-files.js'+import type { HostContext, SessionLike } from '../types'+import { findSession, sessionCwd } from './session-files'/** 宿主会话 store 的删除所需表面(桌面壳补丁暴露 remove(id))。 */interface SessionStoreSurface {diff --git a/packages/dsh-tauri-session/src/host/service/session-files.test.ts b/packages/dsh-tauri-session/src/host/service/session-files.test.tsindex a2659ece..284aa6b3 100644--- a/packages/dsh-tauri-session/src/host/service/session-files.test.ts+++ b/packages/dsh-tauri-session/src/host/service/session-files.test.ts@@ -23,49 +23,49 @@ function makeSessionDir(group: string | undefined, marker: string): string {describe('locateSessionDataDir', () => {it('finds a depth-2 session data directory (sessions/<group>/session-<id>)', () => {const dir = makeSessionDir('--project-a--', 'session-abc')- expect(locateSessionDataDir(dshHome, 'abc')).toBe(dir)+ expect(locateSessionDataDir('abc', dshHome)).toBe(dir)})it('finds a depth-1 session data directory (sessions/session-<id>)', () => {const dir = makeSessionDir(undefined, 'session-xyz')- expect(locateSessionDataDir(dshHome, 'xyz')).toBe(dir)+ expect(locateSessionDataDir('xyz', dshHome)).toBe(dir)})it('returns undefined when no session data directory exists', () => {- expect(locateSessionDataDir(dshHome, 'missing')).toBeUndefined()+ expect(locateSessionDataDir('missing', dshHome)).toBeUndefined()})})describe('removeSessionDataDir', () => {it('removes the located depth-2 directory', () => {makeSessionDir('--project-a--', 'session-abc')- expect(removeSessionDataDir(dshHome, 'abc')).toBe(true)- expect(locateSessionDataDir(dshHome, 'abc')).toBeUndefined()+ expect(removeSessionDataDir('abc', dshHome)).toBe(true)+ expect(locateSessionDataDir('abc', dshHome)).toBeUndefined()})it('prunes an empty parent group directory after removal', () => {makeSessionDir('--project-a--', 'session-abc')- expect(removeSessionDataDir(dshHome, 'abc')).toBe(true)- expect(locateSessionDataDir(dshHome, 'abc')).toBeUndefined()+ expect(removeSessionDataDir('abc', dshHome)).toBe(true)+ expect(locateSessionDataDir('abc', dshHome)).toBeUndefined()expect(existsSync(join(dshHome, 'sessions', '--project-a--'))).toBe(false)})it('keeps a parent group directory that still holds other sessions', () => {makeSessionDir('--project-a--', 'session-abc')makeSessionDir('--project-a--', 'session-def')- expect(removeSessionDataDir(dshHome, 'abc')).toBe(true)+ expect(removeSessionDataDir('abc', dshHome)).toBe(true)expect(existsSync(join(dshHome, 'sessions', '--project-a--'))).toBe(true)- expect(locateSessionDataDir(dshHome, 'def')).toBe(join(dshHome, 'sessions', '--project-a--', 'session-def'))+ expect(locateSessionDataDir('def', dshHome)).toBe(join(dshHome, 'sessions', '--project-a--', 'session-def'))})it('keeps the sessions root itself when a depth-1 directory is removed', () => {const dir = makeSessionDir(undefined, 'session-xyz')- expect(removeSessionDataDir(dshHome, 'xyz')).toBe(true)+ expect(removeSessionDataDir('xyz', dshHome)).toBe(true)expect(existsSync(dir)).toBe(false)expect(existsSync(join(dshHome, 'sessions'))).toBe(true)})it('reports false when the session has no data directory', () => {- expect(removeSessionDataDir(dshHome, 'ghost')).toBe(false)+ expect(removeSessionDataDir('ghost', dshHome)).toBe(false)})})diff --git a/packages/dsh-tauri-session/src/host/service/session-files.ts b/packages/dsh-tauri-session/src/host/service/session-files.tsindex 9a2265fc..40caae55 100644--- a/packages/dsh-tauri-session/src/host/service/session-files.ts+++ b/packages/dsh-tauri-session/src/host/service/session-files.ts@@ -8,9 +8,16 @@* - 物理删除是 best-effort(找不到就跳过),但抛出异常时必须由调用方中止流程。*/-import type { HostContext, SessionLike } from '../types/index.js'+import type { HostContext, SessionLike } from '../types'+import { homedir } from 'node:os'import { readdirSync, rmSync } from 'node:fs'import { dirname, join, resolve, sep } from 'pathe'+import process from 'node:process'++/** 会话数据根目录(默认 `$DSH_HOME/sessions`;测试可注入临时根)。 */+function sessionsRoot(dshHome: string | undefined): string {+ return join(dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'), 'sessions')+}/** 查找会话对象(host ctx.sessions)。 */export function findSession(ctx: HostContext, sessionId: string): SessionLike | undefined {@@ -78,13 +85,13 @@ export function encodeSessionId(id: string): string {* 会从持久化重建会话索引,该会话从工作区/归档中彻底消失。* @returns 是否实际删除了目录。*/-export function removeSessionDataDir(dshHome: string, sessionId: string): boolean {- const sessionsRoot = join(dshHome, 'sessions')- const dir = findSessionDataDir(sessionsRoot, sessionId)+export function removeSessionDataDir(sessionId: string, dshHome?: string): boolean {+ const sessionsRootDir = sessionsRoot(dshHome)+ const dir = findSessionDataDir(sessionsRootDir, sessionId)if (!dir)return falsermSync(dir, { recursive: true, force: true })- pruneEmptyParents(sessionsRoot, dirname(dir))+ pruneEmptyParents(sessionsRootDir, dirname(dir))return true}@@ -104,8 +111,8 @@ function pruneEmptyParents(sessionsRoot: string, parent: string): void {* 供「打开会话目录」解析目标路径使用。* @returns 会话数据目录绝对路径;未找到返回 undefined。*/-export function locateSessionDataDir(dshHome: string, sessionId: string): string | undefined {- return findSessionDataDir(join(dshHome, 'sessions'), sessionId)+export function locateSessionDataDir(sessionId: string, dshHome?: string): string | undefined {+ return findSessionDataDir(sessionsRoot(dshHome), sessionId)}/** 有界扫描(深度 2)查找会话数据目录,返回首个命中(含一级/二级布局)。 */diff --git a/packages/dsh-tauri-session/src/host/storage/index.ts b/packages/dsh-tauri-session/src/host/storage/index.tsindex 4242b808..7ff04391 100644--- a/packages/dsh-tauri-session/src/host/storage/index.ts+++ b/packages/dsh-tauri-session/src/host/storage/index.ts@@ -4,47 +4,20 @@** 适配 unstorage(fs):读走 getItem(自动 JSON 解析),写经 dsh-tauri 的* createAtomicFsStorage(tmp+rename 原子写),读者永远看不到半份 JSON。+ * 模块级单例 `storage`:消费方直接 storage.getItem / storage.setItem,+ * 不关心 DSH_HOME 位置、不传 dshHome 参数。*/-import type { ArchiveDocument } from '../types/index.js'import { homedir } from 'node:os'import process from 'node:process'import { createAtomicFsStorage } from 'dsh-tauri'import { join } from 'pathe'-import { SESSION_ARCHIVE_FILE, SESSION_STATE_DIRECTORY } from '../constants/index.js'+import { SESSION_STATE_DIRECTORY } from '../constants'-/** The plugin's own state directory under DSH_HOME (default `~/.dsh`). */-export function sessionStateDir(dshHome?: string): string {- return join(dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'), SESSION_STATE_DIRECTORY)+/** 插件自持状态目录(默认 `$DSH_HOME/dsh-tauri-session`)。 */+export function sessionStateDir(): string {+ return join(process.env.DSH_HOME ?? join(homedir(), '.dsh'), SESSION_STATE_DIRECTORY)}-/** Fresh empty archive document. */-export function emptyArchive(): ArchiveDocument {- return {}-}--/** Load the archive; missing/corrupt files yield an empty archive. */-export async function loadArchive(dshHome?: string): Promise<ArchiveDocument> {- const storage = createAtomicFsStorage(sessionStateDir(dshHome))- try {- const parsed = await storage.getItem<ArchiveDocument>(SESSION_ARCHIVE_FILE)- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))- return emptyArchive()- const out: ArchiveDocument = {}- for (const [key, value] of Object.entries(parsed as Record<string, unknown>)) {- const record = value as Partial<{ sessionId: string, archivedAt: number }>- if (typeof key === 'string' && typeof record?.sessionId === 'string' && key === record.sessionId)- out[key] = record as ArchiveDocument[string]- }- return out- }- catch {- return emptyArchive()- }-}--/** Persist by atomic rename so readers never observe partial JSON. */-export async function saveArchive(archive: ArchiveDocument, dshHome?: string): Promise<void> {- const storage = createAtomicFsStorage(sessionStateDir(dshHome))- await storage.setItem(SESSION_ARCHIVE_FILE, `${JSON.stringify(archive, null, 2)}\n`)-}+/** 旧版归档存储(模块级单例;key 即 base 下相对路径,`:` 为子目录分隔符)。 */+export const storage = createAtomicFsStorage(sessionStateDir())diff --git a/packages/dsh-tauri-session/src/index.ts b/packages/dsh-tauri-session/src/index.tsindex 8a9ff76b..a05e8494 100644--- a/packages/dsh-tauri-session/src/index.ts+++ b/packages/dsh-tauri-session/src/index.ts@@ -25,7 +25,7 @@* - client/ Browser half(ofetch RPC + 设置分区 + 工作区补丁)。*/-import { SESSION_API_PREFIX, SESSION_PLUGIN_NAME } from './shared/constants.js'+import { SESSION_API_PREFIX, SESSION_PLUGIN_NAME } from './shared/constants'/** 插件名(诊断元数据,与导出的 name 一致)。 */export const name = SESSION_PLUGIN_NAME@@ -36,9 +36,9 @@ export const inject = ['webServer', 'sessions', 'workspaceRegistry', 'connection/** API 路由前缀(客户端同源 fetch)。 */export const API_PREFIX = SESSION_API_PREFIX-export { apply } from './host/apply.js'-export { archiveHooks } from './host/hooks/index.js'-export type { ArchiveLifecycleHooks } from './host/hooks/index.js'-export { buildRoutes } from './host/routes/index.js'-export { updateRegistryArchiveSet } from './host/service/registry.js'-export { encodeSessionId, isWithinSessionsRoot } from './host/service/session-files.js'+export { apply } from './host/apply'+export { archiveHooks } from './host/hooks'+export type { ArchiveLifecycleHooks } from './host/hooks'+export { buildRoutes } from './host/routes'+export { updateRegistryArchiveSet } from './host/service/registry'+export { encodeSessionId, isWithinSessionsRoot } from './host/service/session-files'diff --git a/packages/dsh-tauri-tsdown/src/index.ts b/packages/dsh-tauri-tsdown/src/index.tsindex b31d6bf8..e2ad3a1f 100644--- a/packages/dsh-tauri-tsdown/src/index.ts+++ b/packages/dsh-tauri-tsdown/src/index.ts@@ -71,7 +71,7 @@ export function defineDshConfig(options: DshConfigOptions = {}) {const common: TsdownOptions = {outDir: 'dist',format: 'esm',- outExtensions: () => ({ js: '.js' }),+ outExtensions: () => ({ js: '' }),publint: options.publint ?? true,external: dshExternal,}diff --git a/packages/dsh-tauri-worktree/src/host/apply.ts b/packages/dsh-tauri-worktree/src/host/apply.tsindex 585f941e..b416ac44 100644--- a/packages/dsh-tauri-worktree/src/host/apply.ts+++ b/packages/dsh-tauri-worktree/src/host/apply.ts@@ -9,22 +9,22 @@* 4. HTTP 路由注册在 effect 内,卸载统一释放。*/-import type { HostContext, PendingHandoff, PluginConfig } from './types/index.js'+import type { HostContext, PendingHandoff, PluginConfig } from './types'import { homedir } from 'node:os'import { join } from 'pathe'-import { WORKTREE_SECTION_ORDER } from '../shared/constants.js'-import { createWorktreeHooks } from './hooks/index.js'-import { buildRoutes } from './routes/index.js'-import { completeWorktreeHandoff } from './service/handoff.js'-import { unregisterWorktreeWorkspace, worktreeKey } from './service/operation.js'+import { WORKTREE_SECTION_ORDER } from '../shared/constants'+import { createWorktreeHooks } from './hooks'+import { buildRoutes } from './routes'+import { completeWorktreeHandoff } from './service/handoff'+import { unregisterWorktreeWorkspace, worktreeKey } from './service/operation'import {clearPendingCheckoutContext,listBindingsSync,loadBindingSync,loadCheckoutContextSync,migrateLegacyLedger,-} from './storage/index.js'-import { createToolSet } from './tools/index.js'+} from './storage'+import { createToolSet } from './tools'/*** 插件体:注册工具、HTTP 路由与系统提示注入。diff --git a/packages/dsh-tauri-worktree/src/host/routes/index.ts b/packages/dsh-tauri-worktree/src/host/routes/index.tsindex 2f423b21..77916d9a 100644--- a/packages/dsh-tauri-worktree/src/host/routes/index.ts+++ b/packages/dsh-tauri-worktree/src/host/routes/index.ts@@ -6,18 +6,18 @@* status 的 isGit 判定遵守「会话未知时不猜测」的竞态语义(isGit: null)。*/-import type { HostContext, PluginConfig } from '../types/index.js'+import type { HostContext, PluginConfig } from '../types'import { randomUUID } from 'node:crypto'import { existsSync } from 'node:fs'import { homedir } from 'node:os'import { routeHandler, withConnectionAuth } from 'dsh-tauri'import { join } from 'pathe'-import { WORKTREE_API_PREFIX } from '../../shared/constants.js'-import { gitToplevel } from '../service/git.js'-import { checkoutToLocalAndHandback, inheritSessionIntoWorktree } from '../service/handoff.js'-import { discardWorktree, ensureWorktree, worktreeKey, worktreePath } from '../service/operation.js'-import { findSession, resolveProjectPath } from '../service/session.js'-import { loadBinding } from '../storage/index.js'+import { WORKTREE_API_PREFIX } from '../../shared/constants'+import { gitToplevel } from '../service/git'+import { checkoutToLocalAndHandback, inheritSessionIntoWorktree } from '../service/handoff'+import { discardWorktree, ensureWorktree, worktreeKey, worktreePath } from '../service/operation'+import { findSession, resolveProjectPath } from '../service/session'+import { loadBinding } from '../storage'/** 构建路由列表。 */interface DiscardJob {diff --git a/packages/dsh-tauri-worktree/src/host/service/filesystem.test.ts b/packages/dsh-tauri-worktree/src/host/service/filesystem.test.tsindex 398f3332..9df74b6c 100644--- a/packages/dsh-tauri-worktree/src/host/service/filesystem.test.ts+++ b/packages/dsh-tauri-worktree/src/host/service/filesystem.test.ts@@ -6,7 +6,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'import {REMOVE_TREE_OPTIONS,removeDirectoryReliably,-} from './filesystem.js'+} from './filesystem'const temporaryDirectories: string[] = []diff --git a/packages/dsh-tauri-worktree/src/host/service/git.ts b/packages/dsh-tauri-worktree/src/host/service/git.tsindex 2c10338b..24161249 100644--- a/packages/dsh-tauri-worktree/src/host/service/git.ts+++ b/packages/dsh-tauri-worktree/src/host/service/git.ts@@ -1,4 +1,4 @@-import type { GitOptions, OperationResult } from '../types/index.js'+import type { GitOptions, OperationResult } from '../types'import { mkdtemp, rm, writeFile } from 'node:fs/promises'import { tmpdir } from 'node:os'import { basename, join, resolve } from 'pathe'diff --git a/packages/dsh-tauri-worktree/src/host/service/handoff.ts b/packages/dsh-tauri-worktree/src/host/service/handoff.tsindex 6841bec7..35208657 100644--- a/packages/dsh-tauri-worktree/src/host/service/handoff.ts+++ b/packages/dsh-tauri-worktree/src/host/service/handoff.ts@@ -14,11 +14,11 @@ import type {OperationResult,PendingHandoff,WorktreeParams,-} from '../types/index.js'+} from '../types'import { randomUUID } from 'node:crypto'-import { setPendingCheckoutContext } from '../storage/index.js'-import { checkoutToLocal, discardWorktree } from './operation.js'-import { findSession } from './session.js'+import { setPendingCheckoutContext } from '../storage'+import { checkoutToLocal, discardWorktree } from './operation'+import { findSession } from './session'/*** 用源会话的完整事件创建继承会话(cwd 指向目标路径),供「检出本地」「正在新建工作树」diff --git a/packages/dsh-tauri-worktree/src/host/service/operation.test.ts b/packages/dsh-tauri-worktree/src/host/service/operation.test.tsindex 516c821e..3d9f4179 100644--- a/packages/dsh-tauri-worktree/src/host/service/operation.test.ts+++ b/packages/dsh-tauri-worktree/src/host/service/operation.test.ts@@ -8,8 +8,8 @@ import { tmpdir } from 'node:os'import { join } from 'pathe'import { simpleGit } from 'simple-git'import { afterEach, describe, expect, it } from 'vitest'-import { projectDirname } from './git.js'-import { computeHash, discardWorktree, ensureWorktree, worktreePath } from './operation.js'+import { projectDirname } from './git'+import { computeHash, discardWorktree, ensureWorktree, worktreePath } from './operation'const temporaryDirectories: string[] = []diff --git a/packages/dsh-tauri-worktree/src/host/service/operation.ts b/packages/dsh-tauri-worktree/src/host/service/operation.tsindex cf11a838..266cdf81 100644--- a/packages/dsh-tauri-worktree/src/host/service/operation.ts+++ b/packages/dsh-tauri-worktree/src/host/service/operation.ts@@ -17,15 +17,15 @@ import type {OperationResult,WorktreeParams,WorktreeProcessController,-} from '../types/index.js'+} from '../types'import { createHash } from 'node:crypto'import { existsSync } from 'node:fs'import { rmdir } from 'node:fs/promises'import process from 'node:process'import { join, resolve } from 'pathe'-import { WORKTREE_BRANCH_NAME_PATTERN } from '../constants/index.js'-import { listBindings, loadBinding, removeBinding, saveBinding } from '../storage/index.js'-import { removeDirectoryReliably } from './filesystem.js'+import { WORKTREE_BRANCH_NAME_PATTERN } from '../constants'+import { listBindings, loadBinding, removeBinding, saveBinding } from '../storage'+import { removeDirectoryReliably } from './filesystem'import {applyStagedPatch,carryStagedChanges,@@ -35,7 +35,7 @@ import {projectDirname,shortHead,stagedPatch,-} from './git.js'+} from './git'/** 计算 hash:项目路径 + 会话 ID → sha256 前 12 位。 */export function computeHash(projectPath: string, sessionId: string): string {diff --git a/packages/dsh-tauri-worktree/src/host/service/session.ts b/packages/dsh-tauri-worktree/src/host/service/session.tsindex 37d2b221..2ea3835f 100644--- a/packages/dsh-tauri-worktree/src/host/service/session.ts+++ b/packages/dsh-tauri-worktree/src/host/service/session.ts@@ -9,7 +9,7 @@* 误判 isGit: false,客户端会永久隐藏工作树模式选择器,直到刷新后才纠正。*/-import type { HostContext } from '../types/index.js'+import type { HostContext } from '../types'import { isAbsolute } from 'pathe'/**diff --git a/packages/dsh-tauri-worktree/src/host/storage/index.test.ts b/packages/dsh-tauri-worktree/src/host/storage/index.test.tsindex e451bd0d..247ab669 100644--- a/packages/dsh-tauri-worktree/src/host/storage/index.test.ts+++ b/packages/dsh-tauri-worktree/src/host/storage/index.test.ts@@ -17,7 +17,7 @@ import {migrateLegacyLedger,removeBinding,saveBinding,-} from './index'+} from '.'function tempRoot(): string {return join(tmpdir(), `dsh-worktree-storage-${randomUUID()}`)diff --git a/packages/dsh-tauri-worktree/src/host/storage/index.ts b/packages/dsh-tauri-worktree/src/host/storage/index.tsindex 8aad2ce1..4ca9edd5 100644--- a/packages/dsh-tauri-worktree/src/host/storage/index.ts+++ b/packages/dsh-tauri-worktree/src/host/storage/index.ts@@ -16,7 +16,7 @@* 工具 execute 与 systemPrompt 渲染路径(小文件同步读可接受)。*/-import type { Binding, CheckoutContext } from '../types/index.js'+import type { Binding, CheckoutContext } from '../types'import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs'import { createAtomicFsStorage } from 'dsh-tauri'import { join } from 'pathe'diff --git a/packages/dsh-tauri-worktree/src/host/tools/index.ts b/packages/dsh-tauri-worktree/src/host/tools/index.tsindex a0d214f4..6992a10d 100644--- a/packages/dsh-tauri-worktree/src/host/tools/index.ts+++ b/packages/dsh-tauri-worktree/src/host/tools/index.ts@@ -5,13 +5,13 @@* turn/end(apply 里的 session:turn-end 钩子),保证 seed 是完整会话日志。*/-import type { HostContext, PendingHandoff, PluginConfig } from '../types/index.js'+import type { HostContext, PendingHandoff, PluginConfig } from '../types'import { randomUUID } from 'node:crypto'import { homedir } from 'node:os'import { join } from 'pathe'-import { checkoutToLocal, ensureWorktree } from '../service/operation.js'-import { resolveProjectPath } from '../service/session.js'-import { loadBindingSync } from '../storage/index.js'+import { checkoutToLocal, ensureWorktree } from '../service/operation'+import { resolveProjectPath } from '../service/session'+import { loadBindingSync } from '../storage'/** 文本渲染助手:渲染成模型可见文本。 */function textBlock(text: string): Array<{ type: 'text', text: string }> {diff --git a/packages/dsh-tauri-worktree/src/index.ts b/packages/dsh-tauri-worktree/src/index.tsindex ce3521f9..c85e3655 100644--- a/packages/dsh-tauri-worktree/src/index.ts+++ b/packages/dsh-tauri-worktree/src/index.ts@@ -21,7 +21,7 @@* 创建/切换到 `dsh/<branch>` 分支,Agent 继续在本地仓库工作;主分支不受影响。*/-import { WORKTREE_API_PREFIX, WORKTREE_PLUGIN_NAME } from './shared/constants.js'+import { WORKTREE_API_PREFIX, WORKTREE_PLUGIN_NAME } from './shared/constants'/** 插件名(诊断元数据,与导出的 name 一致)。 */export const name = WORKTREE_PLUGIN_NAME@@ -39,11 +39,11 @@ export const inject = ['tools', 'systemPrompt', 'webServer', 'sessions', 'worksp/** API 路由前缀(客户端同源 fetch)。 */export const API_PREFIX = WORKTREE_API_PREFIX-export { apply } from './host/apply.js'-export { createWorktreeHooks } from './host/hooks/index.js'-export type { WorktreeLifecycleHooks } from './host/hooks/index.js'-export { buildRoutes } from './host/routes/index.js'-export { checkoutToLocalAndHandback, completeWorktreeHandoff } from './host/service/handoff.js'-export { computeHash, worktreeKey, worktreePath } from './host/service/operation.js'-export { checkoutToLocal, discardWorktree, ensureWorktree } from './host/service/operation.js'-export { createToolSet } from './host/tools/index.js'+export { apply } from './host/apply'+export { createWorktreeHooks } from './host/hooks'+export type { WorktreeLifecycleHooks } from './host/hooks'+export { buildRoutes } from './host/routes'+export { checkoutToLocalAndHandback, completeWorktreeHandoff } from './host/service/handoff'+export { computeHash, worktreeKey, worktreePath } from './host/service/operation'+export { checkoutToLocal, discardWorktree, ensureWorktree } from './host/service/operation'+export { createToolSet } from './host/tools'diff --git a/packages/dsh-tauri/src/client/apis/client.test.ts b/packages/dsh-tauri/src/client/apis/client.test.tsindex 3c340d8e..421ba2b1 100644--- a/packages/dsh-tauri/src/client/apis/client.test.ts+++ b/packages/dsh-tauri/src/client/apis/client.test.ts@@ -2,7 +2,7 @@ import type { Server } from 'node:http'import { Buffer } from 'node:buffer'import { createServer } from 'node:http'import { afterAll, beforeAll, describe, expect, it } from 'vitest'-import { fetch } from './index'+import { fetch } from '.'let server: Serverlet base: stringdiff --git a/packages/dsh-tauri/src/host/storage/index.test.ts b/packages/dsh-tauri/src/host/storage/index.test.tsindex 12a9fd0d..ce2eac7b 100644--- a/packages/dsh-tauri/src/host/storage/index.test.ts+++ b/packages/dsh-tauri/src/host/storage/index.test.ts@@ -6,7 +6,7 @@ import { randomUUID } from 'node:crypto'import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterEach, describe, expect, it, vi } from 'vitest'-import { createAtomicFsStorage, writeAtomic } from './index'+import { createAtomicFsStorage, writeAtomic } from '.'/** 每个用例独立的临时目录,避免跨用例污染。 */function tempDir(): string {@@ -96,7 +96,7 @@ describe('原子写 EPERM 锁竞争重试', () => {})// 从被 mock 的模块重新导入被测对象,确保其内部引用同一 rename。vi.resetModules()- const { writeAtomic: writeAtomicRetry } = await import('./index')+ const { writeAtomic: writeAtomicRetry } = await import('.')await expect(writeAtomicRetry(target, 'finally-ok')).resolves.toBeUndefined()await expect(@@ -120,7 +120,7 @@ describe('原子写 EPERM 锁竞争重试', () => {}})vi.resetModules()- const { writeAtomic: writeAtomicFail } = await import('./index')+ const { writeAtomic: writeAtomicFail } = await import('.')await expect(writeAtomicFail(target, 'nope')).rejects.toMatchObject({ code: 'EPERM' })const { readdir } = await import('node:fs/promises')diff --git a/packages/dsh-tauri/src/host/utils/http.ts b/packages/dsh-tauri/src/host/utils/http.tsindex 321af2b6..b343090d 100644--- a/packages/dsh-tauri/src/host/utils/http.ts+++ b/packages/dsh-tauri/src/host/utils/http.ts@@ -10,10 +10,10 @@ import type { IncomingMessage, ServerResponse } from 'node:http'* - 请求体超限即 413,解析失败 400,绝不静默接受。*/-import type { ConnectionGate, JsonBody, RouteFunction, RouteHandler } from '../types/index.js'+import type { ConnectionGate, JsonBody, RouteFunction, RouteHandler } from '../types'import { Buffer } from 'node:buffer'-export type { ConnectionGate, JsonBody, RouteFunction, RouteHandler, RouteResult } from '../types/index.js'+export type { ConnectionGate, JsonBody, RouteFunction, RouteHandler, RouteResult } from '../types'export class HttpError extends Error {constructor(message: string, readonly statusCode: number) {diff --git a/packages/dsh-tauri/src/index.ts b/packages/dsh-tauri/src/index.tsindex f5874608..269caa0d 100644--- a/packages/dsh-tauri/src/index.ts+++ b/packages/dsh-tauri/src/index.ts@@ -13,11 +13,11 @@* 从 `dsh-tauri/client` 导入共享工具(compat/store/http/lifecycle/CssRender)。*/-export { apply } from './host/apply.js'-export * from './host/service/open.js'-export * from './host/storage/index.js'-export * from './host/types/index.js'-export * from './host/utils/http.js'+export { apply } from './host/apply'+export * from './host/service/open'+export * from './host/storage'+export * from './host/types'+export * from './host/utils/http'export type { Context } from '@deepseek-ai/cordis'export type { AgentHandle, ModelSelection } from '@deepseek-ai/dsh-agent'export type { ContentBlock, MessageSource, UserMessage } from '@deepseek-ai/dsh-llm'