dsh-typst-plugin 0.0.0-stage → 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.en.md +87 -0
- package/README.md +86 -2
- package/cordis.patch.yml +6 -0
- package/docs/images/icon.png +0 -0
- package/docs/plugin-detail.en.md +2 -0
- package/docs/plugin-detail.md +2 -0
- package/lib/client.js +41044 -0
- package/lib/client.js.map +7 -0
- package/lib/config.d.ts +50 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +31 -0
- package/lib/config.js.map +7 -0
- package/lib/constants.d.ts +58 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +62 -0
- package/lib/constants.js.map +7 -0
- package/lib/contract.d.ts +179 -0
- package/lib/contract.d.ts.map +1 -0
- package/lib/contract.js +1 -0
- package/lib/contract.js.map +7 -0
- package/lib/errors.d.ts +77 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +86 -0
- package/lib/errors.js.map +7 -0
- package/lib/host/facts.d.ts +31 -0
- package/lib/host/facts.d.ts.map +1 -0
- package/lib/host/facts.js +151 -0
- package/lib/host/facts.js.map +7 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +7 -0
- package/lib/remote.d.ts +69 -0
- package/lib/remote.d.ts.map +1 -0
- package/lib/remote.js +146 -0
- package/lib/remote.js.map +7 -0
- package/lib/service.d.ts +47 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +110 -0
- package/lib/service.js.map +7 -0
- package/lib/skills/typst.d.ts +13 -0
- package/lib/skills/typst.d.ts.map +1 -0
- package/lib/skills/typst.js +72 -0
- package/lib/skills/typst.js.map +7 -0
- package/lib/status-codec.d.ts +11 -0
- package/lib/status-codec.d.ts.map +1 -0
- package/lib/status-codec.js +6 -0
- package/lib/status-codec.js.map +7 -0
- package/lib/tools/registration.d.ts +22 -0
- package/lib/tools/registration.d.ts.map +1 -0
- package/lib/tools/registration.js +525 -0
- package/lib/tools/registration.js.map +7 -0
- package/lib/tools/shared.d.ts +31 -0
- package/lib/tools/shared.d.ts.map +1 -0
- package/lib/tools/shared.js +70 -0
- package/lib/tools/shared.js.map +7 -0
- package/lib/typert.d.ts +23 -0
- package/lib/typert.d.ts.map +1 -0
- package/lib/typert.js +67 -0
- package/lib/typert.js.map +7 -0
- package/lib/typst/diagnostics.d.ts +58 -0
- package/lib/typst/diagnostics.d.ts.map +1 -0
- package/lib/typst/diagnostics.js +171 -0
- package/lib/typst/diagnostics.js.map +7 -0
- package/lib/typst/locate.d.ts +68 -0
- package/lib/typst/locate.d.ts.map +1 -0
- package/lib/typst/locate.js +194 -0
- package/lib/typst/locate.js.map +7 -0
- package/lib/typst/mainfile.d.ts +21 -0
- package/lib/typst/mainfile.d.ts.map +1 -0
- package/lib/typst/mainfile.js +64 -0
- package/lib/typst/mainfile.js.map +7 -0
- package/lib/typst/match.d.ts +59 -0
- package/lib/typst/match.d.ts.map +1 -0
- package/lib/typst/match.js +171 -0
- package/lib/typst/match.js.map +7 -0
- package/lib/typst/oneshot.d.ts +45 -0
- package/lib/typst/oneshot.d.ts.map +1 -0
- package/lib/typst/oneshot.js +76 -0
- package/lib/typst/oneshot.js.map +7 -0
- package/lib/typst/pdf-extract.d.ts +29 -0
- package/lib/typst/pdf-extract.d.ts.map +1 -0
- package/lib/typst/pdf-extract.js +87 -0
- package/lib/typst/pdf-extract.js.map +7 -0
- package/lib/typst/pdfjs-worker.d.js +1 -0
- package/lib/typst/pdfjs-worker.d.js.map +7 -0
- package/lib/typst/text.d.ts +65 -0
- package/lib/typst/text.d.ts.map +1 -0
- package/lib/typst/text.js +314 -0
- package/lib/typst/text.js.map +7 -0
- package/lib/typst/watcher.d.ts +77 -0
- package/lib/typst/watcher.d.ts.map +1 -0
- package/lib/typst/watcher.js +219 -0
- package/lib/typst/watcher.js.map +7 -0
- package/lib/wire-schemas.d.ts +578 -0
- package/lib/wire-schemas.d.ts.map +1 -0
- package/lib/wire-schemas.js +384 -0
- package/lib/wire-schemas.js.map +7 -0
- package/lib/workspace/session.d.ts +209 -0
- package/lib/workspace/session.d.ts.map +1 -0
- package/lib/workspace/session.js +1232 -0
- package/lib/workspace/session.js.map +7 -0
- package/locale/en.json +9 -0
- package/locale/zh.json +9 -0
- package/package.json +256 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/service.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * `ctx.typstWorkbench`: the plugin's stable boundary. It owns the per-\n * workspace `WorkspaceSession` registry (one `typst watch` per workspace\n * root, stopped on dispose), the plugin configuration lifecycle, the Typert\n * manifest and scope lookup, and the agent tools. Host half only.\n *\n * Request-driven like the dsh-zotero core: loading the plugin never spawns\n * typst and touches nothing on disk. The first tool call, or the first\n * panel subscription on a workspace, starts that workspace's session.\n * @module dsh-typst/service\n */\n\nimport { realpath } from \"node:fs/promises\";\nimport { Service, type Context } from \"@deepseek-ai/cordis\";\n// Type-only: the loader `loader/volatile-update` merge for the config reaction.\nimport type {} from \"@deepseek-ai/cordis-plugin-loader\";\nimport { dshCachePath } from \"@deepseek-ai/dsh-home-paths\";\nimport type {} from \"@deepseek-ai/dsh-typert-registry\";\nimport {\n Config,\n readResolvedConfig,\n toLiveEntry,\n type LiveEntry,\n} from \"./config.js\";\nimport { registerTypstTools } from \"./tools/registration.js\";\nimport { registerTypstSkill } from \"./skills/typst.js\";\nimport { TypstRuntime } from \"./remote.js\";\nimport { TYPERT_MANIFEST } from \"./typert.js\";\nimport { WorkspaceSession } from \"./workspace/session.js\";\n\ndeclare module \"@deepseek-ai/cordis\" {\n interface Context {\n typstWorkbench: TypstWorkbenchService;\n }\n}\n\nexport class TypstWorkbenchService extends Service {\n static inject = [\"tools\"];\n\n static Config = Config;\n\n /** Live entry config: volatile references re-read per request. */\n private readonly entry: LiveEntry;\n\n /** Workspace sessions keyed by resolved workspace root. */\n private readonly sessions = new Map<string, WorkspaceSession>();\n\n constructor(ctx: Context, config: Config) {\n super(ctx, \"typstWorkbench\");\n this.entry = toLiveEntry(config);\n }\n\n /** The live entry's current values, read per request. */\n private get resolved(): { typstPath: string } {\n return readResolvedConfig(this.entry);\n }\n\n protected async [Service.init](): Promise<void> {\n const ctx = this.ctx;\n // The manifest describes the wire surface, but the Gateway invokes a\n // live Cordis service. Keep the runtime under this service's ownership so\n // it is present for every request and is disposed with the workbench.\n ctx.plugin(TypstRuntime);\n // The scope lookup resolves the wire SessionId to the workspace root\n // (the `workspaceFileScope` pattern from dsh-api-workspace-files).\n ctx.inject([\"sessions\", \"typert\"], (scope) => {\n scope.effect(\n () => scope.typert.register(TYPERT_MANIFEST),\n \"typst: wire manifest\",\n );\n scope.effect(\n () =>\n scope.typert.lookups.register(\"typstScope\", {\n parameter: \"typstScope\",\n wire: \"typstScopeId\",\n resource: \"session\",\n hostTypeSymbol: \"dsh-typst#TypstScope\",\n // The invocation codec carries the public TypstScopeId alias;\n // strict Gateway resolution requires this symbol to match it.\n wireTypeSymbol: \"@deepseek-ai/dsh-typst#TypstScopeId\",\n resolve: (sessionId) => {\n const header = scope.sessions.get(sessionId)?.header;\n if (header === undefined) return undefined;\n return {\n sessionId,\n workspaceRoot:\n header.cwd ??\n scope.get(\"workingDirectory\")?.defaultDirectory ??\n process.cwd(),\n };\n },\n }),\n \"typst: session scope lookup\",\n );\n });\n // A changed Typst path makes every live workspace look the binary up\n // again (the watcher restarts; sessions converge without remounting).\n ctx.on(\"loader/volatile-update\", () => {\n void this.recheckAll();\n });\n // Ordered teardown: close every session (watchers included).\n ctx.effect(() => {\n const sessions = [...this.sessions.values()];\n return async () => {\n await Promise.all(sessions.map((session) => session.close()));\n this.sessions.clear();\n };\n }, \"typst: session teardown\");\n // Process exit: synchronous tree kill.\n ctx.effect(\n () => () => {\n for (const session of this.sessions.values()) session.killNow();\n },\n \"typst: process-exit kill\",\n );\n registerTypstTools(ctx, this);\n registerTypstSkill(ctx);\n }\n\n /** The configured Typst path setting ('' = look it up). */\n get typstPath(): string {\n return this.resolved.typstPath;\n }\n\n /**\n * The workspace's session, creating it on first use. Keyed by the\n * realpath of the workspace root so symlinked paths of the same workspace\n * share one watcher.\n * @param workspaceRoot - the session workspace's absolute root.\n */\n async sessionFor(workspaceRoot: string): Promise<WorkspaceSession> {\n const root = await realpath(workspaceRoot).catch(() => workspaceRoot);\n const existing = this.sessions.get(root);\n if (existing !== undefined) return existing;\n const session = new WorkspaceSession({\n workspaceRoot: root,\n typstPath: this.typstPath || undefined,\n dataDir: dshCachePath(\"typst\"),\n log: (message) => this.ctx.logger.debug(`[dsh-typst] ${message}`),\n });\n this.sessions.set(root, session);\n return session;\n }\n\n /** A changed Typst path makes every live session look the binary up again. */\n private async recheckAll(): Promise<void> {\n for (const session of this.sessions.values()) {\n await session.recheck(true).catch(() => undefined);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `typst` skill: the agent-facing guidance for working on Typst
|
|
3
|
+
* documents with the workbench. Ported from the ZCode typst-workbench's
|
|
4
|
+
* SKILL.md and adapted to this plugin's tool names and the panel's message
|
|
5
|
+
* protocol. Host half only.
|
|
6
|
+
* @module dsh-typst/skills
|
|
7
|
+
*/
|
|
8
|
+
import type { SkillRegistration } from "@deepseek-ai/dsh-skill";
|
|
9
|
+
/** The skill registration the service mounts. */
|
|
10
|
+
export declare function typstSkill(): SkillRegistration;
|
|
11
|
+
/** Register the skill on the host's skill registry. */
|
|
12
|
+
export declare function registerTypstSkill(ctx: import("@deepseek-ai/cordis").Context): void;
|
|
13
|
+
//# sourceMappingURL=typst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typst.d.ts","sourceRoot":"","sources":["../../src/skills/typst.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAuDhE,iDAAiD;AACjD,wBAAgB,UAAU,IAAI,iBAAiB,CAY9C;AAED,uDAAuD;AACvD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,qBAAqB,EAAE,OAAO,GACzC,IAAI,CAIN"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const CONTENT = [
|
|
2
|
+
"# Typst workbench",
|
|
3
|
+
"",
|
|
4
|
+
"The plugin runs the user's own `typst` (their fonts, packages and version) as a long-running `typst watch` and shows the result in the Typst side panel. **The preview updates by itself whenever a file is saved** \u2014 edit `.typ` files with your normal file tools; the plugin never edits files.",
|
|
5
|
+
"",
|
|
6
|
+
"## 1. Orient",
|
|
7
|
+
"",
|
|
8
|
+
"- Call `typst_status` first. It reports the Typst version, the main file, the other `.typ` files and the latest compile result.",
|
|
9
|
+
"- `TYPST_MISSING` / `TYPST_TOO_OLD` / `TYPST_UNUSABLE`: Typst is not usable. Tell the user, and point them at the Typst panel: it lists what is missing and can send you a setup request with the facts it detected. Do not install software unless the user asks \u2014 an explicitly submitted setup request from the panel is such a request.",
|
|
10
|
+
"- `TYPST_NO_MAIN`: pick the file the user would pass to `typst compile` (the one that `#include`s or `#import`s the others) and call `typst_set_main`; ask if it is unclear. If there are no `.typ` files, create `main.typ` \u2014 the panel picks it up.",
|
|
11
|
+
"- Follow the project's existing structure and conventions (templates, `#import`ed packages, file layout). Use the user's Typst version's syntax; `typst_status` tells you the version.",
|
|
12
|
+
"",
|
|
13
|
+
"## 2. The edit loop",
|
|
14
|
+
"",
|
|
15
|
+
"1. Edit the source files.",
|
|
16
|
+
"2. Call `typst_check` right after editing. It waits until Typst has compiled every change already on disk and returns errors and warnings as `file:line:column`, the source line, Typst's `hint:` lines and the call trace (`from \u2026`). Fix errors at the reported location; follow the hints.",
|
|
17
|
+
"3. While the document has errors the panel keeps showing the last version that compiled, so fix errors before asking the user to look.",
|
|
18
|
+
"4. When layout matters (overfull lines, figure and table placement, page breaks, title pages, slides), call `typst_render_pages` for the affected pages (at most 4 per call; default 110 ppi, raise `ppi` to inspect details) and look at the images. Compile errors do not catch layout problems.",
|
|
19
|
+
"",
|
|
20
|
+
"Do not run `typst compile` or `typst watch` in a shell for previewing; use these tools. A shell `typst` is fine for one-off tasks the tools do not cover (e.g. `typst fonts`, `typst query`).",
|
|
21
|
+
"",
|
|
22
|
+
"## 3. Point at things in the preview",
|
|
23
|
+
"",
|
|
24
|
+
"- `typst_show` with `page` creates a location notification; the user clicks it to navigate.",
|
|
25
|
+
'- `typst_show` with `quote` highlights rendered text (copy the words as they appear in the document; markup is ignored), or with `file` + `line` (+ `endLine`) highlights what those source lines produce. Add a short `comment` explaining why. Use this after making a change the user should look at, or when answering "where is \u2026".',
|
|
26
|
+
"- Highlights follow the text as the document changes and last for the session; `typst_clear_highlights` removes them.",
|
|
27
|
+
"",
|
|
28
|
+
"## 4. What the user sends from the panel",
|
|
29
|
+
"",
|
|
30
|
+
"- Preview feedback includes the main file, snapshot identity, selected text or screenshots, and optionally an approximate source excerpt. Check excerpts and snapshot age before editing; text matching is approximate for math, numbering, bibliographies and generated text.",
|
|
31
|
+
"- Repair requests contain a compile run and reviewed diagnostics. Fix the requested scope and run `typst_check`; acceptance of a request does not mean compilation succeeded.",
|
|
32
|
+
"- Add to chat appends selected text to the user\u2019s existing composer draft. A submitted screenshot request is a normal session message with uploaded images; inspect the image and its PDF-space region coordinates.",
|
|
33
|
+
"",
|
|
34
|
+
"## 5. Export",
|
|
35
|
+
"",
|
|
36
|
+
'`typst_export_pdf` compiles with the user\'s Typst and writes a PDF into the workspace (e.g. `typst_export_pdf { path: "paper.pdf" }`), optionally with a PDF standard (`pdfStandard: "a-2b"`) or a page selection. The preview\'s own PDF is not in the workspace.',
|
|
37
|
+
"",
|
|
38
|
+
"## 6. Citations",
|
|
39
|
+
"",
|
|
40
|
+
'Typst reads BibTeX (`.bib`) and Hayagriva (`.yml`) files with `#bibliography("refs.bib")` and cites with `@key`. If the Zotero plugin is available, use its `zotero_export` to write the `.bib` file and use the citation keys it returns; never invent keys.',
|
|
41
|
+
"",
|
|
42
|
+
"## 7. Setting up Typst",
|
|
43
|
+
"",
|
|
44
|
+
"When the user asks you to install, update or fix Typst \u2014 usually with the panel's message, which lists the operating system, the folders it searched and the package managers it found \u2014 follow its steps:",
|
|
45
|
+
"",
|
|
46
|
+
"- Use the package manager the message names: `brew install typst` (Homebrew), `winget install --id Typst.Typst`, `scoop install typst`, or `cargo install --locked typst-cli`. Without one, use a release from https://github.com/typst/typst/releases. Update an old Typst with the tool that installed it.",
|
|
47
|
+
"- Ask before using `sudo`, installing a package manager, or editing shell profiles.",
|
|
48
|
+
"- Confirm with `typst --version` (0.12 or later).",
|
|
49
|
+
"- The panel looks on PATH, in the usual install folders (Homebrew, `~/.cargo/bin`, `~/.local/bin`, \u2026) and in the login shell. If Typst ends up somewhere else, tell the user the full path for the plugin setting *Typst path*.",
|
|
50
|
+
"- The panel checks again every few seconds and starts the preview by itself; then call `typst_status`."
|
|
51
|
+
].join("\n");
|
|
52
|
+
function typstSkill() {
|
|
53
|
+
return {
|
|
54
|
+
name: "typst",
|
|
55
|
+
description: "Write and fix Typst documents (.typ) with a live preview in the Typst side panel \u2014 compile with the user's own Typst, read errors with file:line and hints, look at rendered pages as images, point at places in the preview, and export PDFs.",
|
|
56
|
+
whenToUse: "Use when the user works on a Typst document (papers, theses, reports, letters, CVs, slides with touying/polylux), mentions Typst or a .typ file, asks to typeset or lay out something in Typst, or when the panel sends a selection, a source location or Typst problems.",
|
|
57
|
+
source: "runtime",
|
|
58
|
+
invocation: { modelInvocable: true, userInvocable: true },
|
|
59
|
+
metadata: { component: "typst" },
|
|
60
|
+
content: CONTENT
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function registerTypstSkill(ctx) {
|
|
64
|
+
ctx.inject(["skills"], (host) => {
|
|
65
|
+
host.effect(() => host.skills.register(typstSkill()), "typst: skill");
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
registerTypstSkill,
|
|
70
|
+
typstSkill
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=typst.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/skills/typst.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The `typst` skill: the agent-facing guidance for working on Typst\n * documents with the workbench. Ported from the ZCode typst-workbench's\n * SKILL.md and adapted to this plugin's tool names and the panel's message\n * protocol. Host half only.\n * @module dsh-typst/skills\n */\n\nimport type { SkillRegistration } from \"@deepseek-ai/dsh-skill\";\n\n/** The skill body: orient \u2192 edit loop \u2192 point \u2192 panel input \u2192 export \u2192 citations \u2192 setup. */\nconst CONTENT = [\n \"# Typst workbench\",\n \"\",\n \"The plugin runs the user's own `typst` (their fonts, packages and version) as a long-running `typst watch` and shows the result in the Typst side panel. **The preview updates by itself whenever a file is saved** \u2014 edit `.typ` files with your normal file tools; the plugin never edits files.\",\n \"\",\n \"## 1. Orient\",\n \"\",\n \"- Call `typst_status` first. It reports the Typst version, the main file, the other `.typ` files and the latest compile result.\",\n \"- `TYPST_MISSING` / `TYPST_TOO_OLD` / `TYPST_UNUSABLE`: Typst is not usable. Tell the user, and point them at the Typst panel: it lists what is missing and can send you a setup request with the facts it detected. Do not install software unless the user asks \u2014 an explicitly submitted setup request from the panel is such a request.\",\n \"- `TYPST_NO_MAIN`: pick the file the user would pass to `typst compile` (the one that `#include`s or `#import`s the others) and call `typst_set_main`; ask if it is unclear. If there are no `.typ` files, create `main.typ` \u2014 the panel picks it up.\",\n \"- Follow the project's existing structure and conventions (templates, `#import`ed packages, file layout). Use the user's Typst version's syntax; `typst_status` tells you the version.\",\n \"\",\n \"## 2. The edit loop\",\n \"\",\n \"1. Edit the source files.\",\n \"2. Call `typst_check` right after editing. It waits until Typst has compiled every change already on disk and returns errors and warnings as `file:line:column`, the source line, Typst's `hint:` lines and the call trace (`from \u2026`). Fix errors at the reported location; follow the hints.\",\n \"3. While the document has errors the panel keeps showing the last version that compiled, so fix errors before asking the user to look.\",\n \"4. When layout matters (overfull lines, figure and table placement, page breaks, title pages, slides), call `typst_render_pages` for the affected pages (at most 4 per call; default 110 ppi, raise `ppi` to inspect details) and look at the images. Compile errors do not catch layout problems.\",\n \"\",\n \"Do not run `typst compile` or `typst watch` in a shell for previewing; use these tools. A shell `typst` is fine for one-off tasks the tools do not cover (e.g. `typst fonts`, `typst query`).\",\n \"\",\n \"## 3. Point at things in the preview\",\n \"\",\n \"- `typst_show` with `page` creates a location notification; the user clicks it to navigate.\",\n '- `typst_show` with `quote` highlights rendered text (copy the words as they appear in the document; markup is ignored), or with `file` + `line` (+ `endLine`) highlights what those source lines produce. Add a short `comment` explaining why. Use this after making a change the user should look at, or when answering \"where is \u2026\".',\n \"- Highlights follow the text as the document changes and last for the session; `typst_clear_highlights` removes them.\",\n \"\",\n \"## 4. What the user sends from the panel\",\n \"\",\n \"- Preview feedback includes the main file, snapshot identity, selected text or screenshots, and optionally an approximate source excerpt. Check excerpts and snapshot age before editing; text matching is approximate for math, numbering, bibliographies and generated text.\",\n \"- Repair requests contain a compile run and reviewed diagnostics. Fix the requested scope and run `typst_check`; acceptance of a request does not mean compilation succeeded.\",\n \"- Add to chat appends selected text to the user\u2019s existing composer draft. A submitted screenshot request is a normal session message with uploaded images; inspect the image and its PDF-space region coordinates.\",\n \"\",\n \"## 5. Export\",\n \"\",\n '`typst_export_pdf` compiles with the user\\'s Typst and writes a PDF into the workspace (e.g. `typst_export_pdf { path: \"paper.pdf\" }`), optionally with a PDF standard (`pdfStandard: \"a-2b\"`) or a page selection. The preview\\'s own PDF is not in the workspace.',\n \"\",\n \"## 6. Citations\",\n \"\",\n 'Typst reads BibTeX (`.bib`) and Hayagriva (`.yml`) files with `#bibliography(\"refs.bib\")` and cites with `@key`. If the Zotero plugin is available, use its `zotero_export` to write the `.bib` file and use the citation keys it returns; never invent keys.',\n \"\",\n \"## 7. Setting up Typst\",\n \"\",\n \"When the user asks you to install, update or fix Typst \u2014 usually with the panel's message, which lists the operating system, the folders it searched and the package managers it found \u2014 follow its steps:\",\n \"\",\n \"- Use the package manager the message names: `brew install typst` (Homebrew), `winget install --id Typst.Typst`, `scoop install typst`, or `cargo install --locked typst-cli`. Without one, use a release from https://github.com/typst/typst/releases. Update an old Typst with the tool that installed it.\",\n \"- Ask before using `sudo`, installing a package manager, or editing shell profiles.\",\n \"- Confirm with `typst --version` (0.12 or later).\",\n \"- The panel looks on PATH, in the usual install folders (Homebrew, `~/.cargo/bin`, `~/.local/bin`, \u2026) and in the login shell. If Typst ends up somewhere else, tell the user the full path for the plugin setting *Typst path*.\",\n \"- The panel checks again every few seconds and starts the preview by itself; then call `typst_status`.\",\n].join(\"\\n\");\n\n/** The skill registration the service mounts. */\nexport function typstSkill(): SkillRegistration {\n return {\n name: \"typst\",\n description:\n \"Write and fix Typst documents (.typ) with a live preview in the Typst side panel \u2014 compile with the user's own Typst, read errors with file:line and hints, look at rendered pages as images, point at places in the preview, and export PDFs.\",\n whenToUse:\n \"Use when the user works on a Typst document (papers, theses, reports, letters, CVs, slides with touying/polylux), mentions Typst or a .typ file, asks to typeset or lay out something in Typst, or when the panel sends a selection, a source location or Typst problems.\",\n source: \"runtime\",\n invocation: { modelInvocable: true, userInvocable: true },\n metadata: { component: \"typst\" },\n content: CONTENT,\n };\n}\n\n/** Register the skill on the host's skill registry. */\nexport function registerTypstSkill(\n ctx: import(\"@deepseek-ai/cordis\").Context,\n): void {\n ctx.inject([\"skills\"], (host) => {\n host.effect(() => host.skills.register(typstSkill()), \"typst: skill\");\n });\n}\n"],
|
|
5
|
+
"mappings": "AAWA,MAAM,UAAU;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAGJ,SAAS,aAAgC;AAC9C,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aACE;AAAA,IACF,WACE;AAAA,IACF,QAAQ;AAAA,IACR,YAAY,EAAE,gBAAgB,MAAM,eAAe,KAAK;AAAA,IACxD,UAAU,EAAE,WAAW,QAAQ;AAAA,IAC/B,SAAS;AAAA,EACX;AACF;AAGO,SAAS,mBACd,KACM;AACN,MAAI,OAAO,CAAC,QAAQ,GAAG,CAAC,SAAS;AAC/B,SAAK,OAAO,MAAM,KAAK,OAAO,SAAS,WAAW,CAAC,GAAG,cAAc;AAAA,EACtE,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only alias of the shared wire boundary: the host Typert manifest's
|
|
3
|
+
* invocations are exactly the shared list (`wire-schemas.ts`), materialized
|
|
4
|
+
* with real zod factories. The client arm (`src/client/status-codec.ts`)
|
|
5
|
+
* aliases the same list, so neither side can drift.
|
|
6
|
+
* @module dsh-typst/status-codec
|
|
7
|
+
*/
|
|
8
|
+
import type { InvocationDescriptor } from "@deepseek-ai/dsh-typert-protocol";
|
|
9
|
+
/** Host Typert manifest invocations (real zod factory). */
|
|
10
|
+
export declare const TYPST_INVOCATIONS_HOST: readonly InvocationDescriptor[];
|
|
11
|
+
//# sourceMappingURL=status-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-codec.d.ts","sourceRoot":"","sources":["../src/status-codec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,2DAA2D;AAC3D,eAAO,MAAM,sBAAsB,EAAE,SAAS,oBAAoB,EAC/C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/status-codec.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Host-only alias of the shared wire boundary: the host Typert manifest's\n * invocations are exactly the shared list (`wire-schemas.ts`), materialized\n * with real zod factories. The client arm (`src/client/status-codec.ts`)\n * aliases the same list, so neither side can drift.\n * @module dsh-typst/status-codec\n */\n\nimport type { InvocationDescriptor } from \"@deepseek-ai/dsh-typert-protocol\";\nimport { TYPST_INVOCATIONS } from \"./wire-schemas.js\";\n\n/** Host Typert manifest invocations (real zod factory). */\nexport const TYPST_INVOCATIONS_HOST: readonly InvocationDescriptor[] =\n TYPST_INVOCATIONS;\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,yBAAyB;AAG3B,MAAM,yBACX;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seven agent tools of the Typst workbench. Semantics ported from the
|
|
3
|
+
* ZCode typst-workbench server (0.2.0); schemas follow the dsh-zotero tool
|
|
4
|
+
* conventions (value-schema literals with per-property `required`, canonical
|
|
5
|
+
* JSON output plus a model-facing render, one registration effect per tool).
|
|
6
|
+
* Host half only.
|
|
7
|
+
*
|
|
8
|
+
* `typst_render_pages` returns base64 PNGs in its canonical value and the
|
|
9
|
+
* client's `tool.call.toolview` view displays them inline; the model-facing
|
|
10
|
+
* render stays text (the canonical JSON is persistence and toolview data).
|
|
11
|
+
* @module dsh-typst/tools/registration
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
14
|
+
import type { TypstWorkbenchService } from "../service.js";
|
|
15
|
+
/**
|
|
16
|
+
* Register the seven tools, one effect each (unregistration is the
|
|
17
|
+
* effect's own teardown).
|
|
18
|
+
* @param ctx - the plugin context.
|
|
19
|
+
* @param service - the workbench service the tools resolve sessions through.
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerTypstTools(ctx: Context, service: TypstWorkbenchService): void;
|
|
22
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../src/tools/registration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAokB3D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAgBN"}
|