offworld 0.1.10 → 0.2.0
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/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as version, t as createOwCli } from "./src-
|
|
2
|
+
import { r as version, t as createOwCli } from "./src-CpQeGpVw.mjs";
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import * as trpc_cli_dist_json_js0 from "trpc-cli/dist/json.js";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
|
-
declare const version = "0.
|
|
7
|
+
declare const version = "0.2.0";
|
|
8
8
|
declare const router: {
|
|
9
9
|
pull: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, z.ZodObject<{
|
|
10
10
|
repo: z.ZodString;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;cA+Ba,OAAA;AAAA,cAEA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAugBG,WAAA,CAAA;0BAAW,SAAA,CAAA,gBAAA;;+
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;cA+Ba,OAAA;AAAA,cAEA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAugBG,WAAA,CAAA;0BAAW,SAAA,CAAA,gBAAA;;+BA5OX,oBAAA,KAAA,sBAAA,CAAA,WAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import { z } from "zod";
|
|
|
6
6
|
import * as p from "@clack/prompts";
|
|
7
7
|
import { AuthenticationError, CommitExistsError, CommitNotFoundError, GitHubError, InvalidInputError, InvalidReferenceError, LowStarsError, NotLoggedInError, Paths, PrivateRepoError, RateLimitError, RepoExistsError, SyncRepoNotFoundError, TokenExpiredError, checkRemote, checkRemoteByName, cleanShellConfig, clearAuthData, cloneRepo, detectInstallMethod, detectInstalledAgents, discoverRepos, executeUninstall, executeUpgrade, fetchLatestVersion, gcRepos, generateReferenceWithAI, getAllAgentConfigs, getAuthPath, getAuthStatus, getClonedRepoPath, getCommitDistance, getCommitSha, getConfigPath, getCurrentVersion, getMapEntry, getMetaPath, getMetaRoot, getProvider, getReferencePath, getRepoRoot, getRepoStatus, getShellConfigFiles, getToken, installGlobalSkill, installReference, isRepoCloned, listProviders, listRepos, loadAuthData, loadConfig, matchDependenciesToReferences, parseDependencies, parseRepoInput, pruneRepos, pullReference, pullReferenceByName, pushReference, readGlobalMap, removeRepo, resolveDependencyRepo, saveAuthData, saveConfig, searchMap, toReferenceFileName, toReferenceName, updateAgentFiles, updateAllRepos, updateRepo, validateProviderModel, writeProjectMap } from "@offworld/sdk";
|
|
8
8
|
import { ReferenceMetaSchema, WorkOSAuthErrorResponseSchema, WorkOSDeviceAuthResponseSchema, WorkOSTokenResponseSchema } from "@offworld/types";
|
|
9
|
+
import { homedir } from "node:os";
|
|
9
10
|
import { AgentSchema, ConfigSchema } from "@offworld/types/schemas";
|
|
10
11
|
import open from "open";
|
|
11
|
-
import { homedir } from "node:os";
|
|
12
12
|
|
|
13
13
|
//#region src/utils/spinner.ts
|
|
14
14
|
var NoOpSpinner = class {
|
|
@@ -38,6 +38,11 @@ const isTTY = process.stdout.isTTY ?? false;
|
|
|
38
38
|
function timestamp() {
|
|
39
39
|
return (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
40
40
|
}
|
|
41
|
+
function toTildePath(absolutePath) {
|
|
42
|
+
const home = homedir();
|
|
43
|
+
if (absolutePath.startsWith(home)) return "~" + absolutePath.slice(home.length);
|
|
44
|
+
return absolutePath;
|
|
45
|
+
}
|
|
41
46
|
function verboseLog(message, verbose) {
|
|
42
47
|
if (verbose) p.log.info(`[${timestamp()}] ${message}`);
|
|
43
48
|
}
|
|
@@ -176,7 +181,9 @@ async function pullHandler(options) {
|
|
|
176
181
|
if (remoteReference) {
|
|
177
182
|
s.stop("Downloaded remote reference");
|
|
178
183
|
saveRemoteReference(source.qualifiedName, source.fullName, repoPath, remoteReference.referenceContent, remoteReference.commitSha, remoteReference.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
179
|
-
|
|
184
|
+
const remoteReferenceFileName = toReferenceFileName(qualifiedName);
|
|
185
|
+
const remoteRelativePath = toTildePath(join(Paths.offworldReferencesDir, remoteReferenceFileName));
|
|
186
|
+
p.log.success(referenceName ? `Reference file (${referenceName}) at: ${remoteRelativePath}` : `Reference file at: ${remoteRelativePath}`);
|
|
180
187
|
return {
|
|
181
188
|
success: true,
|
|
182
189
|
repoPath,
|
|
@@ -208,7 +215,9 @@ async function pullHandler(options) {
|
|
|
208
215
|
model,
|
|
209
216
|
onDebug: verbose ? (message) => {
|
|
210
217
|
p.log.info(`[${timestamp()}] [debug] ${message}`);
|
|
211
|
-
} : (msg) =>
|
|
218
|
+
} : (msg) => {
|
|
219
|
+
if (!msg.startsWith("[")) s.message(msg);
|
|
220
|
+
}
|
|
212
221
|
});
|
|
213
222
|
const meta = {
|
|
214
223
|
referenceUpdatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -217,9 +226,11 @@ async function pullHandler(options) {
|
|
|
217
226
|
};
|
|
218
227
|
const referenceRepoName = source.type === "remote" ? source.fullName : source.name;
|
|
219
228
|
installReference(source.qualifiedName, referenceRepoName, repoPath, referenceContent, meta);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
229
|
+
const referenceFileName = toReferenceFileName(qualifiedName);
|
|
230
|
+
const relativePath = toTildePath(join(Paths.offworldReferencesDir, referenceFileName));
|
|
231
|
+
if (!verbose) s.stop("Reference file created");
|
|
232
|
+
else p.log.success("Reference file created");
|
|
233
|
+
p.log.success(`Reference file at: ${relativePath}`);
|
|
223
234
|
if (source.type === "remote") {
|
|
224
235
|
if (loadAuthData()?.token) p.log.info(`Run 'ow push ${source.fullName}' to share this reference to https://offworld.sh.`);
|
|
225
236
|
}
|
|
@@ -2155,7 +2166,7 @@ async function mapSearchHandler(options) {
|
|
|
2155
2166
|
|
|
2156
2167
|
//#endregion
|
|
2157
2168
|
//#region src/index.ts
|
|
2158
|
-
const version = "0.
|
|
2169
|
+
const version = "0.2.0";
|
|
2159
2170
|
const router = os.router({
|
|
2160
2171
|
pull: os.input(z.object({
|
|
2161
2172
|
repo: z.string().describe("repo").meta({ positional: true }),
|
|
@@ -2455,4 +2466,4 @@ function createOwCli() {
|
|
|
2455
2466
|
|
|
2456
2467
|
//#endregion
|
|
2457
2468
|
export { router as n, version as r, createOwCli as t };
|
|
2458
|
-
//# sourceMappingURL=src-
|
|
2469
|
+
//# sourceMappingURL=src-CpQeGpVw.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-CpQeGpVw.mjs","names":["parseModelFlag","detectProjectRoot"],"sources":["../src/utils/spinner.ts","../src/handlers/pull.ts","../src/handlers/generate.ts","../src/handlers/shared.ts","../src/handlers/repo.ts","../src/handlers/push.ts","../src/handlers/remove.ts","../src/handlers/config.ts","../src/handlers/auth.ts","../src/handlers/init.ts","../src/handlers/project.ts","../src/handlers/upgrade.ts","../src/handlers/uninstall.ts","../src/handlers/map.ts","../src/index.ts"],"sourcesContent":["import * as p from \"@clack/prompts\";\n\nexport interface SpinnerLike {\n\tstart(message?: string): void;\n\tstop(message?: string): void;\n\tmessage(message: string): void;\n}\n\nclass NoOpSpinner implements SpinnerLike {\n\tstart(_message?: string): void {}\n\tstop(_message?: string): void {}\n\tmessage(_message: string): void {}\n}\n\n/**\n * Creates a spinner that works in both TTY and non-TTY environments.\n * In TTY: returns a real @clack/prompts spinner with animation\n * In non-TTY: returns a no-op spinner that outputs nothing\n *\n * This prevents garbage output when running in non-interactive environments\n * (CI, piped output, agent sessions).\n */\nexport function createSpinner(): SpinnerLike {\n\tif (process.stdout.isTTY) {\n\t\treturn p.spinner();\n\t}\n\treturn new NoOpSpinner();\n}\n\n/**\n * Check if running in a TTY environment\n */\nexport const isTTY = process.stdout.isTTY ?? false;\n","import * as p from \"@clack/prompts\";\nimport {\n\tcloneRepo,\n\tupdateRepo,\n\tisRepoCloned,\n\tgetClonedRepoPath,\n\tgetCommitSha,\n\tgetCommitDistance,\n\tparseRepoInput,\n\tpullReference,\n\tpullReferenceByName,\n\tcheckRemote,\n\tcheckRemoteByName,\n\tloadConfig,\n\tloadAuthData,\n\tgetMetaPath,\n\tRepoExistsError,\n\tgenerateReferenceWithAI,\n\tinstallReference,\n\ttoReferenceFileName,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { ReferenceMetaSchema, type RepoSource } from \"@offworld/types\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface PullOptions {\n\trepo: string;\n\treference?: string;\n\tshallow?: boolean;\n\tsparse?: boolean;\n\tbranch?: string;\n\tforce?: boolean;\n\tverbose?: boolean;\n\t/** Model override in provider/model format (e.g., \"anthropic/claude-sonnet-4-20250514\") */\n\tmodel?: string;\n}\n\nexport interface PullResult {\n\tsuccess: boolean;\n\trepoPath: string;\n\treferenceSource: \"remote\" | \"local\" | \"cached\";\n\treferenceInstalled: boolean;\n\tmessage?: string;\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().slice(11, 23);\n}\n\nfunction toTildePath(absolutePath: string): string {\n\tconst home = homedir();\n\tif (absolutePath.startsWith(home)) {\n\t\treturn \"~\" + absolutePath.slice(home.length);\n\t}\n\treturn absolutePath;\n}\n\nfunction verboseLog(message: string, verbose: boolean): void {\n\tif (verbose) {\n\t\tp.log.info(`[${timestamp()}] ${message}`);\n\t}\n}\n\nfunction getLocalMetaDir(source: RepoSource): string {\n\tconst name = source.type === \"remote\" ? source.fullName : source.name;\n\treturn getMetaPath(name);\n}\n\nfunction loadLocalMeta(\n\tsource: RepoSource,\n): { commitSha?: string; referenceUpdatedAt?: string } | null {\n\tconst metaDir = getLocalMetaDir(source);\n\tconst metaPath = join(metaDir, \"meta.json\");\n\tif (!existsSync(metaPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst json = JSON.parse(readFileSync(metaPath, \"utf-8\"));\n\t\tconst parsed = ReferenceMetaSchema.safeParse(json);\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\t\treturn parsed.data;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction hasValidCache(source: RepoSource, currentSha: string): boolean {\n\tconst meta = loadLocalMeta(source);\n\treturn meta?.commitSha?.slice(0, 7) === currentSha.slice(0, 7);\n}\n\n/**\n * Save remote reference to local filesystem.\n * Remote reference comes with pre-generated reference content.\n */\nfunction saveRemoteReference(\n\tqualifiedName: string,\n\treferenceRepoName: string,\n\tlocalPath: string,\n\treferenceContent: string,\n\tcommitSha: string,\n\treferenceUpdatedAt: string,\n): void {\n\tconst meta = { referenceUpdatedAt, commitSha, version: \"0.1.0\" };\n\tinstallReference(qualifiedName, referenceRepoName, localPath, referenceContent, meta);\n}\n\nfunction parseModelFlag(model?: string): { provider?: string; model?: string } {\n\tif (!model) return {};\n\tconst parts = model.split(\"/\");\n\tif (parts.length === 2) {\n\t\treturn { provider: parts[0], model: parts[1] };\n\t}\n\treturn { model };\n}\n\nexport async function pullHandler(options: PullOptions): Promise<PullResult> {\n\tconst { repo, shallow = false, sparse = false, branch, force = false, verbose = false } = options;\n\tconst referenceName = options.reference?.trim() || undefined;\n\tconst { provider, model } = parseModelFlag(options.model);\n\tconst config = loadConfig();\n\tconst isReferenceOverride = Boolean(referenceName);\n\n\tconst s = createSpinner();\n\n\tif (verbose) {\n\t\tp.log.info(\n\t\t\t`[verbose] Options: repo=${repo}, reference=${referenceName ?? \"default\"}, shallow=${shallow}, branch=${branch || \"default\"}, force=${force}`,\n\t\t);\n\t}\n\n\ttry {\n\t\ts.start(\"Parsing repository input...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\t\tverboseLog(\n\t\t\t`Parsed source: type=${source.type}, qualifiedName=${source.qualifiedName}`,\n\t\t\tverbose,\n\t\t);\n\n\t\tlet repoPath: string;\n\n\t\tif (source.type === \"remote\") {\n\t\t\tconst qualifiedName = source.qualifiedName;\n\n\t\t\tif (isRepoCloned(qualifiedName)) {\n\t\t\t\ts.start(\"Updating repository...\");\n\t\t\t\tconst result = await updateRepo(qualifiedName);\n\t\t\t\trepoPath = getClonedRepoPath(qualifiedName)!;\n\n\t\t\t\tif (result.updated) {\n\t\t\t\t\ts.stop(`Updated (${result.previousSha.slice(0, 7)} → ${result.currentSha.slice(0, 7)})`);\n\t\t\t\t} else {\n\t\t\t\t\ts.stop(\"Already up to date\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ts.start(`Cloning ${source.fullName}...`);\n\t\t\t\ttry {\n\t\t\t\t\trepoPath = await cloneRepo(source, {\n\t\t\t\t\t\tshallow,\n\t\t\t\t\t\tsparse,\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tforce,\n\t\t\t\t\t});\n\t\t\t\t\ts.stop(\"Repository cloned\");\n\t\t\t\t\tverboseLog(`Cloned to: ${repoPath}`, verbose);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (err instanceof RepoExistsError && !force) {\n\t\t\t\t\t\ts.stop(\"Repository exists\");\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trepoPath = source.path;\n\t\t}\n\n\t\tconst currentSha = getCommitSha(repoPath);\n\t\tconst qualifiedName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tif (isReferenceOverride && source.type !== \"remote\") {\n\t\t\tthrow new Error(\"--reference can only be used with remote repositories\");\n\t\t}\n\t\tif (isReferenceOverride && !referenceName) {\n\t\t\tthrow new Error(\"--reference requires a reference name\");\n\t\t}\n\t\tconst requiredReferenceName = referenceName ?? \"\";\n\n\t\tif (!force && !isReferenceOverride && hasValidCache(source, currentSha)) {\n\t\t\tverboseLog(\"Using cached reference\", verbose);\n\t\t\ts.stop(\"Using cached reference\");\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\trepoPath,\n\t\t\t\treferenceSource: \"cached\",\n\t\t\t\treferenceInstalled: true,\n\t\t\t};\n\t\t}\n\n\t\tif (source.type === \"remote\" && (!force || isReferenceOverride)) {\n\t\t\tverboseLog(`Checking offworld.sh for reference: ${source.fullName}`, verbose);\n\t\t\ts.start(\"Checking offworld.sh for reference...\");\n\n\t\t\ttry {\n\t\t\t\tconst remoteCheck = isReferenceOverride\n\t\t\t\t\t? await checkRemoteByName(source.fullName, requiredReferenceName)\n\t\t\t\t\t: await checkRemote(source.fullName);\n\n\t\t\t\tif (remoteCheck.exists && remoteCheck.commitSha) {\n\t\t\t\t\tconst remoteSha = remoteCheck.commitSha;\n\t\t\t\t\tconst remoteShaNorm = remoteSha.slice(0, 7);\n\t\t\t\t\tconst currentShaNorm = currentSha.slice(0, 7);\n\n\t\t\t\t\tconst MAX_COMMIT_DISTANCE = 20;\n\t\t\t\t\tconst commitDistance = getCommitDistance(repoPath, remoteSha, currentSha);\n\t\t\t\t\tconst isWithinThreshold =\n\t\t\t\t\t\tremoteShaNorm === currentShaNorm ||\n\t\t\t\t\t\t(commitDistance !== null && commitDistance <= MAX_COMMIT_DISTANCE);\n\n\t\t\t\t\tconst shouldDownload = isReferenceOverride || isWithinThreshold;\n\n\t\t\t\t\tif (shouldDownload) {\n\t\t\t\t\t\tif (!isReferenceOverride) {\n\t\t\t\t\t\t\tif (commitDistance === 0 || remoteShaNorm === currentShaNorm) {\n\t\t\t\t\t\t\t\tverboseLog(`Remote SHA matches (${remoteShaNorm})`, verbose);\n\t\t\t\t\t\t\t\ts.stop(\"Remote reference found (exact match)\");\n\t\t\t\t\t\t\t} else if (commitDistance !== null) {\n\t\t\t\t\t\t\t\tverboseLog(\n\t\t\t\t\t\t\t\t\t`Remote reference is ${commitDistance} commits behind (within ${MAX_COMMIT_DISTANCE} threshold)`,\n\t\t\t\t\t\t\t\t\tverbose,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\ts.stop(`Remote reference found (${commitDistance} commits behind)`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tverboseLog(\"Remote reference found (commit distance unknown)\", verbose);\n\t\t\t\t\t\t\t\ts.stop(\"Remote reference found\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ts.stop(\"Remote reference found\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst previewUrl = referenceName\n\t\t\t\t\t\t\t? `https://offworld.sh/${source.fullName}/${encodeURIComponent(referenceName)}`\n\t\t\t\t\t\t\t: `https://offworld.sh/${source.fullName}`;\n\t\t\t\t\t\tp.log.info(`Preview: ${previewUrl}`);\n\n\t\t\t\t\t\tconst useRemote = await p.confirm({\n\t\t\t\t\t\t\tmessage: \"Download this reference from offworld.sh?\",\n\t\t\t\t\t\t\tinitialValue: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (p.isCancel(useRemote)) {\n\t\t\t\t\t\t\tthrow new Error(\"Operation cancelled\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!useRemote) {\n\t\t\t\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Remote reference download declined\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tp.log.info(\"Skipping remote reference, generating locally...\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ts.start(\"Downloading remote reference...\");\n\t\t\t\t\t\t\tconst remoteReference = isReferenceOverride\n\t\t\t\t\t\t\t\t? await pullReferenceByName(source.fullName, requiredReferenceName)\n\t\t\t\t\t\t\t\t: await pullReference(source.fullName);\n\n\t\t\t\t\t\t\tif (remoteReference) {\n\t\t\t\t\t\t\t\ts.stop(\"Downloaded remote reference\");\n\n\t\t\t\t\t\t\t\tsaveRemoteReference(\n\t\t\t\t\t\t\t\t\tsource.qualifiedName,\n\t\t\t\t\t\t\t\t\tsource.fullName,\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\tremoteReference.referenceContent,\n\t\t\t\t\t\t\t\t\tremoteReference.commitSha,\n\t\t\t\t\t\t\t\t\tremoteReference.generatedAt ?? new Date().toISOString(),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst remoteReferenceFileName = toReferenceFileName(qualifiedName);\n\t\t\t\t\t\t\t\tconst remoteReferencePath = join(\n\t\t\t\t\t\t\t\t\tPaths.offworldReferencesDir,\n\t\t\t\t\t\t\t\t\tremoteReferenceFileName,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst remoteRelativePath = toTildePath(remoteReferencePath);\n\t\t\t\t\t\t\t\tp.log.success(\n\t\t\t\t\t\t\t\t\treferenceName\n\t\t\t\t\t\t\t\t\t\t? `Reference file (${referenceName}) at: ${remoteRelativePath}`\n\t\t\t\t\t\t\t\t\t\t: `Reference file at: ${remoteRelativePath}`,\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\treferenceSource: \"remote\",\n\t\t\t\t\t\t\t\t\treferenceInstalled: true,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Remote reference download failed\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ts.stop(\"Remote download failed, generating locally...\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst distanceInfo =\n\t\t\t\t\t\t\tcommitDistance !== null ? ` (${commitDistance} commits behind)` : \"\";\n\t\t\t\t\t\tverboseLog(\n\t\t\t\t\t\t\t`Remote reference too outdated${distanceInfo}, threshold is ${MAX_COMMIT_DISTANCE}`,\n\t\t\t\t\t\t\tverbose,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ts.stop(`Remote reference outdated${distanceInfo}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ts.stop(\"No remote reference found\");\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tverboseLog(\n\t\t\t\t\t`Remote check failed: ${err instanceof Error ? err.message : \"Unknown\"}`,\n\t\t\t\t\tverbose,\n\t\t\t\t);\n\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\tthrow err instanceof Error ? err : new Error(\"Remote check failed\");\n\t\t\t\t}\n\t\t\t\ts.stop(\"Remote check failed, continuing locally\");\n\t\t\t}\n\t\t}\n\n\t\tif (isReferenceOverride) {\n\t\t\tthrow new Error(`Reference not found on offworld.sh: ${referenceName}`);\n\t\t}\n\n\t\tverboseLog(`Starting AI reference generation for: ${repoPath}`, verbose);\n\n\t\tif (!verbose) {\n\t\t\ts.start(\"Generating reference with AI...\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst onDebug = verbose\n\t\t\t\t? (message: string) => {\n\t\t\t\t\t\tp.log.info(`[${timestamp()}] [debug] ${message}`);\n\t\t\t\t\t}\n\t\t\t\t: (msg: string) => {\n\t\t\t\t\t\t// Filter out internal debug messages (prefixed with [) from spinner\n\t\t\t\t\t\tif (!msg.startsWith(\"[\")) {\n\t\t\t\t\t\t\ts.message(msg);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\tconst result = await generateReferenceWithAI(repoPath, qualifiedName, {\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tonDebug,\n\t\t\t});\n\n\t\t\tconst { referenceContent, commitSha: referenceCommitSha } = result;\n\t\t\tconst referenceUpdatedAt = new Date().toISOString();\n\t\t\tconst meta = { referenceUpdatedAt, commitSha: referenceCommitSha, version: \"0.1.0\" };\n\t\t\tconst referenceRepoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\t\tinstallReference(source.qualifiedName, referenceRepoName, repoPath, referenceContent, meta);\n\n\t\t\tconst referenceFileName = toReferenceFileName(qualifiedName);\n\t\t\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\t\t\tconst relativePath = toTildePath(referencePath);\n\n\t\t\tif (!verbose) {\n\t\t\t\ts.stop(\"Reference file created\");\n\t\t\t} else {\n\t\t\t\tp.log.success(\"Reference file created\");\n\t\t\t}\n\n\t\t\tp.log.success(`Reference file at: ${relativePath}`);\n\n\t\t\tif (source.type === \"remote\") {\n\t\t\t\tconst authData = loadAuthData();\n\t\t\t\tif (authData?.token) {\n\t\t\t\t\tp.log.info(\n\t\t\t\t\t\t`Run 'ow push ${source.fullName}' to share this reference to https://offworld.sh.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\trepoPath,\n\t\t\t\treferenceSource: \"local\",\n\t\t\t\treferenceInstalled: true,\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tif (!verbose) {\n\t\t\t\ts.stop(\"Reference generation failed\");\n\t\t\t}\n\t\t\tconst errMessage = err instanceof Error ? err.message : \"Unknown error\";\n\t\t\tp.log.error(`Failed to generate reference: ${errMessage}`);\n\n\t\t\tthrow new Error(`Reference generation failed: ${errMessage}`);\n\t\t}\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\trepoPath: \"\",\n\t\t\treferenceSource: \"local\",\n\t\t\treferenceInstalled: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tcloneRepo,\n\tisRepoCloned,\n\tgetClonedRepoPath,\n\tcheckRemote,\n\tgenerateReferenceWithAI,\n\tinstallReference,\n\tloadConfig,\n\tgetReferencePath,\n} from \"@offworld/sdk\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface GenerateOptions {\n\trepo: string;\n\tforce?: boolean;\n\t/** Model override in provider/model format (e.g., \"anthropic/claude-sonnet-4-20250514\") */\n\tmodel?: string;\n}\n\nexport interface GenerateResult {\n\tsuccess: boolean;\n\treferencePath?: string;\n\tmessage?: string;\n}\n\nfunction parseModelFlag(model?: string): { provider?: string; model?: string } {\n\tif (!model) return {};\n\tconst parts = model.split(\"/\");\n\tif (parts.length === 2) {\n\t\treturn { provider: parts[0], model: parts[1] };\n\t}\n\treturn { model };\n}\n\nexport async function generateHandler(options: GenerateOptions): Promise<GenerateResult> {\n\tconst { repo, force = false } = options;\n\tconst { provider, model } = parseModelFlag(options.model);\n\tconst config = loadConfig();\n\n\tconst s = createSpinner();\n\n\ttry {\n\t\ts.start(\"Parsing repository input...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\n\t\tlet repoPath: string;\n\n\t\tif (source.type === \"remote\" && !force) {\n\t\t\ts.start(\"Checking for existing remote reference...\");\n\t\t\tconst remoteCheck = await checkRemote(source.fullName);\n\n\t\t\tif (remoteCheck.exists) {\n\t\t\t\ts.stop(\"Remote reference exists\");\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tmessage: \"Remote reference exists. Use --force to override.\",\n\t\t\t\t};\n\t\t\t}\n\t\t\ts.stop(\"No remote reference found\");\n\t\t}\n\n\t\tif (source.type === \"remote\") {\n\t\t\tconst qualifiedName = source.qualifiedName;\n\n\t\t\tif (isRepoCloned(qualifiedName)) {\n\t\t\t\trepoPath = getClonedRepoPath(qualifiedName)!;\n\t\t\t\tp.log.info(`Using existing clone at ${repoPath}`);\n\t\t\t} else {\n\t\t\t\ts.start(`Cloning ${source.fullName}...`);\n\t\t\t\trepoPath = await cloneRepo(source, {\n\t\t\t\t\tshallow: config.defaultShallow,\n\t\t\t\t\tconfig,\n\t\t\t\t});\n\t\t\t\ts.stop(\"Repository cloned\");\n\t\t\t}\n\t\t} else {\n\t\t\trepoPath = source.path;\n\t\t}\n\n\t\ts.start(\"Generating reference with AI...\");\n\n\t\tconst qualifiedName = source.qualifiedName;\n\t\tconst referenceRepoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tconst result = await generateReferenceWithAI(repoPath, referenceRepoName, {\n\t\t\tprovider,\n\t\t\tmodel,\n\t\t\tonDebug: (msg: string) => s.message(msg),\n\t\t});\n\t\ts.stop(\"Reference generated\");\n\n\t\tconst { referenceContent, commitSha } = result;\n\t\tconst referenceUpdatedAt = new Date().toISOString();\n\t\tconst meta = { referenceUpdatedAt, commitSha, version: \"0.1.0\" };\n\n\t\tconst referencePath = getReferencePath(referenceRepoName);\n\n\t\tinstallReference(qualifiedName, referenceRepoName, repoPath, referenceContent, meta);\n\n\t\tp.log.success(`Reference saved to: ${referencePath}`);\n\t\tp.log.info(`Reference installed for: ${qualifiedName}`);\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\treferencePath,\n\t\t};\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n","/**\n * Shared utilities for CLI handlers\n */\n\nimport { readGlobalMap } from \"@offworld/sdk\";\nimport { existsSync } from \"node:fs\";\n\nexport interface RepoListItem {\n\tfullName: string;\n\tqualifiedName: string;\n\tlocalPath: string;\n\thasReference: boolean;\n\treferenceUpdatedAt?: string;\n\tcommitSha?: string;\n\texists: boolean;\n}\n\n/**\n * Format a repo entry for display\n */\nexport function formatRepoForDisplay(item: RepoListItem, showPaths: boolean): string {\n\tconst parts: string[] = [item.fullName];\n\n\tif (item.hasReference) {\n\t\tparts.push(\"[reference]\");\n\t} else {\n\t\tparts.push(\"[no-reference]\");\n\t}\n\n\tif (showPaths) parts.push(`(${item.localPath})`);\n\tif (!item.exists) parts.push(\"[missing]\");\n\n\treturn parts.join(\" \");\n}\n\n/**\n * Convert qualified name to list item\n */\nexport async function entryToListItem(qualifiedName: string): Promise<RepoListItem> {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\n\tif (!entry) {\n\t\treturn {\n\t\t\tfullName: qualifiedName,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: \"\",\n\t\t\thasReference: false,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tconst exists = existsSync(entry.localPath);\n\tconst hasReference = !!entry.references && entry.references.length > 0;\n\n\treturn {\n\t\tfullName: qualifiedName,\n\t\tqualifiedName,\n\t\tlocalPath: entry.localPath,\n\t\thasReference,\n\t\treferenceUpdatedAt: entry.updatedAt,\n\t\tcommitSha: undefined, // Map doesn't store commitSha yet\n\t\texists,\n\t};\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tlistRepos,\n\tgetRepoStatus,\n\tupdateAllRepos,\n\tpruneRepos,\n\tgcRepos,\n\tdiscoverRepos,\n\tgetRepoRoot,\n\tloadConfig,\n\treadGlobalMap,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { formatRepoForDisplay, type RepoListItem } from \"./shared.js\";\n\nexport interface RepoListOptions {\n\tjson?: boolean;\n\tpaths?: boolean;\n\tpattern?: string;\n}\n\nexport type { RepoListItem };\n\nexport interface RepoListResult {\n\trepos: RepoListItem[];\n}\n\nexport interface RepoUpdateOptions {\n\tall?: boolean;\n\tpattern?: string;\n\tdryRun?: boolean;\n\t/** Convert shallow clones to full clones */\n\tunshallow?: boolean;\n}\n\nexport interface RepoUpdateResult {\n\tupdated: string[];\n\tskipped: string[];\n\tunshallowed: string[];\n\terrors: Array<{ repo: string; error: string }>;\n}\n\nexport interface RepoPruneOptions {\n\tdryRun?: boolean;\n\tyes?: boolean;\n\tremoveOrphans?: boolean;\n}\n\nexport interface RepoPruneResult {\n\tremovedFromIndex: string[];\n\torphanedDirs: string[];\n\tremovedOrphans: string[];\n}\n\nexport interface RepoStatusOptions {\n\tjson?: boolean;\n}\n\nexport interface RepoStatusResult {\n\ttotal: number;\n\twithReference: number;\n\tmissing: number;\n\tdiskMB: number;\n}\n\nexport interface RepoGcOptions {\n\tolderThan?: string;\n\twithoutReference?: boolean;\n\tdryRun?: boolean;\n\tyes?: boolean;\n}\n\nexport interface RepoGcResult {\n\tremoved: Array<{ repo: string; reason: string; sizeMB: number }>;\n\tfreedMB: number;\n}\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes} B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n\tif (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n\treturn `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\nfunction parseDays(olderThan: string): number | null {\n\tconst match = olderThan.match(/^(\\d+)d$/);\n\tif (match?.[1]) return parseInt(match[1], 10);\n\treturn null;\n}\n\nfunction matchesPattern(name: string, pattern: string): boolean {\n\tif (!pattern || pattern === \"*\") return true;\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\nexport async function repoListHandler(options: RepoListOptions): Promise<RepoListResult> {\n\tconst { json = false, paths = false, pattern } = options;\n\n\tconst qualifiedNames = listRepos();\n\tconst map = readGlobalMap();\n\n\tif (qualifiedNames.length === 0) {\n\t\tif (!json) {\n\t\t\tp.log.info(\"No repositories cloned yet.\");\n\t\t\tp.log.info(\"Use 'ow pull <repo>' to clone and generate a reference.\");\n\t\t}\n\t\treturn { repos: [] };\n\t}\n\n\tconst items: RepoListItem[] = [];\n\tfor (const qName of qualifiedNames) {\n\t\tconst entry = map.repos[qName];\n\t\tif (!entry) continue;\n\t\tif (pattern && !matchesPattern(qName, pattern)) continue;\n\n\t\tconst exists = existsSync(entry.localPath);\n\t\tconst hasReference = !!entry.primary;\n\n\t\titems.push({\n\t\t\tfullName: qName,\n\t\t\tqualifiedName: qName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\thasReference,\n\t\t\treferenceUpdatedAt: entry.updatedAt,\n\t\t\texists,\n\t\t});\n\t}\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(items, null, 2));\n\t} else {\n\t\tif (items.length === 0) {\n\t\t\tif (pattern) {\n\t\t\t\tp.log.info(`No repositories matching \"${pattern}\".`);\n\t\t\t}\n\t\t} else {\n\t\t\tp.log.info(`Found ${items.length} repositories:\\n`);\n\t\t\tfor (const item of items) {\n\t\t\t\tconsole.log(formatRepoForDisplay(item, paths));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { repos: items };\n}\n\nexport async function repoUpdateHandler(options: RepoUpdateOptions): Promise<RepoUpdateResult> {\n\tconst { all = false, pattern, dryRun = false, unshallow = false } = options;\n\n\tif (!all && !pattern) {\n\t\tp.log.error(\"Specify --all or a pattern to update.\");\n\t\treturn { updated: [], skipped: [], unshallowed: [], errors: [] };\n\t}\n\n\tconst qualifiedNames = listRepos();\n\tconst filtered = pattern\n\t\t? qualifiedNames.filter((q) => matchesPattern(q, pattern))\n\t\t: qualifiedNames;\n\tconst total = filtered.length;\n\n\tif (total === 0) {\n\t\tp.log.info(pattern ? `No repos matching \"${pattern}\"` : \"No repos to update\");\n\t\treturn { updated: [], skipped: [], unshallowed: [], errors: [] };\n\t}\n\n\tlet processed = 0;\n\tconst outcomes: Array<{ repo: string; status: string; message?: string }> = [];\n\n\tconst spinner = p.spinner();\n\tconst action = unshallow ? \"Unshallowing\" : \"Updating\";\n\tspinner.start(dryRun ? `Checking ${total} repos...` : `${action} ${total} repos...`);\n\n\tconst result = await updateAllRepos({\n\t\tpattern,\n\t\tdryRun,\n\t\tunshallow,\n\t\tonProgress: (repo: string, status: string, message?: string) => {\n\t\t\tif (status === \"updating\") {\n\t\t\t\tprocessed++;\n\t\t\t\tspinner.message(`[${processed}/${total}] ${repo}`);\n\t\t\t} else {\n\t\t\t\toutcomes.push({ repo, status, message });\n\t\t\t}\n\t\t},\n\t});\n\n\tspinner.stop(dryRun ? \"Dry run complete\" : `${action} complete`);\n\n\tfor (const { repo, status, message } of outcomes) {\n\t\tif (status === \"updated\") {\n\t\t\tp.log.success(`${repo}${message ? ` (${message})` : \"\"}`);\n\t\t} else if (status === \"unshallowed\") {\n\t\t\tp.log.success(`${repo}: ${message}`);\n\t\t} else if (status === \"error\") {\n\t\t\tp.log.error(`${repo}: ${message}`);\n\t\t} else if (\n\t\t\tstatus === \"skipped\" &&\n\t\t\tmessage !== \"up to date\" &&\n\t\t\tmessage !== \"already up to date\"\n\t\t) {\n\t\t\tp.log.warn(`${repo}: ${message}`);\n\t\t}\n\t}\n\n\tconst parts: string[] = [];\n\tif (result.updated.length > 0)\n\t\tparts.push(`${result.updated.length} ${dryRun ? \"would update\" : \"updated\"}`);\n\tif (result.unshallowed.length > 0) parts.push(`${result.unshallowed.length} unshallowed`);\n\tif (result.skipped.length > 0) parts.push(`${result.skipped.length} skipped`);\n\tif (result.errors.length > 0) parts.push(`${result.errors.length} failed`);\n\n\tif (parts.length > 0) {\n\t\tp.log.info(`Summary: ${parts.join(\", \")}`);\n\t}\n\n\treturn result;\n}\n\nexport async function repoPruneHandler(options: RepoPruneOptions): Promise<RepoPruneResult> {\n\tconst { dryRun = false, yes = false, removeOrphans = false } = options;\n\n\tconst result = await pruneRepos({ dryRun: true });\n\tconst removedOrphans: string[] = [];\n\n\tif (result.removedFromIndex.length === 0 && result.orphanedDirs.length === 0) {\n\t\tp.log.info(\"Nothing to prune. Index and filesystem are in sync.\");\n\t\treturn { removedFromIndex: [], orphanedDirs: [], removedOrphans: [] };\n\t}\n\n\tif (result.removedFromIndex.length > 0) {\n\t\tp.log.info(`Found ${result.removedFromIndex.length} repos in index but missing on disk:`);\n\t\tfor (const repo of result.removedFromIndex) {\n\t\t\tconsole.log(` - ${repo}`);\n\t\t}\n\t}\n\n\tif (result.orphanedDirs.length > 0) {\n\t\tp.log.info(`Found ${result.orphanedDirs.length} directories not in index:`);\n\t\tfor (const dir of result.orphanedDirs) {\n\t\t\tconsole.log(` - ${dir}`);\n\t\t}\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn { ...result, removedOrphans: [] };\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Remove stale index entries?\" });\n\t\tif (p.isCancel(confirm)) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { removedFromIndex: [], orphanedDirs: result.orphanedDirs, removedOrphans: [] };\n\t\t}\n\t\tshouldProceed = confirm;\n\t}\n\n\tif (shouldProceed) {\n\t\tawait pruneRepos({ dryRun: false });\n\t\tp.log.success(`Removed ${result.removedFromIndex.length} stale index entries.`);\n\t}\n\n\tif (removeOrphans && result.orphanedDirs.length > 0) {\n\t\tlet shouldRemoveOrphans = yes;\n\t\tif (!yes) {\n\t\t\tconst confirm = await p.confirm({ message: \"Also remove orphaned directories?\" });\n\t\t\tif (!p.isCancel(confirm) && confirm) {\n\t\t\t\tshouldRemoveOrphans = true;\n\t\t\t}\n\t\t}\n\n\t\tif (shouldRemoveOrphans) {\n\t\t\tfor (const dir of result.orphanedDirs) {\n\t\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t\t\tremovedOrphans.push(dir);\n\t\t\t}\n\t\t\tp.log.success(`Removed ${removedOrphans.length} orphaned directories.`);\n\t\t}\n\t}\n\n\treturn { ...result, removedOrphans };\n}\n\nexport async function repoStatusHandler(options: RepoStatusOptions): Promise<RepoStatusResult> {\n\tconst { json = false } = options;\n\n\tconst spinner = p.spinner();\n\tspinner.start(\"Calculating repo status...\");\n\n\tconst status = await getRepoStatus({\n\t\tonProgress: (current, total, repo) => {\n\t\t\tspinner.message(`[${current}/${total}] ${repo}`);\n\t\t},\n\t});\n\n\tspinner.stop(\"Status complete\");\n\n\tconst output: RepoStatusResult = {\n\t\ttotal: status.total,\n\t\twithReference: status.withReference,\n\t\tmissing: status.missing,\n\t\tdiskMB: Math.round(status.diskBytes / (1024 * 1024)),\n\t};\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(output, null, 2));\n\t} else {\n\t\tp.log.info(`Managed repos: ${status.total}`);\n\t\tp.log.info(` With reference: ${status.withReference}`);\n\t\tp.log.info(` Missing: ${status.missing}`);\n\t\tp.log.info(` Disk usage: ${formatBytes(status.diskBytes)}`);\n\t}\n\n\treturn output;\n}\n\nexport async function repoGcHandler(options: RepoGcOptions): Promise<RepoGcResult> {\n\tconst { olderThan, withoutReference = false, dryRun = false, yes = false } = options;\n\n\tif (!olderThan && !withoutReference) {\n\t\tp.log.error(\"Specify at least one filter: --older-than or --without-reference\");\n\t\treturn { removed: [], freedMB: 0 };\n\t}\n\n\tlet olderThanDays: number | undefined;\n\tif (olderThan) {\n\t\tconst days = parseDays(olderThan);\n\t\tif (days === null) {\n\t\t\tp.log.error(\"Invalid --older-than format. Use e.g. '30d' for 30 days.\");\n\t\t\treturn { removed: [], freedMB: 0 };\n\t\t}\n\t\tolderThanDays = days;\n\t}\n\n\tconst previewResult = await gcRepos({\n\t\tolderThanDays,\n\t\twithoutReference,\n\t\tdryRun: true,\n\t});\n\n\tif (previewResult.removed.length === 0) {\n\t\tp.log.info(\"No repos match the criteria.\");\n\t\treturn { removed: [], freedMB: 0 };\n\t}\n\n\tp.log.info(\n\t\t`Found ${previewResult.removed.length} repos to remove (${formatBytes(previewResult.freedBytes)}):`,\n\t);\n\tfor (const { repo, reason, sizeBytes } of previewResult.removed) {\n\t\tconsole.log(` - ${repo} (${formatBytes(sizeBytes)}) - ${reason}`);\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn {\n\t\t\tremoved: previewResult.removed.map(\n\t\t\t\t(r: { repo: string; reason: string; sizeBytes: number }) => ({\n\t\t\t\t\trepo: r.repo,\n\t\t\t\t\treason: r.reason,\n\t\t\t\t\tsizeMB: Math.round(r.sizeBytes / (1024 * 1024)),\n\t\t\t\t}),\n\t\t\t),\n\t\t\tfreedMB: Math.round(previewResult.freedBytes / (1024 * 1024)),\n\t\t};\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Proceed with removal?\" });\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { removed: [], freedMB: 0 };\n\t\t}\n\t\tshouldProceed = true;\n\t}\n\n\tif (shouldProceed) {\n\t\tconst result = await gcRepos({\n\t\t\tolderThanDays,\n\t\t\twithoutReference,\n\t\t\tdryRun: false,\n\t\t});\n\n\t\tp.log.success(\n\t\t\t`Removed ${result.removed.length} repos, freed ${formatBytes(result.freedBytes)}`,\n\t\t);\n\n\t\treturn {\n\t\t\tremoved: result.removed.map((r: { repo: string; reason: string; sizeBytes: number }) => ({\n\t\t\t\trepo: r.repo,\n\t\t\t\treason: r.reason,\n\t\t\t\tsizeMB: Math.round(r.sizeBytes / (1024 * 1024)),\n\t\t\t})),\n\t\t\tfreedMB: Math.round(result.freedBytes / (1024 * 1024)),\n\t\t};\n\t}\n\n\treturn { removed: [], freedMB: 0 };\n}\n\nexport interface RepoDiscoverOptions {\n\tdryRun?: boolean;\n\tyes?: boolean;\n}\n\nexport interface RepoDiscoverResult {\n\tdiscovered: number;\n\talreadyIndexed: number;\n}\n\nexport async function repoDiscoverHandler(\n\toptions: RepoDiscoverOptions,\n): Promise<RepoDiscoverResult> {\n\tconst { dryRun = false, yes = false } = options;\n\n\tconst config = loadConfig();\n\tconst repoRoot = getRepoRoot(config);\n\n\tif (!existsSync(repoRoot)) {\n\t\tp.log.error(`Repo root does not exist: ${repoRoot}`);\n\t\treturn { discovered: 0, alreadyIndexed: 0 };\n\t}\n\n\tconst previewResult = await discoverRepos({ repoRoot, dryRun: true });\n\n\tif (previewResult.discovered.length === 0) {\n\t\tif (previewResult.alreadyIndexed > 0) {\n\t\t\tp.log.info(`All ${previewResult.alreadyIndexed} repos already indexed.`);\n\t\t} else {\n\t\t\tp.log.info(\"No repos found to discover.\");\n\t\t}\n\t\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n\t}\n\n\tp.log.info(`Found ${previewResult.discovered.length} unindexed repos:`);\n\tfor (const repo of previewResult.discovered.slice(0, 20)) {\n\t\tconsole.log(` + ${repo.fullName}`);\n\t}\n\tif (previewResult.discovered.length > 20) {\n\t\tconsole.log(` ... and ${previewResult.discovered.length - 20} more`);\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn {\n\t\t\tdiscovered: previewResult.discovered.length,\n\t\t\talreadyIndexed: previewResult.alreadyIndexed,\n\t\t};\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Add these repos to the index?\" });\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n\t\t}\n\t\tshouldProceed = true;\n\t}\n\n\tif (shouldProceed) {\n\t\tconst result = await discoverRepos({ repoRoot });\n\t\tp.log.success(\n\t\t\t`Added ${result.discovered.length} repos to clone map (marked as not referenced)`,\n\t\t);\n\t\treturn { discovered: result.discovered.length, alreadyIndexed: result.alreadyIndexed };\n\t}\n\n\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n}\n","/**\n * Push command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tgetToken,\n\tgetMetaPath,\n\tgetReferencePath,\n\ttoReferenceName,\n\tgetCommitSha,\n\tgetClonedRepoPath,\n\tisRepoCloned,\n\tpushReference,\n\tNotLoggedInError,\n\tTokenExpiredError,\n\tAuthenticationError,\n\tRateLimitError,\n\tCommitExistsError,\n\tInvalidInputError,\n\tInvalidReferenceError,\n\tSyncRepoNotFoundError,\n\tLowStarsError,\n\tPrivateRepoError,\n\tCommitNotFoundError,\n\tGitHubError,\n\ttype ReferenceData,\n} from \"@offworld/sdk\";\nimport { ReferenceMetaSchema } from \"@offworld/types\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface PushOptions {\n\trepo: string;\n}\n\nexport interface PushResult {\n\tsuccess: boolean;\n\tmessage: string;\n}\n\nconst DESCRIPTION_MAX = 200;\n\nfunction extractDescription(referenceContent: string, fallback: string): string {\n\tconst lines = referenceContent.split(/\\r?\\n/);\n\tlet sawTitle = false;\n\tlet description = \"\";\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i]?.trim() ?? \"\";\n\t\tif (!line) continue;\n\t\tif (line.startsWith(\"# \")) {\n\t\t\tsawTitle = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!sawTitle || line.startsWith(\"#\")) continue;\n\n\t\tdescription = line;\n\t\tfor (let j = i + 1; j < lines.length; j++) {\n\t\t\tconst next = lines[j]?.trim() ?? \"\";\n\t\t\tif (!next || next.startsWith(\"#\")) break;\n\t\t\tdescription += ` ${next}`;\n\t\t}\n\t\tbreak;\n\t}\n\n\tdescription = description.replace(/\\s+/g, \" \").trim();\n\tif (!description) description = fallback;\n\tif (description.length > DESCRIPTION_MAX)\n\t\tdescription = description.slice(0, DESCRIPTION_MAX).trim();\n\tif (!description) description = fallback.slice(0, DESCRIPTION_MAX);\n\treturn description;\n}\n\n/**\n * Load local reference data from disk.\n * Format: reference file + meta.json\n */\nfunction loadLocalReference(\n\tmetaDir: string,\n\treferencePath: string,\n\tfullName: string,\n): ReferenceData | null {\n\tconst metaPath = join(metaDir, \"meta.json\");\n\n\tif (!existsSync(referencePath) || !existsSync(metaPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst referenceContent = readFileSync(referencePath, \"utf-8\");\n\t\tconst json = JSON.parse(readFileSync(metaPath, \"utf-8\"));\n\t\tconst parsed = ReferenceMetaSchema.safeParse(json);\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\t\tconst meta = parsed.data;\n\t\tconst referenceName = toReferenceName(fullName);\n\t\tconst referenceDescription = extractDescription(referenceContent, `Reference for ${fullName}`);\n\n\t\treturn {\n\t\t\tfullName: \"\",\n\t\t\treferenceName,\n\t\t\treferenceDescription,\n\t\t\treferenceContent,\n\t\t\tcommitSha: meta.commitSha,\n\t\t\tgeneratedAt: meta.referenceUpdatedAt,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function pushHandler(options: PushOptions): Promise<PushResult> {\n\tconst { repo } = options;\n\tconst s = createSpinner();\n\n\ttry {\n\t\tlet token: string;\n\t\ttry {\n\t\t\ttoken = await getToken();\n\t\t} catch (err) {\n\t\t\tif (err instanceof NotLoggedInError || err instanceof TokenExpiredError) {\n\t\t\t\tp.log.error(err.message);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\n\t\ts.start(\"Parsing repository...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\n\t\tif (source.type === \"local\") {\n\t\t\tp.log.error(\"Local repositories cannot be pushed to offworld.sh.\");\n\t\t\tp.log.info(\"Only remote GitHub repositories can be pushed.\");\n\t\t\treturn { success: false, message: \"Local repositories not supported\" };\n\t\t}\n\n\t\tif (source.provider !== \"github\") {\n\t\t\tp.log.error(`${source.provider} repositories are not yet supported.`);\n\t\t\tp.log.info(\"GitHub support only for now - GitLab and Bitbucket coming soon!\");\n\t\t\treturn { success: false, message: \"Only GitHub repositories supported\" };\n\t\t}\n\n\t\tif (!isRepoCloned(source.qualifiedName)) {\n\t\t\tp.log.error(`Repository ${source.fullName} is not cloned locally.`);\n\t\t\tp.log.info(`Run 'ow pull ${source.fullName}' first to clone and analyze.`);\n\t\t\treturn { success: false, message: \"Repository not cloned locally\" };\n\t\t}\n\n\t\ts.start(\"Loading local reference...\");\n\t\tconst metaDir = getMetaPath(source.fullName);\n\t\tconst referencePath = getReferencePath(source.fullName);\n\n\t\tif (!existsSync(metaDir) || !existsSync(referencePath)) {\n\t\t\ts.stop(\"No reference found\");\n\t\t\tp.log.error(`No reference found for ${source.fullName}.`);\n\t\t\tp.log.info(`Run 'ow generate ${source.fullName}' to generate reference.`);\n\t\t\treturn { success: false, message: \"No local reference found\" };\n\t\t}\n\n\t\tconst localReference = loadLocalReference(metaDir, referencePath, source.fullName);\n\n\t\tif (!localReference) {\n\t\t\ts.stop(\"Invalid reference\");\n\t\t\tp.log.error(\"Local reference is incomplete or corrupted.\");\n\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\treturn { success: false, message: \"Local reference incomplete\" };\n\t\t}\n\n\t\tlocalReference.fullName = source.fullName;\n\n\t\tconst repoPath = getClonedRepoPath(source.qualifiedName);\n\t\tif (repoPath) {\n\t\t\tconst currentSha = getCommitSha(repoPath);\n\t\t\tif (currentSha !== localReference.commitSha) {\n\t\t\t\ts.stop(\"Reference outdated\");\n\t\t\t\tp.log.warn(\"Local reference was generated for a different commit.\");\n\t\t\t\tp.log.info(`Reference: ${localReference.commitSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(`Current: ${currentSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\t\treturn { success: false, message: \"Reference outdated - run generate to update\" };\n\t\t\t}\n\t\t}\n\n\t\ts.stop(\"Reference loaded\");\n\n\t\ts.start(\"Uploading to offworld.sh...\");\n\t\ttry {\n\t\t\tconst result = await pushReference(localReference, token);\n\n\t\t\tif (result.success) {\n\t\t\t\ts.stop(\"Reference uploaded!\");\n\t\t\t\tp.log.success(`Successfully pushed reference for ${source.fullName}`);\n\t\t\t\tp.log.info(`View at: https://offworld.sh/${source.owner}/${source.repo}`);\n\t\t\t\treturn { success: true, message: \"Reference pushed successfully\" };\n\t\t\t}\n\t\t\ts.stop(\"Upload failed\");\n\t\t\tp.log.error(result.message || \"Unknown error during upload\");\n\t\t\treturn { success: false, message: result.message || \"Upload failed\" };\n\t\t} catch (err) {\n\t\t\ts.stop(\"Upload failed\");\n\n\t\t\tif (err instanceof AuthenticationError) {\n\t\t\t\tp.log.error(\"Authentication failed.\");\n\t\t\t\tp.log.info(\"Please run 'ow auth login' again.\");\n\t\t\t\treturn { success: false, message: \"Authentication failed\" };\n\t\t\t}\n\n\t\t\tif (err instanceof RateLimitError) {\n\t\t\t\tp.log.error(\"Rate limit exceeded.\");\n\t\t\t\tp.log.info(\"You can push up to 20 references per day.\");\n\t\t\t\tp.log.info(\"Please try again tomorrow.\");\n\t\t\t\treturn { success: false, message: \"Rate limit exceeded\" };\n\t\t\t}\n\n\t\t\tif (err instanceof CommitExistsError) {\n\t\t\t\tp.log.error(\"A reference already exists for this commit.\");\n\t\t\t\tp.log.info(`Commit: ${localReference.commitSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(\n\t\t\t\t\t\"References are immutable per commit. Update the repo and regenerate to push a new version.\",\n\t\t\t\t);\n\t\t\t\treturn { success: false, message: \"Reference already exists for this commit\" };\n\t\t\t}\n\n\t\t\tif (err instanceof InvalidInputError) {\n\t\t\t\tp.log.error(\"Invalid input data.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\n\t\t\tif (err instanceof InvalidReferenceError) {\n\t\t\t\tp.log.error(\"Invalid reference content.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\n\t\t\tif (err instanceof SyncRepoNotFoundError) {\n\t\t\t\tp.log.error(\"Repository not found on GitHub.\");\n\t\t\t\tp.log.info(\"Ensure the repository exists and is public.\");\n\t\t\t\treturn { success: false, message: \"Repository not found\" };\n\t\t\t}\n\n\t\t\tif (err instanceof LowStarsError) {\n\t\t\t\tp.log.error(\"Repository does not meet star requirements.\");\n\t\t\t\tp.log.info(\"Repositories need at least 5 stars to be pushed to offworld.sh.\");\n\t\t\t\tp.log.info(\"This helps ensure quality skills for the community.\");\n\t\t\t\treturn { success: false, message: \"Repository needs 5+ stars\" };\n\t\t\t}\n\n\t\t\tif (err instanceof PrivateRepoError) {\n\t\t\t\tp.log.error(\"Private repositories are not supported.\");\n\t\t\t\tp.log.info(\"Only public GitHub repositories can be pushed to offworld.sh.\");\n\t\t\t\treturn { success: false, message: \"Private repos not supported\" };\n\t\t\t}\n\n\t\t\tif (err instanceof CommitNotFoundError) {\n\t\t\t\tp.log.error(\"Commit not found in repository.\");\n\t\t\t\tp.log.info(\"The analyzed commit may have been rebased or removed.\");\n\t\t\t\tp.log.info(\n\t\t\t\t\t`Run 'ow generate ${source.fullName} --force' to regenerate with current commit.`,\n\t\t\t\t);\n\t\t\t\treturn { success: false, message: \"Commit not found\" };\n\t\t\t}\n\n\t\t\tif (err instanceof GitHubError) {\n\t\t\t\tp.log.error(\"GitHub API error.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\tp.log.info(\"Please try again later.\");\n\t\t\t\treturn { success: false, message: \"GitHub API error\" };\n\t\t\t}\n\n\t\t\tthrow err;\n\t\t}\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Remove command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tremoveRepo,\n\ttoReferenceFileName,\n\treadGlobalMap,\n\tgetMetaPath,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface RmOptions {\n\trepo: string;\n\tyes?: boolean;\n\treferenceOnly?: boolean;\n\trepoOnly?: boolean;\n\tdryRun?: boolean;\n}\n\nexport interface RmResult {\n\tsuccess: boolean;\n\tremoved?: {\n\t\trepoPath?: string;\n\t\treferencePath?: string;\n\t\tsymlinkPaths?: string[];\n\t};\n\tmessage?: string;\n}\n\nfunction getAffectedPathsFromMap(qualifiedName: string): {\n\trepoPath?: string;\n\treferencePath?: string;\n\tsymlinkPaths: string[];\n} | null {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) {\n\t\treturn null;\n\t}\n\n\tconst repoPath = entry.localPath;\n\tconst referenceFileName = entry.primary || \"\";\n\tconst referencePath = referenceFileName\n\t\t? join(Paths.offworldReferencesDir, referenceFileName)\n\t\t: undefined;\n\n\treturn {\n\t\trepoPath: existsSync(repoPath) ? repoPath : undefined,\n\t\treferencePath: referencePath && existsSync(referencePath) ? referencePath : undefined,\n\t\tsymlinkPaths: [],\n\t};\n}\n\nexport async function rmHandler(options: RmOptions): Promise<RmResult> {\n\tconst { repo, yes = false, referenceOnly = false, repoOnly = false, dryRun = false } = options;\n\n\ttry {\n\t\tconst source = parseRepoInput(repo);\n\t\tconst qualifiedName = source.qualifiedName;\n\t\tconst repoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tif (referenceOnly && repoOnly) {\n\t\t\tp.log.error(\"Cannot use --reference-only and --repo-only together\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Invalid options\",\n\t\t\t};\n\t\t}\n\n\t\tconst map = readGlobalMap();\n\t\tconst entry = map.repos[qualifiedName];\n\n\t\tif (!entry && !referenceOnly) {\n\t\t\tp.log.warn(`Repository not found in map: ${repo}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Repository not found\",\n\t\t\t};\n\t\t}\n\n\t\tif (referenceOnly && !entry) {\n\t\t\treturn handleReferenceOnlyRemoval(repoName, yes, dryRun);\n\t\t}\n\n\t\tconst affected = getAffectedPathsFromMap(qualifiedName)!;\n\n\t\tif (dryRun || !yes) {\n\t\t\tp.log.info(\"The following will be removed:\");\n\n\t\t\tif (!referenceOnly && affected.repoPath) {\n\t\t\t\tconsole.log(` Repository: ${affected.repoPath}`);\n\t\t\t}\n\t\t\tif (!repoOnly && affected.referencePath) {\n\t\t\t\tconsole.log(` Reference: ${affected.referencePath}`);\n\t\t\t}\n\t\t\tconsole.log(\"\");\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tp.log.info(\"Dry run - no files were deleted.\");\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: affected,\n\t\t\t};\n\t\t}\n\n\t\tif (!yes) {\n\t\t\tconst what = referenceOnly ? \"reference files\" : repoOnly ? \"repository\" : qualifiedName;\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: `Are you sure you want to remove ${what}?`,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tmessage: \"Aborted by user\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst s = createSpinner();\n\t\tconst action = referenceOnly\n\t\t\t? \"Removing reference files...\"\n\t\t\t: repoOnly\n\t\t\t\t? \"Removing repository...\"\n\t\t\t\t: \"Removing...\";\n\t\ts.start(action);\n\n\t\tconst removed = await removeRepo(qualifiedName, { referenceOnly, repoOnly });\n\n\t\tif (removed) {\n\t\t\tconst doneMsg = referenceOnly\n\t\t\t\t? \"Reference files removed\"\n\t\t\t\t: repoOnly\n\t\t\t\t\t? \"Repository removed\"\n\t\t\t\t\t: \"Removed\";\n\t\t\ts.stop(doneMsg);\n\t\t\tp.log.success(`Removed: ${qualifiedName}`);\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: affected,\n\t\t\t};\n\t\t} else {\n\t\t\ts.stop(\"Failed to remove\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Failed to remove repository\",\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\nasync function handleReferenceOnlyRemoval(\n\trepoName: string,\n\tyes: boolean,\n\tdryRun: boolean,\n): Promise<RmResult> {\n\tconst referenceFileName = toReferenceFileName(repoName);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tconst metaPath = getMetaPath(repoName);\n\n\tif (!existsSync(referencePath) && !existsSync(metaPath)) {\n\t\tp.log.warn(`No reference files found for: ${repoName}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage: \"No reference files found\",\n\t\t};\n\t}\n\n\tif (dryRun || !yes) {\n\t\tp.log.info(\"The following will be removed:\");\n\t\tif (existsSync(referencePath)) {\n\t\t\tconsole.log(` Reference: ${referencePath}`);\n\t\t}\n\t\tif (existsSync(metaPath)) {\n\t\t\tconsole.log(` Meta: ${metaPath}`);\n\t\t}\n\t\tconsole.log(\"\");\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no files were deleted.\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tremoved: { referencePath },\n\t\t};\n\t}\n\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({\n\t\t\tmessage: `Are you sure you want to remove reference files for ${repoName}?`,\n\t\t});\n\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Aborted.\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Aborted by user\",\n\t\t\t};\n\t\t}\n\t}\n\n\tconst s = createSpinner();\n\ts.start(\"Removing reference files...\");\n\n\tif (existsSync(referencePath)) rmSync(referencePath, { force: true });\n\tif (existsSync(metaPath)) rmSync(metaPath, { recursive: true, force: true });\n\n\ts.stop(\"Reference files removed\");\n\tp.log.success(`Removed reference files for: ${repoName}`);\n\treturn {\n\t\tsuccess: true,\n\t\tremoved: { referencePath },\n\t};\n}\n","/**\n * Config command handlers\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tloadConfig,\n\tsaveConfig,\n\tgetConfigPath,\n\tdetectInstalledAgents,\n\tgetAllAgentConfigs,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { ConfigSchema, AgentSchema } from \"@offworld/types/schemas\";\nimport type { Agent } from \"@offworld/types\";\nimport { z } from \"zod\";\nimport { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\nconst VALID_KEYS = [\"repoRoot\", \"defaultShallow\", \"defaultModel\", \"agents\"] as const;\ntype ConfigKey = (typeof VALID_KEYS)[number];\n\nfunction isValidKey(key: string): key is ConfigKey {\n\treturn VALID_KEYS.includes(key as ConfigKey);\n}\n\nexport interface ConfigShowOptions {\n\tjson?: boolean;\n}\n\nexport interface ConfigShowResult {\n\tconfig: Record<string, unknown>;\n\tpaths: {\n\t\tskillDir: string;\n\t\treferencesDir: string;\n\t\tglobalMap: string;\n\t\tprojectMap?: string;\n\t};\n}\n\nexport async function configShowHandler(options: ConfigShowOptions): Promise<ConfigShowResult> {\n\tconst config = loadConfig();\n\n\tconst projectMapPath = resolve(process.cwd(), \".offworld/map.json\");\n\tconst hasProjectMap = existsSync(projectMapPath);\n\n\tconst paths: ConfigShowResult[\"paths\"] = {\n\t\tskillDir: join(Paths.data, \"skill\", \"offworld\"),\n\t\treferencesDir: join(Paths.data, \"skill\", \"offworld\", \"references\"),\n\t\tglobalMap: join(Paths.data, \"skill\", \"offworld\", \"assets\", \"map.json\"),\n\t};\n\tif (hasProjectMap) {\n\t\tpaths.projectMap = projectMapPath;\n\t}\n\n\tif (options.json) {\n\t\tconst output = {\n\t\t\t...config,\n\t\t\tpaths,\n\t\t};\n\t\tconsole.log(JSON.stringify(output, null, 2));\n\t} else {\n\t\tp.log.info(\"Current configuration:\\n\");\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t}\n\t\tconsole.log(\"\");\n\t\tp.log.info(`Config file: ${getConfigPath()}`);\n\t\tif (hasProjectMap) {\n\t\t\tp.log.info(`Project map: ${projectMapPath}`);\n\t\t}\n\t}\n\n\treturn { config, paths };\n}\n\nexport interface ConfigSetOptions {\n\tkey: string;\n\tvalue: string;\n}\n\nexport interface ConfigSetResult {\n\tsuccess: boolean;\n\tkey?: string;\n\tvalue?: unknown;\n\tmessage?: string;\n}\n\nexport async function configSetHandler(options: ConfigSetOptions): Promise<ConfigSetResult> {\n\tconst { key, value } = options;\n\n\tif (!isValidKey(key)) {\n\t\tp.log.error(`Invalid config key: ${key}`);\n\t\tp.log.info(`Valid keys: ${VALID_KEYS.join(\", \")}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage: `Invalid key: ${key}`,\n\t\t};\n\t}\n\n\tlet parsedValue: string | boolean | Agent[];\n\n\tif (key === \"defaultShallow\") {\n\t\tif (value === \"true\" || value === \"1\") {\n\t\t\tparsedValue = true;\n\t\t} else if (value === \"false\" || value === \"0\") {\n\t\t\tparsedValue = false;\n\t\t} else {\n\t\t\tp.log.error(`Invalid boolean value: ${value}. Use 'true' or 'false'.`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: `Invalid boolean value: ${value}`,\n\t\t\t};\n\t\t}\n\t} else if (key === \"agents\") {\n\t\tconst agentValues = value\n\t\t\t.split(\",\")\n\t\t\t.map((a) => a.trim())\n\t\t\t.filter(Boolean);\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(agentValues);\n\n\t\tif (!agentsResult.success) {\n\t\t\tconst invalidAgents = agentValues.filter((a) => !AgentSchema.options.includes(a as Agent));\n\t\t\tp.log.error(`Invalid agent(s): ${invalidAgents.join(\", \")}`);\n\t\t\tp.log.info(`Valid agents: ${AgentSchema.options.join(\", \")}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: `Invalid agents: ${invalidAgents.join(\", \")}`,\n\t\t\t};\n\t\t}\n\n\t\tparsedValue = agentsResult.data;\n\t} else {\n\t\tparsedValue = value;\n\t}\n\n\ttry {\n\t\tconst updates = { [key]: parsedValue };\n\t\tsaveConfig(updates);\n\t\tp.log.success(`Set ${key} = ${JSON.stringify(parsedValue)}`);\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tkey,\n\t\t\tvalue: parsedValue,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\nexport interface ConfigGetOptions {\n\tkey: string;\n}\n\nexport interface ConfigGetResult {\n\tkey: string;\n\tvalue: unknown;\n}\n\nexport async function configGetHandler(options: ConfigGetOptions): Promise<ConfigGetResult> {\n\tconst { key } = options;\n\tconst config = loadConfig();\n\n\tif (!isValidKey(key)) {\n\t\tp.log.error(`Invalid config key: ${key}`);\n\t\tp.log.info(`Valid keys: ${VALID_KEYS.join(\", \")}`);\n\t\treturn { key, value: null };\n\t}\n\n\tconst value = config[key as keyof typeof config];\n\tconsole.log(JSON.stringify(value));\n\n\treturn { key, value };\n}\n\nexport interface ConfigResetResult {\n\tsuccess: boolean;\n}\n\nexport async function configResetHandler(): Promise<ConfigResetResult> {\n\ttry {\n\t\tconst defaults = ConfigSchema.parse({});\n\t\tsaveConfig(defaults);\n\n\t\tp.log.success(\"Configuration reset to defaults:\");\n\t\tfor (const [key, value] of Object.entries(defaults)) {\n\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false };\n\t}\n}\n\nexport interface ConfigPathResult {\n\tpath: string;\n}\n\nexport async function configPathHandler(): Promise<ConfigPathResult> {\n\tconst path = getConfigPath();\n\tconsole.log(path);\n\treturn { path };\n}\n\nexport interface ConfigAgentsResult {\n\tsuccess: boolean;\n\tagents?: Agent[];\n}\n\nexport async function configAgentsHandler(): Promise<ConfigAgentsResult> {\n\tconst config = loadConfig();\n\tconst detectedAgents = detectInstalledAgents();\n\tconst allAgentConfigs = getAllAgentConfigs();\n\n\tif (detectedAgents.length > 0) {\n\t\tconst detectedNames = detectedAgents\n\t\t\t.map((a) => allAgentConfigs.find((c) => c.name === a)?.displayName ?? a)\n\t\t\t.join(\", \");\n\t\tp.log.info(`Detected agents: ${detectedNames}`);\n\t}\n\n\tconst agentOptions = allAgentConfigs.map((cfg) => ({\n\t\tvalue: cfg.name,\n\t\tlabel: cfg.displayName,\n\t\thint: cfg.globalSkillsDir,\n\t}));\n\tconst initialAgents = config.agents && config.agents.length > 0 ? config.agents : detectedAgents;\n\n\tconst agentsResult = await p.multiselect({\n\t\tmessage: \"Select agents to install skills to\",\n\t\toptions: agentOptions,\n\t\tinitialValues: initialAgents,\n\t\trequired: false,\n\t});\n\n\tif (p.isCancel(agentsResult)) {\n\t\tp.log.warn(\"Cancelled\");\n\t\treturn { success: false };\n\t}\n\n\tconst parsedAgents = z.array(AgentSchema).safeParse(agentsResult);\n\tconst agents = parsedAgents.success ? parsedAgents.data : [];\n\n\ttry {\n\t\tsaveConfig({ agents });\n\t\tp.log.success(`Agents set to: ${agents.join(\", \") || \"(none)\"}`);\n\t\treturn { success: true, agents };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false };\n\t}\n}\n","/**\n * Auth command handlers\n * Uses WorkOS Device Authorization Grant for CLI authentication\n */\n\nimport * as p from \"@clack/prompts\";\nimport { saveAuthData, clearAuthData, getAuthStatus, getAuthPath } from \"@offworld/sdk\";\nimport {\n\tWorkOSDeviceAuthResponseSchema,\n\tWorkOSTokenResponseSchema,\n\tWorkOSAuthErrorResponseSchema,\n\ttype WorkOSDeviceAuthResponse,\n\ttype WorkOSTokenResponse,\n} from \"@offworld/types\";\nimport open from \"open\";\nimport { createSpinner } from \"../utils/spinner\";\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 interface AuthLoginResult {\n\tsuccess: boolean;\n\temail?: string;\n\tmessage?: string;\n}\n\nexport interface AuthLogoutResult {\n\tsuccess: boolean;\n\tmessage: string;\n}\n\nexport interface AuthStatusResult {\n\tloggedIn: boolean;\n\temail?: string;\n\tworkosId?: string;\n\texpiresAt?: string;\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\nasync function requestDeviceCode(): Promise<WorkOSDeviceAuthResponse> {\n\tconst response = await fetch(`${WORKOS_API}/user_management/authorize/device`, {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\tbody: new URLSearchParams({ client_id: getWorkosClientId() }),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Failed to request device code: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn WorkOSDeviceAuthResponseSchema.parse(data);\n}\n\nasync function pollForTokens(\n\tdeviceCode: string,\n\tinterval: number,\n\tonStatus?: (status: string) => void,\n): Promise<WorkOSTokenResponse> {\n\tlet pollInterval = interval;\n\n\twhile (true) {\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: \"urn:ietf:params:oauth:grant-type:device_code\",\n\t\t\t\tdevice_code: deviceCode,\n\t\t\t\tclient_id: getWorkosClientId(),\n\t\t\t}),\n\t\t});\n\n\t\tif (response.ok) {\n\t\t\tconst data = await response.json();\n\t\t\treturn WorkOSTokenResponseSchema.parse(data);\n\t\t}\n\n\t\tconst errorData = await response.json();\n\t\tconst data = WorkOSAuthErrorResponseSchema.parse(errorData);\n\n\t\tswitch (data.error) {\n\t\t\tcase \"authorization_pending\":\n\t\t\t\tonStatus?.(\"Waiting for approval...\");\n\t\t\t\tawait sleep(pollInterval * 1000);\n\t\t\t\tbreak;\n\t\t\tcase \"slow_down\":\n\t\t\t\tpollInterval += 5;\n\t\t\t\tonStatus?.(\"Slowing down polling...\");\n\t\t\t\tawait sleep(pollInterval * 1000);\n\t\t\t\tbreak;\n\t\t\tcase \"access_denied\":\n\t\t\t\tthrow new Error(\"Authorization denied by user\");\n\t\t\tcase \"expired_token\":\n\t\t\t\tthrow new Error(\"Device code expired. Please try again.\");\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Authentication failed: ${data.error}`);\n\t\t}\n\t}\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function authLoginHandler(): Promise<AuthLoginResult> {\n\tconst s = createSpinner();\n\n\tconst currentStatus = await getAuthStatus();\n\tif (currentStatus.isLoggedIn) {\n\t\tp.log.info(`Already logged in as ${currentStatus.email || \"unknown user\"}`);\n\t\tconst shouldRelogin = await p.confirm({\n\t\t\tmessage: \"Do you want to log in again?\",\n\t\t});\n\t\tif (!shouldRelogin || p.isCancel(shouldRelogin)) {\n\t\t\treturn { success: true, email: currentStatus.email };\n\t\t}\n\t}\n\n\ts.start(\"Requesting device code...\");\n\n\tlet deviceData: WorkOSDeviceAuthResponse;\n\ttry {\n\t\tdeviceData = await requestDeviceCode();\n\t} catch (error) {\n\t\ts.stop(\"Failed to get device code\");\n\t\treturn { success: false, message: error instanceof Error ? error.message : \"Unknown error\" };\n\t}\n\n\ts.stop();\n\n\tp.log.info(`\\nOpen this URL in your browser:\\n`);\n\tp.log.info(` ${deviceData.verification_uri_complete}\\n`);\n\tp.log.info(`Or go to ${deviceData.verification_uri} and enter code: ${deviceData.user_code}\\n`);\n\n\ttry {\n\t\tawait open(deviceData.verification_uri_complete);\n\t} catch {}\n\n\ts.start(\"Waiting for approval...\");\n\n\ttry {\n\t\tconst tokenData = await pollForTokens(deviceData.device_code, deviceData.interval, (status) => {\n\t\t\ts.message(status);\n\t\t});\n\n\t\ts.stop(\"Login successful!\");\n\n\t\tconst expiresAt = tokenData.expires_at\n\t\t\t? new Date(tokenData.expires_at * 1000).toISOString()\n\t\t\t: extractJwtExpiration(tokenData.access_token);\n\n\t\tsaveAuthData({\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,\n\t\t});\n\n\t\tp.log.success(`Logged in as ${tokenData.user.email}`);\n\n\t\treturn { success: true, email: tokenData.user.email };\n\t} catch (error) {\n\t\ts.stop(\"Login failed\");\n\t\treturn { success: false, message: error instanceof Error ? error.message : \"Unknown error\" };\n\t}\n}\n\nexport async function authLogoutHandler(): Promise<AuthLogoutResult> {\n\tconst status = await getAuthStatus();\n\n\tif (!status.isLoggedIn) {\n\t\tp.log.info(\"Not currently logged in\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmessage: \"Not logged in\",\n\t\t};\n\t}\n\n\tconst cleared = clearAuthData();\n\n\tif (cleared) {\n\t\tp.log.success(\"Logged out successfully\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmessage: \"Logged out successfully\",\n\t\t};\n\t}\n\n\tp.log.warn(\"Could not clear auth data\");\n\treturn {\n\t\tsuccess: false,\n\t\tmessage: \"Could not clear auth data\",\n\t};\n}\n\nexport async function authStatusHandler(): Promise<AuthStatusResult> {\n\tconst status = await getAuthStatus();\n\n\tif (status.isLoggedIn) {\n\t\tp.log.info(`Logged in as: ${status.email || \"unknown\"}`);\n\t\tif (status.expiresAt) {\n\t\t\tconst expiresDate = new Date(status.expiresAt);\n\t\t\tp.log.info(`Session expires: ${expiresDate.toLocaleString()}`);\n\t\t}\n\t\tp.log.info(`Auth file: ${getAuthPath()}`);\n\t} else {\n\t\tp.log.info(\"Not logged in\");\n\t\tp.log.info(\"Run 'ow auth login' to authenticate\");\n\t}\n\n\treturn {\n\t\tloggedIn: status.isLoggedIn,\n\t\temail: status.email,\n\t\tworkosId: status.workosId,\n\t\texpiresAt: status.expiresAt,\n\t};\n}\n","import * as p from \"@clack/prompts\";\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { resolve, join, dirname } from \"node:path\";\nimport {\n\tloadConfig,\n\tsaveConfig,\n\tgetConfigPath,\n\tgetMetaRoot,\n\tPaths,\n\tdetectInstalledAgents,\n\tgetAllAgentConfigs,\n\tgetAuthStatus,\n\tinstallGlobalSkill,\n\tlistProviders,\n\tgetProvider,\n\tvalidateProviderModel,\n\tdiscoverRepos,\n\ttype ProviderInfo,\n\ttype ModelInfo,\n} from \"@offworld/sdk\";\nimport type { Config, Agent } from \"@offworld/types\";\nimport { AgentSchema } from \"@offworld/types/schemas\";\nimport { z } from \"zod\";\nimport { authLoginHandler } from \"./auth.js\";\n\nexport interface InitOptions {\n\tyes?: boolean;\n\t/** Reconfigure even if config exists */\n\tforce?: boolean;\n\t/** Skip auth check (useful for testing) */\n\tskipAuth?: boolean;\n\t/** AI provider and model (e.g., opencode/claude-sonnet-4-5) */\n\tmodel?: string;\n\t/** Where to clone repos */\n\trepoRoot?: string;\n\t/** Comma-separated agents */\n\tagents?: string;\n}\n\nexport interface InitResult {\n\tsuccess: boolean;\n\tconfigPath: string;\n}\n\nconst DEFAULT_PROVIDER = \"anthropic\";\nconst MAX_SELECT_ITEMS = 15;\n\nfunction expandTilde(path: string): string {\n\tif (path.startsWith(\"~/\")) {\n\t\treturn resolve(homedir(), path.slice(2));\n\t}\n\treturn resolve(path);\n}\n\nfunction collapseTilde(path: string): string {\n\tconst home = homedir();\n\tif (path.startsWith(home)) {\n\t\treturn \"~\" + path.slice(home.length);\n\t}\n\treturn path;\n}\n\nfunction validatePath(value: string): string | undefined {\n\tif (!value.trim()) {\n\t\treturn \"Path cannot be empty\";\n\t}\n\treturn undefined;\n}\n\nfunction detectProjectRoot(): string | null {\n\tlet currentDir = process.cwd();\n\twhile (currentDir !== homedir()) {\n\t\tconst packageJsonPath = join(currentDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\treturn currentDir;\n\t\t}\n\t\tconst parent = dirname(currentDir);\n\t\tif (parent === currentDir) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrentDir = parent;\n\t}\n\treturn null;\n}\n\nexport async function initHandler(options: InitOptions = {}): Promise<InitResult> {\n\tconst configPath = getConfigPath();\n\tconst existingConfig = loadConfig();\n\tconst configExists = existsSync(configPath);\n\tconst projectRoot = detectProjectRoot();\n\n\tp.intro(\"ow init\");\n\n\tif (!options.skipAuth) {\n\t\tconst authStatus = await getAuthStatus();\n\t\tif (!authStatus.isLoggedIn) {\n\t\t\tp.log.info(\"You are not logged in\");\n\t\t\tconst shouldLogin = await p.confirm({\n\t\t\t\tmessage: \"Do you want to log in now?\",\n\t\t\t\tinitialValue: true,\n\t\t\t});\n\n\t\t\tif (!p.isCancel(shouldLogin) && shouldLogin) {\n\t\t\t\tawait authLoginHandler();\n\t\t\t}\n\t\t}\n\t}\n\n\tif (configExists) {\n\t\tif (!options.force) {\n\t\t\tif (projectRoot) {\n\t\t\t\tp.log.warn(`Global config already exists at ${configPath}`);\n\t\t\t\tp.log.info(\"\");\n\t\t\t\tp.log.info(\"Did you mean to run project setup? Use:\");\n\t\t\t\tp.log.info(\" ow project init\");\n\t\t\t\tp.log.info(\"\");\n\t\t\t\tp.log.info(\"To reconfigure global settings, use:\");\n\t\t\t\tp.log.info(\" ow init --force\");\n\t\t\t\tp.outro(\"\");\n\t\t\t\treturn { success: false, configPath };\n\t\t\t}\n\t\t\tp.log.warn(\"Already configured. Use --force to reconfigure.\");\n\t\t\tp.outro(\"\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tp.log.info(\"Reconfiguring global settings...\");\n\t}\n\n\tlet repoRoot: string;\n\tif (options.repoRoot) {\n\t\trepoRoot = collapseTilde(expandTilde(options.repoRoot));\n\t} else {\n\t\tconst repoRootResult = await p.text({\n\t\t\tmessage: \"Where should repositories be cloned?\",\n\t\t\tplaceholder: \"~/ow\",\n\t\t\tinitialValue: existingConfig.repoRoot,\n\t\t\tvalidate: validatePath,\n\t\t});\n\n\t\tif (p.isCancel(repoRootResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\trepoRoot = collapseTilde(expandTilde(repoRootResult));\n\t}\n\n\tlet provider: string;\n\tlet model: string;\n\n\tif (options.model) {\n\t\tconst parts = options.model.split(\"/\");\n\t\tif (parts.length !== 2) {\n\t\t\tp.log.error(`Invalid model format. Expected 'provider/model', got '${options.model}'`);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tprovider = parts[0]!;\n\t\tmodel = parts[1]!;\n\n\t\tconst validation = await validateProviderModel(provider, model);\n\t\tif (!validation.valid) {\n\t\t\tp.log.error(validation.error!);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t} else {\n\t\tconst spin = p.spinner();\n\t\tspin.start(\"Fetching available providers...\");\n\n\t\tlet providers;\n\t\ttry {\n\t\t\tproviders = await listProviders();\n\t\t} catch (err) {\n\t\t\tspin.stop(\"Failed to fetch providers\");\n\t\t\tp.log.error(err instanceof Error ? err.message : \"Network error\");\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tspin.stop(\"Loaded providers from models.dev\");\n\n\t\tconst priorityProviders = [\"opencode\", \"anthropic\", \"openai\", \"google\"];\n\t\tconst sortedProviders = [\n\t\t\t...providers.filter((p: ProviderInfo) => priorityProviders.includes(p.id)),\n\t\t\t...providers\n\t\t\t\t.filter((p: ProviderInfo) => !priorityProviders.includes(p.id))\n\t\t\t\t.sort((a: ProviderInfo, b: ProviderInfo) => a.name.localeCompare(b.name)),\n\t\t];\n\n\t\tconst providerOptions = sortedProviders.map((prov: ProviderInfo) => ({\n\t\t\tvalue: prov.id,\n\t\t\tlabel: prov.name,\n\t\t}));\n\n\t\tconst currentProvider = existingConfig.defaultModel?.split(\"/\")[0];\n\t\tconst providerResult = await p.select({\n\t\t\tmessage: \"Select your AI provider\",\n\t\t\toptions: providerOptions,\n\t\t\tinitialValue: currentProvider ?? DEFAULT_PROVIDER,\n\t\t\tmaxItems: MAX_SELECT_ITEMS,\n\t\t});\n\n\t\tif (p.isCancel(providerResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tprovider = String(providerResult);\n\n\t\tspin.start(\"Fetching models...\");\n\t\tconst providerData = await getProvider(provider);\n\t\tspin.stop(`Loaded ${providerData?.models.length ?? 0} models`);\n\n\t\tif (!providerData || providerData.models.length === 0) {\n\t\t\tp.log.error(`No models found for provider \"${provider}\"`);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tconst modelOptions = providerData.models.map((m: ModelInfo) => ({\n\t\t\tvalue: m.id,\n\t\t\tlabel: m.name,\n\t\t\thint: m.reasoning ? \"reasoning\" : m.status === \"beta\" ? \"beta\" : undefined,\n\t\t}));\n\n\t\tconst currentModel = existingConfig.defaultModel?.split(\"/\")[1];\n\t\tconst modelResult = await p.select({\n\t\t\tmessage: \"Select your default model\",\n\t\t\toptions: modelOptions,\n\t\t\tinitialValue: currentModel,\n\t\t\tmaxItems: MAX_SELECT_ITEMS,\n\t\t});\n\n\t\tif (p.isCancel(modelResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tmodel = String(modelResult);\n\t}\n\n\tconst detectedAgents = detectInstalledAgents();\n\tconst allAgentConfigs = getAllAgentConfigs();\n\n\tif (detectedAgents.length > 0) {\n\t\tconst detectedNames = detectedAgents\n\t\t\t.map((a) => allAgentConfigs.find((c) => c.name === a)?.displayName ?? a)\n\t\t\t.join(\", \");\n\t\tp.log.info(`Detected agents: ${detectedNames}`);\n\t}\n\n\tconst agentOptions = allAgentConfigs.map((config) => ({\n\t\tvalue: config.name,\n\t\tlabel: config.displayName,\n\t\thint: config.globalSkillsDir,\n\t}));\n\n\tlet agents: Agent[];\n\tif (options.agents) {\n\t\tconst agentNames = options.agents.split(\",\").map((a) => a.trim());\n\t\tconst validAgents = allAgentConfigs\n\t\t\t.filter((c) => agentNames.includes(c.name))\n\t\t\t.map((c) => c.name);\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(validAgents);\n\t\tif (!agentsResult.success || agentsResult.data.length === 0) {\n\t\t\tp.log.error(\"No valid agent names provided\");\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tagents = agentsResult.data;\n\t} else {\n\t\tconst initialAgents =\n\t\t\texistingConfig.agents && existingConfig.agents.length > 0\n\t\t\t\t? existingConfig.agents\n\t\t\t\t: detectedAgents;\n\n\t\tconst selectResult = await p.multiselect({\n\t\t\tmessage: \"Select agents to install skills to\",\n\t\t\toptions: agentOptions,\n\t\t\tinitialValues: initialAgents,\n\t\t\trequired: false,\n\t\t});\n\n\t\tif (p.isCancel(selectResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(selectResult);\n\t\tagents = agentsResult.success ? agentsResult.data : [];\n\t}\n\n\tconst defaultModel = `${provider}/${model}`;\n\tconst newConfig: Partial<Config> = {\n\t\trepoRoot,\n\t\tdefaultModel,\n\t\tagents,\n\t};\n\n\ttry {\n\t\tsaveConfig(newConfig);\n\t\tinstallGlobalSkill();\n\n\t\tp.log.success(\"Configuration saved!\");\n\t\tp.log.info(` Config file: ${configPath}`);\n\t\tp.log.info(` Repo root: ${repoRoot}`);\n\t\tp.log.info(` Meta root: ${getMetaRoot()}`);\n\t\tp.log.info(` State root: ${Paths.state}`);\n\t\tp.log.info(` Model: ${defaultModel}`);\n\t\tp.log.info(` Agents: ${agents.join(\", \")}`);\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(`Failed to save configuration: ${message}`);\n\t\tp.outro(\"Setup failed\");\n\t\treturn { success: false, configPath };\n\t}\n\n\tconst expandedRepoRoot = expandTilde(repoRoot);\n\tif (existsSync(expandedRepoRoot)) {\n\t\tconst previewResult = await discoverRepos({ repoRoot: expandedRepoRoot, dryRun: true });\n\n\t\tif (previewResult.discovered.length > 0) {\n\t\t\tp.log.info(\"\");\n\t\t\tp.log.info(`Found ${previewResult.discovered.length} existing repos in ${repoRoot}`);\n\n\t\t\tlet shouldDiscover = options.yes;\n\t\t\tif (!options.yes) {\n\t\t\t\tconst confirmDiscover = await p.confirm({\n\t\t\t\t\tmessage: \"Add them to your clone map? (they will be marked as not referenced)\",\n\t\t\t\t\tinitialValue: true,\n\t\t\t\t});\n\t\t\t\tif (!p.isCancel(confirmDiscover)) {\n\t\t\t\t\tshouldDiscover = confirmDiscover;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (shouldDiscover) {\n\t\t\t\tconst result = await discoverRepos({ repoRoot: expandedRepoRoot });\n\t\t\t\tp.log.success(`Added ${result.discovered.length} repos to clone map`);\n\t\t\t}\n\t\t}\n\t}\n\n\tp.outro(\"Setup complete. Run 'ow pull <repo>' to get started.\");\n\treturn { success: true, configPath };\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tgetConfigPath,\n\tloadConfig,\n\tparseDependencies,\n\tresolveDependencyRepo,\n\tmatchDependenciesToReferences,\n\tupdateAgentFiles,\n\tgetReferencePath,\n\ttoReferenceFileName,\n\treadGlobalMap,\n\twriteProjectMap,\n\ttype InstalledReference,\n\ttype ReferenceMatch,\n} from \"@offworld/sdk\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { pullHandler } from \"./pull\";\n\nexport interface ProjectInitOptions {\n\t/** Select all detected dependencies */\n\tall?: boolean;\n\t/** Comma-separated deps to include (skip selection) */\n\tdeps?: string;\n\t/** Comma-separated deps to exclude */\n\tskip?: string;\n\t/** Generate references for deps without existing ones */\n\tgenerate?: boolean;\n\t/** Show what would be done without doing it */\n\tdryRun?: boolean;\n\t/** Skip confirmations */\n\tyes?: boolean;\n}\n\nexport interface ProjectInitResult {\n\tsuccess: boolean;\n\tmessage?: string;\n\treferencesInstalled?: number;\n}\n\nfunction detectProjectRoot(): string | null {\n\tlet currentDir = process.cwd();\n\twhile (currentDir !== homedir()) {\n\t\tconst gitPath = join(currentDir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\treturn currentDir;\n\t\t}\n\t\tconst parent = dirname(currentDir);\n\t\tif (parent === currentDir) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrentDir = parent;\n\t}\n\treturn null;\n}\n\nexport async function projectInitHandler(\n\toptions: ProjectInitOptions = {},\n): Promise<ProjectInitResult> {\n\tp.intro(\"ow project init\");\n\n\tconst configPath = getConfigPath();\n\tif (!existsSync(configPath)) {\n\t\tp.log.error(\"No global config found. Run 'ow init' first to set up global configuration.\");\n\t\tp.outro(\"\");\n\t\treturn { success: false, message: \"No global config found\" };\n\t}\n\n\tconst config = loadConfig();\n\tif (!config.defaultModel) {\n\t\tp.log.error(\"Global config is missing AI settings. Run 'ow init --force' to reconfigure.\");\n\t\tp.outro(\"\");\n\t\treturn { success: false, message: \"Invalid global config\" };\n\t}\n\n\tconst projectRoot = detectProjectRoot() || process.cwd();\n\tp.log.info(`Project root: ${projectRoot}`);\n\n\tp.log.step(\"Scanning dependencies...\");\n\tconst dependencies = parseDependencies(projectRoot);\n\n\tif (dependencies.length === 0) {\n\t\tp.log.warn(\"No dependencies found in manifest files.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies found\" };\n\t}\n\n\tp.log.info(`Found ${dependencies.length} dependencies`);\n\n\tp.log.step(\"Resolving GitHub repositories...\");\n\tconst isInternalDep = (version?: string): boolean => {\n\t\tif (!version) return false;\n\t\treturn (\n\t\t\tversion.startsWith(\"workspace:\") || version.startsWith(\"file:\") || version.startsWith(\"link:\")\n\t\t);\n\t};\n\n\tconst internalDeps = dependencies.filter((dep) => isInternalDep(dep.version));\n\tconst externalDeps = dependencies.filter((dep) => !isInternalDep(dep.version));\n\n\tif (internalDeps.length > 0) {\n\t\tp.log.warn(`Skipped ${internalDeps.length} internal workspace dependencies:`);\n\t\tfor (const dep of internalDeps) {\n\t\t\tp.log.info(` - ${dep.name}`);\n\t\t}\n\t}\n\n\tconst resolvedPromises = externalDeps.map((dep) => resolveDependencyRepo(dep.name));\n\tconst resolved = await Promise.all(resolvedPromises);\n\n\tconst skipList = options.skip ? options.skip.split(\",\").map((d) => d.trim()) : [];\n\tconst depsList = options.deps ? options.deps.split(\",\").map((d) => d.trim()) : [];\n\n\tlet filtered = resolved.filter((r) => {\n\t\tif (skipList.includes(r.dep)) return false;\n\t\tif (depsList.length > 0) return depsList.includes(r.dep);\n\t\treturn true;\n\t});\n\n\tif (filtered.length === 0) {\n\t\tp.log.warn(\"No dependencies left after filtering.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies after filtering\" };\n\t}\n\n\tconst matches = matchDependenciesToReferences(filtered);\n\tconst unresolved = matches.filter((match) => !match.repo);\n\tif (unresolved.length > 0) {\n\t\tp.log.warn(`Could not resolve ${unresolved.length} dependencies to a GitHub repo:`);\n\t\tfor (const match of unresolved) {\n\t\t\tp.log.info(` - ${match.dep}`);\n\t\t}\n\t}\n\n\tconst installable = matches.filter((match) => match.repo);\n\n\tlet selected: ReferenceMatch[];\n\tif (options.all || options.deps) {\n\t\tselected = installable;\n\t} else {\n\t\tconst checklistOptions = matches.map((m) => {\n\t\t\tconst repoLabel = m.repo ?? \"unknown repo\";\n\t\t\tconst label = `${m.dep} (${repoLabel}) - ${m.status}`;\n\t\t\treturn { value: m, label, hint: m.status, disabled: m.status === \"unknown\" };\n\t\t});\n\n\t\tconst selectedResult = await p.multiselect({\n\t\t\tmessage: \"Select dependencies to install references for:\",\n\t\t\toptions: checklistOptions,\n\t\t\trequired: false,\n\t\t});\n\n\t\tif (p.isCancel(selectedResult)) {\n\t\t\tp.cancel(\"Operation cancelled\");\n\t\t\treturn { success: false, message: \"Cancelled by user\" };\n\t\t}\n\n\t\tselected = Array.isArray(selectedResult) ? selectedResult : [];\n\t}\n\n\tif (selected.length === 0) {\n\t\tp.log.warn(\"No dependencies selected.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies selected\" };\n\t}\n\n\tif (!options.yes && !options.dryRun) {\n\t\tconst confirm = await p.confirm({\n\t\t\tmessage: `Install references for ${selected.length} dependencies?`,\n\t\t});\n\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.cancel(\"Operation cancelled\");\n\t\t\treturn { success: false, message: \"Cancelled by user\" };\n\t\t}\n\t}\n\n\tif (options.dryRun) {\n\t\tp.log.info(\"\");\n\t\tp.log.info(\"Dry run - would install references for:\");\n\t\tfor (const match of selected) {\n\t\t\tp.log.info(` - ${match.dep} (${match.repo})`);\n\t\t}\n\t\tp.outro(\"Dry run complete\");\n\t\treturn { success: true, message: \"Dry run complete\" };\n\t}\n\n\tp.log.step(`Installing ${selected.length} references...`);\n\n\tconst installed: InstalledReference[] = [];\n\tlet failedCount = 0;\n\n\tfor (const match of selected) {\n\t\ttry {\n\t\t\tif (!match.repo) continue;\n\n\t\t\tp.log.info(`Installing reference for ${match.dep}...`);\n\n\t\t\tconst pullResult = await pullHandler({\n\t\t\t\trepo: match.repo,\n\t\t\t\tshallow: true,\n\t\t\t\tforce: options.generate,\n\t\t\t\tverbose: false,\n\t\t\t});\n\n\t\t\tif (pullResult.success && pullResult.referenceInstalled) {\n\t\t\t\tconst referencePath = getReferencePath(match.repo);\n\t\t\t\tinstalled.push({\n\t\t\t\t\tdependency: match.dep,\n\t\t\t\t\treference: toReferenceFileName(match.repo),\n\t\t\t\t\tpath: referencePath,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tp.log.warn(`Failed to install reference for ${match.dep}`);\n\t\t\t\tfailedCount++;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errMsg = error instanceof Error ? error.message : \"Unknown error\";\n\t\t\tp.log.error(`Error installing ${match.dep}: ${errMsg}`);\n\t\t\tfailedCount++;\n\t\t}\n\t}\n\n\tconst map = readGlobalMap();\n\tconst projectEntries = Object.fromEntries(\n\t\tselected\n\t\t\t.filter((m) => m.repo)\n\t\t\t.map((m) => {\n\t\t\t\tconst qualifiedName = `github.com:${m.repo}`;\n\t\t\t\tconst entry = map.repos[qualifiedName];\n\t\t\t\treturn [\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\t{\n\t\t\t\t\t\tlocalPath: entry?.localPath ?? \"\",\n\t\t\t\t\t\treference: toReferenceFileName(m.repo!),\n\t\t\t\t\t\tkeywords: entry?.keywords ?? [],\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t);\n\twriteProjectMap(projectRoot, projectEntries);\n\n\tif (installed.length > 0) {\n\t\tp.log.step(\"Updating AGENTS.md...\");\n\t\ttry {\n\t\t\tupdateAgentFiles(projectRoot, installed);\n\t\t\tp.log.success(\"AGENTS.md updated\");\n\t\t} catch (error) {\n\t\t\tconst errMsg = error instanceof Error ? error.message : \"Unknown error\";\n\t\t\tp.log.error(`Failed to update AGENTS.md: ${errMsg}`);\n\t\t}\n\t}\n\n\tp.log.info(\"\");\n\tp.log.success(`Installed ${installed.length} references`);\n\tif (failedCount > 0) {\n\t\tp.log.warn(`Failed to install ${failedCount} references`);\n\t}\n\n\tp.outro(\"Project init complete\");\n\n\treturn { success: true, referencesInstalled: installed.length };\n}\n","/**\n * Upgrade command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tdetectInstallMethod,\n\tgetCurrentVersion,\n\tfetchLatestVersion,\n\texecuteUpgrade,\n\ttype InstallMethod,\n} from \"@offworld/sdk\";\nimport { createSpinner } from \"../utils/spinner.js\";\n\nexport interface UpgradeOptions {\n\ttarget?: string;\n\tmethod?: InstallMethod;\n}\n\nexport interface UpgradeResult {\n\tsuccess: boolean;\n\tfrom?: string;\n\tto?: string;\n\tmessage?: string;\n}\n\nexport async function upgradeHandler(options: UpgradeOptions): Promise<UpgradeResult> {\n\tconst { target, method: methodOverride } = options;\n\n\ttry {\n\t\tconst s = createSpinner();\n\n\t\ts.start(\"Detecting installation method...\");\n\t\tconst method = methodOverride ?? detectInstallMethod();\n\t\ts.stop(`Installation method: ${method}`);\n\n\t\tif (method === \"unknown\") {\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: \"Could not detect installation method. Attempt curl-based upgrade?\",\n\t\t\t\tinitialValue: false,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn { success: false, message: \"Unknown installation method\" };\n\t\t\t}\n\t\t}\n\n\t\tconst effectiveMethod = method === \"unknown\" ? \"curl\" : method;\n\n\t\tconst currentVersion = getCurrentVersion();\n\t\tp.log.info(`Current version: ${currentVersion}`);\n\n\t\tlet targetVersion = target;\n\t\tif (!targetVersion) {\n\t\t\ts.start(\"Fetching latest version...\");\n\t\t\tconst latest = await fetchLatestVersion(effectiveMethod);\n\t\t\ts.stop(latest ? `Latest version: ${latest}` : \"Could not fetch latest version\");\n\n\t\t\tif (!latest) {\n\t\t\t\tp.log.error(\"Failed to fetch latest version\");\n\t\t\t\treturn { success: false, message: \"Failed to fetch latest version\" };\n\t\t\t}\n\t\t\ttargetVersion = latest;\n\t\t}\n\n\t\ttargetVersion = targetVersion.replace(/^v/, \"\");\n\n\t\tif (currentVersion === targetVersion) {\n\t\t\tp.log.success(`Already on version ${targetVersion}`);\n\t\t\treturn { success: true, from: currentVersion, to: targetVersion };\n\t\t}\n\n\t\tp.log.info(`Upgrading from ${currentVersion} to ${targetVersion}...`);\n\n\t\tawait executeUpgrade(effectiveMethod, targetVersion);\n\n\t\tp.log.success(`Successfully upgraded to ${targetVersion}`);\n\t\tp.log.info(\"Restart your terminal or run 'ow --version' to verify.\");\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tfrom: currentVersion,\n\t\t\tto: targetVersion,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Uninstall command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tdetectInstallMethod,\n\texecuteUninstall,\n\tgetShellConfigFiles,\n\tcleanShellConfig,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { createSpinner } from \"../utils/spinner.js\";\n\nexport interface UninstallOptions {\n\tkeepConfig?: boolean;\n\tkeepData?: boolean;\n\tdryRun?: boolean;\n\tforce?: boolean;\n}\n\nexport interface UninstallResult {\n\tsuccess: boolean;\n\tremoved?: {\n\t\tbinary?: boolean;\n\t\tconfig?: boolean;\n\t\tdata?: boolean;\n\t\tstate?: boolean;\n\t\tshellConfigs?: string[];\n\t};\n\tmessage?: string;\n}\n\ninterface RemovalTarget {\n\tpath: string;\n\tlabel: string;\n\tkeep: boolean;\n}\n\nexport async function uninstallHandler(options: UninstallOptions): Promise<UninstallResult> {\n\tconst { keepConfig = false, keepData = false, dryRun = false, force = false } = options;\n\n\ttry {\n\t\tconst method = detectInstallMethod();\n\t\tp.log.info(`Installation method: ${method}`);\n\n\t\tconst directories: RemovalTarget[] = [\n\t\t\t{ path: Paths.data, label: \"Data\", keep: keepData },\n\t\t\t{ path: Paths.config, label: \"Config\", keep: keepConfig },\n\t\t\t{ path: Paths.state, label: \"State\", keep: false },\n\t\t];\n\n\t\tconst toRemove = directories.filter((d) => !d.keep && existsSync(d.path));\n\n\t\tif (dryRun || !force) {\n\t\t\tp.log.info(\"The following will be removed:\");\n\t\t\tconsole.log(\"\");\n\n\t\t\tif (method === \"curl\") {\n\t\t\t\tconsole.log(\" Binary: ~/.local/bin/ow\");\n\t\t\t} else {\n\t\t\t\tconsole.log(` Package: offworld (via ${method})`);\n\t\t\t}\n\n\t\t\tfor (const dir of toRemove) {\n\t\t\t\tconsole.log(` ${dir.label}: ${dir.path}`);\n\t\t\t}\n\n\t\t\tif (keepConfig) {\n\t\t\t\tconsole.log(` [kept] Config: ${Paths.config}`);\n\t\t\t}\n\t\t\tif (keepData) {\n\t\t\t\tconsole.log(` [kept] Data: ${Paths.data}`);\n\t\t\t}\n\n\t\t\tconsole.log(\"\");\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tp.log.info(\"Dry run - nothing was removed.\");\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: {\n\t\t\t\t\tbinary: method === \"curl\",\n\t\t\t\t\tconfig: !keepConfig && existsSync(Paths.config),\n\t\t\t\t\tdata: !keepData && existsSync(Paths.data),\n\t\t\t\t\tstate: existsSync(Paths.state),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (!force) {\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: \"Are you sure you want to uninstall offworld?\",\n\t\t\t\tinitialValue: false,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn { success: false, message: \"Aborted by user\" };\n\t\t\t}\n\t\t}\n\n\t\tconst s = createSpinner();\n\t\tconst removed: UninstallResult[\"removed\"] = {};\n\n\t\ts.start(\"Removing offworld...\");\n\t\ttry {\n\t\t\tawait executeUninstall(method);\n\t\t\tremoved.binary = true;\n\t\t\ts.stop(\"Removed offworld binary/package\");\n\t\t} catch (err) {\n\t\t\ts.stop(\"Failed to remove binary/package\");\n\t\t\tp.log.warn(err instanceof Error ? err.message : \"Unknown error\");\n\t\t}\n\n\t\tfor (const dir of toRemove) {\n\t\t\ts.start(`Removing ${dir.label.toLowerCase()}...`);\n\t\t\ttry {\n\t\t\t\trmSync(dir.path, { recursive: true, force: true });\n\t\t\t\ts.stop(`Removed ${dir.label.toLowerCase()}`);\n\t\t\t\tif (dir.label === \"Config\") removed.config = true;\n\t\t\t\tif (dir.label === \"Data\") removed.data = true;\n\t\t\t\tif (dir.label === \"State\") removed.state = true;\n\t\t\t} catch (err) {\n\t\t\t\ts.stop(`Failed to remove ${dir.label.toLowerCase()}`);\n\t\t\t\tp.log.warn(err instanceof Error ? err.message : \"Unknown error\");\n\t\t\t}\n\t\t}\n\n\t\tif (method === \"curl\") {\n\t\t\tconst shellConfigs = getShellConfigFiles();\n\t\t\tconst cleaned: string[] = [];\n\n\t\t\tfor (const config of shellConfigs) {\n\t\t\t\tif (cleanShellConfig(config)) {\n\t\t\t\t\tcleaned.push(config);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (cleaned.length > 0) {\n\t\t\t\tp.log.info(`Cleaned PATH from: ${cleaned.join(\", \")}`);\n\t\t\t\tremoved.shellConfigs = cleaned;\n\t\t\t}\n\t\t}\n\n\t\tp.log.success(\"Uninstall complete!\");\n\n\t\tif (method === \"curl\") {\n\t\t\tp.log.info(\"You may need to restart your terminal.\");\n\t\t}\n\n\t\treturn { success: true, removed };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Map command handlers for fast repo routing\n */\n\nimport * as p from \"@clack/prompts\";\nimport { getMapEntry, searchMap, Paths, type SearchResult } from \"@offworld/sdk\";\n\nexport interface MapShowOptions {\n\trepo: string;\n\tjson?: boolean;\n\tpath?: boolean;\n\tref?: boolean;\n}\n\nexport interface MapShowResult {\n\tfound: boolean;\n\tscope?: \"project\" | \"global\";\n\tqualifiedName?: string;\n\tlocalPath?: string;\n\tprimary?: string;\n\tkeywords?: string[];\n}\n\nexport async function mapShowHandler(options: MapShowOptions): Promise<MapShowResult> {\n\tconst { repo, json, path, ref } = options;\n\n\tconst result = getMapEntry(repo);\n\n\tif (!result) {\n\t\tif (json) {\n\t\t\tconsole.log(JSON.stringify({ found: false }));\n\t\t} else if (!path && !ref) {\n\t\t\tp.log.error(`Repo not found: ${repo}`);\n\t\t}\n\t\treturn { found: false };\n\t}\n\n\tconst { scope, qualifiedName, entry } = result;\n\n\tconst primary = \"primary\" in entry ? entry.primary : entry.reference;\n\tconst keywords = entry.keywords ?? [];\n\tconst refPath = `${Paths.offworldReferencesDir}/${primary}`;\n\tif (path) {\n\t\tconsole.log(entry.localPath);\n\t\treturn {\n\t\t\tfound: true,\n\t\t\tscope,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\tprimary,\n\t\t\tkeywords,\n\t\t};\n\t}\n\n\tif (ref) {\n\t\tconsole.log(refPath);\n\t\treturn {\n\t\t\tfound: true,\n\t\t\tscope,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\tprimary,\n\t\t\tkeywords,\n\t\t};\n\t}\n\n\tif (json) {\n\t\tconsole.log(\n\t\t\tJSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tfound: true,\n\t\t\t\t\tscope,\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\tlocalPath: entry.localPath,\n\t\t\t\t\tprimary,\n\t\t\t\t\treferencePath: refPath,\n\t\t\t\t\tkeywords,\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t);\n\t} else {\n\t\tconsole.log(`Repo: ${qualifiedName}`);\n\t\tconsole.log(`Scope: ${scope}`);\n\t\tconsole.log(`Path: ${entry.localPath}`);\n\t\tconsole.log(`Reference: ${refPath}`);\n\t\tif (keywords.length > 0) {\n\t\t\tconsole.log(`Keywords: ${keywords.join(\", \")}`);\n\t\t}\n\t}\n\n\treturn {\n\t\tfound: true,\n\t\tscope,\n\t\tqualifiedName,\n\t\tlocalPath: entry.localPath,\n\t\tprimary,\n\t\tkeywords,\n\t};\n}\n\nexport interface MapSearchOptions {\n\tterm: string;\n\tlimit?: number;\n\tjson?: boolean;\n}\n\nexport interface MapSearchResult {\n\tresults: SearchResult[];\n}\n\nexport async function mapSearchHandler(options: MapSearchOptions): Promise<MapSearchResult> {\n\tconst { term, limit = 10, json } = options;\n\n\tconst results = searchMap(term, { limit });\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(results, null, 2));\n\t} else if (results.length === 0) {\n\t\tp.log.warn(`No matches found for: ${term}`);\n\t} else {\n\t\tfor (const r of results) {\n\t\t\tconst refPath = `${Paths.offworldReferencesDir}/${r.primary}`;\n\t\t\tconsole.log(`${r.fullName}`);\n\t\t\tconsole.log(` path: ${r.localPath}`);\n\t\t\tconsole.log(` ref: ${refPath}`);\n\t\t\tif (r.keywords.length > 0) {\n\t\t\t\tconsole.log(` keywords: ${r.keywords.join(\", \")}`);\n\t\t\t}\n\t\t\tconsole.log(\"\");\n\t\t}\n\t}\n\n\treturn { results };\n}\n","import { os } from \"@orpc/server\";\nimport { createCli } from \"trpc-cli\";\nimport { z } from \"zod\";\nimport {\n\tpullHandler,\n\tgenerateHandler,\n\tpushHandler,\n\trmHandler,\n\tconfigShowHandler,\n\tconfigSetHandler,\n\tconfigGetHandler,\n\tconfigResetHandler,\n\tconfigPathHandler,\n\tconfigAgentsHandler,\n\tauthLoginHandler,\n\tauthLogoutHandler,\n\tauthStatusHandler,\n\tinitHandler,\n\tprojectInitHandler,\n\trepoListHandler,\n\trepoUpdateHandler,\n\trepoPruneHandler,\n\trepoStatusHandler,\n\trepoGcHandler,\n\trepoDiscoverHandler,\n\tupgradeHandler,\n\tuninstallHandler,\n\tmapShowHandler,\n\tmapSearchHandler,\n} from \"./handlers/index.js\";\n\nexport const version = \"0.2.0\";\n\nexport const router = os.router({\n\tpull: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\treference: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Reference name to pull (defaults to owner-repo)\")\n\t\t\t\t\t.meta({ alias: \"r\" }),\n\t\t\t\tshallow: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Use shallow clone (--depth 1)\")\n\t\t\t\t\t.meta({ negativeAlias: \"full-history\" }),\n\t\t\t\tsparse: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Use sparse checkout (only src/, lib/, packages/, docs/)\"),\n\t\t\t\tbranch: z.string().optional().describe(\"Branch to clone\"),\n\t\t\t\tforce: z.boolean().default(false).describe(\"Force re-generation\").meta({ alias: \"f\" }),\n\t\t\t\tverbose: z.boolean().default(false).describe(\"Show detailed output\"),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Model override (provider/model)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Clone a repository and fetch or generate its reference\",\n\t\t\tnegateBooleans: true,\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait pullHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\treference: input.reference,\n\t\t\t\tshallow: input.shallow,\n\t\t\t\tsparse: input.sparse,\n\t\t\t\tbranch: input.branch,\n\t\t\t\tforce: input.force,\n\t\t\t\tverbose: input.verbose,\n\t\t\t\tmodel: input.model,\n\t\t\t});\n\t\t}),\n\n\tlist: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\tpaths: z.boolean().default(false).describe(\"Show full paths\"),\n\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern (e.g. 'react-*')\"),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"List managed repositories (alias for 'ow repo list')\",\n\t\t\taliases: { command: [\"ls\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait repoListHandler({\n\t\t\t\tjson: input.json,\n\t\t\t\tpaths: input.paths,\n\t\t\t\tpattern: input.pattern,\n\t\t\t});\n\t\t}),\n\n\tgenerate: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\tforce: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Force even if remote exists\")\n\t\t\t\t\t.meta({ alias: \"f\" }),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Model override (provider/model)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Generate reference locally (ignores remote)\",\n\t\t\taliases: { command: [\"gen\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait generateHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\tforce: input.force,\n\t\t\t\tmodel: input.model,\n\t\t\t});\n\t\t}),\n\n\tpush: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Push local reference to offworld.sh\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait pushHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t});\n\t\t}),\n\n\tremove: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\treferenceOnly: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Only remove reference files (keep repo)\"),\n\t\t\t\trepoOnly: z.boolean().default(false).describe(\"Only remove cloned repo (keep reference)\"),\n\t\t\t\tdryRun: z.boolean().default(false).describe(\"Show what would be done\").meta({ alias: \"d\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Remove a cloned repository and its reference\",\n\t\t\taliases: { command: [\"rm\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait rmHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\tyes: input.yes,\n\t\t\t\treferenceOnly: input.referenceOnly,\n\t\t\t\trepoOnly: input.repoOnly,\n\t\t\t\tdryRun: input.dryRun,\n\t\t\t});\n\t\t}),\n\n\tauth: os.router({\n\t\tlogin: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Login to offworld.sh\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authLoginHandler();\n\t\t\t}),\n\n\t\tlogout: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Logout from offworld.sh\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authLogoutHandler();\n\t\t\t}),\n\n\t\tstatus: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Show authentication status\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authStatusHandler();\n\t\t\t}),\n\t}),\n\n\tconfig: os.router({\n\t\tshow: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Show all config settings\", default: true })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configShowHandler({ json: input.json });\n\t\t\t}),\n\n\t\tset: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tkey: z.string().describe(\"key\").meta({ positional: true }),\n\t\t\t\t\tvalue: z.string().describe(\"value\").meta({ positional: true }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: `Set a config value\n\nValid keys:\n repoRoot (string) Where to clone repos (e.g., ~/ow)\n defaultShallow (boolean) Use shallow clone by default (true/false)\n defaultModel (string) AI provider/model (e.g., anthropic/claude-sonnet-4-20250514)\n agents (list) Comma-separated agents (e.g., claude-code,opencode)`,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configSetHandler({ key: input.key, value: input.value });\n\t\t\t}),\n\n\t\tget: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tkey: z.string().describe(\"key\").meta({ positional: true }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: `Get a config value\n\nValid keys: repoRoot, defaultShallow, defaultModel, agents`,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configGetHandler({ key: input.key });\n\t\t\t}),\n\n\t\treset: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Reset config to defaults\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configResetHandler();\n\t\t\t}),\n\n\t\tpath: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Show config file location\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configPathHandler();\n\t\t\t}),\n\n\t\tagents: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Interactively select agents for reference installation\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configAgentsHandler();\n\t\t\t}),\n\t}),\n\n\tinit: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation prompts\").meta({ alias: \"y\" }),\n\t\t\t\tforce: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Reconfigure even if config exists\")\n\t\t\t\t\t.meta({ alias: \"f\" }),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"AI provider/model (e.g., anthropic/claude-sonnet-4-20250514)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t\trepoRoot: z.string().optional().describe(\"Where to clone repos\"),\n\t\t\t\tagents: z.string().optional().describe(\"Comma-separated agents\").meta({ alias: \"a\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Initialize configuration with interactive setup\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait initHandler({\n\t\t\t\tyes: input.yes,\n\t\t\t\tforce: input.force,\n\t\t\t\tmodel: input.model,\n\t\t\t\trepoRoot: input.repoRoot,\n\t\t\t\tagents: input.agents,\n\t\t\t});\n\t\t}),\n\n\tproject: os.router({\n\t\tinit: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tall: z.boolean().default(false).describe(\"Select all detected dependencies\"),\n\t\t\t\t\tdeps: z.string().optional().describe(\"Comma-separated deps to include (skip selection)\"),\n\t\t\t\t\tskip: z.string().optional().describe(\"Comma-separated deps to exclude\"),\n\t\t\t\t\tgenerate: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Generate references for deps without existing ones\")\n\t\t\t\t\t\t.meta({ alias: \"g\" }),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be done without doing it\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmations\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Scan manifest, install references, update AGENTS.md\",\n\t\t\t\tdefault: true,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait projectInitHandler({\n\t\t\t\t\tall: input.all,\n\t\t\t\t\tdeps: input.deps,\n\t\t\t\t\tskip: input.skip,\n\t\t\t\t\tgenerate: input.generate,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\tmap: os.router({\n\t\tshow: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t\tpath: z.boolean().default(false).describe(\"Print only local path\"),\n\t\t\t\t\tref: z.boolean().default(false).describe(\"Print only reference file path\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Show map entry for a repo\",\n\t\t\t\tdefault: true,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait mapShowHandler({\n\t\t\t\t\trepo: input.repo,\n\t\t\t\t\tjson: input.json,\n\t\t\t\t\tpath: input.path,\n\t\t\t\t\tref: input.ref,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tsearch: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tterm: z.string().describe(\"term\").meta({ positional: true }),\n\t\t\t\t\tlimit: z.number().default(10).describe(\"Max results\").meta({ alias: \"n\" }),\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Search map for repos matching a term\",\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait mapSearchHandler({\n\t\t\t\t\tterm: input.term,\n\t\t\t\t\tlimit: input.limit,\n\t\t\t\t\tjson: input.json,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\trepo: os.router({\n\t\tlist: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t\tpaths: z.boolean().default(false).describe(\"Show full paths\"),\n\t\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern (e.g. 'react-*')\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"List managed repositories\",\n\t\t\t\tdefault: true,\n\t\t\t\taliases: { command: [\"ls\"] },\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoListHandler({\n\t\t\t\t\tjson: input.json,\n\t\t\t\t\tpaths: input.paths,\n\t\t\t\t\tpattern: input.pattern,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tupdate: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tall: z.boolean().default(false).describe(\"Update all repos\"),\n\t\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern\"),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be updated\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tunshallow: z.boolean().default(false).describe(\"Convert shallow clones to full clones\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Update repos (git fetch + pull)\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoUpdateHandler({\n\t\t\t\t\tall: input.all,\n\t\t\t\t\tpattern: input.pattern,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tunshallow: input.unshallow,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tprune: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be pruned\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t\tremoveOrphans: z.boolean().default(false).describe(\"Also remove orphaned directories\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Remove stale index entries and find orphaned directories\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoPruneHandler({\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t\tremoveOrphans: input.removeOrphans,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tstatus: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Show summary of managed repos\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoStatusHandler({ json: input.json });\n\t\t\t}),\n\n\t\tgc: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tolderThan: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe(\"Remove repos not accessed in N days (e.g. '30d')\"),\n\t\t\t\t\twithoutReference: z.boolean().default(false).describe(\"Remove repos without references\"),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be removed\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Garbage collect old/unused repos\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoGcHandler({\n\t\t\t\t\tolderThan: input.olderThan,\n\t\t\t\t\twithoutReference: input.withoutReference,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tdiscover: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be added\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Discover and index existing repos in repoRoot\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoDiscoverHandler({\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\tupgrade: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\ttarget: z.string().optional().describe(\"Version to upgrade to\"),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Upgrade offworld to latest or specific version\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait upgradeHandler({\n\t\t\t\ttarget: input.target,\n\t\t\t});\n\t\t}),\n\n\tuninstall: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tkeepConfig: z.boolean().default(false).describe(\"Keep configuration files\"),\n\t\t\t\tkeepData: z.boolean().default(false).describe(\"Keep data files (references, repos)\"),\n\t\t\t\tdryRun: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Show what would be removed\")\n\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\tforce: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"f\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Uninstall offworld and remove related files\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait uninstallHandler({\n\t\t\t\tkeepConfig: input.keepConfig,\n\t\t\t\tkeepData: input.keepData,\n\t\t\t\tdryRun: input.dryRun,\n\t\t\t\tforce: input.force,\n\t\t\t});\n\t\t}),\n});\n\nconst stripSecondaryDescription = (help: string) =>\n\thelp\n\t\t.split(\"\\n\")\n\t\t.filter((line) => !line.startsWith(\"Available subcommands:\"))\n\t\t.join(\"\\n\");\n\nconst stripDefaultCommandHelp = (help: string) => {\n\tconst firstUsageIndex = help.indexOf(\"Usage:\");\n\tif (firstUsageIndex === -1) return help.trimEnd();\n\tconst secondUsageIndex = help.indexOf(\"Usage:\", firstUsageIndex + 1);\n\tif (secondUsageIndex === -1) return help.trimEnd();\n\treturn help.slice(0, secondUsageIndex).trimEnd();\n};\n\nconst normalizeRootHelp = (help: string) =>\n\tstripDefaultCommandHelp(stripSecondaryDescription(help));\n\nexport function createOwCli() {\n\tconst cli = createCli({\n\t\trouter,\n\t\tdescription: \"Offworld CLI - Repository reference generation for AI coding agents\",\n\t});\n\n\tconst buildProgram: typeof cli.buildProgram = (runParams) => {\n\t\tconst program = cli.buildProgram(runParams);\n\t\tconst originalHelpInformation = program.helpInformation.bind(program);\n\t\tprogram.helpInformation = () => normalizeRootHelp(originalHelpInformation());\n\t\treturn program;\n\t};\n\n\tconst run: typeof cli.run = (runParams, program) =>\n\t\tcli.run(runParams, program ?? buildProgram(runParams));\n\n\treturn {\n\t\t...cli,\n\t\tbuildProgram,\n\t\trun,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,IAAM,cAAN,MAAyC;CACxC,MAAM,UAAyB;CAC/B,KAAK,UAAyB;CAC9B,QAAQ,UAAwB;;;;;;;;;;AAWjC,SAAgB,gBAA6B;AAC5C,KAAI,QAAQ,OAAO,MAClB,QAAO,EAAE,SAAS;AAEnB,QAAO,IAAI,aAAa;;;;;AAMzB,MAAa,QAAQ,QAAQ,OAAO,SAAS;;;;ACgB7C,SAAS,YAAoB;AAC5B,yBAAO,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,IAAI,GAAG;;AAG9C,SAAS,YAAY,cAA8B;CAClD,MAAM,OAAO,SAAS;AACtB,KAAI,aAAa,WAAW,KAAK,CAChC,QAAO,MAAM,aAAa,MAAM,KAAK,OAAO;AAE7C,QAAO;;AAGR,SAAS,WAAW,SAAiB,SAAwB;AAC5D,KAAI,QACH,GAAE,IAAI,KAAK,IAAI,WAAW,CAAC,IAAI,UAAU;;AAI3C,SAAS,gBAAgB,QAA4B;AAEpD,QAAO,YADM,OAAO,SAAS,WAAW,OAAO,WAAW,OAAO,KACzC;;AAGzB,SAAS,cACR,QAC6D;CAE7D,MAAM,WAAW,KADD,gBAAgB,OAAO,EACR,YAAY;AAC3C,KAAI,CAAC,WAAW,SAAS,CACxB,QAAO;A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ACjD,MAAM,mBAAmB,KAAK,QAAQ,UAAU,kBAAkB,EAAE;AACpE,KAAI,qBAAqB,GAAI,QAAO,KAAK,SAAS;AAClD,QAAO,KAAK,MAAM,GAAG,iBAAiB,CAAC,SAAS;;AAGjD,MAAM,qBAAqB,SAC1B,wBAAwB,0BAA0B,KAAK,CAAC;AAEzD,SAAgB,cAAc;CAC7B,MAAM,MAAM,UAAU;EACrB;EACA,aAAa;EACb,CAAC;CAEF,MAAM,gBAAyC,cAAc;EAC5D,MAAM,UAAU,IAAI,aAAa,UAAU;EAC3C,MAAM,0BAA0B,QAAQ,gBAAgB,KAAK,QAAQ;AACrE,UAAQ,wBAAwB,kBAAkB,yBAAyB,CAAC;AAC5E,SAAO;;CAGR,MAAM,OAAuB,WAAW,YACvC,IAAI,IAAI,WAAW,WAAW,aAAa,UAAU,CAAC;AAEvD,QAAO;EACN,GAAG;EACH;EACA;EACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "offworld",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Offworld CLI - Repository reference generation for AI coding agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@clack/prompts": "^0.11.0",
|
|
72
|
-
"@offworld/sdk": "0.1.
|
|
73
|
-
"@offworld/types": "0.1.
|
|
72
|
+
"@offworld/sdk": "0.1.11",
|
|
73
|
+
"@offworld/types": "0.1.11",
|
|
74
74
|
"@orpc/server": "^1.13.4",
|
|
75
75
|
"convex": "^1.31.6",
|
|
76
76
|
"open": "^11.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-Dkw5_7x-.mjs","names":["parseModelFlag","detectProjectRoot"],"sources":["../src/utils/spinner.ts","../src/handlers/pull.ts","../src/handlers/generate.ts","../src/handlers/shared.ts","../src/handlers/repo.ts","../src/handlers/push.ts","../src/handlers/remove.ts","../src/handlers/config.ts","../src/handlers/auth.ts","../src/handlers/init.ts","../src/handlers/project.ts","../src/handlers/upgrade.ts","../src/handlers/uninstall.ts","../src/handlers/map.ts","../src/index.ts"],"sourcesContent":["import * as p from \"@clack/prompts\";\n\nexport interface SpinnerLike {\n\tstart(message?: string): void;\n\tstop(message?: string): void;\n\tmessage(message: string): void;\n}\n\nclass NoOpSpinner implements SpinnerLike {\n\tstart(_message?: string): void {}\n\tstop(_message?: string): void {}\n\tmessage(_message: string): void {}\n}\n\n/**\n * Creates a spinner that works in both TTY and non-TTY environments.\n * In TTY: returns a real @clack/prompts spinner with animation\n * In non-TTY: returns a no-op spinner that outputs nothing\n *\n * This prevents garbage output when running in non-interactive environments\n * (CI, piped output, agent sessions).\n */\nexport function createSpinner(): SpinnerLike {\n\tif (process.stdout.isTTY) {\n\t\treturn p.spinner();\n\t}\n\treturn new NoOpSpinner();\n}\n\n/**\n * Check if running in a TTY environment\n */\nexport const isTTY = process.stdout.isTTY ?? false;\n","import * as p from \"@clack/prompts\";\nimport {\n\tcloneRepo,\n\tupdateRepo,\n\tisRepoCloned,\n\tgetClonedRepoPath,\n\tgetCommitSha,\n\tgetCommitDistance,\n\tparseRepoInput,\n\tpullReference,\n\tpullReferenceByName,\n\tcheckRemote,\n\tcheckRemoteByName,\n\tloadConfig,\n\tloadAuthData,\n\tgetMetaPath,\n\tRepoExistsError,\n\tgenerateReferenceWithAI,\n\tinstallReference,\n} from \"@offworld/sdk\";\nimport { ReferenceMetaSchema, type RepoSource } from \"@offworld/types\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface PullOptions {\n\trepo: string;\n\treference?: string;\n\tshallow?: boolean;\n\tsparse?: boolean;\n\tbranch?: string;\n\tforce?: boolean;\n\tverbose?: boolean;\n\t/** Model override in provider/model format (e.g., \"anthropic/claude-sonnet-4-20250514\") */\n\tmodel?: string;\n}\n\nexport interface PullResult {\n\tsuccess: boolean;\n\trepoPath: string;\n\treferenceSource: \"remote\" | \"local\" | \"cached\";\n\treferenceInstalled: boolean;\n\tmessage?: string;\n}\n\nfunction timestamp(): string {\n\treturn new Date().toISOString().slice(11, 23);\n}\n\nfunction verboseLog(message: string, verbose: boolean): void {\n\tif (verbose) {\n\t\tp.log.info(`[${timestamp()}] ${message}`);\n\t}\n}\n\nfunction getLocalMetaDir(source: RepoSource): string {\n\tconst name = source.type === \"remote\" ? source.fullName : source.name;\n\treturn getMetaPath(name);\n}\n\nfunction loadLocalMeta(\n\tsource: RepoSource,\n): { commitSha?: string; referenceUpdatedAt?: string } | null {\n\tconst metaDir = getLocalMetaDir(source);\n\tconst metaPath = join(metaDir, \"meta.json\");\n\tif (!existsSync(metaPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst json = JSON.parse(readFileSync(metaPath, \"utf-8\"));\n\t\tconst parsed = ReferenceMetaSchema.safeParse(json);\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\t\treturn parsed.data;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction hasValidCache(source: RepoSource, currentSha: string): boolean {\n\tconst meta = loadLocalMeta(source);\n\treturn meta?.commitSha?.slice(0, 7) === currentSha.slice(0, 7);\n}\n\n/**\n * Save remote reference to local filesystem.\n * Remote reference comes with pre-generated reference content.\n */\nfunction saveRemoteReference(\n\tqualifiedName: string,\n\treferenceRepoName: string,\n\tlocalPath: string,\n\treferenceContent: string,\n\tcommitSha: string,\n\treferenceUpdatedAt: string,\n): void {\n\tconst meta = { referenceUpdatedAt, commitSha, version: \"0.1.0\" };\n\tinstallReference(qualifiedName, referenceRepoName, localPath, referenceContent, meta);\n}\n\nfunction parseModelFlag(model?: string): { provider?: string; model?: string } {\n\tif (!model) return {};\n\tconst parts = model.split(\"/\");\n\tif (parts.length === 2) {\n\t\treturn { provider: parts[0], model: parts[1] };\n\t}\n\treturn { model };\n}\n\nexport async function pullHandler(options: PullOptions): Promise<PullResult> {\n\tconst { repo, shallow = false, sparse = false, branch, force = false, verbose = false } = options;\n\tconst referenceName = options.reference?.trim() || undefined;\n\tconst { provider, model } = parseModelFlag(options.model);\n\tconst config = loadConfig();\n\tconst isReferenceOverride = Boolean(referenceName);\n\n\tconst s = createSpinner();\n\n\tif (verbose) {\n\t\tp.log.info(\n\t\t\t`[verbose] Options: repo=${repo}, reference=${referenceName ?? \"default\"}, shallow=${shallow}, branch=${branch || \"default\"}, force=${force}`,\n\t\t);\n\t}\n\n\ttry {\n\t\ts.start(\"Parsing repository input...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\t\tverboseLog(\n\t\t\t`Parsed source: type=${source.type}, qualifiedName=${source.qualifiedName}`,\n\t\t\tverbose,\n\t\t);\n\n\t\tlet repoPath: string;\n\n\t\tif (source.type === \"remote\") {\n\t\t\tconst qualifiedName = source.qualifiedName;\n\n\t\t\tif (isRepoCloned(qualifiedName)) {\n\t\t\t\ts.start(\"Updating repository...\");\n\t\t\t\tconst result = await updateRepo(qualifiedName);\n\t\t\t\trepoPath = getClonedRepoPath(qualifiedName)!;\n\n\t\t\t\tif (result.updated) {\n\t\t\t\t\ts.stop(`Updated (${result.previousSha.slice(0, 7)} → ${result.currentSha.slice(0, 7)})`);\n\t\t\t\t} else {\n\t\t\t\t\ts.stop(\"Already up to date\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ts.start(`Cloning ${source.fullName}...`);\n\t\t\t\ttry {\n\t\t\t\t\trepoPath = await cloneRepo(source, {\n\t\t\t\t\t\tshallow,\n\t\t\t\t\t\tsparse,\n\t\t\t\t\t\tbranch,\n\t\t\t\t\t\tconfig,\n\t\t\t\t\t\tforce,\n\t\t\t\t\t});\n\t\t\t\t\ts.stop(\"Repository cloned\");\n\t\t\t\t\tverboseLog(`Cloned to: ${repoPath}`, verbose);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tif (err instanceof RepoExistsError && !force) {\n\t\t\t\t\t\ts.stop(\"Repository exists\");\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trepoPath = source.path;\n\t\t}\n\n\t\tconst currentSha = getCommitSha(repoPath);\n\t\tconst qualifiedName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tif (isReferenceOverride && source.type !== \"remote\") {\n\t\t\tthrow new Error(\"--reference can only be used with remote repositories\");\n\t\t}\n\t\tif (isReferenceOverride && !referenceName) {\n\t\t\tthrow new Error(\"--reference requires a reference name\");\n\t\t}\n\t\tconst requiredReferenceName = referenceName ?? \"\";\n\n\t\tif (!force && !isReferenceOverride && hasValidCache(source, currentSha)) {\n\t\t\tverboseLog(\"Using cached reference\", verbose);\n\t\t\ts.stop(\"Using cached reference\");\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\trepoPath,\n\t\t\t\treferenceSource: \"cached\",\n\t\t\t\treferenceInstalled: true,\n\t\t\t};\n\t\t}\n\n\t\tif (source.type === \"remote\" && (!force || isReferenceOverride)) {\n\t\t\tverboseLog(`Checking offworld.sh for reference: ${source.fullName}`, verbose);\n\t\t\ts.start(\"Checking offworld.sh for reference...\");\n\n\t\t\ttry {\n\t\t\t\tconst remoteCheck = isReferenceOverride\n\t\t\t\t\t? await checkRemoteByName(source.fullName, requiredReferenceName)\n\t\t\t\t\t: await checkRemote(source.fullName);\n\n\t\t\t\tif (remoteCheck.exists && remoteCheck.commitSha) {\n\t\t\t\t\tconst remoteSha = remoteCheck.commitSha;\n\t\t\t\t\tconst remoteShaNorm = remoteSha.slice(0, 7);\n\t\t\t\t\tconst currentShaNorm = currentSha.slice(0, 7);\n\n\t\t\t\t\tconst MAX_COMMIT_DISTANCE = 20;\n\t\t\t\t\tconst commitDistance = getCommitDistance(repoPath, remoteSha, currentSha);\n\t\t\t\t\tconst isWithinThreshold =\n\t\t\t\t\t\tremoteShaNorm === currentShaNorm ||\n\t\t\t\t\t\t(commitDistance !== null && commitDistance <= MAX_COMMIT_DISTANCE);\n\n\t\t\t\t\tconst shouldDownload = isReferenceOverride || isWithinThreshold;\n\n\t\t\t\t\tif (shouldDownload) {\n\t\t\t\t\t\tif (!isReferenceOverride) {\n\t\t\t\t\t\t\tif (commitDistance === 0 || remoteShaNorm === currentShaNorm) {\n\t\t\t\t\t\t\t\tverboseLog(`Remote SHA matches (${remoteShaNorm})`, verbose);\n\t\t\t\t\t\t\t\ts.stop(\"Remote reference found (exact match)\");\n\t\t\t\t\t\t\t} else if (commitDistance !== null) {\n\t\t\t\t\t\t\t\tverboseLog(\n\t\t\t\t\t\t\t\t\t`Remote reference is ${commitDistance} commits behind (within ${MAX_COMMIT_DISTANCE} threshold)`,\n\t\t\t\t\t\t\t\t\tverbose,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\ts.stop(`Remote reference found (${commitDistance} commits behind)`);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tverboseLog(\"Remote reference found (commit distance unknown)\", verbose);\n\t\t\t\t\t\t\t\ts.stop(\"Remote reference found\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ts.stop(\"Remote reference found\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst previewUrl = referenceName\n\t\t\t\t\t\t\t? `https://offworld.sh/${source.fullName}/${encodeURIComponent(referenceName)}`\n\t\t\t\t\t\t\t: `https://offworld.sh/${source.fullName}`;\n\t\t\t\t\t\tp.log.info(`Preview: ${previewUrl}`);\n\n\t\t\t\t\t\tconst useRemote = await p.confirm({\n\t\t\t\t\t\t\tmessage: \"Download this reference from offworld.sh?\",\n\t\t\t\t\t\t\tinitialValue: true,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (p.isCancel(useRemote)) {\n\t\t\t\t\t\t\tthrow new Error(\"Operation cancelled\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!useRemote) {\n\t\t\t\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Remote reference download declined\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tp.log.info(\"Skipping remote reference, generating locally...\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ts.start(\"Downloading remote reference...\");\n\t\t\t\t\t\t\tconst remoteReference = isReferenceOverride\n\t\t\t\t\t\t\t\t? await pullReferenceByName(source.fullName, requiredReferenceName)\n\t\t\t\t\t\t\t\t: await pullReference(source.fullName);\n\n\t\t\t\t\t\t\tif (remoteReference) {\n\t\t\t\t\t\t\t\ts.stop(\"Downloaded remote reference\");\n\n\t\t\t\t\t\t\t\tsaveRemoteReference(\n\t\t\t\t\t\t\t\t\tsource.qualifiedName,\n\t\t\t\t\t\t\t\t\tsource.fullName,\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\tremoteReference.referenceContent,\n\t\t\t\t\t\t\t\t\tremoteReference.commitSha,\n\t\t\t\t\t\t\t\t\tremoteReference.generatedAt ?? new Date().toISOString(),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tp.log.success(\n\t\t\t\t\t\t\t\t\treferenceName\n\t\t\t\t\t\t\t\t\t\t? `Reference installed (${referenceName}) for: ${qualifiedName}`\n\t\t\t\t\t\t\t\t\t\t: `Reference installed for: ${qualifiedName}`,\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t\t\t\trepoPath,\n\t\t\t\t\t\t\t\t\treferenceSource: \"remote\",\n\t\t\t\t\t\t\t\t\treferenceInstalled: true,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Remote reference download failed\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ts.stop(\"Remote download failed, generating locally...\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst distanceInfo =\n\t\t\t\t\t\t\tcommitDistance !== null ? ` (${commitDistance} commits behind)` : \"\";\n\t\t\t\t\t\tverboseLog(\n\t\t\t\t\t\t\t`Remote reference too outdated${distanceInfo}, threshold is ${MAX_COMMIT_DISTANCE}`,\n\t\t\t\t\t\t\tverbose,\n\t\t\t\t\t\t);\n\t\t\t\t\t\ts.stop(`Remote reference outdated${distanceInfo}`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ts.stop(\"No remote reference found\");\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tverboseLog(\n\t\t\t\t\t`Remote check failed: ${err instanceof Error ? err.message : \"Unknown\"}`,\n\t\t\t\t\tverbose,\n\t\t\t\t);\n\t\t\t\tif (isReferenceOverride) {\n\t\t\t\t\tthrow err instanceof Error ? err : new Error(\"Remote check failed\");\n\t\t\t\t}\n\t\t\t\ts.stop(\"Remote check failed, continuing locally\");\n\t\t\t}\n\t\t}\n\n\t\tif (isReferenceOverride) {\n\t\t\tthrow new Error(`Reference not found on offworld.sh: ${referenceName}`);\n\t\t}\n\n\t\tverboseLog(`Starting AI reference generation for: ${repoPath}`, verbose);\n\n\t\tif (!verbose) {\n\t\t\ts.start(\"Generating reference with AI...\");\n\t\t}\n\n\t\ttry {\n\t\t\tconst onDebug = verbose\n\t\t\t\t? (message: string) => {\n\t\t\t\t\t\tp.log.info(`[${timestamp()}] [debug] ${message}`);\n\t\t\t\t\t}\n\t\t\t\t: (msg: string) => s.message(msg);\n\n\t\t\tconst result = await generateReferenceWithAI(repoPath, qualifiedName, {\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tonDebug,\n\t\t\t});\n\n\t\t\tconst { referenceContent, commitSha: referenceCommitSha } = result;\n\t\t\tconst referenceUpdatedAt = new Date().toISOString();\n\t\t\tconst meta = { referenceUpdatedAt, commitSha: referenceCommitSha, version: \"0.1.0\" };\n\t\t\tconst referenceRepoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\t\tinstallReference(source.qualifiedName, referenceRepoName, repoPath, referenceContent, meta);\n\n\t\t\tif (!verbose) {\n\t\t\t\ts.stop(\"Reference generated\");\n\t\t\t} else {\n\t\t\t\tp.log.success(\"Reference generated\");\n\t\t\t}\n\n\t\t\tp.log.success(`Reference installed for: ${qualifiedName}`);\n\n\t\t\tif (source.type === \"remote\") {\n\t\t\t\tconst authData = loadAuthData();\n\t\t\t\tif (authData?.token) {\n\t\t\t\t\tp.log.info(\n\t\t\t\t\t\t`Run 'ow push ${source.fullName}' to share this reference to https://offworld.sh.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\trepoPath,\n\t\t\t\treferenceSource: \"local\",\n\t\t\t\treferenceInstalled: true,\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tif (!verbose) {\n\t\t\t\ts.stop(\"Reference generation failed\");\n\t\t\t}\n\t\t\tconst errMessage = err instanceof Error ? err.message : \"Unknown error\";\n\t\t\tp.log.error(`Failed to generate reference: ${errMessage}`);\n\n\t\t\tthrow new Error(`Reference generation failed: ${errMessage}`);\n\t\t}\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\trepoPath: \"\",\n\t\t\treferenceSource: \"local\",\n\t\t\treferenceInstalled: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tcloneRepo,\n\tisRepoCloned,\n\tgetClonedRepoPath,\n\tcheckRemote,\n\tgenerateReferenceWithAI,\n\tinstallReference,\n\tloadConfig,\n\tgetReferencePath,\n} from \"@offworld/sdk\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface GenerateOptions {\n\trepo: string;\n\tforce?: boolean;\n\t/** Model override in provider/model format (e.g., \"anthropic/claude-sonnet-4-20250514\") */\n\tmodel?: string;\n}\n\nexport interface GenerateResult {\n\tsuccess: boolean;\n\treferencePath?: string;\n\tmessage?: string;\n}\n\nfunction parseModelFlag(model?: string): { provider?: string; model?: string } {\n\tif (!model) return {};\n\tconst parts = model.split(\"/\");\n\tif (parts.length === 2) {\n\t\treturn { provider: parts[0], model: parts[1] };\n\t}\n\treturn { model };\n}\n\nexport async function generateHandler(options: GenerateOptions): Promise<GenerateResult> {\n\tconst { repo, force = false } = options;\n\tconst { provider, model } = parseModelFlag(options.model);\n\tconst config = loadConfig();\n\n\tconst s = createSpinner();\n\n\ttry {\n\t\ts.start(\"Parsing repository input...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\n\t\tlet repoPath: string;\n\n\t\tif (source.type === \"remote\" && !force) {\n\t\t\ts.start(\"Checking for existing remote reference...\");\n\t\t\tconst remoteCheck = await checkRemote(source.fullName);\n\n\t\t\tif (remoteCheck.exists) {\n\t\t\t\ts.stop(\"Remote reference exists\");\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tmessage: \"Remote reference exists. Use --force to override.\",\n\t\t\t\t};\n\t\t\t}\n\t\t\ts.stop(\"No remote reference found\");\n\t\t}\n\n\t\tif (source.type === \"remote\") {\n\t\t\tconst qualifiedName = source.qualifiedName;\n\n\t\t\tif (isRepoCloned(qualifiedName)) {\n\t\t\t\trepoPath = getClonedRepoPath(qualifiedName)!;\n\t\t\t\tp.log.info(`Using existing clone at ${repoPath}`);\n\t\t\t} else {\n\t\t\t\ts.start(`Cloning ${source.fullName}...`);\n\t\t\t\trepoPath = await cloneRepo(source, {\n\t\t\t\t\tshallow: config.defaultShallow,\n\t\t\t\t\tconfig,\n\t\t\t\t});\n\t\t\t\ts.stop(\"Repository cloned\");\n\t\t\t}\n\t\t} else {\n\t\t\trepoPath = source.path;\n\t\t}\n\n\t\ts.start(\"Generating reference with AI...\");\n\n\t\tconst qualifiedName = source.qualifiedName;\n\t\tconst referenceRepoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tconst result = await generateReferenceWithAI(repoPath, referenceRepoName, {\n\t\t\tprovider,\n\t\t\tmodel,\n\t\t\tonDebug: (msg: string) => s.message(msg),\n\t\t});\n\t\ts.stop(\"Reference generated\");\n\n\t\tconst { referenceContent, commitSha } = result;\n\t\tconst referenceUpdatedAt = new Date().toISOString();\n\t\tconst meta = { referenceUpdatedAt, commitSha, version: \"0.1.0\" };\n\n\t\tconst referencePath = getReferencePath(referenceRepoName);\n\n\t\tinstallReference(qualifiedName, referenceRepoName, repoPath, referenceContent, meta);\n\n\t\tp.log.success(`Reference saved to: ${referencePath}`);\n\t\tp.log.info(`Reference installed for: ${qualifiedName}`);\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\treferencePath,\n\t\t};\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n","/**\n * Shared utilities for CLI handlers\n */\n\nimport { readGlobalMap } from \"@offworld/sdk\";\nimport { existsSync } from \"node:fs\";\n\nexport interface RepoListItem {\n\tfullName: string;\n\tqualifiedName: string;\n\tlocalPath: string;\n\thasReference: boolean;\n\treferenceUpdatedAt?: string;\n\tcommitSha?: string;\n\texists: boolean;\n}\n\n/**\n * Format a repo entry for display\n */\nexport function formatRepoForDisplay(item: RepoListItem, showPaths: boolean): string {\n\tconst parts: string[] = [item.fullName];\n\n\tif (item.hasReference) {\n\t\tparts.push(\"[reference]\");\n\t} else {\n\t\tparts.push(\"[no-reference]\");\n\t}\n\n\tif (showPaths) parts.push(`(${item.localPath})`);\n\tif (!item.exists) parts.push(\"[missing]\");\n\n\treturn parts.join(\" \");\n}\n\n/**\n * Convert qualified name to list item\n */\nexport async function entryToListItem(qualifiedName: string): Promise<RepoListItem> {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\n\tif (!entry) {\n\t\treturn {\n\t\t\tfullName: qualifiedName,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: \"\",\n\t\t\thasReference: false,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tconst exists = existsSync(entry.localPath);\n\tconst hasReference = !!entry.references && entry.references.length > 0;\n\n\treturn {\n\t\tfullName: qualifiedName,\n\t\tqualifiedName,\n\t\tlocalPath: entry.localPath,\n\t\thasReference,\n\t\treferenceUpdatedAt: entry.updatedAt,\n\t\tcommitSha: undefined, // Map doesn't store commitSha yet\n\t\texists,\n\t};\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tlistRepos,\n\tgetRepoStatus,\n\tupdateAllRepos,\n\tpruneRepos,\n\tgcRepos,\n\tdiscoverRepos,\n\tgetRepoRoot,\n\tloadConfig,\n\treadGlobalMap,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { formatRepoForDisplay, type RepoListItem } from \"./shared.js\";\n\nexport interface RepoListOptions {\n\tjson?: boolean;\n\tpaths?: boolean;\n\tpattern?: string;\n}\n\nexport type { RepoListItem };\n\nexport interface RepoListResult {\n\trepos: RepoListItem[];\n}\n\nexport interface RepoUpdateOptions {\n\tall?: boolean;\n\tpattern?: string;\n\tdryRun?: boolean;\n\t/** Convert shallow clones to full clones */\n\tunshallow?: boolean;\n}\n\nexport interface RepoUpdateResult {\n\tupdated: string[];\n\tskipped: string[];\n\tunshallowed: string[];\n\terrors: Array<{ repo: string; error: string }>;\n}\n\nexport interface RepoPruneOptions {\n\tdryRun?: boolean;\n\tyes?: boolean;\n\tremoveOrphans?: boolean;\n}\n\nexport interface RepoPruneResult {\n\tremovedFromIndex: string[];\n\torphanedDirs: string[];\n\tremovedOrphans: string[];\n}\n\nexport interface RepoStatusOptions {\n\tjson?: boolean;\n}\n\nexport interface RepoStatusResult {\n\ttotal: number;\n\twithReference: number;\n\tmissing: number;\n\tdiskMB: number;\n}\n\nexport interface RepoGcOptions {\n\tolderThan?: string;\n\twithoutReference?: boolean;\n\tdryRun?: boolean;\n\tyes?: boolean;\n}\n\nexport interface RepoGcResult {\n\tremoved: Array<{ repo: string; reason: string; sizeMB: number }>;\n\tfreedMB: number;\n}\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes < 1024) return `${bytes} B`;\n\tif (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n\tif (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n\treturn `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;\n}\n\nfunction parseDays(olderThan: string): number | null {\n\tconst match = olderThan.match(/^(\\d+)d$/);\n\tif (match?.[1]) return parseInt(match[1], 10);\n\treturn null;\n}\n\nfunction matchesPattern(name: string, pattern: string): boolean {\n\tif (!pattern || pattern === \"*\") return true;\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\nexport async function repoListHandler(options: RepoListOptions): Promise<RepoListResult> {\n\tconst { json = false, paths = false, pattern } = options;\n\n\tconst qualifiedNames = listRepos();\n\tconst map = readGlobalMap();\n\n\tif (qualifiedNames.length === 0) {\n\t\tif (!json) {\n\t\t\tp.log.info(\"No repositories cloned yet.\");\n\t\t\tp.log.info(\"Use 'ow pull <repo>' to clone and generate a reference.\");\n\t\t}\n\t\treturn { repos: [] };\n\t}\n\n\tconst items: RepoListItem[] = [];\n\tfor (const qName of qualifiedNames) {\n\t\tconst entry = map.repos[qName];\n\t\tif (!entry) continue;\n\t\tif (pattern && !matchesPattern(qName, pattern)) continue;\n\n\t\tconst exists = existsSync(entry.localPath);\n\t\tconst hasReference = !!entry.primary;\n\n\t\titems.push({\n\t\t\tfullName: qName,\n\t\t\tqualifiedName: qName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\thasReference,\n\t\t\treferenceUpdatedAt: entry.updatedAt,\n\t\t\texists,\n\t\t});\n\t}\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(items, null, 2));\n\t} else {\n\t\tif (items.length === 0) {\n\t\t\tif (pattern) {\n\t\t\t\tp.log.info(`No repositories matching \"${pattern}\".`);\n\t\t\t}\n\t\t} else {\n\t\t\tp.log.info(`Found ${items.length} repositories:\\n`);\n\t\t\tfor (const item of items) {\n\t\t\t\tconsole.log(formatRepoForDisplay(item, paths));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { repos: items };\n}\n\nexport async function repoUpdateHandler(options: RepoUpdateOptions): Promise<RepoUpdateResult> {\n\tconst { all = false, pattern, dryRun = false, unshallow = false } = options;\n\n\tif (!all && !pattern) {\n\t\tp.log.error(\"Specify --all or a pattern to update.\");\n\t\treturn { updated: [], skipped: [], unshallowed: [], errors: [] };\n\t}\n\n\tconst qualifiedNames = listRepos();\n\tconst filtered = pattern\n\t\t? qualifiedNames.filter((q) => matchesPattern(q, pattern))\n\t\t: qualifiedNames;\n\tconst total = filtered.length;\n\n\tif (total === 0) {\n\t\tp.log.info(pattern ? `No repos matching \"${pattern}\"` : \"No repos to update\");\n\t\treturn { updated: [], skipped: [], unshallowed: [], errors: [] };\n\t}\n\n\tlet processed = 0;\n\tconst outcomes: Array<{ repo: string; status: string; message?: string }> = [];\n\n\tconst spinner = p.spinner();\n\tconst action = unshallow ? \"Unshallowing\" : \"Updating\";\n\tspinner.start(dryRun ? `Checking ${total} repos...` : `${action} ${total} repos...`);\n\n\tconst result = await updateAllRepos({\n\t\tpattern,\n\t\tdryRun,\n\t\tunshallow,\n\t\tonProgress: (repo: string, status: string, message?: string) => {\n\t\t\tif (status === \"updating\") {\n\t\t\t\tprocessed++;\n\t\t\t\tspinner.message(`[${processed}/${total}] ${repo}`);\n\t\t\t} else {\n\t\t\t\toutcomes.push({ repo, status, message });\n\t\t\t}\n\t\t},\n\t});\n\n\tspinner.stop(dryRun ? \"Dry run complete\" : `${action} complete`);\n\n\tfor (const { repo, status, message } of outcomes) {\n\t\tif (status === \"updated\") {\n\t\t\tp.log.success(`${repo}${message ? ` (${message})` : \"\"}`);\n\t\t} else if (status === \"unshallowed\") {\n\t\t\tp.log.success(`${repo}: ${message}`);\n\t\t} else if (status === \"error\") {\n\t\t\tp.log.error(`${repo}: ${message}`);\n\t\t} else if (\n\t\t\tstatus === \"skipped\" &&\n\t\t\tmessage !== \"up to date\" &&\n\t\t\tmessage !== \"already up to date\"\n\t\t) {\n\t\t\tp.log.warn(`${repo}: ${message}`);\n\t\t}\n\t}\n\n\tconst parts: string[] = [];\n\tif (result.updated.length > 0)\n\t\tparts.push(`${result.updated.length} ${dryRun ? \"would update\" : \"updated\"}`);\n\tif (result.unshallowed.length > 0) parts.push(`${result.unshallowed.length} unshallowed`);\n\tif (result.skipped.length > 0) parts.push(`${result.skipped.length} skipped`);\n\tif (result.errors.length > 0) parts.push(`${result.errors.length} failed`);\n\n\tif (parts.length > 0) {\n\t\tp.log.info(`Summary: ${parts.join(\", \")}`);\n\t}\n\n\treturn result;\n}\n\nexport async function repoPruneHandler(options: RepoPruneOptions): Promise<RepoPruneResult> {\n\tconst { dryRun = false, yes = false, removeOrphans = false } = options;\n\n\tconst result = await pruneRepos({ dryRun: true });\n\tconst removedOrphans: string[] = [];\n\n\tif (result.removedFromIndex.length === 0 && result.orphanedDirs.length === 0) {\n\t\tp.log.info(\"Nothing to prune. Index and filesystem are in sync.\");\n\t\treturn { removedFromIndex: [], orphanedDirs: [], removedOrphans: [] };\n\t}\n\n\tif (result.removedFromIndex.length > 0) {\n\t\tp.log.info(`Found ${result.removedFromIndex.length} repos in index but missing on disk:`);\n\t\tfor (const repo of result.removedFromIndex) {\n\t\t\tconsole.log(` - ${repo}`);\n\t\t}\n\t}\n\n\tif (result.orphanedDirs.length > 0) {\n\t\tp.log.info(`Found ${result.orphanedDirs.length} directories not in index:`);\n\t\tfor (const dir of result.orphanedDirs) {\n\t\t\tconsole.log(` - ${dir}`);\n\t\t}\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn { ...result, removedOrphans: [] };\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Remove stale index entries?\" });\n\t\tif (p.isCancel(confirm)) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { removedFromIndex: [], orphanedDirs: result.orphanedDirs, removedOrphans: [] };\n\t\t}\n\t\tshouldProceed = confirm;\n\t}\n\n\tif (shouldProceed) {\n\t\tawait pruneRepos({ dryRun: false });\n\t\tp.log.success(`Removed ${result.removedFromIndex.length} stale index entries.`);\n\t}\n\n\tif (removeOrphans && result.orphanedDirs.length > 0) {\n\t\tlet shouldRemoveOrphans = yes;\n\t\tif (!yes) {\n\t\t\tconst confirm = await p.confirm({ message: \"Also remove orphaned directories?\" });\n\t\t\tif (!p.isCancel(confirm) && confirm) {\n\t\t\t\tshouldRemoveOrphans = true;\n\t\t\t}\n\t\t}\n\n\t\tif (shouldRemoveOrphans) {\n\t\t\tfor (const dir of result.orphanedDirs) {\n\t\t\t\trmSync(dir, { recursive: true, force: true });\n\t\t\t\tremovedOrphans.push(dir);\n\t\t\t}\n\t\t\tp.log.success(`Removed ${removedOrphans.length} orphaned directories.`);\n\t\t}\n\t}\n\n\treturn { ...result, removedOrphans };\n}\n\nexport async function repoStatusHandler(options: RepoStatusOptions): Promise<RepoStatusResult> {\n\tconst { json = false } = options;\n\n\tconst spinner = p.spinner();\n\tspinner.start(\"Calculating repo status...\");\n\n\tconst status = await getRepoStatus({\n\t\tonProgress: (current, total, repo) => {\n\t\t\tspinner.message(`[${current}/${total}] ${repo}`);\n\t\t},\n\t});\n\n\tspinner.stop(\"Status complete\");\n\n\tconst output: RepoStatusResult = {\n\t\ttotal: status.total,\n\t\twithReference: status.withReference,\n\t\tmissing: status.missing,\n\t\tdiskMB: Math.round(status.diskBytes / (1024 * 1024)),\n\t};\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(output, null, 2));\n\t} else {\n\t\tp.log.info(`Managed repos: ${status.total}`);\n\t\tp.log.info(` With reference: ${status.withReference}`);\n\t\tp.log.info(` Missing: ${status.missing}`);\n\t\tp.log.info(` Disk usage: ${formatBytes(status.diskBytes)}`);\n\t}\n\n\treturn output;\n}\n\nexport async function repoGcHandler(options: RepoGcOptions): Promise<RepoGcResult> {\n\tconst { olderThan, withoutReference = false, dryRun = false, yes = false } = options;\n\n\tif (!olderThan && !withoutReference) {\n\t\tp.log.error(\"Specify at least one filter: --older-than or --without-reference\");\n\t\treturn { removed: [], freedMB: 0 };\n\t}\n\n\tlet olderThanDays: number | undefined;\n\tif (olderThan) {\n\t\tconst days = parseDays(olderThan);\n\t\tif (days === null) {\n\t\t\tp.log.error(\"Invalid --older-than format. Use e.g. '30d' for 30 days.\");\n\t\t\treturn { removed: [], freedMB: 0 };\n\t\t}\n\t\tolderThanDays = days;\n\t}\n\n\tconst previewResult = await gcRepos({\n\t\tolderThanDays,\n\t\twithoutReference,\n\t\tdryRun: true,\n\t});\n\n\tif (previewResult.removed.length === 0) {\n\t\tp.log.info(\"No repos match the criteria.\");\n\t\treturn { removed: [], freedMB: 0 };\n\t}\n\n\tp.log.info(\n\t\t`Found ${previewResult.removed.length} repos to remove (${formatBytes(previewResult.freedBytes)}):`,\n\t);\n\tfor (const { repo, reason, sizeBytes } of previewResult.removed) {\n\t\tconsole.log(` - ${repo} (${formatBytes(sizeBytes)}) - ${reason}`);\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn {\n\t\t\tremoved: previewResult.removed.map(\n\t\t\t\t(r: { repo: string; reason: string; sizeBytes: number }) => ({\n\t\t\t\t\trepo: r.repo,\n\t\t\t\t\treason: r.reason,\n\t\t\t\t\tsizeMB: Math.round(r.sizeBytes / (1024 * 1024)),\n\t\t\t\t}),\n\t\t\t),\n\t\t\tfreedMB: Math.round(previewResult.freedBytes / (1024 * 1024)),\n\t\t};\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Proceed with removal?\" });\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { removed: [], freedMB: 0 };\n\t\t}\n\t\tshouldProceed = true;\n\t}\n\n\tif (shouldProceed) {\n\t\tconst result = await gcRepos({\n\t\t\tolderThanDays,\n\t\t\twithoutReference,\n\t\t\tdryRun: false,\n\t\t});\n\n\t\tp.log.success(\n\t\t\t`Removed ${result.removed.length} repos, freed ${formatBytes(result.freedBytes)}`,\n\t\t);\n\n\t\treturn {\n\t\t\tremoved: result.removed.map((r: { repo: string; reason: string; sizeBytes: number }) => ({\n\t\t\t\trepo: r.repo,\n\t\t\t\treason: r.reason,\n\t\t\t\tsizeMB: Math.round(r.sizeBytes / (1024 * 1024)),\n\t\t\t})),\n\t\t\tfreedMB: Math.round(result.freedBytes / (1024 * 1024)),\n\t\t};\n\t}\n\n\treturn { removed: [], freedMB: 0 };\n}\n\nexport interface RepoDiscoverOptions {\n\tdryRun?: boolean;\n\tyes?: boolean;\n}\n\nexport interface RepoDiscoverResult {\n\tdiscovered: number;\n\talreadyIndexed: number;\n}\n\nexport async function repoDiscoverHandler(\n\toptions: RepoDiscoverOptions,\n): Promise<RepoDiscoverResult> {\n\tconst { dryRun = false, yes = false } = options;\n\n\tconst config = loadConfig();\n\tconst repoRoot = getRepoRoot(config);\n\n\tif (!existsSync(repoRoot)) {\n\t\tp.log.error(`Repo root does not exist: ${repoRoot}`);\n\t\treturn { discovered: 0, alreadyIndexed: 0 };\n\t}\n\n\tconst previewResult = await discoverRepos({ repoRoot, dryRun: true });\n\n\tif (previewResult.discovered.length === 0) {\n\t\tif (previewResult.alreadyIndexed > 0) {\n\t\t\tp.log.info(`All ${previewResult.alreadyIndexed} repos already indexed.`);\n\t\t} else {\n\t\t\tp.log.info(\"No repos found to discover.\");\n\t\t}\n\t\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n\t}\n\n\tp.log.info(`Found ${previewResult.discovered.length} unindexed repos:`);\n\tfor (const repo of previewResult.discovered.slice(0, 20)) {\n\t\tconsole.log(` + ${repo.fullName}`);\n\t}\n\tif (previewResult.discovered.length > 20) {\n\t\tconsole.log(` ... and ${previewResult.discovered.length - 20} more`);\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no changes made.\");\n\t\treturn {\n\t\t\tdiscovered: previewResult.discovered.length,\n\t\t\talreadyIndexed: previewResult.alreadyIndexed,\n\t\t};\n\t}\n\n\tlet shouldProceed = yes;\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({ message: \"Add these repos to the index?\" });\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Cancelled.\");\n\t\t\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n\t\t}\n\t\tshouldProceed = true;\n\t}\n\n\tif (shouldProceed) {\n\t\tconst result = await discoverRepos({ repoRoot });\n\t\tp.log.success(\n\t\t\t`Added ${result.discovered.length} repos to clone map (marked as not referenced)`,\n\t\t);\n\t\treturn { discovered: result.discovered.length, alreadyIndexed: result.alreadyIndexed };\n\t}\n\n\treturn { discovered: 0, alreadyIndexed: previewResult.alreadyIndexed };\n}\n","/**\n * Push command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tgetToken,\n\tgetMetaPath,\n\tgetReferencePath,\n\ttoReferenceName,\n\tgetCommitSha,\n\tgetClonedRepoPath,\n\tisRepoCloned,\n\tpushReference,\n\tNotLoggedInError,\n\tTokenExpiredError,\n\tAuthenticationError,\n\tRateLimitError,\n\tCommitExistsError,\n\tInvalidInputError,\n\tInvalidReferenceError,\n\tSyncRepoNotFoundError,\n\tLowStarsError,\n\tPrivateRepoError,\n\tCommitNotFoundError,\n\tGitHubError,\n\ttype ReferenceData,\n} from \"@offworld/sdk\";\nimport { ReferenceMetaSchema } from \"@offworld/types\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface PushOptions {\n\trepo: string;\n}\n\nexport interface PushResult {\n\tsuccess: boolean;\n\tmessage: string;\n}\n\nconst DESCRIPTION_MAX = 200;\n\nfunction extractDescription(referenceContent: string, fallback: string): string {\n\tconst lines = referenceContent.split(/\\r?\\n/);\n\tlet sawTitle = false;\n\tlet description = \"\";\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i]?.trim() ?? \"\";\n\t\tif (!line) continue;\n\t\tif (line.startsWith(\"# \")) {\n\t\t\tsawTitle = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!sawTitle || line.startsWith(\"#\")) continue;\n\n\t\tdescription = line;\n\t\tfor (let j = i + 1; j < lines.length; j++) {\n\t\t\tconst next = lines[j]?.trim() ?? \"\";\n\t\t\tif (!next || next.startsWith(\"#\")) break;\n\t\t\tdescription += ` ${next}`;\n\t\t}\n\t\tbreak;\n\t}\n\n\tdescription = description.replace(/\\s+/g, \" \").trim();\n\tif (!description) description = fallback;\n\tif (description.length > DESCRIPTION_MAX)\n\t\tdescription = description.slice(0, DESCRIPTION_MAX).trim();\n\tif (!description) description = fallback.slice(0, DESCRIPTION_MAX);\n\treturn description;\n}\n\n/**\n * Load local reference data from disk.\n * Format: reference file + meta.json\n */\nfunction loadLocalReference(\n\tmetaDir: string,\n\treferencePath: string,\n\tfullName: string,\n): ReferenceData | null {\n\tconst metaPath = join(metaDir, \"meta.json\");\n\n\tif (!existsSync(referencePath) || !existsSync(metaPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst referenceContent = readFileSync(referencePath, \"utf-8\");\n\t\tconst json = JSON.parse(readFileSync(metaPath, \"utf-8\"));\n\t\tconst parsed = ReferenceMetaSchema.safeParse(json);\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\t\tconst meta = parsed.data;\n\t\tconst referenceName = toReferenceName(fullName);\n\t\tconst referenceDescription = extractDescription(referenceContent, `Reference for ${fullName}`);\n\n\t\treturn {\n\t\t\tfullName: \"\",\n\t\t\treferenceName,\n\t\t\treferenceDescription,\n\t\t\treferenceContent,\n\t\t\tcommitSha: meta.commitSha,\n\t\t\tgeneratedAt: meta.referenceUpdatedAt,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function pushHandler(options: PushOptions): Promise<PushResult> {\n\tconst { repo } = options;\n\tconst s = createSpinner();\n\n\ttry {\n\t\tlet token: string;\n\t\ttry {\n\t\t\ttoken = await getToken();\n\t\t} catch (err) {\n\t\t\tif (err instanceof NotLoggedInError || err instanceof TokenExpiredError) {\n\t\t\t\tp.log.error(err.message);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\t\t\tthrow err;\n\t\t}\n\n\t\ts.start(\"Parsing repository...\");\n\t\tconst source = parseRepoInput(repo);\n\t\ts.stop(\"Repository parsed\");\n\n\t\tif (source.type === \"local\") {\n\t\t\tp.log.error(\"Local repositories cannot be pushed to offworld.sh.\");\n\t\t\tp.log.info(\"Only remote GitHub repositories can be pushed.\");\n\t\t\treturn { success: false, message: \"Local repositories not supported\" };\n\t\t}\n\n\t\tif (source.provider !== \"github\") {\n\t\t\tp.log.error(`${source.provider} repositories are not yet supported.`);\n\t\t\tp.log.info(\"GitHub support only for now - GitLab and Bitbucket coming soon!\");\n\t\t\treturn { success: false, message: \"Only GitHub repositories supported\" };\n\t\t}\n\n\t\tif (!isRepoCloned(source.qualifiedName)) {\n\t\t\tp.log.error(`Repository ${source.fullName} is not cloned locally.`);\n\t\t\tp.log.info(`Run 'ow pull ${source.fullName}' first to clone and analyze.`);\n\t\t\treturn { success: false, message: \"Repository not cloned locally\" };\n\t\t}\n\n\t\ts.start(\"Loading local reference...\");\n\t\tconst metaDir = getMetaPath(source.fullName);\n\t\tconst referencePath = getReferencePath(source.fullName);\n\n\t\tif (!existsSync(metaDir) || !existsSync(referencePath)) {\n\t\t\ts.stop(\"No reference found\");\n\t\t\tp.log.error(`No reference found for ${source.fullName}.`);\n\t\t\tp.log.info(`Run 'ow generate ${source.fullName}' to generate reference.`);\n\t\t\treturn { success: false, message: \"No local reference found\" };\n\t\t}\n\n\t\tconst localReference = loadLocalReference(metaDir, referencePath, source.fullName);\n\n\t\tif (!localReference) {\n\t\t\ts.stop(\"Invalid reference\");\n\t\t\tp.log.error(\"Local reference is incomplete or corrupted.\");\n\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\treturn { success: false, message: \"Local reference incomplete\" };\n\t\t}\n\n\t\tlocalReference.fullName = source.fullName;\n\n\t\tconst repoPath = getClonedRepoPath(source.qualifiedName);\n\t\tif (repoPath) {\n\t\t\tconst currentSha = getCommitSha(repoPath);\n\t\t\tif (currentSha !== localReference.commitSha) {\n\t\t\t\ts.stop(\"Reference outdated\");\n\t\t\t\tp.log.warn(\"Local reference was generated for a different commit.\");\n\t\t\t\tp.log.info(`Reference: ${localReference.commitSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(`Current: ${currentSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\t\treturn { success: false, message: \"Reference outdated - run generate to update\" };\n\t\t\t}\n\t\t}\n\n\t\ts.stop(\"Reference loaded\");\n\n\t\ts.start(\"Uploading to offworld.sh...\");\n\t\ttry {\n\t\t\tconst result = await pushReference(localReference, token);\n\n\t\t\tif (result.success) {\n\t\t\t\ts.stop(\"Reference uploaded!\");\n\t\t\t\tp.log.success(`Successfully pushed reference for ${source.fullName}`);\n\t\t\t\tp.log.info(`View at: https://offworld.sh/${source.owner}/${source.repo}`);\n\t\t\t\treturn { success: true, message: \"Reference pushed successfully\" };\n\t\t\t}\n\t\t\ts.stop(\"Upload failed\");\n\t\t\tp.log.error(result.message || \"Unknown error during upload\");\n\t\t\treturn { success: false, message: result.message || \"Upload failed\" };\n\t\t} catch (err) {\n\t\t\ts.stop(\"Upload failed\");\n\n\t\t\tif (err instanceof AuthenticationError) {\n\t\t\t\tp.log.error(\"Authentication failed.\");\n\t\t\t\tp.log.info(\"Please run 'ow auth login' again.\");\n\t\t\t\treturn { success: false, message: \"Authentication failed\" };\n\t\t\t}\n\n\t\t\tif (err instanceof RateLimitError) {\n\t\t\t\tp.log.error(\"Rate limit exceeded.\");\n\t\t\t\tp.log.info(\"You can push up to 20 references per day.\");\n\t\t\t\tp.log.info(\"Please try again tomorrow.\");\n\t\t\t\treturn { success: false, message: \"Rate limit exceeded\" };\n\t\t\t}\n\n\t\t\tif (err instanceof CommitExistsError) {\n\t\t\t\tp.log.error(\"A reference already exists for this commit.\");\n\t\t\t\tp.log.info(`Commit: ${localReference.commitSha.slice(0, 7)}`);\n\t\t\t\tp.log.info(\n\t\t\t\t\t\"References are immutable per commit. Update the repo and regenerate to push a new version.\",\n\t\t\t\t);\n\t\t\t\treturn { success: false, message: \"Reference already exists for this commit\" };\n\t\t\t}\n\n\t\t\tif (err instanceof InvalidInputError) {\n\t\t\t\tp.log.error(\"Invalid input data.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\n\t\t\tif (err instanceof InvalidReferenceError) {\n\t\t\t\tp.log.error(\"Invalid reference content.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\tp.log.info(`Run 'ow generate ${source.fullName} --force' to regenerate.`);\n\t\t\t\treturn { success: false, message: err.message };\n\t\t\t}\n\n\t\t\tif (err instanceof SyncRepoNotFoundError) {\n\t\t\t\tp.log.error(\"Repository not found on GitHub.\");\n\t\t\t\tp.log.info(\"Ensure the repository exists and is public.\");\n\t\t\t\treturn { success: false, message: \"Repository not found\" };\n\t\t\t}\n\n\t\t\tif (err instanceof LowStarsError) {\n\t\t\t\tp.log.error(\"Repository does not meet star requirements.\");\n\t\t\t\tp.log.info(\"Repositories need at least 5 stars to be pushed to offworld.sh.\");\n\t\t\t\tp.log.info(\"This helps ensure quality skills for the community.\");\n\t\t\t\treturn { success: false, message: \"Repository needs 5+ stars\" };\n\t\t\t}\n\n\t\t\tif (err instanceof PrivateRepoError) {\n\t\t\t\tp.log.error(\"Private repositories are not supported.\");\n\t\t\t\tp.log.info(\"Only public GitHub repositories can be pushed to offworld.sh.\");\n\t\t\t\treturn { success: false, message: \"Private repos not supported\" };\n\t\t\t}\n\n\t\t\tif (err instanceof CommitNotFoundError) {\n\t\t\t\tp.log.error(\"Commit not found in repository.\");\n\t\t\t\tp.log.info(\"The analyzed commit may have been rebased or removed.\");\n\t\t\t\tp.log.info(\n\t\t\t\t\t`Run 'ow generate ${source.fullName} --force' to regenerate with current commit.`,\n\t\t\t\t);\n\t\t\t\treturn { success: false, message: \"Commit not found\" };\n\t\t\t}\n\n\t\t\tif (err instanceof GitHubError) {\n\t\t\t\tp.log.error(\"GitHub API error.\");\n\t\t\t\tp.log.info(err.message);\n\t\t\t\tp.log.info(\"Please try again later.\");\n\t\t\t\treturn { success: false, message: \"GitHub API error\" };\n\t\t\t}\n\n\t\t\tthrow err;\n\t\t}\n\t} catch (error) {\n\t\ts.stop(\"Failed\");\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Remove command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tparseRepoInput,\n\tremoveRepo,\n\ttoReferenceFileName,\n\treadGlobalMap,\n\tgetMetaPath,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { createSpinner } from \"../utils/spinner\";\n\nexport interface RmOptions {\n\trepo: string;\n\tyes?: boolean;\n\treferenceOnly?: boolean;\n\trepoOnly?: boolean;\n\tdryRun?: boolean;\n}\n\nexport interface RmResult {\n\tsuccess: boolean;\n\tremoved?: {\n\t\trepoPath?: string;\n\t\treferencePath?: string;\n\t\tsymlinkPaths?: string[];\n\t};\n\tmessage?: string;\n}\n\nfunction getAffectedPathsFromMap(qualifiedName: string): {\n\trepoPath?: string;\n\treferencePath?: string;\n\tsymlinkPaths: string[];\n} | null {\n\tconst map = readGlobalMap();\n\tconst entry = map.repos[qualifiedName];\n\tif (!entry) {\n\t\treturn null;\n\t}\n\n\tconst repoPath = entry.localPath;\n\tconst referenceFileName = entry.primary || \"\";\n\tconst referencePath = referenceFileName\n\t\t? join(Paths.offworldReferencesDir, referenceFileName)\n\t\t: undefined;\n\n\treturn {\n\t\trepoPath: existsSync(repoPath) ? repoPath : undefined,\n\t\treferencePath: referencePath && existsSync(referencePath) ? referencePath : undefined,\n\t\tsymlinkPaths: [],\n\t};\n}\n\nexport async function rmHandler(options: RmOptions): Promise<RmResult> {\n\tconst { repo, yes = false, referenceOnly = false, repoOnly = false, dryRun = false } = options;\n\n\ttry {\n\t\tconst source = parseRepoInput(repo);\n\t\tconst qualifiedName = source.qualifiedName;\n\t\tconst repoName = source.type === \"remote\" ? source.fullName : source.name;\n\n\t\tif (referenceOnly && repoOnly) {\n\t\t\tp.log.error(\"Cannot use --reference-only and --repo-only together\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Invalid options\",\n\t\t\t};\n\t\t}\n\n\t\tconst map = readGlobalMap();\n\t\tconst entry = map.repos[qualifiedName];\n\n\t\tif (!entry && !referenceOnly) {\n\t\t\tp.log.warn(`Repository not found in map: ${repo}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Repository not found\",\n\t\t\t};\n\t\t}\n\n\t\tif (referenceOnly && !entry) {\n\t\t\treturn handleReferenceOnlyRemoval(repoName, yes, dryRun);\n\t\t}\n\n\t\tconst affected = getAffectedPathsFromMap(qualifiedName)!;\n\n\t\tif (dryRun || !yes) {\n\t\t\tp.log.info(\"The following will be removed:\");\n\n\t\t\tif (!referenceOnly && affected.repoPath) {\n\t\t\t\tconsole.log(` Repository: ${affected.repoPath}`);\n\t\t\t}\n\t\t\tif (!repoOnly && affected.referencePath) {\n\t\t\t\tconsole.log(` Reference: ${affected.referencePath}`);\n\t\t\t}\n\t\t\tconsole.log(\"\");\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tp.log.info(\"Dry run - no files were deleted.\");\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: affected,\n\t\t\t};\n\t\t}\n\n\t\tif (!yes) {\n\t\t\tconst what = referenceOnly ? \"reference files\" : repoOnly ? \"repository\" : qualifiedName;\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: `Are you sure you want to remove ${what}?`,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\tmessage: \"Aborted by user\",\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst s = createSpinner();\n\t\tconst action = referenceOnly\n\t\t\t? \"Removing reference files...\"\n\t\t\t: repoOnly\n\t\t\t\t? \"Removing repository...\"\n\t\t\t\t: \"Removing...\";\n\t\ts.start(action);\n\n\t\tconst removed = await removeRepo(qualifiedName, { referenceOnly, repoOnly });\n\n\t\tif (removed) {\n\t\t\tconst doneMsg = referenceOnly\n\t\t\t\t? \"Reference files removed\"\n\t\t\t\t: repoOnly\n\t\t\t\t\t? \"Repository removed\"\n\t\t\t\t\t: \"Removed\";\n\t\t\ts.stop(doneMsg);\n\t\t\tp.log.success(`Removed: ${qualifiedName}`);\n\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: affected,\n\t\t\t};\n\t\t} else {\n\t\t\ts.stop(\"Failed to remove\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Failed to remove repository\",\n\t\t\t};\n\t\t}\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\nasync function handleReferenceOnlyRemoval(\n\trepoName: string,\n\tyes: boolean,\n\tdryRun: boolean,\n): Promise<RmResult> {\n\tconst referenceFileName = toReferenceFileName(repoName);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tconst metaPath = getMetaPath(repoName);\n\n\tif (!existsSync(referencePath) && !existsSync(metaPath)) {\n\t\tp.log.warn(`No reference files found for: ${repoName}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage: \"No reference files found\",\n\t\t};\n\t}\n\n\tif (dryRun || !yes) {\n\t\tp.log.info(\"The following will be removed:\");\n\t\tif (existsSync(referencePath)) {\n\t\t\tconsole.log(` Reference: ${referencePath}`);\n\t\t}\n\t\tif (existsSync(metaPath)) {\n\t\t\tconsole.log(` Meta: ${metaPath}`);\n\t\t}\n\t\tconsole.log(\"\");\n\t}\n\n\tif (dryRun) {\n\t\tp.log.info(\"Dry run - no files were deleted.\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tremoved: { referencePath },\n\t\t};\n\t}\n\n\tif (!yes) {\n\t\tconst confirm = await p.confirm({\n\t\t\tmessage: `Are you sure you want to remove reference files for ${repoName}?`,\n\t\t});\n\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.log.info(\"Aborted.\");\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: \"Aborted by user\",\n\t\t\t};\n\t\t}\n\t}\n\n\tconst s = createSpinner();\n\ts.start(\"Removing reference files...\");\n\n\tif (existsSync(referencePath)) rmSync(referencePath, { force: true });\n\tif (existsSync(metaPath)) rmSync(metaPath, { recursive: true, force: true });\n\n\ts.stop(\"Reference files removed\");\n\tp.log.success(`Removed reference files for: ${repoName}`);\n\treturn {\n\t\tsuccess: true,\n\t\tremoved: { referencePath },\n\t};\n}\n","/**\n * Config command handlers\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tloadConfig,\n\tsaveConfig,\n\tgetConfigPath,\n\tdetectInstalledAgents,\n\tgetAllAgentConfigs,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { ConfigSchema, AgentSchema } from \"@offworld/types/schemas\";\nimport type { Agent } from \"@offworld/types\";\nimport { z } from \"zod\";\nimport { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\nconst VALID_KEYS = [\"repoRoot\", \"defaultShallow\", \"defaultModel\", \"agents\"] as const;\ntype ConfigKey = (typeof VALID_KEYS)[number];\n\nfunction isValidKey(key: string): key is ConfigKey {\n\treturn VALID_KEYS.includes(key as ConfigKey);\n}\n\nexport interface ConfigShowOptions {\n\tjson?: boolean;\n}\n\nexport interface ConfigShowResult {\n\tconfig: Record<string, unknown>;\n\tpaths: {\n\t\tskillDir: string;\n\t\treferencesDir: string;\n\t\tglobalMap: string;\n\t\tprojectMap?: string;\n\t};\n}\n\nexport async function configShowHandler(options: ConfigShowOptions): Promise<ConfigShowResult> {\n\tconst config = loadConfig();\n\n\tconst projectMapPath = resolve(process.cwd(), \".offworld/map.json\");\n\tconst hasProjectMap = existsSync(projectMapPath);\n\n\tconst paths: ConfigShowResult[\"paths\"] = {\n\t\tskillDir: join(Paths.data, \"skill\", \"offworld\"),\n\t\treferencesDir: join(Paths.data, \"skill\", \"offworld\", \"references\"),\n\t\tglobalMap: join(Paths.data, \"skill\", \"offworld\", \"assets\", \"map.json\"),\n\t};\n\tif (hasProjectMap) {\n\t\tpaths.projectMap = projectMapPath;\n\t}\n\n\tif (options.json) {\n\t\tconst output = {\n\t\t\t...config,\n\t\t\tpaths,\n\t\t};\n\t\tconsole.log(JSON.stringify(output, null, 2));\n\t} else {\n\t\tp.log.info(\"Current configuration:\\n\");\n\t\tfor (const [key, value] of Object.entries(config)) {\n\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t}\n\t\tconsole.log(\"\");\n\t\tp.log.info(`Config file: ${getConfigPath()}`);\n\t\tif (hasProjectMap) {\n\t\t\tp.log.info(`Project map: ${projectMapPath}`);\n\t\t}\n\t}\n\n\treturn { config, paths };\n}\n\nexport interface ConfigSetOptions {\n\tkey: string;\n\tvalue: string;\n}\n\nexport interface ConfigSetResult {\n\tsuccess: boolean;\n\tkey?: string;\n\tvalue?: unknown;\n\tmessage?: string;\n}\n\nexport async function configSetHandler(options: ConfigSetOptions): Promise<ConfigSetResult> {\n\tconst { key, value } = options;\n\n\tif (!isValidKey(key)) {\n\t\tp.log.error(`Invalid config key: ${key}`);\n\t\tp.log.info(`Valid keys: ${VALID_KEYS.join(\", \")}`);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage: `Invalid key: ${key}`,\n\t\t};\n\t}\n\n\tlet parsedValue: string | boolean | Agent[];\n\n\tif (key === \"defaultShallow\") {\n\t\tif (value === \"true\" || value === \"1\") {\n\t\t\tparsedValue = true;\n\t\t} else if (value === \"false\" || value === \"0\") {\n\t\t\tparsedValue = false;\n\t\t} else {\n\t\t\tp.log.error(`Invalid boolean value: ${value}. Use 'true' or 'false'.`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: `Invalid boolean value: ${value}`,\n\t\t\t};\n\t\t}\n\t} else if (key === \"agents\") {\n\t\tconst agentValues = value\n\t\t\t.split(\",\")\n\t\t\t.map((a) => a.trim())\n\t\t\t.filter(Boolean);\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(agentValues);\n\n\t\tif (!agentsResult.success) {\n\t\t\tconst invalidAgents = agentValues.filter((a) => !AgentSchema.options.includes(a as Agent));\n\t\t\tp.log.error(`Invalid agent(s): ${invalidAgents.join(\", \")}`);\n\t\t\tp.log.info(`Valid agents: ${AgentSchema.options.join(\", \")}`);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tmessage: `Invalid agents: ${invalidAgents.join(\", \")}`,\n\t\t\t};\n\t\t}\n\n\t\tparsedValue = agentsResult.data;\n\t} else {\n\t\tparsedValue = value;\n\t}\n\n\ttry {\n\t\tconst updates = { [key]: parsedValue };\n\t\tsaveConfig(updates);\n\t\tp.log.success(`Set ${key} = ${JSON.stringify(parsedValue)}`);\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tkey,\n\t\t\tvalue: parsedValue,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t};\n\t}\n}\n\nexport interface ConfigGetOptions {\n\tkey: string;\n}\n\nexport interface ConfigGetResult {\n\tkey: string;\n\tvalue: unknown;\n}\n\nexport async function configGetHandler(options: ConfigGetOptions): Promise<ConfigGetResult> {\n\tconst { key } = options;\n\tconst config = loadConfig();\n\n\tif (!isValidKey(key)) {\n\t\tp.log.error(`Invalid config key: ${key}`);\n\t\tp.log.info(`Valid keys: ${VALID_KEYS.join(\", \")}`);\n\t\treturn { key, value: null };\n\t}\n\n\tconst value = config[key as keyof typeof config];\n\tconsole.log(JSON.stringify(value));\n\n\treturn { key, value };\n}\n\nexport interface ConfigResetResult {\n\tsuccess: boolean;\n}\n\nexport async function configResetHandler(): Promise<ConfigResetResult> {\n\ttry {\n\t\tconst defaults = ConfigSchema.parse({});\n\t\tsaveConfig(defaults);\n\n\t\tp.log.success(\"Configuration reset to defaults:\");\n\t\tfor (const [key, value] of Object.entries(defaults)) {\n\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t}\n\n\t\treturn { success: true };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false };\n\t}\n}\n\nexport interface ConfigPathResult {\n\tpath: string;\n}\n\nexport async function configPathHandler(): Promise<ConfigPathResult> {\n\tconst path = getConfigPath();\n\tconsole.log(path);\n\treturn { path };\n}\n\nexport interface ConfigAgentsResult {\n\tsuccess: boolean;\n\tagents?: Agent[];\n}\n\nexport async function configAgentsHandler(): Promise<ConfigAgentsResult> {\n\tconst config = loadConfig();\n\tconst detectedAgents = detectInstalledAgents();\n\tconst allAgentConfigs = getAllAgentConfigs();\n\n\tif (detectedAgents.length > 0) {\n\t\tconst detectedNames = detectedAgents\n\t\t\t.map((a) => allAgentConfigs.find((c) => c.name === a)?.displayName ?? a)\n\t\t\t.join(\", \");\n\t\tp.log.info(`Detected agents: ${detectedNames}`);\n\t}\n\n\tconst agentOptions = allAgentConfigs.map((cfg) => ({\n\t\tvalue: cfg.name,\n\t\tlabel: cfg.displayName,\n\t\thint: cfg.globalSkillsDir,\n\t}));\n\tconst initialAgents = config.agents && config.agents.length > 0 ? config.agents : detectedAgents;\n\n\tconst agentsResult = await p.multiselect({\n\t\tmessage: \"Select agents to install skills to\",\n\t\toptions: agentOptions,\n\t\tinitialValues: initialAgents,\n\t\trequired: false,\n\t});\n\n\tif (p.isCancel(agentsResult)) {\n\t\tp.log.warn(\"Cancelled\");\n\t\treturn { success: false };\n\t}\n\n\tconst parsedAgents = z.array(AgentSchema).safeParse(agentsResult);\n\tconst agents = parsedAgents.success ? parsedAgents.data : [];\n\n\ttry {\n\t\tsaveConfig({ agents });\n\t\tp.log.success(`Agents set to: ${agents.join(\", \") || \"(none)\"}`);\n\t\treturn { success: true, agents };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false };\n\t}\n}\n","/**\n * Auth command handlers\n * Uses WorkOS Device Authorization Grant for CLI authentication\n */\n\nimport * as p from \"@clack/prompts\";\nimport { saveAuthData, clearAuthData, getAuthStatus, getAuthPath } from \"@offworld/sdk\";\nimport {\n\tWorkOSDeviceAuthResponseSchema,\n\tWorkOSTokenResponseSchema,\n\tWorkOSAuthErrorResponseSchema,\n\ttype WorkOSDeviceAuthResponse,\n\ttype WorkOSTokenResponse,\n} from \"@offworld/types\";\nimport open from \"open\";\nimport { createSpinner } from \"../utils/spinner\";\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 interface AuthLoginResult {\n\tsuccess: boolean;\n\temail?: string;\n\tmessage?: string;\n}\n\nexport interface AuthLogoutResult {\n\tsuccess: boolean;\n\tmessage: string;\n}\n\nexport interface AuthStatusResult {\n\tloggedIn: boolean;\n\temail?: string;\n\tworkosId?: string;\n\texpiresAt?: string;\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\nasync function requestDeviceCode(): Promise<WorkOSDeviceAuthResponse> {\n\tconst response = await fetch(`${WORKOS_API}/user_management/authorize/device`, {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\tbody: new URLSearchParams({ client_id: getWorkosClientId() }),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Failed to request device code: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn WorkOSDeviceAuthResponseSchema.parse(data);\n}\n\nasync function pollForTokens(\n\tdeviceCode: string,\n\tinterval: number,\n\tonStatus?: (status: string) => void,\n): Promise<WorkOSTokenResponse> {\n\tlet pollInterval = interval;\n\n\twhile (true) {\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: \"urn:ietf:params:oauth:grant-type:device_code\",\n\t\t\t\tdevice_code: deviceCode,\n\t\t\t\tclient_id: getWorkosClientId(),\n\t\t\t}),\n\t\t});\n\n\t\tif (response.ok) {\n\t\t\tconst data = await response.json();\n\t\t\treturn WorkOSTokenResponseSchema.parse(data);\n\t\t}\n\n\t\tconst errorData = await response.json();\n\t\tconst data = WorkOSAuthErrorResponseSchema.parse(errorData);\n\n\t\tswitch (data.error) {\n\t\t\tcase \"authorization_pending\":\n\t\t\t\tonStatus?.(\"Waiting for approval...\");\n\t\t\t\tawait sleep(pollInterval * 1000);\n\t\t\t\tbreak;\n\t\t\tcase \"slow_down\":\n\t\t\t\tpollInterval += 5;\n\t\t\t\tonStatus?.(\"Slowing down polling...\");\n\t\t\t\tawait sleep(pollInterval * 1000);\n\t\t\t\tbreak;\n\t\t\tcase \"access_denied\":\n\t\t\t\tthrow new Error(\"Authorization denied by user\");\n\t\t\tcase \"expired_token\":\n\t\t\t\tthrow new Error(\"Device code expired. Please try again.\");\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Authentication failed: ${data.error}`);\n\t\t}\n\t}\n}\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function authLoginHandler(): Promise<AuthLoginResult> {\n\tconst s = createSpinner();\n\n\tconst currentStatus = await getAuthStatus();\n\tif (currentStatus.isLoggedIn) {\n\t\tp.log.info(`Already logged in as ${currentStatus.email || \"unknown user\"}`);\n\t\tconst shouldRelogin = await p.confirm({\n\t\t\tmessage: \"Do you want to log in again?\",\n\t\t});\n\t\tif (!shouldRelogin || p.isCancel(shouldRelogin)) {\n\t\t\treturn { success: true, email: currentStatus.email };\n\t\t}\n\t}\n\n\ts.start(\"Requesting device code...\");\n\n\tlet deviceData: WorkOSDeviceAuthResponse;\n\ttry {\n\t\tdeviceData = await requestDeviceCode();\n\t} catch (error) {\n\t\ts.stop(\"Failed to get device code\");\n\t\treturn { success: false, message: error instanceof Error ? error.message : \"Unknown error\" };\n\t}\n\n\ts.stop();\n\n\tp.log.info(`\\nOpen this URL in your browser:\\n`);\n\tp.log.info(` ${deviceData.verification_uri_complete}\\n`);\n\tp.log.info(`Or go to ${deviceData.verification_uri} and enter code: ${deviceData.user_code}\\n`);\n\n\ttry {\n\t\tawait open(deviceData.verification_uri_complete);\n\t} catch {}\n\n\ts.start(\"Waiting for approval...\");\n\n\ttry {\n\t\tconst tokenData = await pollForTokens(deviceData.device_code, deviceData.interval, (status) => {\n\t\t\ts.message(status);\n\t\t});\n\n\t\ts.stop(\"Login successful!\");\n\n\t\tconst expiresAt = tokenData.expires_at\n\t\t\t? new Date(tokenData.expires_at * 1000).toISOString()\n\t\t\t: extractJwtExpiration(tokenData.access_token);\n\n\t\tsaveAuthData({\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,\n\t\t});\n\n\t\tp.log.success(`Logged in as ${tokenData.user.email}`);\n\n\t\treturn { success: true, email: tokenData.user.email };\n\t} catch (error) {\n\t\ts.stop(\"Login failed\");\n\t\treturn { success: false, message: error instanceof Error ? error.message : \"Unknown error\" };\n\t}\n}\n\nexport async function authLogoutHandler(): Promise<AuthLogoutResult> {\n\tconst status = await getAuthStatus();\n\n\tif (!status.isLoggedIn) {\n\t\tp.log.info(\"Not currently logged in\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmessage: \"Not logged in\",\n\t\t};\n\t}\n\n\tconst cleared = clearAuthData();\n\n\tif (cleared) {\n\t\tp.log.success(\"Logged out successfully\");\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tmessage: \"Logged out successfully\",\n\t\t};\n\t}\n\n\tp.log.warn(\"Could not clear auth data\");\n\treturn {\n\t\tsuccess: false,\n\t\tmessage: \"Could not clear auth data\",\n\t};\n}\n\nexport async function authStatusHandler(): Promise<AuthStatusResult> {\n\tconst status = await getAuthStatus();\n\n\tif (status.isLoggedIn) {\n\t\tp.log.info(`Logged in as: ${status.email || \"unknown\"}`);\n\t\tif (status.expiresAt) {\n\t\t\tconst expiresDate = new Date(status.expiresAt);\n\t\t\tp.log.info(`Session expires: ${expiresDate.toLocaleString()}`);\n\t\t}\n\t\tp.log.info(`Auth file: ${getAuthPath()}`);\n\t} else {\n\t\tp.log.info(\"Not logged in\");\n\t\tp.log.info(\"Run 'ow auth login' to authenticate\");\n\t}\n\n\treturn {\n\t\tloggedIn: status.isLoggedIn,\n\t\temail: status.email,\n\t\tworkosId: status.workosId,\n\t\texpiresAt: status.expiresAt,\n\t};\n}\n","import * as p from \"@clack/prompts\";\nimport { existsSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { resolve, join, dirname } from \"node:path\";\nimport {\n\tloadConfig,\n\tsaveConfig,\n\tgetConfigPath,\n\tgetMetaRoot,\n\tPaths,\n\tdetectInstalledAgents,\n\tgetAllAgentConfigs,\n\tgetAuthStatus,\n\tinstallGlobalSkill,\n\tlistProviders,\n\tgetProvider,\n\tvalidateProviderModel,\n\tdiscoverRepos,\n\ttype ProviderInfo,\n\ttype ModelInfo,\n} from \"@offworld/sdk\";\nimport type { Config, Agent } from \"@offworld/types\";\nimport { AgentSchema } from \"@offworld/types/schemas\";\nimport { z } from \"zod\";\nimport { authLoginHandler } from \"./auth.js\";\n\nexport interface InitOptions {\n\tyes?: boolean;\n\t/** Reconfigure even if config exists */\n\tforce?: boolean;\n\t/** Skip auth check (useful for testing) */\n\tskipAuth?: boolean;\n\t/** AI provider and model (e.g., opencode/claude-sonnet-4-5) */\n\tmodel?: string;\n\t/** Where to clone repos */\n\trepoRoot?: string;\n\t/** Comma-separated agents */\n\tagents?: string;\n}\n\nexport interface InitResult {\n\tsuccess: boolean;\n\tconfigPath: string;\n}\n\nconst DEFAULT_PROVIDER = \"anthropic\";\nconst MAX_SELECT_ITEMS = 15;\n\nfunction expandTilde(path: string): string {\n\tif (path.startsWith(\"~/\")) {\n\t\treturn resolve(homedir(), path.slice(2));\n\t}\n\treturn resolve(path);\n}\n\nfunction collapseTilde(path: string): string {\n\tconst home = homedir();\n\tif (path.startsWith(home)) {\n\t\treturn \"~\" + path.slice(home.length);\n\t}\n\treturn path;\n}\n\nfunction validatePath(value: string): string | undefined {\n\tif (!value.trim()) {\n\t\treturn \"Path cannot be empty\";\n\t}\n\treturn undefined;\n}\n\nfunction detectProjectRoot(): string | null {\n\tlet currentDir = process.cwd();\n\twhile (currentDir !== homedir()) {\n\t\tconst packageJsonPath = join(currentDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\treturn currentDir;\n\t\t}\n\t\tconst parent = dirname(currentDir);\n\t\tif (parent === currentDir) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrentDir = parent;\n\t}\n\treturn null;\n}\n\nexport async function initHandler(options: InitOptions = {}): Promise<InitResult> {\n\tconst configPath = getConfigPath();\n\tconst existingConfig = loadConfig();\n\tconst configExists = existsSync(configPath);\n\tconst projectRoot = detectProjectRoot();\n\n\tp.intro(\"ow init\");\n\n\tif (!options.skipAuth) {\n\t\tconst authStatus = await getAuthStatus();\n\t\tif (!authStatus.isLoggedIn) {\n\t\t\tp.log.info(\"You are not logged in\");\n\t\t\tconst shouldLogin = await p.confirm({\n\t\t\t\tmessage: \"Do you want to log in now?\",\n\t\t\t\tinitialValue: true,\n\t\t\t});\n\n\t\t\tif (!p.isCancel(shouldLogin) && shouldLogin) {\n\t\t\t\tawait authLoginHandler();\n\t\t\t}\n\t\t}\n\t}\n\n\tif (configExists) {\n\t\tif (!options.force) {\n\t\t\tif (projectRoot) {\n\t\t\t\tp.log.warn(`Global config already exists at ${configPath}`);\n\t\t\t\tp.log.info(\"\");\n\t\t\t\tp.log.info(\"Did you mean to run project setup? Use:\");\n\t\t\t\tp.log.info(\" ow project init\");\n\t\t\t\tp.log.info(\"\");\n\t\t\t\tp.log.info(\"To reconfigure global settings, use:\");\n\t\t\t\tp.log.info(\" ow init --force\");\n\t\t\t\tp.outro(\"\");\n\t\t\t\treturn { success: false, configPath };\n\t\t\t}\n\t\t\tp.log.warn(\"Already configured. Use --force to reconfigure.\");\n\t\t\tp.outro(\"\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tp.log.info(\"Reconfiguring global settings...\");\n\t}\n\n\tlet repoRoot: string;\n\tif (options.repoRoot) {\n\t\trepoRoot = collapseTilde(expandTilde(options.repoRoot));\n\t} else {\n\t\tconst repoRootResult = await p.text({\n\t\t\tmessage: \"Where should repositories be cloned?\",\n\t\t\tplaceholder: \"~/ow\",\n\t\t\tinitialValue: existingConfig.repoRoot,\n\t\t\tvalidate: validatePath,\n\t\t});\n\n\t\tif (p.isCancel(repoRootResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\trepoRoot = collapseTilde(expandTilde(repoRootResult));\n\t}\n\n\tlet provider: string;\n\tlet model: string;\n\n\tif (options.model) {\n\t\tconst parts = options.model.split(\"/\");\n\t\tif (parts.length !== 2) {\n\t\t\tp.log.error(`Invalid model format. Expected 'provider/model', got '${options.model}'`);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tprovider = parts[0]!;\n\t\tmodel = parts[1]!;\n\n\t\tconst validation = await validateProviderModel(provider, model);\n\t\tif (!validation.valid) {\n\t\t\tp.log.error(validation.error!);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t} else {\n\t\tconst spin = p.spinner();\n\t\tspin.start(\"Fetching available providers...\");\n\n\t\tlet providers;\n\t\ttry {\n\t\t\tproviders = await listProviders();\n\t\t} catch (err) {\n\t\t\tspin.stop(\"Failed to fetch providers\");\n\t\t\tp.log.error(err instanceof Error ? err.message : \"Network error\");\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tspin.stop(\"Loaded providers from models.dev\");\n\n\t\tconst priorityProviders = [\"opencode\", \"anthropic\", \"openai\", \"google\"];\n\t\tconst sortedProviders = [\n\t\t\t...providers.filter((p: ProviderInfo) => priorityProviders.includes(p.id)),\n\t\t\t...providers\n\t\t\t\t.filter((p: ProviderInfo) => !priorityProviders.includes(p.id))\n\t\t\t\t.sort((a: ProviderInfo, b: ProviderInfo) => a.name.localeCompare(b.name)),\n\t\t];\n\n\t\tconst providerOptions = sortedProviders.map((prov: ProviderInfo) => ({\n\t\t\tvalue: prov.id,\n\t\t\tlabel: prov.name,\n\t\t}));\n\n\t\tconst currentProvider = existingConfig.defaultModel?.split(\"/\")[0];\n\t\tconst providerResult = await p.select({\n\t\t\tmessage: \"Select your AI provider\",\n\t\t\toptions: providerOptions,\n\t\t\tinitialValue: currentProvider ?? DEFAULT_PROVIDER,\n\t\t\tmaxItems: MAX_SELECT_ITEMS,\n\t\t});\n\n\t\tif (p.isCancel(providerResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tprovider = String(providerResult);\n\n\t\tspin.start(\"Fetching models...\");\n\t\tconst providerData = await getProvider(provider);\n\t\tspin.stop(`Loaded ${providerData?.models.length ?? 0} models`);\n\n\t\tif (!providerData || providerData.models.length === 0) {\n\t\t\tp.log.error(`No models found for provider \"${provider}\"`);\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tconst modelOptions = providerData.models.map((m: ModelInfo) => ({\n\t\t\tvalue: m.id,\n\t\t\tlabel: m.name,\n\t\t\thint: m.reasoning ? \"reasoning\" : m.status === \"beta\" ? \"beta\" : undefined,\n\t\t}));\n\n\t\tconst currentModel = existingConfig.defaultModel?.split(\"/\")[1];\n\t\tconst modelResult = await p.select({\n\t\t\tmessage: \"Select your default model\",\n\t\t\toptions: modelOptions,\n\t\t\tinitialValue: currentModel,\n\t\t\tmaxItems: MAX_SELECT_ITEMS,\n\t\t});\n\n\t\tif (p.isCancel(modelResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tmodel = String(modelResult);\n\t}\n\n\tconst detectedAgents = detectInstalledAgents();\n\tconst allAgentConfigs = getAllAgentConfigs();\n\n\tif (detectedAgents.length > 0) {\n\t\tconst detectedNames = detectedAgents\n\t\t\t.map((a) => allAgentConfigs.find((c) => c.name === a)?.displayName ?? a)\n\t\t\t.join(\", \");\n\t\tp.log.info(`Detected agents: ${detectedNames}`);\n\t}\n\n\tconst agentOptions = allAgentConfigs.map((config) => ({\n\t\tvalue: config.name,\n\t\tlabel: config.displayName,\n\t\thint: config.globalSkillsDir,\n\t}));\n\n\tlet agents: Agent[];\n\tif (options.agents) {\n\t\tconst agentNames = options.agents.split(\",\").map((a) => a.trim());\n\t\tconst validAgents = allAgentConfigs\n\t\t\t.filter((c) => agentNames.includes(c.name))\n\t\t\t.map((c) => c.name);\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(validAgents);\n\t\tif (!agentsResult.success || agentsResult.data.length === 0) {\n\t\t\tp.log.error(\"No valid agent names provided\");\n\t\t\tp.outro(\"Setup failed\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\t\tagents = agentsResult.data;\n\t} else {\n\t\tconst initialAgents =\n\t\t\texistingConfig.agents && existingConfig.agents.length > 0\n\t\t\t\t? existingConfig.agents\n\t\t\t\t: detectedAgents;\n\n\t\tconst selectResult = await p.multiselect({\n\t\t\tmessage: \"Select agents to install skills to\",\n\t\t\toptions: agentOptions,\n\t\t\tinitialValues: initialAgents,\n\t\t\trequired: false,\n\t\t});\n\n\t\tif (p.isCancel(selectResult)) {\n\t\t\tp.outro(\"Setup cancelled\");\n\t\t\treturn { success: false, configPath };\n\t\t}\n\n\t\tconst agentsResult = z.array(AgentSchema).safeParse(selectResult);\n\t\tagents = agentsResult.success ? agentsResult.data : [];\n\t}\n\n\tconst defaultModel = `${provider}/${model}`;\n\tconst newConfig: Partial<Config> = {\n\t\trepoRoot,\n\t\tdefaultModel,\n\t\tagents,\n\t};\n\n\ttry {\n\t\tsaveConfig(newConfig);\n\t\tinstallGlobalSkill();\n\n\t\tp.log.success(\"Configuration saved!\");\n\t\tp.log.info(` Config file: ${configPath}`);\n\t\tp.log.info(` Repo root: ${repoRoot}`);\n\t\tp.log.info(` Meta root: ${getMetaRoot()}`);\n\t\tp.log.info(` State root: ${Paths.state}`);\n\t\tp.log.info(` Model: ${defaultModel}`);\n\t\tp.log.info(` Agents: ${agents.join(\", \")}`);\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(`Failed to save configuration: ${message}`);\n\t\tp.outro(\"Setup failed\");\n\t\treturn { success: false, configPath };\n\t}\n\n\tconst expandedRepoRoot = expandTilde(repoRoot);\n\tif (existsSync(expandedRepoRoot)) {\n\t\tconst previewResult = await discoverRepos({ repoRoot: expandedRepoRoot, dryRun: true });\n\n\t\tif (previewResult.discovered.length > 0) {\n\t\t\tp.log.info(\"\");\n\t\t\tp.log.info(`Found ${previewResult.discovered.length} existing repos in ${repoRoot}`);\n\n\t\t\tlet shouldDiscover = options.yes;\n\t\t\tif (!options.yes) {\n\t\t\t\tconst confirmDiscover = await p.confirm({\n\t\t\t\t\tmessage: \"Add them to your clone map? (they will be marked as not referenced)\",\n\t\t\t\t\tinitialValue: true,\n\t\t\t\t});\n\t\t\t\tif (!p.isCancel(confirmDiscover)) {\n\t\t\t\t\tshouldDiscover = confirmDiscover;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (shouldDiscover) {\n\t\t\t\tconst result = await discoverRepos({ repoRoot: expandedRepoRoot });\n\t\t\t\tp.log.success(`Added ${result.discovered.length} repos to clone map`);\n\t\t\t}\n\t\t}\n\t}\n\n\tp.outro(\"Setup complete. Run 'ow pull <repo>' to get started.\");\n\treturn { success: true, configPath };\n}\n","import * as p from \"@clack/prompts\";\nimport {\n\tgetConfigPath,\n\tloadConfig,\n\tparseDependencies,\n\tresolveDependencyRepo,\n\tmatchDependenciesToReferences,\n\tupdateAgentFiles,\n\tgetReferencePath,\n\ttoReferenceFileName,\n\treadGlobalMap,\n\twriteProjectMap,\n\ttype InstalledReference,\n\ttype ReferenceMatch,\n} from \"@offworld/sdk\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { homedir } from \"node:os\";\nimport { pullHandler } from \"./pull\";\n\nexport interface ProjectInitOptions {\n\t/** Select all detected dependencies */\n\tall?: boolean;\n\t/** Comma-separated deps to include (skip selection) */\n\tdeps?: string;\n\t/** Comma-separated deps to exclude */\n\tskip?: string;\n\t/** Generate references for deps without existing ones */\n\tgenerate?: boolean;\n\t/** Show what would be done without doing it */\n\tdryRun?: boolean;\n\t/** Skip confirmations */\n\tyes?: boolean;\n}\n\nexport interface ProjectInitResult {\n\tsuccess: boolean;\n\tmessage?: string;\n\treferencesInstalled?: number;\n}\n\nfunction detectProjectRoot(): string | null {\n\tlet currentDir = process.cwd();\n\twhile (currentDir !== homedir()) {\n\t\tconst gitPath = join(currentDir, \".git\");\n\t\tif (existsSync(gitPath)) {\n\t\t\treturn currentDir;\n\t\t}\n\t\tconst parent = dirname(currentDir);\n\t\tif (parent === currentDir) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrentDir = parent;\n\t}\n\treturn null;\n}\n\nexport async function projectInitHandler(\n\toptions: ProjectInitOptions = {},\n): Promise<ProjectInitResult> {\n\tp.intro(\"ow project init\");\n\n\tconst configPath = getConfigPath();\n\tif (!existsSync(configPath)) {\n\t\tp.log.error(\"No global config found. Run 'ow init' first to set up global configuration.\");\n\t\tp.outro(\"\");\n\t\treturn { success: false, message: \"No global config found\" };\n\t}\n\n\tconst config = loadConfig();\n\tif (!config.defaultModel) {\n\t\tp.log.error(\"Global config is missing AI settings. Run 'ow init --force' to reconfigure.\");\n\t\tp.outro(\"\");\n\t\treturn { success: false, message: \"Invalid global config\" };\n\t}\n\n\tconst projectRoot = detectProjectRoot() || process.cwd();\n\tp.log.info(`Project root: ${projectRoot}`);\n\n\tp.log.step(\"Scanning dependencies...\");\n\tconst dependencies = parseDependencies(projectRoot);\n\n\tif (dependencies.length === 0) {\n\t\tp.log.warn(\"No dependencies found in manifest files.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies found\" };\n\t}\n\n\tp.log.info(`Found ${dependencies.length} dependencies`);\n\n\tp.log.step(\"Resolving GitHub repositories...\");\n\tconst isInternalDep = (version?: string): boolean => {\n\t\tif (!version) return false;\n\t\treturn (\n\t\t\tversion.startsWith(\"workspace:\") || version.startsWith(\"file:\") || version.startsWith(\"link:\")\n\t\t);\n\t};\n\n\tconst internalDeps = dependencies.filter((dep) => isInternalDep(dep.version));\n\tconst externalDeps = dependencies.filter((dep) => !isInternalDep(dep.version));\n\n\tif (internalDeps.length > 0) {\n\t\tp.log.warn(`Skipped ${internalDeps.length} internal workspace dependencies:`);\n\t\tfor (const dep of internalDeps) {\n\t\t\tp.log.info(` - ${dep.name}`);\n\t\t}\n\t}\n\n\tconst resolvedPromises = externalDeps.map((dep) => resolveDependencyRepo(dep.name));\n\tconst resolved = await Promise.all(resolvedPromises);\n\n\tconst skipList = options.skip ? options.skip.split(\",\").map((d) => d.trim()) : [];\n\tconst depsList = options.deps ? options.deps.split(\",\").map((d) => d.trim()) : [];\n\n\tlet filtered = resolved.filter((r) => {\n\t\tif (skipList.includes(r.dep)) return false;\n\t\tif (depsList.length > 0) return depsList.includes(r.dep);\n\t\treturn true;\n\t});\n\n\tif (filtered.length === 0) {\n\t\tp.log.warn(\"No dependencies left after filtering.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies after filtering\" };\n\t}\n\n\tconst matches = matchDependenciesToReferences(filtered);\n\tconst unresolved = matches.filter((match) => !match.repo);\n\tif (unresolved.length > 0) {\n\t\tp.log.warn(`Could not resolve ${unresolved.length} dependencies to a GitHub repo:`);\n\t\tfor (const match of unresolved) {\n\t\t\tp.log.info(` - ${match.dep}`);\n\t\t}\n\t}\n\n\tconst installable = matches.filter((match) => match.repo);\n\n\tlet selected: ReferenceMatch[];\n\tif (options.all || options.deps) {\n\t\tselected = installable;\n\t} else {\n\t\tconst checklistOptions = matches.map((m) => {\n\t\t\tconst repoLabel = m.repo ?? \"unknown repo\";\n\t\t\tconst label = `${m.dep} (${repoLabel}) - ${m.status}`;\n\t\t\treturn { value: m, label, hint: m.status, disabled: m.status === \"unknown\" };\n\t\t});\n\n\t\tconst selectedResult = await p.multiselect({\n\t\t\tmessage: \"Select dependencies to install references for:\",\n\t\t\toptions: checklistOptions,\n\t\t\trequired: false,\n\t\t});\n\n\t\tif (p.isCancel(selectedResult)) {\n\t\t\tp.cancel(\"Operation cancelled\");\n\t\t\treturn { success: false, message: \"Cancelled by user\" };\n\t\t}\n\n\t\tselected = Array.isArray(selectedResult) ? selectedResult : [];\n\t}\n\n\tif (selected.length === 0) {\n\t\tp.log.warn(\"No dependencies selected.\");\n\t\tp.outro(\"\");\n\t\treturn { success: true, message: \"No dependencies selected\" };\n\t}\n\n\tif (!options.yes && !options.dryRun) {\n\t\tconst confirm = await p.confirm({\n\t\t\tmessage: `Install references for ${selected.length} dependencies?`,\n\t\t});\n\n\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\tp.cancel(\"Operation cancelled\");\n\t\t\treturn { success: false, message: \"Cancelled by user\" };\n\t\t}\n\t}\n\n\tif (options.dryRun) {\n\t\tp.log.info(\"\");\n\t\tp.log.info(\"Dry run - would install references for:\");\n\t\tfor (const match of selected) {\n\t\t\tp.log.info(` - ${match.dep} (${match.repo})`);\n\t\t}\n\t\tp.outro(\"Dry run complete\");\n\t\treturn { success: true, message: \"Dry run complete\" };\n\t}\n\n\tp.log.step(`Installing ${selected.length} references...`);\n\n\tconst installed: InstalledReference[] = [];\n\tlet failedCount = 0;\n\n\tfor (const match of selected) {\n\t\ttry {\n\t\t\tif (!match.repo) continue;\n\n\t\t\tp.log.info(`Installing reference for ${match.dep}...`);\n\n\t\t\tconst pullResult = await pullHandler({\n\t\t\t\trepo: match.repo,\n\t\t\t\tshallow: true,\n\t\t\t\tforce: options.generate,\n\t\t\t\tverbose: false,\n\t\t\t});\n\n\t\t\tif (pullResult.success && pullResult.referenceInstalled) {\n\t\t\t\tconst referencePath = getReferencePath(match.repo);\n\t\t\t\tinstalled.push({\n\t\t\t\t\tdependency: match.dep,\n\t\t\t\t\treference: toReferenceFileName(match.repo),\n\t\t\t\t\tpath: referencePath,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tp.log.warn(`Failed to install reference for ${match.dep}`);\n\t\t\t\tfailedCount++;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst errMsg = error instanceof Error ? error.message : \"Unknown error\";\n\t\t\tp.log.error(`Error installing ${match.dep}: ${errMsg}`);\n\t\t\tfailedCount++;\n\t\t}\n\t}\n\n\tconst map = readGlobalMap();\n\tconst projectEntries = Object.fromEntries(\n\t\tselected\n\t\t\t.filter((m) => m.repo)\n\t\t\t.map((m) => {\n\t\t\t\tconst qualifiedName = `github.com:${m.repo}`;\n\t\t\t\tconst entry = map.repos[qualifiedName];\n\t\t\t\treturn [\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\t{\n\t\t\t\t\t\tlocalPath: entry?.localPath ?? \"\",\n\t\t\t\t\t\treference: toReferenceFileName(m.repo!),\n\t\t\t\t\t\tkeywords: entry?.keywords ?? [],\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t}),\n\t);\n\twriteProjectMap(projectRoot, projectEntries);\n\n\tif (installed.length > 0) {\n\t\tp.log.step(\"Updating AGENTS.md...\");\n\t\ttry {\n\t\t\tupdateAgentFiles(projectRoot, installed);\n\t\t\tp.log.success(\"AGENTS.md updated\");\n\t\t} catch (error) {\n\t\t\tconst errMsg = error instanceof Error ? error.message : \"Unknown error\";\n\t\t\tp.log.error(`Failed to update AGENTS.md: ${errMsg}`);\n\t\t}\n\t}\n\n\tp.log.info(\"\");\n\tp.log.success(`Installed ${installed.length} references`);\n\tif (failedCount > 0) {\n\t\tp.log.warn(`Failed to install ${failedCount} references`);\n\t}\n\n\tp.outro(\"Project init complete\");\n\n\treturn { success: true, referencesInstalled: installed.length };\n}\n","/**\n * Upgrade command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tdetectInstallMethod,\n\tgetCurrentVersion,\n\tfetchLatestVersion,\n\texecuteUpgrade,\n\ttype InstallMethod,\n} from \"@offworld/sdk\";\nimport { createSpinner } from \"../utils/spinner.js\";\n\nexport interface UpgradeOptions {\n\ttarget?: string;\n\tmethod?: InstallMethod;\n}\n\nexport interface UpgradeResult {\n\tsuccess: boolean;\n\tfrom?: string;\n\tto?: string;\n\tmessage?: string;\n}\n\nexport async function upgradeHandler(options: UpgradeOptions): Promise<UpgradeResult> {\n\tconst { target, method: methodOverride } = options;\n\n\ttry {\n\t\tconst s = createSpinner();\n\n\t\ts.start(\"Detecting installation method...\");\n\t\tconst method = methodOverride ?? detectInstallMethod();\n\t\ts.stop(`Installation method: ${method}`);\n\n\t\tif (method === \"unknown\") {\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: \"Could not detect installation method. Attempt curl-based upgrade?\",\n\t\t\t\tinitialValue: false,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn { success: false, message: \"Unknown installation method\" };\n\t\t\t}\n\t\t}\n\n\t\tconst effectiveMethod = method === \"unknown\" ? \"curl\" : method;\n\n\t\tconst currentVersion = getCurrentVersion();\n\t\tp.log.info(`Current version: ${currentVersion}`);\n\n\t\tlet targetVersion = target;\n\t\tif (!targetVersion) {\n\t\t\ts.start(\"Fetching latest version...\");\n\t\t\tconst latest = await fetchLatestVersion(effectiveMethod);\n\t\t\ts.stop(latest ? `Latest version: ${latest}` : \"Could not fetch latest version\");\n\n\t\t\tif (!latest) {\n\t\t\t\tp.log.error(\"Failed to fetch latest version\");\n\t\t\t\treturn { success: false, message: \"Failed to fetch latest version\" };\n\t\t\t}\n\t\t\ttargetVersion = latest;\n\t\t}\n\n\t\ttargetVersion = targetVersion.replace(/^v/, \"\");\n\n\t\tif (currentVersion === targetVersion) {\n\t\t\tp.log.success(`Already on version ${targetVersion}`);\n\t\t\treturn { success: true, from: currentVersion, to: targetVersion };\n\t\t}\n\n\t\tp.log.info(`Upgrading from ${currentVersion} to ${targetVersion}...`);\n\n\t\tawait executeUpgrade(effectiveMethod, targetVersion);\n\n\t\tp.log.success(`Successfully upgraded to ${targetVersion}`);\n\t\tp.log.info(\"Restart your terminal or run 'ow --version' to verify.\");\n\n\t\treturn {\n\t\t\tsuccess: true,\n\t\t\tfrom: currentVersion,\n\t\t\tto: targetVersion,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Uninstall command handler\n */\n\nimport * as p from \"@clack/prompts\";\nimport {\n\tdetectInstallMethod,\n\texecuteUninstall,\n\tgetShellConfigFiles,\n\tcleanShellConfig,\n\tPaths,\n} from \"@offworld/sdk\";\nimport { existsSync, rmSync } from \"node:fs\";\nimport { createSpinner } from \"../utils/spinner.js\";\n\nexport interface UninstallOptions {\n\tkeepConfig?: boolean;\n\tkeepData?: boolean;\n\tdryRun?: boolean;\n\tforce?: boolean;\n}\n\nexport interface UninstallResult {\n\tsuccess: boolean;\n\tremoved?: {\n\t\tbinary?: boolean;\n\t\tconfig?: boolean;\n\t\tdata?: boolean;\n\t\tstate?: boolean;\n\t\tshellConfigs?: string[];\n\t};\n\tmessage?: string;\n}\n\ninterface RemovalTarget {\n\tpath: string;\n\tlabel: string;\n\tkeep: boolean;\n}\n\nexport async function uninstallHandler(options: UninstallOptions): Promise<UninstallResult> {\n\tconst { keepConfig = false, keepData = false, dryRun = false, force = false } = options;\n\n\ttry {\n\t\tconst method = detectInstallMethod();\n\t\tp.log.info(`Installation method: ${method}`);\n\n\t\tconst directories: RemovalTarget[] = [\n\t\t\t{ path: Paths.data, label: \"Data\", keep: keepData },\n\t\t\t{ path: Paths.config, label: \"Config\", keep: keepConfig },\n\t\t\t{ path: Paths.state, label: \"State\", keep: false },\n\t\t];\n\n\t\tconst toRemove = directories.filter((d) => !d.keep && existsSync(d.path));\n\n\t\tif (dryRun || !force) {\n\t\t\tp.log.info(\"The following will be removed:\");\n\t\t\tconsole.log(\"\");\n\n\t\t\tif (method === \"curl\") {\n\t\t\t\tconsole.log(\" Binary: ~/.local/bin/ow\");\n\t\t\t} else {\n\t\t\t\tconsole.log(` Package: offworld (via ${method})`);\n\t\t\t}\n\n\t\t\tfor (const dir of toRemove) {\n\t\t\t\tconsole.log(` ${dir.label}: ${dir.path}`);\n\t\t\t}\n\n\t\t\tif (keepConfig) {\n\t\t\t\tconsole.log(` [kept] Config: ${Paths.config}`);\n\t\t\t}\n\t\t\tif (keepData) {\n\t\t\t\tconsole.log(` [kept] Data: ${Paths.data}`);\n\t\t\t}\n\n\t\t\tconsole.log(\"\");\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tp.log.info(\"Dry run - nothing was removed.\");\n\t\t\treturn {\n\t\t\t\tsuccess: true,\n\t\t\t\tremoved: {\n\t\t\t\t\tbinary: method === \"curl\",\n\t\t\t\t\tconfig: !keepConfig && existsSync(Paths.config),\n\t\t\t\t\tdata: !keepData && existsSync(Paths.data),\n\t\t\t\t\tstate: existsSync(Paths.state),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (!force) {\n\t\t\tconst confirm = await p.confirm({\n\t\t\t\tmessage: \"Are you sure you want to uninstall offworld?\",\n\t\t\t\tinitialValue: false,\n\t\t\t});\n\n\t\t\tif (p.isCancel(confirm) || !confirm) {\n\t\t\t\tp.log.info(\"Aborted.\");\n\t\t\t\treturn { success: false, message: \"Aborted by user\" };\n\t\t\t}\n\t\t}\n\n\t\tconst s = createSpinner();\n\t\tconst removed: UninstallResult[\"removed\"] = {};\n\n\t\ts.start(\"Removing offworld...\");\n\t\ttry {\n\t\t\tawait executeUninstall(method);\n\t\t\tremoved.binary = true;\n\t\t\ts.stop(\"Removed offworld binary/package\");\n\t\t} catch (err) {\n\t\t\ts.stop(\"Failed to remove binary/package\");\n\t\t\tp.log.warn(err instanceof Error ? err.message : \"Unknown error\");\n\t\t}\n\n\t\tfor (const dir of toRemove) {\n\t\t\ts.start(`Removing ${dir.label.toLowerCase()}...`);\n\t\t\ttry {\n\t\t\t\trmSync(dir.path, { recursive: true, force: true });\n\t\t\t\ts.stop(`Removed ${dir.label.toLowerCase()}`);\n\t\t\t\tif (dir.label === \"Config\") removed.config = true;\n\t\t\t\tif (dir.label === \"Data\") removed.data = true;\n\t\t\t\tif (dir.label === \"State\") removed.state = true;\n\t\t\t} catch (err) {\n\t\t\t\ts.stop(`Failed to remove ${dir.label.toLowerCase()}`);\n\t\t\t\tp.log.warn(err instanceof Error ? err.message : \"Unknown error\");\n\t\t\t}\n\t\t}\n\n\t\tif (method === \"curl\") {\n\t\t\tconst shellConfigs = getShellConfigFiles();\n\t\t\tconst cleaned: string[] = [];\n\n\t\t\tfor (const config of shellConfigs) {\n\t\t\t\tif (cleanShellConfig(config)) {\n\t\t\t\t\tcleaned.push(config);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (cleaned.length > 0) {\n\t\t\t\tp.log.info(`Cleaned PATH from: ${cleaned.join(\", \")}`);\n\t\t\t\tremoved.shellConfigs = cleaned;\n\t\t\t}\n\t\t}\n\n\t\tp.log.success(\"Uninstall complete!\");\n\n\t\tif (method === \"curl\") {\n\t\t\tp.log.info(\"You may need to restart your terminal.\");\n\t\t}\n\n\t\treturn { success: true, removed };\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown error\";\n\t\tp.log.error(message);\n\t\treturn { success: false, message };\n\t}\n}\n","/**\n * Map command handlers for fast repo routing\n */\n\nimport * as p from \"@clack/prompts\";\nimport { getMapEntry, searchMap, Paths, type SearchResult } from \"@offworld/sdk\";\n\nexport interface MapShowOptions {\n\trepo: string;\n\tjson?: boolean;\n\tpath?: boolean;\n\tref?: boolean;\n}\n\nexport interface MapShowResult {\n\tfound: boolean;\n\tscope?: \"project\" | \"global\";\n\tqualifiedName?: string;\n\tlocalPath?: string;\n\tprimary?: string;\n\tkeywords?: string[];\n}\n\nexport async function mapShowHandler(options: MapShowOptions): Promise<MapShowResult> {\n\tconst { repo, json, path, ref } = options;\n\n\tconst result = getMapEntry(repo);\n\n\tif (!result) {\n\t\tif (json) {\n\t\t\tconsole.log(JSON.stringify({ found: false }));\n\t\t} else if (!path && !ref) {\n\t\t\tp.log.error(`Repo not found: ${repo}`);\n\t\t}\n\t\treturn { found: false };\n\t}\n\n\tconst { scope, qualifiedName, entry } = result;\n\n\tconst primary = \"primary\" in entry ? entry.primary : entry.reference;\n\tconst keywords = entry.keywords ?? [];\n\tconst refPath = `${Paths.offworldReferencesDir}/${primary}`;\n\tif (path) {\n\t\tconsole.log(entry.localPath);\n\t\treturn {\n\t\t\tfound: true,\n\t\t\tscope,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\tprimary,\n\t\t\tkeywords,\n\t\t};\n\t}\n\n\tif (ref) {\n\t\tconsole.log(refPath);\n\t\treturn {\n\t\t\tfound: true,\n\t\t\tscope,\n\t\t\tqualifiedName,\n\t\t\tlocalPath: entry.localPath,\n\t\t\tprimary,\n\t\t\tkeywords,\n\t\t};\n\t}\n\n\tif (json) {\n\t\tconsole.log(\n\t\t\tJSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tfound: true,\n\t\t\t\t\tscope,\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\tlocalPath: entry.localPath,\n\t\t\t\t\tprimary,\n\t\t\t\t\treferencePath: refPath,\n\t\t\t\t\tkeywords,\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t);\n\t} else {\n\t\tconsole.log(`Repo: ${qualifiedName}`);\n\t\tconsole.log(`Scope: ${scope}`);\n\t\tconsole.log(`Path: ${entry.localPath}`);\n\t\tconsole.log(`Reference: ${refPath}`);\n\t\tif (keywords.length > 0) {\n\t\t\tconsole.log(`Keywords: ${keywords.join(\", \")}`);\n\t\t}\n\t}\n\n\treturn {\n\t\tfound: true,\n\t\tscope,\n\t\tqualifiedName,\n\t\tlocalPath: entry.localPath,\n\t\tprimary,\n\t\tkeywords,\n\t};\n}\n\nexport interface MapSearchOptions {\n\tterm: string;\n\tlimit?: number;\n\tjson?: boolean;\n}\n\nexport interface MapSearchResult {\n\tresults: SearchResult[];\n}\n\nexport async function mapSearchHandler(options: MapSearchOptions): Promise<MapSearchResult> {\n\tconst { term, limit = 10, json } = options;\n\n\tconst results = searchMap(term, { limit });\n\n\tif (json) {\n\t\tconsole.log(JSON.stringify(results, null, 2));\n\t} else if (results.length === 0) {\n\t\tp.log.warn(`No matches found for: ${term}`);\n\t} else {\n\t\tfor (const r of results) {\n\t\t\tconst refPath = `${Paths.offworldReferencesDir}/${r.primary}`;\n\t\t\tconsole.log(`${r.fullName}`);\n\t\t\tconsole.log(` path: ${r.localPath}`);\n\t\t\tconsole.log(` ref: ${refPath}`);\n\t\t\tif (r.keywords.length > 0) {\n\t\t\t\tconsole.log(` keywords: ${r.keywords.join(\", \")}`);\n\t\t\t}\n\t\t\tconsole.log(\"\");\n\t\t}\n\t}\n\n\treturn { results };\n}\n","import { os } from \"@orpc/server\";\nimport { createCli } from \"trpc-cli\";\nimport { z } from \"zod\";\nimport {\n\tpullHandler,\n\tgenerateHandler,\n\tpushHandler,\n\trmHandler,\n\tconfigShowHandler,\n\tconfigSetHandler,\n\tconfigGetHandler,\n\tconfigResetHandler,\n\tconfigPathHandler,\n\tconfigAgentsHandler,\n\tauthLoginHandler,\n\tauthLogoutHandler,\n\tauthStatusHandler,\n\tinitHandler,\n\tprojectInitHandler,\n\trepoListHandler,\n\trepoUpdateHandler,\n\trepoPruneHandler,\n\trepoStatusHandler,\n\trepoGcHandler,\n\trepoDiscoverHandler,\n\tupgradeHandler,\n\tuninstallHandler,\n\tmapShowHandler,\n\tmapSearchHandler,\n} from \"./handlers/index.js\";\n\nexport const version = \"0.1.10\";\n\nexport const router = os.router({\n\tpull: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\treference: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Reference name to pull (defaults to owner-repo)\")\n\t\t\t\t\t.meta({ alias: \"r\" }),\n\t\t\t\tshallow: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Use shallow clone (--depth 1)\")\n\t\t\t\t\t.meta({ negativeAlias: \"full-history\" }),\n\t\t\t\tsparse: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Use sparse checkout (only src/, lib/, packages/, docs/)\"),\n\t\t\t\tbranch: z.string().optional().describe(\"Branch to clone\"),\n\t\t\t\tforce: z.boolean().default(false).describe(\"Force re-generation\").meta({ alias: \"f\" }),\n\t\t\t\tverbose: z.boolean().default(false).describe(\"Show detailed output\"),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Model override (provider/model)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Clone a repository and fetch or generate its reference\",\n\t\t\tnegateBooleans: true,\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait pullHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\treference: input.reference,\n\t\t\t\tshallow: input.shallow,\n\t\t\t\tsparse: input.sparse,\n\t\t\t\tbranch: input.branch,\n\t\t\t\tforce: input.force,\n\t\t\t\tverbose: input.verbose,\n\t\t\t\tmodel: input.model,\n\t\t\t});\n\t\t}),\n\n\tlist: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\tpaths: z.boolean().default(false).describe(\"Show full paths\"),\n\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern (e.g. 'react-*')\"),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"List managed repositories (alias for 'ow repo list')\",\n\t\t\taliases: { command: [\"ls\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait repoListHandler({\n\t\t\t\tjson: input.json,\n\t\t\t\tpaths: input.paths,\n\t\t\t\tpattern: input.pattern,\n\t\t\t});\n\t\t}),\n\n\tgenerate: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\tforce: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Force even if remote exists\")\n\t\t\t\t\t.meta({ alias: \"f\" }),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"Model override (provider/model)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Generate reference locally (ignores remote)\",\n\t\t\taliases: { command: [\"gen\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait generateHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\tforce: input.force,\n\t\t\t\tmodel: input.model,\n\t\t\t});\n\t\t}),\n\n\tpush: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Push local reference to offworld.sh\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait pushHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t});\n\t\t}),\n\n\tremove: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\treferenceOnly: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Only remove reference files (keep repo)\"),\n\t\t\t\trepoOnly: z.boolean().default(false).describe(\"Only remove cloned repo (keep reference)\"),\n\t\t\t\tdryRun: z.boolean().default(false).describe(\"Show what would be done\").meta({ alias: \"d\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Remove a cloned repository and its reference\",\n\t\t\taliases: { command: [\"rm\"] },\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait rmHandler({\n\t\t\t\trepo: input.repo,\n\t\t\t\tyes: input.yes,\n\t\t\t\treferenceOnly: input.referenceOnly,\n\t\t\t\trepoOnly: input.repoOnly,\n\t\t\t\tdryRun: input.dryRun,\n\t\t\t});\n\t\t}),\n\n\tauth: os.router({\n\t\tlogin: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Login to offworld.sh\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authLoginHandler();\n\t\t\t}),\n\n\t\tlogout: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Logout from offworld.sh\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authLogoutHandler();\n\t\t\t}),\n\n\t\tstatus: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Show authentication status\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait authStatusHandler();\n\t\t\t}),\n\t}),\n\n\tconfig: os.router({\n\t\tshow: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Show all config settings\", default: true })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configShowHandler({ json: input.json });\n\t\t\t}),\n\n\t\tset: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tkey: z.string().describe(\"key\").meta({ positional: true }),\n\t\t\t\t\tvalue: z.string().describe(\"value\").meta({ positional: true }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: `Set a config value\n\nValid keys:\n repoRoot (string) Where to clone repos (e.g., ~/ow)\n defaultShallow (boolean) Use shallow clone by default (true/false)\n defaultModel (string) AI provider/model (e.g., anthropic/claude-sonnet-4-20250514)\n agents (list) Comma-separated agents (e.g., claude-code,opencode)`,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configSetHandler({ key: input.key, value: input.value });\n\t\t\t}),\n\n\t\tget: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tkey: z.string().describe(\"key\").meta({ positional: true }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: `Get a config value\n\nValid keys: repoRoot, defaultShallow, defaultModel, agents`,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait configGetHandler({ key: input.key });\n\t\t\t}),\n\n\t\treset: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Reset config to defaults\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configResetHandler();\n\t\t\t}),\n\n\t\tpath: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Show config file location\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configPathHandler();\n\t\t\t}),\n\n\t\tagents: os\n\t\t\t.input(z.object({}))\n\t\t\t.meta({ description: \"Interactively select agents for reference installation\" })\n\t\t\t.handler(async () => {\n\t\t\t\tawait configAgentsHandler();\n\t\t\t}),\n\t}),\n\n\tinit: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation prompts\").meta({ alias: \"y\" }),\n\t\t\t\tforce: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Reconfigure even if config exists\")\n\t\t\t\t\t.meta({ alias: \"f\" }),\n\t\t\t\tmodel: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\"AI provider/model (e.g., anthropic/claude-sonnet-4-20250514)\")\n\t\t\t\t\t.meta({ alias: \"m\" }),\n\t\t\t\trepoRoot: z.string().optional().describe(\"Where to clone repos\"),\n\t\t\t\tagents: z.string().optional().describe(\"Comma-separated agents\").meta({ alias: \"a\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Initialize configuration with interactive setup\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait initHandler({\n\t\t\t\tyes: input.yes,\n\t\t\t\tforce: input.force,\n\t\t\t\tmodel: input.model,\n\t\t\t\trepoRoot: input.repoRoot,\n\t\t\t\tagents: input.agents,\n\t\t\t});\n\t\t}),\n\n\tproject: os.router({\n\t\tinit: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tall: z.boolean().default(false).describe(\"Select all detected dependencies\"),\n\t\t\t\t\tdeps: z.string().optional().describe(\"Comma-separated deps to include (skip selection)\"),\n\t\t\t\t\tskip: z.string().optional().describe(\"Comma-separated deps to exclude\"),\n\t\t\t\t\tgenerate: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Generate references for deps without existing ones\")\n\t\t\t\t\t\t.meta({ alias: \"g\" }),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be done without doing it\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmations\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Scan manifest, install references, update AGENTS.md\",\n\t\t\t\tdefault: true,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait projectInitHandler({\n\t\t\t\t\tall: input.all,\n\t\t\t\t\tdeps: input.deps,\n\t\t\t\t\tskip: input.skip,\n\t\t\t\t\tgenerate: input.generate,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\tmap: os.router({\n\t\tshow: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\trepo: z.string().describe(\"repo\").meta({ positional: true }),\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t\tpath: z.boolean().default(false).describe(\"Print only local path\"),\n\t\t\t\t\tref: z.boolean().default(false).describe(\"Print only reference file path\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Show map entry for a repo\",\n\t\t\t\tdefault: true,\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait mapShowHandler({\n\t\t\t\t\trepo: input.repo,\n\t\t\t\t\tjson: input.json,\n\t\t\t\t\tpath: input.path,\n\t\t\t\t\tref: input.ref,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tsearch: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tterm: z.string().describe(\"term\").meta({ positional: true }),\n\t\t\t\t\tlimit: z.number().default(10).describe(\"Max results\").meta({ alias: \"n\" }),\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"Search map for repos matching a term\",\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait mapSearchHandler({\n\t\t\t\t\tterm: input.term,\n\t\t\t\t\tlimit: input.limit,\n\t\t\t\t\tjson: input.json,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\trepo: os.router({\n\t\tlist: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t\tpaths: z.boolean().default(false).describe(\"Show full paths\"),\n\t\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern (e.g. 'react-*')\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({\n\t\t\t\tdescription: \"List managed repositories\",\n\t\t\t\tdefault: true,\n\t\t\t\taliases: { command: [\"ls\"] },\n\t\t\t})\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoListHandler({\n\t\t\t\t\tjson: input.json,\n\t\t\t\t\tpaths: input.paths,\n\t\t\t\t\tpattern: input.pattern,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tupdate: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tall: z.boolean().default(false).describe(\"Update all repos\"),\n\t\t\t\t\tpattern: z.string().optional().describe(\"Filter by pattern\"),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be updated\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tunshallow: z.boolean().default(false).describe(\"Convert shallow clones to full clones\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Update repos (git fetch + pull)\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoUpdateHandler({\n\t\t\t\t\tall: input.all,\n\t\t\t\t\tpattern: input.pattern,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tunshallow: input.unshallow,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tprune: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be pruned\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t\tremoveOrphans: z.boolean().default(false).describe(\"Also remove orphaned directories\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Remove stale index entries and find orphaned directories\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoPruneHandler({\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t\tremoveOrphans: input.removeOrphans,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tstatus: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tjson: z.boolean().default(false).describe(\"Output as JSON\"),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Show summary of managed repos\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoStatusHandler({ json: input.json });\n\t\t\t}),\n\n\t\tgc: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tolderThan: z\n\t\t\t\t\t\t.string()\n\t\t\t\t\t\t.optional()\n\t\t\t\t\t\t.describe(\"Remove repos not accessed in N days (e.g. '30d')\"),\n\t\t\t\t\twithoutReference: z.boolean().default(false).describe(\"Remove repos without references\"),\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be removed\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Garbage collect old/unused repos\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoGcHandler({\n\t\t\t\t\tolderThan: input.olderThan,\n\t\t\t\t\twithoutReference: input.withoutReference,\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\n\t\tdiscover: os\n\t\t\t.input(\n\t\t\t\tz.object({\n\t\t\t\t\tdryRun: z\n\t\t\t\t\t\t.boolean()\n\t\t\t\t\t\t.default(false)\n\t\t\t\t\t\t.describe(\"Show what would be added\")\n\t\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\t\tyes: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"y\" }),\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.meta({ description: \"Discover and index existing repos in repoRoot\" })\n\t\t\t.handler(async ({ input }) => {\n\t\t\t\tawait repoDiscoverHandler({\n\t\t\t\t\tdryRun: input.dryRun,\n\t\t\t\t\tyes: input.yes,\n\t\t\t\t});\n\t\t\t}),\n\t}),\n\n\tupgrade: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\ttarget: z.string().optional().describe(\"Version to upgrade to\"),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Upgrade offworld to latest or specific version\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait upgradeHandler({\n\t\t\t\ttarget: input.target,\n\t\t\t});\n\t\t}),\n\n\tuninstall: os\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\tkeepConfig: z.boolean().default(false).describe(\"Keep configuration files\"),\n\t\t\t\tkeepData: z.boolean().default(false).describe(\"Keep data files (references, repos)\"),\n\t\t\t\tdryRun: z\n\t\t\t\t\t.boolean()\n\t\t\t\t\t.default(false)\n\t\t\t\t\t.describe(\"Show what would be removed\")\n\t\t\t\t\t.meta({ alias: \"d\" }),\n\t\t\t\tforce: z.boolean().default(false).describe(\"Skip confirmation\").meta({ alias: \"f\" }),\n\t\t\t}),\n\t\t)\n\t\t.meta({\n\t\t\tdescription: \"Uninstall offworld and remove related files\",\n\t\t})\n\t\t.handler(async ({ input }) => {\n\t\t\tawait uninstallHandler({\n\t\t\t\tkeepConfig: input.keepConfig,\n\t\t\t\tkeepData: input.keepData,\n\t\t\t\tdryRun: input.dryRun,\n\t\t\t\tforce: input.force,\n\t\t\t});\n\t\t}),\n});\n\nconst stripSecondaryDescription = (help: string) =>\n\thelp\n\t\t.split(\"\\n\")\n\t\t.filter((line) => !line.startsWith(\"Available subcommands:\"))\n\t\t.join(\"\\n\");\n\nconst stripDefaultCommandHelp = (help: string) => {\n\tconst firstUsageIndex = help.indexOf(\"Usage:\");\n\tif (firstUsageIndex === -1) return help.trimEnd();\n\tconst secondUsageIndex = help.indexOf(\"Usage:\", firstUsageIndex + 1);\n\tif (secondUsageIndex === -1) return help.trimEnd();\n\treturn help.slice(0, secondUsageIndex).trimEnd();\n};\n\nconst normalizeRootHelp = (help: string) =>\n\tstripDefaultCommandHelp(stripSecondaryDescription(help));\n\nexport function createOwCli() {\n\tconst cli = createCli({\n\t\trouter,\n\t\tdescription: \"Offworld CLI - Repository reference generation for AI coding agents\",\n\t});\n\n\tconst buildProgram: typeof cli.buildProgram = (runParams) => {\n\t\tconst program = cli.buildProgram(runParams);\n\t\tconst originalHelpInformation = program.helpInformation.bind(program);\n\t\tprogram.helpInformation = () => normalizeRootHelp(originalHelpInformation());\n\t\treturn program;\n\t};\n\n\tconst run: typeof cli.run = (runParams, program) =>\n\t\tcli.run(runParams, program ?? buildProgram(runParams));\n\n\treturn {\n\t\t...cli,\n\t\tbuildProgram,\n\t\trun,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,IAAM,cAAN,MAAyC;CACxC,MAAM,UAAyB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