(dirname: string, execPath: string)
| 13 | * 3. Walk up from `dirname` to find `skills/deepnote/` at repo root (dev/test mode) |
| 14 | */ |
| 15 | export function resolveSkillDir(dirname: string, execPath: string): string { |
| 16 | const bundledPath = path.join(dirname, 'skills', 'deepnote') |
| 17 | if (existsSync(path.join(bundledPath, 'SKILL.md'))) { |
| 18 | return bundledPath |
| 19 | } |
| 20 | |
| 21 | // In a Bun compiled binary, import.meta.url is frozen at build time, but |
| 22 | // process.execPath points to the actual binary on disk. The pypi package |
| 23 | // ships skills at ../skills/deepnote/ relative to the bin/ directory. |
| 24 | const execBundledPath = path.join(path.dirname(execPath), '..', 'skills', 'deepnote') |
| 25 | if (existsSync(path.join(execBundledPath, 'SKILL.md'))) { |
| 26 | return execBundledPath |
| 27 | } |
| 28 | |
| 29 | let dir = dirname |
| 30 | for (let i = 0; i < 10; i++) { |
| 31 | const candidate = path.join(dir, 'skills', 'deepnote') |
| 32 | |
| 33 | if (existsSync(path.join(candidate, 'SKILL.md'))) { |
| 34 | return candidate |
| 35 | } |
| 36 | |
| 37 | const parent = path.dirname(dir) |
| 38 | |
| 39 | if (parent === dir) { |
| 40 | break |
| 41 | } |
| 42 | |
| 43 | dir = parent |
| 44 | } |
| 45 | |
| 46 | return bundledPath |
| 47 | } |
| 48 | |
| 49 | /** Returns the absolute path to the bundled skill directory. */ |
| 50 | export function getSkillDir(): string { |
no outgoing calls
no test coverage detected