dsh-new-session 0.0.0-stage → 0.1.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 +58 -2
- package/cordis.patch.yml +15 -0
- package/icon.svg +4 -0
- package/lib/client.js +76 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +86 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 deepseek-plugins contributors
|
|
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,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `dsh-new-session`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
在输入框里敲 `/new`,直接在当前工作区开一个新会话——等价于点侧边栏的 **New Session**
|
|
4
|
+
按钮,但不用把手从键盘上拿开。
|
|
5
|
+
|
|
6
|
+
## 它做什么
|
|
7
|
+
|
|
8
|
+
- 在 `/` 菜单里注册一个 **New session / 新建会话** 命令(`/new`,客户端 action)。
|
|
9
|
+
- 执行时调用 Web GUI 的工作区导航服务,行为和 New Session 按钮完全一致:
|
|
10
|
+
- 当前工作区里已有空白会话时**复用**它——所以回到那个空白会话未发送的草稿;
|
|
11
|
+
- 没有空白会话时新建一个;
|
|
12
|
+
- 旧会话原样留在历史列表里,不会被删除或修改。
|
|
13
|
+
- 命令只在当前 Peer 有 `session/create` 权限时出现;只读的远程访问者看不到这一行。
|
|
14
|
+
- 不提交任何提示词:`action` 类型会消费掉 `/new` 这个 token,不会把它当消息发给模型。
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
# 本地 checkout
|
|
20
|
+
dsh plugin --profile web add /home/ubuntu/code/deepseek-plugins/packages/dsh-new-session
|
|
21
|
+
dsh --profile web --dump-config # 应能看到 "# == dsh-new-session"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
装完需要重启正在运行的 Web profile:浏览器半由宿主发布,页面刷新不够,Host 的
|
|
25
|
+
client-module 扫描要重新 boot。
|
|
26
|
+
|
|
27
|
+
构建产物由 `prepare` 脚本(tsdown)产出;改完源码后重新
|
|
28
|
+
`pnpm --filter dsh-new-session build` 即可。外部安装的插件不在 `pnpm run dev:web` 的监视
|
|
29
|
+
范围内,client-hmr 每 500ms 轮询 `lib/client.js`,重新构建后页面会自动换上新的浏览器半。
|
|
30
|
+
|
|
31
|
+
## 在 GUI 里走一遍
|
|
32
|
+
|
|
33
|
+
1. 重启 Web profile,打开任意一个会话。
|
|
34
|
+
2. 在输入框里输入 `/new`:`/` 菜单里出现 **新建会话** 一行(也可以直接按回车执行)。
|
|
35
|
+
3. 执行后当前视图切到一个空白会话;输入框里是空的(如果那个空白会话本来就有草稿,草稿还在)。
|
|
36
|
+
4. 侧边栏里原来的会话还在,点回去内容完全没变。
|
|
37
|
+
|
|
38
|
+
## 实现
|
|
39
|
+
|
|
40
|
+
两半都只做一件事:
|
|
41
|
+
|
|
42
|
+
- **宿主半**(`src/index.ts`)是空插件。它存在的意义是让 Loader 挂载这个包——只有挂载了,
|
|
43
|
+
client-module 扫描才会把 `lib/client.js` 发布给页面。
|
|
44
|
+
- **浏览器半**(`src/client/index.tsx`)用 `ctx.commandUi.register()` 注册一个
|
|
45
|
+
`kind: 'action'` 的贡献;`run` 调用 `ctx.uiWorkspace.startSession()`。注册包在
|
|
46
|
+
`ctx.remoteAccess.whenAccess('session/create', …)` 里,权限变化时自动装上/卸下。
|
|
47
|
+
|
|
48
|
+
`/new` 这个名字没有对应宿主命令,所以不会和现有 command 撞名;
|
|
49
|
+
`cordis.patch.yml` 只插一行,没有配置项。
|
|
50
|
+
|
|
51
|
+
## 已知边界
|
|
52
|
+
|
|
53
|
+
- **只对 Web GUI 生效**。SDK / 桌面纯文本入口的斜杠命令识别只认内置白名单
|
|
54
|
+
(dsh 的 `query-input.ts`),第三方插件命令不会从那条路进入;要覆盖那些入口需要改 dsh 本体。
|
|
55
|
+
- 它是「新会话」而不是「原地清空上下文」:旧对话仍然在历史里,会话 id 也不变的是**新会话**
|
|
56
|
+
的 id。想在同一个会话里清空上下文是另一件事(surface replace),这个插件不做。
|
|
57
|
+
- 复用空白会话意味着连续两次 `/new` 可能停在同一个空白会话上——和按钮行为一致。
|
|
58
|
+
- 菜单行的文案来自浏览器半的字典(en / zh);`locale/*.json` 只给市场页的
|
|
59
|
+
`meta.title` / `meta.description` 用。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# The configuration layer this bundle contributes to a dsh profile. The row
|
|
2
|
+
# `name` must match the package name in package.json; the host Loader imports
|
|
3
|
+
# that specifier and starts the plugin's main entry.
|
|
4
|
+
#
|
|
5
|
+
# This package has no host-side capability: the `/new` command is a browser
|
|
6
|
+
# contribution. The row exists so the Loader owns the package lifecycle, which
|
|
7
|
+
# is also what makes the client-module scanner publish `lib/client.js` to the
|
|
8
|
+
# Web GUI.
|
|
9
|
+
#
|
|
10
|
+
# Later layers win per row id, and a patch replaces a row's whole `config`
|
|
11
|
+
# value instead of merging keys. Users can therefore override this row from
|
|
12
|
+
# `$DSH_HOME/profiles/<name>/cordis.patch.yml` without touching this package.
|
|
13
|
+
- insert:
|
|
14
|
+
- id: dsh-new-session
|
|
15
|
+
name: 'dsh-new-session'
|
package/icon.svg
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="dsh plugin template">
|
|
2
|
+
<rect width="64" height="64" rx="14" fill="#1f6feb"/>
|
|
3
|
+
<path d="M18 21h28M18 32h28M18 43h17" stroke="#ffffff" stroke-width="4" stroke-linecap="round"/>
|
|
4
|
+
</svg>
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "dsh-new-session", factory: function (require) {
|
|
2
|
+
var module = { exports: {} };
|
|
3
|
+
var exports = module.exports;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
// src/client/locales.ts
|
|
7
|
+
/** English copy. */
|
|
8
|
+
const en = {
|
|
9
|
+
label: "New session",
|
|
10
|
+
description: "Start a fresh conversation in this workspace"
|
|
11
|
+
};
|
|
12
|
+
/** Simplified Chinese copy. */
|
|
13
|
+
const zh = {
|
|
14
|
+
label: "新建会话",
|
|
15
|
+
description: "在当前工作区开一个全新的对话"
|
|
16
|
+
};
|
|
17
|
+
// src/client/index.tsx
|
|
18
|
+
/** Browser module id: package name, bundle row id, plugin id. */
|
|
19
|
+
const name = "dsh-new-session";
|
|
20
|
+
/** Locale namespace this plugin owns. */
|
|
21
|
+
const NS = "newSession";
|
|
22
|
+
/** Client services the command cannot work without. */
|
|
23
|
+
const inject = [
|
|
24
|
+
"commandUi",
|
|
25
|
+
"locale",
|
|
26
|
+
"remoteAccess",
|
|
27
|
+
"uiWorkspace"
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Build the `/new` contribution.
|
|
31
|
+
*
|
|
32
|
+
* Exported for the contract spec: the contribution is the unit under test, and
|
|
33
|
+
* `apply` only decides when to install it.
|
|
34
|
+
*
|
|
35
|
+
* @param deps - translator and navigation callback.
|
|
36
|
+
* @returns the silent action contribution.
|
|
37
|
+
*/
|
|
38
|
+
function createNewSessionCommand(deps) {
|
|
39
|
+
return {
|
|
40
|
+
name: "new",
|
|
41
|
+
label: () => deps.t("label"),
|
|
42
|
+
description: () => deps.t("description"),
|
|
43
|
+
available: () => true,
|
|
44
|
+
ui: {
|
|
45
|
+
kind: "action",
|
|
46
|
+
run: () => {
|
|
47
|
+
deps.start();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mount the browser half.
|
|
54
|
+
* @param ctx - browser-side Cordis context.
|
|
55
|
+
*/
|
|
56
|
+
function apply(ctx) {
|
|
57
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
58
|
+
en,
|
|
59
|
+
zh
|
|
60
|
+
}), "dsh-new-session: dictionaries");
|
|
61
|
+
const t = ctx.locale.bind(NS);
|
|
62
|
+
ctx.effect(() => ctx.remoteAccess.whenAccess("session/create", () => ctx.commandUi.register(createNewSessionCommand({
|
|
63
|
+
t,
|
|
64
|
+
start: () => {
|
|
65
|
+
ctx.uiWorkspace.startSession();
|
|
66
|
+
}
|
|
67
|
+
}))), "dsh-new-session: /new command");
|
|
68
|
+
}
|
|
69
|
+
exports.apply = apply;
|
|
70
|
+
exports.createNewSessionCommand = createNewSessionCommand;
|
|
71
|
+
exports.inject = inject;
|
|
72
|
+
exports.name = name;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
return module.exports;
|
|
76
|
+
} });
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
/** Plugin id: package name, bundle row id, and browser module id. */
|
|
3
|
+
export declare const name = "dsh-new-session";
|
|
4
|
+
/**
|
|
5
|
+
* Mount the inert Host half.
|
|
6
|
+
* @param ctx - the Cordis context.
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(ctx: Context): void;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
/** Plugin id: package name, bundle row id, and browser module id. */
|
|
3
|
+
const name = "dsh-new-session";
|
|
4
|
+
/**
|
|
5
|
+
* Mount the inert Host half.
|
|
6
|
+
* @param ctx - the Cordis context.
|
|
7
|
+
*/
|
|
8
|
+
function apply(ctx) {}
|
|
9
|
+
export { apply, name };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * Host half of the `/new` command plugin.\n *\n * The command itself is a browser contribution: the slash menu and the\n * new-Session navigation both live in the Web GUI, so this Host row only mounts\n * the package — which is enough for the client-module scanner to publish\n * `lib/client.js`, and for the plugin's lifecycle to follow the bundle.\n *\n * @module dsh-new-session\n */\n\nimport type { Context } from '@deepseek-ai/cordis'\n\n/** Plugin id: package name, bundle row id, and browser module id. */\nexport const name = 'dsh-new-session'\n\n/**\n * Mount the inert Host half.\n * @param ctx - the Cordis context.\n */\nexport function apply(ctx: Context): void {\n // No host-side capability on purpose: a Host handler could not move the\n // browser's current Session, so `/new` is a client-owned action instead.\n void ctx\n}\n"],"mappings":";;AAcA,MAAa,OAAO;;;;;AAMpB,SAAgB,MAAM,KAAoB,CAI1C"}
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-new-session",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A `/new` slash command in the Web GUI composer: start a fresh Session in the current Workspace without leaving the keyboard.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"deepseek-harness",
|
|
9
|
+
"plugin",
|
|
10
|
+
"session",
|
|
11
|
+
"command"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"icon": "icon.svg",
|
|
16
|
+
"main": "lib/index.js",
|
|
17
|
+
"types": "lib/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./lib/index.d.ts",
|
|
21
|
+
"default": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./client": "./lib/client.js",
|
|
24
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
25
|
+
"./locale/*.json": "./locale/*.json",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib",
|
|
30
|
+
"cordis.patch.yml",
|
|
31
|
+
"locale",
|
|
32
|
+
"icon.svg",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": "^22.19.0 || >=24.0.0",
|
|
37
|
+
"dsh": ">=0.2.2-rc.1 <0.2.3-0"
|
|
38
|
+
},
|
|
39
|
+
"dsh": {
|
|
40
|
+
"manifestVersion": 1,
|
|
41
|
+
"bundle": {
|
|
42
|
+
"patch": "./cordis.patch.yml"
|
|
43
|
+
},
|
|
44
|
+
"client": {
|
|
45
|
+
"platform": "web",
|
|
46
|
+
"inject": [
|
|
47
|
+
"@deepseek-ai/dsh-api-remote-access",
|
|
48
|
+
"@deepseek-ai/dsh-client-locale",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-commands",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@deepseek-ai/cordis": "^4.1.0",
|
|
56
|
+
"@deepseek-ai/dsh-api-remote-access": ">=0.2.2-rc.1 <0.2.3-0",
|
|
57
|
+
"@deepseek-ai/dsh-api-session-controller": ">=0.2.2-rc.1 <0.2.3-0",
|
|
58
|
+
"@deepseek-ai/dsh-client-locale": ">=0.2.2-rc.1 <0.2.3-0",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-commands": ">=0.2.2-rc.1 <0.2.3-0",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.2.2-rc.1 <0.2.3-0",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-workspace": ">=0.2.2-rc.1 <0.2.3-0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
65
|
+
"@deepseek-ai/dsh-api-remote-access": "0.2.2-rc.1",
|
|
66
|
+
"@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.1",
|
|
67
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.1",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-commands": "0.2.2-rc.1",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.1",
|
|
70
|
+
"@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.1",
|
|
71
|
+
"@types/node": "^26.6.6",
|
|
72
|
+
"tsdown": "^0.23.4",
|
|
73
|
+
"typescript": "^7.0.2",
|
|
74
|
+
"vitest": "^5.0.5"
|
|
75
|
+
},
|
|
76
|
+
"author": "mxn404",
|
|
77
|
+
"homepage": "https://github.com/mxn404/deepseek-plugins/tree/main/packages/dsh-new-session",
|
|
78
|
+
"repository": {
|
|
79
|
+
"type": "git",
|
|
80
|
+
"url": "git+https://github.com/mxn404/deepseek-plugins.git",
|
|
81
|
+
"directory": "packages/dsh-new-session"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "tsdown",
|
|
85
|
+
"watch": "tsdown --watch",
|
|
86
|
+
"typecheck": "tsc --noEmit",
|
|
87
|
+
"test": "vitest run"
|
|
88
|
+
}
|
|
6
89
|
}
|