nuwa-skill
alchaincyf
你想蒸馏的下一个员工,何必是同事。蒸馏任何人的思维方式——心智模型、决策启发式、表达DNA。Distill how anyone thinks.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:FrozMN/dsh-session-adopt
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
English | 中文
A DeepSeek Harness plugin that finds sessions created outside the running desktop window — for example by an IDE's ACP client — and adopts them into their matching Workspace.
It also adds a Sync sessions action to the sidebar footer and refreshes the browser's session catalog, so new sessions appear without restarting the Harness.
On top of that it can detect sessions from other local agent harnesses — starting with pi — and import them as native DSH sessions, filed into the Workspace matching their working directory. The Import sessions sidebar action opens a picker; the same work is available through same-origin JSON routes for scripts.
Sidebar
...
⚙ Settings
⟳ Sync sessions +3
⬇ Import sessions
DeepSeek Harness persists sessions in a store shared by every client and process. A running Web/Desktop Host, however, builds its cwd → Workspace index once at startup, and the browser's session list never re-reads itself.
A session created by another process — VS Code through ACP, an SDK client, a headless run — is therefore written to disk but stays ungrouped; it only appears after restarting the Harness, and even then it may not be attached to its Workspace.
This plugin closes that gap at runtime:
ctx.sessionPersistence.cwd to a canonical path and match it to a Workspace.workspace.attachSession().workspace.follow stream update the sidebar.ctx.sessions.refresh() so the rows are visible immediately.+N badge.cwd has no registration.pi and VS Code Copilot shipped, adapter slots for Claude Code, Codex, Gemini CLI and OpenCode). Foreign stores are only ever read.cwd; a missing Workspace is created on explicit import./session-import/* routes back the dialog and can be driven by local tooling.index.js (webServer, connection, sessionPersistence, workspaceRegistry, sessions).~/.pi/agent/sessions, or the PI_CODING_AGENT_SESSION_DIR /
PI_CODING_AGENT_DIR overrides) and GitHub Copilot Chat in VS Code (the VS Code workspaceStorage
chat stores, or the COPILOT_USER_DATA_DIR / VSCODE_USER_DATA_DIR overrides). Other harnesses need
an adapter module under import/adapters/.The install step must perform both package installation and bundle selection. The Plugins page
does that; a raw pnpm add inside a profile does not.
If the current agent exposes the Host plugin_manager tool, install the bundle with:
plugin_manager install_bundle <absolute-path-or-git-url>
Then verify that the session-adopt row is active:
plugin_manager list_plugins
The package declares a dsh.bundle manifest, so the profile package manager can install and select it
in one command:
dsh plugin --profile web add https://github.com/FrozMN/dsh-session-adopt
Restart the profile (or the desktop app) afterwards to load the new bundle. The same command takes a
local checkout for development, for example
dsh plugin --profile web add /absolute/path/to/dsh-session-adopt. A directory install is linked into
the profile, so later edits only need the plugin to be reloaded.
Replace the package files (or pull the repository), then restart the plugin from the Plugins page. Because the package is a plain ESM bundle with no build step, no compilation is required.
| Action | Result |
|---|---|
| Click Sync sessions | Full scan, including older ungrouped sessions, then refresh the session list |
| Hover the button | Last sync time, number of sessions placed, or the failure reason |
+N badge |
Sessions placed by the latest sync |
The button is registered in the sidebar.footer.action slot, beside the Settings entry. It is
visible in both the expanded sidebar and the collapsed rail.
→ existing workspace, or → new workspace: /path).workspace.follow stream, so new rows appear without a page reload.Sessions that are already imported are skipped by identity, not by title, so running the import twice never duplicates a conversation.
All routes sit behind the same Host/Origin fence and browser-session cookie as the rest of the Harness,
accept application/json, and never accept a filesystem path (selections are opaque keys returned by a
scan):
| Route | Method | Purpose |
|---|---|---|
/session-import/sources |
GET |
Adapter inventory: id, title, availability, roots |
/session-import/scan |
POST |
Scan foreign stores; body {} or { "adapterIds": ["pi"] } |
/session-import/import |
POST |
Import selected candidates; body { "selections": ["<candidateKey>", …], "workspace": "auto" } |
/session-import/status |
GET |
Config, in-flight flags, last scan and last import summaries |
workspace may also be { "kind": "existing", "workspaceId": "…" } or { "kind": "new", "cwd": "/abs/path" };
the default "auto" matches an existing Workspace by canonical cwd and creates one when needed. A
request is a single selection batch, returns HTTP 200 with per-selection imported / skipped /
errors arrays, and is serialized inside the Host process.
An adapter is a dependency-free ESM module under import/adapters/ exporting
id, title, available(ctx), listSessions(ctx) and readSession(ctx, key). listSessions returns
metadata only (a scan never reads conversation content); readSession returns a normalized transcript
(user / assistant / tool messages with text, reasoning and tool-call blocks) that the Host
converts into the native session log. Images are imported as [image] placeholders in this version.
Additional adapters can be dropped in without touching the Host.
Two adapters ship today:
pi — pi session format v1–v3, including branch selection (active leaf), usage tokens and tool
results. Store: ~/.pi/agent/sessions (PI_CODING_AGENT_SESSION_DIR, PI_CODING_AGENT_DIR,
PI_HOME).copilot — GitHub Copilot Chat sessions stored by VS Code. Store:
<user data>/User/workspaceStorage/<workspace id>/chatSessions/, plus the folder-less
globalStorage/emptyWindowChatSessions. The working directory of a session is the folder recorded in
that workspace's workspace.json, so imported Copilot sessions land in the same Workspace you had open
in VS Code. Both on-disk forms are read: the append-only .jsonl operation log used since
microsoft/vscode#286644 (VS Code ~1.109 / Insiders) — replayed with VS Code's own kind 0/1/2/3
semantics — and the legacy single-file .json. Prose, reasoning, tool invocations with their recorded
results (structured output or captured terminal output) and answered question carousels are converted;
progress markers, code-block URIs and undo stops are dropped. VS Code variants (Code, Code - Insiders, VSCodium, Code - OSS) are discovered automatically, and COPILOT_USER_DATA_DIR /
VSCODE_USER_DATA_DIR can name a user-data directory explicitly (path-delimiter separated for
several).The defaults are declared in the bundle's cordis.patch.yml. To change them,
override the session-adopt row in the profile's cordis.patch.yml:
- id: session-adopt
name: "dsh-session-adopt"
config:
pollIntervalMs: 7200000
activeWindowMs: 21600000
autoCreateWorkspaces: true
includeSubagents: false
startupScan: true
startupDelayMs: 2500
importEnabled: true
maxMessages: 4000
maxCandidates: 500
The row's config is replaced wholesale, so restate every key you need.
| Key | Default | Meaning |
|---|---|---|
pollIntervalMs |
7200000 (2 h) |
Interval between active-workspace scans; minimum 1 minute |
activeWindowMs |
21600000 (6 h) |
How recently a session log must have changed for its workspace to be active |
autoCreateWorkspaces |
true |
Create a Workspace when a new session's canonical cwd has none |
includeSubagents |
false |
Also file origin: "subagent" sessions into Workspaces (not recommended) |
startupScan |
true |
Run one full scan after the plugin mounts |
startupDelayMs |
2500 |
Delay before that startup scan |
importEnabled |
true |
Mount the cross-harness import routes and the sidebar dialog |
maxMessages |
4000 |
Upper bound on normalized messages one imported session may carry; larger sessions are rejected with a clear per-selection error |
maxCandidates |
500 |
Upper bound on candidates returned to the dialog per scan (the host cache keeps them all) |
Changes restart the plugin, which also re-arms the timers and the startup scan. The import routes are exact paths on the Host web server, so their names do not change with the loader row id.
index.js implements apply(ctx, config).ctx.sessionPersistence.list(); each snapshot carries the session header and the log's
location.cwd is canonicalized with fs.realpath; only existing directories are considered.ctx.workspaceRegistry.create(path) when policy allows.attachedCount, createdCount, deferredCount,
skipCounts, and bounded error details.Two exact HTTP routes are registered behind the composition's trust fence
(ctx.connection.requestRejection(req) — Host/Origin validation plus the browser login cookie):
| Route | Method | Purpose |
|---|---|---|
/session-adopt/scan |
POST |
Run a scan; body { "scope": "all" \| "active" } |
/session-adopt/status |
GET |
Read config, scanning, next scheduled time, and the last scan summary |
Request bodies are capped at 16 KiB and must be application/json. No request field is used as a
filesystem path.
client.js is a lazy browser module that registers the sidebar action.ctx.sessions.refresh() to re-read the session catalog.workspace.follow. When a Workspace names a
session the catalog does not know yet — the signature of a background scan — it refreshes the
catalog once with a short loop guard.en / zh dictionary through ctx.locale.cwd, matches existing Workspaces and caches everything by an opaque key.import/events.js synthesizes a v4 event log from the normalized transcript: one turn
per user message, one step per assistant response, tool/call + tool/result pairs, a protected
empty system/message surface head (needed before the session can ever be resumed), a session/title
event, and a TOOL_OUTCOME_UNKNOWN repair result for advertised tool calls whose foreign result never
arrived.Session restore path
(ctx.sessions.prepare() with the generated seed), so a conversion that the running Harness would
refuse never reaches disk.ctx.sessionPersistence.create() / append() / flush() with a
deterministic session-<uuid5> id derived from (harness, foreign session id). That id is what makes
re-import idempotent without any sidecar ledger.cwd is matched against ctx.workspaceRegistry.list(); a missing
Workspace is created on an explicit import, then workspace.attachSession(id) publishes the change
through the normal Workspace follow stream.Imported sessions are ordinary durable DSH sessions: they can be opened, renamed, and continued in the Harness (the resumed agent loop appends its own turn/step records and request headers).
To avoid resurrecting a Workspace the user deleted on purpose, scheduled and startup scans only
create a missing Workspace for sessions created after this plugin process started. An explicit
manual sync is allowed to create one for older history. Sessions whose cwd already has a
Workspace are always attached, regardless of age.
connection trust fence before any
work runs; an unauthenticated request receives 401 and a cross-site one 403.ctx.sessionPersistence. No filesystem path is ever accepted from a request.ctx.connection.requestRejection(req) validates Host/Origin and
the browser login cookie before any work runs; request bodies are capped (16 KiB for scans, 64 KiB for
imports), must be application/json, and carry only adapter ids and opaque candidate keys.cwd match, not a parent-directory match.origin: "subagent" sessions and migration-required sessions are skipped by default.+N badge and the last-sync tooltip are page-local; they reset on reload.Cross-harness import adds its own boundaries:
emptyWindowChatSessions) carry no working
directory, so they are listed but cannot be selected for import.already-imported, so refreshing an import is a future feature.session/end-seed {}), records the current
model/preset/permission/sandbox state, opens the next turn, and logs the current system prompt: on
routes with systemPromptUpdate: in-history it is appended after the imported history; on other
routes the protected first system node is rewritten. Imported events are never rewritten. The same
resume path may add another untagged session/end-seed {} at each later cold resume; these markers
are harmless (only { inherited: true } markers define fork cuts) and never reach the model.TOOL_OUTCOME_UNKNOWN); tool results without a preceding
call are dropped (counted in stats); images are downgraded to text; imported assistant reasoning has
no provider replay metadata, so the model sees the content but provider stream/prefix replay of
imported turns is best-effort. Imported tool names that the current DSH preset does not define render
as generic tool cards.cwd must resolve at import time (it is canonicalized for the Workspace); sessions
whose working directory no longer exists are refused rather than attached to an unrelated Workspace.times keep the foreign chronology (clamped to now, monotonic); only
header.createdAt is the import time, which is what the sidebar sorts by. Titles are derived from the
foreign title/first prompt and capped at 60 code points.| File | Purpose |
|---|---|
index.js |
Host plugin: adopt scan, import routes, Workspace attachment, timers |
import/index.js |
Cross-harness import orchestration: scan → convert → persist → Workspace |
import/events.js |
Normalized transcript → validated DSH v4 event log |
import/ids.js |
Deterministic session ids (UUIDv5) for idempotent imports |
import/registry.js |
Adapter scanning, candidate cache, Workspace hints |
import/adapters/ |
Adapter contract plus the shipped pi and copilot adapters |
client.js |
Browser plugin: sidebar actions (sync + import dialog), locale dictionaries |
test/ |
Self-contained event-builder and import-orchestrator tests |
cordis.patch.yml |
Loader row and default config |
locale/en.json, locale/zh.json |
Plugin-manager title and description |
icon.svg |
Original plugin icon |
README.zh.md |
Chinese documentation |
No build step is required:
npm run check # node --check on every host/client module
npm test # node --test test/*.test.mjs import/adapters/*.test.mjs
node -e "for (const f of ['package.json','locale/en.json','locale/zh.json']) JSON.parse(require('fs').readFileSync(f,'utf8'))"
The adapter tests read the machine's real stores when present and skip gracefully otherwise (both are
read-only): ~/.pi/agent/sessions for pi, and the VS Code workspaceStorage/.../chatSessions stores for
Copilot. Copilot sessions are replayed through the same kind 0/1/2/3 operation-log semantics VS Code
itself uses, and the real sessions present on the host are listed and read into the adapter contract
when a store exists.
To test in a live profile, install the checkout as a local bundle
(plugin_manager install_bundle /absolute/path/to/checkout). A directory install is linked into the
profile, so after editing host code toggle the plugin row/bundle off and on (no app restart); client
code is a browser module and a page refresh (or the harness client HMR frame) is enough when it changes.
Before trusting a conversion, the importer validates the whole candidate log through the installed
Session restore path, and the repository tests pin the event invariants.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: agent、session、sessions。