# dsh-init-plugin **Repository Path**: dk-1001/dsh-init-plugin ## Basic Information - **Project Name**: dsh-init-plugin - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-01 - **Last Updated**: 2026-10-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # dsh-init-plugin A [dsh](https://github.com/deepseek-ai/deepseek-harness) (DeepSeek Harness) plugin that registers the `/init` slash command: a deterministic repository scan followed by a dialog-driven `AGENTS.md` generation, Claude Code `/init` style. `AGENTS.md` is dsh's native project instruction file — loaded into every session's agent context (with byte-budget truncation and live re-sync when the file changes). This plugin makes creating it a one-command, chat-driven process. ## How it works 1. `/init [optional instructions]` invokes the registered command handler. 2. The handler runs a **deterministic scan** of the repository root (no model tokens): directory tree (ignoring `.git`, `node_modules`, `.npm-cache`, build output, etc.; directories with more than 40 entries are collapsed with their entry count), README, `package.json` digest, selected config files, and the existing root `AGENTS.md` — all byte-bounded (24 KB summary budget; facts are kept before the tree, which is cut first). 3. The handler `steer`s the scan summary plus a task prompt to the **receiving agent** (the same pattern `dsh-plan-mode` uses to submit the optional `/plan` message). No generation logic lives in the plugin. 4. The agent loop takes over: it reads key files itself, asks you how to treat an existing `AGENTS.md` (overwrite / merge / append / skip), asks a few clarifying questions, writes the file with its normal file tools, and summarizes the result. 5. Refinement is just conversation — keep asking the agent to adjust sections. ## Requirements - A dsh host providing the `commands` registry (`packages/interaction/commands`), `@deepseek-ai/dsh-agent`, and `@deepseek-ai/dsh-llm` (peer dependencies). - Node >= 22.19. ## Install The plugin is a **dsh profile bundle**: registering it once installs and activates it — no manual composition editing. ### Desktop (recommended): Plugins → Add plugin, one step Paste any of these into the "package name or address" field, confirm, then **reopen Desktop**: | Paste | How it installs | Notes | |---|---|---| | `https://gitee.com/dk-1001/dsh-init-plugin.git` | pnpm clones a copy | **Simplest**: the repository is public, so no Gitee account or SSH key is needed (measured 1.6 s) | | `git+ssh://git@gitee.com:dk-1001/dsh-init-plugin.git` | same, over SSH | for machines that already have a Gitee SSH key (measured 2.8 s) | | `D:\WorkSpace\dsh\dsh-init-plugin` | `link:` to the local directory | for local source edits: rebuild not required, just **reopen Desktop** | Afterwards the Plugins page lists `dsh-init-plugin` as running; composition is verifiable in `~/.dsh/profiles/desktop/package.json` (`dsh.profile.bundles` contains `dsh-init-plugin`). `/init` becomes available once Desktop is reopened. > **No build step is needed**: `lib/` and `cordis.patch.yml` both ship in the repository, so a clone is loadable as-is — > unlike `dsh-e2e-autotest` in the same workspace, which depends on host packages and needs its `install.ps1` run first. > > **Why a restart**: the GUI's toggle only rewrites the profile composition; an already-running dsh host does not hot-load new bundles. ### Command line One `dsh plugin add` is equivalent to the GUI route above. ```sh # installs into the profile and registers the bundle layer automatically (replace ) dsh plugin --profile add https://gitee.com/dk-1001/dsh-init-plugin.git ``` Pick `` by how dsh runs: - **dsh Desktop** → `desktop`. Electron owns that profile, so **only the application's bundled command** may manage it — a source-checkout or npm-installed dsh refuses with `profile "desktop" is managed exclusively by the Electron application`. Use `\resources\runtime\cli\bin\dsh.cmd plugin --profile desktop add …`, and start Desktop once to initialize the profile, quit it fully, install, then reopen Desktop. **The GUI's Add plugin route spares you that dance** — it does exactly this for you. - **Source checkout (`pnpm dsh web`)** → `web`, using the `dsh` on PATH. Then **restart dsh** (reopen the Desktop application; bundle layers compose at boot). `/init` registers with the default `root` = the session workspace root (the receiving session's cwd, then the sandbox-policy workspace root, then the process cwd); if the repository to scan differs, override it in your home-level patch (`$DSH_HOME/cordis.patch.yml`) — id-targeted overrides win: ```yaml - id: dsh-init config: root: 'D:/WorkSpace/dsh' ``` Manual install without `dsh plugin`: `npm install --allow-git=all https://gitee.com/dk-1001/dsh-init-plugin.git` (npm 12+ disables git dependencies by default — `allow-git=none`; the flag re-enables them for this install), then add a row naming the package to your composition. The built `lib/` ships in the repository, so installs need no build step. ## Usage ``` /init /init focus on the test setup and the build pipeline ``` The command works in interactive UIs that provide a command adapter (Web/CLI). Headless and ACP surfaces have no command adapter and are out of scope for this plugin. ## Configuration | Key | Default | Meaning | |---|---|---| | `root` | Session workspace root (session cwd → sandbox-policy workspace root → `process.cwd()`) | Repository root to scan. The steered task pins the `AGENTS.md` target to this exact root, so a nested Git repository or subdirectory is never chosen. Absolute path or relative to the dsh working directory. | ```yaml - name: './dsh-init-plugin/src/index.ts' config: root: 'D:/WorkSpace/dsh' ``` ## Development ```sh pnpm install # typescript + @types/node pnpm run typecheck # tsc --noEmit pnpm run test # node --test "tests/**/*.spec.ts" (Node native TS, no test framework) pnpm run build # tsc → lib/ ``` ## Implementation notes - **Command registration** follows the conditional-injection pattern of `dsh-plan-mode`: `ctx.inject(['commands'], ...)` so the plugin activates its command only when a command registry is composed. - **Model-visible ⟺ logged**: the steered task message carries a plugin `source` (`{ kind: 'plugin', plugin: 'dsh-init', form: 'notice', summary }`), so the session log reconstructs exactly what reached the model. - **Scanner isolation**: `src/scan.ts` has zero dsh dependencies (Node builtins only), so it is testable standalone and its budgets bound token cost. - **Zero runtime dsh dependency**: `src/message.ts` reproduces the tiny `createUserMessage` contract from `@deepseek-ai/dsh-llm` (id + role + freeze, verified against the harness source) so the bundle loads anywhere, even before the harness packages are published. Swap back to the official import when they publish. - **Type surface**: `types/dsh.d.ts` declares only the Cordis command surface this plugin uses, because the vendored dsh sources are not resolvable from a standalone package yet. The runtime types come from the dsh host. Refresh the declarations when upstream types change (the shapes are mirrored from `dsh-plan-mode`). - **No dsh source patch**: the plugin composes into dsh; it does not modify the harness. ## Known limitations and deferred work - **Root-level only**: nested package `AGENTS.md` files (supported by dsh's hierarchical loading) are not generated yet — the scan notes them in the tree but the task targets the root file. - **Interactive surfaces only**: headless/ACP have no command adapter (dsh limitation, not a plugin one). - **No image input**: the command declares no `input.images`; future refinement could accept screenshots. - **Scan heuristics**: the constructor-scan budget and candidate lists are tuned for small-to-medium repositories; very large monorepos may need config overrides. ## License MIT