dsh-paste-file
v1.1.0
Published
Mac paste-file for the DSH composer: images attach as draft images; files and folders insert their original path (read from the OS clipboard) as a localized [文件]/[文件夹] or [File]/[Folder] line at the front of the message.
Maintainers
Readme
dsh-paste-file
Mac paste-file for the DSH composer. Paste a local file or folder into the composer input box and it is inserted as a path line at the front of the message — no copy of the content is sent, only the on-disk path.
What it does
Images paste normally: they attach as draft images (built-in composer behavior).
Files / folders show a full-bleed tile in the in-card attachment rail (so the composer grows like a pasted image), then on send (button or Enter) the placeholder tile is removed and a localized path line is prepended before your text:
[文件] /path/to/file.py /path/to/other.md [文件夹] /path/to/a/folderIn an English harness the labels become
[File]/[Folder]. The active language follows the DSH harness locale and defaults to Chinese when the locale is unknown.File placement (host side):
- Non-protected files → hard-linked into the paste dir (no copy).
- Small files (≤ 5 MB) from protected dirs (Downloads/Desktop/Documents) → copied (hard links share the inode and still trip the whole-directory TCC prompt).
- Large files → hard-linked only.
- Folders → referenced by their original path (folders cannot be hard-linked and copying a tree is too heavy).
Scope
This plugin only inserts files into the input box. It does not read or process file content. How the model reads a pasted file (text, PDF, audio, video, …) is left to the model and your own tools.
Package layout
This is a DSH bundle: it ships a cordis.patch.yml (declared by
dsh.bundle.patch) that mounts the paste-file plugin row, plus the host
half (lib/index.js) and client half (lib/client.js). Adding the package to
a profile's dsh.profile.bundles mounts it.
How the halves talk (no build step)
Both halves are self-contained and run on the bundle runtime, so there is no compile step — the browser client is served verbatim by the host's client-modules route.
- The host half is a normal Cordis plugin (no
harness). It exposes its file operations as a CordispasteFileService and registers them as Typert Remote invocations viactx.typert.register(...). - The client half is a classic
<script>registered throughwindow.__ModuleLoader__.load(...). It mounts the same Remote descriptors viactx.remote.$mount(...)and calls the Host throughctx.remote.pasteFile.*— the only client→host RPC channel bundle plugins have. It gets React viarequire("react").
Because the bundle runtime provides no host/harness globals (those are
dynamic-plugin-only), all file access goes through the Typert Remote channel.
Formal deployment
The client is self-contained, so no frontend rebuild and no DSH source checkout are required — a plain npm install of the published package is enough.
1. Publish the package
cd dsh-paste-file
npm publish2. Add the plugin to the web profile
dsh plugin --profile web add dsh-paste-fileThis installs the package into the profile's node_modules and appends
dsh-paste-file to dsh.profile.bundles. (Requires pnpm on PATH.)
3. Configure the paste dir (optional)
dir defaults to the DSH process's working directory + /.pasted — the
workspace the model can read — so no configuration is needed. Override it
only to place pasted files elsewhere, in the profile's cordis.patch.yml
($DSH_HOME/profiles/web/cordis.patch.yml):
- insert:
- id: paste-file
name: 'dsh-paste-file'
config:
dir: '/path/to/workspace/.pasted'4. Boot
dsh webThe plugin is now persistent — it auto-loads on every boot, no reinstall.
Configuration
The host half accepts a Cordis plugin config:
| key | type | default | meaning |
|-------------|--------|------------------------------------------------|-------------------------------------------|
| dir | string | <workspace>/.pasted (auto) | where pasted files are hard-linked/copied |
| protected | array | ['~/Downloads', '~/Desktop', '~/Documents'] | TCC-protected dirs whose small files copy |
Requirements
- macOS (reads the clipboard file URL via
osascript). - The DSH host provides the
typertservice; the client providesconversation,sessions,slots,timer,locale, andremote. The host half needs noshellservice — all file operations (osascript, hard-link/copy) run directly on the built-innode:fs/node:child_processmodules of the bundle host.
License
MIT
