@tritard/waterbrother 0.8.8 → 0.8.9
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/package.json +1 -1
- package/src/cli.js +10 -1
- package/src/tools.js +10 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -1687,7 +1687,16 @@ function extractExplicitWriteRoots(line, cwd) {
|
|
|
1687
1687
|
if (!/\b(create|make|build|write|save|generate|scaffold|edit|update|rewrite|delete|remove|move|rename)\b/i.test(text)) {
|
|
1688
1688
|
return [];
|
|
1689
1689
|
}
|
|
1690
|
-
|
|
1690
|
+
const roots = extractExplicitReadOnlyRoots(text, cwd);
|
|
1691
|
+
const desktopMatch = text.match(/\b(?:in|to|under)\s+(\/[^\s]+)\s+on\s+desktop\b/i);
|
|
1692
|
+
if (desktopMatch) {
|
|
1693
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
1694
|
+
const relative = String(desktopMatch[1] || "").replace(/^\/+/, "");
|
|
1695
|
+
if (home && relative) {
|
|
1696
|
+
roots.push(path.join(home, "Desktop", relative));
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return [...new Set(roots)];
|
|
1691
1700
|
}
|
|
1692
1701
|
|
|
1693
1702
|
function maybeRewriteExplicitInspectionPrompt(promptText, readOnlyRoots = []) {
|
package/src/tools.js
CHANGED
|
@@ -1039,6 +1039,16 @@ export function createToolRuntime({
|
|
|
1039
1039
|
|
|
1040
1040
|
function contractAllows(toolName, args = {}) {
|
|
1041
1041
|
if (!currentTurn.contract) return { ok: !toolRequiresContract(toolName, args), reason: "No active contract" };
|
|
1042
|
+
if ((toolName === "write_file" || toolName === "replace_in_file" || toolName === "make_directory" || toolName === "delete_path") && args.path) {
|
|
1043
|
+
try {
|
|
1044
|
+
resolveSandboxPath(cwd, args.path, allowOutsideCwd, {
|
|
1045
|
+
allowedWriteRoots: getCurrentWriteRoots()
|
|
1046
|
+
});
|
|
1047
|
+
} catch {
|
|
1048
|
+
const touchedPaths = getTouchedPathsForTool(toolName, args);
|
|
1049
|
+
return { ok: false, reason: `Action outside declared contract scope: ${touchedPaths.join(", ")}` };
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1042
1052
|
const touchedPaths = getTouchedPathsForTool(toolName, args);
|
|
1043
1053
|
const allowedPaths = normalizePathList([
|
|
1044
1054
|
...(Array.isArray(currentTurn.contract.paths) ? currentTurn.contract.paths : []),
|