diff --git a/.dsh-version.json b/.dsh-version.json index 6be2944..11edae1 100644 --- a/.dsh-version.json +++ b/.dsh-version.json @@ -42,12 +42,12 @@ ] }, "dsh-editor": { - "version": "0.1.0-alpha.15", + "version": "0.1.0-alpha.16", "rows": [ "editor" ], "rowOverrides": [], - "role": "Editor: the tab type for text and code - a vendored CodeMirror 6 fetched lazily - with create-on-save inside the session workspace through this package's own authenticated routes. Markdown is claimed too, and hands off to the shipped preview. See packages/dsh-editor/README.md.", + "role": "Editor: the tab type for text and code - a vendored CodeMirror 6 fetched lazily - with create-on-save inside the session workspace through this package's own authenticated routes. Markdown is claimed too, and hands off to the shipped preview, whose rendered body exports the file to a PDF on the Desktop. See packages/dsh-editor/README.md.", "uses": [ "dsh-modal", "@deepseek-ai/dsh-client-ui-theme", diff --git a/README.md b/README.md index 824dd93..0e81b77 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ way and what it touches. The exact versions are in | [`dsh-deckcraft`](packages/dsh-deckcraft/README.md) | Slides from the chat: four `deck_*` tools over the DeckCraft CLI (MIT OR Apache-2.0). `deck_commands` lists the command ids the build offers, `deck_run` saves a `.deckcraft` in the workspace, `deck_export` renders the slides to PNG so you can look at them. Nothing is hardcoded: DeckCraft's "every button is a command" contract is the API. | | [`dsh-diagrams`](packages/dsh-diagrams/README.md) | Mermaid, TikZ and the Diagram Design kit as tabs and as seven `diagram_*` tools. The kit 204 examples and 44 documented types are vendored at a pinned commit and browsable on the index page. Every write, including a self-contained HTML document, is validated before it is stored. | | [`dsh-docker`](packages/dsh-docker/README.md) | Docker or Podman as a surface: nine `docker_*` tools over the machine's own CLI, argv-only, with every removal confirmed by repeating the target. `docker_start` launches Docker Desktop or a podman machine and waits for the **daemon**. A Docker tab lists containers and images with their logs, and there is no `exec`, no `system prune` and no free-form `run`. | -| [`dsh-editor`](packages/dsh-editor/README.md) | Text and code tabs over a vendored CodeMirror 6, with save/create and a Markdown preview. Every extension is mapped through a guard, so an older engine opens the document unhighlighted instead of killing the tab. It also backs the `.scd`, diagram-source and research-document editors. | +| [`dsh-editor`](packages/dsh-editor/README.md) | Text and code tabs over a vendored CodeMirror 6, with save/create and a Markdown preview. The preview exports the file as a PDF on the Desktop (the browser on the machine does the printing). Every extension is mapped through a guard, so an older engine opens the document unhighlighted instead of killing the tab. It also backs the `.scd`, diagram-source and research-document editors. | | [`dsh-frontend-craft`](packages/dsh-frontend-craft/README.md) | Front-end design craft: Impeccable's Apache-2.0 corpus vendored at a pinned commit, plus its 61-rule detector built to WebAssembly inside the package. Five `fe_*` tools include `fe_render`, which renders a page in headless Chrome or Edge and measures contrast, tap targets and overflow. There is no `npx impeccable`, no engine download and no network. A Frontend tab shows findings, artifacts and the direction round. | | [`dsh-gittree`](packages/dsh-gittree/README.md) | A read-only History tab: the workspace commits as a graph rail with lanes, merges and PR chips. Each commit lists the files it touched. It never runs a write. | | [`dsh-huggingface`](packages/dsh-huggingface/README.md) | The Hub as a surface the agent can interrogate before it downloads: five `hf_*` tools over the machine's own `hf` CLI and the cache on disk. `hf_repo` gives one repo's licence, gated flag, weight (the Hub's `used_storage`, labelled as such) and whether this disk already has it — complete, metadata-only, stale or absent; `hf_status` counts the stubs that look cached and cannot load; `hf_cache` verifies and reclaims, with an unconfirmed removal being the CLI's own dry run; `hf_download` reports the weight, refuses over a ceiling, and needs the repo id repeated back. For a repo already cached it also sizes the LOAD — parameters from the weight bytes, the KV cache per token from the checkpoint's own attention heads, and a context table that says FITS against the `freeBytes` you pass — without loading the model. Two skills teach the CLI and the cache layout. Host-only, zero npm dependencies, no bundled engine. | diff --git a/docs/COMPATIBILITY.md b/docs/COMPATIBILITY.md index 4b8ec59..cfce736 100644 --- a/docs/COMPATIBILITY.md +++ b/docs/COMPATIBILITY.md @@ -25,7 +25,7 @@ person's own browser, which the launcher finds (Chrome first, the OS opener as t | `dsh-vn-master` | `master` | the pack's final layer (installs last). Carries pack-wide row decisions; today it disables the `browser` row (the Browser tab is built and shipped but off, which also removes its routes and tools) and the four feedback rows `ui-message-feedback`, `message-feedback`, `command-feedback`, `session-telemetry-otel` | | `dsh-rightbar` | `rightbar` | the right bar, a fork of the shipped bundle; disables `ui-sidebar-right` and `ui-sidebar-files` | | `dsh-rightbar-files` | `rightbar-files` | the Files tab on that bar (fork) | -| `dsh-editor` | `editor` | CodeMirror tab type for text and code, Markdown included, blank documents from "+", Preview/Edit hand-off to the rendered view | +| `dsh-editor` | `editor` | CodeMirror tab type for text and code, Markdown included, blank documents from "+", Preview/Edit hand-off to the rendered view, and Export PDF to the Desktop | | `dsh-gittree` | `gittree` | **History**: read-only commit list with a branch-lane graph; needs `git` on `PATH` | | `dsh-image` | `image` | image viewer (PNG, JPEG, GIF, WebP, AVIF, BMP, ICO, SVG, TIFF) | | `dsh-docker` | `docker` | Docker or Podman as tools and a tab; needs `docker`/`podman` on `PATH`, and `docker_start` needs Docker Desktop where it is installed | diff --git a/packages/dsh-editor/README.md b/packages/dsh-editor/README.md index ec23947..391e6df 100644 --- a/packages/dsh-editor/README.md +++ b/packages/dsh-editor/README.md @@ -1,4 +1,4 @@ -# dsh-editor (alpha.14) +# dsh-editor (alpha.16) **A CodeMirror 6 tab type for the pack's right bar (`dsh-rightbar`) that opens text files editable.** It registers the id `dsh-editor` and the kind `editor` through the bar's own tab-type registry, with its body and chip title in the keyed `sidebar.right.pane.tab` / `sidebar.right.pane.tab.title` seats and a guide entry at `order: 20` for the "+" control. It is text-only (strict UTF-8, binary refused), starts blank documents, and writes through authenticated Node routes because `remote.workspaceFiles` exposes no mutation operation. @@ -11,6 +11,7 @@ - **The language map.** Every extension is mapped in `languageExtensionFor` and every lookup goes through a guard, so an engine older than the bundle opens the document unhighlighted rather than killing the tab. Lezer factories (function shape) via `engineLanguage` cover javascript (js/mjs/cjs/jsx/ts/tsx), json (json/jsonc), markdown (md/markdown/mdown), python (py/pyw), html (html/htm/xhtml), css and yaml (yaml/yml). CM5-style **StreamParser objects** (found by their `token()`, via `engineStreamMode`) cover shell (sh/bash/zsh/ksh/dash), powerShell (ps1/psm1/psd1), batch (bat/cmd, from the pack's own `vendor/batch-mode.js`), rust (rs) and toml (toml) from the vendored `@codemirror/legacy-modes`. Each returns `null` plus one console warning naming the missing factory and the rebuild command, so `languageExtensionFor` has no direct `CM.(...)` call. - **The palette follows the app's theme**: **oneDark only while the app is dark**, a token-driven transparent light layer otherwise, switched live through a CodeMirror `Compartment` reconfigured off `ctx.get('theme')` / `theme/change`, with `body[data-ds-dark-theme]` as the fallback. Both theme services are resolved lazily. - **The rendered Markdown body is shadowed.** The keyed `sidebar.right.tab.document` slot is registered at `priority: -10` (lowest renders), so only the page body is this package's while the shipped preview keeps its chrome; uninstalling brings the shipped body back. That body carries an **Edit** pill back to the editor and undoes what the preview's plain-text scrollport imposes (`white-space:pre` and the mono stack). +- **Export PDF, left of Edit (alpha.16).** The rendered body carries a second pill, the same size as Edit: it saves **the file on disk** as a PDF on the Desktop. The client sends only `{session, path}`; the Node half reads the file itself (never a body the tab could have edited), renders it as one **self-contained HTML page** and asks the browser already on the machine to print it (`lib/export-pdf.js`). The destination is the host's real Desktop - a OneDrive-redirected Windows profile, a `XDG_DESKTOP_DIR` Linux folder, or the home folder as the last resort - resolved per request, and `DSH_EDITOR_PDF_DIR` redirects it for a test or for someone whose Desktop is elsewhere. An export never replaces a file: the second one is `name (2).pdf`. The button reports `Exporting…`, then `Saved ✓` with the path in its tooltip, or `Export failed` with the route's reason. - **Authored HTML is rendered, and images resolve (alpha.14).** The shipped Markdown primitive draws raw HTML as literal text and only resolves an image when it is handed a `pathImages` vocabulary, so a README with a centred badge row, a ``, `
` or `![shot](docs/shot.png)` showed its own markup and broken pictures. The shadow body now parses **block-level HTML** itself and rebuilds it as **React elements over an allowlist** — nothing becomes an HTML string, so there is no `innerHTML` to poison and no attribute spelling that can smuggle an `onerror=` through: `', + '```', + '', +].join('\n') +const exportHtml = exportModule.buildPrintDocument(exportMarkdown, { + title: 'Document title', + rootDir: exportRoot, + filePath: path.join(exportDir, 'doc.md'), +}) +check('export renderer: headings, Chinese and links', exportHtml.includes('

Title \u4f60\u597d

') && exportHtml.includes('bold') && exportHtml.includes('a link')) +check('export renderer: tables with their alignment', exportHtml.includes('
') && exportHtml.includes('')) +check('export renderer: fenced code keeps its language', exportHtml.includes('
const x = 1
')) +const labelInFence = exportModule.buildPrintDocument('```\n[ref]: https://example.test\n```\n\n[ref]', {}) +check( + 'export renderer: a reference definition inside a fence stays code', + labelInFence.includes('[ref]: https://example.test') && labelInFence.includes('

[ref]

'), +) +check('export renderer: a local image is embedded, never fetched', exportHtml.includes('remote<') && exportHtml.includes('never-fetched.png') === false) +check('export renderer: an authored container keeps its Markdown', exportHtml.includes('

Centered

')) +check('export renderer: a details element is drawn open', exportHtml.includes('
') && exportHtml.includes('Shown when printed.')) +check('export renderer: a fenced ') === false) +check('export renderer: the page is self-contained', exportHtml.startsWith('') && exportHtml.includes('
Left1