@offworld/sdk 0.3.4 → 0.3.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": "@offworld/sdk",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Core SDK for Offworld - clone repos, generate references, sync with offworld.sh",
5
5
  "keywords": [
6
6
  "ai",
@@ -77,7 +77,7 @@
77
77
  "check": "oxlint && oxfmt --write"
78
78
  },
79
79
  "dependencies": {
80
- "@offworld/types": "0.3.0",
80
+ "@offworld/types": "0.3.5",
81
81
  "xdg-basedir": "^5.1.0",
82
82
  "zod": "^4.3.6"
83
83
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"clone-DyLvmbJZ.mjs","names":[],"sources":["../src/index-manager.ts","../src/clone.ts"],"sourcesContent":["/**\n * Map manager for global and project maps\n *\n * Manages:\n * - Global map: ~/.local/share/offworld/skill/offworld/assets/map.json\n * - Project map: ./.offworld/map.json\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport {\n\tGlobalMapSchema,\n\tProjectMapSchema,\n\ttype GlobalMap,\n\ttype GlobalMapRepoEntry,\n\ttype ProjectMap,\n\ttype ProjectMapRepoEntry,\n} from \"@offworld/types\";\nimport { Paths } from \"./paths.js\";\n\n/**\n * Reads the global map from ~/.local/share/offworld/skill/offworld/assets/map.json\n * Returns empty map if file doesn't exist or is invalid\n */\nexport function readGlobalMap(): GlobalMap {\n\tconst mapPath = Paths.offworldGlobalMapPath;\n\n\tif (!existsSync(mapPath)) {\n\t\treturn { repos: {} };\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\tconst data = JSON.parse(content);\n\t\treturn GlobalMapSchema.parse(data);\n\t} catch {\n\t\treturn { repos: {} };\n\t}\n}\n\n/**\n * Writes the global map to ~/.local/share/offworld/skill/offworld/assets/map.json\n * Creates directory if it doesn't exist\n */\nexport function writeGlobalMap(map: GlobalMap): void {\n\tconst mapPath = Paths.offworldGlobalMapPath;\n\tconst mapDir = dirname(mapPath);\n\n\tif (!existsSync(mapDir)) {\n\t\tmkdirSync(mapDir, { recursive: true });\n\t}\n\n\tconst validated = GlobalMapSchema.parse(map);\n\twriteFileSync(mapPath, JSON.stringify(validated, null, 2), \"utf-8\");\n}\n\n/**\n * Adds or updates a repo entry in the global map\n *\n * @param qualifiedName - The qualified repo name (owner/repo)\n * @param entry - The map entry to add/update\n */\nexport function upsertGlobalMapEntry(qualifiedName: string, entry: GlobalMapRepoEntry): void {\n\tconst map = readGlobalMap();\n\tmap.repos[qualifiedName] = entry;\n\twriteGlobalMap(map);\n}\n\n/**\n * Removes a repo entry from the global map\n *\n * @param qualifiedName - The qualified repo name (owner/repo)\n * @returns true if repo was removed, false if not found\n */\nexport function removeGlobalMapEntry(qualifiedName: string): boolean {\n\tconst map = readGlobalMap();\n\n\tif (!(qualifiedName in map.repos)) {\n\t\treturn false;\n\t}\n\n\tdelete map.repos[qualifiedName];\n\twriteGlobalMap(map);\n\treturn true;\n}\n\n/**\n * Writes a project map to ./.offworld/map.json\n *\n * @param projectRoot - Absolute path to project root\n * @param entries - Map of qualified repo names to project map entries\n */\nexport function writeProjectMap(\n\tprojectRoot: string,\n\tentries: Record<string, ProjectMapRepoEntry>,\n): void {\n\tconst mapPath = join(projectRoot, \".offworld\", \"map.json\");\n\tconst mapDir = dirname(mapPath);\n\n\tif (!existsSync(mapDir)) {\n\t\tmkdirSync(mapDir, { recursive: true });\n\t}\n\n\tconst projectMap: ProjectMap = {\n\t\tversion: 1,\n\t\tscope: \"project\",\n\t\tglobalMapPath: Paths.offworldGlobalMapPath,\n\t\trepos: entries,\n\t};\n\n\tconst validated = ProjectMapSchema.parse(projectMap);\n\twriteFileSync(mapPath, JSON.stringify(validated, null, 2), \"utf-8\");\n}\n","/**\n * Git clone and repository management utilities\n */\n\nimport { existsSync, readdirSync, rmSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { execFileSync, spawn } from \"node:child_process\";\nimport type { Config, RemoteRepoSource } from \"@offworld/types\";\nimport { getRepoPath, loadConfig, toReferenceFileName } from \"./config.js\";\nimport { readGlobalMap, upsertGlobalMapEntry, removeGlobalMapEntry } from \"./index-manager.js\";\nimport { Paths } from \"./paths.js\";\n\nexport class CloneError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"CloneError\";\n\t}\n}\n\nexport class RepoExistsError extends CloneError {\n\tconstructor(path: string) {\n\t\tsuper(`Repository already exists at: ${path}`);\n\t\tthis.name = \"RepoExistsError\";\n\t}\n}\n\nexport class RepoNotFoundError extends CloneError {\n\tconstructor(qualifiedName: string) {\n\t\tsuper(`Repository not found in index: ${qualifiedName}`);\n\t\tthis.name = \"RepoNotFoundError\";\n\t}\n}\n\nexport class GitError extends CloneError {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly command: string,\n\t\tpublic readonly exitCode: number | null,\n\t) {\n\t\tsuper(`Git command failed: ${message}`);\n\t\tthis.name = \"GitError\";\n\t}\n}\n\nexport interface CloneOptions {\n\t/** Use shallow clone (--depth 1) */\n\tshallow?: boolean;\n\t/** Clone specific branch */\n\tbranch?: string;\n\t/** Custom config for repo root path */\n\tconfig?: Config;\n\t/** Force clone even if directory exists (removes existing) */\n\tforce?: boolean;\n\t/** Use sparse checkout for large repos (only src/, lib/, packages/, docs/) */\n\tsparse?: boolean;\n}\n\nfunction execGit(args: string[], cwd?: string): string {\n\ttry {\n\t\tconst result = execFileSync(\"git\", args, {\n\t\t\tcwd,\n\t\t\tencoding: \"utf-8\",\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\t\treturn result.trim();\n\t} catch (error) {\n\t\tconst err = error as { status?: number; stderr?: Buffer | string; message?: string };\n\t\tconst stderr = err.stderr\n\t\t\t? typeof err.stderr === \"string\"\n\t\t\t\t? err.stderr\n\t\t\t\t: err.stderr.toString()\n\t\t\t: err.message || \"Unknown error\";\n\t\tthrow new GitError(stderr.trim(), `git ${args.join(\" \")}`, err.status ?? null);\n\t}\n}\n\nfunction execGitAsync(args: string[], cwd?: string): Promise<string> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst proc = spawn(\"git\", args, {\n\t\t\tcwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tenv: { ...process.env, GIT_TERMINAL_PROMPT: \"0\" },\n\t\t});\n\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\n\t\tproc.stdout.on(\"data\", (data: Buffer) => {\n\t\t\tstdout += data.toString();\n\t\t});\n\t\tproc.stderr.on(\"data\", (data: Buffer) => {\n\t\t\tstderr += data.toString();\n\t\t});\n\n\t\tproc.on(\"close\", (code) => {\n\t\t\tif (code === 0) {\n\t\t\t\tresolve(stdout.trim());\n\t\t\t} else {\n\t\t\t\treject(new GitError(stderr.trim() || \"Unknown error\", `git ${args.join(\" \")}`, code));\n\t\t\t}\n\t\t});\n\n\t\tproc.on(\"error\", (err) => {\n\t\t\treject(new GitError(err.message, `git ${args.join(\" \")}`, null));\n\t\t});\n\t});\n}\n\nexport function getCommitSha(repoPath: string): string {\n\treturn execGit([\"rev-parse\", \"HEAD\"], repoPath);\n}\n\nexport function getCommitDistance(\n\trepoPath: string,\n\tolderSha: string,\n\tnewerSha = \"HEAD\",\n): number | null {\n\ttry {\n\t\ttry {\n\t\t\texecGit([\"cat-file\", \"-e\", olderSha], repoPath);\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t\tconst count = execGit([\"rev-list\", \"--count\", `${olderSha}..${newerSha}`], repoPath);\n\t\treturn Number.parseInt(count, 10);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nconst SPARSE_CHECKOUT_DIRS = [\"src\", \"lib\", \"packages\", \"docs\", \"README.md\", \"package.json\"];\n\n/**\n * Clone a remote repository to the local repo root.\n *\n * @param source - Remote repo source from parseRepoInput()\n * @param options - Clone options (shallow, branch, config)\n * @returns The local path where the repo was cloned\n * @throws RepoExistsError if repo already exists (unless force is true)\n * @throws GitError if clone fails\n */\nexport async function cloneRepo(\n\tsource: RemoteRepoSource,\n\toptions: CloneOptions = {},\n): Promise<string> {\n\tconst config = options.config ?? loadConfig();\n\tconst repoPath = getRepoPath(source.fullName, source.provider, config);\n\n\tif (existsSync(repoPath)) {\n\t\tif (options.force) {\n\t\t\trmSync(repoPath, { recursive: true, force: true });\n\t\t} else {\n\t\t\tthrow new RepoExistsError(repoPath);\n\t\t}\n\t}\n\n\ttry {\n\t\tif (options.sparse) {\n\t\t\tawait cloneSparse(source.cloneUrl, repoPath, options);\n\t\t} else {\n\t\t\tawait cloneStandard(source.cloneUrl, repoPath, options);\n\t\t}\n\t} catch (err) {\n\t\tcleanupEmptyParentDirs(repoPath);\n\t\tthrow err;\n\t}\n\n\tconst referenceFileName = toReferenceFileName(source.fullName);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tconst hasReference = existsSync(referencePath);\n\n\tupsertGlobalMapEntry(source.qualifiedName, {\n\t\tlocalPath: repoPath,\n\t\treferences: hasReference ? [referenceFileName] : [],\n\t\tprimary: hasReference ? referenceFileName : \"\",\n\t\tkeywords: [],\n\t\tupdatedAt: new Date().toISOString(),\n\t});\n\n\treturn repoPath;\n}\n\nfunction cleanupEmptyParentDirs(repoPath: string): void {\n\tconst ownerDir = dirname(repoPath);\n\tif (existsSync(ownerDir) && readdirSync(ownerDir).length === 0) {\n\t\trmSync(ownerDir, { recursive: true, force: true });\n\t}\n}\n\nasync function cloneStandard(\n\tcloneUrl: string,\n\trepoPath: string,\n\toptions: CloneOptions,\n): Promise<void> {\n\tconst args = [\"clone\"];\n\n\tif (options.shallow) {\n\t\targs.push(\"--depth\", \"1\");\n\t}\n\n\tif (options.branch) {\n\t\targs.push(\"--branch\", options.branch);\n\t}\n\n\targs.push(cloneUrl, repoPath);\n\tawait execGitAsync(args);\n}\n\nasync function cloneSparse(\n\tcloneUrl: string,\n\trepoPath: string,\n\toptions: CloneOptions,\n): Promise<void> {\n\tconst args = [\"clone\", \"--filter=blob:none\", \"--no-checkout\", \"--sparse\"];\n\n\tif (options.shallow) {\n\t\targs.push(\"--depth\", \"1\");\n\t}\n\n\tif (options.branch) {\n\t\targs.push(\"--branch\", options.branch);\n\t}\n\n\targs.push(cloneUrl, repoPath);\n\tawait execGitAsync(args);\n\n\tawait execGitAsync([\"sparse-checkout\", \"set\", ...SPARSE_CHECKOUT_DIRS], repoPath);\n\tawait execGitAsync([\"checkout\"], repoPath);\n}\n\nexport function isShallowClone(repoPath: string): boolean {\n\ttry {\n\t\tconst result = execGit([\"rev-parse\", \"--is-shallow-repository\"], repoPath);\n\t\treturn result === \"true\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function unshallowRepo(repoPath: string): Promise<boolean> {\n\tif (!isShallowClone(repoPath)) {\n\t\treturn false;\n\t}\n\n\tawait execGitAsync([\"fetch\", \"--unshallow\"], repoPath);\n\treturn true;\n}\n\nexport interface UpdateResult {\n\t/** Whether any updates were fetched */\n\tupdated: boolean;\n\t/** Previous commit SHA before update */\n\tpreviousSha: string;\n\t/** Current commit SHA after update */\n\tcurrentSha: string;\n\t/** Whether the repo was unshallowed */\n\tunshallowed?: boolean;\n}\n\nexport interface UpdateOptions {\n\t/** Convert shallow clone to full clone */\n\tunshallow?: boolean;\n}\n\n/**\n * Update a cloned repository by running git fetch and pull.\n *\n * @param qualifiedName - The qualified name of the repo (e.g., \"github.com:owner/repo\")\n * @param options - Update options\n * @returns Update result with commit SHAs\n * @throws RepoNotFoundError if repo not in index\n * @throws GitError if fetch/pull fails\n */\nexport async function updateRepo(\n\tqualifiedName: string,\n\toptions: UpdateOptions = {},\n): Promise<UpdateResult> {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) {\n\t\tthrow new RepoNotFoundError(qualifiedName);\n\t}\n\n\tconst repoPath = entry.localPath;\n\n\tif (!existsSync(repoPath)) {\n\t\tthrow new RepoNotFoundError(qualifiedName);\n\t}\n\n\tconst previousSha = getCommitSha(repoPath);\n\tlet unshallowed = false;\n\tif (options.unshallow) {\n\t\tunshallowed = await unshallowRepo(repoPath);\n\t}\n\n\tawait execGitAsync([\"fetch\"], repoPath);\n\tawait execGitAsync([\"pull\", \"--ff-only\"], repoPath);\n\n\tconst currentSha = getCommitSha(repoPath);\n\tupsertGlobalMapEntry(qualifiedName, {\n\t\t...entry,\n\t\tupdatedAt: new Date().toISOString(),\n\t});\n\n\treturn {\n\t\tupdated: previousSha !== currentSha,\n\t\tpreviousSha,\n\t\tcurrentSha,\n\t\tunshallowed,\n\t};\n}\n\nexport interface RemoveOptions {\n\treferenceOnly?: boolean;\n\trepoOnly?: boolean;\n}\n\nexport async function removeRepo(\n\tqualifiedName: string,\n\toptions: RemoveOptions = {},\n): Promise<boolean> {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) {\n\t\treturn false;\n\t}\n\n\tconst { referenceOnly = false, repoOnly = false } = options;\n\tconst removeRepoFiles = !referenceOnly;\n\tconst removeReferenceFiles = !repoOnly;\n\n\tif (removeRepoFiles && existsSync(entry.localPath)) {\n\t\trmSync(entry.localPath, { recursive: true, force: true });\n\t\tcleanupEmptyParentDirs(entry.localPath);\n\t}\n\n\tif (removeReferenceFiles) {\n\t\tfor (const referenceFileName of entry.references) {\n\t\t\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\t\t\tif (existsSync(referencePath)) {\n\t\t\t\trmSync(referencePath, { force: true });\n\t\t\t}\n\t\t}\n\n\t\tif (entry.primary) {\n\t\t\tconst metaDirName = entry.primary.replace(/\\.md$/, \"\");\n\t\t\tconst metaPath = join(Paths.metaDir, metaDirName);\n\t\t\tif (existsSync(metaPath)) {\n\t\t\t\trmSync(metaPath, { recursive: true, force: true });\n\t\t\t}\n\t\t}\n\t}\n\n\tif (removeRepoFiles) {\n\t\tremoveGlobalMapEntry(qualifiedName);\n\t} else if (removeReferenceFiles) {\n\t\tupsertGlobalMapEntry(qualifiedName, {\n\t\t\t...entry,\n\t\t\treferences: [],\n\t\t\tprimary: \"\",\n\t\t});\n\t}\n\n\treturn true;\n}\n\nexport function listRepos(): string[] {\n\tconst map = readGlobalMap();\n\treturn Object.keys(map.repos);\n}\n\nexport function isRepoCloned(qualifiedName: string): boolean {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) return false;\n\treturn existsSync(entry.localPath);\n}\n\n/**\n * Get the local path for a cloned repository.\n *\n * @param qualifiedName - The qualified name of the repo\n * @returns The local path or undefined if not cloned\n */\nexport function getClonedRepoPath(qualifiedName: string): string | undefined {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) return undefined;\n\tif (!existsSync(entry.localPath)) return undefined;\n\treturn entry.localPath;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAAgB,gBAA2B;CAC1C,MAAM,UAAU,MAAM;AAEtB,KAAI,CAAC,WAAW,QAAQ,CACvB,QAAO,EAAE,OAAO,EAAE,EAAE;AAGrB,KAAI;EACH,MAAM,UAAU,aAAa,SAAS,QAAQ;EAC9C,MAAM,OAAO,KAAK,MAAM,QAAQ;AAChC,SAAO,gBAAgB,MAAM,KAAK;SAC3B;AACP,SAAO,EAAE,OAAO,EAAE,EAAE;;;;;;;AAQtB,SAAgB,eAAe,KAAsB;CACpD,MAAM,UAAU,MAAM;CACtB,MAAM,SAAS,QAAQ,QAAQ;AAE/B,KAAI,CAAC,WAAW,OAAO,CACtB,WAAU,QAAQ,EAAE,WAAW,MAAM,CAAC;CAGvC,MAAM,YAAY,gBAAgB,MAAM,IAAI;AAC5C,eAAc,SAAS,KAAK,UAAU,WAAW,MAAM,EAAE,EAAE,QAAQ;;;;;;;;AASpE,SAAgB,qBAAqB,eAAuB,OAAiC;CAC5F,MAA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,UAAU;CACpD,MAAM,kBAAkB,CAAC;CACzB,MAAM,uBAAuB,CAAC;AAE9B,KAAI,mBAAmB,WAAW,MAAM,UAAU,EAAE;AACnD,SAAO,MAAM,WAAW;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;AACzD,yBAAuB,MAAM,UAAU;;AAGxC,KAAI,sBAAsB;AACzB,OAAK,MAAM,qBAAqB,MAAM,YAAY;GACjD,MAAM,gBAAgB,KAAK,MAAM,uBAAuB,kBAAkB;AAC1E,OAAI,WAAW,cAAc,CAC5B,QAAO,eAAe,EAAE,OAAO,MAAM,CAAC;;AAIxC,MAAI,MAAM,SAAS;GAClB,MAAM,cAAc,MAAM,QAAQ,QAAQ,SAAS,GAAG;GACtD,MAAM,WAAW,KAAK,MAAM,SAAS,YAAY;AACjD,OAAI,WAAW,SAAS,CACvB,QAAO,UAAU;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;;;AAKrD,KAAI,gBACH,sBAAqB,cAAc;UACzB,qBACV,sBAAqB,eAAe;EACnC,GAAG;EACH,YAAY,EAAE;EACd,SAAS;EACT,CAAC;AAGH,QAAO;;AAGR,SAAgB,YAAsB;CACrC,MAAM,MAAM,eAAe;AAC3B,QAAO,OAAO,KAAK,IAAI,MAAM;;AAG9B,SAAgB,aAAa,eAAgC;CAE5D,MAAM,QADM,eAAe,CACT,MAAM;AACxB,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,WAAW,MAAM,UAAU;;;;;;;;AASnC,SAAgB,kBAAkB,eAA2C;CAE5E,MAAM,QADM,eAAe,CACT,MAAM;AACxB,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,CAAC,WAAW,MAAM,UAAU,CAAE,QAAO;AACzC,QAAO,MAAM"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"public-BKG6lLlV.d.mts","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/paths.ts","../src/repo-source.ts","../src/index-manager.ts","../src/map.ts","../src/clone.ts","../src/auth.ts","../src/reference.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AA;AAAA,iBAyDxD,UAAA,CAAW,OAAA,GAAS,YAAA,GAAoB,OAAA,CAAQ,WAAA;AAAA,iBA8DhD,OAAA,CAAQ,OAAA,GAAS,SAAA,GAAiB,OAAA,CAAQ,QAAA;AAAA,UAoE/C,eAAA;EAChB,QAAA;EACA,MAAA;EACA,UAAA,IAAc,IAAA,UAAc,QAAA;AAAA;AAAA,UAGZ,cAAA;EAChB,UAAA,EAAY,KAAA;IAAQ,QAAA;IAAkB,aAAA;IAAuB,SAAA;EAAA;EAC7D,cAAA;AAAA;AAAA,iBAGqB,aAAA,CAAc,OAAA,GAAS,eAAA,GAAuB,OAAA,CAAQ,cAAA;;;;;;UCzV3D,YAAA;EAChB,EAAA;EACA,IAAA;EACA,GAAA;AAAA;AdCD;;;AAAA,UcKiB,SAAA;EAChB,EAAA;EACA,IAAA;EACA,SAAA;EACA,YAAA;EACA,MAAA;AAAA;;;;UAMgB,kBAAA,SAA2B,YAAA;EAC3C,MAAA,EAAQ,SAAA;AAAA;;;AbGT;iBakCsB,aAAA,CAAA,GAAiB,OAAA,CAAQ,YAAA;;;;iBAezB,WAAA,CAAY,UAAA,WAAqB,OAAA,CAAQ,kBAAA;;;;iBA4BzC,uBAAA,CAAA,GAA2B,OAAA,CAAQ,kBAAA;Ab5DzD;;;AAAA,iBaqFsB,qBAAA,CACrB,UAAA,UACA,OAAA,WACE,OAAA;EAAU,KAAA;EAAgB,KAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"public-C_ZpC7eH.mjs","names":["GlobalMapSchema","ProjectMapSchema"],"sources":["../src/constants.ts","../src/repo-source.ts","../src/map.ts","../src/auth.ts","../src/agents.ts","../src/dep-mappings.ts","../src/reference.ts","../src/manifest.ts","../src/reference-matcher.ts","../src/repo-manager.ts","../src/models.ts"],"sourcesContent":["/**\n * SDK Constants\n */\n\n/** SDK version - must match package.json */\nexport const VERSION = \"0.3.4\";\n\n/**\n * Default patterns to ignore when scanning repositories.\n * Includes directories, binary files, IDE configs, and build outputs.\n */\nexport const DEFAULT_IGNORE_PATTERNS = [\n\t\".git\",\n\t\".git/**\",\n\t\".svn\",\n\t\".hg\",\n\n\t\"node_modules\",\n\t\"node_modules/**\",\n\t\"vendor\",\n\t\"vendor/**\",\n\t\".pnpm\",\n\t\".yarn\",\n\n\t\"dist\",\n\t\"dist/**\",\n\t\"build\",\n\t\"build/**\",\n\t\"out\",\n\t\"out/**\",\n\t\".next\",\n\t\".nuxt\",\n\t\".output\",\n\t\"target\",\n\t\"__pycache__\",\n\t\"*.pyc\",\n\n\t\".vscode\",\n\t\".vscode/**\",\n\t\".idea\",\n\t\".idea/**\",\n\t\"*.swp\",\n\t\"*.swo\",\n\t\".DS_Store\",\n\n\t\"*.jpg\",\n\t\"*.jpeg\",\n\t\"*.png\",\n\t\"*.gif\",\n\t\"*.ico\",\n\t\"*.webp\",\n\t\"*.svg\",\n\t\"*.bmp\",\n\t\"*.tiff\",\n\t\"*.mp4\",\n\t\"*.webm\",\n\t\"*.mov\",\n\t\"*.avi\",\n\t\"*.mkv\",\n\t\"*.mp3\",\n\t\"*.wav\",\n\t\"*.flac\",\n\t\"*.ogg\",\n\t\"*.pdf\",\n\t\"*.zip\",\n\t\"*.tar\",\n\t\"*.gz\",\n\t\"*.rar\",\n\t\"*.7z\",\n\t\"*.exe\",\n\t\"*.dll\",\n\t\"*.so\",\n\t\"*.dylib\",\n\t\"*.bin\",\n\t\"*.wasm\",\n\t\"*.woff\",\n\t\"*.woff2\",\n\t\"*.ttf\",\n\t\"*.eot\",\n\t\"*.otf\",\n\n\t\"package-lock.json\",\n\t\"yarn.lock\",\n\t\"pnpm-lock.yaml\",\n\t\"bun.lockb\",\n\t\"Cargo.lock\",\n\t\"Gemfile.lock\",\n\t\"poetry.lock\",\n\t\"composer.lock\",\n\t\"go.sum\",\n\n\t\"coverage\",\n\t\"coverage/**\",\n\t\".nyc_output\",\n\t\".coverage\",\n\t\"htmlcov\",\n\n\t\"*.log\",\n\t\"logs\",\n\t\"tmp\",\n\t\"temp\",\n\t\".tmp\",\n\t\".temp\",\n\t\".cache\",\n\n\t\".env\",\n\t\".env.*\",\n\t\"*.pem\",\n\t\"*.key\",\n] as const;\n","/**\n * Repository source parsing utilities\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { basename } from \"node:path\";\nimport type { GitProvider, LocalRepoSource, RemoteRepoSource, RepoSource } from \"@offworld/types\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { expandTilde } from \"./paths.js\";\n\nexport class RepoSourceError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RepoSourceError\";\n\t}\n}\n\nexport class PathNotFoundError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Path does not exist: ${path}`);\n\t\tthis.name = \"PathNotFoundError\";\n\t}\n}\n\nexport class NotGitRepoError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Directory is not a git repository: ${path}`);\n\t\tthis.name = \"NotGitRepoError\";\n\t}\n}\n\nconst PROVIDER_HOSTS: Record<string, GitProvider> = {\n\t\"github.com\": \"github\",\n\t\"gitlab.com\": \"gitlab\",\n\t\"bitbucket.org\": \"bitbucket\",\n};\n\nconst HTTPS_URL_REGEX =\n\t/^https?:\\/\\/(github\\.com|gitlab\\.com|bitbucket\\.org)\\/([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SSH_URL_REGEX = /^git@(github\\.com|gitlab\\.com|bitbucket\\.org):([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SHORT_FORMAT_REGEX = /^([^/:@]+)\\/([^/:@]+)$/;\n\n/**\n * Generates a short hash of a path for local repo identification\n */\nfunction hashPath(path: string): string {\n\treturn createHash(\"sha256\").update(path).digest(\"hex\").slice(0, 12);\n}\n\n/**\n * Builds a clone URL for a remote repository\n */\nfunction buildCloneUrl(provider: GitProvider, owner: string, repo: string): string {\n\tconst hosts: Record<GitProvider, string> = {\n\t\tgithub: \"github.com\",\n\t\tgitlab: \"gitlab.com\",\n\t\tbitbucket: \"bitbucket.org\",\n\t};\n\treturn `https://${hosts[provider]}/${owner}/${repo}.git`;\n}\n\n/**\n * Parses a remote repository from HTTPS URL format\n */\nfunction parseHttpsUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(HTTPS_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from SSH URL format\n */\nfunction parseSshUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SSH_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from short format (owner/repo)\n * Defaults to GitHub as provider\n */\nfunction parseShortFormat(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SHORT_FORMAT_REGEX);\n\tif (!match) return null;\n\n\tconst [, owner, repo] = match;\n\tif (!owner || !repo) return null;\n\n\tconst provider: GitProvider = \"github\";\n\tconst host = \"github.com\";\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a local repository path\n * Validates that the path exists and contains a .git directory\n */\nfunction parseLocalPath(input: string): LocalRepoSource {\n\tconst absolutePath = resolve(expandTilde(input));\n\n\tif (!existsSync(absolutePath)) {\n\t\tthrow new PathNotFoundError(absolutePath);\n\t}\n\n\tconst stats = statSync(absolutePath);\n\tif (!stats.isDirectory()) {\n\t\tthrow new RepoSourceError(`Path is not a directory: ${absolutePath}`);\n\t}\n\n\tconst gitPath = resolve(absolutePath, \".git\");\n\tif (!existsSync(gitPath)) {\n\t\tthrow new NotGitRepoError(absolutePath);\n\t}\n\n\tconst name = basename(absolutePath);\n\tconst hash = hashPath(absolutePath);\n\n\treturn {\n\t\ttype: \"local\",\n\t\tpath: absolutePath,\n\t\tname,\n\t\tqualifiedName: `local:${hash}`,\n\t};\n}\n\n/**\n * Determines if input looks like a local path\n */\nfunction isLocalPath(input: string): boolean {\n\treturn input.startsWith(\".\") || input.startsWith(\"/\") || input.startsWith(\"~\");\n}\n\n/**\n * Parses a repository input and returns a structured RepoSource\n *\n * Supported formats:\n * - owner/repo (short format, defaults to GitHub)\n * - https://github.com/owner/repo\n * - https://gitlab.com/owner/repo\n * - https://bitbucket.org/owner/repo\n * - git@github.com:owner/repo.git (SSH format)\n * - . (current directory as local repo)\n * - /absolute/path (local repo)\n *\n * @throws PathNotFoundError if local path doesn't exist\n * @throws NotGitRepoError if local path is not a git repository\n * @throws RepoSourceError for other parsing failures\n */\nexport function parseRepoInput(input: string): RepoSource {\n\tconst trimmed = input.trim();\n\n\tconst httpsResult = parseHttpsUrl(trimmed);\n\tif (httpsResult) return httpsResult;\n\n\tconst sshResult = parseSshUrl(trimmed);\n\tif (sshResult) return sshResult;\n\n\tif (isLocalPath(trimmed)) {\n\t\treturn parseLocalPath(trimmed);\n\t}\n\n\tconst shortResult = parseShortFormat(trimmed);\n\tif (shortResult) return shortResult;\n\n\tthrow new RepoSourceError(\n\t\t`Unable to parse repository input: ${input}. ` +\n\t\t\t\"Expected formats: owner/repo, https://github.com/owner/repo, git@github.com:owner/repo.git, or a local path\",\n\t);\n}\n\nexport function getReferenceFileNameForSource(source: RepoSource): string {\n\tif (source.type === \"remote\") {\n\t\treturn toReferenceFileName(source.fullName);\n\t}\n\treturn toReferenceFileName(source.name);\n}\n","/**\n * Map query helpers for fast routing without reading full map.json\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type {\n\tGlobalMap,\n\tGlobalMapRepoEntry,\n\tProjectMap,\n\tProjectMapRepoEntry,\n} from \"@offworld/types\";\nimport { GlobalMapSchema, ProjectMapSchema } from \"@offworld/types/schemas\";\nimport { Paths } from \"./paths.js\";\n\nexport interface MapEntry {\n\tscope: \"project\" | \"global\";\n\tqualifiedName: string;\n\tentry: GlobalMapRepoEntry | ProjectMapRepoEntry;\n}\n\nexport interface SearchResult {\n\tqualifiedName: string;\n\tfullName: string;\n\tlocalPath: string;\n\tprimary: string;\n\tkeywords: string[];\n\tscore: number;\n}\n\nexport interface GetMapEntryOptions {\n\tpreferProject?: boolean;\n\tcwd?: string;\n}\n\nexport interface SearchMapOptions {\n\tlimit?: number;\n\tcwd?: string;\n}\n\nfunction readGlobalMapSafe(): GlobalMap | null {\n\tconst mapPath = Paths.offworldGlobalMapPath;\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn GlobalMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction readProjectMapSafe(cwd: string): ProjectMap | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn ProjectMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Normalize input to match against repo keys.\n * Accepts: github.com:owner/repo, owner/repo, repo\n */\nfunction normalizeInput(input: string): { provider?: string; fullName: string; repoName: string } {\n\tconst trimmed = input.trim().toLowerCase();\n\n\tif (trimmed.includes(\":\")) {\n\t\tconst parts = trimmed.split(\":\", 2);\n\t\tconst provider = parts[0];\n\t\tconst fullName = parts[1] ?? \"\";\n\t\tconst repoName = fullName.split(\"/\").pop() ?? fullName;\n\t\treturn { provider, fullName, repoName };\n\t}\n\n\tif (trimmed.includes(\"/\")) {\n\t\tconst repoName = trimmed.split(\"/\").pop() ?? trimmed;\n\t\treturn { fullName: trimmed, repoName };\n\t}\n\n\treturn { fullName: trimmed, repoName: trimmed };\n}\n\n/**\n * Tokenize a string for search matching.\n * Lowercase, strip @, split on /_- and whitespace.\n */\nfunction tokenize(str: string): string[] {\n\treturn str\n\t\t.toLowerCase()\n\t\t.replace(/@/g, \"\")\n\t\t.split(/[/_\\-\\s]+/)\n\t\t.filter(Boolean);\n}\n\n/**\n * Resolve an input string to a qualified repo key in a map.\n *\n * @param input - Accepts github.com:owner/repo, owner/repo, or repo name\n * @param map - A global or project map\n * @returns The matching qualified name or null\n */\nexport function resolveRepoKey(input: string, map: GlobalMap | ProjectMap): string | null {\n\tconst { provider, fullName, repoName } = normalizeInput(input);\n\tconst keys = Object.keys(map.repos);\n\n\tif (provider) {\n\t\tconst qualifiedKey = `${provider}:${fullName}`;\n\t\tif (keys.includes(qualifiedKey)) {\n\t\t\treturn qualifiedKey;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyFullName = key.includes(\":\") ? key.split(\":\")[1] : key;\n\t\tif (keyFullName?.toLowerCase() === fullName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyRepoName = key.split(\"/\").pop()?.toLowerCase();\n\t\tif (keyRepoName === repoName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Get a map entry for a repo, preferring project map if available.\n *\n * @param input - Repo identifier (github.com:owner/repo, owner/repo, or repo)\n * @param options - Options for lookup\n * @returns Entry with scope and qualified name, or null if not found\n */\nexport function getMapEntry(input: string, options: GetMapEntryOptions = {}): MapEntry | null {\n\tconst { preferProject = true, cwd = process.cwd() } = options;\n\n\tconst projectMap = preferProject ? readProjectMapSafe(cwd) : null;\n\tconst globalMap = readGlobalMapSafe();\n\n\tif (projectMap) {\n\t\tconst key = resolveRepoKey(input, projectMap);\n\t\tif (key && projectMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"project\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: projectMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\tif (globalMap) {\n\t\tconst key = resolveRepoKey(input, globalMap);\n\t\tif (key && globalMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"global\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: globalMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Search the map for repos matching a term.\n *\n * Scoring:\n * - Exact fullName match: 100\n * - Keyword hit: 50 per keyword\n * - Partial contains in fullName: 25\n * - Partial contains in keywords: 10\n *\n * @param term - Search term\n * @param options - Search options\n * @returns Sorted list of matches\n */\nexport function searchMap(term: string, options: SearchMapOptions = {}): SearchResult[] {\n\tconst { limit = 10 } = options;\n\n\tconst globalMap = readGlobalMapSafe();\n\tif (!globalMap) return [];\n\n\tconst termTokens = tokenize(term);\n\tconst termLower = term.toLowerCase();\n\tconst results: SearchResult[] = [];\n\n\tfor (const qualifiedName of Object.keys(globalMap.repos)) {\n\t\tconst entry = globalMap.repos[qualifiedName];\n\t\tif (!entry) continue;\n\n\t\tconst fullName = qualifiedName.includes(\":\")\n\t\t\t? (qualifiedName.split(\":\")[1] ?? qualifiedName)\n\t\t\t: qualifiedName;\n\t\tconst fullNameLower = fullName.toLowerCase();\n\t\tconst keywords = entry.keywords ?? [];\n\t\tconst keywordsLower = keywords.map((k) => k.toLowerCase());\n\n\t\tlet score = 0;\n\n\t\tif (fullNameLower === termLower) {\n\t\t\tscore += 100;\n\t\t}\n\n\t\tfor (const token of termTokens) {\n\t\t\tif (keywordsLower.includes(token)) {\n\t\t\t\tscore += 50;\n\t\t\t}\n\t\t}\n\n\t\tif (fullNameLower.includes(termLower) && score < 100) {\n\t\t\tscore += 25;\n\t\t}\n\n\t\tfor (const kw of keywordsLower) {\n\t\t\tif (kw.includes(termLower)) {\n\t\t\t\tscore += 10;\n\t\t\t}\n\t\t}\n\n\t\tconst fullNameTokens = tokenize(fullName);\n\t\tfor (const token of termTokens) {\n\t\t\tif (fullNameTokens.includes(token)) {\n\t\t\t\tscore += 30;\n\t\t\t}\n\t\t}\n\n\t\tif (score > 0) {\n\t\t\tresults.push({\n\t\t\t\tqualifiedName,\n\t\t\t\tfullName,\n\t\t\t\tlocalPath: entry.localPath,\n\t\t\t\tprimary: entry.primary,\n\t\t\t\tkeywords,\n\t\t\t\tscore,\n\t\t\t});\n\t\t}\n\t}\n\n\tresults.sort((a, b) => {\n\t\tif (b.score !== a.score) return b.score - a.score;\n\t\treturn a.fullName.localeCompare(b.fullName);\n\t});\n\n\treturn results.slice(0, limit);\n}\n\n/**\n * Get the project map path if it exists in cwd.\n */\nexport function getProjectMapPath(cwd: string = process.cwd()): string | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\treturn existsSync(mapPath) ? mapPath : null;\n}\n","/**\n * Authentication utilities for offworld CLI\n */\n\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport { WorkOSTokenResponseSchema } from \"@offworld/types\";\nimport { Paths } from \"./paths\";\n\nconst AuthDataSchema = z.object({\n\ttoken: z.string(),\n\texpiresAt: z.string().optional(),\n\tworkosId: z.string().optional(),\n\trefreshToken: z.string().optional(),\n\temail: z.string().optional(),\n});\n\nexport interface AuthData {\n\ttoken: string;\n\texpiresAt?: string;\n\tworkosId?: string;\n\trefreshToken?: string;\n\temail?: string;\n}\n\n/** Authentication status */\nexport interface AuthStatus {\n\tisLoggedIn: boolean;\n\temail?: string;\n\tworkosId?: string;\n\texpiresAt?: string;\n}\n\nexport class AuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class NotLoggedInError extends AuthError {\n\tconstructor(message = \"Not logged in. Please run 'ow auth login' first.\") {\n\t\tsuper(message);\n\t\tthis.name = \"NotLoggedInError\";\n\t}\n}\n\nexport class TokenExpiredError extends AuthError {\n\tconstructor(message = \"Session expired. Please run 'ow auth login' again.\") {\n\t\tsuper(message);\n\t\tthis.name = \"TokenExpiredError\";\n\t}\n}\n\nfunction extractJwtExpiration(token: string): string | undefined {\n\ttry {\n\t\tconst parts = token.split(\".\");\n\t\tif (parts.length !== 3) return undefined;\n\n\t\tconst payload = parts[1];\n\t\tif (!payload) return undefined;\n\n\t\tconst decoded = JSON.parse(Buffer.from(payload, \"base64\").toString(\"utf-8\"));\n\t\tif (typeof decoded.exp !== \"number\") return undefined;\n\n\t\treturn new Date(decoded.exp * 1000).toISOString();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function getAuthPath(): string {\n\treturn Paths.authFile;\n}\n\nexport function saveAuthData(data: AuthData): void {\n\tconst authPath = getAuthPath();\n\tconst authDir = dirname(authPath);\n\n\tif (!existsSync(authDir)) {\n\t\tmkdirSync(authDir, { recursive: true });\n\t}\n\n\twriteFileSync(authPath, JSON.stringify(data, null, 2), \"utf-8\");\n\tchmodSync(authPath, 0o600);\n}\n\n/**\n * Loads authentication data from ~/.local/share/offworld/auth.json\n * Returns null if file doesn't exist or is invalid\n */\nexport function loadAuthData(): AuthData | null {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(authPath, \"utf-8\");\n\t\tconst json = JSON.parse(content);\n\t\tconst parsed = AuthDataSchema.safeParse(json);\n\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn parsed.data;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Clears stored authentication data\n * @returns true if auth file was deleted, false if it didn't exist\n */\nexport function clearAuthData(): boolean {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tunlinkSync(authPath);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function getToken(): Promise<string> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\tthrow new NotLoggedInError();\n\t}\n\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new TokenExpiredError();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new TokenExpiredError();\n\t\t}\n\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\treturn data.token;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn data.token;\n}\n\n/**\n * Gets the current authentication token, or null if not logged in\n * Does not throw errors\n */\nexport async function getTokenOrNull(): Promise<string | null> {\n\ttry {\n\t\treturn await getToken();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function isLoggedIn(): Promise<boolean> {\n\treturn (await getTokenOrNull()) !== null;\n}\n\nexport async function getAuthStatus(): Promise<AuthStatus> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\treturn { isLoggedIn: false };\n\t}\n\n\t// Extract expiration from JWT if not already saved (mirrors getToken() logic)\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\t// Token already expired - attempt refresh\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\treturn { isLoggedIn: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { isLoggedIn: false };\n\t\t}\n\n\t\t// Proactive refresh: token expires within 1 minute\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\t// Refresh failed, but token still valid - return current data\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tworkosId: data.workosId,\n\t\t\t\t\t\texpiresAt: expiresAtStr,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tisLoggedIn: true,\n\t\temail: data.email,\n\t\tworkosId: data.workosId,\n\t\texpiresAt: expiresAtStr,\n\t};\n}\n\nconst WORKOS_API = \"https://api.workos.com\";\n\n// Production WorkOS client ID - dev can override via WORKOS_CLIENT_ID env var\nconst PRODUCTION_WORKOS_CLIENT_ID = \"client_01KFAD76TNGN02AP96982HG35E\";\n\nfunction getWorkosClientId(): string {\n\treturn process.env.WORKOS_CLIENT_ID ?? PRODUCTION_WORKOS_CLIENT_ID;\n}\n\nexport async function refreshAccessToken(): Promise<AuthData> {\n\tconst data = loadAuthData();\n\n\tif (!data?.refreshToken) {\n\t\tthrow new AuthError(\"No refresh token available. Please log in again.\");\n\t}\n\n\ttry {\n\t\tconst response = await fetch(`${WORKOS_API}/user_management/authenticate`, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\trefresh_token: data.refreshToken,\n\t\t\t\tclient_id: getWorkosClientId(),\n\t\t\t}),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst error = await response.text();\n\t\t\tthrow new AuthError(`Token refresh failed: ${error}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\t\tconst tokenData = WorkOSTokenResponseSchema.parse(json);\n\n\t\tconst newAuthData: AuthData = {\n\t\t\ttoken: tokenData.access_token,\n\t\t\temail: tokenData.user.email,\n\t\t\tworkosId: tokenData.user.id,\n\t\t\trefreshToken: tokenData.refresh_token,\n\t\t\texpiresAt: tokenData.expires_at\n\t\t\t\t? new Date(tokenData.expires_at * 1000).toISOString()\n\t\t\t\t: extractJwtExpiration(tokenData.access_token),\n\t\t};\n\n\t\tsaveAuthData(newAuthData);\n\t\treturn newAuthData;\n\t} catch (error) {\n\t\tif (error instanceof AuthError) throw error;\n\t\tthrow new AuthError(\n\t\t\t`Failed to refresh token: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n","/**\n * Agent Registry & Auto-Detection\n *\n * Centralized registry of supported AI coding agents with their\n * skill directory locations and detection functions.\n */\n\nimport { existsSync } from \"node:fs\";\nimport type { Agent } from \"@offworld/types\";\nimport { expandTilde } from \"./paths\";\n\nexport interface AgentConfig {\n\t/** Agent identifier (matches AgentSchema enum) */\n\tname: Agent;\n\t/** Human-readable name for display */\n\tdisplayName: string;\n\t/** Project-level skill directory (relative path) */\n\tskillsDir: string;\n\t/** User-level skill directory (absolute with ~) */\n\tglobalSkillsDir: string;\n\t/** Check if this agent is installed on the system */\n\tdetectInstalled: () => boolean;\n}\n\nexport const agents: Record<Agent, AgentConfig> = {\n\topencode: {\n\t\tname: \"opencode\",\n\t\tdisplayName: \"OpenCode\",\n\t\tskillsDir: \".opencode/skills\",\n\t\tglobalSkillsDir: \"~/.config/opencode/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/opencode\")),\n\t},\n\t\"claude-code\": {\n\t\tname: \"claude-code\",\n\t\tdisplayName: \"Claude Code\",\n\t\tskillsDir: \".claude/skills\",\n\t\tglobalSkillsDir: \"~/.claude/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.claude\")),\n\t},\n\tcodex: {\n\t\tname: \"codex\",\n\t\tdisplayName: \"Codex (OpenAI)\",\n\t\tskillsDir: \".codex/skills\",\n\t\tglobalSkillsDir: \"~/.codex/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.codex\")),\n\t},\n\tamp: {\n\t\tname: \"amp\",\n\t\tdisplayName: \"Amp\",\n\t\tskillsDir: \".agents/skills\",\n\t\tglobalSkillsDir: \"~/.config/agents/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/amp\")),\n\t},\n\tantigravity: {\n\t\tname: \"antigravity\",\n\t\tdisplayName: \"Antigravity\",\n\t\tskillsDir: \".agent/skills\",\n\t\tglobalSkillsDir: \"~/.gemini/antigravity/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.gemini/antigravity\")),\n\t},\n\tcursor: {\n\t\tname: \"cursor\",\n\t\tdisplayName: \"Cursor\",\n\t\tskillsDir: \".cursor/skills\",\n\t\tglobalSkillsDir: \"~/.cursor/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.cursor\")),\n\t},\n};\n\n/**\n * Detect which agents are installed on the system.\n * Checks for the existence of each agent's config directory.\n *\n * @returns Array of installed agent identifiers\n */\nexport function detectInstalledAgents(): Agent[] {\n\tconst installed: Agent[] = [];\n\n\tfor (const config of Object.values(agents)) {\n\t\tif (config.detectInstalled()) {\n\t\t\tinstalled.push(config.name);\n\t\t}\n\t}\n\n\treturn installed;\n}\n\n/**\n * Get the configuration for a specific agent.\n *\n * @param type - Agent identifier\n * @returns AgentConfig for the specified agent\n */\nexport function getAgentConfig(type: Agent): AgentConfig {\n\treturn agents[type];\n}\n\n/**\n * Get all agent configurations as an array.\n *\n * @returns Array of all agent configurations\n */\nexport function getAllAgentConfigs(): AgentConfig[] {\n\treturn Object.values(agents);\n}\n","/**\n * Dependency name to GitHub repo resolution:\n * 1. Parse repo from dependency spec (git/https/github shorthand)\n * 2. Query npm registry for repository.url\n * 3. Fall back to FALLBACK_MAPPINGS for packages missing repository field\n * 4. Return unknown (caller handles)\n */\n\nimport { NpmPackageResponseSchema } from \"@offworld/types\";\n\nexport type ResolvedDep = {\n\tdep: string;\n\trepo: string | null;\n\tsource: \"spec\" | \"npm\" | \"fallback\" | \"unknown\";\n};\n\nexport interface ResolveDependencyRepoOptions {\n\tallowNpm?: boolean;\n\tnpmTimeoutMs?: number;\n}\n\nconst DEFAULT_NPM_FETCH_TIMEOUT_MS = 5000;\n\n/**\n * Fallback mappings for packages where npm registry doesn't have repository.url.\n * Only add packages here that genuinely don't have the field set.\n */\nexport const FALLBACK_MAPPINGS: Record<string, string> = {\n\t\"@convex-dev/react-query\": \"get-convex/convex-react-query\",\n\t\"@opencode-ai/sdk\": \"anomalyco/opencode-sdk-js\",\n};\n\n/**\n * Parse GitHub repo from various git URL formats.\n * Handles:\n * - git+https://github.com/owner/repo.git\n * - https://github.com/owner/repo\n * - git://github.com/owner/repo.git\n * - https://github.com/owner/repo/tree/main\n * - git@github.com:owner/repo.git\n * - github:owner/repo\n */\nfunction parseGitHubUrl(url: string): string | null {\n\tconst cleaned = url\n\t\t.trim()\n\t\t.replace(/^git\\+/, \"\")\n\t\t.split(\"#\")[0]\n\t\t?.split(\"?\")[0]\n\t\t?.trim();\n\n\tif (!cleaned) return null;\n\n\tconst patterns = [\n\t\t/github\\.com[/:]([\\w.-]+)\\/([\\w.-]+)(?:\\.git)?(?:[/?#].*)?$/,\n\t\t/^github:([\\w.-]+)\\/([\\w.-]+)(?:[/?#].*)?$/,\n\t];\n\n\tfor (const pattern of patterns) {\n\t\tconst match = cleaned.match(pattern);\n\t\tif (match) {\n\t\t\tconst owner = match[1];\n\t\t\tconst repo = match[2]?.replace(/\\.git$/i, \"\");\n\t\t\tif (!owner || !repo) return null;\n\t\t\treturn `${owner}/${repo}`;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction resolveFromSpec(spec?: string): string | null {\n\tif (!spec) return null;\n\n\tconst trimmed = spec.trim();\n\tif (!trimmed) return null;\n\n\tconst isGitSpec =\n\t\ttrimmed.startsWith(\"github:\") ||\n\t\ttrimmed.startsWith(\"git+\") ||\n\t\ttrimmed.startsWith(\"git://\") ||\n\t\ttrimmed.startsWith(\"https://\") ||\n\t\ttrimmed.startsWith(\"http://\") ||\n\t\ttrimmed.startsWith(\"ssh://\") ||\n\t\ttrimmed.startsWith(\"git@\");\n\n\tif (!isGitSpec) return null;\n\n\treturn parseGitHubUrl(trimmed);\n}\n\nasync function fetchNpmPackage(\n\tpackageName: string,\n\ttimeoutMs = DEFAULT_NPM_FETCH_TIMEOUT_MS,\n): Promise<{\n\trepository?: string | { url?: string };\n\tkeywords?: string[];\n} | null> {\n\tconst controller = new AbortController();\n\tconst timeoutId = setTimeout(() => controller.abort(), timeoutMs);\n\n\ttry {\n\t\tconst res = await fetch(`https://registry.npmjs.org/${packageName}`, {\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tif (!res.ok) return null;\n\n\t\tconst json = await res.json();\n\t\tconst result = NpmPackageResponseSchema.safeParse(json);\n\t\tif (!result.success) return null;\n\n\t\treturn result.data;\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\tclearTimeout(timeoutId);\n\t}\n}\n\n/**\n * Fallback to npm registry to extract repository.url.\n * Returns null if package not found, no repo field, or not a GitHub repo.\n */\nexport async function resolveFromNpm(packageName: string, timeoutMs?: number): Promise<string | null> {\n\tconst pkg = await fetchNpmPackage(packageName, timeoutMs);\n\tif (!pkg?.repository) return null;\n\n\tconst repoUrl = typeof pkg.repository === \"string\" ? pkg.repository : pkg.repository.url;\n\tif (!repoUrl) return null;\n\n\treturn parseGitHubUrl(repoUrl);\n}\n\nexport async function getNpmKeywords(packageName: string): Promise<string[]> {\n\tconst pkg = await fetchNpmPackage(packageName);\n\tif (!pkg?.keywords || pkg.keywords.length === 0) return [];\n\n\tconst seen = new Set<string>();\n\tfor (const keyword of pkg.keywords) {\n\t\tconst normalized = keyword.trim().toLowerCase();\n\t\tif (normalized.length < 2) continue;\n\t\tseen.add(normalized);\n\t}\n\n\treturn Array.from(seen);\n}\n\n/**\n * Resolution order:\n * 1. Parse repo from dependency spec (git/https/github shorthand)\n * 2. Query npm registry for repository.url\n * 3. Check FALLBACK_MAPPINGS for packages missing repository field\n * 4. Return unknown\n */\nexport async function resolveDependencyRepo(\n\tdep: string,\n\tspec?: string,\n\toptions: ResolveDependencyRepoOptions = {},\n): Promise<ResolvedDep> {\n\tconst { allowNpm = true, npmTimeoutMs } = options;\n\n\tconst specRepo = resolveFromSpec(spec);\n\tif (specRepo) {\n\t\treturn { dep, repo: specRepo, source: \"spec\" };\n\t}\n\n\tif (allowNpm) {\n\t\tconst npmRepo = await resolveFromNpm(dep, npmTimeoutMs);\n\t\tif (npmRepo) {\n\t\t\treturn { dep, repo: npmRepo, source: \"npm\" };\n\t\t}\n\n\t\tif (dep in FALLBACK_MAPPINGS) {\n\t\t\treturn { dep, repo: FALLBACK_MAPPINGS[dep] ?? null, source: \"fallback\" };\n\t\t}\n\t}\n\n\treturn { dep, repo: null, source: \"unknown\" };\n}\n","import {\n\tmkdirSync,\n\twriteFileSync,\n\treadFileSync,\n\tlstatSync,\n\tunlinkSync,\n\trmSync,\n\tsymlinkSync,\n\texistsSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport { loadConfig, toMetaDirName, toReferenceFileName } from \"./config.js\";\nimport { agents } from \"./agents.js\";\nimport { expandTilde, Paths } from \"./paths.js\";\nimport { readGlobalMap, writeGlobalMap } from \"./index-manager.js\";\nimport { getNpmKeywords } from \"./dep-mappings.js\";\n\nconst PackageJsonNameSchema = z.object({\n\tname: z.string().optional(),\n});\n\nexport interface InstallReferenceMeta {\n\t/** ISO timestamp when the reference was generated */\n\treferenceUpdatedAt: string;\n\t/** Git commit SHA at time of generation */\n\tcommitSha: string;\n\t/** SDK version used for generation */\n\tversion: string;\n}\n\nfunction normalizeKeywords(values: string[]): string[] {\n\tconst seen = new Set<string>();\n\tfor (const value of values) {\n\t\tconst normalized = value.trim().toLowerCase();\n\t\tif (normalized.length < 2) continue;\n\t\tseen.add(normalized);\n\t}\n\treturn Array.from(seen);\n}\n\nfunction deriveMinimalKeywords(fullName: string): string[] {\n\tconst normalized = fullName.trim().toLowerCase();\n\tif (!normalized) return [];\n\n\tconst repoName = normalized.split(\"/\").pop() ?? normalized;\n\treturn normalizeKeywords([normalized, repoName]);\n}\n\nfunction getPackageName(localPath: string): string | null {\n\tconst packageJsonPath = join(localPath, \"package.json\");\n\tif (!existsSync(packageJsonPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\tconst json = JSON.parse(content);\n\t\tconst parsed = PackageJsonNameSchema.safeParse(json);\n\t\tif (!parsed.success || !parsed.data.name) return null;\n\t\treturn parsed.data.name;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Resolve keywords with npm-first strategy.\n * - npm package: package name + npm keywords\n * - non-npm package: minimal repo-derived keywords\n */\nexport async function resolveReferenceKeywords(\n\tfullName: string,\n\tlocalPath: string,\n): Promise<string[]> {\n\tconst packageName = getPackageName(localPath);\n\tif (!packageName) {\n\t\treturn deriveMinimalKeywords(fullName);\n\t}\n\n\tconst npmKeywords = await getNpmKeywords(packageName);\n\tif (npmKeywords.length > 0) {\n\t\treturn normalizeKeywords([packageName, ...npmKeywords]);\n\t}\n\n\treturn normalizeKeywords([packageName]);\n}\n\n/**\n * Ensure a symlink exists, removing any existing file/directory at the path\n */\nfunction ensureSymlink(target: string, linkPath: string): void {\n\ttry {\n\t\tconst stat = lstatSync(linkPath);\n\t\tif (stat.isSymbolicLink()) {\n\t\t\tunlinkSync(linkPath);\n\t\t} else if (stat.isDirectory()) {\n\t\t\trmSync(linkPath, { recursive: true });\n\t\t} else {\n\t\t\tunlinkSync(linkPath);\n\t\t}\n\t} catch {}\n\n\tconst linkDir = join(linkPath, \"..\");\n\tmkdirSync(linkDir, { recursive: true });\n\tsymlinkSync(target, linkPath, \"dir\");\n}\n\n/**\n * Static template for the global SKILL.md file.\n * This is the single routing skill that all agents see.\n */\nconst GLOBAL_SKILL_TEMPLATE = `---\nname: offworld\ndescription: Routes queries to Offworld reference files. Find and read per-repo references for dependency knowledge.\nallowed-tools: Bash(ow:*) Read\n---\n\n# Offworld Reference Router\n\nUse \\`ow\\` to locate and read Offworld reference files for dependencies.\n\n## What This Does\n\n- Finds references for libraries and repos\n- Returns paths for reference files and local clones\n- Helps you read the right context fast\n\n## When to Use\n\n- You need docs or patterns for a dependency\n- You want the verified reference instead of web search\n- You are about to work inside a repo clone\n\n## Installation and Setup\n\nIf Offworld CLI or opencode is missing, read \\`references/installation.md\\` in this skill directory and follow it.\n\n## Usage\n\n**Find a reference:**\n\\`\\`\\`bash\now map search <term> # search by name or keyword\now map show <repo> # get info for specific repo\n\\`\\`\\`\n\n**Get paths for tools:**\n\\`\\`\\`bash\now map show <repo> --ref # reference file path (use with Read)\now map show <repo> --path # clone directory path\n\\`\\`\\`\n\n**Example workflow:**\n\\`\\`\\`bash\n# 1. Find the repo\now map search zod\n\n# 2. Get reference path\now map show colinhacks/zod --ref\n# Output: /Users/.../.local/share/offworld/skill/offworld/references/colinhacks-zod.md\n\n# 3. Read the reference with the path from step 2\n\\`\\`\\`\n\n## If Reference Not Found\n\n\\`\\`\\`bash\now pull <owner/repo> # clone + generate reference\now project init # scan project deps, install references\n\\`\\`\\`\n\n## Notes\n\n- Project map (\\`.offworld/map.json\\`) takes precedence over global map when present\n- Reference files are markdown with API docs, patterns, best practices\n- Clone paths useful for exploring source code after reading reference\n\n## Additional Resources\n\n- Docs: https://offworld.sh/cli\n`;\n\nconst INSTALLATION_REFERENCE_TEMPLATE = `# Offworld Installation\n\nUse this when Offworld CLI or opencode is not installed.\n\n## 1) Check opencode\n\n\\`\\`\\`bash\nopencode --version\n\\`\\`\\`\n\nIf missing:\n\n\\`\\`\\`bash\ncurl -fsSL https://opencode.ai/install | bash\n\\`\\`\\`\n\n## 2) Check Offworld CLI\n\n\\`\\`\\`bash\now --version\n\\`\\`\\`\n\nIf missing:\n\n\\`\\`\\`bash\ncurl -fsSL https://offworld.sh/install | bash\n\\`\\`\\`\n\n## 3) Initialize Offworld (non-interactive)\n\n\\`\\`\\`bash\now init --yes --agents \"<agent-list>\" --repo-root \"<clone-dir>\" --model \"<provider/model>\"\n\\`\\`\\`\n\nExample:\n\n\\`\\`\\`bash\now init --yes --agents \"opencode,codex\" --repo-root \"~/ow\" --model \"anthropic/claude-sonnet-4-20250514\"\n\\`\\`\\`\n\n## 4) Initialize current project\n\n\\`\\`\\`bash\now project init --yes --all --generate\n\\`\\`\\`\n\n## 5) Verify\n\n\\`\\`\\`bash\now config show\now list\n\\`\\`\\`\n`;\n\n/**\n * Ensures the global SKILL.md exists and symlinks the offworld/ directory to all agent skill directories.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/SKILL.md (static routing template)\n * - ~/.local/share/offworld/skill/offworld/assets/ (for map.json)\n * - ~/.local/share/offworld/skill/offworld/references/ (for reference files)\n * - Symlinks entire offworld/ directory to each agent's skill directory\n */\nexport function installGlobalSkill(): void {\n\tconst config = loadConfig();\n\n\tmkdirSync(Paths.offworldSkillDir, { recursive: true });\n\tmkdirSync(Paths.offworldAssetsDir, { recursive: true });\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\n\tconst skillPath = join(Paths.offworldSkillDir, \"SKILL.md\");\n\tif (!existsSync(skillPath)) {\n\t\twriteFileSync(skillPath, GLOBAL_SKILL_TEMPLATE, \"utf-8\");\n\t}\n\n\tconst installationReferencePath = join(Paths.offworldReferencesDir, \"installation.md\");\n\tif (!existsSync(installationReferencePath)) {\n\t\twriteFileSync(installationReferencePath, INSTALLATION_REFERENCE_TEMPLATE, \"utf-8\");\n\t}\n\n\tconst configuredAgents = config.agents ?? [];\n\tfor (const agentName of configuredAgents) {\n\t\tconst agentConfig = agents[agentName];\n\t\tif (agentConfig) {\n\t\t\tconst agentSkillDir = expandTilde(join(agentConfig.globalSkillsDir, \"offworld\"));\n\t\t\tensureSymlink(Paths.offworldSkillDir, agentSkillDir);\n\t\t}\n\t}\n}\n\n/**\n * Install a reference file for a specific repository.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/references/{owner-repo}.md\n * - ~/.local/share/offworld/meta/{owner-repo}/meta.json\n * - Updates global map with reference info\n *\n * @param qualifiedName - Qualified key for map storage (e.g., \"github.com:owner/repo\" or \"local:name\")\n * @param fullName - Full repo name for file naming (e.g., \"owner/repo\")\n * @param localPath - Absolute path to the cloned repository\n * @param referenceContent - The generated reference markdown content\n * @param meta - Metadata about the generation (referenceUpdatedAt, commitSha, version)\n * @param keywords - Optional array of keywords for search/routing\n */\nexport function installReference(\n\tqualifiedName: string,\n\tfullName: string,\n\tlocalPath: string,\n\treferenceContent: string,\n\tmeta: InstallReferenceMeta,\n\tkeywords?: string[],\n): void {\n\tinstallGlobalSkill();\n\n\tconst referenceFileName = toReferenceFileName(fullName);\n\tconst metaDirName = toMetaDirName(fullName);\n\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\twriteFileSync(referencePath, referenceContent, \"utf-8\");\n\n\tconst metaDir = join(Paths.metaDir, metaDirName);\n\tmkdirSync(metaDir, { recursive: true });\n\tconst metaJson = JSON.stringify(meta, null, 2);\n\twriteFileSync(join(metaDir, \"meta.json\"), metaJson, \"utf-8\");\n\n\tconst map = readGlobalMap();\n\tconst existingEntry = map.repos[qualifiedName];\n\tconst legacyProviderMap: Record<string, string> = {\n\t\t\"github.com\": \"github\",\n\t\t\"gitlab.com\": \"gitlab\",\n\t\t\"bitbucket.org\": \"bitbucket\",\n\t};\n\tconst [host] = qualifiedName.split(\":\");\n\tconst legacyProvider = host ? legacyProviderMap[host] : undefined;\n\tconst legacyQualifiedName = legacyProvider ? `${legacyProvider}:${fullName}` : undefined;\n\tconst legacyEntry = legacyQualifiedName ? map.repos[legacyQualifiedName] : undefined;\n\n\tconst references = [...(existingEntry?.references ?? []), ...(legacyEntry?.references ?? [])];\n\tif (!references.includes(referenceFileName)) {\n\t\treferences.push(referenceFileName);\n\t}\n\n\tconst derivedKeywords =\n\t\tkeywords && keywords.length > 0 ? keywords : deriveMinimalKeywords(fullName);\n\n\tmap.repos[qualifiedName] = {\n\t\tlocalPath,\n\t\treferences,\n\t\tprimary: referenceFileName,\n\t\tkeywords: normalizeKeywords(derivedKeywords),\n\t\tupdatedAt: new Date().toISOString(),\n\t};\n\n\tif (legacyQualifiedName && legacyQualifiedName in map.repos) {\n\t\tdelete map.repos[legacyQualifiedName];\n\t}\n\n\twriteGlobalMap(map);\n}\n","/**\n * Dependency manifest parsing for multiple package ecosystems\n */\n\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport type ManifestType = \"npm\" | \"python\" | \"rust\" | \"go\" | \"unknown\";\n\nexport interface Dependency {\n\tname: string;\n\tversion?: string;\n\tdev: boolean;\n}\n\nconst DEFAULT_IGNORED_DIRS = new Set([\n\t\".git\",\n\t\".offworld\",\n\t\".turbo\",\n\t\"build\",\n\t\"dist\",\n\t\"node_modules\",\n\t\"out\",\n]);\n\n/**\n * Detects the manifest type in a directory\n */\nexport function detectManifestType(dir: string): ManifestType {\n\tif (existsSync(join(dir, \"package.json\"))) return \"npm\";\n\tif (existsSync(join(dir, \"pyproject.toml\"))) return \"python\";\n\tif (existsSync(join(dir, \"Cargo.toml\"))) return \"rust\";\n\tif (existsSync(join(dir, \"go.mod\"))) return \"go\";\n\tif (existsSync(join(dir, \"requirements.txt\"))) return \"python\";\n\treturn \"unknown\";\n}\n\n/**\n * Parses dependencies from manifest files\n */\nexport function parseDependencies(dir: string): Dependency[] {\n\tconst type = detectManifestType(dir);\n\n\tswitch (type) {\n\t\tcase \"npm\":\n\t\t\treturn parseNpmDependencies(dir);\n\t\tcase \"python\":\n\t\t\treturn existsSync(join(dir, \"pyproject.toml\"))\n\t\t\t\t? parsePyprojectToml(join(dir, \"pyproject.toml\"))\n\t\t\t\t: parseRequirementsTxt(join(dir, \"requirements.txt\"));\n\t\tcase \"rust\":\n\t\t\treturn parseCargoToml(join(dir, \"Cargo.toml\"));\n\t\tcase \"go\":\n\t\t\treturn parseGoMod(join(dir, \"go.mod\"));\n\t\tdefault:\n\t\t\treturn [];\n\t}\n}\n\nfunction parseNpmDependencies(dir: string): Dependency[] {\n\tconst rootPath = join(dir, \"package.json\");\n\tconst rootDeps = parsePackageJson(rootPath);\n\tconst workspaceDeps = parseWorkspaceDependencies(dir);\n\treturn mergeDependencies(rootDeps, workspaceDeps).sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction parseWorkspaceDependencies(dir: string): Dependency[] {\n\tconst workspacePatterns = getWorkspacePatterns(dir);\n\tif (workspacePatterns.length === 0) return [];\n\n\tconst packageJsonPaths = resolveWorkspacePackageJsonPaths(dir, workspacePatterns);\n\tconst deps: Dependency[] = [];\n\tfor (const path of packageJsonPaths) {\n\t\tdeps.push(...parsePackageJson(path));\n\t}\n\n\treturn mergeDependencies([], deps);\n}\n\nfunction getWorkspacePatterns(dir: string): string[] {\n\tconst patterns = new Set<string>();\n\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\tconst rootJson = readJson(packageJsonPath);\n\t\tconst workspaces = rootJson?.workspaces;\n\t\tif (Array.isArray(workspaces)) {\n\t\t\tfor (const pattern of workspaces) {\n\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t}\n\t\t} else if (workspaces && typeof workspaces === \"object\") {\n\t\t\tconst packagesField = (workspaces as { packages?: unknown }).packages;\n\t\t\tif (Array.isArray(packagesField)) {\n\t\t\t\tfor (const pattern of packagesField) {\n\t\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst pnpmWorkspacePath = existsSync(join(dir, \"pnpm-workspace.yaml\"))\n\t\t? join(dir, \"pnpm-workspace.yaml\")\n\t\t: existsSync(join(dir, \"pnpm-workspace.yml\"))\n\t\t\t? join(dir, \"pnpm-workspace.yml\")\n\t\t\t: null;\n\n\tif (pnpmWorkspacePath) {\n\t\tfor (const pattern of parsePnpmWorkspacePackages(pnpmWorkspacePath)) {\n\t\t\tpatterns.add(pattern);\n\t\t}\n\t}\n\n\treturn Array.from(patterns);\n}\n\nfunction resolveWorkspacePackageJsonPaths(dir: string, patterns: string[]): string[] {\n\tconst includePatterns = patterns.filter((pattern) => !pattern.startsWith(\"!\"));\n\tconst excludePatterns = patterns\n\t\t.filter((pattern) => pattern.startsWith(\"!\"))\n\t\t.map((pattern) => pattern.slice(1));\n\n\tif (includePatterns.length === 0) return [];\n\n\tconst includeRegexes = includePatterns.map(patternToRegex);\n\tconst excludeRegexes = excludePatterns.map(patternToRegex);\n\n\tconst matches: string[] = [];\n\tconst directories = walkDirectories(dir);\n\n\tfor (const relativePath of directories) {\n\t\tif (!includeRegexes.some((regex) => regex.test(relativePath))) continue;\n\t\tif (excludeRegexes.some((regex) => regex.test(relativePath))) continue;\n\n\t\tconst packageJsonPath = join(dir, relativePath, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tmatches.push(packageJsonPath);\n\t\t}\n\t}\n\n\treturn Array.from(new Set(matches));\n}\n\nfunction walkDirectories(root: string): string[] {\n\tconst results: string[] = [];\n\tconst stack: string[] = [\"\"];\n\n\twhile (stack.length > 0) {\n\t\tconst relativePath = stack.pop();\n\t\tconst currentPath = relativePath ? join(root, relativePath) : root;\n\n\t\tlet entries: Dirent[];\n\t\ttry {\n\t\t\tentries = readdirSync(currentPath, { withFileTypes: true }) as Dirent[];\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory()) continue;\n\t\t\tif (DEFAULT_IGNORED_DIRS.has(entry.name)) continue;\n\n\t\t\tconst nextRelative = relativePath ? `${relativePath}/${entry.name}` : entry.name;\n\t\t\tresults.push(nextRelative);\n\t\t\tstack.push(nextRelative);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction patternToRegex(pattern: string): RegExp {\n\tlet normalized = pattern.trim().replace(/\\\\/g, \"/\");\n\tif (normalized.startsWith(\"./\")) normalized = normalized.slice(2);\n\tif (normalized.endsWith(\"/\")) normalized = normalized.slice(0, -1);\n\n\tconst escaped = normalized.replace(/[.+^${}()|[\\]\\\\*]/g, \"\\\\$&\");\n\tconst withGlob = escaped.replace(/\\\\\\*\\\\\\*/g, \".*\").replace(/\\\\\\*/g, \"[^/]+\");\n\n\treturn new RegExp(`^${withGlob}$`);\n}\n\nfunction parsePnpmWorkspacePackages(path: string): string[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst patterns: string[] = [];\n\t\tlet inPackages = false;\n\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tif (/^packages\\s*:/.test(trimmed)) {\n\t\t\t\tinPackages = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!inPackages) continue;\n\n\t\t\tconst entryMatch = trimmed.match(/^-\\s*(.+)$/);\n\t\t\tif (entryMatch?.[1]) {\n\t\t\t\tconst value = entryMatch[1].trim().replace(/^['\"]|['\"]$/g, \"\");\n\t\t\t\tif (value) patterns.push(value);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!line.startsWith(\" \") && !line.startsWith(\"\\t\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn patterns;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nfunction readJson(path: string): Record<string, unknown> | null {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\treturn JSON.parse(content) as Record<string, unknown>;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction mergeDependencies(base: Dependency[], incoming: Dependency[]): Dependency[] {\n\tconst map = new Map<string, Dependency>();\n\n\tfor (const dep of [...base, ...incoming]) {\n\t\tconst existing = map.get(dep.name);\n\t\tif (!existing) {\n\t\t\tmap.set(dep.name, { ...dep });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst dev = existing.dev && dep.dev;\n\t\tconst version = existing.version ?? dep.version;\n\t\tmap.set(dep.name, { name: dep.name, version, dev });\n\t}\n\n\treturn Array.from(map.values());\n}\n\n/**\n * Parse package.json dependencies\n */\nfunction parsePackageJson(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst pkg = JSON.parse(content);\n\t\tconst deps: Dependency[] = [];\n\n\t\tif (pkg.dependencies && typeof pkg.dependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.dependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.devDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: true });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.peerDependencies && typeof pkg.peerDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.peerDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.optionalDependencies && typeof pkg.optionalDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.optionalDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse pyproject.toml dependencies\n */\nfunction parsePyprojectToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[project\\.dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/[\"']([a-zA-Z0-9_-]+)(?:[>=<~!]+([^\"']+))?[\"']/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse Cargo.toml dependencies\n */\nfunction parseCargoToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst simpleMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*\"([^\"]+)\"/);\n\t\t\tconst tableMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*{.*version\\s*=\\s*\"([^\"]+)\"/);\n\n\t\t\tif (simpleMatch?.[1] && simpleMatch[2]) {\n\t\t\t\tdeps.push({ name: simpleMatch[1], version: simpleMatch[2], dev: false });\n\t\t\t} else if (tableMatch?.[1] && tableMatch[2]) {\n\t\t\t\tdeps.push({ name: tableMatch[1], version: tableMatch[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse go.mod dependencies\n */\nfunction parseGoMod(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst requireSection = content.match(/require\\s*\\(([\\s\\S]*?)\\)/);\n\t\tif (!requireSection?.[1]) {\n\t\t\tconst singleRequire = content.match(/require\\s+([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (singleRequire?.[1] && singleRequire[2]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: singleRequire[1],\n\t\t\t\t\tversion: singleRequire[2],\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn deps;\n\t\t}\n\n\t\tconst lines = requireSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/^\\s*([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (match?.[1] && match[2]) {\n\t\t\t\tdeps.push({ name: match[1], version: match[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse requirements.txt dependencies\n */\nfunction parseRequirementsTxt(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst lines = content.split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tconst match = trimmed.match(/^([a-zA-Z0-9_-]+)(?:[>=<~!]+(.+))?/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n","/**\n * Reference matching utilities for dependency resolution\n *\n * Maps dependencies to their reference status (installed, remote, generate, unknown)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\nimport type { ResolvedDep } from \"./dep-mappings.js\";\n\nexport type ReferenceStatus = \"installed\" | \"remote\" | \"generate\" | \"unknown\";\n\nexport interface ReferenceMatch {\n\t/** Dependency name */\n\tdep: string;\n\t/** GitHub repo (owner/repo) or null if unknown */\n\trepo: string | null;\n\t/** Reference availability status */\n\tstatus: ReferenceStatus;\n\t/** Resolution source: 'spec' | 'npm' | 'fallback' | 'unknown' */\n\tsource: \"spec\" | \"npm\" | \"fallback\" | \"unknown\";\n}\n\n/**\n * Check if a reference is installed locally.\n * A reference is considered installed if {owner-repo}.md exists in offworld/references/.\n *\n * @param repo - Repo name in owner/repo format\n * @returns true if reference is installed locally\n */\nexport function isReferenceInstalled(repo: string): boolean {\n\tconst referenceFileName = toReferenceFileName(repo);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\treturn existsSync(referencePath);\n}\n\n/**\n * Match dependencies to their reference availability status.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Array of reference matches with status\n */\nexport function matchDependenciesToReferences(resolvedDeps: ResolvedDep[]): ReferenceMatch[] {\n\treturn resolvedDeps.map((dep) => {\n\t\tif (!dep.repo) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: null,\n\t\t\t\tstatus: \"unknown\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: dep.repo,\n\t\t\t\tstatus: \"installed\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tdep: dep.dep,\n\t\t\trepo: dep.repo,\n\t\t\tstatus: \"generate\",\n\t\t\tsource: dep.source,\n\t\t};\n\t});\n}\n\n/**\n * Match dependencies to their reference availability status with remote check.\n * This is async because it checks the remote server for each dependency.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Promise of array of reference matches with status\n */\nexport async function matchDependenciesToReferencesWithRemoteCheck(\n\tresolvedDeps: ResolvedDep[],\n): Promise<ReferenceMatch[]> {\n\tconst { checkRemote } = await import(\"./sync.js\");\n\tconst repoStatus = new Map<string, ReferenceStatus>();\n\n\tconst remoteChecks: Promise<void>[] = [];\n\tfor (const dep of resolvedDeps) {\n\t\tif (!dep.repo || repoStatus.has(dep.repo)) continue;\n\n\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\trepoStatus.set(dep.repo, \"installed\");\n\t\t\tcontinue;\n\t\t}\n\n\t\trepoStatus.set(dep.repo, \"generate\");\n\t\tremoteChecks.push(\n\t\t\t(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tconst remote = await checkRemote(dep.repo!);\n\t\t\t\t\tif (remote.exists) {\n\t\t\t\t\t\trepoStatus.set(dep.repo!, \"remote\");\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Network error - keep generate status\n\t\t\t\t}\n\t\t\t})(),\n\t\t);\n\t}\n\n\tawait Promise.all(remoteChecks);\n\n\treturn resolvedDeps.map((dep) => {\n\t\tif (!dep.repo) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: null,\n\t\t\t\tstatus: \"unknown\" as const,\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\tconst status = repoStatus.get(dep.repo) ?? \"generate\";\n\t\treturn {\n\t\t\tdep: dep.dep,\n\t\t\trepo: dep.repo,\n\t\t\tstatus,\n\t\t\tsource: dep.source,\n\t\t};\n\t});\n}\n","import { existsSync, statSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { updateRepo, GitError } from \"./clone.js\";\nimport { readGlobalMap, removeGlobalMapEntry, upsertGlobalMapEntry } from \"./index-manager.js\";\nimport { loadConfig, getRepoRoot } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\n\nexport interface RepoStatusSummary {\n\ttotal: number;\n\twithReference: number;\n\tmissing: number;\n\tdiskBytes: number;\n}\n\nexport interface RepoStatusOptions {\n\tonProgress?: (current: number, total: number, repo: string) => void;\n}\n\nexport interface UpdateAllOptions {\n\tpattern?: string;\n\tdryRun?: boolean;\n\t/** Convert shallow clones to full clones */\n\tunshallow?: boolean;\n\tonProgress?: (\n\t\trepo: string,\n\t\tstatus: \"updating\" | \"updated\" | \"skipped\" | \"error\" | \"unshallowed\",\n\t\tmessage?: string,\n\t) => void;\n}\n\nexport interface UpdateAllResult {\n\tupdated: string[];\n\tskipped: string[];\n\tunshallowed: string[];\n\terrors: Array<{ repo: string; error: string }>;\n}\n\nexport interface PruneOptions {\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string) => void;\n}\n\nexport interface PruneResult {\n\tremovedFromIndex: string[];\n\torphanedDirs: string[];\n}\n\nexport interface GcOptions {\n\tolderThanDays?: number;\n\twithoutReference?: boolean;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string, sizeBytes?: number) => void;\n}\n\nexport interface GcResult {\n\tremoved: Array<{ repo: string; reason: string; sizeBytes: number }>;\n\tfreedBytes: number;\n}\n\nfunction getDirSize(dirPath: string): number {\n\tif (!existsSync(dirPath)) return 0;\n\n\tlet size = 0;\n\ttry {\n\t\tconst entries = readdirSync(dirPath, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(dirPath, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tsize += getDirSize(fullPath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tsize += statSync(fullPath).size;\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn size;\n}\n\nfunction getLastAccessTime(dirPath: string): Date | null {\n\tif (!existsSync(dirPath)) return null;\n\n\tlet latestTime: Date | null = null;\n\ttry {\n\t\tconst stat = statSync(dirPath);\n\t\tlatestTime = stat.mtime;\n\n\t\tconst fetchHead = join(dirPath, \".git\", \"FETCH_HEAD\");\n\t\tif (existsSync(fetchHead)) {\n\t\t\tconst fetchStat = statSync(fetchHead);\n\t\t\tif (!latestTime || fetchStat.mtime > latestTime) {\n\t\t\t\tlatestTime = fetchStat.mtime;\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn latestTime;\n}\n\nfunction matchesPattern(name: string, pattern: string): boolean {\n\tif (!pattern || pattern === \"*\") return true;\n\n\tconst regex = new RegExp(\n\t\t\"^\" +\n\t\t\tpattern\n\t\t\t\t.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\t\t\t\t.replace(/\\*/g, \".*\")\n\t\t\t\t.replace(/\\?/g, \".\") +\n\t\t\t\"$\",\n\t\t\"i\",\n\t);\n\treturn regex.test(name);\n}\n\nconst yieldToEventLoop = () => new Promise<void>((resolve) => setImmediate(resolve));\n\nexport async function getRepoStatus(options: RepoStatusOptions = {}): Promise<RepoStatusSummary> {\n\tconst { onProgress } = options;\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst total = qualifiedNames.length;\n\n\tlet withReference = 0;\n\tlet missing = 0;\n\tlet diskBytes = 0;\n\n\tfor (let i = 0; i < qualifiedNames.length; i++) {\n\t\tconst qualifiedName = qualifiedNames[i]!;\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tonProgress?.(i + 1, total, qualifiedName);\n\n\t\tawait yieldToEventLoop();\n\n\t\tconst exists = existsSync(entry.localPath);\n\n\t\tif (!exists) {\n\t\t\tmissing++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.references.length > 0) {\n\t\t\twithReference++;\n\t\t}\n\n\t\tdiskBytes += getDirSize(entry.localPath);\n\t}\n\n\treturn {\n\t\ttotal,\n\t\twithReference,\n\t\tmissing,\n\t\tdiskBytes,\n\t};\n}\n\nexport async function updateAllRepos(options: UpdateAllOptions = {}): Promise<UpdateAllResult> {\n\tconst { pattern, dryRun = false, unshallow = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst updated: string[] = [];\n\tconst skipped: string[] = [];\n\tconst unshallowed: string[] = [];\n\tconst errors: Array<{ repo: string; error: string }> = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\n\t\tif (pattern && !matchesPattern(qualifiedName, pattern)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tskipped.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"skipped\", \"missing on disk\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tupdated.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"updated\", \"would update\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tonProgress?.(qualifiedName, \"updating\");\n\t\ttry {\n\t\t\tconst result = await updateRepo(qualifiedName, { unshallow });\n\t\t\tif (result.unshallowed) {\n\t\t\t\tunshallowed.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"unshallowed\", \"converted to full clone\");\n\t\t\t}\n\t\t\tif (result.updated) {\n\t\t\t\tupdated.push(qualifiedName);\n\t\t\t\tonProgress?.(\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\t\"updated\",\n\t\t\t\t\t`${result.previousSha.slice(0, 7)} → ${result.currentSha.slice(0, 7)}`,\n\t\t\t\t);\n\t\t\t} else if (!result.unshallowed) {\n\t\t\t\tskipped.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"skipped\", \"already up to date\");\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof GitError ? err.message : String(err);\n\t\t\terrors.push({ repo: qualifiedName, error: message });\n\t\t\tonProgress?.(qualifiedName, \"error\", message);\n\t\t}\n\t}\n\n\treturn { updated, skipped, unshallowed, errors };\n}\n\nexport async function pruneRepos(options: PruneOptions = {}): Promise<PruneResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removedFromIndex: string[] = [];\n\tconst orphanedDirs: string[] = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tonProgress?.(qualifiedName, \"missing on disk\");\n\t\t\tremovedFromIndex.push(qualifiedName);\n\n\t\t\tif (!dryRun) {\n\t\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst config = loadConfig();\n\tconst repoRoot = getRepoRoot(config);\n\n\tif (existsSync(repoRoot)) {\n\t\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\t\ttry {\n\t\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\t\tfor (const provider of providers) {\n\t\t\t\tif (!provider.isDirectory()) continue;\n\t\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\t\tfor (const owner of owners) {\n\t\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\t\tif (!indexedPaths.has(repoPath)) {\n\t\t\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\t\t\tonProgress?.(fullName, \"not in map\");\n\t\t\t\t\t\t\torphanedDirs.push(repoPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\treturn { removedFromIndex, orphanedDirs };\n}\n\nexport async function gcRepos(options: GcOptions = {}): Promise<GcResult> {\n\tconst { olderThanDays, withoutReference = false, dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removed: Array<{ repo: string; reason: string; sizeBytes: number }> = [];\n\tlet freedBytes = 0;\n\n\tconst now = new Date();\n\tconst cutoffDate = olderThanDays\n\t\t? new Date(now.getTime() - olderThanDays * 24 * 60 * 60 * 1000)\n\t\t: null;\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) continue;\n\n\t\tlet shouldRemove = false;\n\t\tlet reason = \"\";\n\n\t\tif (cutoffDate) {\n\t\t\tconst lastAccess = getLastAccessTime(entry.localPath);\n\t\t\tif (lastAccess && lastAccess < cutoffDate) {\n\t\t\t\tshouldRemove = true;\n\t\t\t\treason = `not accessed in ${olderThanDays}+ days`;\n\t\t\t}\n\t\t}\n\n\t\tif (withoutReference && entry.references.length === 0) {\n\t\t\tshouldRemove = true;\n\t\t\treason = reason ? `${reason}, no reference` : \"no reference\";\n\t\t}\n\n\t\tif (!shouldRemove) continue;\n\n\t\tconst sizeBytes = getDirSize(entry.localPath);\n\t\tonProgress?.(qualifiedName, reason, sizeBytes);\n\n\t\tif (!dryRun) {\n\t\t\trmSync(entry.localPath, { recursive: true, force: true });\n\n\t\t\tfor (const refFile of entry.references) {\n\t\t\t\tconst refPath = join(Paths.offworldReferencesDir, refFile);\n\t\t\t\tif (existsSync(refPath)) {\n\t\t\t\t\trmSync(refPath, { force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (entry.primary) {\n\t\t\t\tconst metaDirName = entry.primary.replace(/\\.md$/, \"\");\n\t\t\t\tconst metaPath = join(Paths.metaDir, metaDirName);\n\t\t\t\tif (existsSync(metaPath)) {\n\t\t\t\t\trmSync(metaPath, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t}\n\n\t\tremoved.push({ repo: qualifiedName, reason, sizeBytes });\n\t\tfreedBytes += sizeBytes;\n\t}\n\n\treturn { removed, freedBytes };\n}\n\nexport interface DiscoverOptions {\n\trepoRoot?: string;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, provider: string) => void;\n}\n\nexport interface DiscoverResult {\n\tdiscovered: Array<{ fullName: string; qualifiedName: string; localPath: string }>;\n\talreadyIndexed: number;\n}\n\nexport async function discoverRepos(options: DiscoverOptions = {}): Promise<DiscoverResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst config = loadConfig();\n\tconst repoRoot = options.repoRoot ?? getRepoRoot(config);\n\tconst discovered: Array<{ fullName: string; qualifiedName: string; localPath: string }> = [];\n\tlet alreadyIndexed = 0;\n\n\tif (!existsSync(repoRoot)) {\n\t\treturn { discovered, alreadyIndexed };\n\t}\n\n\tconst map = readGlobalMap();\n\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\ttry {\n\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\tfor (const provider of providers) {\n\t\t\tif (!provider.isDirectory()) continue;\n\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\tconst providerHostMap: Record<string, string> = {\n\t\t\t\tgithub: \"github.com\",\n\t\t\t\tgitlab: \"gitlab.com\",\n\t\t\t\tbitbucket: \"bitbucket.org\",\n\t\t\t};\n\t\t\tconst providerHost = providerHostMap[provider.name] ?? provider.name;\n\n\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\tfor (const owner of owners) {\n\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\tif (indexedPaths.has(repoPath)) {\n\t\t\t\t\t\talreadyIndexed++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\tconst qualifiedName = `${providerHost}:${fullName}`;\n\n\t\t\t\t\tonProgress?.(fullName, providerHost);\n\n\t\t\t\t\tif (!dryRun) {\n\t\t\t\t\t\tupsertGlobalMapEntry(qualifiedName, {\n\t\t\t\t\t\t\tlocalPath: repoPath,\n\t\t\t\t\t\t\treferences: [],\n\t\t\t\t\t\t\tprimary: \"\",\n\t\t\t\t\t\t\tkeywords: [],\n\t\t\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tdiscovered.push({ fullName, qualifiedName, localPath: repoPath });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\n\treturn { discovered, alreadyIndexed };\n}\n","import { ModelsDevDataSchema, type ModelsDevProvider } from \"@offworld/types\";\n\nconst MODELS_DEV_URL = \"https://models.dev/api.json\";\n\n/**\n * Simplified provider info for CLI display\n */\nexport interface ProviderInfo {\n\tid: string;\n\tname: string;\n\tenv: string[];\n}\n\n/**\n * Simplified model info for CLI display\n */\nexport interface ModelInfo {\n\tid: string;\n\tname: string;\n\treasoning: boolean;\n\texperimental?: boolean;\n\tstatus?: \"alpha\" | \"beta\" | \"deprecated\";\n}\n\n/**\n * Full provider with models for CLI display\n */\nexport interface ProviderWithModels extends ProviderInfo {\n\tmodels: ModelInfo[];\n}\n\nlet cachedData: Record<string, ModelsDevProvider> | null = null;\nlet cacheTime = 0;\nconst CACHE_TTL_MS = 5 * 60 * 1000;\n\n/**\n * Fetch raw data from models.dev with caching\n */\nasync function fetchModelsDevData(): Promise<Record<string, ModelsDevProvider>> {\n\tconst now = Date.now();\n\tif (cachedData && now - cacheTime < CACHE_TTL_MS) {\n\t\treturn cachedData;\n\t}\n\n\tconst res = await fetch(MODELS_DEV_URL, {\n\t\tsignal: AbortSignal.timeout(10_000),\n\t});\n\n\tif (!res.ok) {\n\t\tthrow new Error(`Failed to fetch models.dev: ${res.status} ${res.statusText}`);\n\t}\n\n\tconst json = await res.json();\n\tconst parsed = ModelsDevDataSchema.safeParse(json);\n\tif (!parsed.success) {\n\t\tthrow new Error(`Invalid models.dev response: ${parsed.error.message}`);\n\t}\n\tcachedData = parsed.data;\n\tcacheTime = now;\n\treturn cachedData;\n}\n\n/**\n * List all available providers from models.dev\n */\nexport async function listProviders(): Promise<ProviderInfo[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Get a specific provider with all its models\n */\nexport async function getProvider(providerId: string): Promise<ProviderWithModels | null> {\n\tconst data = await fetchModelsDevData();\n\tconst provider = data[providerId];\n\n\tif (!provider) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tid: provider.id,\n\t\tname: provider.name,\n\t\tenv: provider.env ?? [],\n\t\tmodels: Object.values(provider.models)\n\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t.map((m) => ({\n\t\t\t\tid: m.id,\n\t\t\t\tname: m.name,\n\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\texperimental: m.experimental,\n\t\t\t\tstatus: m.status,\n\t\t\t}))\n\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t};\n}\n\n/**\n * Get all providers with their models\n */\nexport async function listProvidersWithModels(): Promise<ProviderWithModels[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t\tmodels: Object.values(p.models)\n\t\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t\t.map((m) => ({\n\t\t\t\t\tid: m.id,\n\t\t\t\t\tname: m.name,\n\t\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\t\texperimental: m.experimental,\n\t\t\t\t\tstatus: m.status,\n\t\t\t\t}))\n\t\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Validate that a provider/model combination exists\n */\nexport async function validateProviderModel(\n\tproviderId: string,\n\tmodelId: string,\n): Promise<{ valid: boolean; error?: string }> {\n\tconst provider = await getProvider(providerId);\n\n\tif (!provider) {\n\t\tconst providers = await listProviders();\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Provider \"${providerId}\" not found. Available: ${providers\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((p) => p.id)\n\t\t\t\t.join(\", \")}${providers.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\tconst model = provider.models.find((m) => m.id === modelId);\n\tif (!model) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Model \"${modelId}\" not found for provider \"${providerId}\". Available: ${provider.models\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((m) => m.id)\n\t\t\t\t.join(\", \")}${provider.models.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\treturn { valid: true };\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,UAAU;;;;;AAMvB,MAAa,0BAA0B;CACtC;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;;;;;;;ACjGD,IAAa,kBAAb,cAAqC,MAAM;CAC1C,YAAY,SAAiB;AAC5B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAId,IAAa,oBAAb,cAAuC,gBAAgB;CACtD,YAAY,MAAc;AACzB,QAAM,wBAAwB,OAAO;AACrC,OAAK,OAAO;;;AAId,IAAa,kBAAb,cAAqC,gBAAgB;CACpD,YAAY,MAAc;AACzB,QAAM,sCAAsC,OAAO;AACnD,OAAK,OAAO;;;AAId,MAAM,iBAA8C;CACnD,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB;AAED,MAAM,kBACL;AACD,MAAM,gBAAgB;AACtB,MAAM,qBAAqB;;;;AAK3B,SAAS,SAAS,MAAsB;AACvC,QAAO,WAAW,SAAS,CAAC,OAAO,KAAK,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,GAAG;;;;;AAMpE,SAAS,cAAc,UAAuB,OAAe,MAAsB;AAMlF,QAAO,WALoC;EAC1C,QAAQ;EACR,QAAQ;EACR,WAAW;EACX,CACuB,UAAU,GAAG,MAAM,GAAG,KAAK;;;;;AAMpD,SAAS,cAAc,OAAwC;CAC9D,MAAM,QAAQ,MA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