@pmelab/gtd 20.0.0 → 20.0.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.
- package/.claude-plugin/plugin.json +1 -1
- package/claude/hooks/access.ts +11 -4
- package/package.json +1 -1
package/claude/hooks/access.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { isAbsolute, relative, resolve } from "node:path"
|
|
2
|
-
|
|
3
1
|
import { globMatches } from "../../src/replay/Glob.js"
|
|
4
2
|
|
|
5
3
|
export type AccessDef = { read: string[] | null; write: string[] | null }
|
|
@@ -12,10 +10,19 @@ const WRITE: Record<string, string> = {
|
|
|
12
10
|
NotebookEdit: "notebook_path",
|
|
13
11
|
}
|
|
14
12
|
|
|
13
|
+
// Hand-rolled because a hooks module may not import `node:path`.
|
|
14
|
+
const segments = (p: string): string[] =>
|
|
15
|
+
p.split("/").reduce<string[]>((out, s) => {
|
|
16
|
+
if (s === "..") out.pop()
|
|
17
|
+
else if (s && s !== ".") out.push(s)
|
|
18
|
+
return out
|
|
19
|
+
}, [])
|
|
20
|
+
|
|
15
21
|
// Repo-relative form of a path; undefined when it lies outside the repo.
|
|
16
22
|
const inRepo = (p: string, root: string): string | undefined => {
|
|
17
|
-
const
|
|
18
|
-
|
|
23
|
+
const base = segments(root)
|
|
24
|
+
const target = segments(p.startsWith("/") ? p : `${root}/${p}`)
|
|
25
|
+
return base.every((s, i) => target[i] === s) ? target.slice(base.length).join("/") : undefined
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
const deny = (verb: string, path: string, globs: string[]) =>
|