dsh-context 0.38.4 → 0.38.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/lib/client.js CHANGED
@@ -4833,7 +4833,7 @@ window.__ModuleLoader__.load({
4833
4833
  return function PluginInfo() {
4834
4834
  const [latest, setLatest] = React.useState(null);
4835
4835
  React.useEffect(() => {
4836
- if ("0.38.4".includes("-dev")) return;
4836
+ if ("0.38.5".includes("-dev")) return;
4837
4837
  let on = true;
4838
4838
  fetchLatestVersion().then((v) => {
4839
4839
  if (on && v) setLatest(v);
@@ -4842,8 +4842,8 @@ window.__ModuleLoader__.load({
4842
4842
  on = false;
4843
4843
  };
4844
4844
  }, []);
4845
- const update = latest !== null && isNewerVersion(latest, "0.38.4") ? latest : null;
4846
- const nameText = "dsh-context (v0.38.4)";
4845
+ const update = latest !== null && isNewerVersion(latest, "0.38.5") ? latest : null;
4846
+ const nameText = "dsh-context (v0.38.5)";
4847
4847
  const nameValue = [nameText];
4848
4848
  if (update) nameValue.push(/* @__PURE__ */ React.createElement("span", {
4849
4849
  key: "update",
package/lib/index.js CHANGED
@@ -90,7 +90,10 @@ const FIRST_PARTY_SOURCES = Object.freeze({
90
90
  * wraps that instance's `register` (once — an earlier wrapper of a previous
91
91
  * hook incarnation is peeled back to the original, so a plugin reload
92
92
  * re-wraps without stacking) to capture the reader at registration time
93
- * into a live map.
93
+ * into a live map. Every wrapper is undone when the plugin unloads: the
94
+ * original `register` goes back on the instance, unless a newer hook
95
+ * incarnation re-wrapped it first (that incarnation's own cleanup then
96
+ * owns the restore).
94
97
  * - When the reader slot is missing, root-named, or this plugin's own (e.g.
95
98
  * LOCAL-LINK plugins — dev installs via `dsh plugin add <path>` or
96
99
  * npm/pnpm link — whose anonymous entrypoints make cordis fall back to the
@@ -186,8 +189,8 @@ function callerPackageFrom(stack) {
186
189
  }
187
190
  /**
188
191
  * Install the runtime-attribution hook on a cordis app context. The hook
189
- * rides the calling fiber's lifetime (`ctx.on` / `ctx.get`), so it is
190
- * disposed with the plugin.
192
+ * rides the calling fiber's lifetime (`ctx.on`, and an effect that restores
193
+ * every patched `register`), so it is disposed with the plugin.
191
194
  * @param ctx - the context the dsh-context plugin runs in; its fiber name is
192
195
  * excluded from attributions.
193
196
  */
@@ -196,6 +199,7 @@ function createToolAttribution(ctx) {
196
199
  const wrapped = /* @__PURE__ */ new WeakSet();
197
200
  const self = ctx.fiber.name;
198
201
  let lastReader;
202
+ const patched = [];
199
203
  const wrapInstance = (tools) => {
200
204
  if (!tools || typeof tools !== "object" || wrapped.has(tools)) return;
201
205
  const register = tools.register;
@@ -223,6 +227,9 @@ function createToolAttribution(ctx) {
223
227
  };
224
228
  wrappedRegister.attributedOriginal = original;
225
229
  instance.register = wrappedRegister;
230
+ patched.push(() => {
231
+ if (instance.register === wrappedRegister) instance.register = original;
232
+ });
226
233
  };
227
234
  ctx.on("internal/get", (reader, name, _error, next) => {
228
235
  if (name !== "tools") return next();
@@ -231,6 +238,9 @@ function createToolAttribution(ctx) {
231
238
  wrapInstance(tools);
232
239
  return tools;
233
240
  });
241
+ ctx.effect(() => () => {
242
+ for (const restore of patched.splice(0)) restore();
243
+ }, "tools.register attribution");
234
244
  const toolsService = ctx.get("tools", false);
235
245
  wrapInstance(toolsService);
236
246
  const boot = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-context",
3
- "version": "0.38.4",
3
+ "version": "0.38.5",
4
4
  "description": "A DeepSeek Harness plugin for context insight and management, with context dashboard and context command, for understanding how the context is made of, and how it evolves.",
5
5
  "author": "bowenliang123",
6
6
  "repository": {