@lukstei/dsh-debug 0.0.0-stage → 0.2.2-rc.5.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lukas Steinbrecher
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # @lukstei/dsh-debug
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Summary
4
+
5
+ Adds two slash commands that copy the current session's transcript or ID to the clipboard. Use them to attach a session to a bug report.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Use this package](#use-this-package)
10
+ - [Understand the implementation](#understand-the-implementation)
11
+ - [Further Exploration](#further-exploration)
12
+ - [Model Experience](#model-experience)
13
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
14
+ - [Dev Note](#dev-note)
15
+
16
+ -----
17
+
18
+ <a id="use-this-package"></a>
19
+ ## Use this package
20
+
21
+ Mount through the bundle patch ([`cordis.patch.yml`](cordis.patch.yml)):
22
+
23
+ ```yaml
24
+ - insert:
25
+ - id: debug
26
+ name: '@lukstei/dsh-debug'
27
+ config: {}
28
+ ```
29
+
30
+ Required service: `commands`.
31
+
32
+ | Field | Default | Meaning |
33
+ |---|---|---|
34
+ | `copy` | `pbcopy` writer | Hidden, programmatic only: `(text: string) => Promise<void>`. Not settable from YAML. |
35
+
36
+ Commands:
37
+
38
+ | Command | Result |
39
+ |---|---|
40
+ | `/copy-transcript` | Copies all events of the session's in-memory snapshot as JSON Lines. Success text: `Copied <n> session events to clipboard`. Error `Session contains no events to copy` if empty; the clipboard is left untouched. |
41
+ | `/copy-session-id` | Copies the session id. |
42
+
43
+ The default clipboard writer spawns `pbcopy` and works on macOS only. Other platforms fail with `Clipboard copy is unsupported on <platform>; expected darwin`, returned as a command error (`Failed to copy ...`). To support Linux, pass a `copy` function when mounting programmatically:
44
+
45
+ ```typescript
46
+ ctx.plugin(debugPlugin, {
47
+ copy: async (text: string) => {
48
+ // pipe to wl-copy, xclip, or a test sink
49
+ },
50
+ });
51
+ ```
52
+
53
+ ### Plugin dependencies
54
+
55
+ Server-side only. `inject: commands`.
56
+
57
+ | Plugin / service | Required? | Provided by | Effect without it |
58
+ |---|---|---|---|
59
+ | `commands` | Required | @deepseek-ai/dsh-commands | Plugin stays pending; never applies. No `/copy-transcript` or `/copy-session-id`. |
60
+
61
+ Non-plugin requirement: default clipboard export spawns `pbcopy` (macOS only; other platforms reject with an error; `config.copy` replaces it).
62
+
63
+ Used by: nothing.
64
+
65
+ -----
66
+
67
+ <a id="understand-the-implementation"></a>
68
+ ## Understand the implementation
69
+
70
+ <details>
71
+ <summary>Implementation internals — click to expand</summary>
72
+
73
+ Single file: [`src/index.ts`](src/index.ts). Tests: [`src/index.test.js`](src/index.test.js). Exports `Config`, `serializeEventsToJsonl`, `copyToClipboard`, `apply`.
74
+
75
+ - `/copy-transcript` reads `invocation.agent.session.snapshotEvents()` (live in-memory events, deprecated upstream API) and serializes one `JSON.stringify(event)` per line, trailing newline.
76
+ - Handlers return `{ kind: "success" | "error", text }`; clipboard failures never throw.
77
+ - `Config.copy` is `Schema.any().hidden()`: no type validation of the supplied function.
78
+
79
+ </details>
80
+
81
+ -----
82
+
83
+ <a id="further-exploration"></a>
84
+ ## Further Exploration
85
+
86
+ - Upstream: [DSH module graph](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/module-graph.md).
87
+
88
+ <a id="model-experience"></a>
89
+ ## Model Experience
90
+
91
+ No model-visible surface. This package adds no tools, prompt text, or context to the model.
92
+
93
+ <a id="known-limitations-and-deferred-work"></a>
94
+ ## Known Limitations and Deferred Work
95
+
96
+ - Clipboard support is macOS only unless a custom `copy` is supplied.
97
+ - The transcript is the in-memory snapshot, not the persisted log.
98
+ - Uses the deprecated `snapshotEvents()`; no replacement is wired.
99
+
100
+ <a id="dev-note"></a>
101
+ ### Dev Note
102
+
103
+ <details>
104
+ <summary>Working context for maintainers — click to expand</summary>
105
+
106
+ None.
107
+
108
+ </details>
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: debug
3
+ name: '@lukstei/dsh-debug'
4
+ config: {}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@lukstei/dsh-debug",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.2-rc.5.3",
4
+ "description": "Debug commands and transcript tools for DSH",
5
+ "type": "module",
6
+ "main": "./src/index.ts",
7
+ "exports": {
8
+ ".": "./src/index.ts"
9
+ },
10
+ "dsh": {
11
+ "bundle": {
12
+ "patch": "./cordis.patch.yml"
13
+ }
14
+ },
15
+ "peerDependencies": {
16
+ "@deepseek-ai/cordis": "*",
17
+ "@deepseek-ai/dsh-commands": "*",
18
+ "@deepseek-ai/dsh-session": "*",
19
+ "@deepseek-ai/schemastery": "*"
20
+ },
21
+ "devDependencies": {
22
+ "@deepseek-ai/cordis": "4.1.0",
23
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.5",
24
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
25
+ "@deepseek-ai/schemastery": "3.19.0",
26
+ "@types/node": "^26.0.0",
27
+ "typescript": "^7.0.2"
28
+ },
29
+ "files": [
30
+ "src",
31
+ "README.md",
32
+ "cordis.patch.yml",
33
+ "!src/**/*.spec.*",
34
+ "!src/**/*.test.*",
35
+ "!src/**/*.stories.*",
36
+ "!src/**/stories",
37
+ "!src/**/*.e2e.*",
38
+ "!src/**/__snapshots__",
39
+ "!src/**/fixtures"
40
+ ],
41
+ "types": "./src/index.ts",
42
+ "license": "MIT",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/lukstei/dsh-plugins.git",
46
+ "directory": "packages/dsh-debug"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "check": "biome check --reporter=concise .",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "node --test --test-reporter=dot",
55
+ "verify": "pnpm --silent run check && pnpm --silent run typecheck && pnpm --silent run test"
56
+ }
6
57
  }
package/src/index.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { spawn } from "node:child_process";
2
+ import type { Context } from "@deepseek-ai/cordis";
3
+ import type {
4
+ CommandInvocation,
5
+ CommandResult,
6
+ } from "@deepseek-ai/dsh-commands";
7
+ import type { SessionEvent } from "@deepseek-ai/dsh-session";
8
+ import Schema from "@deepseek-ai/schemastery";
9
+
10
+ export const name = "debug";
11
+ export const inject = ["commands"];
12
+
13
+ export interface Config {
14
+ readonly copy?: (text: string) => Promise<void>;
15
+ }
16
+
17
+ export const Config: Schema<Config> = Schema.object({
18
+ copy: Schema.any().hidden(),
19
+ });
20
+
21
+ export function serializeEventsToJsonl(
22
+ events: readonly SessionEvent[],
23
+ ): string {
24
+ if (events.length === 0) return "";
25
+ return `${events.map((event) => JSON.stringify(event)).join("\n")}\n`;
26
+ }
27
+
28
+ export function copyToClipboard(text: string): Promise<void> {
29
+ return new Promise((resolve, reject) => {
30
+ if (process.platform !== "darwin") {
31
+ // edge case: clipboard command differs outside macOS
32
+ reject(
33
+ new Error(
34
+ `Clipboard copy is unsupported on ${process.platform}; expected darwin`,
35
+ ),
36
+ );
37
+ return;
38
+ }
39
+
40
+ const proc = spawn("pbcopy");
41
+ proc.on("error", reject);
42
+ proc.on("close", (code) => {
43
+ if (code === 0) {
44
+ resolve();
45
+ return;
46
+ }
47
+ reject(new Error(`pbcopy exited with code ${code}`));
48
+ });
49
+ proc.stdin.write(text);
50
+ proc.stdin.end();
51
+ });
52
+ }
53
+
54
+ export function apply(ctx: Context, config?: Config): void {
55
+ const copy = config && config.copy ? config.copy : copyToClipboard;
56
+
57
+ ctx.commands.register({
58
+ name: "copy-transcript",
59
+ description: "Copy current session transcript (JSONL) to clipboard",
60
+ handler: async (invocation: CommandInvocation): Promise<CommandResult> => {
61
+ // oxlint-disable-next-line typescript/no-deprecated -- reading live in-memory session snapshot
62
+ const events = invocation.agent.session.snapshotEvents();
63
+ if (events.length === 0) {
64
+ // edge case: do not overwrite user clipboard when session has no events
65
+ return {
66
+ kind: "error",
67
+ text: "Session contains no events to copy",
68
+ };
69
+ }
70
+
71
+ const jsonl = serializeEventsToJsonl(events);
72
+ try {
73
+ await copy(jsonl);
74
+ return {
75
+ kind: "success",
76
+ text: `Copied ${events.length} session events to clipboard`,
77
+ };
78
+ } catch (error: unknown) {
79
+ return {
80
+ kind: "error",
81
+ text: `Failed to copy transcript: ${error instanceof Error ? error.message : String(error)}`,
82
+ };
83
+ }
84
+ },
85
+ });
86
+
87
+ ctx.commands.register({
88
+ name: "copy-session-id",
89
+ description: "Copy current session ID to clipboard",
90
+ handler: async (invocation: CommandInvocation): Promise<CommandResult> => {
91
+ try {
92
+ await copy(invocation.agent.session.id);
93
+ return {
94
+ kind: "success",
95
+ text: "Copied session ID to clipboard",
96
+ };
97
+ } catch (error: unknown) {
98
+ return {
99
+ kind: "error",
100
+ text: `Failed to copy session ID: ${error instanceof Error ? error.message : String(error)}`,
101
+ };
102
+ }
103
+ },
104
+ });
105
+ }