|
1 | 1 | import { readFile, opendir, realpath, stat } from "node:fs/promises"; |
2 | | -import { homedir } from "node:os"; |
3 | | -import { resolve, isAbsolute, join } from "node:path"; |
4 | | -import { isSensitivePathResolved } from "../plugins/secret-guard-plugin.js"; |
| 2 | +import { resolve, isAbsolute } from "node:path"; |
| 3 | +import { |
| 4 | + expandHome, |
| 5 | + isSensitivePathResolved, |
| 6 | +} from "../plugins/secret-guard-plugin.js"; |
5 | 7 |
|
6 | 8 | const MAX_MENTION_FILE_BYTES = 200_000; |
7 | 9 | const MAX_MENTION_TOTAL_BYTES = 400_000; |
@@ -45,16 +47,8 @@ async function summarizeDir(abs: string): Promise<string> { |
45 | 47 | return parts.length > 0 ? parts.join(", ") : "empty directory"; |
46 | 48 | } |
47 | 49 |
|
48 | | -// `~` means the operator's home to the shell, not a cwd-relative name — |
49 | | -// expand before both sensitivity gates (same ordering as the shell-token |
50 | | -// matcher) so a home-relative credential path denies as itself instead of |
51 | | -// resolving to a usually-missing cwd child that reads as merely not found. |
52 | | -function expandHome(path: string): string { |
53 | | - if (path === "~") return homedir(); |
54 | | - if (path.startsWith("~/")) return join(homedir(), path.slice(2)); |
55 | | - return path; |
56 | | -} |
57 | | -// An @mention is the operator directly asking the agent to read one path, once, |
| 50 | +// `~` expansion lives in secret-guard-plugin.ts (single owner); the comment |
| 51 | +// there documents the ordering. An @mention is the operator directly asking the agent to read one path, once, |
58 | 52 | // right now — the same consent that already lets the agent read any workspace |
59 | 53 | // file. There is no workspace-boundary check here: mentioning a path outside |
60 | 54 | // the workspace inlines it exactly like a workspace path would, gated only by |
|
0 commit comments