@yankeguo/dsh-command-devlead 0.1.0 → 0.2.0
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 +48 -0
- package/lib/index.js +133 -84
- package/package.json +5 -4
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @yankeguo/dsh-command-devlead
|
|
2
|
+
|
|
3
|
+
The human-facing `/devlead` command behind the UI mode switch; it also owns watch-set changes,
|
|
4
|
+
damage recovery, and the human-readable status view. The status output includes
|
|
5
|
+
`Worktree isolation: available|unavailable` so a human can see whether the optional
|
|
6
|
+
checkout-isolation capability is composed.
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
/devlead # status: mode, worktree capability, watched sessions, recent notifications
|
|
10
|
+
/devlead on # enable DevLead mode for this Session (human-only)
|
|
11
|
+
/devlead off # disable it; on a frozen fold it recovers by resetting the damaged state
|
|
12
|
+
/devlead reset # human-only recovery: discard this Session's DevLead state (mode/watch/digest)
|
|
13
|
+
/devlead watch <session> # watch a Session by full id or unique prefix
|
|
14
|
+
/devlead unwatch <session> # stop watching it
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The command parses the DSH `CommandInvocation.rawInput` contract (text after the command name),
|
|
18
|
+
does not accept composer attachments, and renders domain failures as friendly text instead of
|
|
19
|
+
throwing. Prefix references are confirmed with the core's exhaustive resolver before a watch
|
|
20
|
+
mutation, so a bounded listing cannot silently shadow another matching Session. Outcome titles are
|
|
21
|
+
derived from a post-mutation snapshot, so a concurrent command cannot leave the title describing a
|
|
22
|
+
different state than the rendered body.
|
|
23
|
+
|
|
24
|
+
`/devlead reset` appends a `plugin:devlead/reset` durable record: replay applies it before the
|
|
25
|
+
corruption freeze check, so a Session whose earlier `plugin:devlead/*` record is corrupt becomes
|
|
26
|
+
usable again (both projections restart from the default disabled state). `/devlead off` runs the
|
|
27
|
+
same recovery when the fold is frozen; `/devlead on` refuses and asks for the explicit reset.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Normally installed as part of the bundle:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
dsh plugin --profile desktop add @yankeguo/dsh-devlead-bundle
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Related docs
|
|
38
|
+
|
|
39
|
+
- [Repository README (English)](https://github.com/yankeguo/dsh-devlead/blob/main/README.md) / [中文](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)
|
|
40
|
+
- [Design notes: command contract and error mapping](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)
|
|
41
|
+
|
|
42
|
+
## 中文
|
|
43
|
+
|
|
44
|
+
`@yankeguo/dsh-command-devlead` 提供人类 `/devlead` 命令:状态、开关、reset、watch/unwatch。
|
|
45
|
+
0.2.0 起 `/devlead reset`(以及冻结时 `/devlead off`)追加 `plugin:devlead/reset` 记录并解冻
|
|
46
|
+
损坏的 fold;reset 会丢弃该会话的 watch 集合与通知 digest。命令按 DSH `rawInput` 契约解析,
|
|
47
|
+
不接受附件,前缀引用在变更前由 core 穷尽验证,变更后的标题与正文来自同一 post-mutation 快照。完整中文文档见
|
|
48
|
+
[根 README.zh.md](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)与[设计说明](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)。
|
package/lib/index.js
CHANGED
|
@@ -7,15 +7,15 @@ import { DEVLEAD_COMMAND_NAME as DEVLEAD_COMMAND_NAME2 } from "@yankeguo/dsh-dev
|
|
|
7
7
|
|
|
8
8
|
// packages/command/src/parse.ts
|
|
9
9
|
import { DEVLEAD_COMMAND_NAME } from "@yankeguo/dsh-devlead-protocol";
|
|
10
|
-
var COMMAND_GRAMMAR = "[status|on|off|watch <session>|unwatch <session>]";
|
|
10
|
+
var COMMAND_GRAMMAR = "[status|on|off|reset|watch <session>|unwatch <session>]";
|
|
11
11
|
var USAGE = `Usage: /${DEVLEAD_COMMAND_NAME} ${COMMAND_GRAMMAR}`;
|
|
12
12
|
function invalid(message) {
|
|
13
13
|
return { kind: "invalid", message };
|
|
14
14
|
}
|
|
15
15
|
function splitHead(input) {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
return { head:
|
|
16
|
+
const separator = input.search(/\s/u);
|
|
17
|
+
if (separator === -1) return { head: input.toLowerCase(), rest: "" };
|
|
18
|
+
return { head: input.slice(0, separator).toLowerCase(), rest: input.slice(separator).trim() };
|
|
19
19
|
}
|
|
20
20
|
function unquote(text) {
|
|
21
21
|
const trimmed = text.trim();
|
|
@@ -35,6 +35,11 @@ function parseSessionArgument(subcommand, text) {
|
|
|
35
35
|
`/devlead ${subcommand} requires a Session id or a unique id prefix. Run /devlead to inspect the current watch set.`
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
+
if (/^["']|["']$/u.test(session)) {
|
|
39
|
+
return invalid(
|
|
40
|
+
`The /devlead ${subcommand} Session reference has an unmatched quote; wrap the whole reference in one matching pair of quotes.`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
38
43
|
if (/\s/u.test(session)) {
|
|
39
44
|
return invalid(
|
|
40
45
|
`"/devlead ${subcommand}" takes one Session reference without spaces; pass the full Session id or a unique id prefix.`
|
|
@@ -43,9 +48,7 @@ function parseSessionArgument(subcommand, text) {
|
|
|
43
48
|
return { kind: subcommand, session };
|
|
44
49
|
}
|
|
45
50
|
function parseDevLeadCommand(rawInput) {
|
|
46
|
-
const
|
|
47
|
-
const complete = /^\/devlead[/\s]*/iu.exec(trimmed);
|
|
48
|
-
const input = (complete === null ? trimmed : trimmed.slice(complete[0].length)).trim();
|
|
51
|
+
const input = rawInput.trim();
|
|
49
52
|
if (input.length === 0) return { kind: "status" };
|
|
50
53
|
switch (input.toLowerCase()) {
|
|
51
54
|
case "status":
|
|
@@ -54,6 +57,8 @@ function parseDevLeadCommand(rawInput) {
|
|
|
54
57
|
return { kind: "on" };
|
|
55
58
|
case "off":
|
|
56
59
|
return { kind: "off" };
|
|
60
|
+
case "reset":
|
|
61
|
+
return { kind: "reset" };
|
|
57
62
|
default:
|
|
58
63
|
break;
|
|
59
64
|
}
|
|
@@ -68,6 +73,7 @@ function parseDevLeadCommand(rawInput) {
|
|
|
68
73
|
case "status":
|
|
69
74
|
case "on":
|
|
70
75
|
case "off":
|
|
76
|
+
case "reset":
|
|
71
77
|
return unexpectedArgument(head);
|
|
72
78
|
default:
|
|
73
79
|
return invalid(`Unknown /devlead subcommand "${head}".`);
|
|
@@ -80,14 +86,62 @@ import {
|
|
|
80
86
|
notificationLine,
|
|
81
87
|
transitionLabel
|
|
82
88
|
} from "@yankeguo/dsh-devlead-protocol";
|
|
89
|
+
|
|
90
|
+
// packages/command/src/resolve.ts
|
|
91
|
+
import {
|
|
92
|
+
DEVLEAD_ERROR_EXCERPT_MAX,
|
|
93
|
+
excerptLine
|
|
94
|
+
} from "@yankeguo/dsh-devlead-protocol";
|
|
95
|
+
function candidateOf(view) {
|
|
96
|
+
return view.title === void 0 ? { sessionId: view.sessionId } : { sessionId: view.sessionId, title: view.title };
|
|
97
|
+
}
|
|
98
|
+
function mergeCandidates(listed, watchedSessionIds) {
|
|
99
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
100
|
+
for (const view of listed) candidates.set(view.sessionId, candidateOf(view));
|
|
101
|
+
for (const sessionId of watchedSessionIds) {
|
|
102
|
+
if (!candidates.has(sessionId)) candidates.set(sessionId, { sessionId });
|
|
103
|
+
}
|
|
104
|
+
return [...candidates.values()];
|
|
105
|
+
}
|
|
106
|
+
function resolveSessionReference(query, candidates) {
|
|
107
|
+
const reference = query.trim();
|
|
108
|
+
if (reference.length === 0) return { kind: "missing" };
|
|
109
|
+
for (const candidate of candidates) {
|
|
110
|
+
if (candidate.sessionId !== reference) continue;
|
|
111
|
+
return candidate.title === void 0 ? { kind: "resolved", sessionId: candidate.sessionId } : { kind: "resolved", sessionId: candidate.sessionId, title: candidate.title };
|
|
112
|
+
}
|
|
113
|
+
const matches = candidates.filter((candidate) => candidate.sessionId.startsWith(reference));
|
|
114
|
+
const first = matches[0];
|
|
115
|
+
if (first === void 0) return { kind: "missing" };
|
|
116
|
+
if (matches.length === 1) {
|
|
117
|
+
return first.title === void 0 ? { kind: "resolved", sessionId: first.sessionId } : { kind: "resolved", sessionId: first.sessionId, title: first.title };
|
|
118
|
+
}
|
|
119
|
+
return { kind: "ambiguous", candidates: matches };
|
|
120
|
+
}
|
|
121
|
+
var MAX_RENDERED_CANDIDATES = 10;
|
|
122
|
+
function sessionRefLabel(sessionId, title) {
|
|
123
|
+
const line = title === void 0 ? void 0 : excerptLine(title, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
124
|
+
return line === void 0 ? sessionId : `${line} (${sessionId})`;
|
|
125
|
+
}
|
|
126
|
+
function candidateLabel(candidate) {
|
|
127
|
+
return sessionRefLabel(candidate.sessionId, candidate.title);
|
|
128
|
+
}
|
|
129
|
+
function formatCandidates(candidates) {
|
|
130
|
+
const shown = candidates.slice(0, MAX_RENDERED_CANDIDATES);
|
|
131
|
+
const lines = shown.map((candidate) => ` - ${candidateLabel(candidate)}`);
|
|
132
|
+
const hidden = candidates.length - shown.length;
|
|
133
|
+
if (hidden > 0) lines.push(` \u2026 and ${hidden} more`);
|
|
134
|
+
return lines;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// packages/command/src/render.ts
|
|
83
138
|
var RECENT_NOTIFICATION_LIMIT = 5;
|
|
84
|
-
var HELP_LINE = "Help: /devlead on | /devlead off | /devlead watch <session> | /devlead unwatch <session>";
|
|
139
|
+
var HELP_LINE = "Help: /devlead (status) | /devlead on | /devlead off | /devlead reset | /devlead watch <session> | /devlead unwatch <session>";
|
|
85
140
|
function modeLabel(enabled) {
|
|
86
141
|
return enabled ? "on" : "off";
|
|
87
142
|
}
|
|
88
143
|
function sessionLabel(view) {
|
|
89
|
-
|
|
90
|
-
return title.length === 0 ? view.sessionId : `${title} (${view.sessionId})`;
|
|
144
|
+
return sessionRefLabel(view.sessionId, view.title);
|
|
91
145
|
}
|
|
92
146
|
function sessionStateLabel(view) {
|
|
93
147
|
const state = view.archived ? "archived" : view.running ? "running" : view.live ? "idle" : "cold";
|
|
@@ -121,6 +175,7 @@ function notificationLines(snapshot) {
|
|
|
121
175
|
function statusLines(snapshot) {
|
|
122
176
|
const lines = [
|
|
123
177
|
`DevLead mode: ${modeLabel(snapshot.enabled)}`,
|
|
178
|
+
`Worktree isolation: ${snapshot.worktreeIsolation ? "available" : "unavailable"}`,
|
|
124
179
|
...watchedLines(snapshot),
|
|
125
180
|
...notificationLines(snapshot)
|
|
126
181
|
];
|
|
@@ -141,60 +196,20 @@ function errorResult(text) {
|
|
|
141
196
|
return { kind: "error", text };
|
|
142
197
|
}
|
|
143
198
|
|
|
144
|
-
// packages/command/src/resolve.ts
|
|
145
|
-
function candidateOf(view) {
|
|
146
|
-
return view.title === void 0 ? { sessionId: view.sessionId } : { sessionId: view.sessionId, title: view.title };
|
|
147
|
-
}
|
|
148
|
-
function mergeCandidates(listed, watchedSessionIds) {
|
|
149
|
-
const candidates = /* @__PURE__ */ new Map();
|
|
150
|
-
for (const view of listed) candidates.set(view.sessionId, candidateOf(view));
|
|
151
|
-
for (const sessionId of watchedSessionIds) {
|
|
152
|
-
if (!candidates.has(sessionId)) candidates.set(sessionId, { sessionId });
|
|
153
|
-
}
|
|
154
|
-
return [...candidates.values()];
|
|
155
|
-
}
|
|
156
|
-
function resolveSessionReference(query, candidates) {
|
|
157
|
-
const reference = query.trim();
|
|
158
|
-
if (reference.length === 0) return { kind: "missing" };
|
|
159
|
-
for (const candidate of candidates) {
|
|
160
|
-
if (candidate.sessionId !== reference) continue;
|
|
161
|
-
return candidate.title === void 0 ? { kind: "resolved", sessionId: candidate.sessionId } : { kind: "resolved", sessionId: candidate.sessionId, title: candidate.title };
|
|
162
|
-
}
|
|
163
|
-
const matches = candidates.filter((candidate) => candidate.sessionId.startsWith(reference));
|
|
164
|
-
const first = matches[0];
|
|
165
|
-
if (first === void 0) return { kind: "missing" };
|
|
166
|
-
if (matches.length === 1) {
|
|
167
|
-
return first.title === void 0 ? { kind: "resolved", sessionId: first.sessionId } : { kind: "resolved", sessionId: first.sessionId, title: first.title };
|
|
168
|
-
}
|
|
169
|
-
return { kind: "ambiguous", candidates: matches };
|
|
170
|
-
}
|
|
171
|
-
var MAX_RENDERED_CANDIDATES = 10;
|
|
172
|
-
function candidateLabel(candidate) {
|
|
173
|
-
return candidate.title === void 0 ? candidate.sessionId : `${candidate.title} (${candidate.sessionId})`;
|
|
174
|
-
}
|
|
175
|
-
function formatCandidates(candidates) {
|
|
176
|
-
const shown = candidates.slice(0, MAX_RENDERED_CANDIDATES);
|
|
177
|
-
const lines = shown.map((candidate) => ` - ${candidateLabel(candidate)}`);
|
|
178
|
-
const hidden = candidates.length - shown.length;
|
|
179
|
-
if (hidden > 0) lines.push(` \u2026 and ${hidden} more`);
|
|
180
|
-
return lines;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
199
|
// packages/command/src/index.ts
|
|
184
200
|
var name = "command-devlead";
|
|
185
201
|
var inject = ["commands", "devLead"];
|
|
186
|
-
var DESCRIPTION = "Turn DevLead mode on or off for this Session, watch or unwatch another Session, and inspect the DevLead mode, watch set, and recent notification digest.";
|
|
202
|
+
var DESCRIPTION = "Turn DevLead mode on or off for this Session, reset damaged DevLead state, watch or unwatch another Session, and inspect the DevLead mode, watch set, and recent notification digest.";
|
|
187
203
|
var NOT_ENABLED_MESSAGE = "DevLead mode is off for this Session, so its watch set cannot change. Turn it on with /devlead on first.";
|
|
188
204
|
async function collectStatus(ctx, invocation) {
|
|
189
205
|
const view = ctx.devLead.view(invocation.agent);
|
|
190
206
|
const watched = [];
|
|
191
207
|
const missingWatched = [];
|
|
192
208
|
if (view.sessions.length > 0) {
|
|
193
|
-
const sessions = await ctx.devLead.listSessions(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
209
|
+
const sessions = await ctx.devLead.listSessions(invocation.agent, {
|
|
210
|
+
watchedOnly: true,
|
|
211
|
+
signal: invocation.signal
|
|
212
|
+
});
|
|
198
213
|
const byId = new Map(sessions.map((session) => [session.sessionId, session]));
|
|
199
214
|
for (const sessionId of view.sessions) {
|
|
200
215
|
const session = byId.get(sessionId);
|
|
@@ -204,13 +219,14 @@ async function collectStatus(ctx, invocation) {
|
|
|
204
219
|
}
|
|
205
220
|
return {
|
|
206
221
|
enabled: view.enabled,
|
|
222
|
+
worktreeIsolation: ctx.devLead.worktreeIsolationAvailable,
|
|
207
223
|
watched,
|
|
208
224
|
missingWatched,
|
|
209
|
-
notifications:
|
|
225
|
+
notifications: view.notifications.slice(-RECENT_NOTIFICATION_LIMIT)
|
|
210
226
|
};
|
|
211
227
|
}
|
|
212
228
|
async function collectCandidates(ctx, invocation, watchedSessionIds) {
|
|
213
|
-
const sessions = await ctx.devLead.listSessions(invocation.agent, {
|
|
229
|
+
const sessions = await ctx.devLead.listSessions(invocation.agent, { signal: invocation.signal });
|
|
214
230
|
return mergeCandidates(sessions, watchedSessionIds);
|
|
215
231
|
}
|
|
216
232
|
function ambiguousResult(query, candidates) {
|
|
@@ -225,9 +241,6 @@ function missingSessionResult(query) {
|
|
|
225
241
|
`No Session matches "${query}". Check the Session id, or run /devlead to inspect the watched Sessions.`
|
|
226
242
|
);
|
|
227
243
|
}
|
|
228
|
-
function referenceLabel(sessionId, title) {
|
|
229
|
-
return title === void 0 ? sessionId : `${title} (${sessionId})`;
|
|
230
|
-
}
|
|
231
244
|
async function resolveBeyondListing(ctx, invocation, reference) {
|
|
232
245
|
try {
|
|
233
246
|
const view = await ctx.devLead.getSession(invocation.agent, reference, invocation.signal);
|
|
@@ -242,10 +255,10 @@ async function resolveBeyondListing(ctx, invocation, reference) {
|
|
|
242
255
|
async function resolveWatchTarget(ctx, invocation, reference, watchedSessionIds) {
|
|
243
256
|
const candidates = await collectCandidates(ctx, invocation, watchedSessionIds);
|
|
244
257
|
const resolution = resolveSessionReference(reference, candidates);
|
|
245
|
-
if (resolution.kind === "resolved") return resolution;
|
|
246
258
|
if (resolution.kind === "ambiguous") {
|
|
247
259
|
return { kind: "failure", result: ambiguousResult(reference, resolution.candidates) };
|
|
248
260
|
}
|
|
261
|
+
if (resolution.kind === "resolved" && reference === resolution.sessionId) return resolution;
|
|
249
262
|
const fallback = await resolveBeyondListing(ctx, invocation, reference);
|
|
250
263
|
if (fallback.kind === "resolved") return fallback;
|
|
251
264
|
if (fallback.kind === "ambiguous") {
|
|
@@ -257,14 +270,41 @@ Use a longer prefix or the full Session id.`)
|
|
|
257
270
|
}
|
|
258
271
|
return { kind: "failure", result: missingSessionResult(reference) };
|
|
259
272
|
}
|
|
273
|
+
function snapshotWatches(snapshot, sessionId) {
|
|
274
|
+
return snapshot.watched.some((view) => view.sessionId === sessionId) || snapshot.missingWatched.includes(sessionId);
|
|
275
|
+
}
|
|
276
|
+
function modeTitle(requested, previous, actual) {
|
|
277
|
+
if (actual !== requested) {
|
|
278
|
+
return `DevLead mode is ${actual ? "on" : "off"} (another command changed it).`;
|
|
279
|
+
}
|
|
280
|
+
if (previous !== requested) return requested ? "DevLead mode enabled." : "DevLead mode disabled.";
|
|
281
|
+
return requested ? "DevLead mode is already on." : "DevLead mode is already off.";
|
|
282
|
+
}
|
|
283
|
+
function watchTitle(command, label, previous, actual) {
|
|
284
|
+
const requested = command === "watch";
|
|
285
|
+
if (actual !== requested) {
|
|
286
|
+
return requested ? `Not watching ${label} (another command changed it).` : `Still watching ${label} (another command changed it).`;
|
|
287
|
+
}
|
|
288
|
+
if (requested) return previous ? `Already watching ${label}.` : `Now watching ${label}.`;
|
|
289
|
+
return previous ? `Stopped watching ${label}.` : `Not watching ${label}.`;
|
|
290
|
+
}
|
|
260
291
|
async function executeMode(ctx, invocation, enabled) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
292
|
+
let previous;
|
|
293
|
+
try {
|
|
294
|
+
previous = ctx.devLead.view(invocation.agent).enabled;
|
|
295
|
+
} catch (error) {
|
|
296
|
+
if (!isDevLeadError(error) || error.code !== "DEVLEAD_PROJECTION_INVALID") throw error;
|
|
297
|
+
if (enabled) throw error;
|
|
298
|
+
await ctx.devLead.setEnabled(invocation.agent, false, invocation.signal);
|
|
299
|
+
const snapshot2 = await collectStatus(ctx, invocation);
|
|
300
|
+
const title = snapshot2.enabled ? "DevLead mode is on (another command changed it)." : "DevLead mode disabled; the damaged DevLead records were reset.";
|
|
301
|
+
return renderStatus(snapshot2, title);
|
|
302
|
+
}
|
|
303
|
+
if (previous !== enabled) {
|
|
304
|
+
await ctx.devLead.setEnabled(invocation.agent, enabled, invocation.signal);
|
|
264
305
|
}
|
|
265
|
-
await ctx
|
|
266
|
-
|
|
267
|
-
return renderStatus(await collectStatus(ctx, invocation), title);
|
|
306
|
+
const snapshot = await collectStatus(ctx, invocation);
|
|
307
|
+
return renderStatus(snapshot, modeTitle(enabled, previous, snapshot.enabled));
|
|
268
308
|
}
|
|
269
309
|
async function executeWatch(ctx, invocation, command) {
|
|
270
310
|
const view = ctx.devLead.view(invocation.agent);
|
|
@@ -272,29 +312,36 @@ async function executeWatch(ctx, invocation, command) {
|
|
|
272
312
|
const target = await resolveWatchTarget(ctx, invocation, command.session, view.sessions);
|
|
273
313
|
if (target.kind === "failure") return target.result;
|
|
274
314
|
const { sessionId } = target;
|
|
275
|
-
const label =
|
|
315
|
+
const label = sessionRefLabel(sessionId, target.title);
|
|
276
316
|
const watching = view.sessions.includes(sessionId);
|
|
277
317
|
if (command.kind === "watch") {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
318
|
+
if (!watching) await ctx.devLead.watchSession(invocation.agent, sessionId, true, invocation.signal);
|
|
319
|
+
} else if (watching) {
|
|
320
|
+
await ctx.devLead.watchSession(invocation.agent, sessionId, false, invocation.signal);
|
|
281
321
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
322
|
+
const snapshot = await collectStatus(ctx, invocation);
|
|
323
|
+
return renderStatus(
|
|
324
|
+
snapshot,
|
|
325
|
+
watchTitle(command.kind, label, watching, snapshotWatches(snapshot, sessionId))
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
async function executeReset(ctx, invocation) {
|
|
329
|
+
await ctx.devLead.reset(invocation.agent, invocation.signal);
|
|
330
|
+
const snapshot = await collectStatus(ctx, invocation);
|
|
331
|
+
return renderStatus(snapshot, "DevLead state reset.");
|
|
285
332
|
}
|
|
286
333
|
function friendlyDevLeadError(error) {
|
|
287
334
|
switch (error.code) {
|
|
288
335
|
case "DEVLEAD_NOT_ENABLED":
|
|
289
336
|
return NOT_ENABLED_MESSAGE;
|
|
290
337
|
case "DEVLEAD_AGENT_NOT_LIVE":
|
|
291
|
-
return "This Session is no longer live, so
|
|
338
|
+
return "This Session is no longer live in this Host, so the command cannot run. Open it again from the sidebar and retry.";
|
|
292
339
|
case "DEVLEAD_INVALID_INPUT":
|
|
293
340
|
return `The /devlead request is not usable: ${error.message}`;
|
|
294
341
|
case "DEVLEAD_SESSION_NOT_FOUND":
|
|
295
342
|
return `The host could not find that Session: ${error.message}`;
|
|
296
343
|
case "DEVLEAD_SESSION_ARCHIVED":
|
|
297
|
-
return "That Session is archived;
|
|
344
|
+
return "That Session is archived; restore it from the Workspace sidebar before watching it.";
|
|
298
345
|
case "DEVLEAD_SESSION_UNAVAILABLE":
|
|
299
346
|
return `That Session cannot be resumed right now: ${error.message}`;
|
|
300
347
|
case "DEVLEAD_WATCH_LIMIT":
|
|
@@ -302,22 +349,19 @@ function friendlyDevLeadError(error) {
|
|
|
302
349
|
case "DEVLEAD_SELF_WATCH":
|
|
303
350
|
return "A DevLead Session cannot watch itself.";
|
|
304
351
|
case "DEVLEAD_PROJECTION_INVALID":
|
|
305
|
-
return `This Session's DevLead records are damaged: ${error.message}. Inspect the Session log for the offending plugin:devlead record.`;
|
|
352
|
+
return `This Session's DevLead records are damaged, so its DevLead state cannot be read: ${error.message}. Run /devlead reset to discard the damaged state and start over (that also discards the watched-Session set and the notification digest). Inspect the Session log for the offending plugin:devlead record.`;
|
|
306
353
|
case "DEVLEAD_WORKSPACE_NOT_FOUND":
|
|
307
354
|
return `The Workspace could not be resolved: ${error.message}`;
|
|
308
355
|
case "DEVLEAD_DIRECTORY_MISSING":
|
|
309
356
|
return `The target directory is missing: ${error.message}`;
|
|
310
|
-
default:
|
|
311
|
-
|
|
357
|
+
default: {
|
|
358
|
+
const unknownCode = error.code;
|
|
359
|
+
return `The DevLead request failed (${String(unknownCode)}): ${error.message}`;
|
|
360
|
+
}
|
|
312
361
|
}
|
|
313
362
|
}
|
|
314
363
|
async function executeDevLeadCommand(ctx, invocation) {
|
|
315
364
|
const command = parseDevLeadCommand(invocation.rawInput);
|
|
316
|
-
if (invocation.attachments.length > 0) {
|
|
317
|
-
return errorResult(
|
|
318
|
-
"The /devlead command does not accept attachments; use the plain command text instead."
|
|
319
|
-
);
|
|
320
|
-
}
|
|
321
365
|
if (command.kind === "invalid") return errorResult(`${command.message}
|
|
322
366
|
${USAGE}`);
|
|
323
367
|
try {
|
|
@@ -327,6 +371,8 @@ ${USAGE}`);
|
|
|
327
371
|
case "on":
|
|
328
372
|
case "off":
|
|
329
373
|
return await executeMode(ctx, invocation, command.kind === "on");
|
|
374
|
+
case "reset":
|
|
375
|
+
return await executeReset(ctx, invocation);
|
|
330
376
|
case "watch":
|
|
331
377
|
case "unwatch":
|
|
332
378
|
return await executeWatch(ctx, invocation, command);
|
|
@@ -341,6 +387,9 @@ function apply(ctx) {
|
|
|
341
387
|
definitionId: CommandDefinitionId("@yankeguo/dsh-command-devlead"),
|
|
342
388
|
name: DEVLEAD_COMMAND_NAME2,
|
|
343
389
|
description: DESCRIPTION,
|
|
390
|
+
// The grammar is text-only, so the definition deliberately declares no
|
|
391
|
+
// `input.attachments`: the CommandRuntime then rejects composer attachments
|
|
392
|
+
// before this handler runs, and no handler-side guard is needed.
|
|
344
393
|
input: { hint: COMMAND_GRAMMAR },
|
|
345
394
|
handler: (invocation) => executeDevLeadCommand(ctx, invocation)
|
|
346
395
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-command-devlead",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
"./package.json": "./package.json"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"lib"
|
|
13
|
+
"lib",
|
|
14
|
+
"README.md"
|
|
14
15
|
],
|
|
15
16
|
"peerDependencies": {
|
|
16
17
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
17
18
|
"@deepseek-ai/dsh-commands": "0.2.2-rc.1"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@yankeguo/dsh-devlead": "0.
|
|
21
|
-
"@yankeguo/dsh-devlead-protocol": "0.
|
|
21
|
+
"@yankeguo/dsh-devlead": "0.2.0",
|
|
22
|
+
"@yankeguo/dsh-devlead-protocol": "0.2.0"
|
|
22
23
|
},
|
|
23
24
|
"engines": {
|
|
24
25
|
"dsh": ">=0.2.2-rc.1 <0.3.0"
|