dsh-wsl-workspace 0.3.0 → 0.3.2
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/README.de.md +3 -0
- package/README.es.md +3 -0
- package/README.fr.md +3 -0
- package/README.ja.md +3 -0
- package/README.ko.md +3 -0
- package/README.md +12 -0
- package/README.pt.md +3 -0
- package/README.ru.md +3 -0
- package/README.zh.md +3 -0
- package/TESTING.md +103 -0
- package/lib/fs.js +1 -1
- package/lib/index.js +351 -1
- package/lib/index.js.map +1 -1
- package/lib/shell.js +382 -382
- package/lib/wsl-C5_mxGPM.js +227 -227
- package/lib/wsl-credentials-BI4v5TNZ.js +108 -108
- package/package.json +2 -1
- package/src/host/wsl-skills.ts +430 -0
- package/src/index.ts +15 -0
- package/lib/paths-BDE1NVOv.js +0 -120
- package/lib/paths-BDE1NVOv.js.map +0 -1
- package/lib/wsl-DdNPGaPo.js +0 -1019
- package/lib/wsl-DdNPGaPo.js.map +0 -1
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/host/variants.ts","../src/index.ts"],"sourcesContent":["/**\r\n * WSL preset-variant generator. For every healthy source preset the roster\r\n * supplies, a `wsl-<id>` variant is materialized under the roster's user\r\n * root: the source composition with its shell/filesystem world replaced by\r\n * the WSL providers, so any mode (standard, minimal, code, cordis, user\r\n * presets) can run on top of a WSL execution world. The execution world is\r\n * therefore orthogonal to the mode instead of a mode itself.\r\n *\r\n * The transformation is text-level on the top-level rows of the composition\r\n * (the shape all shipped presets share), with surgical edits for the known\r\n * special groups; unknown shapes are kept verbatim where possible.\r\n * @module dsh-wsl-workspace/host/variants\r\n */\r\n\r\n/** Top-level rows that name the execution world and are replaced by the variant's own. */\r\nconst WORLD_ROWS = new Set(['tool-bash', 'tool-pwsh', 'tool-fs', 'tool-fs-search', 'str-replace-editor', 'filesystem', 'persistent-shell', 'custom-bash', 'bootstrap-filesystem'])\r\n\r\n/** The injected WSL world group: providers + the bash/fs consumers, entry-local. */\r\nfunction wslWorldGroup(shellPath: string, fsPath: string, includeEditor: boolean): string {\r\n return [\r\n '# ── WSL execution world (dsh-wsl-workspace variant) ─────────────────────',\r\n '# The shell and fs services are provided entry-locally (the isolate',\r\n '# realm); host services (tools registry, shell-env, jobs) fall through.',\r\n '# tool-fs-search is intentionally absent: the packaged ripgrep runs on',\r\n '# the Windows host and cannot open Linux paths; WSL sessions search with',\r\n '# shell tools instead.',\r\n '- id: wsl-world',\r\n \" name: cordis:group\",\r\n ' group: true',\r\n ' isolate:',\r\n ' shell: true',\r\n ' fs: true',\r\n ' config:',\r\n ` - id: shell-wsl`,\r\n ` name: '${shellPath.replace(/'/g, \"''\")}'`,\r\n ' - id: fs-wsl',\r\n ` name: '${fsPath.replace(/'/g, \"''\")}'`,\r\n ' - id: tool-bash',\r\n \" name: '@deepseek-ai/dsh-tool-bash'\",\r\n ' - id: tool-fs',\r\n \" name: '@deepseek-ai/dsh-tool-fs'\",\r\n // The editor resolves through this entry-local WSL fs. Older editor builds\r\n // pass no cwd, so the provider inherits it from the current tool execution.\r\n // Anchored-family presets require this name during bootstrap.\r\n ...(includeEditor\r\n ? [\r\n ' - id: str-replace-editor',\r\n \" name: '@deepseek-ai/dsh-tool-str-replace-editor'\",\r\n ' config:',\r\n ' maxOutputChars: 16000',\r\n ]\r\n : []),\r\n '',\r\n ].join('\\n')\r\n}\r\n\r\n/** The sentence appended to a standard-like persona when the variant runs in WSL. */\r\nconst PERSONA_APPEND = ' Your working directory {{cwd}} is inside a WSL (Windows Subsystem for Linux) distribution: the bash tool and the file read/write/edit tools use Linux paths, and the Windows filesystem is reachable as /mnt/<drive> for file migration.'\r\n\r\n/** The top-level rows of one composition, as (startLine, endLineExclusive) spans. */\r\nfunction topLevelSpans(lines: readonly string[]): { start: number; end: number }[] {\r\n const spans: { start: number; end: number }[] = []\r\n let start = -1\r\n for (let index = 0; index < lines.length; index++) {\r\n if (lines[index]?.startsWith('- id: ') === true) {\r\n if (start >= 0) spans.push({ start, end: index })\r\n start = index\r\n }\r\n }\r\n if (start >= 0) spans.push({ start, end: lines.length })\r\n return spans\r\n}\r\n\r\n/** The row id of a top-level span, or undefined when the first line is malformed. */\r\nfunction spanId(lines: readonly string[], span: { start: number; end: number }): string | undefined {\r\n return /^- id: ([A-Za-z0-9_.-]+)/.exec(lines[span.start] ?? '')?.[1]\r\n}\r\n\r\n/** Whether a top-level span is a `persona` row with an appendable folded text. */\r\nfunction appendablePersona(lines: readonly string[], span: { start: number; end: number }): boolean {\r\n const block = lines.slice(span.start, span.end).join('\\n')\r\n if (!block.includes('complete: true') && /text: [>|-]/.test(block)) {\r\n // Append only when the folded text actually has content lines.\r\n const textLine = block.split('\\n').find(line => /^(\\s*)text: [>|-]/.test(line))\r\n if (textLine !== undefined) {\r\n const indent = /^(\\s*)/.exec(textLine)?.[1]?.length ?? 0\r\n return block.split('\\n').some(line => line.length > indent && /^\\s+/.test(line) && !line.includes(':'))\r\n }\r\n }\r\n return false\r\n}\r\n\r\n/** Append the WSL sentence to a persona row's folded text (in place of its last text line). */\r\nfunction appendPersona(lines: readonly string[], span: { start: number; end: number }): string[] {\r\n const block = lines.slice(span.start, span.end)\r\n const textIndex = block.findIndex(line => /^(\\s*)text: [>|-]/.test(line))\r\n if (textIndex < 0) return [...block]\r\n const indent = /^(\\s*)/.exec(block[textIndex] ?? '')?.[1]?.length ?? 0\r\n let lastText = -1\r\n for (let index = textIndex + 1; index < block.length; index++) {\r\n const line = block[index] ?? ''\r\n if (line.trim() === '') continue\r\n if (line.length > indent && /^\\s+/.test(line)) lastText = index\r\n }\r\n if (lastText < 0) return [...block]\r\n const updated = [...block]\r\n const textIndent = /^(\\s*)/.exec(block[lastText] ?? '')?.[1] ?? ' '\r\n updated.splice(lastText + 1, 0, `${textIndent}${PERSONA_APPEND}`)\r\n return updated\r\n}\r\n\r\n/**\r\n * Transform one source preset composition into its WSL variant: drop the\r\n * execution-world rows, keep everything else verbatim, and append the WSL\r\n * world group. The persistent-shell group is NOT re-added: it registers the\r\n * same `bash` tool name as the WSL world's `dsh-tool-bash`, and the tools\r\n * registry rejects duplicates within one preset layer — the whole variant\r\n * fails to mount and the session falls back to another preset. Its PTY\r\n * backend additionally cannot run on this plugin's Windows host\r\n * (`dsh-subprocess-local`: \"terminal inspection is unsupported on platform\r\n * win32\"), so the group could never spawn a shell here anyway. The WSL\r\n * world's ordinary `bash` tool covers command execution for every variant.\r\n * @param source - the source composition text.\r\n * @param shellPath - absolute path of the plugin's built WSL shell provider.\r\n * @param fsPath - absolute path of the plugin's built WSL fs provider.\r\n * @returns the variant composition text.\r\n */\r\nexport function transformPresetForWsl(source: string, shellPath: string, fsPath: string): string {\r\n const lines = source.split('\\n')\r\n const spans = topLevelSpans(lines)\r\n const kept: string[] = []\r\n let sawEditor = false\r\n let personaAppended = false\r\n for (const span of spans) {\r\n const id = spanId(lines, span)\r\n if (id === undefined) {\r\n kept.push(...lines.slice(span.start, span.end))\r\n continue\r\n }\r\n if (WORLD_ROWS.has(id)) continue\r\n if (id === 'persona' && !personaAppended && appendablePersona(lines, span)) {\r\n kept.push(...appendPersona(lines, span))\r\n personaAppended = true\r\n continue\r\n }\r\n kept.push(...lines.slice(span.start, span.end))\r\n if (id === 'str-replace-editor') sawEditor = true\r\n }\r\n if (source.includes('str-replace-editor')) sawEditor = true\r\n const result = [...kept]\r\n if (result.length > 0 && result[result.length - 1] !== '') result.push('')\r\n result.push(wslWorldGroup(shellPath, fsPath, sawEditor))\r\n return result.join('\\n').replace(/\\n{3,}/g, '\\n\\n').replace(/\\n+$/, '\\n')\r\n}\r\n\r\n/** Whether an id is one of this plugin's own preset directories. */\r\nexport function isWslVariantId(id: string): boolean {\r\n return id === 'wsl' || /^wsl-[a-z0-9-]+$/.test(id)\r\n}\r\n\r\n/** The variant id for one source preset id. */\r\nexport function variantIdFor(sourceId: string): string {\r\n return `wsl-${sourceId.toLowerCase()}`\r\n}\r\n","/**\r\n * Host half of dsh-wsl-workspace. Three responsibilities:\r\n *\r\n * 1. Materialize a `wsl-<mode>` variant for every healthy roster preset\r\n * under `<dshHome>/.agent-presets/` (the roster's auto-scanned user\r\n * root), so the WSL execution world — `shell-wsl` + `fs-wsl` behind one\r\n * entry-local realm, with `tool-bash`/`tool-fs` consumers — composes with\r\n * ANY mode instead of being a mode itself; the legacy standalone `wsl`\r\n * preset directory and stale variants are removed on boot. The preset\r\n * rows name THIS package's built lib files by absolute path, which the\r\n * preset mount resolves to `file:` URLs without relying on bare specifier\r\n * resolution from the preset's home directory.\r\n *\r\n * 2. Serve the browser dialog's data route (`/wsl-workspace/api`):\r\n * distribution discovery, one-level directory listing, path checks, and\r\n * the per-workspace username store — all over the 9P UNC share.\r\n * Loopback-only, matching the sensitivity of the privileged configuration\r\n * surface.\r\n *\r\n * 3. Contribute the per-session `DSH_WSL_DISTRO` managed-env fact so the WSL\r\n * shell executor can resolve a plain Linux `workdir` to the calling\r\n * session's distribution.\r\n * @module dsh-wsl-workspace\r\n */\r\n\r\nimport { Context } from '@deepseek-ai/cordis'\r\nimport z from '@deepseek-ai/schemastery'\r\nimport { cpSync, existsSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'\r\nimport { fileURLToPath } from 'node:url'\r\nimport { dirname, join } from 'node:path'\r\nimport type { IncomingMessage, ServerResponse } from 'node:http'\r\nimport { homedir } from 'node:os'\r\nimport { joinUnc, mntToWindowsPath, normalizeLinuxPath, isAbsoluteLinuxPath, isValidWslUsername, parseWslUnc } from './shared/paths.ts'\r\nimport { canonicalWslUnc, getWindowsWorkspace, getWorkspaceUsername, listWorkspaceKeys, registerWindowsWorkspace, setWorkspaceUsername } from './shared/wsl-credentials.ts'\r\nimport { defaultDistro, listDistros } from './shared/wsl.ts'\r\nimport { isWslVariantId, transformPresetForWsl, variantIdFor } from './host/variants.ts'\r\n\r\n/** The HTTP route this plugin serves (a relative, same-origin path). */\r\nexport const DEFAULT_ROUTE = '/wsl-workspace/api'\r\n\r\n/**\r\n * Bilingual display labels for the shipped source modes, matching the app's\r\n * own built-in copy in each language — note the `code` preset is \"PTC 模式\"\r\n * in the Chinese copy but \"Code mode\" in English. The DSH picker localizes\r\n * only the four built-in ids itself; `wsl-*` variant ids render the\r\n * preset.yml text verbatim, so the plugin writes one bilingual string so\r\n * both locales can identify each variant. Custom presets keep their own\r\n * name.\r\n */\r\nconst MODE_DISPLAY_LABELS: Readonly<Record<string, { en: string; zh: string }>> = {\r\n standard: { en: 'Standard mode', zh: '标准模式' },\r\n code: { en: 'Code mode', zh: 'PTC 模式' },\r\n minimal: { en: 'Minimal mode', zh: '极简模式' },\r\n cordis: { en: 'Creator mode', zh: '创造模式' },\r\n}\r\n\r\n/**\r\n * Quote a value as a single-line YAML single-quoted scalar. Plain scalars\r\n * cannot contain `: ` (colon + space), which plain English sentences do —\r\n * written unquoted they make the whole preset.yml unparsable, dropping the\r\n * name, description and order together.\r\n */\r\nfunction yamlScalar(value: string): string {\r\n return `'${value.replace(/'/g, \"''\")}'`\r\n}\r\n\r\n/** The variant name for one shipped mode (bilingual) or a custom preset. */\r\nfunction variantName(presetId: string, sourceName: string): string {\r\n const labels = MODE_DISPLAY_LABELS[presetId]\r\n return labels === undefined ? `WSL · ${sourceName}` : `WSL · ${labels.en}(${labels.zh})`\r\n}\r\n\r\n/** The variant description for one shipped mode (bilingual) or a custom preset. */\r\nfunction variantDescription(presetId: string): string {\r\n const labels = MODE_DISPLAY_LABELS[presetId]\r\n const display = labels === undefined ? presetId : `${labels.en}(${labels.zh})`\r\n return `WSL execution world for ${display}: bash and file tools run inside the WSL distribution.`\r\n}\r\n\r\n/** Plugin config. */\r\nexport interface Config {\r\n /** The route under which the dialog data API is served. */\r\n route?: string\r\n}\r\n\r\n/** The shape after schemastery applied the defaults. */\r\ntype ResolvedConfig = Required<Config>\r\n\r\n/** The `webServer.register` route contract this plugin consumes. */\r\ninterface WebServerRoute {\r\n kind: 'exact'\r\n path: string\r\n handler(req: IncomingMessage, res: ServerResponse): Promise<void>\r\n}\r\n\r\ninterface WebServerService {\r\n register(route: WebServerRoute): () => void\r\n}\r\n\r\n/** The `ctx.shellEnv` registry face this plugin consumes (optional service). */\r\ninterface ShellEnvService {\r\n register(contributor: {\r\n name: string\r\n variables: Readonly<Record<string, { description: string }>>\r\n resolve(execution: {\r\n agent?: { session: { header: { cwd?: string } } }\r\n }): Readonly<Partial<Record<string, string>>>\r\n }): () => void\r\n}\r\n\r\n/** One directory entry the dialog lists. */\r\ninterface WslDirEntryWire {\r\n name: string\r\n kind: 'directory' | 'file' | 'other'\r\n}\r\n\r\n/** One directory level plus its breadcrumb ancestry. */\r\ninterface WslDirListingWire {\r\n path: string\r\n parent: string | null\r\n entries: WslDirEntryWire[]\r\n}\r\n\r\n/** The wire envelope every method answers with. */\r\ntype Envelope<T> = { ok: true; value: T } | { ok: false; error: string }\r\n\r\nconst MAX_BODY_BYTES = 1024 * 1024\r\n\r\n/** Valid WSL distribution names: one path-safe segment (no separators, no dot-dirs). */\r\nconst DISTRO_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]*$/\r\n\r\n/** The loopback hostnames the data route answers to (DNS-rebinding fence). */\r\nconst LOOPBACK_HOSTNAMES = new Set(['localhost', '127.0.0.1', '::1', '::ffff:127.0.0.1'])\r\n\r\n/** True when a socket address is loopback (any IPv4/IPv6 spelling). */\r\nfunction isLoopback(address: string | undefined): boolean {\r\n return address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1'\r\n}\r\n\r\n/** The hostname part of a `Host` header value (port and IPv6 brackets stripped). */\r\nfunction hostNameOf(host: string): string {\r\n if (host.startsWith('[')) {\r\n const end = host.indexOf(']')\r\n return end >= 0 ? host.slice(1, end) : host\r\n }\r\n return host.split(':')[0] ?? ''\r\n}\r\n\r\n/** True when the request's `Host` header names a loopback host. */\r\nfunction isLoopbackHost(host: string | undefined): boolean {\r\n return host !== undefined && LOOPBACK_HOSTNAMES.has(hostNameOf(host).toLowerCase())\r\n}\r\n\r\n/**\r\n * Validate a wire-supplied distribution name before it becomes a UNC segment:\r\n * an attacker-controlled segment containing separators or `..` would escape\r\n * the `\\\\wsl.localhost\\` share structure into arbitrary UNC paths.\r\n * @param value - the raw wire value.\r\n * @returns the validated distro name.\r\n */\r\nfunction requireDistro(value: unknown): string {\r\n if (typeof value !== 'string' || !DISTRO_PATTERN.test(value) || value === '.' || value === '..') {\r\n throw new Error('distro must be a valid WSL distribution name')\r\n }\r\n return value\r\n}\r\n\r\n/** Human text for an unknown rejection. */\r\nfunction messageOf(value: unknown): string {\r\n return value instanceof Error ? value.message : String(value)\r\n}\r\n\r\n/** Write one JSON envelope. */\r\nfunction json(res: ServerResponse, status: number, body: Envelope<unknown>): void {\r\n res.writeHead(status, {\r\n 'content-type': 'application/json; charset=utf-8',\r\n 'cache-control': 'no-store',\r\n 'x-content-type-options': 'nosniff',\r\n })\r\n res.end(JSON.stringify(body))\r\n}\r\n\r\n/** Collect and parse the request body, bounded. */\r\nasync function readBody(req: IncomingMessage): Promise<Record<string, unknown>> {\r\n const chunks: Buffer[] = []\r\n let size = 0\r\n for await (const chunk of req) {\r\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)\r\n size += buffer.length\r\n if (size > MAX_BODY_BYTES) throw new Error('request body is too large')\r\n chunks.push(buffer)\r\n }\r\n const parsed = JSON.parse(Buffer.concat(chunks).toString('utf8')) as unknown\r\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\r\n throw new Error('request body must be a JSON object')\r\n }\r\n return parsed as Record<string, unknown>\r\n}\r\n\r\n/** Normalize a Linux path for the wire (rejecting non-absolute input). */\r\nfunction requireLinuxPath(value: unknown, label: string): string {\r\n if (typeof value !== 'string' || !isAbsoluteLinuxPath(value)) {\r\n throw new Error(`${label} must be an absolute Linux path`)\r\n }\r\n return normalizeLinuxPath(value)\r\n}\r\n\r\n/** Validate a wire-supplied workspace path and return its canonical UNC form. */\r\nfunction requireWslUnc(value: unknown): string {\r\n if (typeof value !== 'string') throw new Error('path must be a string')\r\n const canonical = canonicalWslUnc(value)\r\n if (canonical === null) throw new Error('path must be a WSL UNC workspace path')\r\n return canonical\r\n}\r\n\r\n/**\r\n * Resolve one directory listing for the dialog. The 9P share (`\\\\wsl.localhost\\…`)\r\n * serves only the ext4 volume: `/mnt/<drive>` (drvfs) reads return Access\r\n * denied, so drvfs paths are read through their Windows drive spelling and\r\n * `/mnt` itself is synthesized from the drives present on the host.\r\n */\r\nfunction listWslDir(distro: string, linuxPath: string): WslDirListingWire {\r\n if (linuxPath === '/mnt') {\r\n const entries: WslDirEntryWire[] = []\r\n for (let i = 0; i < 26; i++) {\r\n const letter = String.fromCharCode(65 + i)\r\n try {\r\n const info = statSync(`${letter}:\\\\`)\r\n if (info.isDirectory()) entries.push({ name: letter.toLowerCase(), kind: 'directory' })\r\n } catch {\r\n // Absent drive: skip.\r\n }\r\n }\r\n return { path: '/mnt', parent: '/', entries }\r\n }\r\n const winPath = mntToWindowsPath(linuxPath)\r\n const readPath = winPath !== null ? winPath : joinUnc(distro, linuxPath)\r\n const dirents = readdirSync(readPath, { withFileTypes: true })\r\n const entries: WslDirEntryWire[] = dirents\r\n .slice(0, 1000)\r\n .map((dirent): WslDirEntryWire => {\r\n const kind: WslDirEntryWire['kind'] = dirent.isDirectory()\r\n ? 'directory'\r\n : dirent.isFile() ? 'file' : 'other'\r\n return { name: dirent.name, kind }\r\n })\r\n .sort((a, b) => {\r\n if (a.kind === 'directory' && b.kind !== 'directory') return -1\r\n if (a.kind !== 'directory' && b.kind === 'directory') return 1\r\n return a.name.localeCompare(b.name)\r\n })\r\n const parent = linuxPath === '/' ? null : linuxPath.split('/').slice(0, -1).join('/') || '/'\r\n return { path: linuxPath, parent, entries }\r\n}\r\n\r\n/** Route one method dispatch. */\r\nasync function dispatch(method: string, params: Record<string, unknown>): Promise<unknown> {\r\n switch (method) {\r\n case 'listDistros': {\r\n const distros = await listDistros()\r\n const fallback = await defaultDistro()\r\n if (fallback !== undefined && distros.includes(fallback)) {\r\n return [fallback, ...distros.filter(name => name !== fallback)]\r\n }\r\n return distros\r\n }\r\n case 'listDir': {\r\n const distro = requireDistro(params.distro)\r\n const path = requireLinuxPath(params.path, 'path')\r\n return listWslDir(distro, path)\r\n }\r\n case 'check': {\r\n const distro = requireDistro(params.distro)\r\n const path = requireLinuxPath(params.path, 'path')\r\n // drvfs paths (Access denied over 9P) are checked through their drive spelling.\r\n const winPath = mntToWindowsPath(path)\r\n const readPath = winPath !== null ? winPath : joinUnc(distro, path)\r\n try {\r\n const info = statSync(readPath)\r\n return { exists: true, isDirectory: info.isDirectory() }\r\n } catch {\r\n return { exists: false, isDirectory: false }\r\n }\r\n }\r\n case 'registerWindows': {\r\n // A `/mnt/<drive>` workspace registers under its Windows drive path\r\n // (the registry realpath/stats it, and 9P cannot serve drvfs) with the\r\n // distro stored for the per-session env contributor.\r\n const distro = requireDistro(params.distro)\r\n const linuxPath = requireLinuxPath(params.linuxPath, 'path')\r\n const winPath = mntToWindowsPath(linuxPath)\r\n if (winPath === null) throw new Error('registerWindows requires a /mnt/<drive> Linux path')\r\n const username = typeof params.username === 'string' ? params.username : undefined\r\n registerWindowsWorkspace(winPath, distro, username)\r\n return null\r\n }\r\n case 'listWorkspaces': {\r\n // Every registered WSL workspace key (UNC and Windows drive spellings):\r\n // the client uses the drive keys to recognize `/mnt` workspaces.\r\n return listWorkspaceKeys()\r\n }\r\n case 'setUser': {\r\n const path = requireWslUnc(params.path)\r\n const username = params.username\r\n if (username === undefined || username === '') {\r\n setWorkspaceUsername(path, undefined)\r\n } else {\r\n if (typeof username !== 'string' || !isValidWslUsername(username)) {\r\n throw new Error('username must match the Linux username pattern [A-Za-z_][A-Za-z0-9_.-]*')\r\n }\r\n setWorkspaceUsername(path, username)\r\n }\r\n return null\r\n }\r\n default:\r\n throw new Error(`unknown method \"${method}\"`)\r\n }\r\n}\r\n\r\n/** The `ctx.agentPresets` roster face this plugin consumes (optional service). */\r\ninterface AgentPresetsService {\r\n list(): Promise<{ id: string; broken?: string; path: string }[]>\r\n read(id: string): Promise<string>\r\n}\r\n\r\n/**\r\n * Publish a fully staged preset directory while preserving the last complete\r\n * variant if publication fails. Stable sibling names also let the next boot\r\n * recover an interrupted old-to-backup rename before doing new work.\r\n */\r\nfunction publishVariant(staging: string, dest: string): void {\r\n const previous = `${dest}.previous`\r\n if (!existsSync(dest) && existsSync(previous)) renameSync(previous, dest)\r\n if (existsSync(previous)) rmSync(previous, { recursive: true, force: true })\r\n if (existsSync(dest)) renameSync(dest, previous)\r\n try {\r\n renameSync(staging, dest)\r\n } catch (error) {\r\n if (!existsSync(dest) && existsSync(previous)) renameSync(previous, dest)\r\n throw error\r\n }\r\n rmSync(previous, { recursive: true, force: true })\r\n}\r\n\r\n/** Materialize one WSL variant per healthy source preset. */\r\nasync function materializeVariants(\r\n agentPresets: AgentPresetsService,\r\n dshHome: string,\r\n shellPath: string,\r\n fsPath: string,\r\n): Promise<void> {\r\n const presets = await agentPresets.list()\r\n const userRoot = join(dshHome, '.agent-presets')\r\n const generated = new Set<string>()\r\n for (const preset of presets) {\r\n if (preset.broken !== undefined) continue\r\n if (isWslVariantId(preset.id)) continue\r\n const variantId = variantIdFor(preset.id)\r\n const source = await agentPresets.read(preset.id)\r\n const transformed = transformPresetForWsl(source, shellPath, fsPath)\r\n const dir = join(userRoot, variantId)\r\n const staging = `${dir}.staging`\r\n rmSync(staging, { recursive: true, force: true })\r\n // A preset directory is an opaque, self-contained plugin unit. Mirror it\r\n // without interpreting local code or asset names, then overwrite only the\r\n // two files owned by this generator.\r\n cpSync(dirname(preset.path), staging, { recursive: true, force: true })\r\n writeFileSync(join(staging, 'agent.cordis.yml'), transformed, 'utf8')\r\n const labels = MODE_DISPLAY_LABELS[preset.id]\r\n let name = variantName(preset.id, preset.id)\r\n let orderLine = ''\r\n try {\r\n const meta = readFileSync(join(dirname(preset.path), 'preset.yml'), 'utf8')\r\n if (labels === undefined) {\r\n // Custom presets keep their own display name; shipped modes use the\r\n // bilingual labels above so both locales can identify the variant.\r\n const match = /^name:\\s*(.+)$/m.exec(meta)\r\n if (match?.[1] !== undefined && match[1].trim() !== '') {\r\n name = variantName(preset.id, match[1].trim())\r\n }\r\n }\r\n // Inherit the source's declared order so the WSL variants line up with\r\n // the local modes in the roster (standard, PTC, minimal, cordis).\r\n const orderMatch = /^order:\\s*(\\d+)\\s*$/m.exec(meta)\r\n if (orderMatch?.[1] !== undefined) orderLine = `order: ${orderMatch[1]}\\n`\r\n } catch {\r\n // Absent or unreadable display metadata falls back to the id-based name.\r\n }\r\n writeFileSync(\r\n join(staging, 'preset.yml'),\r\n `name: ${yamlScalar(name)}\\n`\r\n + orderLine\r\n + `description: ${yamlScalar(variantDescription(preset.id))}\\n`,\r\n 'utf8',\r\n )\r\n publishVariant(staging, dir)\r\n generated.add(variantId)\r\n }\r\n for (const entry of readdirSync(userRoot, { withFileTypes: true })) {\r\n if (!entry.isDirectory()) continue\r\n if (entry.name === 'wsl') {\r\n // The legacy standalone WSL mode: folded into the variants above.\r\n rmSync(join(userRoot, entry.name), { recursive: true, force: true })\r\n continue\r\n }\r\n if (!/^wsl-[a-z0-9-]+$/.test(entry.name)) continue\r\n if (!generated.has(entry.name)) rmSync(join(userRoot, entry.name), { recursive: true, force: true })\r\n }\r\n}\r\n\r\n/** Function-plugin plugin contract. */\r\nexport const name = 'dsh-wsl-workspace'\r\n\r\n/** Required services. */\r\nexport const inject = ['webServer']\r\n\r\n/** Validated plugin config (schemastery applied the defaults). */\r\nexport const Config: z<Config> = z.object({\r\n route: z.string().default(DEFAULT_ROUTE),\r\n})\r\n\r\n/**\r\n * Apply the host half: materialize a `wsl-<mode>` variant for every healthy\r\n * roster preset, register the data route, and\r\n * contribute the per-session `DSH_WSL_DISTRO` managed-env fact so the WSL\r\n * shell executor can resolve a plain Linux `workdir` to the calling\r\n * session's distribution.\r\n * @param ctx - the host plugin context.\r\n * @param config - the validated configuration.\r\n */\r\nexport function apply(ctx: Context, config: Config): void {\r\n const resolved = config as ResolvedConfig\r\n const dshHome = process.env.DSH_HOME ?? join(homedir(), '.dsh')\r\n const packageRoot = fileURLToPath(new URL('..', import.meta.url))\r\n const shellPath = join(packageRoot, 'lib', 'shell.js').replace(/\\\\/g, '/')\r\n const fsPath = join(packageRoot, 'lib', 'fs.js').replace(/\\\\/g, '/')\r\n\r\n const agentPresets = ctx.get('agentPresets') as unknown as AgentPresetsService | undefined\r\n if (agentPresets !== undefined) {\r\n ctx.effect(() => {\r\n void materializeVariants(agentPresets, dshHome, shellPath, fsPath).catch((error) => {\r\n // Variant generation is best-effort over a live roster: a missing or\r\n // unreadable source preset must not take the whole plugin down, but\r\n // the failure is surfaced loudly rather than hidden.\r\n console.error(`dsh-wsl-workspace: WSL preset-variant generation failed: ${messageOf(error)}`)\r\n })\r\n return () => {}\r\n }, 'dsh-wsl-workspace: WSL preset variants')\r\n }\r\n\r\n const shellEnv = ctx.get('shellEnv') as unknown as ShellEnvService | undefined\r\n if (shellEnv !== undefined) {\r\n ctx.effect(() => shellEnv.register({\r\n name: 'wsl-workspace-distro',\r\n variables: {\r\n DSH_WSL_DISTRO: {\r\n description: 'The WSL distribution of the calling session workspace, when the session cwd is a WSL UNC path.',\r\n },\r\n DSH_WSL_USER: {\r\n description: 'The Linux user of the calling session workspace, when the workspace has one configured.',\r\n },\r\n },\r\n resolve(execution) {\r\n const cwd = execution.agent?.session.header.cwd\r\n const unc = cwd === undefined ? null : parseWslUnc(cwd)\r\n if (unc !== null) {\r\n const username = getWorkspaceUsername(joinUnc(unc.distro, unc.linuxPath))\r\n return username === undefined || username === ''\r\n ? { DSH_WSL_DISTRO: unc.distro }\r\n : { DSH_WSL_DISTRO: unc.distro, DSH_WSL_USER: username }\r\n }\r\n // A Windows-drive cwd belongs to a `/mnt/<drive>` WSL workspace (9P\r\n // cannot serve drvfs, so those register under their drive path): the\r\n // stored distro drives `wsl.exe -d` for bash.\r\n if (cwd !== undefined && /^[A-Za-z]:[\\\\/]/.test(cwd)) {\r\n const entry = getWindowsWorkspace(cwd)\r\n if (entry !== undefined && entry.distro !== undefined && entry.distro !== '') {\r\n return entry.username === undefined || entry.username === ''\r\n ? { DSH_WSL_DISTRO: entry.distro }\r\n : { DSH_WSL_DISTRO: entry.distro, DSH_WSL_USER: entry.username }\r\n }\r\n }\r\n return {}\r\n },\r\n }), 'dsh-wsl-workspace: per-session distro env fact')\r\n }\r\n\r\n const webServer = ctx.get('webServer') as unknown as WebServerService\r\n ctx.effect(() => webServer.register({\r\n kind: 'exact',\r\n path: resolved.route,\r\n handler: async (req, res) => {\r\n if (!isLoopback(req.socket.remoteAddress) || !isLoopbackHost(req.headers.host)) {\r\n json(res, 403, { ok: false, error: 'loopback-only' })\r\n return\r\n }\r\n if (req.method !== 'POST') {\r\n json(res, 405, { ok: false, error: 'method not allowed' })\r\n return\r\n }\r\n let body: Record<string, unknown>\r\n try {\r\n body = await readBody(req)\r\n } catch (error) {\r\n json(res, 400, { ok: false, error: messageOf(error) })\r\n return\r\n }\r\n const method = typeof body.method === 'string' ? body.method : ''\r\n const params = body.params === undefined ? {} : body.params\r\n if (params === null || typeof params !== 'object' || Array.isArray(params)) {\r\n json(res, 400, { ok: false, error: 'params must be an object' })\r\n return\r\n }\r\n try {\r\n const value = await dispatch(method, params as Record<string, unknown>)\r\n json(res, 200, { ok: true, value })\r\n } catch (error) {\r\n json(res, 200, { ok: false, error: messageOf(error) })\r\n }\r\n },\r\n }), 'dsh-wsl-workspace: dialog data route')\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,aAAa,IAAI,IAAI;CAAC;CAAa;CAAa;CAAW;CAAkB;CAAsB;CAAc;CAAoB;CAAe;AAAsB,CAAC;;AAGjL,SAAS,cAAc,WAAmB,QAAgB,eAAgC;CACxF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB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AAC;IAC/D;GACF;GACA,IAAI;IAEF,KAAK,KAAK,KAAK;KAAE,IAAI;KAAM,OAAA,MADP,SAAS,QAAQ,MAAiC;IACrC,CAAC;GACpC,SAAS,OAAO;IACd,KAAK,KAAK,KAAK;KAAE,IAAI;KAAO,OAAO,UAAU,KAAK;IAAE,CAAC;GACvD;EACF;CACF,CAAC,GAAG,sCAAsC;AAC5C"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["joinWindowsPath"],"sources":["../src/host/variants.ts","../src/host/wsl-skills.ts","../src/index.ts"],"sourcesContent":["/**\r\n * WSL preset-variant generator. For every healthy source preset the roster\r\n * supplies, a `wsl-<id>` variant is materialized under the roster's user\r\n * root: the source composition with its shell/filesystem world replaced by\r\n * the WSL providers, so any mode (standard, minimal, code, cordis, user\r\n * presets) can run on top of a WSL execution world. The execution world is\r\n * therefore orthogonal to the mode instead of a mode itself.\r\n *\r\n * The transformation is text-level on the top-level rows of the composition\r\n * (the shape all shipped presets share), with surgical edits for the known\r\n * special groups; unknown shapes are kept verbatim where possible.\r\n * @module dsh-wsl-workspace/host/variants\r\n */\r\n\r\n/** Top-level rows that name the execution world and are replaced by the variant's own. */\r\nconst WORLD_ROWS = new Set(['tool-bash', 'tool-pwsh', 'tool-fs', 'tool-fs-search', 'str-replace-editor', 'filesystem', 'persistent-shell', 'custom-bash', 'bootstrap-filesystem'])\r\n\r\n/** The injected WSL world group: providers + the bash/fs consumers, entry-local. */\r\nfunction wslWorldGroup(shellPath: string, fsPath: string, includeEditor: boolean): string {\r\n return [\r\n '# ── WSL execution world (dsh-wsl-workspace variant) ─────────────────────',\r\n '# The shell and fs services are provided entry-locally (the isolate',\r\n '# realm); host services (tools registry, shell-env, jobs) fall through.',\r\n '# tool-fs-search is intentionally absent: the packaged ripgrep runs on',\r\n '# the Windows host and cannot open Linux paths; WSL sessions search with',\r\n '# shell tools instead.',\r\n '- id: wsl-world',\r\n \" name: cordis:group\",\r\n ' group: true',\r\n ' isolate:',\r\n ' shell: true',\r\n ' fs: true',\r\n ' config:',\r\n ` - id: shell-wsl`,\r\n ` name: '${shellPath.replace(/'/g, \"''\")}'`,\r\n ' - id: fs-wsl',\r\n ` name: '${fsPath.replace(/'/g, \"''\")}'`,\r\n ' - id: tool-bash',\r\n \" name: '@deepseek-ai/dsh-tool-bash'\",\r\n ' - id: tool-fs',\r\n \" name: '@deepseek-ai/dsh-tool-fs'\",\r\n // The editor resolves through this entry-local WSL fs. Older editor builds\r\n // pass no cwd, so the provider inherits it from the current tool execution.\r\n // Anchored-family presets require this name during bootstrap.\r\n ...(includeEditor\r\n ? [\r\n ' - id: str-replace-editor',\r\n \" name: '@deepseek-ai/dsh-tool-str-replace-editor'\",\r\n ' config:',\r\n ' maxOutputChars: 16000',\r\n ]\r\n : []),\r\n '',\r\n ].join('\\n')\r\n}\r\n\r\n/** The sentence appended to a standard-like persona when the variant runs in WSL. */\r\nconst PERSONA_APPEND = ' Your working directory {{cwd}} is inside a WSL (Windows Subsystem for Linux) distribution: the bash tool and the file read/write/edit tools use Linux paths, and the Windows filesystem is reachable as /mnt/<drive> for file migration.'\r\n\r\n/** The top-level rows of one composition, as (startLine, endLineExclusive) spans. */\r\nfunction topLevelSpans(lines: readonly string[]): { start: number; end: number }[] {\r\n const spans: { start: number; end: number }[] = []\r\n let start = -1\r\n for (let index = 0; index < lines.length; index++) {\r\n if (lines[index]?.startsWith('- id: ') === true) {\r\n if (start >= 0) spans.push({ start, end: index })\r\n start = index\r\n }\r\n }\r\n if (start >= 0) spans.push({ start, end: lines.length })\r\n return spans\r\n}\r\n\r\n/** The row id of a top-level span, or undefined when the first line is malformed. */\r\nfunction spanId(lines: readonly string[], span: { start: number; end: number }): string | undefined {\r\n return /^- id: ([A-Za-z0-9_.-]+)/.exec(lines[span.start] ?? '')?.[1]\r\n}\r\n\r\n/** Whether a top-level span is a `persona` row with an appendable folded text. */\r\nfunction appendablePersona(lines: readonly string[], span: { start: number; end: number }): boolean {\r\n const block = lines.slice(span.start, span.end).join('\\n')\r\n if (!block.includes('complete: true') && /text: [>|-]/.test(block)) {\r\n // Append only when the folded text actually has content lines.\r\n const textLine = block.split('\\n').find(line => /^(\\s*)text: [>|-]/.test(line))\r\n if (textLine !== undefined) {\r\n const indent = /^(\\s*)/.exec(textLine)?.[1]?.length ?? 0\r\n return block.split('\\n').some(line => line.length > indent && /^\\s+/.test(line) && !line.includes(':'))\r\n }\r\n }\r\n return false\r\n}\r\n\r\n/** Append the WSL sentence to a persona row's folded text (in place of its last text line). */\r\nfunction appendPersona(lines: readonly string[], span: { start: number; end: number }): string[] {\r\n const block = lines.slice(span.start, span.end)\r\n const textIndex = block.findIndex(line => /^(\\s*)text: [>|-]/.test(line))\r\n if (textIndex < 0) return [...block]\r\n const indent = /^(\\s*)/.exec(block[textIndex] ?? '')?.[1]?.length ?? 0\r\n let lastText = -1\r\n for (let index = textIndex + 1; index < block.length; index++) {\r\n const line = block[index] ?? ''\r\n if (line.trim() === '') continue\r\n if (line.length > indent && /^\\s+/.test(line)) lastText = index\r\n }\r\n if (lastText < 0) return [...block]\r\n const updated = [...block]\r\n const textIndent = /^(\\s*)/.exec(block[lastText] ?? '')?.[1] ?? ' '\r\n updated.splice(lastText + 1, 0, `${textIndent}${PERSONA_APPEND}`)\r\n return updated\r\n}\r\n\r\n/**\r\n * Transform one source preset composition into its WSL variant: drop the\r\n * execution-world rows, keep everything else verbatim, and append the WSL\r\n * world group. The persistent-shell group is NOT re-added: it registers the\r\n * same `bash` tool name as the WSL world's `dsh-tool-bash`, and the tools\r\n * registry rejects duplicates within one preset layer — the whole variant\r\n * fails to mount and the session falls back to another preset. Its PTY\r\n * backend additionally cannot run on this plugin's Windows host\r\n * (`dsh-subprocess-local`: \"terminal inspection is unsupported on platform\r\n * win32\"), so the group could never spawn a shell here anyway. The WSL\r\n * world's ordinary `bash` tool covers command execution for every variant.\r\n * @param source - the source composition text.\r\n * @param shellPath - absolute path of the plugin's built WSL shell provider.\r\n * @param fsPath - absolute path of the plugin's built WSL fs provider.\r\n * @returns the variant composition text.\r\n */\r\nexport function transformPresetForWsl(source: string, shellPath: string, fsPath: string): string {\r\n const lines = source.split('\\n')\r\n const spans = topLevelSpans(lines)\r\n const kept: string[] = []\r\n let sawEditor = false\r\n let personaAppended = false\r\n for (const span of spans) {\r\n const id = spanId(lines, span)\r\n if (id === undefined) {\r\n kept.push(...lines.slice(span.start, span.end))\r\n continue\r\n }\r\n if (WORLD_ROWS.has(id)) continue\r\n if (id === 'persona' && !personaAppended && appendablePersona(lines, span)) {\r\n kept.push(...appendPersona(lines, span))\r\n personaAppended = true\r\n continue\r\n }\r\n kept.push(...lines.slice(span.start, span.end))\r\n if (id === 'str-replace-editor') sawEditor = true\r\n }\r\n if (source.includes('str-replace-editor')) sawEditor = true\r\n const result = [...kept]\r\n if (result.length > 0 && result[result.length - 1] !== '') result.push('')\r\n result.push(wslWorldGroup(shellPath, fsPath, sawEditor))\r\n return result.join('\\n').replace(/\\n{3,}/g, '\\n\\n').replace(/\\n+$/, '\\n')\r\n}\r\n\r\n/** Whether an id is one of this plugin's own preset directories. */\r\nexport function isWslVariantId(id: string): boolean {\r\n return id === 'wsl' || /^wsl-[a-z0-9-]+$/.test(id)\r\n}\r\n\r\n/** The variant id for one source preset id. */\r\nexport function variantIdFor(sourceId: string): string {\r\n return `wsl-${sourceId.toLowerCase()}`\r\n}\r\n","/**\n * WSL workspace skill provider (host half).\n *\n * DSH's shipped skill-filesystem provider scans only the session cwd's\n * project root (the nearest `.git` ancestor) for `.dsh/skills` / `.agents/skills`\n * and never descends into nested projects. A WSL workspace whose project\n * folders live below the registered workspace root therefore shows an empty\n * skill catalog, even though the same layout works when the session cwd is\n * the project folder itself (issue #10).\n *\n * This provider mirrors the host's discovery rules for WSL UNC session\n * workspaces: it starts at the session cwd's nearest `.git` ancestor (the\n * host's project-root rule; the cwd itself when no ancestor has a `.git`\n * marker), then walks that root (depth- and budget-bounded), collects every\n * `.dsh/skills` and `.agents/skills` directory it finds — including nested\n * projects — and publishes their skills with the same\n * project ranks and sources the host uses, so precedence and duplicate\n * resolution behave identically. Non-WSL lookups return nothing and leave\n * the host's own providers untouched.\n *\n * All filesystem reads go through `node:fs` against the `\\\\wsl.localhost\\…`\n * 9P share (the same substrate `WslFileSystem` uses); an injectable IO face\n * keeps the discovery logic unit-testable without a live distro.\n *\n * @module dsh-wsl-workspace/host/wsl-skills\n */\n\nimport { readdir, readFile, stat } from 'node:fs/promises'\nimport type { Dirent } from 'node:fs'\nimport { join as joinWindowsPath, posix } from 'node:path'\nimport { joinUnc, parseWslUnc } from '../shared/paths.ts'\n\n/** Project ranks copied from @deepseek-ai/dsh-skill-filesystem so WSL and host entries interleave identically. */\nconst PROJECT_DSH_RANK = 100\nconst PROJECT_AGENTS_RANK = 200\n\n/** How many directory levels below the workspace root are scanned. */\nconst MAX_SCAN_DEPTH = 4\n/** Maximum distinct skill directories published per lookup. */\nconst MAX_SKILL_ROOTS = 64\n/** Maximum directories visited per lookup (an absolute blast-radius cap). */\nconst MAX_VISITED_DIRECTORIES = 4096\n/** How many parent levels above the session cwd are searched for a `.git` project marker. */\nconst MAX_ANCESTOR_WALK = 64\n\n/** Kebab-case skill names, matching the host grammar. */\nconst SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/\n\n/** Directory names that never contain project skill roots (safe to prune while walking). */\nconst PRUNED_DIRECTORY_NAMES = new Set([\n '.git', '.hg', '.svn', '.bzr', 'node_modules', '.venv', 'venv', '.tox',\n '.pants.d', '.next', '.nuxt', 'dist', 'build', 'out', 'coverage',\n '__pycache__', '.mypy_cache', '.pytest_cache', '.ruff_cache', '.cache',\n '.idea', '.vscode', '.serverless', '.terraform', '.yarn', '.pnpm-store',\n])\n\n/** One `name: value` frontmatter line pair the parser understands. */\ninterface ParsedSkill {\n name: string\n description: string\n whenToUse?: string\n invocation: { modelInvocable: boolean; userInvocable: boolean }\n content: string\n}\n\n/** The provider's minimal skill-candidate contract (mirrors @deepseek-ai/dsh-skill). */\nexport interface WslSkillCandidate {\n readonly name: string\n readonly description: string\n readonly whenToUse?: string\n readonly invocation: { modelInvocable: boolean; userInvocable: boolean }\n readonly source: string\n readonly provider: string\n readonly rank: number\n readonly locator: { path: string; directory: string }\n readonly path: string\n}\n\n/** The provider's minimal skill-definition contract (candidate plus body). */\nexport interface WslSkillDefinition extends WslSkillCandidate {\n readonly content: string\n}\n\n/** Lookup options the registry passes to `list`/`get`. */\nexport interface WslSkillLookupOptions {\n readonly cwd?: string\n readonly signal?: AbortSignal\n}\n\n/** Registration-scoped lifecycle face passed to the provider constructor. */\nexport interface WslSkillProviderControl {\n readonly signal: AbortSignal\n readonly invalidate: () => void\n}\n\n/** The `ctx.skills` registry face this provider registers on (optional service). */\nexport interface WslSkillsRegistryFace {\n registerProvider(create: (control: WslSkillProviderControl) => {\n readonly name: string\n list(options: WslSkillLookupOptions): Promise<unknown>\n get(candidate: WslSkillCandidate, options: WslSkillLookupOptions): Promise<unknown>\n }): () => void\n}\n\n/** Injectable filesystem face (defaults to node:fs/promises on the real 9P share). */\nexport interface WslSkillIo {\n readdir(path: string, options: { withFileTypes: true }): Promise<Dirent[]>\n readFile(path: string, options: { encoding: 'utf8' }): Promise<string>\n stat(path: string): Promise<{ isDirectory(): boolean }>\n}\n\n/** The node:fs/promises implementation the provider uses in production. */\nexport const nodeSkillIo: WslSkillIo = {\n readdir: async (path, options) => readdir(path, options),\n readFile: async (path, options) => readFile(path, options),\n stat: async path => stat(path),\n}\n\n/** One discovered skill directory under a WSL workspace. */\ninterface SkillRoot {\n /** Absolute UNC path of the skills directory (`…\\.dsh\\skills`). */\n path: string\n /** Host source label ('project-dsh' | 'project-agents'). */\n source: 'project-dsh' | 'project-agents'\n /** Host project rank so same-name wins and precedence stay consistent. */\n rank: number\n}\n\n/** Whether a skills-directory entry is a directory-bundle or a flat markdown skill. */\ninterface SkillEntry {\n name: string\n kind: 'bundle' | 'flat'\n path: string\n}\n\n/**\n * Locate the nearest ancestor of `linuxDir` (the directory itself included)\n * containing a `.git` marker, mirroring the host skill-filesystem's\n * project-root rule. `.git` may be a directory or a worktree pointer file;\n * existence is enough. Bounded so a pathological path cannot spin the walk.\n * @param distro - the WSL distribution name.\n * @param linuxDir - the session cwd's absolute Linux path.\n * @param io - filesystem face.\n * @returns the project root's Linux path, or `undefined` when no ancestor carries a `.git`.\n */\nasync function nearestGitAncestor(distro: string, linuxDir: string, io: WslSkillIo): Promise<string | undefined> {\n let current = linuxDir\n for (let levels = 0; levels <= MAX_ANCESTOR_WALK; levels += 1) {\n try {\n await io.stat(joinUnc(distro, posix.join(current, '.git')))\n return current\n } catch {\n // No `.git` marker at this level; keep walking towards the filesystem root.\n }\n const parent = posix.dirname(current)\n if (parent === current) return undefined\n current = parent\n }\n return undefined\n}\n\n/**\n * Scan a WSL workspace root for nested skill directories.\n * @param distro - the WSL distribution name.\n * @param linuxRoot - the workspace's absolute Linux path.\n * @param io - filesystem face.\n * @returns discovered skill directories, bounded by depth and budget.\n */\nasync function discoverSkillRoots(distro: string, linuxRoot: string, io: WslSkillIo): Promise<SkillRoot[]> {\n const roots: SkillRoot[] = []\n const visited = new Set<string>()\n // BFS layers so the budget prunes the widest, most redundant levels first\n // (shallow skill dirs matter most): [path, depth] pairs.\n let frontier: [string, number][] = [[linuxRoot, 0]]\n while (frontier.length > 0 && roots.length < MAX_SKILL_ROOTS) {\n const next: [string, number][] = []\n for (const [dir, depth] of frontier) {\n if (visited.size >= MAX_VISITED_DIRECTORIES) return roots\n if (visited.has(dir)) continue\n visited.add(dir)\n if (roots.length < MAX_SKILL_ROOTS) {\n const directoryRoots = await skillRootsOfDirectory(distro, dir, io)\n roots.push(...directoryRoots.slice(0, MAX_SKILL_ROOTS - roots.length))\n }\n if (depth >= MAX_SCAN_DEPTH) continue\n let entries: Dirent[]\n try {\n entries = await io.readdir(joinUnc(distro, dir), { withFileTypes: true })\n } catch {\n // An unreadable directory (permissions, vanished mid-walk) prunes its subtree.\n continue\n }\n for (const entry of entries) {\n if (!entry.isDirectory()) continue\n if (PRUNED_DIRECTORY_NAMES.has(entry.name)) continue\n if (entry.name.startsWith('.') && entry.name !== '.dsh' && entry.name !== '.agents') continue\n if (entry.name === '.dsh' || entry.name === '.agents') continue\n next.push([posix.join(dir, entry.name), depth + 1])\n }\n }\n frontier = next\n }\n return roots\n}\n\n/**\n * Publish the skill roots of one scanned directory (its `.dsh/skills` and\n * `.agents/skills`, each with the host's project ranks).\n * @param distro - the WSL distribution name.\n * @param linuxDir - the scanned directory's Linux path.\n * @param io - filesystem face.\n * @returns the directory's skill roots that exist.\n */\nasync function skillRootsOfDirectory(distro: string, linuxDir: string, io: WslSkillIo): Promise<SkillRoot[]> {\n const result: SkillRoot[] = []\n for (const [marker, source, rank] of [\n ['.dsh', 'project-dsh', PROJECT_DSH_RANK],\n ['.agents', 'project-agents', PROJECT_AGENTS_RANK],\n ] as const) {\n const path = joinUnc(distro, posix.join(linuxDir, marker, 'skills'))\n try {\n const info = await io.stat(path)\n if (info.isDirectory()) result.push({ path, source, rank })\n } catch {\n // Absent skills directory: nothing to publish.\n }\n }\n return result\n}\n\n/** List one skills directory's entries (directory bundles and flat `.md` skills). */\nasync function listSkillEntries(root: SkillRoot, io: WslSkillIo): Promise<SkillEntry[]> {\n let dirents: Dirent[]\n try {\n dirents = await io.readdir(root.path, { withFileTypes: true })\n } catch {\n return []\n }\n const entries: SkillEntry[] = []\n for (const entry of dirents) {\n if (entry.isDirectory()) {\n entries.push({ name: entry.name, kind: 'bundle', path: joinWindowsPath(root.path, entry.name, 'SKILL.md') })\n } else if (entry.isFile() && entry.name.endsWith('.md')) {\n entries.push({ name: entry.name.slice(0, -3), kind: 'flat', path: joinWindowsPath(root.path, entry.name) })\n }\n }\n return entries.sort((a, b) => a.name.localeCompare(b.name))\n}\n\n/** Read and parse one skill file; `undefined` when missing or unparsable. */\nasync function readSkill(path: string, io: WslSkillIo, signal?: AbortSignal): Promise<ParsedSkill | undefined> {\n signal?.throwIfAborted()\n let raw: string\n try {\n raw = await io.readFile(path, { encoding: 'utf8' })\n } catch {\n return undefined\n }\n signal?.throwIfAborted()\n return parseSkillFrontmatter(raw, path)\n}\n\n/**\n * Parse the frontmatter subset skill files use: `---` fenced YAML with\n * `name` / `description` / `whenToUse` / `user-invocable` /\n * `disable-model-invocation`. Host-incompatible files are skipped, matching\n * the shipped provider's leniency: a bad file must not fail the catalog.\n */\nfunction parseSkillFrontmatter(raw: string, path: string): ParsedSkill | undefined {\n const firstLineEnd = raw.indexOf('\\n')\n if (firstLineEnd < 0) return undefined\n if (raw.slice(0, firstLineEnd).replace(/\\r$/, '') !== '---') return undefined\n const start = firstLineEnd + 1\n const closing = findFrontmatterEnd(raw, start)\n if (closing === undefined) return undefined\n const fields = new Map<string, string>()\n for (const line of raw.slice(start, closing).split('\\n')) {\n const match = /^([A-Za-z0-9-]+):\\s*(.*)$/.exec(line.replace(/\\r$/, ''))\n if (match === null) continue\n const value = match[2]?.trim() ?? ''\n if (value !== '') fields.set(match[1] ?? '', unquote(value))\n }\n const name = fields.get('name') ?? ''\n const description = fields.get('description') ?? ''\n if (!SKILL_NAME.test(name) || description === '') {\n return undefined\n }\n const whenToUse = fields.get('whenToUse')\n return {\n name,\n description,\n ...whenToUse !== undefined && whenToUse !== '' ? { whenToUse } : {},\n invocation: {\n modelInvocable: !frontmatterBoolean(fields, 'disable-model-invocation'),\n userInvocable: frontmatterBoolean(fields, 'user-invocable', true),\n },\n content: raw.slice(closing + 1).trim(),\n }\n}\n\n/** Locate the closing `---` line of a frontmatter block. */\nfunction findFrontmatterEnd(raw: string, start: number): number | undefined {\n let lineStart = start\n while (lineStart <= raw.length) {\n const nextNewline = raw.indexOf('\\n', lineStart)\n const lineEnd = nextNewline < 0 ? raw.length : nextNewline\n if (raw.slice(lineStart, lineEnd).replace(/\\r$/, '') === '---') return lineEnd + 1\n if (nextNewline < 0) return undefined\n lineStart = nextNewline + 1\n }\n return undefined\n}\n\n/** Strip one level of matching quotes from a scalar value. */\nfunction unquote(value: string): string {\n if (value.length >= 2) {\n const first = value[0]\n const last = value[value.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return value.slice(1, -1)\n }\n }\n return value\n}\n\n/** Boolean semantics for `user-invocable` / `disable-model-invocation` (matches the host parser). */\nfunction frontmatterBoolean(fields: Map<string, string>, key: string, dflt = false): boolean {\n const value = fields.get(key)\n if (value === undefined) return dflt\n switch (value.toLowerCase()) {\n case 'true':\n case 'yes':\n case 'on':\n case '1':\n return true\n case 'false':\n case 'no':\n case 'off':\n case '0':\n return false\n default:\n return dflt\n }\n}\n\n/**\n * The WSL workspace skill provider. Registered on the host's `ctx.skills`\n * registry; serves only lookups whose cwd is a WSL UNC workspace path.\n */\nexport class WslSkillsProvider {\n readonly name = 'wsl-workspace'\n private readonly control: WslSkillProviderControl\n private readonly io: WslSkillIo\n\n constructor(control: WslSkillProviderControl, io: WslSkillIo = nodeSkillIo) {\n this.control = control\n this.io = io\n }\n\n /**\n * Discover nested project skills for a WSL UNC session workspace.\n * @param options - lookup options; `cwd` selects the WSL workspace.\n * @returns candidates for every `.dsh/skills` / `.agents/skills` under the\n * session's scan root — the nearest `.git` ancestor of the cwd, else the\n * cwd itself — or an empty array for non-WSL lookups.\n */\n async list(options: WslSkillLookupOptions): Promise<WslSkillCandidate[]> {\n this.control.signal.throwIfAborted()\n options.signal?.throwIfAborted()\n const unc = options.cwd === undefined ? null : parseWslUnc(options.cwd)\n if (unc === null) return []\n // Host parity: the session's project root is the nearest `.git` ancestor\n // of the cwd, so lookups from inside a project subtree still see that\n // project's skills; nested projects below it join via the bounded BFS.\n // Without a `.git` ancestor the session cwd itself is the scan root (the\n // issue #10 workspace layout).\n const scanRoot = (await nearestGitAncestor(unc.distro, unc.linuxPath, this.io)) ?? unc.linuxPath\n const roots = await discoverSkillRoots(unc.distro, scanRoot, this.io)\n const candidates: WslSkillCandidate[] = []\n for (const root of roots) {\n const entries = await listSkillEntries(root, this.io)\n for (const entry of entries) {\n options.signal?.throwIfAborted()\n const parsed = await readSkill(entry.path, this.io, options.signal)\n if (parsed === undefined) continue\n candidates.push({\n name: parsed.name,\n description: parsed.description,\n ...parsed.whenToUse !== undefined ? { whenToUse: parsed.whenToUse } : {},\n invocation: parsed.invocation,\n source: root.source,\n provider: this.name,\n rank: root.rank,\n locator: {\n path: entry.path,\n directory: entry.kind === 'bundle'\n ? joinWindowsPath(entry.path, '..')\n : root.path,\n },\n path: entry.path,\n })\n }\n }\n return candidates\n }\n\n /**\n * Load a complete skill body for a previously listed candidate.\n * @param candidate - the candidate this provider returned.\n * @param options - lookup options whose signal cancels the read.\n * @returns the full skill, or `undefined` if the file disappeared.\n */\n async get(candidate: WslSkillCandidate, options: WslSkillLookupOptions): Promise<WslSkillDefinition | undefined> {\n this.control.signal.throwIfAborted()\n const parsed = await readSkill(candidate.locator.path, this.io, options.signal)\n if (parsed === undefined || parsed.name !== candidate.name) return undefined\n return {\n name: parsed.name,\n description: parsed.description,\n ...parsed.whenToUse !== undefined ? { whenToUse: parsed.whenToUse } : {},\n invocation: parsed.invocation,\n source: candidate.source,\n provider: candidate.provider,\n rank: candidate.rank,\n locator: candidate.locator,\n path: candidate.path,\n content: parsed.content,\n }\n }\n}","/**\r\n * Host half of dsh-wsl-workspace. Three responsibilities:\r\n *\r\n * 1. Materialize a `wsl-<mode>` variant for every healthy roster preset\r\n * under `<dshHome>/.agent-presets/` (the roster's auto-scanned user\r\n * root), so the WSL execution world — `shell-wsl` + `fs-wsl` behind one\r\n * entry-local realm, with `tool-bash`/`tool-fs` consumers — composes with\r\n * ANY mode instead of being a mode itself; the legacy standalone `wsl`\r\n * preset directory and stale variants are removed on boot. The preset\r\n * rows name THIS package's built lib files by absolute path, which the\r\n * preset mount resolves to `file:` URLs without relying on bare specifier\r\n * resolution from the preset's home directory.\r\n *\r\n * 2. Serve the browser dialog's data route (`/wsl-workspace/api`):\r\n * distribution discovery, one-level directory listing, path checks, and\r\n * the per-workspace username store — all over the 9P UNC share.\r\n * Loopback-only, matching the sensitivity of the privileged configuration\r\n * surface.\r\n *\r\n * 3. Contribute the per-session `DSH_WSL_DISTRO` managed-env fact so the WSL\r\n * shell executor can resolve a plain Linux `workdir` to the calling\r\n * session's distribution.\r\n * @module dsh-wsl-workspace\r\n */\r\n\r\nimport { Context } from '@deepseek-ai/cordis'\r\nimport z from '@deepseek-ai/schemastery'\r\nimport { cpSync, existsSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'\r\nimport { fileURLToPath } from 'node:url'\r\nimport { dirname, join } from 'node:path'\r\nimport type { IncomingMessage, ServerResponse } from 'node:http'\r\nimport { homedir } from 'node:os'\r\nimport { joinUnc, mntToWindowsPath, normalizeLinuxPath, isAbsoluteLinuxPath, isValidWslUsername, parseWslUnc } from './shared/paths.ts'\r\nimport { canonicalWslUnc, getWindowsWorkspace, getWorkspaceUsername, listWorkspaceKeys, registerWindowsWorkspace, setWorkspaceUsername } from './shared/wsl-credentials.ts'\r\nimport { defaultDistro, listDistros } from './shared/wsl.ts'\r\nimport { isWslVariantId, transformPresetForWsl, variantIdFor } from './host/variants.ts'\r\nimport { WslSkillsProvider, type WslSkillsRegistryFace } from './host/wsl-skills.ts'\r\n\r\n/** The HTTP route this plugin serves (a relative, same-origin path). */\r\nexport const DEFAULT_ROUTE = '/wsl-workspace/api'\r\n\r\n/**\r\n * Bilingual display labels for the shipped source modes, matching the app's\r\n * own built-in copy in each language — note the `code` preset is \"PTC 模式\"\r\n * in the Chinese copy but \"Code mode\" in English. The DSH picker localizes\r\n * only the four built-in ids itself; `wsl-*` variant ids render the\r\n * preset.yml text verbatim, so the plugin writes one bilingual string so\r\n * both locales can identify each variant. Custom presets keep their own\r\n * name.\r\n */\r\nconst MODE_DISPLAY_LABELS: Readonly<Record<string, { en: string; zh: string }>> = {\r\n standard: { en: 'Standard mode', zh: '标准模式' },\r\n code: { en: 'Code mode', zh: 'PTC 模式' },\r\n minimal: { en: 'Minimal mode', zh: '极简模式' },\r\n cordis: { en: 'Creator mode', zh: '创造模式' },\r\n}\r\n\r\n/**\r\n * Quote a value as a single-line YAML single-quoted scalar. Plain scalars\r\n * cannot contain `: ` (colon + space), which plain English sentences do —\r\n * written unquoted they make the whole preset.yml unparsable, dropping the\r\n * name, description and order together.\r\n */\r\nfunction yamlScalar(value: string): string {\r\n return `'${value.replace(/'/g, \"''\")}'`\r\n}\r\n\r\n/** The variant name for one shipped mode (bilingual) or a custom preset. */\r\nfunction variantName(presetId: string, sourceName: string): string {\r\n const labels = MODE_DISPLAY_LABELS[presetId]\r\n return labels === undefined ? `WSL · ${sourceName}` : `WSL · ${labels.en}(${labels.zh})`\r\n}\r\n\r\n/** The variant description for one shipped mode (bilingual) or a custom preset. */\r\nfunction variantDescription(presetId: string): string {\r\n const labels = MODE_DISPLAY_LABELS[presetId]\r\n const display = labels === undefined ? presetId : `${labels.en}(${labels.zh})`\r\n return `WSL execution world for ${display}: bash and file tools run inside the WSL distribution.`\r\n}\r\n\r\n/** Plugin config. */\r\nexport interface Config {\r\n /** The route under which the dialog data API is served. */\r\n route?: string\r\n}\r\n\r\n/** The shape after schemastery applied the defaults. */\r\ntype ResolvedConfig = Required<Config>\r\n\r\n/** The `webServer.register` route contract this plugin consumes. */\r\ninterface WebServerRoute {\r\n kind: 'exact'\r\n path: string\r\n handler(req: IncomingMessage, res: ServerResponse): Promise<void>\r\n}\r\n\r\ninterface WebServerService {\r\n register(route: WebServerRoute): () => void\r\n}\r\n\r\n/** The `ctx.shellEnv` registry face this plugin consumes (optional service). */\r\ninterface ShellEnvService {\r\n register(contributor: {\r\n name: string\r\n variables: Readonly<Record<string, { description: string }>>\r\n resolve(execution: {\r\n agent?: { session: { header: { cwd?: string } } }\r\n }): Readonly<Partial<Record<string, string>>>\r\n }): () => void\r\n}\r\n\r\n/** One directory entry the dialog lists. */\r\ninterface WslDirEntryWire {\r\n name: string\r\n kind: 'directory' | 'file' | 'other'\r\n}\r\n\r\n/** One directory level plus its breadcrumb ancestry. */\r\ninterface WslDirListingWire {\r\n path: string\r\n parent: string | null\r\n entries: WslDirEntryWire[]\r\n}\r\n\r\n/** The wire envelope every method answers with. */\r\ntype Envelope<T> = { ok: true; value: T } | { ok: false; error: string }\r\n\r\nconst MAX_BODY_BYTES = 1024 * 1024\r\n\r\n/** Valid WSL distribution names: one path-safe segment (no separators, no dot-dirs). */\r\nconst DISTRO_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]*$/\r\n\r\n/** The loopback hostnames the data route answers to (DNS-rebinding fence). */\r\nconst LOOPBACK_HOSTNAMES = new Set(['localhost', '127.0.0.1', '::1', '::ffff:127.0.0.1'])\r\n\r\n/** True when a socket address is loopback (any IPv4/IPv6 spelling). */\r\nfunction isLoopback(address: string | undefined): boolean {\r\n return address === '127.0.0.1' || address === '::1' || address === '::ffff:127.0.0.1'\r\n}\r\n\r\n/** The hostname part of a `Host` header value (port and IPv6 brackets stripped). */\r\nfunction hostNameOf(host: string): string {\r\n if (host.startsWith('[')) {\r\n const end = host.indexOf(']')\r\n return end >= 0 ? host.slice(1, end) : host\r\n }\r\n return host.split(':')[0] ?? ''\r\n}\r\n\r\n/** True when the request's `Host` header names a loopback host. */\r\nfunction isLoopbackHost(host: string | undefined): boolean {\r\n return host !== undefined && LOOPBACK_HOSTNAMES.has(hostNameOf(host).toLowerCase())\r\n}\r\n\r\n/**\r\n * Validate a wire-supplied distribution name before it becomes a UNC segment:\r\n * an attacker-controlled segment containing separators or `..` would escape\r\n * the `\\\\wsl.localhost\\` share structure into arbitrary UNC paths.\r\n * @param value - the raw wire value.\r\n * @returns the validated distro name.\r\n */\r\nfunction requireDistro(value: unknown): string {\r\n if (typeof value !== 'string' || !DISTRO_PATTERN.test(value) || value === '.' || value === '..') {\r\n throw new Error('distro must be a valid WSL distribution name')\r\n }\r\n return value\r\n}\r\n\r\n/** Human text for an unknown rejection. */\r\nfunction messageOf(value: unknown): string {\r\n return value instanceof Error ? value.message : String(value)\r\n}\r\n\r\n/** Write one JSON envelope. */\r\nfunction json(res: ServerResponse, status: number, body: Envelope<unknown>): void {\r\n res.writeHead(status, {\r\n 'content-type': 'application/json; charset=utf-8',\r\n 'cache-control': 'no-store',\r\n 'x-content-type-options': 'nosniff',\r\n })\r\n res.end(JSON.stringify(body))\r\n}\r\n\r\n/** Collect and parse the request body, bounded. */\r\nasync function readBody(req: IncomingMessage): Promise<Record<string, unknown>> {\r\n const chunks: Buffer[] = []\r\n let size = 0\r\n for await (const chunk of req) {\r\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)\r\n size += buffer.length\r\n if (size > MAX_BODY_BYTES) throw new Error('request body is too large')\r\n chunks.push(buffer)\r\n }\r\n const parsed = JSON.parse(Buffer.concat(chunks).toString('utf8')) as unknown\r\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {\r\n throw new Error('request body must be a JSON object')\r\n }\r\n return parsed as Record<string, unknown>\r\n}\r\n\r\n/** Normalize a Linux path for the wire (rejecting non-absolute input). */\r\nfunction requireLinuxPath(value: unknown, label: string): string {\r\n if (typeof value !== 'string' || !isAbsoluteLinuxPath(value)) {\r\n throw new Error(`${label} must be an absolute Linux path`)\r\n }\r\n return normalizeLinuxPath(value)\r\n}\r\n\r\n/** Validate a wire-supplied workspace path and return its canonical UNC form. */\r\nfunction requireWslUnc(value: unknown): string {\r\n if (typeof value !== 'string') throw new Error('path must be a string')\r\n const canonical = canonicalWslUnc(value)\r\n if (canonical === null) throw new Error('path must be a WSL UNC workspace path')\r\n return canonical\r\n}\r\n\r\n/**\r\n * Resolve one directory listing for the dialog. The 9P share (`\\\\wsl.localhost\\…`)\r\n * serves only the ext4 volume: `/mnt/<drive>` (drvfs) reads return Access\r\n * denied, so drvfs paths are read through their Windows drive spelling and\r\n * `/mnt` itself is synthesized from the drives present on the host.\r\n */\r\nfunction listWslDir(distro: string, linuxPath: string): WslDirListingWire {\r\n if (linuxPath === '/mnt') {\r\n const entries: WslDirEntryWire[] = []\r\n for (let i = 0; i < 26; i++) {\r\n const letter = String.fromCharCode(65 + i)\r\n try {\r\n const info = statSync(`${letter}:\\\\`)\r\n if (info.isDirectory()) entries.push({ name: letter.toLowerCase(), kind: 'directory' })\r\n } catch {\r\n // Absent drive: skip.\r\n }\r\n }\r\n return { path: '/mnt', parent: '/', entries }\r\n }\r\n const winPath = mntToWindowsPath(linuxPath)\r\n const readPath = winPath !== null ? winPath : joinUnc(distro, linuxPath)\r\n const dirents = readdirSync(readPath, { withFileTypes: true })\r\n const entries: WslDirEntryWire[] = dirents\r\n .slice(0, 1000)\r\n .map((dirent): WslDirEntryWire => {\r\n const kind: WslDirEntryWire['kind'] = dirent.isDirectory()\r\n ? 'directory'\r\n : dirent.isFile() ? 'file' : 'other'\r\n return { name: dirent.name, kind }\r\n })\r\n .sort((a, b) => {\r\n if (a.kind === 'directory' && b.kind !== 'directory') return -1\r\n if (a.kind !== 'directory' && b.kind === 'directory') return 1\r\n return a.name.localeCompare(b.name)\r\n })\r\n const parent = linuxPath === '/' ? null : linuxPath.split('/').slice(0, -1).join('/') || '/'\r\n return { path: linuxPath, parent, entries }\r\n}\r\n\r\n/** Route one method dispatch. */\r\nasync function dispatch(method: string, params: Record<string, unknown>): Promise<unknown> {\r\n switch (method) {\r\n case 'listDistros': {\r\n const distros = await listDistros()\r\n const fallback = await defaultDistro()\r\n if (fallback !== undefined && distros.includes(fallback)) {\r\n return [fallback, ...distros.filter(name => name !== fallback)]\r\n }\r\n return distros\r\n }\r\n case 'listDir': {\r\n const distro = requireDistro(params.distro)\r\n const path = requireLinuxPath(params.path, 'path')\r\n return listWslDir(distro, path)\r\n }\r\n case 'check': {\r\n const distro = requireDistro(params.distro)\r\n const path = requireLinuxPath(params.path, 'path')\r\n // drvfs paths (Access denied over 9P) are checked through their drive spelling.\r\n const winPath = mntToWindowsPath(path)\r\n const readPath = winPath !== null ? winPath : joinUnc(distro, path)\r\n try {\r\n const info = statSync(readPath)\r\n return { exists: true, isDirectory: info.isDirectory() }\r\n } catch {\r\n return { exists: false, isDirectory: false }\r\n }\r\n }\r\n case 'registerWindows': {\r\n // A `/mnt/<drive>` workspace registers under its Windows drive path\r\n // (the registry realpath/stats it, and 9P cannot serve drvfs) with the\r\n // distro stored for the per-session env contributor.\r\n const distro = requireDistro(params.distro)\r\n const linuxPath = requireLinuxPath(params.linuxPath, 'path')\r\n const winPath = mntToWindowsPath(linuxPath)\r\n if (winPath === null) throw new Error('registerWindows requires a /mnt/<drive> Linux path')\r\n const username = typeof params.username === 'string' ? params.username : undefined\r\n registerWindowsWorkspace(winPath, distro, username)\r\n return null\r\n }\r\n case 'listWorkspaces': {\r\n // Every registered WSL workspace key (UNC and Windows drive spellings):\r\n // the client uses the drive keys to recognize `/mnt` workspaces.\r\n return listWorkspaceKeys()\r\n }\r\n case 'setUser': {\r\n const path = requireWslUnc(params.path)\r\n const username = params.username\r\n if (username === undefined || username === '') {\r\n setWorkspaceUsername(path, undefined)\r\n } else {\r\n if (typeof username !== 'string' || !isValidWslUsername(username)) {\r\n throw new Error('username must match the Linux username pattern [A-Za-z_][A-Za-z0-9_.-]*')\r\n }\r\n setWorkspaceUsername(path, username)\r\n }\r\n return null\r\n }\r\n default:\r\n throw new Error(`unknown method \"${method}\"`)\r\n }\r\n}\r\n\r\n/** The `ctx.agentPresets` roster face this plugin consumes (optional service). */\r\ninterface AgentPresetsService {\r\n list(): Promise<{ id: string; broken?: string; path: string }[]>\r\n read(id: string): Promise<string>\r\n}\r\n\r\n/**\r\n * Publish a fully staged preset directory while preserving the last complete\r\n * variant if publication fails. Stable sibling names also let the next boot\r\n * recover an interrupted old-to-backup rename before doing new work.\r\n */\r\nfunction publishVariant(staging: string, dest: string): void {\r\n const previous = `${dest}.previous`\r\n if (!existsSync(dest) && existsSync(previous)) renameSync(previous, dest)\r\n if (existsSync(previous)) rmSync(previous, { recursive: true, force: true })\r\n if (existsSync(dest)) renameSync(dest, previous)\r\n try {\r\n renameSync(staging, dest)\r\n } catch (error) {\r\n if (!existsSync(dest) && existsSync(previous)) renameSync(previous, dest)\r\n throw error\r\n }\r\n rmSync(previous, { recursive: true, force: true })\r\n}\r\n\r\n/** Materialize one WSL variant per healthy source preset. */\r\nasync function materializeVariants(\r\n agentPresets: AgentPresetsService,\r\n dshHome: string,\r\n shellPath: string,\r\n fsPath: string,\r\n): Promise<void> {\r\n const presets = await agentPresets.list()\r\n const userRoot = join(dshHome, '.agent-presets')\r\n const generated = new Set<string>()\r\n for (const preset of presets) {\r\n if (preset.broken !== undefined) continue\r\n if (isWslVariantId(preset.id)) continue\r\n const variantId = variantIdFor(preset.id)\r\n const source = await agentPresets.read(preset.id)\r\n const transformed = transformPresetForWsl(source, shellPath, fsPath)\r\n const dir = join(userRoot, variantId)\r\n const staging = `${dir}.staging`\r\n rmSync(staging, { recursive: true, force: true })\r\n // A preset directory is an opaque, self-contained plugin unit. Mirror it\r\n // without interpreting local code or asset names, then overwrite only the\r\n // two files owned by this generator.\r\n cpSync(dirname(preset.path), staging, { recursive: true, force: true })\r\n writeFileSync(join(staging, 'agent.cordis.yml'), transformed, 'utf8')\r\n const labels = MODE_DISPLAY_LABELS[preset.id]\r\n let name = variantName(preset.id, preset.id)\r\n let orderLine = ''\r\n try {\r\n const meta = readFileSync(join(dirname(preset.path), 'preset.yml'), 'utf8')\r\n if (labels === undefined) {\r\n // Custom presets keep their own display name; shipped modes use the\r\n // bilingual labels above so both locales can identify the variant.\r\n const match = /^name:\\s*(.+)$/m.exec(meta)\r\n if (match?.[1] !== undefined && match[1].trim() !== '') {\r\n name = variantName(preset.id, match[1].trim())\r\n }\r\n }\r\n // Inherit the source's declared order so the WSL variants line up with\r\n // the local modes in the roster (standard, PTC, minimal, cordis).\r\n const orderMatch = /^order:\\s*(\\d+)\\s*$/m.exec(meta)\r\n if (orderMatch?.[1] !== undefined) orderLine = `order: ${orderMatch[1]}\\n`\r\n } catch {\r\n // Absent or unreadable display metadata falls back to the id-based name.\r\n }\r\n writeFileSync(\r\n join(staging, 'preset.yml'),\r\n `name: ${yamlScalar(name)}\\n`\r\n + orderLine\r\n + `description: ${yamlScalar(variantDescription(preset.id))}\\n`,\r\n 'utf8',\r\n )\r\n publishVariant(staging, dir)\r\n generated.add(variantId)\r\n }\r\n for (const entry of readdirSync(userRoot, { withFileTypes: true })) {\r\n if (!entry.isDirectory()) continue\r\n if (entry.name === 'wsl') {\r\n // The legacy standalone WSL mode: folded into the variants above.\r\n rmSync(join(userRoot, entry.name), { recursive: true, force: true })\r\n continue\r\n }\r\n if (!/^wsl-[a-z0-9-]+$/.test(entry.name)) continue\r\n if (!generated.has(entry.name)) rmSync(join(userRoot, entry.name), { recursive: true, force: true })\r\n }\r\n}\r\n\r\n/** Function-plugin plugin contract. */\r\nexport const name = 'dsh-wsl-workspace'\r\n\r\n/** Required services. */\r\nexport const inject = ['webServer']\r\n\r\n/** Validated plugin config (schemastery applied the defaults). */\r\nexport const Config: z<Config> = z.object({\r\n route: z.string().default(DEFAULT_ROUTE),\r\n})\r\n\r\n/**\r\n * Apply the host half: materialize a `wsl-<mode>` variant for every healthy\r\n * roster preset, register the data route, and\r\n * contribute the per-session `DSH_WSL_DISTRO` managed-env fact so the WSL\r\n * shell executor can resolve a plain Linux `workdir` to the calling\r\n * session's distribution.\r\n * @param ctx - the host plugin context.\r\n * @param config - the validated configuration.\r\n */\r\nexport function apply(ctx: Context, config: Config): void {\r\n const resolved = config as ResolvedConfig\r\n const dshHome = process.env.DSH_HOME ?? join(homedir(), '.dsh')\r\n const packageRoot = fileURLToPath(new URL('..', import.meta.url))\r\n const shellPath = join(packageRoot, 'lib', 'shell.js').replace(/\\\\/g, '/')\r\n const fsPath = join(packageRoot, 'lib', 'fs.js').replace(/\\\\/g, '/')\r\n\r\n const agentPresets = ctx.get('agentPresets') as unknown as AgentPresetsService | undefined\r\n if (agentPresets !== undefined) {\r\n ctx.effect(() => {\r\n void materializeVariants(agentPresets, dshHome, shellPath, fsPath).catch((error) => {\r\n // Variant generation is best-effort over a live roster: a missing or\r\n // unreadable source preset must not take the whole plugin down, but\r\n // the failure is surfaced loudly rather than hidden.\r\n console.error(`dsh-wsl-workspace: WSL preset-variant generation failed: ${messageOf(error)}`)\r\n })\r\n return () => {}\r\n }, 'dsh-wsl-workspace: WSL preset variants')\r\n }\r\n\r\n const skills = ctx.get('skills') as unknown as WslSkillsRegistryFace | undefined\r\n if (skills !== undefined && typeof skills.registerProvider === 'function') {\r\n // The shipped skill-filesystem provider scans only the session cwd's\r\n // project root, so WSL workspaces whose `.dsh/skills` live in nested\r\n // projects would show an empty skill catalog. This provider mirrors the\r\n // host's project discovery for WSL UNC workspaces, bounded to the\r\n // workspace root (issue #10). The method check keeps a host whose\r\n // `skills` service exists with a different shape from breaking plugin\r\n // load; the provider is an enhancement, never a load-time requirement.\r\n ctx.effect(() => skills.registerProvider(\r\n control => new WslSkillsProvider(control),\r\n ), 'dsh-wsl-workspace: WSL workspace skills provider')\r\n }\r\n\r\n const shellEnv = ctx.get('shellEnv') as unknown as ShellEnvService | undefined\r\n if (shellEnv !== undefined) {\r\n ctx.effect(() => shellEnv.register({\r\n name: 'wsl-workspace-distro',\r\n variables: {\r\n DSH_WSL_DISTRO: {\r\n description: 'The WSL distribution of the calling session workspace, when the session cwd is a WSL UNC path.',\r\n },\r\n DSH_WSL_USER: {\r\n description: 'The Linux user of the calling session workspace, when the workspace has one configured.',\r\n },\r\n },\r\n resolve(execution) {\r\n const cwd = execution.agent?.session.header.cwd\r\n const unc = cwd === undefined ? null : parseWslUnc(cwd)\r\n if (unc !== null) {\r\n const username = getWorkspaceUsername(joinUnc(unc.distro, unc.linuxPath))\r\n return username === undefined || username === ''\r\n ? { DSH_WSL_DISTRO: unc.distro }\r\n : { DSH_WSL_DISTRO: unc.distro, DSH_WSL_USER: username }\r\n }\r\n // A Windows-drive cwd belongs to a `/mnt/<drive>` WSL workspace (9P\r\n // cannot serve drvfs, so those register under their drive path): the\r\n // stored distro drives `wsl.exe -d` for bash.\r\n if (cwd !== undefined && /^[A-Za-z]:[\\\\/]/.test(cwd)) {\r\n const entry = getWindowsWorkspace(cwd)\r\n if (entry !== undefined && entry.distro !== undefined && entry.distro !== '') {\r\n return entry.username === undefined || entry.username === ''\r\n ? { DSH_WSL_DISTRO: entry.distro }\r\n : { DSH_WSL_DISTRO: entry.distro, DSH_WSL_USER: entry.username }\r\n }\r\n }\r\n return {}\r\n },\r\n }), 'dsh-wsl-workspace: per-session distro env fact')\r\n }\r\n\r\n const webServer = ctx.get('webServer') as unknown as WebServerService\r\n ctx.effect(() => webServer.register({\r\n kind: 'exact',\r\n path: resolved.route,\r\n handler: async (req, res) => {\r\n if (!isLoopback(req.socket.remoteAddress) || !isLoopbackHost(req.headers.host)) {\r\n json(res, 403, { ok: false, error: 'loopback-only' })\r\n return\r\n }\r\n if (req.method !== 'POST') {\r\n json(res, 405, { ok: false, error: 'method not allowed' })\r\n return\r\n }\r\n let body: Record<string, unknown>\r\n try {\r\n body = await readBody(req)\r\n } catch (error) {\r\n json(res, 400, { ok: false, error: messageOf(error) })\r\n return\r\n }\r\n const method = typeof body.method === 'string' ? body.method : ''\r\n const params = body.params === undefined ? {} : body.params\r\n if (params === null || typeof params !== 'object' || Array.isArray(params)) {\r\n json(res, 400, { ok: false, error: 'params must be an object' })\r\n return\r\n }\r\n try {\r\n const value = await dispatch(method, params as Record<string, unknown>)\r\n json(res, 200, { ok: true, value })\r\n } catch (error) {\r\n json(res, 200, { ok: false, error: messageOf(error) })\r\n }\r\n },\r\n }), 'dsh-wsl-workspace: dialog data route')\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,aAAa,IAAI,IAAI;CAAC;CAAa;CAAa;CAAW;CAAkB;CAAsB;CAAc;CAAoB;CAAe;AAAsB,CAAC;;AAGjL,SAAS,cAAc,WAAmB,QAAgB,eAAgC;CACxF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,gBAAgB,UAAU,QAAQ,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