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