@yankeguo/dsh-command-devlead 0.2.6 → 0.3.0-rc.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/lib/index.js +15 -14
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -32,11 +32,14 @@ function closingQuoteOf(opening) {
|
|
|
32
32
|
function isClosingQuote(value) {
|
|
33
33
|
return QUOTE_PAIRS.some(([, close]) => close === value);
|
|
34
34
|
}
|
|
35
|
+
function isOpeningQuote(value) {
|
|
36
|
+
return QUOTE_PAIRS.some(([open]) => open === value);
|
|
37
|
+
}
|
|
35
38
|
function unexpectedArgument(subcommand) {
|
|
36
39
|
return invalid(`The /devlead ${subcommand} subcommand does not take an argument.`);
|
|
37
40
|
}
|
|
38
41
|
function parseSessionArgument(subcommand, text) {
|
|
39
|
-
const raw = text.trim();
|
|
42
|
+
const raw = text.trim().replace(/[\u200B\u200C\u200D\uFEFF]/gu, "");
|
|
40
43
|
if (raw.length === 0) {
|
|
41
44
|
return invalid(
|
|
42
45
|
`/devlead ${subcommand} requires a Session id or a unique id prefix. Run /devlead to inspect the current watch set.`
|
|
@@ -66,7 +69,9 @@ function parseSessionArgument(subcommand, text) {
|
|
|
66
69
|
}
|
|
67
70
|
return { kind: subcommand, session };
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
const first = raw[0] ?? "";
|
|
73
|
+
const last = raw[raw.length - 1] ?? "";
|
|
74
|
+
if (isClosingQuote(first) || isClosingQuote(last) || isOpeningQuote(last)) {
|
|
70
75
|
return invalid(
|
|
71
76
|
`The /devlead ${subcommand} Session reference has an unmatched quote; wrap the whole reference in one matching pair of quotes.`
|
|
72
77
|
);
|
|
@@ -126,8 +131,7 @@ import {
|
|
|
126
131
|
|
|
127
132
|
// packages/command/src/resolve.ts
|
|
128
133
|
import {
|
|
129
|
-
|
|
130
|
-
excerptLine
|
|
134
|
+
sessionRefLabel
|
|
131
135
|
} from "@yankeguo/dsh-devlead-protocol";
|
|
132
136
|
function candidateOf(view) {
|
|
133
137
|
return view.title === void 0 ? { sessionId: view.sessionId } : { sessionId: view.sessionId, title: view.title };
|
|
@@ -140,6 +144,7 @@ function mergeCandidates(listed, watchedSessionIds) {
|
|
|
140
144
|
}
|
|
141
145
|
return [...candidates.values()];
|
|
142
146
|
}
|
|
147
|
+
var SESSION_ID_PREFIX = "session-";
|
|
143
148
|
function resolveSessionReference(query, candidates) {
|
|
144
149
|
const reference = query.trim();
|
|
145
150
|
if (reference.length === 0) return { kind: "missing" };
|
|
@@ -147,7 +152,8 @@ function resolveSessionReference(query, candidates) {
|
|
|
147
152
|
if (candidate.sessionId !== reference) continue;
|
|
148
153
|
return candidate.title === void 0 ? { kind: "resolved", sessionId: candidate.sessionId } : { kind: "resolved", sessionId: candidate.sessionId, title: candidate.title };
|
|
149
154
|
}
|
|
150
|
-
const
|
|
155
|
+
const mayOmitPrefix = !reference.startsWith(SESSION_ID_PREFIX);
|
|
156
|
+
const matches = candidates.filter((candidate) => candidate.sessionId.startsWith(reference) || mayOmitPrefix && candidate.sessionId.startsWith(SESSION_ID_PREFIX) && candidate.sessionId.slice(SESSION_ID_PREFIX.length).startsWith(reference));
|
|
151
157
|
const first = matches[0];
|
|
152
158
|
if (first === void 0) return { kind: "missing" };
|
|
153
159
|
if (matches.length === 1) {
|
|
@@ -156,10 +162,6 @@ function resolveSessionReference(query, candidates) {
|
|
|
156
162
|
return { kind: "ambiguous", candidates: matches };
|
|
157
163
|
}
|
|
158
164
|
var MAX_RENDERED_CANDIDATES = 10;
|
|
159
|
-
function sessionRefLabel(sessionId, title) {
|
|
160
|
-
const line = title === void 0 ? void 0 : excerptLine(title, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
161
|
-
return line === void 0 ? sessionId : `${line} (${sessionId})`;
|
|
162
|
-
}
|
|
163
165
|
function candidateLabel(candidate) {
|
|
164
166
|
return sessionRefLabel(candidate.sessionId, candidate.title);
|
|
165
167
|
}
|
|
@@ -184,7 +186,7 @@ function sessionLabel(view) {
|
|
|
184
186
|
function sessionStateLabel(view) {
|
|
185
187
|
const state = view.archived ? view.running ? "archived (running)" : "archived" : view.running ? "running" : view.live ? "idle" : "cold";
|
|
186
188
|
const parts = [state];
|
|
187
|
-
if (
|
|
189
|
+
if ((view.pendingInputs ?? 0) > 0) parts.push(`${view.pendingInputs} queued`);
|
|
188
190
|
if (view.lastTurn !== void 0) {
|
|
189
191
|
const outcome = view.lastTransition === void 0 ? "" : ` ${transitionLabel(view.lastTransition)}`;
|
|
190
192
|
parts.push(`last turn ${view.lastTurn}${outcome}`);
|
|
@@ -214,10 +216,7 @@ function archivedOccupantLines(snapshot) {
|
|
|
214
216
|
if (snapshot.archivedOccupants.length === 0) return [];
|
|
215
217
|
return [
|
|
216
218
|
`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
|
-
})
|
|
219
|
+
...snapshot.archivedOccupants.map((occupant) => ` - ${sessionRefLabel(occupant.sessionId, occupant.title)} \u2014 unarchive and run /devlead off, or delete it`)
|
|
221
220
|
];
|
|
222
221
|
}
|
|
223
222
|
function reportLines(snapshot) {
|
|
@@ -420,6 +419,8 @@ function friendlyDevLeadError(error) {
|
|
|
420
419
|
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.`;
|
|
421
420
|
case "DEVLEAD_WORKSPACE_NOT_FOUND":
|
|
422
421
|
return `The Workspace could not be resolved: ${error.message}`;
|
|
422
|
+
case "DEVLEAD_WORKSPACE_AMBIGUOUS":
|
|
423
|
+
return `The Workspace reference is ambiguous: ${error.message}. Use one of the listed ids or paths instead.`;
|
|
423
424
|
case "DEVLEAD_DIRECTORY_MISSING":
|
|
424
425
|
return `The target directory is missing: ${error.message}`;
|
|
425
426
|
case "DEVLEAD_MODEL_UNAVAILABLE":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-command-devlead",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-rc.1",
|
|
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",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@deepseek-ai/dsh-commands": ">=0.2.2-rc.1 <0.3.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@yankeguo/dsh-devlead": "0.
|
|
24
|
-
"@yankeguo/dsh-devlead-protocol": "0.
|
|
23
|
+
"@yankeguo/dsh-devlead": "0.3.0-rc.1",
|
|
24
|
+
"@yankeguo/dsh-devlead-protocol": "0.3.0-rc.1"
|
|
25
25
|
},
|
|
26
26
|
"engines": {
|
|
27
27
|
"dsh": ">=0.2.2-rc.1 <0.3.0"
|