dsh-last-turn-delete 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/lib/core.js +25 -5
  2. package/package.json +1 -1
package/lib/core.js CHANGED
@@ -22,27 +22,45 @@
22
22
  * events stay in the log untouched (soft delete; nothing is lost).
23
23
  */
24
24
 
25
- /** Package name — also the identity stored on every deletion marker. */
25
+ /**
26
+ * Package name — also the plugin identity stored on every deletion marker
27
+ * (`source.plugin`).
28
+ */
26
29
  export const PKG_NAME = "dsh-last-turn-delete";
27
30
 
28
31
  /**
29
32
  * The marker user/message's source identity. The chat transcript folds only
30
33
  * append-surface user messages, so this replacement never renders a row; it
31
34
  * only occupies the surface slot where the deleted turn used to be.
35
+ *
36
+ * The shape is the format-mandated plugin message source
37
+ * (`{ kind: "plugin", plugin: <package name> }`, see
38
+ * `@deepseek-ai/dsh-llm`'s `MessageSourceMap` and the released Session format
39
+ * validators): the Session log is durable history read back through the
40
+ * versioned format migration chain, and an off-schema source makes that chain
41
+ * refuse the whole Session. Invented members such as `name`/`operation` are
42
+ * therefore not free-form — the package name is the only identity a marker may
43
+ * carry.
32
44
  */
33
45
  export function deletionMarkerSource() {
34
46
  return {
35
47
  kind: "plugin",
36
- name: PKG_NAME,
37
- operation: "delete"
48
+ plugin: PKG_NAME
38
49
  };
39
50
  }
40
51
 
41
52
  /**
42
53
  * Whether an event is one of this plugin's deletion markers: a
43
54
  * `user/message` surface replacement carrying the plugin's source identity.
55
+ *
56
+ * {@link deletionMarkerSource} is the only shape this plugin writes, but the
57
+ * `plugin` member only landed with the corrected identity: the first release
58
+ * wrote `{ kind: "plugin", name, operation }`, which the format validator
59
+ * rejects. Historical logs may still contain that shape until they are
60
+ * repaired, so recognize both — reading old markers must never depend on a
61
+ * migration having been run.
44
62
  * @param event - one durable Session event.
45
- * @returns true for marker replacements appended by this plugin.
63
+ * @returns true for marker replacements appended by this plugin, either shape.
46
64
  */
47
65
  export function isDeleteMarker(event) {
48
66
  if (event === null || typeof event !== "object") return false;
@@ -51,7 +69,9 @@ export function isDeleteMarker(event) {
51
69
  if (op === null || typeof op !== "object" || op.op !== "replace") return false;
52
70
  const source = event.data?.source;
53
71
  if (source === null || typeof source !== "object") return false;
54
- return source.kind === "plugin" && source.name === PKG_NAME && source.operation === "delete";
72
+ if (source.kind !== "plugin") return false;
73
+ if (source.plugin === PKG_NAME) return true;
74
+ return source.name === PKG_NAME && source.operation === "delete";
55
75
  }
56
76
 
57
77
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-last-turn-delete",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "DeepSeek Harness (DSH) bundle: a delete button on the last user message that soft-deletes that turn — user message plus all its model replies — keeping it out of future model context, stepping back to the previous user message until a compact boundary or none remain (最后一条用户消息上的删除按钮:软删除该用户消息及其全部模型回复,不再进入后续模型上下文;按钮随后移到上一条用户消息,直到 compact 边界或无消息)",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",