@agentv/core 0.2.3 → 0.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentv/core",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "description": "Primitive runtime components for AgentV",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/evaluation/file-utils.ts"],"sourcesContent":["import { constants } from \"node:fs\";\r\nimport { access } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\n\r\nexport async function fileExists(filePath: string): Promise<boolean> {\r\n try {\r\n await access(filePath, constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Find git repository root by walking up the directory tree.\r\n */\r\nexport async function findGitRoot(startPath: string): Promise<string | null> {\r\n let currentDir = path.dirname(path.resolve(startPath));\r\n const root = path.parse(currentDir).root;\r\n\r\n while (currentDir !== root) {\r\n const gitPath = path.join(currentDir, \".git\");\r\n if (await fileExists(gitPath)) {\r\n return currentDir;\r\n }\r\n\r\n const parentDir = path.dirname(currentDir);\r\n if (parentDir === currentDir) {\r\n break;\r\n }\r\n currentDir = parentDir;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Build search roots for file resolution, matching yaml-parser behavior.\r\n * Searches from eval file directory up to repo root.\r\n */\r\nexport function buildSearchRoots(evalPath: string, repoRoot: string): readonly string[] {\r\n const uniqueRoots: string[] = [];\r\n const addRoot = (root: string): void => {\r\n const normalized = path.resolve(root);\r\n if (!uniqueRoots.includes(normalized)) {\r\n uniqueRoots.push(normalized);\r\n }\r\n };\r\n\r\n let currentDir = path.dirname(evalPath);\r\n let reachedBoundary = false;\r\n while (!reachedBoundary) {\r\n addRoot(currentDir);\r\n const parentDir = path.dirname(currentDir);\r\n if (currentDir === repoRoot || parentDir === currentDir) {\r\n reachedBoundary = true;\r\n } else {\r\n currentDir = parentDir;\r\n }\r\n }\r\n\r\n addRoot(repoRoot);\r\n addRoot(process.cwd());\r\n return uniqueRoots;\r\n}\r\n\r\n/**\r\n * Trim leading path separators for display.\r\n */\r\nfunction trimLeadingSeparators(value: string): string {\r\n const trimmed = value.replace(/^[/\\\\]+/, \"\");\r\n return trimmed.length > 0 ? trimmed : value;\r\n}\r\n\r\n/**\r\n * Resolve a file reference using search roots, matching yaml-parser behavior.\r\n */\r\nexport async function resolveFileReference(\r\n rawValue: string,\r\n searchRoots: readonly string[],\r\n): Promise<{\r\n readonly displayPath: string;\r\n readonly resolvedPath?: string;\r\n readonly attempted: readonly string[];\r\n}> {\r\n const displayPath = trimLeadingSeparators(rawValue);\r\n const potentialPaths: string[] = [];\r\n\r\n if (path.isAbsolute(rawValue)) {\r\n potentialPaths.push(path.normalize(rawValue));\r\n }\r\n\r\n for (const base of searchRoots) {\r\n potentialPaths.push(path.resolve(base, displayPath));\r\n }\r\n\r\n const attempted: string[] = [];\r\n const seen = new Set<string>();\r\n for (const candidate of potentialPaths) {\r\n const absoluteCandidate = path.resolve(candidate);\r\n if (seen.has(absoluteCandidate)) {\r\n continue;\r\n }\r\n seen.add(absoluteCandidate);\r\n attempted.push(absoluteCandidate);\r\n if (await fileExists(absoluteCandidate)) {\r\n return { displayPath, resolvedPath: absoluteCandidate, attempted };\r\n }\r\n }\r\n\r\n return { displayPath, attempted };\r\n}\r\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,OAAO,UAAU;AAEjB,eAAsB,WAAW,UAAoC;AACnE,MAAI;AACF,UAAM,OAAO,UAAU,UAAU,IAAI;AACrC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKA,eAAsB,YAAY,WAA2C;AAC3E,MAAI,aAAa,KAAK,QAAQ,KAAK,QAAQ,SAAS,CAAC;AACrD,QAAM,OAAO,KAAK,MAAM,UAAU,EAAE;AAEpC,SAAO,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