- Accueil
- Plugins
- Juste pour le plaisir
- dsh-scifi-story
dsh-scifi-story
jasonz-ai-2026/dsh-scifi-story
Turns any set of physics terms into a complete short science-fiction story, with a sidebar writing panel and a model-facing tool.
Installer
dsh plugin --profile web add github:jasonz-ai-2026/dsh-scifi-storyREADME
dsh-scifi-story
把任意一组物理学名词变成一篇完整的短篇科幻小说。这是一个 DeepSeek Harness 双端插件:
- 宿主端:注册模型可调用的
scifi_story工具,模型可以直接写小说; - 客户端:在右侧栏加入「科幻工坊」面板,输入术语、点击按钮就能生成,不经过对话。
它做什么
调用方只需给出一组术语:
{
"terms": ["量子纠缠", "事件视界", "超导"],
"tone": "悬疑",
"length": "short",
"language": "zh"
}
插件内部会完成一次独立的模型调用,要求模型:
- 把每一个术语写成情节机制,而不是术语解释;
- 给出具体人物、场景、冲突和不可逆的代价;
- 开头制造悬念,中段有认知反转,结尾留余味;
- 返回标题与正文。
结果是结构化对象 { title, story, terms, language }。模型工具会渲染成带标题的 Markdown;侧栏面板会显示标题、正文和术语脚注,并支持一键复制。
两种用法
1. 侧栏面板
重启 DSH 桌面端后,右侧栏会出现「科幻工坊」标签页。打开后:
- 输入 1–12 个物理名词(逗号、顿号或换行分隔);
- 可选填写叙事基调,选择篇幅和语言;
- 点击「生成小说」,或按
Cmd/Ctrl + Enter。
面板通过同源接口 POST /api/scifi-story/generate 调用宿主端。请求带 x-scifi-story: 1 头,宿主只接受带这个头的同源请求。
生成在后台进行:切换到其他页面或右侧栏标签再回来,输入、生成进度和结果都会保留;即使面板被卸载,请求也不会被取消。同一浏览器会话内刷新页面,最近一次结果也会从 sessionStorage 恢复。生成中标签标题旁会显示蓝色小圆点;生成完成但面板未打开时,会显示绿色小圆点提示。
2. 模型工具
直接在对话里说“用这几个物理名词写一篇科幻短篇”,模型会调用 scifi_story。成功加载后,工具列表中能看到 scifi_story。
参数
| 参数 | 必填 | 说明 |
|---|---|---|
terms | 是 | 1–12 个物理学名词,字符串数组 |
tone | 否 | 叙事基调,如“硬科幻”“悬疑”“温情”“黑色幽默”“史诗”“惊悚” |
length | 否 | flash(约 800–1200 字)、short(约 1500–2500 字,默认)、long(约 3000–4500 字) |
language | 否 | zh(默认)或 en |
安装
插件目录本身就是一个 DSH bundle:
dsh-scifi-story/
├── package.json # dsh.bundle.patch + dsh.client
├── cordis.patch.yml # - insert: id: scifi-story / name: dsh-scifi-story
├── index.js # 宿主入口:scifi_story 工具 + HTTP 路由
├── client.js # 浏览器入口:右侧栏「科幻工坊」面板
└── README.md
把插件目录复制进当前桌面 profile:
cp -R /Users/zheng/Codes/rust/Hello_World/dsh-scifi-story \
~/.dsh/profiles/desktop/node_modules/dsh-scifi-story
在 ~/.dsh/profiles/desktop/package.json 中登记依赖,并把包名加入 dsh.profile.bundles:
{
"dependencies": {
"dsh-scifi-story": "file:/Users/zheng/Codes/rust/Hello_World/dsh-scifi-story"
},
"dsh": {
"profile": {
"bundles": ["...", "dsh-scifi-story"]
}
}
}
也可以在 DSH 的插件管理器中启用 dsh-scifi-story。新宿主插件和客户端面板都不能热加载:启用后需要完整重启一次 DSH 桌面端,scifi_story 工具和「科幻工坊」标签页才会出现。
包自带的 cordis.patch.yml 会负责插入插件行,不要再去 profile 的 cordis.patch.yml 里手写同一条 - insert:,否则会重复注册。
设计说明
- 零运行时依赖:宿主端只使用
node:crypto;客户端只依赖 DSH 注入的 React 和右侧栏槽位,不需要构建步骤。 - 模型路由:通过
ctx.agentDefaultModel.currentSelection()取当前默认模型,不硬编码 provider/model。 - 取消传播:把
exec.signal原样传给ctx.llm.stream;HTTP 路由使用 300 秒超时的AbortController。 - 容错解析:优先解析严格 JSON;模型若返回 Markdown 代码块或纯散文,则回退到“首行标题 + 正文”的启发式解析。
- 截断容忍:
max-tokens结束时保留已生成的部分正文,而不是丢弃整篇故事。 - 同源保护:面板请求必须带
x-scifi-story: 1,避免其他网页通过简单请求触发本地模型调用。 - 跨页面状态:面板状态和进行中的请求放在模块级 store 中,不随组件卸载销毁;
sessionStorage负责刷新后的兜底恢复。
License
MIT
Plugins associés
dsh-web-ui (dsh-pet)
zhu1090093659/dsh-web-ui
dsh-pet (dsh-pet)
pc2005-cloud/dsh-pet
dsh-tavern (dsh-tavern)
flizzywine/dsh-tavern
dsh-tavern (dsh-profile-bridge)
flizzywine/dsh-tavern