@zh0vy4n/dsh-ops-kit 0.0.0-stage → 0.1.1

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/docs/SKILLS.md ADDED
@@ -0,0 +1,84 @@
1
+ # 可复制的 AGENTS.md 片段
2
+
3
+ 五节,各节独立,按需粘。粘的时候把 `<项目>` 换成项目名,路径改成目标仓库的实际路径。
4
+
5
+ ---
6
+
7
+ ## 一 · 记忆路由表(开工先读什么)
8
+
9
+ 文档攒到几百 KB 之后,没人能整读。按症状查表,别通读。
10
+
11
+ | 你在做什么 | 只读这里 | 不要读 |
12
+ |---|---|---|
13
+ | 改前端 / 改入口文件 | 下面第二段的「三条纪律」+ guardrails 的红线与坑清单 | 改动记录全文 |
14
+ | 用户报一个现象、怀疑以前修过 | 先猜条号再 grep 改动记录;更早的查归档文件,只读命中那几十行 | 两个文件整读 |
15
+ | 部署 / 出安装包 / 换机器 | 运维手册的对应小节 | — |
16
+ | 改名字 / 改口径 / 改标签规则 | lessons 的「已废止口径」段 | 历史讨论 |
17
+ | 有人质疑数据来源与隔离 | 信息安全声明 | — |
18
+ | 接手别人干到一半的活 | handoff 的「当前状态」段 | 做梦日志 |
19
+
20
+ 配套两条:发文之后跑一次 `node bin/dream.mjs --after-deploy`(2 秒,默认 dry-run);新踩的坑立刻用 `--card` 落卡——对话会被压缩,lessons 不会。
21
+
22
+ 四段式汇报(每次交付怎么汇报)见本文件第五节。
23
+
24
+ ---
25
+
26
+ ## 二 · 三条纪律(改代码时)
27
+
28
+ 1. **用能够校验的写入方式改大文件。** 单文件几千行的 HTML/JS,历史上因为拼错一个引号让整页 SyntaxError、界面全空白。做法:用 Node 读 UTF-8 全文 → `includes()` 校验锚点存在 → `replace()` 写回;改完先 `node --check` 或起本地静态服务器无头验一次(断言 errs 为空、关键元素数量 > 0),再谈发布。
29
+ 2. **改完必须跑闸门,不许绕过。** `python bin/verify.py` 不绿就不发。发布脚本内部也要接这一道;有「强制跳过」开关的话,只能在人明确要求时用,且要在汇报里写明跳过了什么。
30
+ 3. **改完更新改动记录。** 一条:改了什么 / 为什么 / 版本号。没有条号,下一个 agent 就没法用 grep 找到这次的上下文。
31
+
32
+ ---
33
+
34
+ ## 三 · 指挥部纪律(派活的那一方)
35
+
36
+ - **先分诊,再动手。** L0(单点、无歧义、可逆)直接做,不派活不开会;L1(2–5 个文件、1–2 个待定点)问 1–2 个关键问题然后自己做或派一个;L2(跨模块、有隐藏前提、能并行)才走「澄清 → 计划 → 并行子会话 → 分层验收」。不允许对 L0/L1 也搞重流程。
37
+ - **一轮只发一次版。** 计划、brief、验收标准一起发;不要边发边改 brief。需要改,就停下来说清楚为什么改,改完再重发。
38
+ - **每条 brief 必须有五段**:目标 / 边界文件(只许动这些)/ 禁止(不 commit、不 push、不动某些目录)/ 验收标准 / 回报格式。缺一段就别发。
39
+ - **收工必须独立复核证据,不许只看它说「已完成」。** 复核对的是:它贴的可复现命令 + 输出、关键 diff、验收标准逐条过。子会话的自述是证据,不是结论。
40
+ - **一卡最多重发两次。** 两次还不过,就换方案或自己上手,并把「卡在哪条验收」记下来——不要用第三次重发来掩盖 brief 本身写得不清。
41
+ - **决定权归用户。** 要不要发版、要不要改口径、两个方案选哪个——用 `ask_user_question` 提问,推荐项放第一位并标「(推荐)」,同时留一个自定义输入位。自己有倾向要说清理由和「什么情况下这个推荐会反转」,但不许替人拍板。
42
+ - **不替子会话写代码。** 它负责的模块它说了算;你要做的是定边界、验结果、把结论汇总给人。
43
+
44
+ ---
45
+
46
+ ## 四 · 子会话纪律(干活的那一方)
47
+
48
+ - **只动 brief 里列出的文件。** 发现别的地方也不对,写进回报的「顺手发现」段,不要动。
49
+ - **不 commit / 不 push。** 除非 brief 明确要求。
50
+ - **改完自验,并把可复现命令 + 输出贴进结果文件。** 命令要能被人直接粘回去跑;输出要贴退出码与关键行,不要只写「测试通过」。
51
+ - **brief 与现实冲突时,先记录再降级处理。** 例:brief 说要改的文件不存在、说验证的命令在这里跑不起来——先在结果文件里写「冲突:brief 第 N 条 vs 现实」,然后选一个不扩大范围的降级做法(跳过 / 用等价命令 / 只做能做的部分),不要擅自扩大范围或改写目标。
52
+ - **回报必须包含「解决了哪条老问题」。** 对应用户以前提过的原话或条号,写清「以前是什么行为 → 现在是什么行为」。找不到对应老问题就说「纯新增」,别硬凑。
53
+ - **越界即失效。** 动了边界外的文件、改了别的人正在改的模块,这一轮的成果不算数,要退回重做。
54
+
55
+ ---
56
+
57
+ ## 五 · 汇报四段(每次交付怎么汇报)
58
+
59
+ 段落顺序固定,别只报「这次做了什么」。四段缺一段,等于没汇报。
60
+
61
+ 1. **解决了你提过的哪些问题** —— 按用户原话列,每条后面跟条号与一句「现在是什么行为」;没解决的老问题也要写一行「仍未解决 + 卡在哪」。
62
+ 2. **这轮新做的** —— 新增能力、新文件、新闸门,每条带验收证据。
63
+ 3. **你要动手的**(如果有)—— 双击哪个 bat、重启哪个进程、在哪个界面点一下,一句话一条。
64
+ 4. **被动风险** —— 会让什么失效(例:换密钥会让已信任的设备掉线),先说后做。
65
+
66
+ 汇报用通俗话:不写内部字段名和流水号,写「会话」「排队」「做完了」。
67
+
68
+ 填空模板(直接抄):
69
+
70
+ ```
71
+ 解决了你提过的哪些问题:<原话/条号 → 现在什么行为>
72
+ 这轮新做的:<3–6 条,每条写清验收证据>
73
+ 你要动手的:<只有用户能做的事>
74
+ 被动风险:<会变坏的地方 + 触发条件>
75
+ ```
76
+
77
+ 例(结构示范,内容来自一次真实交付):
78
+
79
+ ```
80
+ 解决了你提过的哪些问题:第 12 条「报错日志看不懂」→ 现在闸门失败会直接打印 文件:行 + 原因,退出码非 0;第 15 条「换机器就乱」→ 仍未解决,卡在没有机器指纹的替代方案。
81
+ 这轮新做的:新增 verify.py 内联脚本解析(证据:node --check 通过,故意插错一个引号后正确报 文件:行);新增 after-deploy 的登记核对(证据:拿一个没登记的模块跑,输出 3 条 WARN);新增 docs/SKILLS.md 五节。
82
+ 你要动手的:把 docs/SKILLS.md 里的路由表贴进你们的 AGENTS.md;在发布脚本里加一行 python bin/verify.py。
83
+ 被动风险:闸门变严之后,历史上一直没被检查的老文件可能第一次跑就不绿;触发条件是 syntaxGlobs 覆盖到那些文件,第一次跑之前先看一眼命中列表。
84
+ ```
package/dsh/index.js ADDED
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Host half of the dsh-ops-kit bundle: two tools that run the kit's own CLIs.
3
+ *
4
+ * 设计约束(改之前先读):
5
+ * 1. 这个插件只做转发,不含任何业务逻辑;dream/verify 的规则全在 bin/ 里。
6
+ * 2. 默认 dry-run:只有调用方显式传 apply:true,才会给 dream 加 --apply。
7
+ * 3. 没有 kit.config.json 时两个脚本自己非 0 退出、不写文件;这里只把原话转给模型。
8
+ * 4. 输出一律带 [kit] 前缀(脚本自己打的),模型据此认出这不是目标仓库自带的闸门。
9
+ */
10
+ import { spawn } from 'node:child_process'
11
+ import path from 'node:path'
12
+ import { fileURLToPath } from 'node:url'
13
+
14
+ export const name = 'dsh-ops-kit'
15
+ export const inject = ['tools']
16
+
17
+ const HERE = path.dirname(fileURLToPath(import.meta.url))
18
+ const PKG = path.resolve(HERE, '..')
19
+ const DREAM = path.join(PKG, 'bin', 'dream.mjs')
20
+ const VERIFY = path.join(PKG, 'bin', 'verify.py')
21
+ const MODES = ['daily', 'weekly', 'card', 'after-deploy', 'status']
22
+ const DREAM_TIMEOUT = 60000
23
+ const VERIFY_TIMEOUT = 180000
24
+ const MAX_OUT = 8000
25
+
26
+ function clip(s) {
27
+ const t = String(s === undefined || s === null ? '' : s)
28
+ if (t.length <= MAX_OUT) return t
29
+ return '…(超长截断,只保留最后 ' + MAX_OUT + ' 字符)' + String.fromCharCode(10) + t.slice(-MAX_OUT)
30
+ }
31
+
32
+ function nodeBin() { return process.env.NODE_BIN || process.execPath }
33
+ function pythonBin() { return process.env.PYTHON_BIN || (process.platform === 'win32' ? 'python' : 'python3') }
34
+
35
+ function run(cmd, argv, signal, timeoutMs) {
36
+ return new Promise(function (resolve) {
37
+ let child
38
+ try {
39
+ child = spawn(cmd, argv, { cwd: PKG, windowsHide: true, env: Object.assign({}, process.env, { PYTHONIOENCODING: 'utf-8' }) })
40
+ } catch (e) {
41
+ resolve({ code: -1, out: '', err: String((e && e.message) || e) });
42
+ return;
43
+ }
44
+ let out = '';
45
+ let err = '';
46
+ let settled = false;
47
+ let timer = null;
48
+ function finish(r) {
49
+ if (settled) return;
50
+ settled = true;
51
+ if (timer) clearTimeout(timer);
52
+ resolve(r);
53
+ }
54
+ function kill() { try { child.kill(); } catch (e) { /* 已经退出 */ } }
55
+ timer = setTimeout(function () {
56
+ kill();
57
+ finish({ code: -1, out: out, err: err + '\n[kit] 超时 ' + timeoutMs + 'ms,已终止' });
58
+ }, timeoutMs);
59
+ if (signal && typeof signal.addEventListener === 'function') {
60
+ if (signal.aborted) {
61
+ kill();
62
+ finish({ code: -1, out: '', err: '[kit] 调用已取消' });
63
+ return;
64
+ }
65
+ signal.addEventListener('abort', function () { kill(); }, { once: true });
66
+ }
67
+ child.stdout.on('data', function (d) { out += String(d) });
68
+ child.stderr.on('data', function (d) { err += String(d) });
69
+ child.on('error', function (e) { finish({ code: -1, out: out, err: err + '\n' + String((e && e.message) || e) }) });
70
+ child.on('close', function (code) { finish({ code: code === null ? -1 : code, out: out, err: err }) });
71
+ });
72
+ }
73
+
74
+ function cfgArg(args, config) {
75
+ const direct = args && typeof args.config === 'string' ? args.config.trim() : ''
76
+ const fallback = config && typeof config.configPath === 'string' ? config.configPath.trim() : ''
77
+ const chosen = direct || fallback
78
+ return chosen ? '--config=' + path.resolve(chosen) : ''
79
+ }
80
+
81
+ function dreamTool(config) {
82
+ return {
83
+ name: 'kit_dream',
84
+ description:
85
+ 'Run the ops-kit dream pass (daily / weekly / card / after-deploy / status). ' +
86
+ 'Use it when a long session needs its memory consolidated: 日结、周总账、把刚踩的坑写成事实卡、发版后核对登记、看当前状态。' +
87
+ 'Default is dry-run; pass apply:true only when the user asked for a write in this turn. ' +
88
+ 'Output starts with [kit]: this is never the target repo own release gate — do not treat its green as a deploy approval.',
89
+ parameters: {
90
+ type: 'object',
91
+ properties: {
92
+ mode: { type: 'string', enum: MODES, description: 'daily 日结(默认)/ weekly 周总账 / card 落一张事实卡 / after-deploy 发版后核对 / status 现状卡' },
93
+ apply: { type: 'boolean', description: 'true 才真正写文件;默认 false(dry-run)' },
94
+ force: { type: 'boolean', description: 'daily 今天已跑过时强制重跑' },
95
+ config: { type: 'string', description: 'kit.config.json 路径;省略则脚本自己按 脚本目录 → 上级 → 上两级 → cwd 查找' },
96
+ symptom: { type: 'string', description: 'mode=card 时:现象' },
97
+ cause: { type: 'string', description: 'mode=card 时:原因' },
98
+ fix: { type: 'string', description: 'mode=card 时:修法' },
99
+ lesson: { type: 'string', description: 'mode=card 时:一句话教训(下次别再踩)' }
100
+ },
101
+ required: ['mode']
102
+ },
103
+ isConcurrencySafe: function () { return false },
104
+ async execute(args, exec) {
105
+ const a = args || {};
106
+ const mode = String(a.mode || 'daily');
107
+ if (MODES.indexOf(mode) < 0) throw new Error('kit_dream: mode 只能是 ' + MODES.join(' | '));
108
+ const argv = [DREAM, '--' + mode];
109
+ if (mode === 'card') {
110
+ const keys = ['symptom', 'cause', 'fix', 'lesson'];
111
+ for (const k of keys) {
112
+ if (typeof a[k] === 'string' && a[k].trim()) argv.push('--' + k + '=' + a[k].trim());
113
+ }
114
+ }
115
+ const c = cfgArg(a, config);
116
+ if (c) argv.push(c);
117
+ if (a.apply === true) argv.push('--apply');
118
+ if (a.force === true) argv.push('--force');
119
+ const r = await run(nodeBin(), argv, exec && exec.signal, DREAM_TIMEOUT);
120
+ const head = '[kit] dream ' + mode + ' exit=' + r.code + (r.code === 0 ? '(正常;退出 0 不代表没有告警,看结论行)' : '(非 0:配置缺失或有告警)');
121
+ return clip(head + String.fromCharCode(10) + r.out + (r.err ? String.fromCharCode(10) + '[stderr]' + String.fromCharCode(10) + r.err : ''));
122
+ }
123
+ };
124
+ }
125
+
126
+ function verifyTool(config) {
127
+ return {
128
+ name: 'kit_verify',
129
+ description:
130
+ 'Run the ops-kit static gate: node --check on the configured globs, inline <script> parsing in configured HTML, ' +
131
+ 'and registered probes that must print RESULT {"ok":true}. 发版前跑它,或提交前只验改动文件。' +
132
+ 'Output starts with [kit] and is prefixed; it is never a substitute for the target repo own gate.',
133
+ parameters: {
134
+ type: 'object',
135
+ properties: {
136
+ probes: { type: 'string', description: '留空不跑探针;"all" 全跑;"a,b" 点名跑;"default" 跑标记为默认的' },
137
+ changed: { type: 'boolean', description: 'true 时只验本次改动(需要 git)' },
138
+ quiet: { type: 'boolean', description: '只打结论行' },
139
+ config: { type: 'string', description: 'kit.config.json 路径;省略则自动查找' }
140
+ },
141
+ required: []
142
+ },
143
+ isConcurrencySafe: function () { return true },
144
+ async execute(args, exec) {
145
+ const a = args || {};
146
+ const argv = [VERIFY];
147
+ const c = cfgArg(a, config);
148
+ if (c) argv.push(c);
149
+ const pr = typeof a.probes === 'string' ? a.probes.trim() : '';
150
+ if (pr === 'default') argv.push('--probes');
151
+ else if (pr) argv.push('--probes=' + pr);
152
+ if (a.changed === true) argv.push('--changed');
153
+ if (a.quiet === true) argv.push('--quiet');
154
+ const r = await run(pythonBin(), argv, exec && exec.signal, VERIFY_TIMEOUT);
155
+ const head = '[kit] verify exit=' + r.code + (r.code === 0 ? '(通过)' : '(未通过:先看上面的明细行)');
156
+ return clip(head + String.fromCharCode(10) + r.out + (r.err ? String.fromCharCode(10) + '[stderr]' + String.fromCharCode(10) + r.err : ''));
157
+ }
158
+ };
159
+ }
160
+
161
+ export function apply(ctx, config) {
162
+ const cfg = config || {};
163
+ const tools = [dreamTool(cfg), verifyTool(cfg)];
164
+ const register = function (tool) {
165
+ try {
166
+ if (typeof ctx.effect === 'function') ctx.effect(function () { return ctx.tools.register(tool) });
167
+ else ctx.tools.register(tool);
168
+ } catch (e) {
169
+ console.error('[kit] ' + tool.name + ' 注册失败(不影响宿主):' + String((e && e.message) || e));
170
+ }
171
+ };
172
+ for (const t of tools) register(t);
173
+ }
package/gate.bat ADDED
@@ -0,0 +1,31 @@
1
+ @echo off
2
+ rem dsh-ops-kit release gate: python verify.py in the folder you pass (or this kit's config).
3
+ rem Usage: gate.bat [project-dir]
4
+ setlocal
5
+ chcp 65001 >nul 2>&1
6
+ cd /d "%~dp0"
7
+
8
+ set "PY_EXE="
9
+ for %%P in (python.exe) do if not defined PY_EXE if exist "%%~$PATH:P" set "PY_EXE=%%~$PATH:P"
10
+ if not defined PY_EXE if exist "%LOCALAPPDATA%\Programs\Python\Python312\python.exe" set "PY_EXE=%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
11
+ if not defined PY_EXE (
12
+ echo [kit] python.exe not found. Install Python 3.10+ or set PY_EXE=D:\path\to\python.exe
13
+ if not defined KIT_NOPAUSE pause
14
+ exit /b 2
15
+ )
16
+
17
+ if "%~1"=="" (
18
+ "%PY_EXE%" "bin\verify.py"
19
+ ) else (
20
+ "%PY_EXE%" "bin\verify.py" --config="%~1\kit.config.json"
21
+ )
22
+ if errorlevel 1 (
23
+ echo.
24
+ echo [kit] FAILED - do not ship
25
+ if not defined KIT_NOPAUSE pause
26
+ exit /b 1
27
+ )
28
+ echo.
29
+ echo [kit] OK - verify green
30
+ if not defined KIT_NOPAUSE pause
31
+ exit /b 0
package/icon.svg ADDED
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="ops kit">
2
+ <rect x="4" y="6" width="56" height="52" rx="12" fill="#111827"/>
3
+ <rect x="14" y="16" width="36" height="7" rx="3.5" fill="#38bdf8"/>
4
+ <rect x="14" y="29" width="26" height="7" rx="3.5" fill="#94a3b8"/>
5
+ <rect x="14" y="42" width="32" height="7" rx="3.5" fill="#22c55e"/>
6
+ <circle cx="50" cy="46" r="4" fill="#f59e0b"/>
7
+ </svg>
@@ -0,0 +1,201 @@
1
+ {
2
+ "_note": "复制成 kit.config.json 再改路径。所有路径都相对本文件所在目录;JSON 不能写注释,说明放 _note 字段。",
3
+ "_minimal": "最小可用集是 changelog / lessons / guardrails / index / handoff 五个路径;缺哪个就跳过哪项检查,不报错。",
4
+ "_paths": "probes(探针登记表 .tsv)+ probeDir(探针目录)驱动登记核对与遗忘清单;logDir 放做梦日志、周报、现状卡片和水位文件(.dream-state.json,可用 stateFile 覆写)。",
5
+ "changelog": "docs/changelog.md",
6
+ "lessons": "docs/lessons.md",
7
+ "guardrails": "docs/guardrails.md",
8
+ "index": "docs/INDEX.md",
9
+ "handoff": "docs/handoff.md",
10
+ "probes": "tools/probes.tsv",
11
+ "probeDir": ".probe",
12
+ "logDir": "docs/logs",
13
+ "_scan": {
14
+ "0": "s",
15
+ "1": "c",
16
+ "2": "a",
17
+ "3": "n",
18
+ "4": "M",
19
+ "5": "a",
20
+ "6": "r",
21
+ "7": "k",
22
+ "8": "d",
23
+ "9": "o",
24
+ "10": "w",
25
+ "11": "n",
26
+ "12": "D",
27
+ "13": "i",
28
+ "14": "r",
29
+ "15": "s",
30
+ "16": " ",
31
+ "17": "查",
32
+ "18": "旧",
33
+ "19": "口",
34
+ "20": "径",
35
+ "21": "残",
36
+ "22": "留",
37
+ "23": "时",
38
+ "24": "扫",
39
+ "25": "的",
40
+ "26": "目",
41
+ "27": "录",
42
+ "28": ";",
43
+ "29": "s",
44
+ "30": "c",
45
+ "31": "a",
46
+ "32": "n",
47
+ "33": "C",
48
+ "34": "o",
49
+ "35": "d",
50
+ "36": "e",
51
+ "37": "D",
52
+ "38": "i",
53
+ "39": "r",
54
+ "40": "s",
55
+ "41": " ",
56
+ "42": "只",
57
+ "43": "扫",
58
+ "44": "注",
59
+ "45": "释",
60
+ "46": "行",
61
+ "47": ";",
62
+ "48": "s",
63
+ "49": "k",
64
+ "50": "i",
65
+ "51": "p",
66
+ "52": "D",
67
+ "53": "a",
68
+ "54": "t",
69
+ "55": "a",
70
+ "56": "F",
71
+ "57": "i",
72
+ "58": "l",
73
+ "59": "e",
74
+ "60": "s",
75
+ "61": " ",
76
+ "62": "是",
77
+ "63": "内",
78
+ "64": "容",
79
+ "65": "文",
80
+ "66": "件",
81
+ "67": "(",
82
+ "68": "不",
83
+ "69": "是",
84
+ "70": "代",
85
+ "71": "码",
86
+ "72": ")",
87
+ "73": ",",
88
+ "74": "别",
89
+ "75": "扫",
90
+ "76": "。",
91
+ "_nodeCandidates": "找不到 node 时依次试这些路径(NODE_BIN 环境变量优先)。留空表示只查 PATH 里的 node / node.exe;换机器只改这里,别改脚本。"
92
+ },
93
+ "scanMarkdownDirs": [
94
+ "docs"
95
+ ],
96
+ "scanCodeDirs": [
97
+ "src"
98
+ ],
99
+ "scanHtmlFiles": [],
100
+ "skipDataFiles": [
101
+ "data.js"
102
+ ],
103
+ "_patterns": "别的仓库标题写法不一样时只改这里,不用改代码:retired / exempt 是 lessons 里两个段名(可带 ## 前缀);card / cardNo / cardState 是事实卡的正则;entry 是额外条目正则,必须带命名分组 no 与 title,例如 \"^## (?<no>\\d+)|(?<title>.*)$\"。内置已认 5 种条目写法,通常不用配。",
104
+ "patterns": {
105
+ "retired": "已废止口径",
106
+ "exempt": "冲突检测豁免",
107
+ "card": "^### ([A-Z]\\d+) · (.*)$",
108
+ "cardNo": "^-\\s*条号[::]\\s*(.*)$",
109
+ "cardState": "^-\\s*状态[::]\\s*(.*)$",
110
+ "entry": ""
111
+ },
112
+ "_thresholds": "陈旧/遗忘/滚动/容量阈值,单位是行与天。",
113
+ "staleDays": 30,
114
+ "forgetDays": 14,
115
+ "logKeep": 30,
116
+ "weekKeep": 12,
117
+ "lessonsMaxLines": 300,
118
+ "guardrailsMaxLines": 200,
119
+ "archiveAfterDays": 90,
120
+ "changelogArchive": [],
121
+ "_moduleRegistry": "发版体检只核对 freshHours 内真改过的模块;points 是必须出现文件名的登记点,template 里的 {name} 是文件名、{stem} 是去扩展名。",
122
+ "moduleRegistry": {
123
+ "pattern": "^src/[A-Za-z0-9_.-]+\\.js$",
124
+ "freshHours": 6,
125
+ "points": [
126
+ {
127
+ "file": "src/index.html",
128
+ "label": "页面 script 标签",
129
+ "template": "{name}"
130
+ },
131
+ {
132
+ "file": "tools/deploy.py",
133
+ "label": "cache-bust 名单",
134
+ "template": "{name}"
135
+ },
136
+ {
137
+ "file": "src/sw.js",
138
+ "label": "Service Worker 白名单",
139
+ "template": "/{name}"
140
+ }
141
+ ]
142
+ },
143
+ "_allowed": "发版体检里算「计划外改动」的目录白名单。",
144
+ "allowedRoots": [
145
+ "docs",
146
+ "src",
147
+ "tools"
148
+ ],
149
+ "allowedRootFiles": [
150
+ "AGENTS.md"
151
+ ],
152
+ "_verify": "syntaxGlobs 是 node --check 的清单;inlineHtml 可以写一个对象、也可以写数组(每个页面都查一遍),parser 留空走内置解析(把内联 script 体落临时文件再 node --check);probeCommand 是探针执行器模板,留空默认 node <文件>,可换 python / deno / 带参数的包装命令(支持 {node} {python} {file});probeDefault 是「默认」列在 tsv 里的 0 基下标。",
153
+ "syntaxGlobs": [
154
+ "src/**/*.js",
155
+ "tools/*.mjs"
156
+ ],
157
+ "inlineHtml": [
158
+ {
159
+ "file": "src/index.html",
160
+ "parser": ""
161
+ }
162
+ ],
163
+ "probeCommand": "",
164
+ "probeDefault": 4,
165
+ "probeNameFilter": "",
166
+ "_status": "status 段可选:配了才出心跳表;不配就只出改动记录/探针/事实卡/guardrails 这几行。",
167
+ "status": {
168
+ "file": "state/status.json",
169
+ "buildFile": "state/build.json",
170
+ "deployFile": "state/deploy.json",
171
+ "sections": [
172
+ {
173
+ "key": "collect",
174
+ "label": "<环节名>"
175
+ }
176
+ ],
177
+ "statusCardName": "current.md",
178
+ "_fields": "心跳字段名不同就改这里:fields 是每个环节里的 beat/ok/count/msg;buildKeys 是版本标识与时间的键名(按序取第一个存在的),deployKeys 同。",
179
+ "fields": {
180
+ "beat": "beat",
181
+ "ok": "ok",
182
+ "count": "count",
183
+ "msg": "msg"
184
+ },
185
+ "buildKeys": [
186
+ "d",
187
+ "version"
188
+ ],
189
+ "buildTimeKeys": [
190
+ "t",
191
+ "time"
192
+ ],
193
+ "deployUrlKeys": [
194
+ "url"
195
+ ],
196
+ "deployTimeKeys": [
197
+ "time"
198
+ ]
199
+ },
200
+ "nodeCandidates": []
201
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Ops Kit (dream + verify gates)",
4
+ "description": "Memory layering, dream passes, and a pre-release static gate for long-running agents, plus coordinator and subagent discipline."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "运维骨架(日结 + 发版闸门)",
4
+ "description": "给长跑 agent 的记忆分层、做梦整理、发版静态闸门,以及指挥部与子会话的分工纪律。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@zh0vy4n/dsh-ops-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Long-run agent ops kit: memory layering, dream passes, a pre-release static gate, and coordinator/subagent discipline. Ships as a skill and as a DSH bundle.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "dsh-ops-kit contributors",
8
+ "private": false,
9
+ "exports": {
10
+ ".": "./dsh/index.js",
11
+ "./locale/*.json": "./locale/*.json",
12
+ "./icon": "./icon.svg"
13
+ },
14
+ "files": [
15
+ "dsh",
16
+ "bin",
17
+ "scripts",
18
+ "docs",
19
+ "SKILL.md",
20
+ "README.md",
21
+ "LICENSE",
22
+ "CHANGELOG.md",
23
+ "kit.config.example.json",
24
+ "cordis.patch.yml",
25
+ "locale/*.json",
26
+ "icon.svg",
27
+ "check.bat",
28
+ "gate.bat"
29
+ ],
30
+ "keywords": [
31
+ "dsh",
32
+ "dsh-bundle",
33
+ "skill",
34
+ "agent-ops",
35
+ "memory",
36
+ "release-gate"
37
+ ],
38
+ "engines": {
39
+ "node": ">=20"
40
+ },
41
+ "dsh": {
42
+ "bundle": {
43
+ "patch": "./cordis.patch.yml"
44
+ }
45
+ },
46
+ "scripts": {
47
+ "selfcheck": "node scripts/selfcheck.mjs",
48
+ "test:plugin": "node scripts/test-plugin.mjs",
49
+ "rename": "node scripts/rename-package.mjs",
50
+ "selfcheck:bash": "bash scripts/selfcheck.sh",
51
+ "sync": "node scripts/sync-skill.mjs",
52
+ "sync:check": "node scripts/sync-skill.mjs --check"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
6
57
  }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ // 一条命令改包名(四处联动,避免发出去以后改不动):
3
+ // package.json.name(全名,可带 @scope)
4
+ // cordis.patch.yml 的 id(短名)与 name(全名)
5
+ // dsh/index.js 的 export const name(短名)
6
+ // SKILL.md frontmatter 的 name(短名)
7
+ // 用法:node scripts/rename-package.mjs @scope/pkg
8
+ // node scripts/rename-package.mjs --check 只比对四处是否一致
9
+ import { readFileSync, writeFileSync } from 'node:fs';
10
+ import { join, dirname } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+
13
+ const KIT = join(dirname(fileURLToPath(import.meta.url)), '..');
14
+ const F = {
15
+ pkg: join(KIT, 'package.json'),
16
+ patch: join(KIT, 'cordis.patch.yml'),
17
+ index: join(KIT, 'dsh', 'index.js'),
18
+ skill: join(KIT, 'SKILL.md'),
19
+ };
20
+ const read = (p) => readFileSync(p, 'utf8');
21
+ const shortOf = (full) => String(full).replace(/^@[^/]+\//, '');
22
+
23
+ const pkg = JSON.parse(read(F.pkg));
24
+ const patchTxt = read(F.patch);
25
+ const indexTxt = read(F.index);
26
+ const skillTxt = read(F.skill);
27
+
28
+ function snapshot() {
29
+ const pkgNow = JSON.parse(read(F.pkg));
30
+ const patchNow = read(F.patch);
31
+ const indexNow = read(F.index);
32
+ const skillNow = read(F.skill);
33
+ return {
34
+ 'package.json.name': pkgNow.name,
35
+ 'cordis id': (patchNow.match(/^\s+-\s*id:\s*'?([^'\n]+)'?\s*$/m) || [])[1],
36
+ 'cordis name': (patchNow.match(/^\s+name:\s*'?([^'\n]+)'?\s*$/m) || [])[1],
37
+ 'dsh/index name': (indexNow.match(/^export const name = '([^']+)'/m) || [])[1],
38
+ 'SKILL name': (skillNow.match(/^name:\s*(.+)$/m) || [])[1],
39
+ };
40
+ }
41
+
42
+ function report() {
43
+ const got = snapshot();
44
+ for (const [k, v] of Object.entries(got)) console.log('[kit] ' + k + ' = ' + v);
45
+ const full = got['package.json.name'];
46
+ const want = { 'cordis id': shortOf(full), 'cordis name': full, 'dsh/index name': shortOf(full), 'SKILL name': shortOf(full) };
47
+ const bad = Object.keys(want).filter((k) => got[k] !== want[k]);
48
+ if (bad.length) console.log('[kit] 不一致:' + bad.join(', '));
49
+ return bad.length === 0;
50
+ }
51
+
52
+ const arg = process.argv[2] || '';
53
+ if (!arg || arg === '--check') {
54
+ console.log('[kit] 当前名字:');
55
+ const ok = report();
56
+ console.log(ok ? '[kit] 四处一致' : '[kit] 跑 node scripts/rename-package.mjs <新名字> 统一');
57
+ process.exit(ok ? 0 : 1);
58
+ }
59
+ if (!/^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(arg)) {
60
+ console.error('[kit] 名字不合法(小写、可带 @scope/、不能有大写和空格):' + arg);
61
+ process.exit(2);
62
+ }
63
+
64
+ const short = shortOf(arg);
65
+ pkg.name = arg;
66
+ writeFileSync(F.pkg, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
67
+ writeFileSync(F.patch, patchTxt
68
+ .replace(/^(\s+-\s*id:\s*)'?[^'\n]+'?\s*$/m, (m, pre) => pre + short)
69
+ .replace(/^(\s+name:\s*)'?[^'\n]+'?\s*$/m, (m, pre) => pre + "'" + arg + "'"), 'utf8');
70
+ writeFileSync(F.index, indexTxt.replace(/^export const name = '[^']+'/m, "export const name = '" + short + "'"), 'utf8');
71
+ writeFileSync(F.skill, skillTxt.replace(/^name:\s*.+$/m, 'name: ' + short), 'utf8');
72
+
73
+ console.log('[kit] 已改名 → ' + arg + '(短名 ' + short + ')');
74
+ const ok = report();
75
+ console.log('[kit] 下一步(cmd / PowerShell / bash 通用):');
76
+ console.log('[kit] node scripts/selfcheck.mjs');
77
+ console.log('[kit] node scripts/sync-skill.mjs');
78
+ process.exit(ok ? 0 : 1);