@yankeguo/dsh-command-devlead 0.2.3 → 0.2.5
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 +30 -3
- package/lib/index.js +82 -16
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @yankeguo/dsh-command-devlead
|
|
2
2
|
|
|
3
|
-
The human-facing `/devlead` command behind the
|
|
3
|
+
The human-facing `/devlead` command behind the composer-toolbar toggle; it also owns watch-set changes,
|
|
4
4
|
damage recovery, and the human-readable status view. The status output includes
|
|
5
5
|
`Worktree isolation: available|unavailable` so a human can see whether the optional
|
|
6
6
|
checkout-isolation capability is composed.
|
|
7
7
|
|
|
8
8
|
```text
|
|
9
|
-
/devlead # status: mode, worktree capability, watched sessions, recent notifications
|
|
9
|
+
/devlead # status: mode, worktree capability, watched sessions, recent notifications/reports
|
|
10
10
|
/devlead on # enable DevLead mode for this Session (human-only)
|
|
11
11
|
/devlead off # disable it; on a frozen fold it recovers by resetting the damaged state
|
|
12
12
|
/devlead reset # human-only recovery: discard this Session's DevLead state (mode/watch/digest)
|
|
@@ -14,6 +14,13 @@ checkout-isolation capability is composed.
|
|
|
14
14
|
/devlead unwatch <session> # stop watching it
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
DevLead mode is Host-wide and single-active: exactly one Session may hold it across every
|
|
18
|
+
Workspace. `/devlead on` in a second Session is refused with `DEVLEAD_ALREADY_ACTIVE`, whose
|
|
19
|
+
message names the occupying Session and says to run `/devlead off` there first; the refused
|
|
20
|
+
Session's projection stays disabled. Off/reset release the slot immediately, and archiving the
|
|
21
|
+
holder makes it releasable on the next admission/startup (the core writes the durable mode-off
|
|
22
|
+
when it can).
|
|
23
|
+
|
|
17
24
|
The command parses the DSH `CommandInvocation.rawInput` contract (text after the command name),
|
|
18
25
|
does not accept composer attachments, and renders domain failures as friendly text instead of
|
|
19
26
|
throwing. Prefix references are confirmed with the core's exhaustive resolver before a watch
|
|
@@ -21,6 +28,17 @@ mutation, so a bounded listing cannot silently shadow another matching Session.
|
|
|
21
28
|
derived from a post-mutation snapshot, so a concurrent command cannot leave the title describing a
|
|
22
29
|
different state than the rendered body.
|
|
23
30
|
|
|
31
|
+
The status view also renders the five newest mid-turn reports (`Recent reports:`) with timestamp,
|
|
32
|
+
sender, kind, and summary/message; report errors (not-supervised, rate-limited, invalid fields) are
|
|
33
|
+
rendered as friendly command text. A report is not sent by the command itself; watched Sessions
|
|
34
|
+
use the `devlead_report` tool.
|
|
35
|
+
|
|
36
|
+
An archived DevLead holder no longer blocks `/devlead on`: admission treats archived Sessions as
|
|
37
|
+
inactive and records a durable tombstone when the mode-off cannot be written. `/devlead status`
|
|
38
|
+
lists such holders under `Archived DevLead holders (ignored for admission)` with the action
|
|
39
|
+
`unarchive and run /devlead off, or delete it`; opening the unarchived Session reconciles it so a
|
|
40
|
+
second enabled lead is not left behind.
|
|
41
|
+
|
|
24
42
|
`/devlead reset` appends a `plugin:devlead/reset` durable record: replay applies it before the
|
|
25
43
|
corruption freeze check, so a Session whose earlier `plugin:devlead/*` record is corrupt becomes
|
|
26
44
|
usable again (both projections restart from the default disabled state). `/devlead off` runs the
|
|
@@ -41,7 +59,16 @@ dsh plugin --profile desktop add @yankeguo/dsh-devlead-bundle
|
|
|
41
59
|
|
|
42
60
|
## 中文
|
|
43
61
|
|
|
44
|
-
`@yankeguo/dsh-command-devlead` 提供人类 `/devlead`
|
|
62
|
+
`@yankeguo/dsh-command-devlead` 提供人类 `/devlead` 命令:模式状态、reset、watch/unwatch。
|
|
63
|
+
DevLead 模式全局单活:第二个会话执行 `/devlead on` 会以 `DEVLEAD_ALREADY_ACTIVE` 被拒,
|
|
64
|
+
消息给出占用者并提示先在占用者上 `/devlead off`;关闭/重置立即释放,归档占用者在下一次
|
|
65
|
+
准入/启动时可被释放。
|
|
66
|
+
状态视图还会列出最近 5 条中途汇报(`Recent reports:`,含时间、sender、kind、summary/message);
|
|
67
|
+
not-supervised / rate-limited / 参数错误都会转成友好命令文本。命令本身不发送汇报;被监督会话
|
|
68
|
+
使用 `devlead_report` 工具。已归档 DevLead 占用者不再阻塞 `/devlead on`:准入把它视为非 active,
|
|
69
|
+
mode-off 写不掉时记录 durable tombstone;`/devlead status` 的
|
|
70
|
+
`Archived DevLead holders (ignored for admission)` 会列出它并提示 unarchive + `/devlead off`
|
|
71
|
+
或删除,打开后 reconciliation 会消除双活。
|
|
45
72
|
0.2.0 起 `/devlead reset`(以及冻结时 `/devlead off`)追加 `plugin:devlead/reset` 记录并解冻
|
|
46
73
|
损坏的 fold;reset 会丢弃该会话的 watch 集合与通知 digest。命令按 DSH `rawInput` 契约解析,
|
|
47
74
|
不接受附件,前缀引用在变更前由 core 穷尽验证,变更后的标题与正文来自同一 post-mutation 快照。完整中文文档见
|
package/lib/index.js
CHANGED
|
@@ -17,35 +17,66 @@ function splitHead(input) {
|
|
|
17
17
|
if (separator === -1) return { head: input.toLowerCase(), rest: "" };
|
|
18
18
|
return { head: input.slice(0, separator).toLowerCase(), rest: input.slice(separator).trim() };
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
var QUOTE_PAIRS = [
|
|
21
|
+
['"', '"'],
|
|
22
|
+
["'", "'"],
|
|
23
|
+
["\u201C", "\u201D"],
|
|
24
|
+
["\u2018", "\u2019"],
|
|
25
|
+
["\u300C", "\u300D"],
|
|
26
|
+
["\u300E", "\u300F"],
|
|
27
|
+
["\uFF02", "\uFF02"]
|
|
28
|
+
];
|
|
29
|
+
function closingQuoteOf(opening) {
|
|
30
|
+
return QUOTE_PAIRS.find(([open]) => open === opening)?.[1];
|
|
31
|
+
}
|
|
32
|
+
function isClosingQuote(value) {
|
|
33
|
+
return QUOTE_PAIRS.some(([, close]) => close === value);
|
|
27
34
|
}
|
|
28
35
|
function unexpectedArgument(subcommand) {
|
|
29
36
|
return invalid(`The /devlead ${subcommand} subcommand does not take an argument.`);
|
|
30
37
|
}
|
|
31
38
|
function parseSessionArgument(subcommand, text) {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
39
|
+
const raw = text.trim();
|
|
40
|
+
if (raw.length === 0) {
|
|
34
41
|
return invalid(
|
|
35
42
|
`/devlead ${subcommand} requires a Session id or a unique id prefix. Run /devlead to inspect the current watch set.`
|
|
36
43
|
);
|
|
37
44
|
}
|
|
38
|
-
|
|
45
|
+
const closer = closingQuoteOf(raw[0] ?? "");
|
|
46
|
+
if (closer !== void 0) {
|
|
47
|
+
const end = raw.indexOf(closer, 1);
|
|
48
|
+
if (end === -1) {
|
|
49
|
+
return invalid(
|
|
50
|
+
`The /devlead ${subcommand} Session reference has an unmatched quote; wrap the whole reference in one matching pair of quotes.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (raw.slice(end + 1).trim().length > 0) {
|
|
54
|
+
return invalid(
|
|
55
|
+
`"/devlead ${subcommand}" takes exactly one Session reference; unexpected text follows the quoted reference.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const session = raw.slice(1, end).trim();
|
|
59
|
+
if (session.length === 0) {
|
|
60
|
+
return invalid(`/devlead ${subcommand} requires a Session id or a unique id prefix.`);
|
|
61
|
+
}
|
|
62
|
+
if (/\s/u.test(session)) {
|
|
63
|
+
return invalid(
|
|
64
|
+
`"/devlead ${subcommand}" takes one Session reference without spaces; pass the full Session id or a unique id prefix.`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return { kind: subcommand, session };
|
|
68
|
+
}
|
|
69
|
+
if (isClosingQuote(raw[raw.length - 1] ?? "")) {
|
|
39
70
|
return invalid(
|
|
40
71
|
`The /devlead ${subcommand} Session reference has an unmatched quote; wrap the whole reference in one matching pair of quotes.`
|
|
41
72
|
);
|
|
42
73
|
}
|
|
43
|
-
if (/\s/u.test(
|
|
74
|
+
if (/\s/u.test(raw)) {
|
|
44
75
|
return invalid(
|
|
45
76
|
`"/devlead ${subcommand}" takes one Session reference without spaces; pass the full Session id or a unique id prefix.`
|
|
46
77
|
);
|
|
47
78
|
}
|
|
48
|
-
return { kind: subcommand, session };
|
|
79
|
+
return { kind: subcommand, session: raw };
|
|
49
80
|
}
|
|
50
81
|
function parseDevLeadCommand(rawInput) {
|
|
51
82
|
const input = rawInput.trim();
|
|
@@ -76,6 +107,11 @@ function parseDevLeadCommand(rawInput) {
|
|
|
76
107
|
case "reset":
|
|
77
108
|
return unexpectedArgument(head);
|
|
78
109
|
default:
|
|
110
|
+
if (head === `/${DEVLEAD_COMMAND_NAME.toLowerCase()}`) {
|
|
111
|
+
return invalid(
|
|
112
|
+
'Pass only the text after the command name (for example "on"), not the full /devlead line.'
|
|
113
|
+
);
|
|
114
|
+
}
|
|
79
115
|
return invalid(`Unknown /devlead subcommand "${head}".`);
|
|
80
116
|
}
|
|
81
117
|
}
|
|
@@ -84,6 +120,7 @@ function parseDevLeadCommand(rawInput) {
|
|
|
84
120
|
import {
|
|
85
121
|
formatInstant,
|
|
86
122
|
notificationLine,
|
|
123
|
+
reportLine,
|
|
87
124
|
transitionLabel
|
|
88
125
|
} from "@yankeguo/dsh-devlead-protocol";
|
|
89
126
|
|
|
@@ -136,6 +173,7 @@ function formatCandidates(candidates) {
|
|
|
136
173
|
|
|
137
174
|
// packages/command/src/render.ts
|
|
138
175
|
var RECENT_NOTIFICATION_LIMIT = 5;
|
|
176
|
+
var RECENT_REPORT_LIMIT = 5;
|
|
139
177
|
var HELP_LINE = "Help: /devlead (status) | /devlead on | /devlead off | /devlead reset | /devlead watch <session> | /devlead unwatch <session>";
|
|
140
178
|
function modeLabel(enabled) {
|
|
141
179
|
return enabled ? "on" : "off";
|
|
@@ -144,7 +182,7 @@ function sessionLabel(view) {
|
|
|
144
182
|
return sessionRefLabel(view.sessionId, view.title);
|
|
145
183
|
}
|
|
146
184
|
function sessionStateLabel(view) {
|
|
147
|
-
const state = view.archived ? "archived" : view.running ? "running" : view.live ? "idle" : "cold";
|
|
185
|
+
const state = view.archived ? view.running ? "archived (running)" : "archived" : view.running ? "running" : view.live ? "idle" : "cold";
|
|
148
186
|
const parts = [state];
|
|
149
187
|
if (view.running && (view.pendingInputs ?? 0) > 0) parts.push(`${view.pendingInputs} queued`);
|
|
150
188
|
if (view.lastTurn !== void 0) {
|
|
@@ -157,7 +195,7 @@ function sessionStateLabel(view) {
|
|
|
157
195
|
function watchedLines(snapshot) {
|
|
158
196
|
const total = snapshot.watched.length + snapshot.missingWatched.length;
|
|
159
197
|
if (total === 0) return ["Watched sessions: none"];
|
|
160
|
-
const running = snapshot.watched.filter((view) => view.running).length;
|
|
198
|
+
const running = snapshot.watched.filter((view) => view.running && !view.archived).length;
|
|
161
199
|
const summary = running === 0 ? `Watched sessions: ${total}` : `Watched sessions: ${total} (${running} running)`;
|
|
162
200
|
const lines = [summary];
|
|
163
201
|
for (const view of snapshot.watched) lines.push(` - ${sessionLabel(view)} \u2014 ${sessionStateLabel(view)}`);
|
|
@@ -172,12 +210,32 @@ function notificationLines(snapshot) {
|
|
|
172
210
|
}
|
|
173
211
|
return lines;
|
|
174
212
|
}
|
|
213
|
+
function archivedOccupantLines(snapshot) {
|
|
214
|
+
if (snapshot.archivedOccupants.length === 0) return [];
|
|
215
|
+
return [
|
|
216
|
+
`Archived DevLead holders (ignored for admission): ${String(snapshot.archivedOccupants.length)}`,
|
|
217
|
+
...snapshot.archivedOccupants.map((occupant) => {
|
|
218
|
+
const label = occupant.title === void 0 ? occupant.sessionId : `${occupant.title} (${occupant.sessionId})`;
|
|
219
|
+
return ` - ${label} \u2014 unarchive and run /devlead off, or delete it`;
|
|
220
|
+
})
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
function reportLines(snapshot) {
|
|
224
|
+
if (snapshot.reports.length === 0) return ["Recent reports: none"];
|
|
225
|
+
const lines = ["Recent reports:"];
|
|
226
|
+
for (const report of snapshot.reports) {
|
|
227
|
+
lines.push(` - ${formatInstant(report.at)} ${reportLine(report)}`);
|
|
228
|
+
}
|
|
229
|
+
return lines;
|
|
230
|
+
}
|
|
175
231
|
function statusLines(snapshot) {
|
|
176
232
|
const lines = [
|
|
177
233
|
`DevLead mode: ${modeLabel(snapshot.enabled)}`,
|
|
178
234
|
`Worktree isolation: ${snapshot.worktreeIsolation ? "available" : "unavailable"}`,
|
|
179
235
|
...watchedLines(snapshot),
|
|
180
|
-
...
|
|
236
|
+
...archivedOccupantLines(snapshot),
|
|
237
|
+
...notificationLines(snapshot),
|
|
238
|
+
...reportLines(snapshot)
|
|
181
239
|
];
|
|
182
240
|
if (!snapshot.enabled) {
|
|
183
241
|
lines.push(
|
|
@@ -217,12 +275,15 @@ async function collectStatus(ctx, invocation) {
|
|
|
217
275
|
else watched.push(session);
|
|
218
276
|
}
|
|
219
277
|
}
|
|
278
|
+
const archivedOccupants = await ctx.devLead.archivedOccupants(invocation.signal);
|
|
220
279
|
return {
|
|
221
280
|
enabled: view.enabled,
|
|
222
281
|
worktreeIsolation: ctx.devLead.worktreeIsolationAvailable,
|
|
223
282
|
watched,
|
|
224
283
|
missingWatched,
|
|
225
|
-
|
|
284
|
+
archivedOccupants,
|
|
285
|
+
notifications: view.notifications.slice(-RECENT_NOTIFICATION_LIMIT),
|
|
286
|
+
reports: view.reports.slice(-RECENT_REPORT_LIMIT)
|
|
226
287
|
};
|
|
227
288
|
}
|
|
228
289
|
async function collectCandidates(ctx, invocation, watchedSessionIds) {
|
|
@@ -334,6 +395,11 @@ function friendlyDevLeadError(error) {
|
|
|
334
395
|
switch (error.code) {
|
|
335
396
|
case "DEVLEAD_NOT_ENABLED":
|
|
336
397
|
return NOT_ENABLED_MESSAGE;
|
|
398
|
+
case "DEVLEAD_ALREADY_ACTIVE":
|
|
399
|
+
return error.message;
|
|
400
|
+
case "DEVLEAD_NOT_SUPERVISED":
|
|
401
|
+
case "DEVLEAD_REPORT_RATE_LIMITED":
|
|
402
|
+
return error.message;
|
|
337
403
|
case "DEVLEAD_AGENT_NOT_LIVE":
|
|
338
404
|
return "This Session is no longer live in this Host, so the command cannot run. Open it again from the sidebar and retry.";
|
|
339
405
|
case "DEVLEAD_INVALID_INPUT":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-command-devlead",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Human-facing /devlead command: enable or disable DevLead mode for the current session and inspect the lead's managed workspaces, sessions, and notifications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
],
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
20
|
-
"@deepseek-ai/dsh-commands": "0.2.2-rc.1"
|
|
20
|
+
"@deepseek-ai/dsh-commands": ">=0.2.2-rc.1 <0.3.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@yankeguo/dsh-devlead": "0.2.
|
|
24
|
-
"@yankeguo/dsh-devlead-protocol": "0.2.
|
|
23
|
+
"@yankeguo/dsh-devlead": "0.2.5",
|
|
24
|
+
"@yankeguo/dsh-devlead-protocol": "0.2.5"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"dsh": ">=0.2.2-rc.1 <0.3.0"
|