@yankeguo/dsh-devlead-protocol 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 ADDED
@@ -0,0 +1,47 @@
1
+ # @yankeguo/dsh-devlead-protocol
2
+
3
+ Pure shared protocol for the DevLead plugin suite: durable record payloads, Session projection
4
+ types, formatting helpers, and the constants both the Host and the browser bundle use.
5
+
6
+ This package has **no runtime dependency** on any DSH package. Its single DSH import is a
7
+ type-only projection-map augmentation; it is erased at build time. Installing it alone does not
8
+ enable DevLead — install the bundle (below) to get the host service, tools, command, and UI.
9
+
10
+ ## Install
11
+
12
+ Normally installed as part of the main bundle:
13
+
14
+ ```sh
15
+ dsh plugin --profile desktop add @yankeguo/dsh-devlead-bundle
16
+ ```
17
+
18
+ Only install this package directly when you are composing the suite yourself.
19
+
20
+ ## Exports
21
+
22
+ | Export | Contents |
23
+ | --- | --- |
24
+ | `@yankeguo/dsh-devlead-protocol` | Host entry; re-exports the client-safe surface |
25
+ | `@yankeguo/dsh-devlead-protocol/client` | Browser-safe constants, types, and pure formatting helpers |
26
+ | `@yankeguo/dsh-devlead-protocol/package.json` | Package manifest |
27
+
28
+ The public contract includes the `devLead` / `devLeadMode` projection keys and types, durable
29
+ `plugin:devlead/*` record types and their version (mode / watch / notification / **reset**;
30
+ `DevLeadResetRecord` discards every earlier DevLead record of a Session and restarts both
31
+ projections from their empty state), retention/excerpt/instant constants, transition vocabulary,
32
+ `notificationLine` / `excerptLine` / `formatInstant`, the `DevLeadUseWorkspaceRequest` shape
33
+ (`{ path, title?, create? }`, `create` defaults to `false`), and the `DevLeadIsolation` outcome
34
+ carried by the required `DevLeadCreatedSession.isolation` field.
35
+
36
+ ## Related docs
37
+
38
+ - [Repository README (English)](https://github.com/yankeguo/dsh-devlead/blob/main/README.md) / [中文](https://github.com/yankeguo/dsh-devlead/blob/main/README.zh.md)
39
+ - [Design notes](https://github.com/yankeguo/dsh-devlead/blob/main/docs/DESIGN.md)
40
+ - [Optional-dependency audit](https://github.com/yankeguo/dsh-devlead/blob/main/docs/OPTIONAL-DEPENDENCIES.md)
41
+
42
+ ## 中文
43
+
44
+ `@yankeguo/dsh-devlead-protocol` 是 DevLead 套件的纯协议包:host 与浏览器共用的类型、常量、
45
+ projection 键、`plugin:devlead/*` 持久记录类型(mode / watch / notification / reset)与格式化
46
+ 函数,以及 `DevLeadUseWorkspaceRequest`、必填的 `DevLeadCreatedSession.isolation` 等请求/结果
47
+ 形状。它没有运行时 DSH 依赖,通常随 bundle 安装。完整中文文档见[根 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/client.js CHANGED
@@ -4,14 +4,17 @@
4
4
  var DEVLEAD_MODE_RECORD_TYPE = "plugin:devlead/mode";
5
5
  var DEVLEAD_WATCH_RECORD_TYPE = "plugin:devlead/watch";
6
6
  var DEVLEAD_NOTIFICATION_RECORD_TYPE = "plugin:devlead/notification";
7
+ var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
7
8
  var DEVLEAD_RECORD_VERSION = 1;
8
9
  var DEVLEAD_PROJECTION_KEY = "devLead";
10
+ var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
9
11
  var DEVLEAD_COMMAND_NAME = "devlead";
10
12
  var DEVLEAD_MESSAGE_KIND = "devlead";
11
13
  var DEVLEAD_TOOL_PREFIX = "devlead_";
12
14
  var DEVLEAD_DEFAULT_MAX_WATCHED = 64;
13
15
  var DEVLEAD_DEFAULT_NOTIFICATION_RETENTION = 64;
14
16
  var DEVLEAD_ERROR_EXCERPT_MAX = 240;
17
+ var DEVLEAD_MAX_INSTANT = 864e13;
15
18
 
16
19
  // packages/protocol/src/format.ts
17
20
  var DEVLEAD_TRANSITIONS = [
@@ -23,8 +26,9 @@ var DEVLEAD_TRANSITIONS = [
23
26
  "interrupted",
24
27
  "forked"
25
28
  ];
29
+ var TRANSITION_SET = new Set(DEVLEAD_TRANSITIONS);
26
30
  function isDevLeadTransition(value) {
27
- return typeof value === "string" && DEVLEAD_TRANSITIONS.includes(value);
31
+ return typeof value === "string" && TRANSITION_SET.has(value);
28
32
  }
29
33
  function notificationId(sessionId, turn, transition) {
30
34
  return `${sessionId}:${turn}:${transition}`;
@@ -32,8 +36,11 @@ function notificationId(sessionId, turn, transition) {
32
36
  function excerptLine(text, max) {
33
37
  const collapsed = text.replace(/\s+/gu, " ").trim();
34
38
  if (collapsed.length === 0) return void 0;
35
- if (collapsed.length <= max) return collapsed;
36
- return `${collapsed.slice(0, Math.max(0, max - 1))}\u2026`;
39
+ const budget = Number.isFinite(max) ? Math.floor(max) : Number.POSITIVE_INFINITY;
40
+ if (budget < 1) return void 0;
41
+ const points = Array.from(collapsed);
42
+ if (points.length <= budget) return collapsed;
43
+ return `${points.slice(0, budget - 1).join("")}\u2026`;
37
44
  }
38
45
  var TRANSITION_LABELS = {
39
46
  completed: "completed",
@@ -47,11 +54,17 @@ var TRANSITION_LABELS = {
47
54
  function transitionLabel(transition) {
48
55
  return TRANSITION_LABELS[transition];
49
56
  }
57
+ function presentLine(value) {
58
+ if (value === void 0) return void 0;
59
+ return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
60
+ }
50
61
  function notificationLine(notification) {
51
- const who = notification.sessionTitle === void 0 ? notification.sessionId : `${notification.sessionTitle} (${notification.sessionId})`;
52
- const error = notification.error === void 0 ? "" : `: ${notification.error}`;
53
- const summary = notification.error === void 0 && notification.summary !== void 0 ? `: ${notification.summary}` : "";
54
- return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${error}${summary}`;
62
+ const title = presentLine(notification.sessionTitle);
63
+ const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
64
+ const error = presentLine(notification.error);
65
+ const detail = error ?? presentLine(notification.summary);
66
+ const suffix = detail === void 0 ? "" : `: ${detail}`;
67
+ return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${suffix}`;
55
68
  }
56
69
  function notificationDigest(notifications) {
57
70
  return notifications.map(notificationLine);
@@ -64,11 +77,14 @@ export {
64
77
  DEVLEAD_DEFAULT_MAX_WATCHED,
65
78
  DEVLEAD_DEFAULT_NOTIFICATION_RETENTION,
66
79
  DEVLEAD_ERROR_EXCERPT_MAX,
80
+ DEVLEAD_MAX_INSTANT,
67
81
  DEVLEAD_MESSAGE_KIND,
82
+ DEVLEAD_MODE_PROJECTION_KEY,
68
83
  DEVLEAD_MODE_RECORD_TYPE,
69
84
  DEVLEAD_NOTIFICATION_RECORD_TYPE,
70
85
  DEVLEAD_PROJECTION_KEY,
71
86
  DEVLEAD_RECORD_VERSION,
87
+ DEVLEAD_RESET_RECORD_TYPE,
72
88
  DEVLEAD_TOOL_PREFIX,
73
89
  DEVLEAD_TRANSITIONS,
74
90
  DEVLEAD_WATCH_RECORD_TYPE,
package/lib/index.js CHANGED
@@ -4,14 +4,17 @@
4
4
  var DEVLEAD_MODE_RECORD_TYPE = "plugin:devlead/mode";
5
5
  var DEVLEAD_WATCH_RECORD_TYPE = "plugin:devlead/watch";
6
6
  var DEVLEAD_NOTIFICATION_RECORD_TYPE = "plugin:devlead/notification";
7
+ var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
7
8
  var DEVLEAD_RECORD_VERSION = 1;
8
9
  var DEVLEAD_PROJECTION_KEY = "devLead";
10
+ var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
9
11
  var DEVLEAD_COMMAND_NAME = "devlead";
10
12
  var DEVLEAD_MESSAGE_KIND = "devlead";
11
13
  var DEVLEAD_TOOL_PREFIX = "devlead_";
12
14
  var DEVLEAD_DEFAULT_MAX_WATCHED = 64;
13
15
  var DEVLEAD_DEFAULT_NOTIFICATION_RETENTION = 64;
14
16
  var DEVLEAD_ERROR_EXCERPT_MAX = 240;
17
+ var DEVLEAD_MAX_INSTANT = 864e13;
15
18
 
16
19
  // packages/protocol/src/format.ts
17
20
  var DEVLEAD_TRANSITIONS = [
@@ -23,8 +26,9 @@ var DEVLEAD_TRANSITIONS = [
23
26
  "interrupted",
24
27
  "forked"
25
28
  ];
29
+ var TRANSITION_SET = new Set(DEVLEAD_TRANSITIONS);
26
30
  function isDevLeadTransition(value) {
27
- return typeof value === "string" && DEVLEAD_TRANSITIONS.includes(value);
31
+ return typeof value === "string" && TRANSITION_SET.has(value);
28
32
  }
29
33
  function notificationId(sessionId, turn, transition) {
30
34
  return `${sessionId}:${turn}:${transition}`;
@@ -32,8 +36,11 @@ function notificationId(sessionId, turn, transition) {
32
36
  function excerptLine(text, max) {
33
37
  const collapsed = text.replace(/\s+/gu, " ").trim();
34
38
  if (collapsed.length === 0) return void 0;
35
- if (collapsed.length <= max) return collapsed;
36
- return `${collapsed.slice(0, Math.max(0, max - 1))}\u2026`;
39
+ const budget = Number.isFinite(max) ? Math.floor(max) : Number.POSITIVE_INFINITY;
40
+ if (budget < 1) return void 0;
41
+ const points = Array.from(collapsed);
42
+ if (points.length <= budget) return collapsed;
43
+ return `${points.slice(0, budget - 1).join("")}\u2026`;
37
44
  }
38
45
  var TRANSITION_LABELS = {
39
46
  completed: "completed",
@@ -47,11 +54,17 @@ var TRANSITION_LABELS = {
47
54
  function transitionLabel(transition) {
48
55
  return TRANSITION_LABELS[transition];
49
56
  }
57
+ function presentLine(value) {
58
+ if (value === void 0) return void 0;
59
+ return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
60
+ }
50
61
  function notificationLine(notification) {
51
- const who = notification.sessionTitle === void 0 ? notification.sessionId : `${notification.sessionTitle} (${notification.sessionId})`;
52
- const error = notification.error === void 0 ? "" : `: ${notification.error}`;
53
- const summary = notification.error === void 0 && notification.summary !== void 0 ? `: ${notification.summary}` : "";
54
- return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${error}${summary}`;
62
+ const title = presentLine(notification.sessionTitle);
63
+ const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
64
+ const error = presentLine(notification.error);
65
+ const detail = error ?? presentLine(notification.summary);
66
+ const suffix = detail === void 0 ? "" : `: ${detail}`;
67
+ return `${who} \u2014 turn ${notification.turn} ${transitionLabel(notification.transition)}${suffix}`;
55
68
  }
56
69
  function notificationDigest(notifications) {
57
70
  return notifications.map(notificationLine);
@@ -64,11 +77,14 @@ export {
64
77
  DEVLEAD_DEFAULT_MAX_WATCHED,
65
78
  DEVLEAD_DEFAULT_NOTIFICATION_RETENTION,
66
79
  DEVLEAD_ERROR_EXCERPT_MAX,
80
+ DEVLEAD_MAX_INSTANT,
67
81
  DEVLEAD_MESSAGE_KIND,
82
+ DEVLEAD_MODE_PROJECTION_KEY,
68
83
  DEVLEAD_MODE_RECORD_TYPE,
69
84
  DEVLEAD_NOTIFICATION_RECORD_TYPE,
70
85
  DEVLEAD_PROJECTION_KEY,
71
86
  DEVLEAD_RECORD_VERSION,
87
+ DEVLEAD_RESET_RECORD_TYPE,
72
88
  DEVLEAD_TOOL_PREFIX,
73
89
  DEVLEAD_TRANSITIONS,
74
90
  DEVLEAD_WATCH_RECORD_TYPE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-devlead-protocol",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Pure shared protocol of the devlead plugin suite: durable mode, watched-session and notification types, plus the pure fold and formatting rules used by both Host and browser.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,7 +12,8 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "files": [
15
- "lib"
15
+ "lib",
16
+ "README.md"
16
17
  ],
17
18
  "engines": {
18
19
  "dsh": ">=0.2.2-rc.1 <0.3.0"