@yankeguo/dsh-devlead-protocol 0.2.4 → 0.2.6

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
@@ -25,10 +25,13 @@ Only install this package directly when you are composing the suite yourself.
25
25
  | `@yankeguo/dsh-devlead-protocol/client` | Browser-safe constants, types, and pure formatting helpers |
26
26
  | `@yankeguo/dsh-devlead-protocol/package.json` | Package manifest |
27
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,
28
+ The public contract includes the `devLead` / `devLeadMode` / `devLeadWatch` projection keys and
29
+ types, durable `plugin:devlead/*` record types and their version (mode / watch / notification /
30
+ **report** / **reset**; `DevLeadResetRecord` discards every earlier DevLead record of a Session and
31
+ restarts all three projections from their empty state), the summary-sized `DevLeadWatchProjection`
32
+ (`{ sessions }`, used by the sidebar to mark watched rows), the watched-child `DevLeadReport` receipt
33
+ (`kind`, `message`, `summary?`, sender/lead ids, turn; bounded message/summary), retention/excerpt/
34
+ instant constants, transition/report-kind vocabulary, `devLeadReportId`, `reportLine`,
32
35
  `notificationLine` / `excerptLine` / `formatInstant`, the `DevLeadUseWorkspaceRequest` shape
33
36
  (`{ path, title?, create? }`, `create` defaults to `false`), and the `DevLeadIsolation` outcome
34
37
  carried by the required `DevLeadCreatedSession.isolation` field.
@@ -42,6 +45,6 @@ carried by the required `DevLeadCreatedSession.isolation` field.
42
45
  ## 中文
43
46
 
44
47
  `@yankeguo/dsh-devlead-protocol` 是 DevLead 套件的纯协议包:host 与浏览器共用的类型、常量、
45
- projection 键、`plugin:devlead/*` 持久记录类型(mode / watch / notification / reset)与格式化
48
+ projection 键(`devLead` / `devLeadMode` / `devLeadWatch`)、`plugin:devlead/*` 持久记录类型(mode / watch / notification / report / reset)与格式化
46
49
  函数,以及 `DevLeadUseWorkspaceRequest`、必填的 `DevLeadCreatedSession.isolation` 等请求/结果
47
50
  形状。它没有运行时 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,17 +4,24 @@
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_REPORT_RECORD_TYPE = "plugin:devlead/report";
7
8
  var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
8
9
  var DEVLEAD_RECORD_VERSION = 1;
9
10
  var DEVLEAD_PROJECTION_KEY = "devLead";
10
11
  var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
12
+ var DEVLEAD_WATCH_PROJECTION_KEY = "devLeadWatch";
11
13
  var DEVLEAD_COMMAND_NAME = "devlead";
12
14
  var DEVLEAD_MESSAGE_KIND = "devlead";
13
15
  var DEVLEAD_TOOL_PREFIX = "devlead_";
14
16
  var DEVLEAD_DEFAULT_MAX_WATCHED = 64;
15
17
  var DEVLEAD_DEFAULT_NOTIFICATION_RETENTION = 64;
16
18
  var DEVLEAD_ERROR_EXCERPT_MAX = 240;
19
+ var DEVLEAD_REPORT_MESSAGE_MAX = 4e3;
20
+ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
21
+ var DEVLEAD_REPORT_MAX_PER_TURN = 4;
22
+ var DEVLEAD_REPORT_RETENTION = 64;
17
23
  var DEVLEAD_MAX_INSTANT = 864e13;
24
+ var DEVLEAD_REPORT_KINDS = ["progress", "blocked", "decision", "fyi"];
18
25
 
19
26
  // packages/protocol/src/format.ts
