Files
oh-my-opencode/src/shared/skill-path-resolver.ts
T
YeonGyu-Kim d2c576c510 fix: resolve 25 pre-publish blockers
- postinstall.mjs: fix alias package detection
- migrate-legacy-plugin-entry: dedupe + regression tests
- task_system: default consistency across runtime paths
- task() contract: consistent tool behavior
- runtime model selection, tool cap, stale-task cancellation
- recovery sanitization, context-limit gating
- Ralph semantic DONE hardening, Atlas fallback persistence
- native-skill description/content, skill path traversal guard
- publish workflow: platform awaited via reusable workflow job
- release: version edits reapplied before commit/tag
- JSONC plugin migration: top-level plugin key safety
- cold-cache: user fallback models skip disconnected providers
- docs/version/release framing updates

Verified: bun test (4599 pass), tsc --noEmit clean, bun run build clean
2026-03-28 15:24:18 +09:00

27 lines
969 B
TypeScript

import { isAbsolute, relative, resolve, sep } from "node:path"
function looksLikeFilePath(path: string): boolean {
if (path.endsWith("/")) return true
const lastSegment = path.split("/").pop() ?? ""
return /\.[a-zA-Z0-9]+$/.test(lastSegment)
}
export function resolveSkillPathReferences(content: string, basePath: string): string {
const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath
return content.replace(
/(?<![a-zA-Z0-9])@([a-zA-Z0-9_-]+\/[a-zA-Z0-9_.\-\/]*)/g,
(match, relativePath: string) => {
if (!looksLikeFilePath(relativePath)) return match
const resolvedPath = resolve(normalizedBase, relativePath)
const relativePathFromBase = relative(normalizedBase, resolvedPath)
if (relativePathFromBase.startsWith("..") || isAbsolute(relativePathFromBase)) {
return match
}
if (relativePath.endsWith("/") && !resolvedPath.endsWith(sep)) {
return `${resolvedPath}/`
}
return resolvedPath
}
)
}