@yankeguo/dsh-devlead-protocol 0.2.6 → 0.3.0-rc.2

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/lib/client.js CHANGED
@@ -21,7 +21,13 @@ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
21
21
  var DEVLEAD_REPORT_MAX_PER_TURN = 4;
22
22
  var DEVLEAD_REPORT_RETENTION = 64;
23
23
  var DEVLEAD_MAX_INSTANT = 864e13;
24
- var DEVLEAD_REPORT_KINDS = ["progress", "blocked", "decision", "fyi"];
24
+ var DEVLEAD_REPORT_KINDS = [
25
+ "progress",
26
+ "blocked",
27
+ "decision",
28
+ "question",
29
+ "fyi"
30
+ ];
25
31
 
26
32
  // packages/protocol/src/format.ts
27
33
  var DEVLEAD_TRANSITIONS = [
@@ -41,7 +47,7 @@ function notificationId(sessionId, turn, transition) {
41
47
  return `${sessionId}:${turn}:${transition}`;
42
48
  }
43
49
  function excerptLine(text, max) {
44
- const collapsed = text.replace(/\s+/gu, " ").trim();
50
+ const collapsed = text.replace(/\s+/gu, " ").replace(/[\u0000-\u001f\u007f-\u009f]/gu, "").trim();
45
51
  if (collapsed.length === 0) return void 0;
46
52
  const budget = Number.isFinite(max) ? Math.floor(max) : Number.POSITIVE_INFINITY;
47
53
  if (budget < 1) return void 0;
@@ -62,12 +68,15 @@ function transitionLabel(transition) {
62
68
  return TRANSITION_LABELS[transition];
63
69
  }
64
70
  function presentLine(value) {
65
- if (value === void 0) return void 0;
71
+ if (typeof value !== "string") return void 0;
66
72
  return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
67
73
  }
74
+ function sessionRefLabel(sessionId, title) {
75
+ const line = presentLine(title);
76
+ return line === void 0 ? sessionId : `${line} (${sessionId})`;
77
+ }
68
78
  function notificationLine(notification) {
69
- const title = presentLine(notification.sessionTitle);
70
- const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
79
+ const who = sessionRefLabel(notification.sessionId, notification.sessionTitle);
71
80
  const error = presentLine(notification.error);
72
81
  const detail = error ?? presentLine(notification.summary);
73
82
  const suffix = detail === void 0 ? "" : `: ${detail}`;
@@ -83,6 +92,7 @@ var REPORT_KIND_LABELS = {
83
92
  progress: "progress",
84
93
  blocked: "blocked",
85
94
  decision: "decision needed",
95
+ question: "question",
86
96
  fyi: "fyi"
87
97
  };
88
98
  function isDevLeadReportKind(value) {
@@ -97,11 +107,11 @@ function devLeadReportId(senderSessionId, turn, kind, message) {
97
107
  return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
98
108
  }
99
109
  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);
110
+ const who = sessionRefLabel(report.senderSessionId, report.senderSessionTitle);
111
+ const detail = presentLine(report.summary) ?? presentLine(report.message);
103
112
  const suffix = detail === void 0 ? "" : `: ${detail}`;
104
- return `${who} \u2014 report ${REPORT_KIND_LABELS[report.kind]}${suffix}`;
113
+ const kind = REPORT_KIND_LABELS[report.kind] ?? String(report.kind);
114
+ return `${who} \u2014 report ${kind}${suffix}`;
105
115
  }
106
116
  function reportDigest(reports) {
107
117
  return reports.map(reportLine);
@@ -139,5 +149,6 @@ export {
139
149
  notificationLine,
140
150
  reportDigest,
141
151
  reportLine,
152
+ sessionRefLabel,
142
153
  transitionLabel
143
154
  };
package/lib/index.js CHANGED
@@ -21,7 +21,13 @@ var DEVLEAD_REPORT_SUMMARY_MAX = 200;
21
21
  var DEVLEAD_REPORT_MAX_PER_TURN = 4;
22
22
  var DEVLEAD_REPORT_RETENTION = 64;
23
23
  var DEVLEAD_MAX_INSTANT = 864e13;
24
- var DEVLEAD_REPORT_KINDS = ["progress", "blocked", "decision", "fyi"];
24
+ var DEVLEAD_REPORT_KINDS = [
25
+ "progress",
26
+ "blocked",
27
+ "decision",
28
+ "question",
29
+ "fyi"
30
+ ];
25
31
 
26
32
  // packages/protocol/src/format.ts
27
33
  var DEVLEAD_TRANSITIONS = [
@@ -41,7 +47,7 @@ function notificationId(sessionId, turn, transition) {
41
47
  return `${sessionId}:${turn}:${transition}`;
42
48
  }
43
49
  function excerptLine(text, max) {
44
- const collapsed = text.replace(/\s+/gu, " ").trim();
50
+ const collapsed = text.replace(/\s+/gu, " ").replace(/[\u0000-\u001f\u007f-\u009f]/gu, "").trim();
45
51
  if (collapsed.length === 0) return void 0;
46
52
  const budget = Number.isFinite(max) ? Math.floor(max) : Number.POSITIVE_INFINITY;
47
53
  if (budget < 1) return void 0;
@@ -62,12 +68,15 @@ function transitionLabel(transition) {
62
68
  return TRANSITION_LABELS[transition];
63
69
  }
64
70
  function presentLine(value) {
65
- if (value === void 0) return void 0;
71
+ if (typeof value !== "string") return void 0;
66
72
  return excerptLine(value, DEVLEAD_ERROR_EXCERPT_MAX);
67
73
  }
74
+ function sessionRefLabel(sessionId, title) {
75
+ const line = presentLine(title);
76
+ return line === void 0 ? sessionId : `${line} (${sessionId})`;
77
+ }
68
78
  function notificationLine(notification) {
69
- const title = presentLine(notification.sessionTitle);
70
- const who = title === void 0 ? notification.sessionId : `${title} (${notification.sessionId})`;
79
+ const who = sessionRefLabel(notification.sessionId, notification.sessionTitle);
71
80
  const error = presentLine(notification.error);
72
81
  const detail = error ?? presentLine(notification.summary);
73
82
  const suffix = detail === void 0 ? "" : `: ${detail}`;
@@ -83,6 +92,7 @@ var REPORT_KIND_LABELS = {
83
92
  progress: "progress",
84
93
  blocked: "blocked",
85
94
  decision: "decision needed",
95
+ question: "question",
86
96
  fyi: "fyi"
87
97
  };
88
98
  function isDevLeadReportKind(value) {
@@ -97,11 +107,11 @@ function devLeadReportId(senderSessionId, turn, kind, message) {
97
107
  return `${senderSessionId}:${turn}:report:${kind}:${(hash >>> 0).toString(36)}`;
98
108
  }
99
109
  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);
110
+ const who = sessionRefLabel(report.senderSessionId, report.senderSessionTitle);
111
+ const detail = presentLine(report.summary) ?? presentLine(report.message);
103
112
  const suffix = detail === void 0 ? "" : `: ${detail}`;
104
- return `${who} \u2014 report ${REPORT_KIND_LABELS[report.kind]}${suffix}`;
113
+ const kind = REPORT_KIND_LABELS[report.kind] ?? String(report.kind);
114
+ return `${who} \u2014 report ${kind}${suffix}`;
105
115
  }
106
116
  function reportDigest(reports) {
107
117
  return reports.map(reportLine);
@@ -139,5 +149,6 @@ export {
139
149
  notificationLine,
140
150
  reportDigest,
141
151
  reportLine,
152
+ sessionRefLabel,
142
153
  transitionLabel
143
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yankeguo/dsh-devlead-protocol",
3
- "version": "0.2.6",
3
+ "version": "0.3.0-rc.2",
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",
@@ -13,6 +13,7 @@
13
13
  "./package.json": "./package.json"
14
14
  },
15
15
  "files": [
16
+ "LICENSE",
16
17
  "lib",
17
18
  "locale/*.json",
18
19
  "README.md"