20
27
  var DEVLEAD_TRANSITIONS = [
@@ -72,6 +79,33 @@ function notificationDigest(notifications) {
72
79
  function formatInstant(at) {
73
80
  return new Date(at).toISOString().replace(/\.\d{3}Z$/u, "Z");
74
81
  }
82
+ var REPORT_KIND_LABELS = {
83
+ progress: "progress",
84
+ blocked: "blocked",
85
+ decision: "decision needed",
86
+ fyi: "fyi"
87
+ };
88
+ function isDevLeadReportKind(value) {
89
+ return typeof value === "string" && DEVLEAD_REPORT_KINDS.includes(value);
90
+ }
91
+ function devLeadReportId(senderSessionId, turn, kind, message) {
92
+ let hash = 2166136261;
93
+ for (const character of `${kind}\0${message}`) {
94
+ hash ^= character.codePointAt(0) ?? 0;
95
+ hash = Math.imul(hash, 16777619);
96
+ }
97
+ return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
98
+ }
99
+ function reportLine(report) {
100
+ const title = presentLine(report.senderSessionTitle);
101
+ const who = title === void 0 ? report.senderSessionId : `${title} (${report.senderSessionId})`;
102
+ const detail = presentLine(report.summary) ?? excerptLine(report.message, DEVLEAD_ERROR_EXCERPT_MAX);
103
+ const suffix = detail === void 0 ? "" : `: ${detail}`;
104
+ return `${who} \u2014 report ${REPORT_KIND_LABELS[report.kind]}${suffix}`;
105
+ }
106
+ function reportDigest(reports) {
107
+ return reports.map(reportLine);
108
+ }
75
109
  export {
76
110
  DEVLEAD_COMMAND_NAME,
77
111
  DEVLEAD_DEFAULT_MAX_WATCHED,
@@ -84,15 +118,26 @@ export {
84
118
  DEVLEAD_NOTIFICATION_RECORD_TYPE,
85
119
  DEVLEAD_PROJECTION_KEY,
86
120
  DEVLEAD_RECORD_VERSION,
121
+ DEVLEAD_REPORT_KINDS,
122
+ DEVLEAD_REPORT_MAX_PER_TURN,
123
+ DEVLEAD_REPORT_MESSAGE_MAX,
124
+ DEVLEAD_REPORT_RECORD_TYPE,
125
+ DEVLEAD_REPORT_RETENTION,
126
+ DEVLEAD_REPORT_SUMMARY_MAX,
87
127
  DEVLEAD_RESET_RECORD_TYPE,
88
128
  DEVLEAD_TOOL_PREFIX,
89
129
  DEVLEAD_TRANSITIONS,
130
+ DEVLEAD_WATCH_PROJECTION_KEY,
90
131
  DEVLEAD_WATCH_RECORD_TYPE,
132
+ devLeadReportId,
91
133
  excerptLine,
92
134
  formatInstant,
135
+ isDevLeadReportKind,
93
136
  isDevLeadTransition,
94
137
  notificationDigest,
95
138
  notificationId,
96
139
  notificationLine,
140
+ reportDigest,
141
+ reportLine,
97
142
  transitionLabel
98
143
  };
package/lib/index.js CHANGED
@@ -4,17 +4,24 @@
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_REPORT_RECORD_TYPE = "plugin:devlead/report";
7
8
  var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
8
9
  var DEVLEAD_RECORD_VERSION = 1;
9
10
  var DEVLEAD_PROJECTION_KEY = "devLead";
10
11
  var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
12
+ var DEVLEAD_WATCH_PROJECTION_KEY = "devLeadWatch";
11
13
  var DEVLEAD_COMMAND_NAME = "devlead";
12
14
  var DEVLEAD_MESSAGE_KIND = "devlead";
13
15
  var DEVLEAD_TOOL_PREFIX = "devlead_";
14
16
  var DEVLEAD_DEFAULT_MAX_WATCHED = 64;
15
17
  var DEVLEAD_DEFAULT_NOTIFICATION_RETENTION = 64;
16
18
  var DEVLEAD_ERROR_EXCERPT_MAX = 240;
19
+ var DEVLEAD_REPORT_MESSAGE_MAX = 4e3;
20
+ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
21
+ var DEVLEAD_REPORT_MAX_PER_TURN = 4;
22
+ var DEVLEAD_REPORT_RETENTION = 64;
17
23
  var DEVLEAD_MAX_INSTANT = 864e13;
24
+ var DEVLEAD_REPORT_KINDS = ["progress", "blocked", "decision", "fyi"];
18
25
 
19
26
  // packages/protocol/src/format.ts
20
27
  var DEVLEAD_TRANSITIONS = [
@@ -72,6 +79,33 @@ function notificationDigest(notifications) {
72
79
  function formatInstant(at) {
73
80
  return new Date(at).toISOString().replace(/\.\d{3}Z$/u, "Z");
74
81
  }
82
+ var REPORT_KIND_LABELS = {
83
+ progress: "progress",
84
+ blocked: "blocked",
85
+ decision: "decision needed",
86
+ fyi: "fyi"
87
+ };
88
+ function isDevLeadReportKind(value) {
89
+ return typeof value === "string" && DEVLEAD_REPORT_KINDS.includes(value);
90
+ }
91
+ function devLeadReportId(senderSessionId, turn, kind, message) {
92
+ let hash = 2166136261;
93
+ for (const character of `${kind}\0${message}`) {
94
+ hash ^= character.codePointAt(0) ?? 0;
95
+ hash = Math.imul(hash, 16777619);
96
+ }
97
+ return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
98
+ }
99
+ function reportLine(report) {
100
+ const title = presentLine(report.senderSessionTitle);
101
+ const who = title === void 0 ? report.senderSessionId : `${title} (${report.senderSessionId})`;
102
+ const detail = presentLine(report.summary) ?? excerptLine(report.message, DEVLEAD_ERROR_EXCERPT_MAX);
103
+ const suffix = detail === void 0 ? "" : `: ${detail}`;
104
+ return `${who} \u2014 report ${REPORT_KIND_LABELS[report.kind]}${suffix}`;
105
+ }
106
+ function reportDigest(reports) {
107
+ return reports.map(reportLine);
108
+ }
75
109
  export {
76
110
  DEVLEAD_COMMAND_NAME,
77
111
  DEVLEAD_DEFAULT_MAX_WATCHED,
@@ -84,15 +118,26 @@ export {
84
118
  DEVLEAD_NOTIFICATION_RECORD_TYPE,
85
119
  DEVLEAD_PROJECTION_KEY,
86
120
  DEVLEAD_RECORD_VERSION,
121
+ DEVLEAD_REPORT_KINDS,
122
+ DEVLEAD_REPORT_MAX_PER_TURN,
123
+ DEVLEAD_REPORT_MESSAGE_MAX,
124
+ DEVLEAD_REPORT_RECORD_TYPE,
125
+ DEVLEAD_REPORT_RETENTION,
126
+ DEVLEAD_REPORT_SUMMARY_MAX,
87
127
  DEVLEAD_RESET_RECORD_TYPE,
88
128
  DEVLEAD_TOOL_PREFIX,
89
129
  DEVLEAD_TRANSITIONS,
130
+ DEVLEAD_WATCH_PROJECTION_KEY,
90
131
  DEVLEAD_WATCH_RECORD_TYPE,
132
+ devLeadReportId,
91
133
  excerptLine,
92
134
  formatInstant,
135
+ isDevLeadReportKind,
93
136
  isDevLeadTransition,
94
137
  notificationDigest,
95
138
  notificationId,
96
139
  notificationLine,
140
+ reportDigest,
141
+ reportLine,
97
142
  transitionLabel
98
143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-devlead-protocol",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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",