@yankeguo/dsh-devlead-protocol 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 +6 -5
- package/lib/client.js +21 -8
- package/lib/index.js +21 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,10 +25,11 @@ 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
|
|
29
|
-
`plugin:devlead/*` record types and their version (mode / watch / notification /
|
|
30
|
-
`DevLeadResetRecord` discards every earlier DevLead record of a Session and
|
|
31
|
-
projections from their empty state), the
|
|
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
|
|
32
33
|
(`kind`, `message`, `summary?`, sender/lead ids, turn; bounded message/summary), retention/excerpt/
|
|
33
34
|
instant constants, transition/report-kind vocabulary, `devLeadReportId`, `reportLine`,
|
|
34
35
|
`notificationLine` / `excerptLine` / `formatInstant`, the `DevLeadUseWorkspaceRequest` shape
|
|
@@ -44,6 +45,6 @@ carried by the required `DevLeadCreatedSession.isolation` field.
|
|
|
44
45
|
## 中文
|
|
45
46
|
|
|
46
47
|
`@yankeguo/dsh-devlead-protocol` 是 DevLead 套件的纯协议包:host 与浏览器共用的类型、常量、
|
|
47
|
-
projection
|
|
48
|
+
projection 键(`devLead` / `devLeadMode` / `devLeadWatch`)、`plugin:devlead/*` 持久记录类型(mode / watch / notification / report / reset)与格式化
|
|
48
49
|
函数,以及 `DevLeadUseWorkspaceRequest`、必填的 `DevLeadCreatedSession.isolation` 等请求/结果
|
|
49
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
|
@@ -9,6 +9,7 @@ var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
|
|
|
9
9
|
var DEVLEAD_RECORD_VERSION = 1;
|
|
10
10
|
var DEVLEAD_PROJECTION_KEY = "devLead";
|
|
11
11
|
var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
|
|
12
|
+
var DEVLEAD_WATCH_PROJECTION_KEY = "devLeadWatch";
|
|
12
13
|
var DEVLEAD_COMMAND_NAME = "devlead";
|
|
13
14
|
var DEVLEAD_MESSAGE_KIND = "devlead";
|
|
14
15
|
var DEVLEAD_TOOL_PREFIX = "devlead_";
|
|
@@ -20,7 +21,13 @@ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
|
|
|
20
21
|
var DEVLEAD_REPORT_MAX_PER_TURN = 4;
|
|
21
22
|
var DEVLEAD_REPORT_RETENTION = 64;
|
|
22
23
|
var DEVLEAD_MAX_INSTANT = 864e13;
|
|
23
|
-
var DEVLEAD_REPORT_KINDS = [
|
|
24
|
+
var DEVLEAD_REPORT_KINDS = [
|
|
25
|
+
"progress",
|
|
26
|
+
"blocked",
|
|
27
|
+
"decision",
|
|
28
|
+
"question",
|
|
29
|
+
"fyi"
|
|
30
|
+
];
|
|
24
31
|
|
|
25
32
|
// packages/protocol/src/format.ts
|
|
26
33
|
var DEVLEAD_TRANSITIONS = [
|
|
@@ -61,12 +68,15 @@ function transitionLabel(transition) {
|
|
|
61
68
|
return TRANSITION_LABELS[transition];
|
|
62
69
|
}
|
|
63
70
|
function presentLine(value) {
|
|
64
|
-
if (value
|
|
71
|
+
if (typeof value !== "string") return void 0;
|
|
65
72
|
return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
66
73
|
}
|
|
74
|
+
function sessionRefLabel(sessionId, title) {
|
|
75
|
+
const line = presentLine(title);
|
|
76
|
+
return line === void 0 ? sessionId : `${line} (${sessionId})`;
|
|
77
|
+
}
|
|
67
78
|
function notificationLine(notification) {
|
|
68
|
-
const
|
|
69
|
-
const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
|
|
79
|
+
const who = sessionRefLabel(notification.sessionId, notification.sessionTitle);
|
|
70
80
|
const error = presentLine(notification.error);
|
|
71
81
|
const detail = error ?? presentLine(notification.summary);
|
|
72
82
|
const suffix = detail === void 0 ? "" : `: ${detail}`;
|
|
@@ -82,6 +92,7 @@ var REPORT_KIND_LABELS = {
|
|
|
82
92
|
progress: "progress",
|
|
83
93
|
blocked: "blocked",
|
|
84
94
|
decision: "decision needed",
|
|
95
|
+
question: "question",
|
|
85
96
|
fyi: "fyi"
|
|
86
97
|
};
|
|
87
98
|
function isDevLeadReportKind(value) {
|
|
@@ -96,11 +107,11 @@ function devLeadReportId(senderSessionId, turn, kind, message) {
|
|
|
96
107
|
return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
|
|
97
108
|
}
|
|
98
109
|
function reportLine(report) {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const detail = presentLine(report.summary) ?? excerptLine(report.message, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
110
|
+
const who = sessionRefLabel(report.senderSessionId, report.senderSessionTitle);
|
|
111
|
+
const detail = presentLine(report.summary) ?? presentLine(report.message);
|
|
102
112
|
const suffix = detail === void 0 ? "" : `: ${detail}`;
|
|
103
|
-
|
|
113
|
+
const kind = REPORT_KIND_LABELS[report.kind] ?? String(report.kind);
|
|
114
|
+
return `${who} \u2014 report ${kind}${suffix}`;
|
|
104
115
|
}
|
|
105
116
|
function reportDigest(reports) {
|
|
106
117
|
return reports.map(reportLine);
|
|
@@ -126,6 +137,7 @@ export {
|
|
|
126
137
|
DEVLEAD_RESET_RECORD_TYPE,
|
|
127
138
|
DEVLEAD_TOOL_PREFIX,
|
|
128
139
|
DEVLEAD_TRANSITIONS,
|
|
140
|
+
DEVLEAD_WATCH_PROJECTION_KEY,
|
|
129
141
|
DEVLEAD_WATCH_RECORD_TYPE,
|
|
130
142
|
devLeadReportId,
|
|
131
143
|
excerptLine,
|
|
@@ -137,5 +149,6 @@ export {
|
|
|
137
149
|
notificationLine,
|
|
138
150
|
reportDigest,
|
|
139
151
|
reportLine,
|
|
152
|
+
sessionRefLabel,
|
|
140
153
|
transitionLabel
|
|
141
154
|
};
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var DEVLEAD_RESET_RECORD_TYPE = "plugin:devlead/reset";
|
|
|
9
9
|
var DEVLEAD_RECORD_VERSION = 1;
|
|
10
10
|
var DEVLEAD_PROJECTION_KEY = "devLead";
|
|
11
11
|
var DEVLEAD_MODE_PROJECTION_KEY = "devLeadMode";
|
|
12
|
+
var DEVLEAD_WATCH_PROJECTION_KEY = "devLeadWatch";
|
|
12
13
|
var DEVLEAD_COMMAND_NAME = "devlead";
|
|
13
14
|
var DEVLEAD_MESSAGE_KIND = "devlead";
|
|
14
15
|
var DEVLEAD_TOOL_PREFIX = "devlead_";
|
|
@@ -20,7 +21,13 @@ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
|
|
|
20
21
|
var DEVLEAD_REPORT_MAX_PER_TURN = 4;
|
|
21
22
|
var DEVLEAD_REPORT_RETENTION = 64;
|
|
22
23
|
var DEVLEAD_MAX_INSTANT = 864e13;
|
|
23
|
-
var DEVLEAD_REPORT_KINDS = [
|
|
24
|
+
var DEVLEAD_REPORT_KINDS = [
|
|
25
|
+
"progress",
|
|
26
|
+
"blocked",
|
|
27
|
+
"decision",
|
|
28
|
+
"question",
|
|
29
|
+
"fyi"
|
|
30
|
+
];
|
|
24
31
|
|
|
25
32
|
// packages/protocol/src/format.ts
|
|
26
33
|
var DEVLEAD_TRANSITIONS = [
|
|
@@ -61,12 +68,15 @@ function transitionLabel(transition) {
|
|
|
61
68
|
return TRANSITION_LABELS[transition];
|
|
62
69
|
}
|
|
63
70
|
function presentLine(value) {
|
|
64
|
-
if (value
|
|
71
|
+
if (typeof value !== "string") return void 0;
|
|
65
72
|
return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
66
73
|
}
|
|
74
|
+
function sessionRefLabel(sessionId, title) {
|
|
75
|
+
const line = presentLine(title);
|
|
76
|
+
return line === void 0 ? sessionId : `${line} (${sessionId})`;
|
|
77
|
+
}
|
|
67
78
|
function notificationLine(notification) {
|
|
68
|
-
const
|
|
69
|
-
const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
|
|
79
|
+
const who = sessionRefLabel(notification.sessionId, notification.sessionTitle);
|
|
70
80
|
const error = presentLine(notification.error);
|
|
71
81
|
const detail = error ?? presentLine(notification.summary);
|
|
72
82
|
const suffix = detail === void 0 ? "" : `: ${detail}`;
|
|
@@ -82,6 +92,7 @@ var REPORT_KIND_LABELS = {
|
|
|
82
92
|
progress: "progress",
|
|
83
93
|
blocked: "blocked",
|
|
84
94
|
decision: "decision needed",
|
|
95
|
+
question: "question",
|
|
85
96
|
fyi: "fyi"
|
|
86
97
|
};
|
|
87
98
|
function isDevLeadReportKind(value) {
|
|
@@ -96,11 +107,11 @@ function devLeadReportId(senderSessionId, turn, kind, message) {
|
|
|
96
107
|
return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
|
|
97
108
|
}
|
|
98
109
|
function reportLine(report) {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const detail = presentLine(report.summary) ?? excerptLine(report.message, DEVLEAD_ERROR_EXCERPT_MAX);
|
|
110
|
+
const who = sessionRefLabel(report.senderSessionId, report.senderSessionTitle);
|
|
111
|
+
const detail = presentLine(report.summary) ?? presentLine(report.message);
|
|
102
112
|
const suffix = detail === void 0 ? "" : `: ${detail}`;
|
|
103
|
-
|
|
113
|
+
const kind = REPORT_KIND_LABELS[report.kind] ?? String(report.kind);
|
|
114
|
+
return `${who} \u2014 report ${kind}${suffix}`;
|
|
104
115
|
}
|
|
105
116
|
function reportDigest(reports) {
|
|
106
117
|
return reports.map(reportLine);
|
|
@@ -126,6 +137,7 @@ export {
|
|
|
126
137
|
DEVLEAD_RESET_RECORD_TYPE,
|
|
127
138
|
DEVLEAD_TOOL_PREFIX,
|
|
128
139
|
DEVLEAD_TRANSITIONS,
|
|
140
|
+
DEVLEAD_WATCH_PROJECTION_KEY,
|
|
129
141
|
DEVLEAD_WATCH_RECORD_TYPE,
|
|
130
142
|
devLeadReportId,
|
|
131
143
|
excerptLine,
|
|
@@ -137,5 +149,6 @@ export {
|
|
|
137
149
|
notificationLine,
|
|
138
150
|
reportDigest,
|
|
139
151
|
reportLine,
|
|
152
|
+
sessionRefLabel,
|
|
140
153
|
transitionLabel
|
|
141
154
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yankeguo/dsh-devlead-protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-rc.1",
|
|
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",
|