dsh-plugin-mesh 0.5.0 → 0.5.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/README.md +3 -2
- package/client/client.js +6410 -893
- package/cordis.patch.yml +3 -2
- package/lib/_rehearsal-peer.mjs +2 -1
- package/lib/_selftest-capabilities.mjs +3 -1
- package/lib/_selftest-client.mjs +6 -389
- package/lib/_selftest-layout.mjs +112 -0
- package/lib/_selftest-prompt.mjs +67 -1
- package/lib/_selftest-reply-route.mjs +12 -1
- package/lib/_selftest-workbench.mjs +728 -0
- package/lib/discovery.js +33 -3
- package/lib/index.js +246 -27
- package/lib/layout.js +128 -0
- package/lib/persist.js +4 -0
- package/lib/prompt.js +25 -7
- package/package.json +4 -3
- package/scripts/_selftest-release-plan.mjs +33 -2
- package/scripts/release-plan.mjs +19 -1
package/lib/prompt.js
CHANGED
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* 这种 bug 只有能单测才防得住。
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* 「手动派发」在会话里留下的第一条消息。
|
|
14
|
+
*
|
|
15
|
+
* 为什么需要:派发时会预建一个会话等回执,但如果它是空的,用户点进去只看到
|
|
16
|
+
* 「暂无消息」,不知道自己发了什么。这里把原文摆进第一条,并明确告诉 agent
|
|
17
|
+
* **不要再调 mesh_run** —— 宿主已经替它发出去了,重复调用会让对端收到两份。
|
|
18
|
+
*/
|
|
12
19
|
/**
|
|
13
20
|
* @param input 入参可能是两种形状:webhook delivery(deliveryId/source)或
|
|
14
21
|
* mesh task(id/from)。两条入站路径都会走到这里,所以统一做一次归一化 ——
|
|
@@ -30,6 +37,14 @@ export function buildPrompt(input) {
|
|
|
30
37
|
// 退化成把 `/user` 后缀切掉。
|
|
31
38
|
const replyTo = String(input?.fromMachine || "").trim() || String(from).split("/")[0] || "unknown";
|
|
32
39
|
|
|
40
|
+
// 「这条是回执」和「这是一条新任务」必须给 agent 完全相反的指令。
|
|
41
|
+
//
|
|
42
|
+
// 真机事故(2026-10-21 手动派发):对端的回执被注入会话后,提示词仍然写着
|
|
43
|
+
// 「做完后用 mesh_run 回派给 X」→ 会话里的 agent 认真照做 → 对端又把它的回执
|
|
44
|
+
// 注回它自己的会话 → 两边互相回执,停不下来。
|
|
45
|
+
// 回执的处理方式只有一个:**转述给用户,不要再回派**。
|
|
46
|
+
const isReply = input?.isReply === true;
|
|
47
|
+
|
|
33
48
|
return [
|
|
34
49
|
`[DSH Mesh 任务 ${id}]`,
|
|
35
50
|
`来自: ${from}${input?.fromMachine ? ` (${input.fromMachine})` : ""}`,
|
|
@@ -37,13 +52,16 @@ export function buildPrompt(input) {
|
|
|
37
52
|
"",
|
|
38
53
|
String(input?.task ?? ""),
|
|
39
54
|
"",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
// 精简原则:每条只留**可执行的动作**,删掉解释性长句。
|
|
56
|
+
// 「为什么」留给本文件的注释和 docs,不放进取景框 —— 对端 agent 不需要被说服,
|
|
57
|
+
// 它只需要知道做什么、别做什么。
|
|
58
|
+
isReply
|
|
59
|
+
? "—— 这是回执,不是新任务:直接转述给用户,**不要再用 mesh_run 回派**(回执套回执会循环)。"
|
|
60
|
+
: [
|
|
61
|
+
`—— 对端派给你的任务。做完后用 mesh_run 把结果回派给 ${replyTo}(thread ${thread}),` +
|
|
62
|
+
`peer 填**机器名**(${replyTo}),不要填 "机器名/用户"。`,
|
|
63
|
+
"回派一次即可;纯回执带 noWake: true,否则会来回循环。",
|
|
64
|
+
].join("\n"),
|
|
47
65
|
]
|
|
48
66
|
.filter(Boolean)
|
|
49
67
|
.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-mesh",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH Mesh:局域网自动发现同网段的 DSH 实例、显示每台机器上报的能力,并双向派发任务;可用内置的用户态 Tailscale 节点跨互联网组网。Discovers other DSH instances on the LAN, shows the capabilities each one reports, and dispatches tasks between machines in both directions, with an optional userspace Tailscale node for links across networks.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,8 +63,9 @@
|
|
|
63
63
|
"selftest:resume": "node --experimental-vm-modules lib/_selftest-resume.mjs",
|
|
64
64
|
"selftest:persist": "node lib/_selftest-persist.mjs",
|
|
65
65
|
"selftest:reasoning": "node lib/_selftest-reasoning.mjs",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
66
|
+
"selftest:layout": "node lib/_selftest-layout.mjs",
|
|
67
|
+
"test": "npm run check && npm run selftest && npm run selftest:prompt && npm run selftest:pairing && npm run selftest:client && npm run selftest:caps && npm run selftest:release && npm run selftest:reply && npm run selftest:reasoning && npm run selftest:resume && npm run selftest:persist && npm run selftest:layout",
|
|
68
|
+
"check": "node scripts/check-version.mjs && node scripts/check-tdz.mjs && node --check lib/index.js && node --check lib/layout.js && node --check lib/discovery.js && node --check lib/conversation.js && node --check lib/identity.js && node --check lib/capabilities.js && node --check lib/prompt.js && node --check lib/pairing.js && node --check lib/scan.js && node --check lib/tsnet/download.js && node --check lib/tsnet/manager.js && node --check lib/tsnet/bridge.js && node --check client/client.js && node --check scripts/release-plan.mjs && npm run check:loadable && npm run check:docs",
|
|
68
69
|
"build:sidecar": "bash scripts/build-sidecar.sh",
|
|
69
70
|
"verify:mirror": "node scripts/verify-lan-mirror.mjs",
|
|
70
71
|
"release:plan": "node scripts/release-plan.mjs",
|
|
@@ -122,7 +122,7 @@ test("只认 plugin-v 前缀,别把 sidecar 的 tag 当插件版本", () => {
|
|
|
122
122
|
|
|
123
123
|
console.log("\n── 状态机:真实半态 ──");
|
|
124
124
|
|
|
125
|
-
test("
|
|
125
|
+
test("0.x 阶段 feat 只升 patch:0.3.33 + feat → 0.3.34", () => {
|
|
126
126
|
const p = planRelease({
|
|
127
127
|
pkgVersion: "0.3.33",
|
|
128
128
|
tag: "plugin-v0.3.33",
|
|
@@ -130,8 +130,39 @@ test("正常推进:tag=npm=仓库=0.3.33,有 feat → 0.4.0", () => {
|
|
|
130
130
|
commits: [{ subject: "feat: 新面板" }],
|
|
131
131
|
});
|
|
132
132
|
assert.equal(p.mode, "bump");
|
|
133
|
+
assert.equal(p.version, "0.3.34", "0.x 阶段加功能不应把 minor 推上去(真机反馈:一天从 0.3.36 涨到 0.5.0 太快)");
|
|
134
|
+
assert.equal(p.tag, "plugin-v0.3.34");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test("1.0 之后 feat 恢复标准 semver:1.2.3 + feat → 1.3.0", () => {
|
|
138
|
+
const p = planRelease({
|
|
139
|
+
pkgVersion: "1.2.3",
|
|
140
|
+
tag: "plugin-v1.2.3",
|
|
141
|
+
npmLatest: "1.2.3",
|
|
142
|
+
commits: [{ subject: "feat: 新面板" }],
|
|
143
|
+
});
|
|
144
|
+
assert.equal(p.version, "1.3.0");
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("0.x 阶段 breaking 仍然升 minor:0.3.33 + feat! → 0.4.0", () => {
|
|
148
|
+
const p = planRelease({
|
|
149
|
+
pkgVersion: "0.3.33",
|
|
150
|
+
tag: "plugin-v0.3.33",
|
|
151
|
+
npmLatest: "0.3.33",
|
|
152
|
+
commits: [{ subject: "feat!: 换协议" }],
|
|
153
|
+
});
|
|
154
|
+
assert.equal(p.version, "0.4.0");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("手动 --bump minor 不被 0.x 规则收敛(显式意图优先)", () => {
|
|
158
|
+
const p = planRelease({
|
|
159
|
+
pkgVersion: "0.3.33",
|
|
160
|
+
tag: "plugin-v0.3.33",
|
|
161
|
+
npmLatest: "0.3.33",
|
|
162
|
+
forcedBump: "minor",
|
|
163
|
+
commits: [{ subject: "chore: 手动发一版" }],
|
|
164
|
+
});
|
|
133
165
|
assert.equal(p.version, "0.4.0");
|
|
134
|
-
assert.equal(p.tag, "plugin-v0.4.0");
|
|
135
166
|
});
|
|
136
167
|
|
|
137
168
|
test("只有文档改动 → 不发版(每改一句话就发一版是最贵的注意力税)", () => {
|
package/scripts/release-plan.mjs
CHANGED
|
@@ -56,6 +56,13 @@ export function compareSemver(a, b) {
|
|
|
56
56
|
return 0;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/** 0.x 阶段把 minor 收敛成 patch(breaking 走的 major 不受影响)。 */
|
|
60
|
+
function zeroFeatAsPatch(base, bump) {
|
|
61
|
+
if (!ZERO_FEAT_AS_PATCH || bump !== "minor") return bump;
|
|
62
|
+
const v = parseSemver(base);
|
|
63
|
+
return v && v.major === 0 ? "patch" : bump;
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
export function applyBump(version, bump) {
|
|
60
67
|
const v = parseSemver(version);
|
|
61
68
|
if (!v) throw new Error(`当前版本号不合法:${version}`);
|
|
@@ -78,6 +85,16 @@ export function applyBump(version, bump) {
|
|
|
78
85
|
/** 一行是不是 Conventional Commit;允许前面带列表符号(合并提交的正文会长这样)。 */
|
|
79
86
|
const HEADER = /^\s*(?:[-*+]\s*)?(feat|fix|perf|refactor|revert|docs|chore|ci|test|style|build)(?:\([^)]*\))?(!)?\s*:\s*/;
|
|
80
87
|
|
|
88
|
+
/**
|
|
89
|
+
* 0.x 阶段把 `feat` 当 patch 处理。
|
|
90
|
+
*
|
|
91
|
+
* semver 允许 0.x 任意变动,而"加了个功能就 0.4.0、再修一个就 0.5.0"在真实使用里
|
|
92
|
+
* 涨得太快 —— 0.3.36 一天之内变成 0.5.0,维护者直接反馈"版本增长不要这么大"。
|
|
93
|
+
* 所以 0.x 期间:feat / fix / perf 都只升 patch,**只有 breaking 才升 minor**
|
|
94
|
+
* (见 applyBump 里的 ZERO_MAJOR_AS_MINOR)。1.0 之后恢复标准 semver。
|
|
95
|
+
*/
|
|
96
|
+
const ZERO_FEAT_AS_PATCH = true;
|
|
97
|
+
|
|
81
98
|
const RANK = { none: 0, patch: 1, minor: 2, major: 3 };
|
|
82
99
|
/** 只有这三种会让人真的想装新版本;其余(docs/chore/ci/test/style/build)不触发发版。 */
|
|
83
100
|
const TYPE_TO_BUMP = { feat: "minor", fix: "patch", perf: "patch", refactor: "patch", revert: "patch" };
|
|
@@ -235,7 +252,8 @@ export function planRelease({ pkgVersion, tag = "", npmLatest = "", since = "",
|
|
|
235
252
|
const analyzed = forcedBump
|
|
236
253
|
? { bump: forcedBump, hits: [] }
|
|
237
254
|
: analyzeCommits(commits);
|
|
238
|
-
|
|
255
|
+
// 手动 --bump 是显式意图,不收敛;只有自动分析出来的才套 0.x 规则
|
|
256
|
+
const bump = forcedBump ? analyzed.bump : zeroFeatAsPatch(base, analyzed.bump);
|
|
239
257
|
|
|
240
258
|
if (bump === "none") {
|
|
241
259
|
return {
|