dsh-nested-workspaces 0.0.0-stage → 1.3.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.md +122 -2
- package/client.js +2274 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +7 -0
- package/index.js +140 -0
- package/locale/en.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +57 -4
package/cordis.patch.yml
ADDED
package/icon.svg
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" width="36" height="36" role="img" aria-label="Nested workspaces">
|
|
2
|
+
<rect x="2" y="2" width="32" height="32" rx="8" fill="#247bbf" fill-opacity="0.14"/>
|
|
3
|
+
<path d="M5 23.6V13.4a2 2 0 0 1 2-2h4.6l1.7 2.2h13.7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2z"
|
|
4
|
+
fill="none" stroke="#247bbf" stroke-width="2.2" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M14.6 22.2v-3.9a1.5 1.5 0 0 1 1.5-1.5h2.6l1.1 1.4h4.6a1.5 1.5 0 0 1 1.5 1.5v2.5a1.5 1.5 0 0 1-1.5 1.5h-8.3a1.5 1.5 0 0 1-1.5-1.5z"
|
|
6
|
+
fill="#247bbf" fill-opacity="0.9"/>
|
|
7
|
+
</svg>
|
package/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host half of the nested-workspaces bundle.
|
|
3
|
+
*
|
|
4
|
+
* Child workspaces are ordinary workspaces whose directory sits inside the parent
|
|
5
|
+
* workspace, so the workspace controller already persists them — nothing here
|
|
6
|
+
* touches workspace records.
|
|
7
|
+
*
|
|
8
|
+
* The one thing the Host must do is make the child directory. The Client's
|
|
9
|
+
* `uiWorkspace.createDirectory()` goes through the composed directory picker,
|
|
10
|
+
* and a Host whose picker backend is the OS chooser serves only the `native`
|
|
11
|
+
* capability: `directoryPicker.createDirectory` then answers
|
|
12
|
+
* `directory-picker/unavailable: ... needs the browse capability`. Creating a
|
|
13
|
+
* folder is not really a "browse" feature, so this bundle answers it over the
|
|
14
|
+
* public Connection transport instead (the same `/api` carrier other bundles
|
|
15
|
+
* use), and the Client falls back to `createDirectory` when this route is
|
|
16
|
+
* missing.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { mkdir, stat } from 'node:fs/promises'
|
|
20
|
+
import path from 'node:path'
|
|
21
|
+
|
|
22
|
+
/** Connection is the only Host service this half needs. */
|
|
23
|
+
export const inject = ['connection']
|
|
24
|
+
|
|
25
|
+
/** Exact route below `/api`; Connection rejects anything that is not an exact `/api/...` path. */
|
|
26
|
+
const ROUTE_PATH = '/api/nested-workspaces'
|
|
27
|
+
/** Envelope method name, mirrored by the Client call. */
|
|
28
|
+
const ENDPOINT = 'nested-workspaces'
|
|
29
|
+
|
|
30
|
+
/** A child name becomes one directory segment, so it may not carry a separator. */
|
|
31
|
+
const INVALID_NAME = /[\\/]/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Validate the requested child name.
|
|
35
|
+
* @param value - raw name from the Client.
|
|
36
|
+
* @returns the trimmed name, or null when it cannot be a directory segment.
|
|
37
|
+
*/
|
|
38
|
+
function normalizeName(value) {
|
|
39
|
+
if (typeof value !== 'string') return null
|
|
40
|
+
const name = value.trim()
|
|
41
|
+
if (name === '' || name === '.' || name === '..') return null
|
|
42
|
+
if (INVALID_NAME.test(name)) return null
|
|
43
|
+
return name
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** One failure result in the Connection envelope. */
|
|
47
|
+
function failure(code, message) {
|
|
48
|
+
return { ok: false, error: { code, message, details: {} } }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create `<parent>/<name>` without creating any other segment.
|
|
53
|
+
* @param payload - decoded request payload.
|
|
54
|
+
* @returns a Connection handler result.
|
|
55
|
+
*/
|
|
56
|
+
async function createChild(payload) {
|
|
57
|
+
const parent = payload !== null && typeof payload === 'object' ? payload.parent : undefined
|
|
58
|
+
const name = normalizeName(payload !== null && typeof payload === 'object' ? payload.name : undefined)
|
|
59
|
+
if (typeof parent !== 'string' || parent.trim() === '') {
|
|
60
|
+
return failure('nested-workspaces/invalid-parent', 'A parent directory is required.')
|
|
61
|
+
}
|
|
62
|
+
if (name === null) {
|
|
63
|
+
return failure('nested-workspaces/invalid-name', 'A child name may not be empty, "." , ".." or contain a separator.')
|
|
64
|
+
}
|
|
65
|
+
const target = path.join(parent, name)
|
|
66
|
+
try {
|
|
67
|
+
await mkdir(target)
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error !== null && typeof error === 'object' && error.code === 'EEXIST') {
|
|
70
|
+
return failure('directory-picker/exists', `"${target}" already exists.`)
|
|
71
|
+
}
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
73
|
+
return failure('directory-picker/create-failed', message)
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const info = await stat(target)
|
|
77
|
+
if (!info.isDirectory()) {
|
|
78
|
+
return failure('directory-picker/create-failed', `"${target}" is not a directory.`)
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
82
|
+
return failure('directory-picker/unreadable', message)
|
|
83
|
+
}
|
|
84
|
+
return { ok: true, value: { path: target } }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Reply in the envelope `createWebConnectionRpc` parses. */
|
|
88
|
+
function reply(rpcId, result) {
|
|
89
|
+
return Response.json({ type: 'server-response', rpcId, result })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Register the child-directory route.
|
|
94
|
+
* @param ctx - the Host plugin context.
|
|
95
|
+
*/
|
|
96
|
+
export function apply(ctx) {
|
|
97
|
+
let dispose
|
|
98
|
+
try {
|
|
99
|
+
dispose = ctx.connection.fetch.register({
|
|
100
|
+
path: ROUTE_PATH,
|
|
101
|
+
methods: ['POST'],
|
|
102
|
+
requestBody: 'buffered',
|
|
103
|
+
async fetch(request) {
|
|
104
|
+
if (request.method !== 'POST') return new Response('method not allowed', { status: 405 })
|
|
105
|
+
let message
|
|
106
|
+
try {
|
|
107
|
+
message = await request.json()
|
|
108
|
+
} catch {
|
|
109
|
+
return new Response('body is not JSON', { status: 400 })
|
|
110
|
+
}
|
|
111
|
+
const rpcId = message !== null && typeof message === 'object' && typeof message.rpcId === 'string'
|
|
112
|
+
? message.rpcId
|
|
113
|
+
: 'invalid-request'
|
|
114
|
+
if (
|
|
115
|
+
message === null
|
|
116
|
+
|| typeof message !== 'object'
|
|
117
|
+
|| message.type !== 'client-request'
|
|
118
|
+
|| typeof message.method !== 'string'
|
|
119
|
+
|| message.method !== ENDPOINT
|
|
120
|
+
) {
|
|
121
|
+
return reply(rpcId, failure('gateway/bad-request', 'Invalid nested-workspaces request.'))
|
|
122
|
+
}
|
|
123
|
+
const payload = message.payload
|
|
124
|
+
if (payload === null || typeof payload !== 'object' || payload.action !== 'createChild') {
|
|
125
|
+
return reply(rpcId, failure('gateway/bad-request', 'Unknown nested-workspaces action.'))
|
|
126
|
+
}
|
|
127
|
+
return reply(rpcId, await createChild(payload))
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
} catch (error) {
|
|
131
|
+
/* The route registry is a Host-wide singleton: a live reload can reach this
|
|
132
|
+
* line with the previous instance still holding the path. Yielding keeps the
|
|
133
|
+
* serving instance authoritative instead of failing the whole composition. */
|
|
134
|
+
if (/already registered/.test(String(error && error.message ? error.message : error))) return
|
|
135
|
+
throw error
|
|
136
|
+
}
|
|
137
|
+
/* `fetch.register` already returns the disposer that drops the route; hand it
|
|
138
|
+
* straight to the effect instead of wrapping it a second time. */
|
|
139
|
+
ctx.effect(() => dispose, 'dsh-nested-workspaces: child directory route')
|
|
140
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"title": "Nested workspaces",
|
|
4
|
+
"description": "Nested child workspaces in the DeepSeek Harness sidebar. Create a child workspace inside its parent folder without the OS picker, drag workspaces to reorder siblings, drag sessions between workspaces, rename the section title by double-clicking, and see each session last-used time and pin marker."
|
|
5
|
+
}
|
|
6
|
+
}
|
package/locale/ja.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-nested-workspaces",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Nested child workspaces in the DeepSeek Harness sidebar: editable section title, an Add child workspace menu, and sessions you can drag between workspaces.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"dsh",
|
|
9
|
+
"dsh-plugin",
|
|
10
|
+
"deepseek-harness",
|
|
11
|
+
"sidebar",
|
|
12
|
+
"workspace",
|
|
13
|
+
"session"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "poker",
|
|
17
|
+
"homepage": "https://github.com/pokereva/dsh-nested-workspaces#readme",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/pokereva/dsh-nested-workspaces.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/pokereva/dsh-nested-workspaces/issues"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./index.js",
|
|
27
|
+
"./client": "./client.js",
|
|
28
|
+
"./locale/*.json": "./locale/*.json",
|
|
29
|
+
"./icon": "./icon.svg"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"index.js",
|
|
33
|
+
"client.js",
|
|
34
|
+
"cordis.patch.yml",
|
|
35
|
+
"locale/*.json",
|
|
36
|
+
"icon.svg",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "node test/harness.cjs",
|
|
42
|
+
"check": "node --check client.js && node --check index.js"
|
|
43
|
+
},
|
|
44
|
+
"dsh": {
|
|
45
|
+
"bundle": {
|
|
46
|
+
"patch": "./cordis.patch.yml"
|
|
47
|
+
},
|
|
48
|
+
"client": {
|
|
49
|
+
"platform": "web",
|
|
50
|
+
"immediately": true,
|
|
51
|
+
"inject": [
|
|
52
|
+
"@deepseek-ai/dsh-client-locale",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-slots",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-context-menu",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|