MCPcopy Create free account
hub / github.com/tiann/hapi / isHapiManagedDir

Function isHapiManagedDir

cli/src/opencode/utils/hookPlugin.ts:133–146  ·  view source on GitHub ↗

* `rootPath` is a HAPI-managed directory only when it lives under * `configuration.happyHomeDir` (the default `OPENCODE_CONFIG_DIR` we * synthesize per-session). If a user has exported `OPENCODE_CONFIG_DIR` * pointing at e.g. their own `~/.config/opencode`, we must not pollute it * with a placeh

(rootPath: string)

Source from the content-addressed store, hash-verified

131 * with a placeholder `package.json`.
132 */
133function isHapiManagedDir(rootPath: string): boolean {
134 const home = configuration.happyHomeDir;
135 if (!home) {
136 return false;
137 }
138 const rel = relative(home, rootPath);
139 // `relative` returns a path that does NOT start with '..' and is not
140 // absolute when rootPath is inside home. On Windows a cross-volume
141 // input (e.g. home=`C:\\hapi`, rootPath=`D:\\…`) makes `relative`
142 // return the absolute `D:\\…` verbatim — `startsWith('/')` would miss
143 // that, so use `isAbsolute` which covers both POSIX `/` and win32
144 // `<letter>:\\`.
145 return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel);
146}
147
148function hasDeclaredPluginPackage(packageJsonPath: string): boolean {
149 try {

Callers 1

ensurePluginRuntimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected