@yankeguo/dsh-command-devlead 0.2.5 → 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/README.md CHANGED
@@ -29,7 +29,7 @@ derived from a post-mutation snapshot, so a concurrent command cannot leave the
29
29
  different state than the rendered body.
30
30
 
31
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
32
+ sender, kind, and summary/message; report errors (not-watched / `DEVLEAD_NOT_SUPERVISED`, rate-limited, invalid fields) are
33
33
  rendered as friendly command text. A report is not sent by the command itself; watched Sessions
34
34
  use the `devlead_report` tool.
35
35
 
@@ -41,7 +41,7 @@ second enabled lead is not left behind.
41
41
 
42
42
  `/devlead reset` appends a `plugin:devlead/reset` durable record: replay applies it before the
43
43
  corruption freeze check, so a Session whose earlier `plugin:devlead/*` record is corrupt becomes
44
- usable again (both projections restart from the default disabled state). `/devlead off` runs the
44
+ usable again (all three projections restart from the default disabled state). `/devlead off` runs the
45
45
  same recovery when the fold is frozen; `/devlead on` refuses and asks for the explicit reset.
46
46
 
47
47
  ## Install
@@ -64,12 +64,12 @@ DevLead 模式全局单活:第二个会话执行 `/devlead on` 会以 `DEVLEAD
64
64
  消息给出占用者并提示先在占用者上 `/devlead off`;关闭/重置立即释放,归档占用者在下一次
65
65
  准入/启动时可被释放。
66
66
  状态视图还会列出最近 5 条中途汇报(`Recent reports:`,含时间、sender、kind、summary/message);
67
- not-supervised / rate-limited / 参数错误都会转成友好命令文本。命令本身不发送汇报;被监督会话
67
+ not-watched(`DEVLEAD_NOT_SUPERVISED`)/ rate-limited / 参数错误都会转成友好命令文本。命令本身不发送汇报;已关注会话
68
68
  使用 `devlead_report` 工具。已归档 DevLead 占用者不再阻塞 `/devlead on`:准入把它视为非 active,
69
69
  mode-off 写不掉时记录 durable tombstone;`/devlead status` 的
70
70
  `Archived DevLead holders (ignored for admission)` 会列出它并提示 unarchive + `/devlead off`
71
71
  或删除,打开后 reconciliation 会消除双活。
72
72
  0.2.0 起 `/devlead reset`(以及冻结时 `/devlead off`)追加 `plugin:devlead/reset` 记录并解冻
73
- 损坏的 fold;reset 会丢弃该会话的 watch 集合与通知 digest。命令按 DSH `rawInput` 契约解析,
73
+ 损坏的 fold;reset 会丢弃该会话的关注集合与通知 digest。命令按 DSH `rawInput` 契约解析,
74
74
  不接受附件,前缀引用在变更前由 core 穷尽验证,变更后的标题与正文来自同一 post-mutation 快照。完整中文文档见
75
75
  [根 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
@@ -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
- if (isClosingQuote(raw[raw.length - 1] ?? "")) {
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
- DEVLEAD_ERROR_EXCERPT_MAX,
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 matches = candidates.filter((candidate) => candidate.sessionId.startsWith(reference));
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 (view.running && (view.pendingInputs ?? 0) > 0) parts.push(`${view.pendingInputs} queued`);
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/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "DevLead 命令",
4
- "description": "面向人类的 /devlead 命令:开启或关闭 DevLead 模式、监督或取消监督会话、重置损坏状态,并显示状态视图。"
4
+ "description": "面向人类的 /devlead 命令:开启或关闭 DevLead 模式、关注或取消关注会话、重置损坏状态,并显示状态视图。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-command-devlead",
3
- "version": "0.2.5",
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.2.5",
24
- "@yankeguo/dsh-devlead-protocol": "0.2.5"
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"