@dotdotgod/claude-code 0.3.5 → 0.3.7
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/hooks/runtime.mjs +41 -4
- package/mcp/server.mjs +0 -1
- package/package.json +2 -2
package/hooks/runtime.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// packages/context/src/hooks.mjs
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
|
-
import { dirname, join, parse, resolve } from "node:path";
|
|
7
|
+
import { dirname, isAbsolute, join, parse, relative, resolve } from "node:path";
|
|
8
8
|
function inputText() {
|
|
9
9
|
return readFileSync(0, "utf8");
|
|
10
10
|
}
|
|
@@ -64,6 +64,25 @@ function fileHash(path) {
|
|
|
64
64
|
return "missing";
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
function isInsideRoot(root, path) {
|
|
68
|
+
if (!root || typeof path !== "string") return false;
|
|
69
|
+
const absolute = resolve(path);
|
|
70
|
+
const rel = relative(root, absolute);
|
|
71
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
72
|
+
}
|
|
73
|
+
function normalizeProjectPath(root, path) {
|
|
74
|
+
if (!root || typeof path !== "string" || !path.trim()) return null;
|
|
75
|
+
const absolute = resolve(root, path);
|
|
76
|
+
return isInsideRoot(root, absolute) ? absolute : null;
|
|
77
|
+
}
|
|
78
|
+
function prunePending(state, root) {
|
|
79
|
+
const next = {};
|
|
80
|
+
for (const [path, fingerprint] of Object.entries(state.pending || {})) {
|
|
81
|
+
const absolute = normalizeProjectPath(root, path);
|
|
82
|
+
if (absolute) next[absolute] = fingerprint;
|
|
83
|
+
}
|
|
84
|
+
state.pending = next;
|
|
85
|
+
}
|
|
67
86
|
function toolName(input) {
|
|
68
87
|
return String(input.tool_name || input.toolName || "");
|
|
69
88
|
}
|
|
@@ -90,7 +109,14 @@ function isImpactGate(name, input) {
|
|
|
90
109
|
function changedPath(input, root) {
|
|
91
110
|
const value = toolInput(input);
|
|
92
111
|
const path = value.file_path || value.path;
|
|
93
|
-
return
|
|
112
|
+
return normalizeProjectPath(root, path);
|
|
113
|
+
}
|
|
114
|
+
function hasFailedToolResult(input) {
|
|
115
|
+
const response = input.tool_response || input.toolResponse || input.tool_result || input.toolResult || input.result;
|
|
116
|
+
if (!response || typeof response !== "object") return false;
|
|
117
|
+
if (response.is_error === true || response.isError === true || response.error) return true;
|
|
118
|
+
if (response.ok === false || response.status === "error" || response.status === "failed") return true;
|
|
119
|
+
return false;
|
|
94
120
|
}
|
|
95
121
|
function runHook(event) {
|
|
96
122
|
const input = parseInput();
|
|
@@ -98,6 +124,10 @@ function runHook(event) {
|
|
|
98
124
|
const context = resolveHookContext(input, event);
|
|
99
125
|
const state = readState(context?.path);
|
|
100
126
|
state.pending ||= {};
|
|
127
|
+
if (context) {
|
|
128
|
+
prunePending(state, context.root);
|
|
129
|
+
writeState(context.path, state);
|
|
130
|
+
}
|
|
101
131
|
if (event === "sessionstart") {
|
|
102
132
|
if (!context) return {};
|
|
103
133
|
state.loadRequired = true;
|
|
@@ -116,10 +146,17 @@ function runHook(event) {
|
|
|
116
146
|
if (mcpTool(name, "dotdotgod_project_load")) state.loadRequired = false;
|
|
117
147
|
else if (mcpTool(name, "dotdotgod_project_impact")) {
|
|
118
148
|
const checked = toolInput(input).paths;
|
|
149
|
+
let cleared = 0;
|
|
119
150
|
if (Array.isArray(checked)) for (const path of checked) {
|
|
120
|
-
const absolute =
|
|
121
|
-
if (state.pending
|
|
151
|
+
const absolute = normalizeProjectPath(context.root, path);
|
|
152
|
+
if (absolute && Object.hasOwn(state.pending, absolute)) {
|
|
153
|
+
delete state.pending[absolute];
|
|
154
|
+
cleared += 1;
|
|
155
|
+
}
|
|
122
156
|
}
|
|
157
|
+
writeState(context.path, state);
|
|
158
|
+
if (cleared > 0 && hasFailedToolResult(input)) return { hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: `dotdotgod_project_impact reported a failure, but dotdotgod cleared pending graph impact for ${cleared} requested path(s) to avoid a blocking retry loop. Review the impact error before broad operations.` } };
|
|
159
|
+
return {};
|
|
123
160
|
} else if (/^(Edit|Write|apply_patch)$/i.test(name)) {
|
|
124
161
|
const path = changedPath(input, context.root);
|
|
125
162
|
if (path) state.pending[path] = fileHash(path);
|
package/mcp/server.mjs
CHANGED
|
@@ -22936,7 +22936,6 @@ async function fetchAndIndex(store, input, sessionId2, signal, capabilities = {}
|
|
|
22936
22936
|
controller.abort(new Error("Browser rendering timed out."));
|
|
22937
22937
|
reject(new Error(`Browser rendering timed out after ${timeoutMs}ms.`));
|
|
22938
22938
|
}, timeoutMs);
|
|
22939
|
-
timer.unref?.();
|
|
22940
22939
|
});
|
|
22941
22940
|
let rendered;
|
|
22942
22941
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotdotgod/claude-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Claude Code adapter for dotdotgod project memory workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Elastic-2.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"esbuild": "0.27.3",
|
|
28
|
-
"@dotdotgod/context": "0.3.
|
|
28
|
+
"@dotdotgod/context": "0.3.7"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
".claude-plugin",
|