feat: native DSH skin template (dshell.css/html served at /api/worktable/template) + knowledge pack mandates it for generated HTML

This commit is contained in:
Aisland
2026-08-19 23:54:26 +08:00
parent a4d5646f1d
commit 30b694341b
7 changed files with 202 additions and 0 deletions
+1
View File
@@ -29,6 +29,7 @@ await build({
format: 'esm',
target: ['node22'],
external: ['@deepseek-ai/*', 'node:*', 'ws', 'node-pty'],
loader: { '.css': 'text', '.html': 'text' }, // 原生皮肤模板以文本嵌入服务端 bundle
})
await build({
+3
View File
@@ -428,6 +428,9 @@ const KNOWLEDGE_PACK = [
' 窗内容还可放 iframe 网页与文件预览(.md/.txt/.tsx/.css/.html 等)。',
'- 窗口可装载的形式:HTML 单文件(交互 UI,放项目文件夹后在资源管理器点击渲染)、网页 URL、',
' 文件预览(.md/.txt/.tsx/.css/.html/图片/.mp4 等);产出形式按任务类型选,不要一律 HTML。',
'- 产出 HTML 必须用工作台原生皮肤:在页面 <head> 加 <link rel="stylesheet" href="/api/worktable/template/dshell.css">,',
' 组件类参考 /api/worktable/template/dshell.html(卡片/按钮/状态徽标/标签页/列表/统计/进度/表格等),',
' 界面即可与 DSH 原生风格一致;自造样式控制在最小范围。',
'- 服务端能力:/api/worktable/fs(列目录)、/api/worktable/write(写文件)、/api/worktable/mkdir(建目录)、',
' /api/worktable/git(git 状态)、/api/worktable/site(静态托管)。',
'- 改完插件在 01_content 目录执行 npm run build;重启 dsh web 或浏览器 F5 生效。',
+29
View File
@@ -38,6 +38,13 @@ const FILE_TYPES: Record<string, string> = {
const SITE_PREFIX = '/api/worktable/site'
// 原生皮肤模板(esbuild text loader 嵌入;/api/worktable/template 路由直接下发)
// @ts-ignore
import dshellCss from '../template/dshell.css'
// @ts-ignore
import dshellHtml from '../template/dshell.html'
const TEMPLATE_PREFIX = '/api/worktable/template'
/**
* 从本插件模块位置向祖先方向查找并加载 node_modules 包(如 ws / node-pty)。
* 本包经 junction 链接进 profile,普通 import 可能解析不到 profile 级依赖;
@@ -236,6 +243,28 @@ export function apply(ctx: Context) {
// 本地站点(目录级静态托管):点开 index.html 时挂载整个所在目录,
// 让 ./assets/... 等相对引用正常解析(前缀路由,余下路径 = <rootToken>/<相对路径>)。
// 原生皮肤模板:HTML 骨架 + 设计系统样式表(随插件分发,主题自动适配)
webServer.register({
kind: 'prefix',
path: TEMPLATE_PREFIX,
handler: (req: any, res: any) => {
try {
if (req.method !== 'GET') { res.writeHead(405); res.end(); return }
const pathname = new URL(req.url ?? '/', 'http://dsh.internal').pathname
const rel = pathname.slice(TEMPLATE_PREFIX.length)
if (rel === '/dshell.css') {
res.writeHead(200, { 'content-type': 'text/css; charset=utf-8', 'cache-control': 'no-store' })
res.end(dshellCss)
} else {
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store' })
res.end(dshellHtml)
}
} catch (err) {
res.writeHead(404); res.end(String(err))
}
},
})
webServer.register({
kind: 'prefix',
path: SITE_PREFIX,
+74
View File
@@ -0,0 +1,74 @@
/* dsh-worktable 原生皮肤 · DSH 设计系统组件库
用法:<link rel="stylesheet" href="/api/worktable/template/dshell.css">
所有颜色走 DSH 主题变量(--dsw-alias-*),自动适配明暗主题。 */
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
background: var(--dsw-alias-bg-base, #0b0e14);
color: var(--dsw-alias-label-primary, #e6e8eb);
font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
font-size: 13px;
line-height: 1.6;
}
.dshell { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; min-height: 100%; }
/* 文字层级 */
.dshell-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }
.dshell-sub { margin: 0; font-size: 12px; color: var(--dsw-alias-label-secondary, #9aa4b2); }
.dshell-muted { color: var(--dsw-alias-label-tertiary, #6b7280); font-size: 11.5px; }
/* 卡片 */
.dshell-card { border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); padding: 12px 14px; }
.dshell-card + .dshell-card { margin-top: 10px; }
/* 按钮(绿色主按钮 / 幽灵按钮 / 危险) */
.dshell-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1px solid transparent; background: #3fb950; color: #0b0e14; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.dshell-btn:hover { filter: brightness(1.08); }
.dshell-btnGhost { background: transparent; border-color: var(--dsw-alias-border-l1, #262b36); color: var(--dsw-alias-label-secondary, #9aa4b2); }
.dshell-btnGhost:hover { color: var(--dsw-alias-label-primary, #e6e8eb); border-color: var(--dsw-alias-border-l2, #3a4150); }
.dshell-btnDanger { background: transparent; border-color: #f85149; color: #f85149; }
/* 状态徽标(圆点 + 文字;绿=已完成 黄=待办/待发布 灰=未开始) */
.dshell-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, #262b36); font-size: 11.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); }
.dshell-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }
.dshell-badgeDone { color: #3fb950; border-color: rgba(63,185,80,.4); }
.dshell-badgeDone::before { background: #3fb950; box-shadow: 0 0 5px #3fb950; }
.dshell-badgeWait { color: #d29922; border-color: rgba(210,153,34,.4); }
.dshell-badgeWait::before { background: #d29922; box-shadow: 0 0 5px #d29922; }
.dshell-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-label-tertiary, #6b7280); }
.dshell-dotDone { background: #3fb950; box-shadow: 0 0 5px #3fb950; }
.dshell-dotWait { background: #d29922; box-shadow: 0 0 5px #d29922; }
/* 标签页 */
.dshell-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }
.dshell-tab { padding: 7px 12px; font-size: 12.5px; color: var(--dsw-alias-label-secondary, #9aa4b2); cursor: pointer; border: none; background: none; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dshell-tabOn { color: var(--dsw-alias-label-primary, #e6e8eb); border-bottom-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }
/* 列表 */
.dshell-list { display: flex; flex-direction: column; gap: 6px; }
.dshell-listItem { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); cursor: pointer; }
.dshell-listItem:hover { border-color: var(--dsw-alias-border-l2, #3a4150); background: var(--dsw-alias-fill-l1, rgba(255,255,255,.05)); }
.dshell-listItemTitle { font-size: 12.5px; color: var(--dsw-alias-label-primary, #e6e8eb); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dshell-listItemMeta { flex: none; font-size: 11px; color: var(--dsw-alias-label-tertiary, #6b7280); }
/* 网格 / 统计 */
.dshell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dshell-stat { padding: 10px 12px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 10px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.02)); }
.dshell-statLabel { font-size: 11px; color: var(--dsw-alias-label-secondary, #9aa4b2); }
.dshell-statValue { font-size: 20px; font-weight: 600; color: var(--dsw-alias-label-primary, #e6e8eb); }
.dshell-statDelta { font-size: 11px; color: #3fb950; }
/* 进度条 */
.dshell-progress { height: 6px; border-radius: 3px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.06)); overflow: hidden; }
.dshell-progressBar { height: 100%; border-radius: 3px; background: #3fb950; }
/* 输入 */
.dshell-input, .dshell-textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l1, #262b36); border-radius: 8px; background: var(--dsw-alias-fill-l1, rgba(255,255,255,.03)); color: var(--dsw-alias-label-primary, #e6e8eb); font: inherit; font-size: 12.5px; outline: none; }
.dshell-input:focus, .dshell-textarea:focus { border-color: var(--dsw-alias-state-accent-primary, #4f8ef7); }
/* 表格 */
.dshell-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dshell-table th, .dshell-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--dsw-alias-border-l1, #262b36); }
.dshell-table th { color: var(--dsw-alias-label-secondary, #9aa4b2); font-weight: 500; }
/* 键值对 */
.dshell-kv { display: flex; flex-direction: column; gap: 6px; }
.dshell-kvRow { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.dshell-kvKey { color: var(--dsw-alias-label-secondary, #9aa4b2); }
.dshell-kvValue { color: var(--dsw-alias-label-primary, #e6e8eb); text-align: right; }
/* 分割线 */
.dshell-divider { height: 1px; background: var(--dsw-alias-border-l1, #262b36); margin: 6px 0; }
/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
+78
View File
@@ -0,0 +1,78 @@
<!doctype html>
<!-- dsh-worktable 原生皮肤模板:新页面以此为基础,替换下面示例内容即可。
样式表由插件提供(随主题自动适配),不要复制或改写它。 -->
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>我的窗口</title>
<link rel="stylesheet" href="/api/worktable/template/dshell.css" />
</head>
<body>
<div class="dshell">
<!-- 标题区 -->
<h1 class="dshell-title">窗口标题</h1>
<p class="dshell-sub">一句话说明这个窗口做什么。</p>
<!-- 状态徽标:已完成 dshell-badgeDone / 进行中 dshell-badgeWait / 默认 -->
<div>
<span class="dshell-badge dshell-badgeDone">已完成</span>
<span class="dshell-badge dshell-badgeWait">进行中</span>
<span class="dshell-badge">未开始</span>
</div>
<!-- 标签页 -->
<div class="dshell-tabs">
<button class="dshell-tab dshell-tabOn">概览</button>
<button class="dshell-tab">详情</button>
<button class="dshell-tab">设置</button>
</div>
<!-- 统计卡片网格 -->
<div class="dshell-grid">
<div class="dshell-stat">
<div class="dshell-statLabel">总数</div>
<div class="dshell-statValue">128</div>
<div class="dshell-statDelta">+12.4%</div>
</div>
<div class="dshell-stat">
<div class="dshell-statLabel">进行中</div>
<div class="dshell-statValue">7</div>
</div>
<div class="dshell-stat">
<div class="dshell-statLabel">已完成</div>
<div class="dshell-statValue">121</div>
</div>
</div>
<!-- 列表 -->
<div class="dshell-list">
<div class="dshell-listItem">
<span class="dshell-listItemTitle">条目一:示例内容标题</span>
<span class="dshell-listItemMeta">昨天</span>
</div>
<div class="dshell-listItem">
<span class="dshell-listItemTitle">条目二:示例内容标题</span>
<span class="dshell-badge dshell-badgeDone">已发布</span>
</div>
</div>
<!-- 卡片 + 键值对 -->
<div class="dshell-card">
<h2 class="dshell-sub" style="margin:0 0 8px">详情</h2>
<div class="dshell-kv">
<div class="dshell-kvRow"><span class="dshell-kvKey">字段 A</span><span class="dshell-kvValue">值 A</span></div>
<div class="dshell-kvRow"><span class="dshell-kvKey">字段 B</span><span class="dshell-kvValue">值 B</span></div>
</div>
<div class="dshell-divider"></div>
<div class="dshell-progress"><div class="dshell-progressBar" style="width:72%"></div></div>
</div>
<!-- 操作区 -->
<div style="display:flex;gap:8px">
<button class="dshell-btn">主要操作</button>
<button class="dshell-btn dshell-btnGhost">次要操作</button>
</div>
</div>
</body>
</html>
@@ -964,6 +964,20 @@
ERROR_COUNT: 0(终端窗不在回归范围内,视觉部分请用户重启后确认)。
- 备注:-NoProfile 为服务端改动,需重启 dsh web 生效;字体/换行转义为客户端改动,F5 生效。
## 补记(原生皮肤模板 + 知识包接入)
- 用户目标:参照「Oil Creator」爆改 DSH 的效果,让自定义窗口内容与 DSH 原生风格一致。
- 实现:① 新增 01_content/template/dshell.css(设计系统:全部走 --dsw-alias-* 主题变量,
含卡片/按钮(绿pill+幽灵)/状态徽标(绿黄点)/标签页/列表/统计/进度/输入/表格/键值对/滚动条)
与 dshell.html(起始骨架示例);② esbuild text loader 把两者嵌入服务端 bundle,
新增前缀路由 /api/worktable/template 下发;③ 窗口任务知识包新增:产出 HTML 必须
<link href="/api/worktable/template/dshell.css">,组件类参考模板——界面自动原生质感。
- 验证:lib/index.js 含 dshell.css/.html 与路由 ✓;lib/client.js 知识包含模板引用 ✓;
functional-diag 全 20 STEP ERROR_COUNT: 0。
- 备注:模板路由为服务端改动,需重启 dsh web 后生效(重启后浏览器可直开
/api/worktable/template/dshell.html 预览模板)。
+3
View File
@@ -46,6 +46,9 @@ node --check lib/index.js
放进该文件夹」指令——用户要求项目产出文件不得落到默认位置。
- **窗口任务提示词**:buildWindowTaskText 统一组装(窗口身份「项目+窗口N」+ 项目文件夹 +
插件知识包);知识包注明「不要重新侦察插件源码」,改提示词时保持这个原则。
- **原生皮肤模板**:01_content/template/dshell.css + dshell.html(esbuild text loader 嵌入服务端
bundle,/api/worktable/template 路由下发);知识包要求产出 HTML 一律引用该样式表,组件类
参考模板。新增组件样式只加到 dshell.css,保持单一来源。
- **提示词零泄漏(硬约束)**:所有对外生成的提示词(buildWindowTaskText 窗口任务提示词、
buildCustomLayoutPrompt 剪贴板布局提示词)禁止写入用户的个人工作区分组名(如 Projects /
DeepseekHarness)、其他用户的项目名与私人路径。剪贴板提示词会发给别人的 DSH,必须只含