@offworld/sdk 0.3.0 → 0.3.1
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/ai/index.d.mts.map +1 -1
- package/dist/ai/index.mjs +22 -0
- package/dist/ai/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/{public-MYVLaKUi.d.mts → public-Cdr8rPRd.d.mts} +2 -2
- package/dist/{public-MYVLaKUi.d.mts.map → public-Cdr8rPRd.d.mts.map} +1 -1
- package/dist/{public-DbZeh2Mr.mjs → public-CjA2mMwu.mjs} +2 -2
- package/dist/{public-DbZeh2Mr.mjs.map → public-CjA2mMwu.mjs.map} +1 -1
- package/package.json +3 -3
package/dist/ai/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/ai/opencode.ts","../../src/ai/errors.ts","../../src/generate.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/ai/opencode.ts","../../src/ai/errors.ts","../../src/generate.ts"],"mappings":";cAca,mBAAA;AAAA,cACA,gBAAA;AAAA,UAEI,mBAAA;EAChB,MAAA;EACA,GAAA;EACA,YAAA;EACA,QAAA;EAEA,KAAA;;EAEA,SAAA;EACA,OAAA,IAAW,OAAA;EACX,QAAA,IAAY,IAAA;AAAA;AAAA,UAGI,kBAAA;EAChB,IAAA;EACA,SAAA;EACA,UAAA;AAAA;AAAA,iBAyLqB,YAAA,CAAa,OAAA,EAAS,mBAAA,GAAsB,OAAA,CAAQ,kBAAA;;;;AA5M1E;;cCXa,sBAAA,SAA+B,KAAA;EAAA,SAI1B,OAAA;EAAA,SAHR,IAAA;cAER,OAAA,UACgB,OAAA;AAAA;;;;cA0BL,gBAAA,SAAyB,sBAAA;EAAA,SAC5B,IAAA;cACG,OAAA;AA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d as toReferenceName, s as loadConfig } from "../config-DW8J4gl5.mjs";
|
|
2
2
|
import { c as getCommitSha } from "../clone-DyLvmbJZ.mjs";
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
|
|
5
6
|
//#region src/ai/errors.ts
|
|
@@ -15,6 +16,19 @@ var OpenCodeReferenceError = class extends Error {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
19
|
+
* Error when the opencode CLI binary is not installed
|
|
20
|
+
*/
|
|
21
|
+
var OpenCodeNotInstalledError = class extends OpenCodeReferenceError {
|
|
22
|
+
_tag = "OpenCodeNotInstalledError";
|
|
23
|
+
hint;
|
|
24
|
+
constructor() {
|
|
25
|
+
const hint = "opencode is required for local AI reference generation. Install it: curl -fsSL https://opencode.ai/install | bash";
|
|
26
|
+
super(`opencode is not installed. ${hint}`);
|
|
27
|
+
this.name = "OpenCodeNotInstalledError";
|
|
28
|
+
this.hint = hint;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
18
32
|
* Error when the @opencode-ai/sdk package is not installed or invalid
|
|
19
33
|
*/
|
|
20
34
|
var OpenCodeSDKError = class extends OpenCodeReferenceError {
|
|
@@ -387,11 +401,19 @@ const DEFAULT_AI_PROVIDER = "opencode";
|
|
|
387
401
|
const DEFAULT_AI_MODEL = "claude-opus-4-5";
|
|
388
402
|
let cachedCreateOpencode = null;
|
|
389
403
|
let cachedCreateOpencodeClient = null;
|
|
404
|
+
function assertOpenCodeInstalled() {
|
|
405
|
+
try {
|
|
406
|
+
execSync("opencode --version", { stdio: "ignore" });
|
|
407
|
+
} catch {
|
|
408
|
+
throw new OpenCodeNotInstalledError();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
390
411
|
async function getOpenCodeSDK() {
|
|
391
412
|
if (cachedCreateOpencode && cachedCreateOpencodeClient) return {
|
|
392
413
|
createOpencode: cachedCreateOpencode,
|
|
393
414
|
createOpencodeClient: cachedCreateOpencodeClient
|
|
394
415
|
};
|
|
416
|
+
assertOpenCodeInstalled();
|
|
395
417
|
try {
|
|
396
418
|
const sdk = await import("@opencode-ai/sdk");
|
|
397
419
|
if (typeof sdk.createOpencode !== "function" || typeof sdk.createOpencodeClient !== "function") throw new OpenCodeSDKError("SDK missing required exports");
|
package/dist/ai/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/ai/errors.ts","../../src/ai/stream/types.ts","../../src/ai/stream/accumulator.ts","../../src/ai/stream/transformer.ts","../../src/ai/opencode.ts","../../src/generate.ts"],"sourcesContent":["/**\n * Base class for OpenCode reference errors\n */\nexport class OpenCodeReferenceError extends Error {\n\treadonly _tag: string = \"OpenCodeReferenceError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"OpenCodeReferenceError\";\n\t}\n}\n\n/**\n * Error when the @opencode-ai/sdk package is not installed or invalid\n */\nexport class OpenCodeSDKError extends OpenCodeReferenceError {\n\treadonly _tag = \"OpenCodeSDKError\" as const;\n\tconstructor(message?: string) {\n\t\tsuper(\n\t\t\tmessage ?? \"Failed to import @opencode-ai/sdk. Install it with: bun add @opencode-ai/sdk\",\n\t\t);\n\t\tthis.name = \"OpenCodeSDKError\";\n\t}\n}\n\n/**\n * Error when the requested provider is not found\n */\nexport class InvalidProviderError extends OpenCodeReferenceError {\n\treadonly _tag = \"InvalidProviderError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly availableProviders: string[],\n\t) {\n\t\tconst hint =\n\t\t\tavailableProviders.length > 0\n\t\t\t\t? `Available providers: ${availableProviders.join(\", \")}`\n\t\t\t\t: \"No providers available. Check your OpenCode configuration.\";\n\t\tsuper(`Provider \"${providerID}\" not found. ${hint}`);\n\t\tthis.name = \"InvalidProviderError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the provider exists but is not connected/authenticated\n */\nexport class ProviderNotConnectedError extends OpenCodeReferenceError {\n\treadonly _tag = \"ProviderNotConnectedError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly connectedProviders: string[],\n\t) {\n\t\tconst hint =\n\t\t\tconnectedProviders.length > 0\n\t\t\t\t? `Connected providers: ${connectedProviders.join(\", \")}. Run 'opencode auth ${providerID}' to connect.`\n\t\t\t\t: `No providers connected. Run 'opencode auth ${providerID}' to authenticate.`;\n\t\tsuper(`Provider \"${providerID}\" is not connected. ${hint}`);\n\t\tthis.name = \"ProviderNotConnectedError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the requested model is not found for a provider\n */\nexport class InvalidModelError extends OpenCodeReferenceError {\n\treadonly _tag = \"InvalidModelError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly modelID: string,\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly availableModels: string[],\n\t) {\n\t\tconst hint =\n\t\t\tavailableModels.length > 0\n\t\t\t\t? `Available models for ${providerID}: ${availableModels.slice(0, 10).join(\", \")}${availableModels.length > 10 ? ` (and ${availableModels.length - 10} more)` : \"\"}`\n\t\t\t\t: `No models available for provider \"${providerID}\".`;\n\t\tsuper(`Model \"${modelID}\" not found for provider \"${providerID}\". ${hint}`);\n\t\tthis.name = \"InvalidModelError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the OpenCode server fails to start\n */\nexport class ServerStartError extends OpenCodeReferenceError {\n\treadonly _tag = \"ServerStartError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly port?: number,\n\t\tdetails?: unknown,\n\t) {\n\t\tconst hint = port\n\t\t\t? `Failed to start server on port ${port}. Ensure no other process is using this port.`\n\t\t\t: \"Failed to start OpenCode server. Check your OpenCode installation and configuration.\";\n\t\tsuper(`${message}. ${hint}`, details);\n\t\tthis.name = \"ServerStartError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when a session operation fails\n */\nexport class SessionError extends OpenCodeReferenceError {\n\treadonly _tag = \"SessionError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly sessionId?: string,\n\t\tpublic readonly sessionState?: string,\n\t\tdetails?: unknown,\n\t) {\n\t\tconst context = sessionId ? ` (session: ${sessionId})` : \"\";\n\t\tconst stateInfo = sessionState ? ` State: ${sessionState}.` : \"\";\n\t\tconst hint = `Session operation failed${context}.${stateInfo} Try creating a new session.`;\n\t\tsuper(`${message}. ${hint}`, details);\n\t\tthis.name = \"SessionError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when a request times out\n */\nexport class TimeoutError extends OpenCodeReferenceError {\n\treadonly _tag = \"TimeoutError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly timeoutMs: number,\n\t\tpublic readonly operation: string = \"operation\",\n\t) {\n\t\tconst hint = `The ${operation} did not complete within ${timeoutMs}ms. Consider increasing the timeout or checking if the model is responding.`;\n\t\tsuper(`Timeout: ${operation} did not complete within ${timeoutMs}ms. ${hint}`);\n\t\tthis.name = \"TimeoutError\";\n\t\tthis.hint = hint;\n\t}\n}\n","/**\n * Zod schemas for OpenCode stream events\n * Replaces inline `as` casts with runtime-validated types\n */\n\nimport { z } from \"zod\";\n\nconst PartBaseSchema = z.object({\n\tid: z.string().optional(),\n\tsessionID: z.string().optional(),\n\tmessageID: z.string().optional(),\n});\n\nexport const TextPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"text\"),\n\ttext: z.string().optional(),\n});\n\nexport const ToolStatePendingSchema = z.object({\n\tstatus: z.literal(\"pending\"),\n});\n\nexport const ToolStateRunningSchema = z.object({\n\tstatus: z.literal(\"running\"),\n\ttitle: z.string().optional(),\n\tinput: z.unknown().optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateCompletedSchema = z.object({\n\tstatus: z.literal(\"completed\"),\n\ttitle: z.string().optional(),\n\tinput: z.record(z.string(), z.unknown()).optional(),\n\toutput: z.string().optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t\tend: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateErrorSchema = z.object({\n\tstatus: z.literal(\"error\"),\n\terror: z.string().optional(),\n\tinput: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t\tend: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateSchema = z.discriminatedUnion(\"status\", [\n\tToolStatePendingSchema,\n\tToolStateRunningSchema,\n\tToolStateCompletedSchema,\n\tToolStateErrorSchema,\n]);\n\nexport const ToolPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool\"),\n\tcallID: z.string().optional(),\n\ttool: z.string().optional(),\n\tstate: ToolStateSchema.optional(),\n});\n\nexport const StepStartPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"step-start\"),\n});\n\nexport const StepFinishPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"step-finish\"),\n\treason: z.string().optional(),\n});\n\nexport const ToolUsePartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool-use\"),\n\ttoolUseId: z.string().optional(),\n\tname: z.string().optional(),\n});\n\nexport const ToolResultPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool-result\"),\n\ttoolUseId: z.string().optional(),\n});\n\nexport const MessagePartSchema = z.discriminatedUnion(\"type\", [\n\tTextPartSchema,\n\tToolPartSchema,\n\tStepStartPartSchema,\n\tStepFinishPartSchema,\n\tToolUsePartSchema,\n\tToolResultPartSchema,\n]);\n\n/**\n * Session error payload\n */\nexport const SessionErrorSchema = z.object({\n\tname: z.string().optional(),\n\tmessage: z.string().optional(),\n\tcode: z.string().optional(),\n});\n\nexport const MessagePartUpdatedPropsSchema = z.object({\n\tpart: MessagePartSchema,\n});\n\n/**\n * Properties for session.idle event\n */\nexport const SessionIdlePropsSchema = z.object({\n\tsessionID: z.string(),\n});\n\n/**\n * Properties for session.error event\n */\nexport const SessionErrorPropsSchema = z.object({\n\tsessionID: z.string(),\n\terror: SessionErrorSchema.optional(),\n});\n\n/**\n * Properties for session.updated event\n */\nexport const SessionUpdatedPropsSchema = z.object({\n\tsessionID: z.string(),\n\tstatus: z.string().optional(),\n});\n\n/**\n * message.part.updated event\n */\nexport const MessagePartUpdatedEventSchema = z.object({\n\ttype: z.literal(\"message.part.updated\"),\n\tproperties: MessagePartUpdatedPropsSchema,\n});\n\n/**\n * session.idle event\n */\nexport const SessionIdleEventSchema = z.object({\n\ttype: z.literal(\"session.idle\"),\n\tproperties: SessionIdlePropsSchema,\n});\n\n/**\n * session.error event\n */\nexport const SessionErrorEventSchema = z.object({\n\ttype: z.literal(\"session.error\"),\n\tproperties: SessionErrorPropsSchema,\n});\n\n/**\n * session.updated event\n */\nexport const SessionUpdatedEventSchema = z.object({\n\ttype: z.literal(\"session.updated\"),\n\tproperties: SessionUpdatedPropsSchema,\n});\n\n/**\n * Generic event for unknown types (passthrough)\n */\nexport const GenericEventSchema = z.object({\n\ttype: z.string(),\n\tproperties: z.record(z.string(), z.unknown()),\n});\n\nexport type TextPart = z.infer<typeof TextPartSchema>;\nexport type ToolPart = z.infer<typeof ToolPartSchema>;\nexport type ToolState = z.infer<typeof ToolStateSchema>;\nexport type ToolStateRunning = z.infer<typeof ToolStateRunningSchema>;\nexport type ToolUsePart = z.infer<typeof ToolUsePartSchema>;\nexport type ToolResultPart = z.infer<typeof ToolResultPartSchema>;\nexport type MessagePart = z.infer<typeof MessagePartSchema>;\n\nexport type SessionErrorPayload = z.infer<typeof SessionErrorSchema>;\n\nexport type MessagePartUpdatedProps = z.infer<typeof MessagePartUpdatedPropsSchema>;\nexport type SessionIdleProps = z.infer<typeof SessionIdlePropsSchema>;\nexport type SessionErrorProps = z.infer<typeof SessionErrorPropsSchema>;\nexport type SessionUpdatedProps = z.infer<typeof SessionUpdatedPropsSchema>;\n\nexport type MessagePartUpdatedEvent = z.infer<typeof MessagePartUpdatedEventSchema>;\nexport type SessionIdleEvent = z.infer<typeof SessionIdleEventSchema>;\nexport type SessionErrorEvent = z.infer<typeof SessionErrorEventSchema>;\nexport type SessionUpdatedEvent = z.infer<typeof SessionUpdatedEventSchema>;\nexport type GenericEvent = z.infer<typeof GenericEventSchema>;\n\n/**\n * All known stream event types\n */\nexport type StreamEvent =\n\t| MessagePartUpdatedEvent\n\t| SessionIdleEvent\n\t| SessionErrorEvent\n\t| SessionUpdatedEvent\n\t| GenericEvent;\n","/**\n * Text accumulator for stream events\n * Manages accumulation of text parts by ID and provides delta extraction\n */\n\nimport type { TextPart } from \"./types.js\";\n\n/**\n * Accumulates text from streaming message parts.\n * Tracks multiple parts by ID and provides delta text between updates.\n */\nexport class TextAccumulator {\n\tprivate readonly parts = new Map<string, string>();\n\tprivate _firstTextReceived = false;\n\n\t/**\n\t * Whether any text has been received\n\t */\n\tget hasReceivedText(): boolean {\n\t\treturn this._firstTextReceived;\n\t}\n\n\t/**\n\t * Accumulate text from a message part and return the delta (new text only).\n\t * Returns null if the part should be skipped (non-text, no ID, no text).\n\t */\n\taccumulatePart(part: TextPart): string | null {\n\t\tif (part.type !== \"text\" || !part.text || !part.id) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst partId = part.id;\n\t\tconst prevText = this.parts.get(partId) ?? \"\";\n\t\tthis.parts.set(partId, part.text);\n\n\t\tif (!this._firstTextReceived) {\n\t\t\tthis._firstTextReceived = true;\n\t\t}\n\n\t\tif (part.text.length > prevText.length) {\n\t\t\treturn part.text.slice(prevText.length);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get the full accumulated text from all parts\n\t */\n\tgetFullText(): string {\n\t\treturn Array.from(this.parts.values()).join(\"\");\n\t}\n\n\t/**\n\t * Get the number of distinct parts accumulated\n\t */\n\tgetPartCount(): number {\n\t\treturn this.parts.size;\n\t}\n\n\t/**\n\t * Get info about each part for debugging\n\t */\n\tgetPartInfo(): Array<{ id: string; length: number }> {\n\t\treturn Array.from(this.parts.entries()).map(([id, text]) => ({\n\t\t\tid,\n\t\t\tlength: text.length,\n\t\t}));\n\t}\n\n\t/**\n\t * Clear accumulated text\n\t */\n\tclear(): void {\n\t\tthis.parts.clear();\n\t\tthis._firstTextReceived = false;\n\t}\n}\n","/**\n * Stream event transformer and parser\n * Safely parses and validates stream events using Zod schemas\n */\n\nimport {\n\tMessagePartUpdatedPropsSchema,\n\tSessionIdlePropsSchema,\n\tSessionErrorPropsSchema,\n\tSessionErrorSchema,\n\ttype TextPart,\n\ttype ToolPart,\n\ttype SessionErrorPayload,\n\ttype MessagePartUpdatedProps,\n\ttype SessionIdleProps,\n\ttype SessionErrorProps,\n} from \"./types.js\";\n\n/**\n * Raw event from the OpenCode SDK stream\n */\nexport interface RawStreamEvent {\n\ttype: string;\n\tproperties: Record<string, unknown>;\n}\n\n/**\n * Result of parsing a stream event\n */\nexport type ParsedEventResult =\n\t| {\n\t\t\ttype: \"message.part.updated\";\n\t\t\tprops: MessagePartUpdatedProps;\n\t\t\ttextPart: TextPart | null;\n\t\t\ttoolPart: ToolPart | null;\n\t }\n\t| { type: \"session.idle\"; props: SessionIdleProps }\n\t| { type: \"session.error\"; props: SessionErrorProps; error: SessionErrorPayload | null }\n\t| { type: \"unknown\"; rawType: string };\n\n/**\n * Parse a raw stream event into a typed result.\n * Uses safe parsing - returns type: \"unknown\" for unrecognized or invalid events.\n */\nexport function parseStreamEvent(event: RawStreamEvent): ParsedEventResult {\n\tswitch (event.type) {\n\t\tcase \"message.part.updated\": {\n\t\t\tconst propsResult = MessagePartUpdatedPropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\tconst props = propsResult.data;\n\t\t\tconst textPart = props.part.type === \"text\" ? props.part : null;\n\t\t\tconst toolPart = props.part.type === \"tool\" ? props.part : null;\n\t\t\treturn { type: \"message.part.updated\", props, textPart, toolPart };\n\t\t}\n\n\t\tcase \"session.idle\": {\n\t\t\tconst propsResult = SessionIdlePropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\treturn { type: \"session.idle\", props: propsResult.data };\n\t\t}\n\n\t\tcase \"session.error\": {\n\t\t\tconst propsResult = SessionErrorPropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\tconst props = propsResult.data;\n\n\t\t\tlet error: SessionErrorPayload | null = null;\n\t\t\tif (props.error) {\n\t\t\t\tconst errorResult = SessionErrorSchema.safeParse(props.error);\n\t\t\t\tif (errorResult.success) {\n\t\t\t\t\terror = errorResult.data;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { type: \"session.error\", props, error };\n\t\t}\n\n\t\tdefault:\n\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t}\n}\n\nexport function isEventForSession(event: RawStreamEvent, sessionId: string): boolean {\n\tconst props = event.properties;\n\tif (\"sessionID\" in props && typeof props.sessionID === \"string\") {\n\t\treturn props.sessionID === sessionId;\n\t}\n\tif (\n\t\t\"part\" in props &&\n\t\ttypeof props.part === \"object\" &&\n\t\tprops.part !== null &&\n\t\t\"sessionID\" in props.part &&\n\t\ttypeof props.part.sessionID === \"string\"\n\t) {\n\t\treturn props.part.sessionID === sessionId;\n\t}\n\treturn true;\n}\n","import {\n\tOpenCodeReferenceError,\n\tOpenCodeSDKError,\n\tInvalidProviderError,\n\tProviderNotConnectedError,\n\tInvalidModelError,\n\tServerStartError,\n\tSessionError,\n\tTimeoutError,\n} from \"./errors.js\";\nimport { TextAccumulator, parseStreamEvent, isEventForSession } from \"./stream/index.js\";\n\nexport const DEFAULT_AI_PROVIDER = \"opencode\";\nexport const DEFAULT_AI_MODEL = \"claude-opus-4-5\";\n\nexport interface StreamPromptOptions {\n\tprompt: string;\n\tcwd: string;\n\tsystemPrompt?: string;\n\tprovider?: string;\n\n\tmodel?: string;\n\t/** Timeout in milliseconds. Set to 0 or undefined for no timeout. */\n\ttimeoutMs?: number;\n\tonDebug?: (message: string) => void;\n\tonStream?: (text: string) => void;\n}\n\nexport interface StreamPromptResult {\n\ttext: string;\n\tsessionId: string;\n\tdurationMs: number;\n}\n\ninterface OpenCodeServer {\n\tclose: () => void;\n\turl: string;\n}\n\ninterface OpenCodeSession {\n\tid: string;\n}\n\ninterface OpenCodeEvent {\n\ttype: string;\n\tproperties: Record<string, unknown>;\n}\n\ninterface OpenCodeProviderModel {\n\tid: string;\n\tname: string;\n}\n\ninterface OpenCodeProvider {\n\tid: string;\n\tname: string;\n\tmodels: Record<string, OpenCodeProviderModel>;\n}\n\ninterface OpenCodeProviderListResponse {\n\tall: OpenCodeProvider[];\n\tconnected: string[];\n\tdefault: Record<string, string>;\n}\n\ninterface OpenCodeClient {\n\tsession: {\n\t\tcreate: () => Promise<{ data: OpenCodeSession; error?: unknown }>;\n\t\tprompt: (options: {\n\t\t\tpath: { id: string };\n\t\t\tbody: {\n\t\t\t\tagent?: string;\n\t\t\t\tparts: Array<{ type: string; text: string }>;\n\t\t\t\tmodel?: { providerID: string; modelID: string };\n\t\t\t};\n\t\t}) => Promise<{ data: unknown; error?: unknown }>;\n\t};\n\tevent: {\n\t\tsubscribe: () => Promise<{\n\t\t\tstream: AsyncIterable<OpenCodeEvent>;\n\t\t}>;\n\t};\n\tprovider: {\n\t\tlist: () => Promise<{ data: OpenCodeProviderListResponse; error?: unknown }>;\n\t};\n}\n\ninterface AgentConfig {\n\tdisable?: boolean;\n\tprompt?: string;\n\tdescription?: string;\n\tmode?: string;\n\tpermission?: Record<string, string>;\n\ttools?: Record<string, boolean>;\n}\n\ninterface OpenCodeConfig {\n\tplugin?: unknown[];\n\tmcp?: Record<string, unknown>;\n\tinstructions?: unknown[];\n\tagent?: Record<string, AgentConfig>;\n}\n\ntype CreateOpencodeResult = { server: OpenCodeServer };\ntype CreateOpencodeClientFn = (opts: { baseUrl: string; directory: string }) => OpenCodeClient;\ntype CreateOpencodeFn = (opts: {\n\tport: number;\n\tcwd?: string;\n\tconfig?: OpenCodeConfig;\n}) => Promise<CreateOpencodeResult>;\n\nlet cachedCreateOpencode: CreateOpencodeFn | null = null;\nlet cachedCreateOpencodeClient: CreateOpencodeClientFn | null = null;\n\nasync function getOpenCodeSDK(): Promise<{\n\tcreateOpencode: CreateOpencodeFn;\n\tcreateOpencodeClient: CreateOpencodeClientFn;\n}> {\n\tif (cachedCreateOpencode && cachedCreateOpencodeClient) {\n\t\treturn {\n\t\t\tcreateOpencode: cachedCreateOpencode,\n\t\t\tcreateOpencodeClient: cachedCreateOpencodeClient,\n\t\t};\n\t}\n\n\ttry {\n\t\tconst sdk = await import(\"@opencode-ai/sdk\");\n\t\tif (\n\t\t\ttypeof sdk.createOpencode !== \"function\" ||\n\t\t\ttypeof sdk.createOpencodeClient !== \"function\"\n\t\t) {\n\t\t\tthrow new OpenCodeSDKError(\"SDK missing required exports\");\n\t\t}\n\t\tcachedCreateOpencode = sdk.createOpencode as CreateOpencodeFn;\n\t\tcachedCreateOpencodeClient = sdk.createOpencodeClient as CreateOpencodeClientFn;\n\t\treturn {\n\t\t\tcreateOpencode: cachedCreateOpencode,\n\t\t\tcreateOpencodeClient: cachedCreateOpencodeClient,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof OpenCodeSDKError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new OpenCodeSDKError();\n\t}\n}\n\ninterface ToolRunningState {\n\tstatus: \"running\";\n\ttitle?: string;\n\tinput?: unknown;\n}\n\nfunction formatToolMessage(tool: string | undefined, state: ToolRunningState): string | null {\n\tif (state.title) {\n\t\treturn state.title;\n\t}\n\n\tif (!tool) {\n\t\treturn null;\n\t}\n\n\tconst input =\n\t\tstate.input && typeof state.input === \"object\" && !Array.isArray(state.input)\n\t\t\t? (state.input as Record<string, unknown>)\n\t\t\t: undefined;\n\tif (!input) {\n\t\treturn `Running ${tool}...`;\n\t}\n\n\tswitch (tool) {\n\t\tcase \"read\": {\n\t\t\tconst path = input.filePath ?? input.path;\n\t\t\tif (typeof path === \"string\") {\n\t\t\t\tconst filename = path.split(\"/\").pop();\n\t\t\t\treturn `Reading ${filename}...`;\n\t\t\t}\n\t\t\treturn \"Reading file...\";\n\t\t}\n\t\tcase \"glob\": {\n\t\t\tconst pattern = input.pattern;\n\t\t\tif (typeof pattern === \"string\") {\n\t\t\t\treturn `Globbing ${pattern}...`;\n\t\t\t}\n\t\t\treturn \"Searching files...\";\n\t\t}\n\t\tcase \"grep\": {\n\t\t\tconst pattern = input.pattern;\n\t\t\tif (typeof pattern === \"string\") {\n\t\t\t\tconst truncated = pattern.length > 30 ? `${pattern.slice(0, 30)}...` : pattern;\n\t\t\t\treturn `Searching for \"${truncated}\"...`;\n\t\t\t}\n\t\t\treturn \"Searching content...\";\n\t\t}\n\t\tcase \"list\": {\n\t\t\tconst path = input.path;\n\t\t\tif (typeof path === \"string\") {\n\t\t\t\treturn `Listing ${path}...`;\n\t\t\t}\n\t\t\treturn \"Listing directory...\";\n\t\t}\n\t\tdefault:\n\t\t\treturn `Running ${tool}...`;\n\t}\n}\n\nexport async function streamPrompt(options: StreamPromptOptions): Promise<StreamPromptResult> {\n\tconst {\n\t\tprompt,\n\t\tcwd,\n\t\tsystemPrompt,\n\t\tprovider: optProvider,\n\t\tmodel: optModel,\n\t\ttimeoutMs,\n\t\tonDebug,\n\t\tonStream,\n\t} = options;\n\n\tconst debug = onDebug ?? (() => {});\n\tconst stream = onStream ?? (() => {});\n\tconst startTime = Date.now();\n\n\tdebug(\"Loading OpenCode SDK...\");\n\tconst { createOpencode, createOpencodeClient } = await getOpenCodeSDK();\n\n\tconst maxAttempts = 10;\n\tlet server: OpenCodeServer | null = null;\n\tlet client: OpenCodeClient | null = null;\n\tlet port = 0;\n\n\tconst config: OpenCodeConfig = {\n\t\tplugin: [],\n\t\tmcp: {},\n\t\tinstructions: [],\n\t\tagent: {\n\t\t\tbuild: { disable: true },\n\t\t\tgeneral: { disable: true },\n\t\t\tplan: { disable: true },\n\t\t\texplore: { disable: true },\n\t\t\tanalyze: {\n\t\t\t\tprompt: [\n\t\t\t\t\t\"You are an expert at analyzing open source codebases and producing documentation.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Your job is to read the codebase and produce structured output based on the user's request.\",\n\t\t\t\t\t\"Use glob to discover files, grep to search for patterns, and read to examine file contents.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Guidelines:\",\n\t\t\t\t\t\"- Explore the codebase thoroughly before producing output\",\n\t\t\t\t\t\"- Focus on understanding architecture, key abstractions, and usage patterns\",\n\t\t\t\t\t\"- When asked for JSON output, respond with ONLY valid JSON - no markdown, no code blocks\",\n\t\t\t\t\t\"- When asked for prose, write clear and concise documentation\",\n\t\t\t\t\t\"- Always base your analysis on actual code you've read, never speculate\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\tmode: \"primary\",\n\t\t\t\tdescription: \"Analyze open source codebases and produce summaries and reference files\",\n\t\t\t\ttools: {\n\t\t\t\t\tread: true,\n\t\t\t\t\tgrep: true,\n\t\t\t\t\tglob: true,\n\t\t\t\t\tlist: true,\n\t\t\t\t\twrite: false,\n\t\t\t\t\tbash: false,\n\t\t\t\t\tdelete: false,\n\t\t\t\t\tedit: false,\n\t\t\t\t\tpatch: false,\n\t\t\t\t\tpath: false,\n\t\t\t\t\ttodowrite: false,\n\t\t\t\t\ttodoread: false,\n\t\t\t\t\twebsearch: false,\n\t\t\t\t\twebfetch: false,\n\t\t\t\t\tcodesearch: false,\n\t\t\t\t\tskill: false,\n\t\t\t\t\ttask: false,\n\t\t\t\t\tmcp: false,\n\t\t\t\t\tquestion: false,\n\t\t\t\t\tplan_enter: false,\n\t\t\t\t\tplan_exit: false,\n\t\t\t\t},\n\t\t\t\tpermission: {\n\t\t\t\t\tedit: \"deny\",\n\t\t\t\t\tbash: \"deny\",\n\t\t\t\t\twebfetch: \"deny\",\n\t\t\t\t\texternal_directory: \"deny\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tdebug(\"Starting embedded OpenCode server...\");\n\n\tfor (let attempt = 0; attempt < maxAttempts; attempt++) {\n\t\tport = Math.floor(Math.random() * 3000) + 3000;\n\t\ttry {\n\t\t\tconst result = await createOpencode({ port, cwd, config });\n\t\t\tserver = result.server;\n\t\t\tclient = createOpencodeClient({\n\t\t\t\tbaseUrl: `http://localhost:${port}`,\n\t\t\t\tdirectory: cwd,\n\t\t\t});\n\t\t\tdebug(`Server started on port ${port}`);\n\t\t\tbreak;\n\t\t} catch (err) {\n\t\t\tif (err instanceof Error && err.message?.includes(\"port\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new ServerStartError(\"Failed to start OpenCode server\", port, err);\n\t\t}\n\t}\n\n\tif (!server || !client) {\n\t\tthrow new ServerStartError(\"Failed to start OpenCode server after all attempts\");\n\t}\n\n\tconst providerID = optProvider ?? DEFAULT_AI_PROVIDER;\n\tconst modelID = optModel ?? DEFAULT_AI_MODEL;\n\n\ttry {\n\t\tdebug(\"Creating session...\");\n\t\tconst sessionResult = await client.session.create();\n\t\tif (sessionResult.error) {\n\t\t\tthrow new SessionError(\"Failed to create session\", undefined, undefined, sessionResult.error);\n\t\t}\n\t\tconst sessionId = sessionResult.data.id;\n\t\tdebug(`Session created: ${sessionId}`);\n\n\t\tdebug(\"Validating provider and model...\");\n\t\tconst providerResult = await client.provider.list();\n\t\tif (providerResult.error) {\n\t\t\tthrow new OpenCodeReferenceError(\"Failed to fetch provider list\", providerResult.error);\n\t\t}\n\n\t\tconst { all: allProviders, connected: connectedProviders } = providerResult.data;\n\t\tconst allProviderIds = allProviders.map((p) => p.id);\n\n\t\tconst provider = allProviders.find((p) => p.id === providerID);\n\t\tif (!provider) {\n\t\t\tthrow new InvalidProviderError(providerID, allProviderIds);\n\t\t}\n\n\t\tif (!connectedProviders.includes(providerID)) {\n\t\t\tthrow new ProviderNotConnectedError(providerID, connectedProviders);\n\t\t}\n\n\t\tconst availableModelIds = Object.keys(provider.models);\n\t\tif (!provider.models[modelID]) {\n\t\t\tthrow new InvalidModelError(modelID, providerID, availableModelIds);\n\t\t}\n\n\t\tdebug(`Provider \"${providerID}\" and model \"${modelID}\" validated`);\n\n\t\tdebug(\"Subscribing to events...\");\n\t\tconst { stream: eventStream } = await client.event.subscribe();\n\n\t\tconst fullPrompt = systemPrompt\n\t\t\t? `${systemPrompt}\\n\\nAnalyzing codebase at: ${cwd}\\n\\n${prompt}`\n\t\t\t: `Analyzing codebase at: ${cwd}\\n\\n${prompt}`;\n\n\t\tdebug(\"Sending prompt...\");\n\t\tconst promptPromise = client.session.prompt({\n\t\t\tpath: { id: sessionId },\n\t\t\tbody: {\n\t\t\t\tagent: \"analyze\",\n\t\t\t\tparts: [{ type: \"text\", text: fullPrompt }],\n\t\t\t\tmodel: { providerID, modelID },\n\t\t\t},\n\t\t});\n\n\t\tconst textAccumulator = new TextAccumulator();\n\t\tdebug(\"Waiting for response...\");\n\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n\t\tconst processEvents = async (): Promise<string> => {\n\t\t\tfor await (const event of eventStream) {\n\t\t\t\tif (!isEventForSession(event, sessionId)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst parsed = parseStreamEvent(event);\n\n\t\t\t\tswitch (parsed.type) {\n\t\t\t\t\tcase \"message.part.updated\": {\n\t\t\t\t\t\tif (parsed.toolPart?.state) {\n\t\t\t\t\t\t\tconst { state, tool } = parsed.toolPart;\n\t\t\t\t\t\t\tif (state.status === \"running\") {\n\t\t\t\t\t\t\t\tconst message = formatToolMessage(tool, state);\n\t\t\t\t\t\t\t\tif (message) {\n\t\t\t\t\t\t\t\t\tdebug(message);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.textPart) {\n\t\t\t\t\t\t\tconst delta = textAccumulator.accumulatePart(parsed.textPart);\n\t\t\t\t\t\t\tif (!textAccumulator.hasReceivedText) {\n\t\t\t\t\t\t\t\tdebug(\"Writing reference...\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (delta) {\n\t\t\t\t\t\t\t\tstream(delta);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"session.idle\": {\n\t\t\t\t\t\tif (parsed.props.sessionID === sessionId) {\n\t\t\t\t\t\t\tdebug(\"Response complete\");\n\t\t\t\t\t\t\treturn textAccumulator.getFullText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"session.error\": {\n\t\t\t\t\t\tif (parsed.props.sessionID === sessionId) {\n\t\t\t\t\t\t\tconst errorName = parsed.error?.name ?? \"Unknown session error\";\n\t\t\t\t\t\t\tdebug(`Session error: ${JSON.stringify(parsed.props.error)}`);\n\t\t\t\t\t\t\tthrow new SessionError(errorName, sessionId, \"error\", parsed.props.error);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"unknown\":\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn textAccumulator.getFullText();\n\t\t};\n\n\t\tlet responseText: string;\n\t\tif (timeoutMs && timeoutMs > 0) {\n\t\t\tconst timeoutPromise = new Promise<never>((_, reject) => {\n\t\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\t\treject(new TimeoutError(timeoutMs, \"session response\"));\n\t\t\t\t}, timeoutMs);\n\t\t\t});\n\t\t\tresponseText = await Promise.race([processEvents(), timeoutPromise]);\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t} else {\n\t\t\tresponseText = await processEvents();\n\t\t}\n\n\t\tawait promptPromise;\n\n\t\tif (!responseText) {\n\t\t\tthrow new OpenCodeReferenceError(\"No response received from OpenCode\");\n\t\t}\n\n\t\tdebug(`Response received (${responseText.length} chars)`);\n\n\t\tconst durationMs = Date.now() - startTime;\n\t\tdebug(`Complete in ${durationMs}ms`);\n\n\t\treturn {\n\t\t\ttext: responseText,\n\t\t\tsessionId,\n\t\t\tdurationMs,\n\t\t};\n\t} finally {\n\t\tdebug(\"Closing server...\");\n\t\tserver.close();\n\t}\n}\n","/**\n * This module provides a streamlined approach to generating reference files\n * by delegating all codebase exploration to the AI agent via OpenCode.\n */\n\nimport { streamPrompt, type StreamPromptOptions } from \"./ai/opencode.js\";\nimport { loadConfig, toReferenceName } from \"./config.js\";\nimport { getCommitSha } from \"./clone.js\";\n\nexport interface GenerateReferenceOptions {\n\t/** AI provider ID (e.g., \"anthropic\", \"openai\"). Defaults to config value. */\n\tprovider?: string;\n\t/** AI model ID. Defaults to config value. */\n\tmodel?: string;\n\t/** Debug callback for detailed logging */\n\tonDebug?: (message: string) => void;\n\t/** Stream callback for real-time AI output */\n\tonStream?: (text: string) => void;\n}\n\nexport interface GenerateReferenceResult {\n\t/** The generated reference markdown content */\n\treferenceContent: string;\n\t/** The commit SHA at the time of generation */\n\tcommitSha: string;\n}\n\nfunction createReferenceGenerationPrompt(referenceName: string): string {\n\treturn `You are an expert at analyzing open source libraries and producing reference documentation for AI coding agents.\n\n## PRIMARY GOAL\n\nGenerate a reference markdown file that helps developers USE this library effectively. This is NOT a contribution guide - it's a usage reference for developers consuming this library in their own projects.\n\n## CRITICAL RULES\n\n1. **USER PERSPECTIVE ONLY**: Write for developers who will npm/pip/cargo install this library and use it in THEIR code.\n - DO NOT include: how to contribute, internal test commands, repo-specific policies\n - DO NOT include: \"never mock in tests\" or similar internal dev guidelines\n - DO NOT include: commands like \"npx hereby\", \"just ready\", \"bun test\" that run the library's own tests\n - DO include: how to install, import, configure, and use the public API\n\n2. **NO FRONTMATTER**: Output pure markdown with NO YAML frontmatter. Start directly with the library name heading.\n\n3. **QUICK REFERENCES**: Include a \"Quick References\" section with paths to key entry points in the repo:\n - Paths must be relative from repo root (e.g., \\`src/index.ts\\`, \\`docs/api.md\\`)\n - Include: main entry point, type definitions, README, key docs\n - DO NOT include absolute paths or user-specific paths\n - Keep to 3-5 most important files that help users understand the library\n\n4. **PUBLIC API FOCUS**: Document what users import and call, not internal implementation details.\n - Entry points: what to import from the package\n - Configuration: how to set up/initialize\n - Core methods/functions: the main API surface\n - Types: key TypeScript interfaces users need\n\n5. **MONOREPO AWARENESS**: Many libraries are monorepos with multiple packages:\n - Check for \\`packages/\\`, \\`apps/\\`, \\`crates/\\`, or \\`libs/\\` directories\n - Check root package.json for \\`workspaces\\` field\n - If monorepo: document the package structure and key packages users would install\n - Use full paths from repo root (e.g., \\`packages/core/src/index.ts\\`)\n - Identify which packages are publishable vs internal\n\n## EXPLORATION STEPS\n\nUse Read, Grep, Glob tools to explore:\n1. Root package.json / Cargo.toml - check for workspaces/monorepo config\n2. Check for \\`packages/\\`, \\`apps/\\`, \\`crates/\\` directories\n3. README.md - official usage documentation\n4. For monorepos: explore each publishable package's entry point\n5. docs/ or website/ - find documentation\n6. examples/ - real usage patterns\n7. TypeScript definitions (.d.ts) - public API surface\n\n## OUTPUT FORMAT\n\nIMPORTANT: Reference name is \"${referenceName}\" (for internal tracking only - do NOT include in output).\n\n\\`\\`\\`markdown\n# {Library Name}\n\n{2-3 sentence overview of what this library does and its key value proposition}\n\n## Quick References\n\n| File | Purpose |\n|------|---------|\n| \\`packages/{pkg}/src/index.ts\\` | Main entry point (monorepo example) |\n| \\`src/index.ts\\` | Main entry point (single-package example) |\n| \\`README.md\\` | Documentation |\n\n(For monorepos, include paths to key publishable packages)\n\n## Packages (for monorepos only)\n\n| Package | npm name | Description |\n|---------|----------|-------------|\n| \\`packages/core\\` | \\`@scope/core\\` | Core functionality |\n| \\`packages/react\\` | \\`@scope/react\\` | React bindings |\n\n(OMIT this section for single-package repos)\n\n## When to Use\n\n- {Practical scenario where a developer would reach for this library}\n- {Another real-world use case}\n- {Problem this library solves}\n\n## Installation\n\n\\`\\`\\`bash\n# Single package\nnpm install {package-name}\n\n# Monorepo (show key packages)\nnpm install @scope/core @scope/react\n\\`\\`\\`\n\n## Best Practices\n\n1. {Actionable best practice for USERS of this library}\n2. {Common mistake to avoid when using this library}\n3. {Performance or correctness tip}\n\n## Common Patterns\n\n**{Pattern Name}:**\n\\`\\`\\`{language}\n{Minimal working code example}\n\\`\\`\\`\n\n**{Another Pattern}:**\n\\`\\`\\`{language}\n{Another code example}\n\\`\\`\\`\n\n## API Quick Reference\n\n| Export | Type | Description |\n|--------|------|-------------|\n| \\`{main export}\\` | {type} | {what it does} |\n| \\`{another export}\\` | {type} | {what it does} |\n\n{Add more sections as appropriate for the library: Configuration, Types, CLI Commands (if user-facing), etc.}\n\\`\\`\\`\n\n## QUALITY CHECKLIST\n\nBefore outputting, verify:\n- [ ] NO YAML frontmatter - start directly with # heading\n- [ ] Every code example is something a USER would write, not a contributor\n- [ ] No internal test commands or contribution workflows\n- [ ] Quick References paths are relative from repo root (no absolute/user paths)\n- [ ] Best practices are for using the library, not developing it\n- [ ] If monorepo: Packages section lists publishable packages with npm names\n- [ ] If monorepo: paths include package directory (e.g., \\`packages/core/src/index.ts\\`)\n\nNow explore the codebase and generate the reference content.\n\n## OUTPUT INSTRUCTIONS\n\nAfter exploring, output your complete reference wrapped in XML tags like this:\n\n\\`\\`\\`\n<reference_output>\n(your complete markdown reference here)\n</reference_output>\n\\`\\`\\`\n\nREQUIREMENTS:\n- Start with a level-1 heading with the actual library name (e.g., \"# TanStack Query\")\n- Include sections: Quick References (table), When to Use (bullets), Installation, Best Practices, Common Patterns (with code), API Quick Reference (table)\n- Minimum 2000 characters of actual content - short or placeholder content will be rejected\n- Fill in real information from your exploration - do not use placeholder text like \"{Library Name}\"\n- No YAML frontmatter - start directly with the markdown heading\n- Output ONLY the reference inside the tags, no other text\n\nBegin exploring now.`;\n}\n\n/**\n * Extract the actual reference markdown content from AI response.\n * The response may include echoed prompt/system context before the actual reference.\n * Handles multiple edge cases:\n * - Model echoes the prompt template (skip template content)\n * - Model forgets to close the tag (extract to end of response)\n * - Multiple tag pairs (find the one with real content)\n */\nfunction extractReferenceContent(rawResponse: string, onDebug?: (message: string) => void): string {\n\tconst openTag = \"<reference_output>\";\n\tconst closeTag = \"</reference_output>\";\n\n\tonDebug?.(`[extract] Raw response length: ${rawResponse.length} chars`);\n\n\t// Find all occurrences of open and close tags\n\tconst openIndices: number[] = [];\n\tconst closeIndices: number[] = [];\n\tlet pos = 0;\n\twhile ((pos = rawResponse.indexOf(openTag, pos)) !== -1) {\n\t\topenIndices.push(pos);\n\t\tpos += openTag.length;\n\t}\n\tpos = 0;\n\twhile ((pos = rawResponse.indexOf(closeTag, pos)) !== -1) {\n\t\tcloseIndices.push(pos);\n\t\tpos += closeTag.length;\n\t}\n\n\tonDebug?.(\n\t\t`[extract] Found ${openIndices.length} open tag(s), ${closeIndices.length} close tag(s)`,\n\t);\n\n\t// Helper to clean content (strip markdown fences)\n\tconst cleanContent = (raw: string): string => {\n\t\tlet content = raw.trim();\n\t\tif (content.startsWith(\"```\")) {\n\t\t\tcontent = content.replace(/^```(?:markdown)?\\s*\\n?/, \"\");\n\t\t\tcontent = content.replace(/\\n?```\\s*$/, \"\");\n\t\t}\n\t\treturn content.trim();\n\t};\n\n\t// Helper to check if content is template placeholder\n\tconst isTemplateContent = (content: string): boolean => {\n\t\treturn (\n\t\t\tcontent.includes(\"{Library Name}\") ||\n\t\t\tcontent.includes(\"(your complete markdown reference here)\")\n\t\t);\n\t};\n\n\t// Strategy 1: Find properly paired tags, starting from the LAST open tag\n\t// (Last is more likely to be actual output, not echoed prompt)\n\tfor (let i = openIndices.length - 1; i >= 0; i--) {\n\t\tconst openIdx = openIndices[i];\n\t\tif (openIdx === undefined) continue;\n\n\t\t// Find the first close tag after this open tag\n\t\tconst closeIdx = closeIndices.find((c) => c > openIdx);\n\t\tif (closeIdx !== undefined) {\n\t\t\tconst rawContent = rawResponse.slice(openIdx + openTag.length, closeIdx);\n\t\t\tconst content = cleanContent(rawContent);\n\n\t\t\tonDebug?.(`[extract] Pair ${i}: open=${openIdx}, close=${closeIdx}, len=${content.length}`);\n\t\t\tonDebug?.(\n\t\t\t\t`[extract] Preview: \"${content.slice(0, 200)}${content.length > 200 ? \"...\" : \"\"}\"`,\n\t\t\t);\n\n\t\t\tif (isTemplateContent(content)) {\n\t\t\t\tonDebug?.(`[extract] Skipping pair ${i} - template placeholder content`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (content.length >= 500) {\n\t\t\t\tonDebug?.(`[extract] Using pair ${i} - valid content`);\n\t\t\t\tvalidateReferenceContent(content);\n\t\t\t\treturn content;\n\t\t\t}\n\t\t\tonDebug?.(`[extract] Pair ${i} too short (${content.length} chars)`);\n\t\t}\n\t}\n\n\t// Strategy 2: Handle unclosed tag - model output <reference_output> but never closed it\n\t// Find the last open tag that has no close tag after it\n\tconst lastOpenIdx = openIndices[openIndices.length - 1];\n\tif (lastOpenIdx !== undefined) {\n\t\tconst hasCloseAfter = closeIndices.some((c) => c > lastOpenIdx);\n\t\tif (!hasCloseAfter) {\n\t\t\tonDebug?.(`[extract] Last open tag at ${lastOpenIdx} is unclosed - extracting to end`);\n\t\t\tconst rawContent = rawResponse.slice(lastOpenIdx + openTag.length);\n\t\t\tconst content = cleanContent(rawContent);\n\n\t\t\tonDebug?.(`[extract] Unclosed content: ${content.length} chars`);\n\t\t\tonDebug?.(\n\t\t\t\t`[extract] Preview: \"${content.slice(0, 200)}${content.length > 200 ? \"...\" : \"\"}\"`,\n\t\t\t);\n\n\t\t\tif (!isTemplateContent(content) && content.length >= 500) {\n\t\t\t\tonDebug?.(`[extract] Using unclosed content - valid`);\n\t\t\t\tvalidateReferenceContent(content);\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}\n\t}\n\n\tonDebug?.(`[extract] No valid content found`);\n\tonDebug?.(`[extract] Response tail: \"${rawResponse.slice(-300)}\"`);\n\n\tthrow new Error(\n\t\t\"Failed to extract reference content: no valid <reference_output> tags found. \" +\n\t\t\t\"The AI may have failed to follow the output format or produced placeholder content.\",\n\t);\n}\n\n/**\n * Validate extracted reference content has minimum required structure.\n * Throws if content is invalid.\n */\nfunction validateReferenceContent(content: string): void {\n\t// Check for template placeholders that indicate the model just echoed the format\n\tconst templatePlaceholders = [\n\t\t\"{Library Name}\",\n\t\t\"{Full overview paragraph}\",\n\t\t\"{Table with 3-5 key files}\",\n\t\t\"{3+ bullet points}\",\n\t\t\"{Install commands}\",\n\t\t\"{3+ numbered items}\",\n\t\t\"{2+ code examples\",\n\t\t\"{Table of key exports}\",\n\t\t\"{Additional sections\",\n\t];\n\n\tconst foundPlaceholders = templatePlaceholders.filter((p) => content.includes(p));\n\tif (foundPlaceholders.length > 0) {\n\t\tthrow new Error(\n\t\t\t`Invalid reference content: contains template placeholders (${foundPlaceholders.slice(0, 3).join(\", \")}). ` +\n\t\t\t\t\"The AI echoed the format instead of generating actual content.\",\n\t\t);\n\t}\n\n\tif (content.length < 500) {\n\t\tthrow new Error(\n\t\t\t`Invalid reference content: too short (${content.length} chars, minimum 500). ` +\n\t\t\t\t\"The AI may have produced placeholder or incomplete content.\",\n\t\t);\n\t}\n\n\tif (!content.startsWith(\"#\")) {\n\t\tthrow new Error(\n\t\t\t\"Invalid reference content: must start with markdown heading. \" +\n\t\t\t\t\"Content must begin with '# Library Name' (no YAML frontmatter).\",\n\t\t);\n\t}\n}\n\n/**\n * Generate a reference markdown file for a repository using AI.\n *\n * Opens an OpenCode session and instructs the AI agent to explore the codebase\n * using Read, Grep, and Glob tools, then produce a comprehensive reference.\n *\n * @param repoPath - Path to the repository to analyze\n * @param repoName - Qualified name of the repo (e.g., \"tanstack/query\" or \"my-local-repo\")\n * @param options - Generation options (provider, model, callbacks)\n * @returns The generated reference content and commit SHA\n */\nexport async function generateReferenceWithAI(\n\trepoPath: string,\n\trepoName: string,\n\toptions: GenerateReferenceOptions = {},\n): Promise<GenerateReferenceResult> {\n\tconst { provider, model, onDebug, onStream } = options;\n\tconst config = loadConfig();\n\n\tconst [configProvider, configModel] = config.defaultModel?.split(\"/\") ?? [];\n\tconst aiProvider = provider ?? configProvider;\n\tconst aiModel = model ?? configModel;\n\n\tonDebug?.(`Starting AI reference generation for ${repoName}`);\n\tonDebug?.(`Repo path: ${repoPath}`);\n\tonDebug?.(`Provider: ${aiProvider ?? \"default\"}, Model: ${aiModel ?? \"default\"}`);\n\n\tconst commitSha = getCommitSha(repoPath);\n\tonDebug?.(`Commit SHA: ${commitSha}`);\n\n\tconst referenceName = toReferenceName(repoName);\n\tonDebug?.(`Reference name: ${referenceName}`);\n\n\tconst promptOptions: StreamPromptOptions = {\n\t\tprompt: createReferenceGenerationPrompt(referenceName),\n\t\tcwd: repoPath,\n\t\tprovider: aiProvider,\n\t\tmodel: aiModel,\n\t\tonDebug,\n\t\tonStream,\n\t};\n\n\tconst result = await streamPrompt(promptOptions);\n\n\tonDebug?.(`Generation complete (${result.durationMs}ms, ${result.text.length} chars)`);\n\n\tconst referenceContent = extractReferenceContent(result.text, onDebug);\n\tonDebug?.(`Extracted reference content (${referenceContent.length} chars)`);\n\n\treturn {\n\t\treferenceContent,\n\t\tcommitSha,\n\t};\n}\n"],"mappings":";;;;;;;;AAGA,IAAa,yBAAb,cAA4C,MAAM;CACjD,AAAS,OAAe;CACxB,YACC,SACA,AAAgB,SACf;AACD,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;;;;;;AAOd,IAAa,mBAAb,cAAsC,uBAAuB;CAC5D,AAAS,OAAO;CAChB,YAAY,SAAkB;AAC7B,QACC,WAAW,+EACX;AACD,OA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CAE8C,QAAQ,MAAM,QAAQ,SAAS,EAAE,CAAC;AACjF,KAAI,kBAAkB,SAAS,EAC9B,OAAM,IAAI,MACT,8DAA8D,kBAAkB,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC,mEAEvG;AAGF,KAAI,QAAQ,SAAS,IACpB,OAAM,IAAI,MACT,yCAAyC,QAAQ,OAAO,mFAExD;AAGF,KAAI,CAAC,QAAQ,WAAW,IAAI,CAC3B,OAAM,IAAI,MACT,+HAEA;;;;;;;;;;;;;AAeH,eAAsB,wBACrB,UACA,UACA,UAAoC,EAAE,EACH;CACnC,MAAM,EAAE,UAAU,OAAO,SAAS,aAAa;CAG/C,MAAM,CAAC,gBAAgB,eAFR,YAAY,CAEkB,cAAc,MAAM,IAAI,IAAI,EAAE;CAC3E,MAAM,aAAa,YAAY;CAC/B,MAAM,UAAU,SAAS;AAEzB,WAAU,wCAAwC,WAAW;AAC7D,WAAU,cAAc,WAAW;AACnC,WAAU,aAAa,cAAc,UAAU,WAAW,WAAW,YAAY;CAEjF,MAAM,YAAY,aAAa,SAAS;AACxC,WAAU,eAAe,YAAY;CAErC,MAAM,gBAAgB,gBAAgB,SAAS;AAC/C,WAAU,mBAAmB,gBAAgB;CAW7C,MAAM,SAAS,MAAM,aATsB;EAC1C,QAAQ,gCAAgC,cAAc;EACtD,KAAK;EACL,UAAU;EACV,OAAO;EACP;EACA;EACA,CAE+C;AAEhD,WAAU,wBAAwB,OAAO,WAAW,MAAM,OAAO,KAAK,OAAO,SAAS;CAEtF,MAAM,mBAAmB,wBAAwB,OAAO,MAAM,QAAQ;AACtE,WAAU,gCAAgC,iBAAiB,OAAO,SAAS;AAE3E,QAAO;EACN;EACA;EACA"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/ai/errors.ts","../../src/ai/stream/types.ts","../../src/ai/stream/accumulator.ts","../../src/ai/stream/transformer.ts","../../src/ai/opencode.ts","../../src/generate.ts"],"sourcesContent":["/**\n * Base class for OpenCode reference errors\n */\nexport class OpenCodeReferenceError extends Error {\n\treadonly _tag: string = \"OpenCodeReferenceError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"OpenCodeReferenceError\";\n\t}\n}\n\n/**\n * Error when the opencode CLI binary is not installed\n */\nexport class OpenCodeNotInstalledError extends OpenCodeReferenceError {\n\treadonly _tag = \"OpenCodeNotInstalledError\" as const;\n\treadonly hint: string;\n\n\tconstructor() {\n\t\tconst hint =\n\t\t\t\"opencode is required for local AI reference generation. Install it: curl -fsSL https://opencode.ai/install | bash\";\n\t\tsuper(`opencode is not installed. ${hint}`);\n\t\tthis.name = \"OpenCodeNotInstalledError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the @opencode-ai/sdk package is not installed or invalid\n */\nexport class OpenCodeSDKError extends OpenCodeReferenceError {\n\treadonly _tag = \"OpenCodeSDKError\" as const;\n\tconstructor(message?: string) {\n\t\tsuper(\n\t\t\tmessage ?? \"Failed to import @opencode-ai/sdk. Install it with: bun add @opencode-ai/sdk\",\n\t\t);\n\t\tthis.name = \"OpenCodeSDKError\";\n\t}\n}\n\n/**\n * Error when the requested provider is not found\n */\nexport class InvalidProviderError extends OpenCodeReferenceError {\n\treadonly _tag = \"InvalidProviderError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly availableProviders: string[],\n\t) {\n\t\tconst hint =\n\t\t\tavailableProviders.length > 0\n\t\t\t\t? `Available providers: ${availableProviders.join(\", \")}`\n\t\t\t\t: \"No providers available. Check your OpenCode configuration.\";\n\t\tsuper(`Provider \"${providerID}\" not found. ${hint}`);\n\t\tthis.name = \"InvalidProviderError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the provider exists but is not connected/authenticated\n */\nexport class ProviderNotConnectedError extends OpenCodeReferenceError {\n\treadonly _tag = \"ProviderNotConnectedError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly connectedProviders: string[],\n\t) {\n\t\tconst hint =\n\t\t\tconnectedProviders.length > 0\n\t\t\t\t? `Connected providers: ${connectedProviders.join(\", \")}. Run 'opencode auth ${providerID}' to connect.`\n\t\t\t\t: `No providers connected. Run 'opencode auth ${providerID}' to authenticate.`;\n\t\tsuper(`Provider \"${providerID}\" is not connected. ${hint}`);\n\t\tthis.name = \"ProviderNotConnectedError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the requested model is not found for a provider\n */\nexport class InvalidModelError extends OpenCodeReferenceError {\n\treadonly _tag = \"InvalidModelError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly modelID: string,\n\t\tpublic readonly providerID: string,\n\t\tpublic readonly availableModels: string[],\n\t) {\n\t\tconst hint =\n\t\t\tavailableModels.length > 0\n\t\t\t\t? `Available models for ${providerID}: ${availableModels.slice(0, 10).join(\", \")}${availableModels.length > 10 ? ` (and ${availableModels.length - 10} more)` : \"\"}`\n\t\t\t\t: `No models available for provider \"${providerID}\".`;\n\t\tsuper(`Model \"${modelID}\" not found for provider \"${providerID}\". ${hint}`);\n\t\tthis.name = \"InvalidModelError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when the OpenCode server fails to start\n */\nexport class ServerStartError extends OpenCodeReferenceError {\n\treadonly _tag = \"ServerStartError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly port?: number,\n\t\tdetails?: unknown,\n\t) {\n\t\tconst hint = port\n\t\t\t? `Failed to start server on port ${port}. Ensure no other process is using this port.`\n\t\t\t: \"Failed to start OpenCode server. Check your OpenCode installation and configuration.\";\n\t\tsuper(`${message}. ${hint}`, details);\n\t\tthis.name = \"ServerStartError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when a session operation fails\n */\nexport class SessionError extends OpenCodeReferenceError {\n\treadonly _tag = \"SessionError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly sessionId?: string,\n\t\tpublic readonly sessionState?: string,\n\t\tdetails?: unknown,\n\t) {\n\t\tconst context = sessionId ? ` (session: ${sessionId})` : \"\";\n\t\tconst stateInfo = sessionState ? ` State: ${sessionState}.` : \"\";\n\t\tconst hint = `Session operation failed${context}.${stateInfo} Try creating a new session.`;\n\t\tsuper(`${message}. ${hint}`, details);\n\t\tthis.name = \"SessionError\";\n\t\tthis.hint = hint;\n\t}\n}\n\n/**\n * Error when a request times out\n */\nexport class TimeoutError extends OpenCodeReferenceError {\n\treadonly _tag = \"TimeoutError\" as const;\n\treadonly hint: string;\n\n\tconstructor(\n\t\tpublic readonly timeoutMs: number,\n\t\tpublic readonly operation: string = \"operation\",\n\t) {\n\t\tconst hint = `The ${operation} did not complete within ${timeoutMs}ms. Consider increasing the timeout or checking if the model is responding.`;\n\t\tsuper(`Timeout: ${operation} did not complete within ${timeoutMs}ms. ${hint}`);\n\t\tthis.name = \"TimeoutError\";\n\t\tthis.hint = hint;\n\t}\n}\n","/**\n * Zod schemas for OpenCode stream events\n * Replaces inline `as` casts with runtime-validated types\n */\n\nimport { z } from \"zod\";\n\nconst PartBaseSchema = z.object({\n\tid: z.string().optional(),\n\tsessionID: z.string().optional(),\n\tmessageID: z.string().optional(),\n});\n\nexport const TextPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"text\"),\n\ttext: z.string().optional(),\n});\n\nexport const ToolStatePendingSchema = z.object({\n\tstatus: z.literal(\"pending\"),\n});\n\nexport const ToolStateRunningSchema = z.object({\n\tstatus: z.literal(\"running\"),\n\ttitle: z.string().optional(),\n\tinput: z.unknown().optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateCompletedSchema = z.object({\n\tstatus: z.literal(\"completed\"),\n\ttitle: z.string().optional(),\n\tinput: z.record(z.string(), z.unknown()).optional(),\n\toutput: z.string().optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t\tend: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateErrorSchema = z.object({\n\tstatus: z.literal(\"error\"),\n\terror: z.string().optional(),\n\tinput: z.record(z.string(), z.unknown()).optional(),\n\ttime: z\n\t\t.object({\n\t\t\tstart: z.number(),\n\t\t\tend: z.number(),\n\t\t})\n\t\t.optional(),\n});\n\nexport const ToolStateSchema = z.discriminatedUnion(\"status\", [\n\tToolStatePendingSchema,\n\tToolStateRunningSchema,\n\tToolStateCompletedSchema,\n\tToolStateErrorSchema,\n]);\n\nexport const ToolPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool\"),\n\tcallID: z.string().optional(),\n\ttool: z.string().optional(),\n\tstate: ToolStateSchema.optional(),\n});\n\nexport const StepStartPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"step-start\"),\n});\n\nexport const StepFinishPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"step-finish\"),\n\treason: z.string().optional(),\n});\n\nexport const ToolUsePartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool-use\"),\n\ttoolUseId: z.string().optional(),\n\tname: z.string().optional(),\n});\n\nexport const ToolResultPartSchema = PartBaseSchema.extend({\n\ttype: z.literal(\"tool-result\"),\n\ttoolUseId: z.string().optional(),\n});\n\nexport const MessagePartSchema = z.discriminatedUnion(\"type\", [\n\tTextPartSchema,\n\tToolPartSchema,\n\tStepStartPartSchema,\n\tStepFinishPartSchema,\n\tToolUsePartSchema,\n\tToolResultPartSchema,\n]);\n\n/**\n * Session error payload\n */\nexport const SessionErrorSchema = z.object({\n\tname: z.string().optional(),\n\tmessage: z.string().optional(),\n\tcode: z.string().optional(),\n});\n\nexport const MessagePartUpdatedPropsSchema = z.object({\n\tpart: MessagePartSchema,\n});\n\n/**\n * Properties for session.idle event\n */\nexport const SessionIdlePropsSchema = z.object({\n\tsessionID: z.string(),\n});\n\n/**\n * Properties for session.error event\n */\nexport const SessionErrorPropsSchema = z.object({\n\tsessionID: z.string(),\n\terror: SessionErrorSchema.optional(),\n});\n\n/**\n * Properties for session.updated event\n */\nexport const SessionUpdatedPropsSchema = z.object({\n\tsessionID: z.string(),\n\tstatus: z.string().optional(),\n});\n\n/**\n * message.part.updated event\n */\nexport const MessagePartUpdatedEventSchema = z.object({\n\ttype: z.literal(\"message.part.updated\"),\n\tproperties: MessagePartUpdatedPropsSchema,\n});\n\n/**\n * session.idle event\n */\nexport const SessionIdleEventSchema = z.object({\n\ttype: z.literal(\"session.idle\"),\n\tproperties: SessionIdlePropsSchema,\n});\n\n/**\n * session.error event\n */\nexport const SessionErrorEventSchema = z.object({\n\ttype: z.literal(\"session.error\"),\n\tproperties: SessionErrorPropsSchema,\n});\n\n/**\n * session.updated event\n */\nexport const SessionUpdatedEventSchema = z.object({\n\ttype: z.literal(\"session.updated\"),\n\tproperties: SessionUpdatedPropsSchema,\n});\n\n/**\n * Generic event for unknown types (passthrough)\n */\nexport const GenericEventSchema = z.object({\n\ttype: z.string(),\n\tproperties: z.record(z.string(), z.unknown()),\n});\n\nexport type TextPart = z.infer<typeof TextPartSchema>;\nexport type ToolPart = z.infer<typeof ToolPartSchema>;\nexport type ToolState = z.infer<typeof ToolStateSchema>;\nexport type ToolStateRunning = z.infer<typeof ToolStateRunningSchema>;\nexport type ToolUsePart = z.infer<typeof ToolUsePartSchema>;\nexport type ToolResultPart = z.infer<typeof ToolResultPartSchema>;\nexport type MessagePart = z.infer<typeof MessagePartSchema>;\n\nexport type SessionErrorPayload = z.infer<typeof SessionErrorSchema>;\n\nexport type MessagePartUpdatedProps = z.infer<typeof MessagePartUpdatedPropsSchema>;\nexport type SessionIdleProps = z.infer<typeof SessionIdlePropsSchema>;\nexport type SessionErrorProps = z.infer<typeof SessionErrorPropsSchema>;\nexport type SessionUpdatedProps = z.infer<typeof SessionUpdatedPropsSchema>;\n\nexport type MessagePartUpdatedEvent = z.infer<typeof MessagePartUpdatedEventSchema>;\nexport type SessionIdleEvent = z.infer<typeof SessionIdleEventSchema>;\nexport type SessionErrorEvent = z.infer<typeof SessionErrorEventSchema>;\nexport type SessionUpdatedEvent = z.infer<typeof SessionUpdatedEventSchema>;\nexport type GenericEvent = z.infer<typeof GenericEventSchema>;\n\n/**\n * All known stream event types\n */\nexport type StreamEvent =\n\t| MessagePartUpdatedEvent\n\t| SessionIdleEvent\n\t| SessionErrorEvent\n\t| SessionUpdatedEvent\n\t| GenericEvent;\n","/**\n * Text accumulator for stream events\n * Manages accumulation of text parts by ID and provides delta extraction\n */\n\nimport type { TextPart } from \"./types.js\";\n\n/**\n * Accumulates text from streaming message parts.\n * Tracks multiple parts by ID and provides delta text between updates.\n */\nexport class TextAccumulator {\n\tprivate readonly parts = new Map<string, string>();\n\tprivate _firstTextReceived = false;\n\n\t/**\n\t * Whether any text has been received\n\t */\n\tget hasReceivedText(): boolean {\n\t\treturn this._firstTextReceived;\n\t}\n\n\t/**\n\t * Accumulate text from a message part and return the delta (new text only).\n\t * Returns null if the part should be skipped (non-text, no ID, no text).\n\t */\n\taccumulatePart(part: TextPart): string | null {\n\t\tif (part.type !== \"text\" || !part.text || !part.id) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst partId = part.id;\n\t\tconst prevText = this.parts.get(partId) ?? \"\";\n\t\tthis.parts.set(partId, part.text);\n\n\t\tif (!this._firstTextReceived) {\n\t\t\tthis._firstTextReceived = true;\n\t\t}\n\n\t\tif (part.text.length > prevText.length) {\n\t\t\treturn part.text.slice(prevText.length);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get the full accumulated text from all parts\n\t */\n\tgetFullText(): string {\n\t\treturn Array.from(this.parts.values()).join(\"\");\n\t}\n\n\t/**\n\t * Get the number of distinct parts accumulated\n\t */\n\tgetPartCount(): number {\n\t\treturn this.parts.size;\n\t}\n\n\t/**\n\t * Get info about each part for debugging\n\t */\n\tgetPartInfo(): Array<{ id: string; length: number }> {\n\t\treturn Array.from(this.parts.entries()).map(([id, text]) => ({\n\t\t\tid,\n\t\t\tlength: text.length,\n\t\t}));\n\t}\n\n\t/**\n\t * Clear accumulated text\n\t */\n\tclear(): void {\n\t\tthis.parts.clear();\n\t\tthis._firstTextReceived = false;\n\t}\n}\n","/**\n * Stream event transformer and parser\n * Safely parses and validates stream events using Zod schemas\n */\n\nimport {\n\tMessagePartUpdatedPropsSchema,\n\tSessionIdlePropsSchema,\n\tSessionErrorPropsSchema,\n\tSessionErrorSchema,\n\ttype TextPart,\n\ttype ToolPart,\n\ttype SessionErrorPayload,\n\ttype MessagePartUpdatedProps,\n\ttype SessionIdleProps,\n\ttype SessionErrorProps,\n} from \"./types.js\";\n\n/**\n * Raw event from the OpenCode SDK stream\n */\nexport interface RawStreamEvent {\n\ttype: string;\n\tproperties: Record<string, unknown>;\n}\n\n/**\n * Result of parsing a stream event\n */\nexport type ParsedEventResult =\n\t| {\n\t\t\ttype: \"message.part.updated\";\n\t\t\tprops: MessagePartUpdatedProps;\n\t\t\ttextPart: TextPart | null;\n\t\t\ttoolPart: ToolPart | null;\n\t }\n\t| { type: \"session.idle\"; props: SessionIdleProps }\n\t| { type: \"session.error\"; props: SessionErrorProps; error: SessionErrorPayload | null }\n\t| { type: \"unknown\"; rawType: string };\n\n/**\n * Parse a raw stream event into a typed result.\n * Uses safe parsing - returns type: \"unknown\" for unrecognized or invalid events.\n */\nexport function parseStreamEvent(event: RawStreamEvent): ParsedEventResult {\n\tswitch (event.type) {\n\t\tcase \"message.part.updated\": {\n\t\t\tconst propsResult = MessagePartUpdatedPropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\tconst props = propsResult.data;\n\t\t\tconst textPart = props.part.type === \"text\" ? props.part : null;\n\t\t\tconst toolPart = props.part.type === \"tool\" ? props.part : null;\n\t\t\treturn { type: \"message.part.updated\", props, textPart, toolPart };\n\t\t}\n\n\t\tcase \"session.idle\": {\n\t\t\tconst propsResult = SessionIdlePropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\treturn { type: \"session.idle\", props: propsResult.data };\n\t\t}\n\n\t\tcase \"session.error\": {\n\t\t\tconst propsResult = SessionErrorPropsSchema.safeParse(event.properties);\n\t\t\tif (!propsResult.success) {\n\t\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t\t\t}\n\t\t\tconst props = propsResult.data;\n\n\t\t\tlet error: SessionErrorPayload | null = null;\n\t\t\tif (props.error) {\n\t\t\t\tconst errorResult = SessionErrorSchema.safeParse(props.error);\n\t\t\t\tif (errorResult.success) {\n\t\t\t\t\terror = errorResult.data;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { type: \"session.error\", props, error };\n\t\t}\n\n\t\tdefault:\n\t\t\treturn { type: \"unknown\", rawType: event.type };\n\t}\n}\n\nexport function isEventForSession(event: RawStreamEvent, sessionId: string): boolean {\n\tconst props = event.properties;\n\tif (\"sessionID\" in props && typeof props.sessionID === \"string\") {\n\t\treturn props.sessionID === sessionId;\n\t}\n\tif (\n\t\t\"part\" in props &&\n\t\ttypeof props.part === \"object\" &&\n\t\tprops.part !== null &&\n\t\t\"sessionID\" in props.part &&\n\t\ttypeof props.part.sessionID === \"string\"\n\t) {\n\t\treturn props.part.sessionID === sessionId;\n\t}\n\treturn true;\n}\n","import { execSync } from \"node:child_process\";\nimport {\n\tOpenCodeReferenceError,\n\tOpenCodeSDKError,\n\tOpenCodeNotInstalledError,\n\tInvalidProviderError,\n\tProviderNotConnectedError,\n\tInvalidModelError,\n\tServerStartError,\n\tSessionError,\n\tTimeoutError,\n} from \"./errors.js\";\nimport { TextAccumulator, parseStreamEvent, isEventForSession } from \"./stream/index.js\";\n\nexport const DEFAULT_AI_PROVIDER = \"opencode\";\nexport const DEFAULT_AI_MODEL = \"claude-opus-4-5\";\n\nexport interface StreamPromptOptions {\n\tprompt: string;\n\tcwd: string;\n\tsystemPrompt?: string;\n\tprovider?: string;\n\n\tmodel?: string;\n\t/** Timeout in milliseconds. Set to 0 or undefined for no timeout. */\n\ttimeoutMs?: number;\n\tonDebug?: (message: string) => void;\n\tonStream?: (text: string) => void;\n}\n\nexport interface StreamPromptResult {\n\ttext: string;\n\tsessionId: string;\n\tdurationMs: number;\n}\n\ninterface OpenCodeServer {\n\tclose: () => void;\n\turl: string;\n}\n\ninterface OpenCodeSession {\n\tid: string;\n}\n\ninterface OpenCodeEvent {\n\ttype: string;\n\tproperties: Record<string, unknown>;\n}\n\ninterface OpenCodeProviderModel {\n\tid: string;\n\tname: string;\n}\n\ninterface OpenCodeProvider {\n\tid: string;\n\tname: string;\n\tmodels: Record<string, OpenCodeProviderModel>;\n}\n\ninterface OpenCodeProviderListResponse {\n\tall: OpenCodeProvider[];\n\tconnected: string[];\n\tdefault: Record<string, string>;\n}\n\ninterface OpenCodeClient {\n\tsession: {\n\t\tcreate: () => Promise<{ data: OpenCodeSession; error?: unknown }>;\n\t\tprompt: (options: {\n\t\t\tpath: { id: string };\n\t\t\tbody: {\n\t\t\t\tagent?: string;\n\t\t\t\tparts: Array<{ type: string; text: string }>;\n\t\t\t\tmodel?: { providerID: string; modelID: string };\n\t\t\t};\n\t\t}) => Promise<{ data: unknown; error?: unknown }>;\n\t};\n\tevent: {\n\t\tsubscribe: () => Promise<{\n\t\t\tstream: AsyncIterable<OpenCodeEvent>;\n\t\t}>;\n\t};\n\tprovider: {\n\t\tlist: () => Promise<{ data: OpenCodeProviderListResponse; error?: unknown }>;\n\t};\n}\n\ninterface AgentConfig {\n\tdisable?: boolean;\n\tprompt?: string;\n\tdescription?: string;\n\tmode?: string;\n\tpermission?: Record<string, string>;\n\ttools?: Record<string, boolean>;\n}\n\ninterface OpenCodeConfig {\n\tplugin?: unknown[];\n\tmcp?: Record<string, unknown>;\n\tinstructions?: unknown[];\n\tagent?: Record<string, AgentConfig>;\n}\n\ntype CreateOpencodeResult = { server: OpenCodeServer };\ntype CreateOpencodeClientFn = (opts: { baseUrl: string; directory: string }) => OpenCodeClient;\ntype CreateOpencodeFn = (opts: {\n\tport: number;\n\tcwd?: string;\n\tconfig?: OpenCodeConfig;\n}) => Promise<CreateOpencodeResult>;\n\nlet cachedCreateOpencode: CreateOpencodeFn | null = null;\nlet cachedCreateOpencodeClient: CreateOpencodeClientFn | null = null;\n\nfunction assertOpenCodeInstalled(): void {\n\ttry {\n\t\texecSync(\"opencode --version\", { stdio: \"ignore\" });\n\t} catch {\n\t\tthrow new OpenCodeNotInstalledError();\n\t}\n}\n\nasync function getOpenCodeSDK(): Promise<{\n\tcreateOpencode: CreateOpencodeFn;\n\tcreateOpencodeClient: CreateOpencodeClientFn;\n}> {\n\tif (cachedCreateOpencode && cachedCreateOpencodeClient) {\n\t\treturn {\n\t\t\tcreateOpencode: cachedCreateOpencode,\n\t\t\tcreateOpencodeClient: cachedCreateOpencodeClient,\n\t\t};\n\t}\n\n\tassertOpenCodeInstalled();\n\n\ttry {\n\t\tconst sdk = await import(\"@opencode-ai/sdk\");\n\t\tif (\n\t\t\ttypeof sdk.createOpencode !== \"function\" ||\n\t\t\ttypeof sdk.createOpencodeClient !== \"function\"\n\t\t) {\n\t\t\tthrow new OpenCodeSDKError(\"SDK missing required exports\");\n\t\t}\n\t\tcachedCreateOpencode = sdk.createOpencode as CreateOpencodeFn;\n\t\tcachedCreateOpencodeClient = sdk.createOpencodeClient as CreateOpencodeClientFn;\n\t\treturn {\n\t\t\tcreateOpencode: cachedCreateOpencode,\n\t\t\tcreateOpencodeClient: cachedCreateOpencodeClient,\n\t\t};\n\t} catch (error) {\n\t\tif (error instanceof OpenCodeSDKError) {\n\t\t\tthrow error;\n\t\t}\n\t\tthrow new OpenCodeSDKError();\n\t}\n}\n\ninterface ToolRunningState {\n\tstatus: \"running\";\n\ttitle?: string;\n\tinput?: unknown;\n}\n\nfunction formatToolMessage(tool: string | undefined, state: ToolRunningState): string | null {\n\tif (state.title) {\n\t\treturn state.title;\n\t}\n\n\tif (!tool) {\n\t\treturn null;\n\t}\n\n\tconst input =\n\t\tstate.input && typeof state.input === \"object\" && !Array.isArray(state.input)\n\t\t\t? (state.input as Record<string, unknown>)\n\t\t\t: undefined;\n\tif (!input) {\n\t\treturn `Running ${tool}...`;\n\t}\n\n\tswitch (tool) {\n\t\tcase \"read\": {\n\t\t\tconst path = input.filePath ?? input.path;\n\t\t\tif (typeof path === \"string\") {\n\t\t\t\tconst filename = path.split(\"/\").pop();\n\t\t\t\treturn `Reading ${filename}...`;\n\t\t\t}\n\t\t\treturn \"Reading file...\";\n\t\t}\n\t\tcase \"glob\": {\n\t\t\tconst pattern = input.pattern;\n\t\t\tif (typeof pattern === \"string\") {\n\t\t\t\treturn `Globbing ${pattern}...`;\n\t\t\t}\n\t\t\treturn \"Searching files...\";\n\t\t}\n\t\tcase \"grep\": {\n\t\t\tconst pattern = input.pattern;\n\t\t\tif (typeof pattern === \"string\") {\n\t\t\t\tconst truncated = pattern.length > 30 ? `${pattern.slice(0, 30)}...` : pattern;\n\t\t\t\treturn `Searching for \"${truncated}\"...`;\n\t\t\t}\n\t\t\treturn \"Searching content...\";\n\t\t}\n\t\tcase \"list\": {\n\t\t\tconst path = input.path;\n\t\t\tif (typeof path === \"string\") {\n\t\t\t\treturn `Listing ${path}...`;\n\t\t\t}\n\t\t\treturn \"Listing directory...\";\n\t\t}\n\t\tdefault:\n\t\t\treturn `Running ${tool}...`;\n\t}\n}\n\nexport async function streamPrompt(options: StreamPromptOptions): Promise<StreamPromptResult> {\n\tconst {\n\t\tprompt,\n\t\tcwd,\n\t\tsystemPrompt,\n\t\tprovider: optProvider,\n\t\tmodel: optModel,\n\t\ttimeoutMs,\n\t\tonDebug,\n\t\tonStream,\n\t} = options;\n\n\tconst debug = onDebug ?? (() => {});\n\tconst stream = onStream ?? (() => {});\n\tconst startTime = Date.now();\n\n\tdebug(\"Loading OpenCode SDK...\");\n\tconst { createOpencode, createOpencodeClient } = await getOpenCodeSDK();\n\n\tconst maxAttempts = 10;\n\tlet server: OpenCodeServer | null = null;\n\tlet client: OpenCodeClient | null = null;\n\tlet port = 0;\n\n\tconst config: OpenCodeConfig = {\n\t\tplugin: [],\n\t\tmcp: {},\n\t\tinstructions: [],\n\t\tagent: {\n\t\t\tbuild: { disable: true },\n\t\t\tgeneral: { disable: true },\n\t\t\tplan: { disable: true },\n\t\t\texplore: { disable: true },\n\t\t\tanalyze: {\n\t\t\t\tprompt: [\n\t\t\t\t\t\"You are an expert at analyzing open source codebases and producing documentation.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Your job is to read the codebase and produce structured output based on the user's request.\",\n\t\t\t\t\t\"Use glob to discover files, grep to search for patterns, and read to examine file contents.\",\n\t\t\t\t\t\"\",\n\t\t\t\t\t\"Guidelines:\",\n\t\t\t\t\t\"- Explore the codebase thoroughly before producing output\",\n\t\t\t\t\t\"- Focus on understanding architecture, key abstractions, and usage patterns\",\n\t\t\t\t\t\"- When asked for JSON output, respond with ONLY valid JSON - no markdown, no code blocks\",\n\t\t\t\t\t\"- When asked for prose, write clear and concise documentation\",\n\t\t\t\t\t\"- Always base your analysis on actual code you've read, never speculate\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\tmode: \"primary\",\n\t\t\t\tdescription: \"Analyze open source codebases and produce summaries and reference files\",\n\t\t\t\ttools: {\n\t\t\t\t\tread: true,\n\t\t\t\t\tgrep: true,\n\t\t\t\t\tglob: true,\n\t\t\t\t\tlist: true,\n\t\t\t\t\twrite: false,\n\t\t\t\t\tbash: false,\n\t\t\t\t\tdelete: false,\n\t\t\t\t\tedit: false,\n\t\t\t\t\tpatch: false,\n\t\t\t\t\tpath: false,\n\t\t\t\t\ttodowrite: false,\n\t\t\t\t\ttodoread: false,\n\t\t\t\t\twebsearch: false,\n\t\t\t\t\twebfetch: false,\n\t\t\t\t\tcodesearch: false,\n\t\t\t\t\tskill: false,\n\t\t\t\t\ttask: false,\n\t\t\t\t\tmcp: false,\n\t\t\t\t\tquestion: false,\n\t\t\t\t\tplan_enter: false,\n\t\t\t\t\tplan_exit: false,\n\t\t\t\t},\n\t\t\t\tpermission: {\n\t\t\t\t\tedit: \"deny\",\n\t\t\t\t\tbash: \"deny\",\n\t\t\t\t\twebfetch: \"deny\",\n\t\t\t\t\texternal_directory: \"deny\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t};\n\n\tdebug(\"Starting embedded OpenCode server...\");\n\n\tfor (let attempt = 0; attempt < maxAttempts; attempt++) {\n\t\tport = Math.floor(Math.random() * 3000) + 3000;\n\t\ttry {\n\t\t\tconst result = await createOpencode({ port, cwd, config });\n\t\t\tserver = result.server;\n\t\t\tclient = createOpencodeClient({\n\t\t\t\tbaseUrl: `http://localhost:${port}`,\n\t\t\t\tdirectory: cwd,\n\t\t\t});\n\t\t\tdebug(`Server started on port ${port}`);\n\t\t\tbreak;\n\t\t} catch (err) {\n\t\t\tif (err instanceof Error && err.message?.includes(\"port\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new ServerStartError(\"Failed to start OpenCode server\", port, err);\n\t\t}\n\t}\n\n\tif (!server || !client) {\n\t\tthrow new ServerStartError(\"Failed to start OpenCode server after all attempts\");\n\t}\n\n\tconst providerID = optProvider ?? DEFAULT_AI_PROVIDER;\n\tconst modelID = optModel ?? DEFAULT_AI_MODEL;\n\n\ttry {\n\t\tdebug(\"Creating session...\");\n\t\tconst sessionResult = await client.session.create();\n\t\tif (sessionResult.error) {\n\t\t\tthrow new SessionError(\"Failed to create session\", undefined, undefined, sessionResult.error);\n\t\t}\n\t\tconst sessionId = sessionResult.data.id;\n\t\tdebug(`Session created: ${sessionId}`);\n\n\t\tdebug(\"Validating provider and model...\");\n\t\tconst providerResult = await client.provider.list();\n\t\tif (providerResult.error) {\n\t\t\tthrow new OpenCodeReferenceError(\"Failed to fetch provider list\", providerResult.error);\n\t\t}\n\n\t\tconst { all: allProviders, connected: connectedProviders } = providerResult.data;\n\t\tconst allProviderIds = allProviders.map((p) => p.id);\n\n\t\tconst provider = allProviders.find((p) => p.id === providerID);\n\t\tif (!provider) {\n\t\t\tthrow new InvalidProviderError(providerID, allProviderIds);\n\t\t}\n\n\t\tif (!connectedProviders.includes(providerID)) {\n\t\t\tthrow new ProviderNotConnectedError(providerID, connectedProviders);\n\t\t}\n\n\t\tconst availableModelIds = Object.keys(provider.models);\n\t\tif (!provider.models[modelID]) {\n\t\t\tthrow new InvalidModelError(modelID, providerID, availableModelIds);\n\t\t}\n\n\t\tdebug(`Provider \"${providerID}\" and model \"${modelID}\" validated`);\n\n\t\tdebug(\"Subscribing to events...\");\n\t\tconst { stream: eventStream } = await client.event.subscribe();\n\n\t\tconst fullPrompt = systemPrompt\n\t\t\t? `${systemPrompt}\\n\\nAnalyzing codebase at: ${cwd}\\n\\n${prompt}`\n\t\t\t: `Analyzing codebase at: ${cwd}\\n\\n${prompt}`;\n\n\t\tdebug(\"Sending prompt...\");\n\t\tconst promptPromise = client.session.prompt({\n\t\t\tpath: { id: sessionId },\n\t\t\tbody: {\n\t\t\t\tagent: \"analyze\",\n\t\t\t\tparts: [{ type: \"text\", text: fullPrompt }],\n\t\t\t\tmodel: { providerID, modelID },\n\t\t\t},\n\t\t});\n\n\t\tconst textAccumulator = new TextAccumulator();\n\t\tdebug(\"Waiting for response...\");\n\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n\t\tconst processEvents = async (): Promise<string> => {\n\t\t\tfor await (const event of eventStream) {\n\t\t\t\tif (!isEventForSession(event, sessionId)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst parsed = parseStreamEvent(event);\n\n\t\t\t\tswitch (parsed.type) {\n\t\t\t\t\tcase \"message.part.updated\": {\n\t\t\t\t\t\tif (parsed.toolPart?.state) {\n\t\t\t\t\t\t\tconst { state, tool } = parsed.toolPart;\n\t\t\t\t\t\t\tif (state.status === \"running\") {\n\t\t\t\t\t\t\t\tconst message = formatToolMessage(tool, state);\n\t\t\t\t\t\t\t\tif (message) {\n\t\t\t\t\t\t\t\t\tdebug(message);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (parsed.textPart) {\n\t\t\t\t\t\t\tconst delta = textAccumulator.accumulatePart(parsed.textPart);\n\t\t\t\t\t\t\tif (!textAccumulator.hasReceivedText) {\n\t\t\t\t\t\t\t\tdebug(\"Writing reference...\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (delta) {\n\t\t\t\t\t\t\t\tstream(delta);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"session.idle\": {\n\t\t\t\t\t\tif (parsed.props.sessionID === sessionId) {\n\t\t\t\t\t\t\tdebug(\"Response complete\");\n\t\t\t\t\t\t\treturn textAccumulator.getFullText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"session.error\": {\n\t\t\t\t\t\tif (parsed.props.sessionID === sessionId) {\n\t\t\t\t\t\t\tconst errorName = parsed.error?.name ?? \"Unknown session error\";\n\t\t\t\t\t\t\tdebug(`Session error: ${JSON.stringify(parsed.props.error)}`);\n\t\t\t\t\t\t\tthrow new SessionError(errorName, sessionId, \"error\", parsed.props.error);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tcase \"unknown\":\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn textAccumulator.getFullText();\n\t\t};\n\n\t\tlet responseText: string;\n\t\tif (timeoutMs && timeoutMs > 0) {\n\t\t\tconst timeoutPromise = new Promise<never>((_, reject) => {\n\t\t\t\ttimeoutId = setTimeout(() => {\n\t\t\t\t\treject(new TimeoutError(timeoutMs, \"session response\"));\n\t\t\t\t}, timeoutMs);\n\t\t\t});\n\t\t\tresponseText = await Promise.race([processEvents(), timeoutPromise]);\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t} else {\n\t\t\tresponseText = await processEvents();\n\t\t}\n\n\t\tawait promptPromise;\n\n\t\tif (!responseText) {\n\t\t\tthrow new OpenCodeReferenceError(\"No response received from OpenCode\");\n\t\t}\n\n\t\tdebug(`Response received (${responseText.length} chars)`);\n\n\t\tconst durationMs = Date.now() - startTime;\n\t\tdebug(`Complete in ${durationMs}ms`);\n\n\t\treturn {\n\t\t\ttext: responseText,\n\t\t\tsessionId,\n\t\t\tdurationMs,\n\t\t};\n\t} finally {\n\t\tdebug(\"Closing server...\");\n\t\tserver.close();\n\t}\n}\n","/**\n * This module provides a streamlined approach to generating reference files\n * by delegating all codebase exploration to the AI agent via OpenCode.\n */\n\nimport { streamPrompt, type StreamPromptOptions } from \"./ai/opencode.js\";\nimport { loadConfig, toReferenceName } from \"./config.js\";\nimport { getCommitSha } from \"./clone.js\";\n\nexport interface GenerateReferenceOptions {\n\t/** AI provider ID (e.g., \"anthropic\", \"openai\"). Defaults to config value. */\n\tprovider?: string;\n\t/** AI model ID. Defaults to config value. */\n\tmodel?: string;\n\t/** Debug callback for detailed logging */\n\tonDebug?: (message: string) => void;\n\t/** Stream callback for real-time AI output */\n\tonStream?: (text: string) => void;\n}\n\nexport interface GenerateReferenceResult {\n\t/** The generated reference markdown content */\n\treferenceContent: string;\n\t/** The commit SHA at the time of generation */\n\tcommitSha: string;\n}\n\nfunction createReferenceGenerationPrompt(referenceName: string): string {\n\treturn `You are an expert at analyzing open source libraries and producing reference documentation for AI coding agents.\n\n## PRIMARY GOAL\n\nGenerate a reference markdown file that helps developers USE this library effectively. This is NOT a contribution guide - it's a usage reference for developers consuming this library in their own projects.\n\n## CRITICAL RULES\n\n1. **USER PERSPECTIVE ONLY**: Write for developers who will npm/pip/cargo install this library and use it in THEIR code.\n - DO NOT include: how to contribute, internal test commands, repo-specific policies\n - DO NOT include: \"never mock in tests\" or similar internal dev guidelines\n - DO NOT include: commands like \"npx hereby\", \"just ready\", \"bun test\" that run the library's own tests\n - DO include: how to install, import, configure, and use the public API\n\n2. **NO FRONTMATTER**: Output pure markdown with NO YAML frontmatter. Start directly with the library name heading.\n\n3. **QUICK REFERENCES**: Include a \"Quick References\" section with paths to key entry points in the repo:\n - Paths must be relative from repo root (e.g., \\`src/index.ts\\`, \\`docs/api.md\\`)\n - Include: main entry point, type definitions, README, key docs\n - DO NOT include absolute paths or user-specific paths\n - Keep to 3-5 most important files that help users understand the library\n\n4. **PUBLIC API FOCUS**: Document what users import and call, not internal implementation details.\n - Entry points: what to import from the package\n - Configuration: how to set up/initialize\n - Core methods/functions: the main API surface\n - Types: key TypeScript interfaces users need\n\n5. **MONOREPO AWARENESS**: Many libraries are monorepos with multiple packages:\n - Check for \\`packages/\\`, \\`apps/\\`, \\`crates/\\`, or \\`libs/\\` directories\n - Check root package.json for \\`workspaces\\` field\n - If monorepo: document the package structure and key packages users would install\n - Use full paths from repo root (e.g., \\`packages/core/src/index.ts\\`)\n - Identify which packages are publishable vs internal\n\n## EXPLORATION STEPS\n\nUse Read, Grep, Glob tools to explore:\n1. Root package.json / Cargo.toml - check for workspaces/monorepo config\n2. Check for \\`packages/\\`, \\`apps/\\`, \\`crates/\\` directories\n3. README.md - official usage documentation\n4. For monorepos: explore each publishable package's entry point\n5. docs/ or website/ - find documentation\n6. examples/ - real usage patterns\n7. TypeScript definitions (.d.ts) - public API surface\n\n## OUTPUT FORMAT\n\nIMPORTANT: Reference name is \"${referenceName}\" (for internal tracking only - do NOT include in output).\n\n\\`\\`\\`markdown\n# {Library Name}\n\n{2-3 sentence overview of what this library does and its key value proposition}\n\n## Quick References\n\n| File | Purpose |\n|------|---------|\n| \\`packages/{pkg}/src/index.ts\\` | Main entry point (monorepo example) |\n| \\`src/index.ts\\` | Main entry point (single-package example) |\n| \\`README.md\\` | Documentation |\n\n(For monorepos, include paths to key publishable packages)\n\n## Packages (for monorepos only)\n\n| Package | npm name | Description |\n|---------|----------|-------------|\n| \\`packages/core\\` | \\`@scope/core\\` | Core functionality |\n| \\`packages/react\\` | \\`@scope/react\\` | React bindings |\n\n(OMIT this section for single-package repos)\n\n## When to Use\n\n- {Practical scenario where a developer would reach for this library}\n- {Another real-world use case}\n- {Problem this library solves}\n\n## Installation\n\n\\`\\`\\`bash\n# Single package\nnpm install {package-name}\n\n# Monorepo (show key packages)\nnpm install @scope/core @scope/react\n\\`\\`\\`\n\n## Best Practices\n\n1. {Actionable best practice for USERS of this library}\n2. {Common mistake to avoid when using this library}\n3. {Performance or correctness tip}\n\n## Common Patterns\n\n**{Pattern Name}:**\n\\`\\`\\`{language}\n{Minimal working code example}\n\\`\\`\\`\n\n**{Another Pattern}:**\n\\`\\`\\`{language}\n{Another code example}\n\\`\\`\\`\n\n## API Quick Reference\n\n| Export | Type | Description |\n|--------|------|-------------|\n| \\`{main export}\\` | {type} | {what it does} |\n| \\`{another export}\\` | {type} | {what it does} |\n\n{Add more sections as appropriate for the library: Configuration, Types, CLI Commands (if user-facing), etc.}\n\\`\\`\\`\n\n## QUALITY CHECKLIST\n\nBefore outputting, verify:\n- [ ] NO YAML frontmatter - start directly with # heading\n- [ ] Every code example is something a USER would write, not a contributor\n- [ ] No internal test commands or contribution workflows\n- [ ] Quick References paths are relative from repo root (no absolute/user paths)\n- [ ] Best practices are for using the library, not developing it\n- [ ] If monorepo: Packages section lists publishable packages with npm names\n- [ ] If monorepo: paths include package directory (e.g., \\`packages/core/src/index.ts\\`)\n\nNow explore the codebase and generate the reference content.\n\n## OUTPUT INSTRUCTIONS\n\nAfter exploring, output your complete reference wrapped in XML tags like this:\n\n\\`\\`\\`\n<reference_output>\n(your complete markdown reference here)\n</reference_output>\n\\`\\`\\`\n\nREQUIREMENTS:\n- Start with a level-1 heading with the actual library name (e.g., \"# TanStack Query\")\n- Include sections: Quick References (table), When to Use (bullets), Installation, Best Practices, Common Patterns (with code), API Quick Reference (table)\n- Minimum 2000 characters of actual content - short or placeholder content will be rejected\n- Fill in real information from your exploration - do not use placeholder text like \"{Library Name}\"\n- No YAML frontmatter - start directly with the markdown heading\n- Output ONLY the reference inside the tags, no other text\n\nBegin exploring now.`;\n}\n\n/**\n * Extract the actual reference markdown content from AI response.\n * The response may include echoed prompt/system context before the actual reference.\n * Handles multiple edge cases:\n * - Model echoes the prompt template (skip template content)\n * - Model forgets to close the tag (extract to end of response)\n * - Multiple tag pairs (find the one with real content)\n */\nfunction extractReferenceContent(rawResponse: string, onDebug?: (message: string) => void): string {\n\tconst openTag = \"<reference_output>\";\n\tconst closeTag = \"</reference_output>\";\n\n\tonDebug?.(`[extract] Raw response length: ${rawResponse.length} chars`);\n\n\t// Find all occurrences of open and close tags\n\tconst openIndices: number[] = [];\n\tconst closeIndices: number[] = [];\n\tlet pos = 0;\n\twhile ((pos = rawResponse.indexOf(openTag, pos)) !== -1) {\n\t\topenIndices.push(pos);\n\t\tpos += openTag.length;\n\t}\n\tpos = 0;\n\twhile ((pos = rawResponse.indexOf(closeTag, pos)) !== -1) {\n\t\tcloseIndices.push(pos);\n\t\tpos += closeTag.length;\n\t}\n\n\tonDebug?.(\n\t\t`[extract] Found ${openIndices.length} open tag(s), ${closeIndices.length} close tag(s)`,\n\t);\n\n\t// Helper to clean content (strip markdown fences)\n\tconst cleanContent = (raw: string): string => {\n\t\tlet content = raw.trim();\n\t\tif (content.startsWith(\"```\")) {\n\t\t\tcontent = content.replace(/^```(?:markdown)?\\s*\\n?/, \"\");\n\t\t\tcontent = content.replace(/\\n?```\\s*$/, \"\");\n\t\t}\n\t\treturn content.trim();\n\t};\n\n\t// Helper to check if content is template placeholder\n\tconst isTemplateContent = (content: string): boolean => {\n\t\treturn (\n\t\t\tcontent.includes(\"{Library Name}\") ||\n\t\t\tcontent.includes(\"(your complete markdown reference here)\")\n\t\t);\n\t};\n\n\t// Strategy 1: Find properly paired tags, starting from the LAST open tag\n\t// (Last is more likely to be actual output, not echoed prompt)\n\tfor (let i = openIndices.length - 1; i >= 0; i--) {\n\t\tconst openIdx = openIndices[i];\n\t\tif (openIdx === undefined) continue;\n\n\t\t// Find the first close tag after this open tag\n\t\tconst closeIdx = closeIndices.find((c) => c > openIdx);\n\t\tif (closeIdx !== undefined) {\n\t\t\tconst rawContent = rawResponse.slice(openIdx + openTag.length, closeIdx);\n\t\t\tconst content = cleanContent(rawContent);\n\n\t\t\tonDebug?.(`[extract] Pair ${i}: open=${openIdx}, close=${closeIdx}, len=${content.length}`);\n\t\t\tonDebug?.(\n\t\t\t\t`[extract] Preview: \"${content.slice(0, 200)}${content.length > 200 ? \"...\" : \"\"}\"`,\n\t\t\t);\n\n\t\t\tif (isTemplateContent(content)) {\n\t\t\t\tonDebug?.(`[extract] Skipping pair ${i} - template placeholder content`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (content.length >= 500) {\n\t\t\t\tonDebug?.(`[extract] Using pair ${i} - valid content`);\n\t\t\t\tvalidateReferenceContent(content);\n\t\t\t\treturn content;\n\t\t\t}\n\t\t\tonDebug?.(`[extract] Pair ${i} too short (${content.length} chars)`);\n\t\t}\n\t}\n\n\t// Strategy 2: Handle unclosed tag - model output <reference_output> but never closed it\n\t// Find the last open tag that has no close tag after it\n\tconst lastOpenIdx = openIndices[openIndices.length - 1];\n\tif (lastOpenIdx !== undefined) {\n\t\tconst hasCloseAfter = closeIndices.some((c) => c > lastOpenIdx);\n\t\tif (!hasCloseAfter) {\n\t\t\tonDebug?.(`[extract] Last open tag at ${lastOpenIdx} is unclosed - extracting to end`);\n\t\t\tconst rawContent = rawResponse.slice(lastOpenIdx + openTag.length);\n\t\t\tconst content = cleanContent(rawContent);\n\n\t\t\tonDebug?.(`[extract] Unclosed content: ${content.length} chars`);\n\t\t\tonDebug?.(\n\t\t\t\t`[extract] Preview: \"${content.slice(0, 200)}${content.length > 200 ? \"...\" : \"\"}\"`,\n\t\t\t);\n\n\t\t\tif (!isTemplateContent(content) && content.length >= 500) {\n\t\t\t\tonDebug?.(`[extract] Using unclosed content - valid`);\n\t\t\t\tvalidateReferenceContent(content);\n\t\t\t\treturn content;\n\t\t\t}\n\t\t}\n\t}\n\n\tonDebug?.(`[extract] No valid content found`);\n\tonDebug?.(`[extract] Response tail: \"${rawResponse.slice(-300)}\"`);\n\n\tthrow new Error(\n\t\t\"Failed to extract reference content: no valid <reference_output> tags found. \" +\n\t\t\t\"The AI may have failed to follow the output format or produced placeholder content.\",\n\t);\n}\n\n/**\n * Validate extracted reference content has minimum required structure.\n * Throws if content is invalid.\n */\nfunction validateReferenceContent(content: string): void {\n\t// Check for template placeholders that indicate the model just echoed the format\n\tconst templatePlaceholders = [\n\t\t\"{Library Name}\",\n\t\t\"{Full overview paragraph}\",\n\t\t\"{Table with 3-5 key files}\",\n\t\t\"{3+ bullet points}\",\n\t\t\"{Install commands}\",\n\t\t\"{3+ numbered items}\",\n\t\t\"{2+ code examples\",\n\t\t\"{Table of key exports}\",\n\t\t\"{Additional sections\",\n\t];\n\n\tconst foundPlaceholders = templatePlaceholders.filter((p) => content.includes(p));\n\tif (foundPlaceholders.length > 0) {\n\t\tthrow new Error(\n\t\t\t`Invalid reference content: contains template placeholders (${foundPlaceholders.slice(0, 3).join(\", \")}). ` +\n\t\t\t\t\"The AI echoed the format instead of generating actual content.\",\n\t\t);\n\t}\n\n\tif (content.length < 500) {\n\t\tthrow new Error(\n\t\t\t`Invalid reference content: too short (${content.length} chars, minimum 500). ` +\n\t\t\t\t\"The AI may have produced placeholder or incomplete content.\",\n\t\t);\n\t}\n\n\tif (!content.startsWith(\"#\")) {\n\t\tthrow new Error(\n\t\t\t\"Invalid reference content: must start with markdown heading. \" +\n\t\t\t\t\"Content must begin with '# Library Name' (no YAML frontmatter).\",\n\t\t);\n\t}\n}\n\n/**\n * Generate a reference markdown file for a repository using AI.\n *\n * Opens an OpenCode session and instructs the AI agent to explore the codebase\n * using Read, Grep, and Glob tools, then produce a comprehensive reference.\n *\n * @param repoPath - Path to the repository to analyze\n * @param repoName - Qualified name of the repo (e.g., \"tanstack/query\" or \"my-local-repo\")\n * @param options - Generation options (provider, model, callbacks)\n * @returns The generated reference content and commit SHA\n */\nexport async function generateReferenceWithAI(\n\trepoPath: string,\n\trepoName: string,\n\toptions: GenerateReferenceOptions = {},\n): Promise<GenerateReferenceResult> {\n\tconst { provider, model, onDebug, onStream } = options;\n\tconst config = loadConfig();\n\n\tconst [configProvider, configModel] = config.defaultModel?.split(\"/\") ?? [];\n\tconst aiProvider = provider ?? configProvider;\n\tconst aiModel = model ?? configModel;\n\n\tonDebug?.(`Starting AI reference generation for ${repoName}`);\n\tonDebug?.(`Repo path: ${repoPath}`);\n\tonDebug?.(`Provider: ${aiProvider ?? \"default\"}, Model: ${aiModel ?? \"default\"}`);\n\n\tconst commitSha = getCommitSha(repoPath);\n\tonDebug?.(`Commit SHA: ${commitSha}`);\n\n\tconst referenceName = toReferenceName(repoName);\n\tonDebug?.(`Reference name: ${referenceName}`);\n\n\tconst promptOptions: StreamPromptOptions = {\n\t\tprompt: createReferenceGenerationPrompt(referenceName),\n\t\tcwd: repoPath,\n\t\tprovider: aiProvider,\n\t\tmodel: aiModel,\n\t\tonDebug,\n\t\tonStream,\n\t};\n\n\tconst result = await streamPrompt(promptOptions);\n\n\tonDebug?.(`Generation complete (${result.durationMs}ms, ${result.text.length} chars)`);\n\n\tconst referenceContent = extractReferenceContent(result.text, onDebug);\n\tonDebug?.(`Extracted reference content (${referenceContent.length} chars)`);\n\n\treturn {\n\t\treferenceContent,\n\t\tcommitSha,\n\t};\n}\n"],"mappings":";;;;;;;;;AAGA,IAAa,yBAAb,cAA4C,MAAM;CACjD,AAAS,OAAe;CACxB,YACC,SACA,AAAgB,SACf;AACD,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;;;;;;AAOd,IAAa,4BAAb,cAA+C,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;EACA,CAE+C;AAEhD,WAAU,wBAAwB,OAAO,WAAW,MAAM,OAAO,KAAK,OAAO,SAAS;CAEtF,MAAM,mBAAmB,wBAAwB,OAAO,MAAM,QAAQ;AACtE,WAAU,gCAAgC,iBAAiB,OAAO,SAAS;AAE3E,QAAO;EACN;EACA;EACA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as AuthData, $t as getMetaRoot, A as pruneRepos, At as updateRepo, B as resolveFromNpm, Bt as removeGlobalMapEntry, C as RepoStatusOptions, Ct as getCommitDistance, D as discoverRepos, Dt as listRepos, E as UpdateAllResult, Et as isShallowClone, F as matchDependenciesToReferences, Ft as getMapEntry, G as AgentConfig, Gt as PathNotFoundError, H as ManifestType, Ht as writeGlobalMap, I as matchDependenciesToReferencesWithRemoteCheck, It as getProjectMapPath, J as getAgentConfig, Jt as parseRepoInput, K as agents, Kt as RepoSourceError, L as FALLBACK_MAPPINGS, Lt as resolveRepoKey, M as ReferenceMatch, Mt as MapEntry, N as ReferenceStatus, Nt as SearchMapOptions, O as gcRepos, Ot as removeRepo, P as isReferenceInstalled, Pt as SearchResult, Q as installReference, Qt as getMetaPath, R as ResolvedDep, Rt as searchMap, S as PruneResult, St as getClonedRepoPath, T as UpdateAllOptions, Tt as isRepoCloned, U as detectManifestType, Ut as writeProjectMap, V as Dependency, Vt as upsertGlobalMapEntry, W as parseDependencies, Wt as NotGitRepoError, X as InstallReferenceMeta, Xt as expandTilde, Y as getAllAgentConfigs, Yt as Paths, Z as installGlobalSkill, Zt as getConfigPath, _ as DiscoverOptions, _t as RepoExistsError, a as GlobalMap, an as toMetaDirName, at as getAuthPath, b as GcResult, bt as UpdateResult, c as ProjectMapRepoEntry, cn as DEFAULT_IGNORE_PATTERNS, ct as getTokenOrNull, d as ProviderInfo, dt as refreshAccessToken, en as getReferencePath, et as AuthError, f as ProviderWithModels, ft as saveAuthData, g as validateProviderModel, gt as RemoveOptions, h as listProvidersWithModels, ht as GitError, i as FileRole, in as saveConfig, it as clearAuthData, j as updateAllRepos, jt as GetMapEntryOptions, k as getRepoStatus, kt as unshallowRepo, l as RepoSource, ln as VERSION, lt as isLoggedIn, m as listProviders, mt as CloneOptions, n as FileIndex, nn as getRepoRoot, nt as NotLoggedInError, o as GlobalMapRepoEntry, on as toReferenceFileName, ot as getAuthStatus, p as getProvider, pt as CloneError, q as detectInstalledAgents, qt as getReferenceFileNameForSource, r as FileIndexEntry, rn as loadConfig, rt as TokenExpiredError, s as ProjectMap, sn as toReferenceName, st as getToken, t as Config, tn as getRepoPath, tt as AuthStatus, u as ModelInfo, ut as loadAuthData, v as DiscoverResult, vt as RepoNotFoundError, w as RepoStatusSummary, wt as getCommitSha, x as PruneOptions, xt as cloneRepo, y as GcOptions, yt as UpdateOptions, z as resolveDependencyRepo, zt as readGlobalMap } from "./public-
|
|
1
|
+
import { $ as AuthData, $t as getMetaRoot, A as pruneRepos, At as updateRepo, B as resolveFromNpm, Bt as removeGlobalMapEntry, C as RepoStatusOptions, Ct as getCommitDistance, D as discoverRepos, Dt as listRepos, E as UpdateAllResult, Et as isShallowClone, F as matchDependenciesToReferences, Ft as getMapEntry, G as AgentConfig, Gt as PathNotFoundError, H as ManifestType, Ht as writeGlobalMap, I as matchDependenciesToReferencesWithRemoteCheck, It as getProjectMapPath, J as getAgentConfig, Jt as parseRepoInput, K as agents, Kt as RepoSourceError, L as FALLBACK_MAPPINGS, Lt as resolveRepoKey, M as ReferenceMatch, Mt as MapEntry, N as ReferenceStatus, Nt as SearchMapOptions, O as gcRepos, Ot as removeRepo, P as isReferenceInstalled, Pt as SearchResult, Q as installReference, Qt as getMetaPath, R as ResolvedDep, Rt as searchMap, S as PruneResult, St as getClonedRepoPath, T as UpdateAllOptions, Tt as isRepoCloned, U as detectManifestType, Ut as writeProjectMap, V as Dependency, Vt as upsertGlobalMapEntry, W as parseDependencies, Wt as NotGitRepoError, X as InstallReferenceMeta, Xt as expandTilde, Y as getAllAgentConfigs, Yt as Paths, Z as installGlobalSkill, Zt as getConfigPath, _ as DiscoverOptions, _t as RepoExistsError, a as GlobalMap, an as toMetaDirName, at as getAuthPath, b as GcResult, bt as UpdateResult, c as ProjectMapRepoEntry, cn as DEFAULT_IGNORE_PATTERNS, ct as getTokenOrNull, d as ProviderInfo, dt as refreshAccessToken, en as getReferencePath, et as AuthError, f as ProviderWithModels, ft as saveAuthData, g as validateProviderModel, gt as RemoveOptions, h as listProvidersWithModels, ht as GitError, i as FileRole, in as saveConfig, it as clearAuthData, j as updateAllRepos, jt as GetMapEntryOptions, k as getRepoStatus, kt as unshallowRepo, l as RepoSource, ln as VERSION, lt as isLoggedIn, m as listProviders, mt as CloneOptions, n as FileIndex, nn as getRepoRoot, nt as NotLoggedInError, o as GlobalMapRepoEntry, on as toReferenceFileName, ot as getAuthStatus, p as getProvider, pt as CloneError, q as detectInstalledAgents, qt as getReferenceFileNameForSource, r as FileIndexEntry, rn as loadConfig, rt as TokenExpiredError, s as ProjectMap, sn as toReferenceName, st as getToken, t as Config, tn as getRepoPath, tt as AuthStatus, u as ModelInfo, ut as loadAuthData, v as DiscoverResult, vt as RepoNotFoundError, w as RepoStatusSummary, wt as getCommitSha, x as PruneOptions, xt as cloneRepo, y as GcOptions, yt as UpdateOptions, z as resolveDependencyRepo, zt as readGlobalMap } from "./public-Cdr8rPRd.mjs";
|
|
2
2
|
export { AgentConfig, AuthData, AuthError, AuthStatus, CloneError, CloneOptions, Config, DEFAULT_IGNORE_PATTERNS, Dependency, DiscoverOptions, DiscoverResult, FALLBACK_MAPPINGS, FileIndex, FileIndexEntry, FileRole, GcOptions, GcResult, GetMapEntryOptions, GitError, GlobalMap, GlobalMapRepoEntry, InstallReferenceMeta, ManifestType, MapEntry, ModelInfo, NotGitRepoError, NotLoggedInError, PathNotFoundError, Paths, ProjectMap, ProjectMapRepoEntry, ProviderInfo, ProviderWithModels, PruneOptions, PruneResult, ReferenceMatch, ReferenceStatus, RemoveOptions, RepoExistsError, RepoNotFoundError, RepoSource, RepoSourceError, RepoStatusOptions, RepoStatusSummary, ResolvedDep, SearchMapOptions, SearchResult, TokenExpiredError, UpdateAllOptions, UpdateAllResult, UpdateOptions, UpdateResult, VERSION, agents, clearAuthData, cloneRepo, detectInstalledAgents, detectManifestType, discoverRepos, expandTilde, gcRepos, getAgentConfig, getAllAgentConfigs, getAuthPath, getAuthStatus, getClonedRepoPath, getCommitDistance, getCommitSha, getConfigPath, getMapEntry, getMetaPath, getMetaRoot, getProjectMapPath, getProvider, getReferenceFileNameForSource, getReferencePath, getRepoPath, getRepoRoot, getRepoStatus, getToken, getTokenOrNull, installGlobalSkill, installReference, isLoggedIn, isReferenceInstalled, isRepoCloned, isShallowClone, listProviders, listProvidersWithModels, listRepos, loadAuthData, loadConfig, matchDependenciesToReferences, matchDependenciesToReferencesWithRemoteCheck, parseDependencies, parseRepoInput, pruneRepos, readGlobalMap, refreshAccessToken, removeGlobalMapEntry, removeRepo, resolveDependencyRepo, resolveFromNpm, resolveRepoKey, saveAuthData, saveConfig, searchMap, toMetaDirName, toReferenceFileName, toReferenceName, unshallowRepo, updateAllRepos, updateRepo, upsertGlobalMapEntry, validateProviderModel, writeGlobalMap, writeProjectMap };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as getToken, B as NotGitRepoError, C as getAllAgentConfigs, D as clearAuthData, E as TokenExpiredError, F as saveAuthData, G as DEFAULT_IGNORE_PATTERNS, H as RepoSourceError, I as getMapEntry, K as VERSION, L as getProjectMapPath, M as isLoggedIn, N as loadAuthData, O as getAuthPath, P as refreshAccessToken, R as resolveRepoKey, S as getAgentConfig, T as NotLoggedInError, U as getReferenceFileNameForSource, V as PathNotFoundError, W as parseRepoInput, _ as parseDependencies, a as discoverRepos, b as agents, c as pruneRepos, d as matchDependenciesToReferences, f as matchDependenciesToReferencesWithRemoteCheck, g as detectManifestType, h as resolveFromNpm, i as validateProviderModel, j as getTokenOrNull, k as getAuthStatus, l as updateAllRepos, m as resolveDependencyRepo, n as listProviders, o as gcRepos, p as FALLBACK_MAPPINGS, r as listProvidersWithModels, s as getRepoStatus, t as getProvider, u as isReferenceInstalled, v as installGlobalSkill, w as AuthError, x as detectInstalledAgents, y as installReference, z as searchMap } from "./public-
|
|
1
|
+
import { A as getToken, B as NotGitRepoError, C as getAllAgentConfigs, D as clearAuthData, E as TokenExpiredError, F as saveAuthData, G as DEFAULT_IGNORE_PATTERNS, H as RepoSourceError, I as getMapEntry, K as VERSION, L as getProjectMapPath, M as isLoggedIn, N as loadAuthData, O as getAuthPath, P as refreshAccessToken, R as resolveRepoKey, S as getAgentConfig, T as NotLoggedInError, U as getReferenceFileNameForSource, V as PathNotFoundError, W as parseRepoInput, _ as parseDependencies, a as discoverRepos, b as agents, c as pruneRepos, d as matchDependenciesToReferences, f as matchDependenciesToReferencesWithRemoteCheck, g as detectManifestType, h as resolveFromNpm, i as validateProviderModel, j as getTokenOrNull, k as getAuthStatus, l as updateAllRepos, m as resolveDependencyRepo, n as listProviders, o as gcRepos, p as FALLBACK_MAPPINGS, r as listProvidersWithModels, s as getRepoStatus, t as getProvider, u as isReferenceInstalled, v as installGlobalSkill, w as AuthError, x as detectInstalledAgents, y as installReference, z as searchMap } from "./public-CjA2mMwu.mjs";
|
|
2
2
|
import { a as getRepoPath, c as saveConfig, d as toReferenceName, f as Paths, i as getReferencePath, l as toMetaDirName, n as getMetaPath, o as getRepoRoot, p as expandTilde, r as getMetaRoot, s as loadConfig, t as getConfigPath, u as toReferenceFileName } from "./config-DW8J4gl5.mjs";
|
|
3
3
|
import { _ as upsertGlobalMapEntry, a as cloneRepo, c as getCommitSha, d as listRepos, f as removeRepo, g as removeGlobalMapEntry, h as readGlobalMap, i as RepoNotFoundError, l as isRepoCloned, m as updateRepo, n as GitError, o as getClonedRepoPath, p as unshallowRepo, r as RepoExistsError, s as getCommitDistance, t as CloneError, u as isShallowClone, v as writeGlobalMap, y as writeProjectMap } from "./clone-DyLvmbJZ.mjs";
|
|
4
4
|
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as AuthData, $t as getMetaRoot, A as pruneRepos, At as updateRepo, B as resolveFromNpm, Bt as removeGlobalMapEntry, C as RepoStatusOptions, Ct as getCommitDistance, D as discoverRepos, Dt as listRepos, E as UpdateAllResult, Et as isShallowClone, F as matchDependenciesToReferences, Ft as getMapEntry, G as AgentConfig, Gt as PathNotFoundError, H as ManifestType, Ht as writeGlobalMap, I as matchDependenciesToReferencesWithRemoteCheck, It as getProjectMapPath, J as getAgentConfig, Jt as parseRepoInput, K as agents, Kt as RepoSourceError, L as FALLBACK_MAPPINGS, Lt as resolveRepoKey, M as ReferenceMatch, Mt as MapEntry, N as ReferenceStatus, Nt as SearchMapOptions, O as gcRepos, Ot as removeRepo, P as isReferenceInstalled, Pt as SearchResult, Q as installReference, Qt as getMetaPath, R as ResolvedDep, Rt as searchMap, S as PruneResult, St as getClonedRepoPath, T as UpdateAllOptions, Tt as isRepoCloned, U as detectManifestType, Ut as writeProjectMap, V as Dependency, Vt as upsertGlobalMapEntry, W as parseDependencies, Wt as NotGitRepoError, X as InstallReferenceMeta, Xt as expandTilde, Y as getAllAgentConfigs, Yt as Paths, Z as installGlobalSkill, Zt as getConfigPath, _ as DiscoverOptions, _t as RepoExistsError, a as GlobalMap, an as toMetaDirName, at as getAuthPath, b as GcResult, bt as UpdateResult, c as ProjectMapRepoEntry, cn as DEFAULT_IGNORE_PATTERNS, ct as getTokenOrNull, d as ProviderInfo, dt as refreshAccessToken, en as getReferencePath, et as AuthError, f as ProviderWithModels, ft as saveAuthData, g as validateProviderModel, gt as RemoveOptions, h as listProvidersWithModels, ht as GitError, i as FileRole, in as saveConfig, it as clearAuthData, j as updateAllRepos, jt as GetMapEntryOptions, k as getRepoStatus, kt as unshallowRepo, l as RepoSource, ln as VERSION, lt as isLoggedIn, m as listProviders, mt as CloneOptions, n as FileIndex, nn as getRepoRoot, nt as NotLoggedInError, o as GlobalMapRepoEntry, on as toReferenceFileName, ot as getAuthStatus, p as getProvider, pt as CloneError, q as detectInstalledAgents, qt as getReferenceFileNameForSource, r as FileIndexEntry, rn as loadConfig, rt as TokenExpiredError, s as ProjectMap, sn as toReferenceName, st as getToken, t as Config, tn as getRepoPath, tt as AuthStatus, u as ModelInfo, ut as loadAuthData, v as DiscoverResult, vt as RepoNotFoundError, w as RepoStatusSummary, wt as getCommitSha, x as PruneOptions, xt as cloneRepo, y as GcOptions, yt as UpdateOptions, z as resolveDependencyRepo, zt as readGlobalMap } from "./public-
|
|
1
|
+
import { $ as AuthData, $t as getMetaRoot, A as pruneRepos, At as updateRepo, B as resolveFromNpm, Bt as removeGlobalMapEntry, C as RepoStatusOptions, Ct as getCommitDistance, D as discoverRepos, Dt as listRepos, E as UpdateAllResult, Et as isShallowClone, F as matchDependenciesToReferences, Ft as getMapEntry, G as AgentConfig, Gt as PathNotFoundError, H as ManifestType, Ht as writeGlobalMap, I as matchDependenciesToReferencesWithRemoteCheck, It as getProjectMapPath, J as getAgentConfig, Jt as parseRepoInput, K as agents, Kt as RepoSourceError, L as FALLBACK_MAPPINGS, Lt as resolveRepoKey, M as ReferenceMatch, Mt as MapEntry, N as ReferenceStatus, Nt as SearchMapOptions, O as gcRepos, Ot as removeRepo, P as isReferenceInstalled, Pt as SearchResult, Q as installReference, Qt as getMetaPath, R as ResolvedDep, Rt as searchMap, S as PruneResult, St as getClonedRepoPath, T as UpdateAllOptions, Tt as isRepoCloned, U as detectManifestType, Ut as writeProjectMap, V as Dependency, Vt as upsertGlobalMapEntry, W as parseDependencies, Wt as NotGitRepoError, X as InstallReferenceMeta, Xt as expandTilde, Y as getAllAgentConfigs, Yt as Paths, Z as installGlobalSkill, Zt as getConfigPath, _ as DiscoverOptions, _t as RepoExistsError, a as GlobalMap, an as toMetaDirName, at as getAuthPath, b as GcResult, bt as UpdateResult, c as ProjectMapRepoEntry, cn as DEFAULT_IGNORE_PATTERNS, ct as getTokenOrNull, d as ProviderInfo, dt as refreshAccessToken, en as getReferencePath, et as AuthError, f as ProviderWithModels, ft as saveAuthData, g as validateProviderModel, gt as RemoveOptions, h as listProvidersWithModels, ht as GitError, i as FileRole, in as saveConfig, it as clearAuthData, j as updateAllRepos, jt as GetMapEntryOptions, k as getRepoStatus, kt as unshallowRepo, l as RepoSource, ln as VERSION, lt as isLoggedIn, m as listProviders, mt as CloneOptions, n as FileIndex, nn as getRepoRoot, nt as NotLoggedInError, o as GlobalMapRepoEntry, on as toReferenceFileName, ot as getAuthStatus, p as getProvider, pt as CloneError, q as detectInstalledAgents, qt as getReferenceFileNameForSource, r as FileIndexEntry, rn as loadConfig, rt as TokenExpiredError, s as ProjectMap, sn as toReferenceName, st as getToken, t as Config, tn as getRepoPath, tt as AuthStatus, u as ModelInfo, ut as loadAuthData, v as DiscoverResult, vt as RepoNotFoundError, w as RepoStatusSummary, wt as getCommitSha, x as PruneOptions, xt as cloneRepo, y as GcOptions, yt as UpdateOptions, z as resolveDependencyRepo, zt as readGlobalMap } from "./public-Cdr8rPRd.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/agents-md.d.ts
|
|
4
4
|
/**
|
package/dist/internal.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as getToken, B as NotGitRepoError, C as getAllAgentConfigs, D as clearAuthData, E as TokenExpiredError, F as saveAuthData, G as DEFAULT_IGNORE_PATTERNS, H as RepoSourceError, I as getMapEntry, K as VERSION, L as getProjectMapPath, M as isLoggedIn, N as loadAuthData, O as getAuthPath, P as refreshAccessToken, R as resolveRepoKey, S as getAgentConfig, T as NotLoggedInError, U as getReferenceFileNameForSource, V as PathNotFoundError, W as parseRepoInput, _ as parseDependencies, a as discoverRepos, b as agents, c as pruneRepos, d as matchDependenciesToReferences, f as matchDependenciesToReferencesWithRemoteCheck, g as detectManifestType, h as resolveFromNpm, i as validateProviderModel, j as getTokenOrNull, k as getAuthStatus, l as updateAllRepos, m as resolveDependencyRepo, n as listProviders, o as gcRepos, p as FALLBACK_MAPPINGS, r as listProvidersWithModels, s as getRepoStatus, t as getProvider, u as isReferenceInstalled, v as installGlobalSkill, w as AuthError, x as detectInstalledAgents, y as installReference, z as searchMap } from "./public-
|
|
1
|
+
import { A as getToken, B as NotGitRepoError, C as getAllAgentConfigs, D as clearAuthData, E as TokenExpiredError, F as saveAuthData, G as DEFAULT_IGNORE_PATTERNS, H as RepoSourceError, I as getMapEntry, K as VERSION, L as getProjectMapPath, M as isLoggedIn, N as loadAuthData, O as getAuthPath, P as refreshAccessToken, R as resolveRepoKey, S as getAgentConfig, T as NotLoggedInError, U as getReferenceFileNameForSource, V as PathNotFoundError, W as parseRepoInput, _ as parseDependencies, a as discoverRepos, b as agents, c as pruneRepos, d as matchDependenciesToReferences, f as matchDependenciesToReferencesWithRemoteCheck, g as detectManifestType, h as resolveFromNpm, i as validateProviderModel, j as getTokenOrNull, k as getAuthStatus, l as updateAllRepos, m as resolveDependencyRepo, n as listProviders, o as gcRepos, p as FALLBACK_MAPPINGS, r as listProvidersWithModels, s as getRepoStatus, t as getProvider, u as isReferenceInstalled, v as installGlobalSkill, w as AuthError, x as detectInstalledAgents, y as installReference, z as searchMap } from "./public-CjA2mMwu.mjs";
|
|
2
2
|
import { a as getRepoPath, c as saveConfig, d as toReferenceName, f as Paths, i as getReferencePath, l as toMetaDirName, n as getMetaPath, o as getRepoRoot, p as expandTilde, r as getMetaRoot, s as loadConfig, t as getConfigPath, u as toReferenceFileName } from "./config-DW8J4gl5.mjs";
|
|
3
3
|
import { _ as upsertGlobalMapEntry, a as cloneRepo, c as getCommitSha, d as listRepos, f as removeRepo, g as removeGlobalMapEntry, h as readGlobalMap, i as RepoNotFoundError, l as isRepoCloned, m as updateRepo, n as GitError, o as getClonedRepoPath, p as unshallowRepo, r as RepoExistsError, s as getCommitDistance, t as CloneError, u as isShallowClone, v as writeGlobalMap, y as writeProjectMap } from "./clone-DyLvmbJZ.mjs";
|
|
4
4
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -5,7 +5,7 @@ import { Agent, Config, Config as Config$1, FileIndex, FileIndexEntry, FileRole,
|
|
|
5
5
|
* SDK Constants
|
|
6
6
|
*/
|
|
7
7
|
/** SDK version - must match package.json */
|
|
8
|
-
declare const VERSION = "0.3.
|
|
8
|
+
declare const VERSION = "0.3.1";
|
|
9
9
|
/**
|
|
10
10
|
* Default patterns to ignore when scanning repositories.
|
|
11
11
|
* Includes directories, binary files, IDE configs, and build outputs.
|
|
@@ -652,4 +652,4 @@ declare function validateProviderModel(providerId: string, modelId: string): Pro
|
|
|
652
652
|
}>;
|
|
653
653
|
//#endregion
|
|
654
654
|
export { AuthData as $, getMetaRoot as $t, pruneRepos as A, updateRepo as At, resolveFromNpm as B, removeGlobalMapEntry as Bt, RepoStatusOptions as C, getCommitDistance as Ct, discoverRepos as D, listRepos as Dt, UpdateAllResult as E, isShallowClone as Et, matchDependenciesToReferences as F, getMapEntry as Ft, AgentConfig as G, PathNotFoundError as Gt, ManifestType as H, writeGlobalMap as Ht, matchDependenciesToReferencesWithRemoteCheck as I, getProjectMapPath as It, getAgentConfig as J, parseRepoInput as Jt, agents as K, RepoSourceError as Kt, FALLBACK_MAPPINGS as L, resolveRepoKey as Lt, ReferenceMatch as M, MapEntry as Mt, ReferenceStatus as N, SearchMapOptions as Nt, gcRepos as O, removeRepo as Ot, isReferenceInstalled as P, SearchResult as Pt, installReference as Q, getMetaPath as Qt, ResolvedDep as R, searchMap as Rt, PruneResult as S, getClonedRepoPath as St, UpdateAllOptions as T, isRepoCloned as Tt, detectManifestType as U, writeProjectMap as Ut, Dependency as V, upsertGlobalMapEntry as Vt, parseDependencies as W, NotGitRepoError as Wt, InstallReferenceMeta as X, expandTilde as Xt, getAllAgentConfigs as Y, Paths as Yt, installGlobalSkill as Z, getConfigPath as Zt, DiscoverOptions as _, RepoExistsError as _t, GlobalMap$1 as a, toMetaDirName as an, getAuthPath as at, GcResult as b, UpdateResult as bt, ProjectMapRepoEntry$1 as c, DEFAULT_IGNORE_PATTERNS as cn, getTokenOrNull as ct, ProviderInfo as d, refreshAccessToken as dt, getReferencePath as en, AuthError as et, ProviderWithModels as f, saveAuthData as ft, validateProviderModel as g, RemoveOptions as gt, listProvidersWithModels as h, GitError as ht, FileRole as i, saveConfig as in, clearAuthData as it, updateAllRepos as j, GetMapEntryOptions as jt, getRepoStatus as k, unshallowRepo as kt, RepoSource$1 as l, VERSION as ln, isLoggedIn as lt, listProviders as m, CloneOptions as mt, FileIndex as n, getRepoRoot as nn, NotLoggedInError as nt, GlobalMapRepoEntry$1 as o, toReferenceFileName as on, getAuthStatus as ot, getProvider as p, CloneError as pt, detectInstalledAgents as q, getReferenceFileNameForSource as qt, FileIndexEntry as r, loadConfig as rn, TokenExpiredError as rt, ProjectMap$1 as s, toReferenceName as sn, getToken as st, Config$1 as t, getRepoPath as tn, AuthStatus as tt, ModelInfo as u, loadAuthData as ut, DiscoverResult as v, RepoNotFoundError as vt, RepoStatusSummary as w, getCommitSha as wt, PruneOptions as x, cloneRepo as xt, GcOptions as y, UpdateOptions as yt, resolveDependencyRepo as z, readGlobalMap as zt };
|
|
655
|
-
//# sourceMappingURL=public-
|
|
655
|
+
//# sourceMappingURL=public-Cdr8rPRd.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-
|
|
1
|
+
{"version":3,"file":"public-Cdr8rPRd.d.mts","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/paths.ts","../src/repo-source.ts","../src/index-manager.ts","../src/map.ts","../src/clone.ts","../src/auth.ts","../src/reference.ts","../src/agents.ts","../src/manifest.ts","../src/dep-mappings.ts","../src/reference-matcher.ts","../src/repo-manager.ts","../src/models.ts"],"mappings":";;;;;;AAKA;AAAA,cAAa,OAAA;;;;AAMb;cAAa,uBAAA;;;;;;;iBCGG,WAAA,CAAA;AAAA,iBAIA,WAAA,CAAY,MAAA,GAAS,MAAA;;;;;;;AAJrC;;iBAiBgB,W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B,EAAA;EACA,IAAA;EACA,GAAA;AAAA;AdCD;;;AAAA,UcKiB,SAAA;EAChB,EAAA;EACA,IAAA;EACA,SAAA;EACA,YAAA;EACA,MAAA;AAAA;;;;UAMgB,kBAAA,SAA2B,YAAA;EAC3C,MAAA,EAAQ,SAAA;AAAA;;;AbGT;iBakCsB,aAAA,CAAA,GAAiB,OAAA,CAAQ,YAAA;;;;iBAezB,WAAA,CAAY,UAAA,WAAqB,OAAA,CAAQ,kBAAA;;;;iBA4BzC,uBAAA,CAAA,GAA2B,OAAA,CAAQ,kBAAA;Ab5DzD;;;AAAA,iBaqFsB,qBAAA,CACrB,UAAA,UACA,OAAA,WACE,OAAA;EAAU,KAAA;EAAgB,KAAA;AAAA"}
|
|
@@ -12,7 +12,7 @@ import { z } from "zod";
|
|
|
12
12
|
* SDK Constants
|
|
13
13
|
*/
|
|
14
14
|
/** SDK version - must match package.json */
|
|
15
|
-
const VERSION = "0.3.
|
|
15
|
+
const VERSION = "0.3.1";
|
|
16
16
|
/**
|
|
17
17
|
* Default patterns to ignore when scanning repositories.
|
|
18
18
|
* Includes directories, binary files, IDE configs, and build outputs.
|
|
@@ -1820,4 +1820,4 @@ async function validateProviderModel(providerId, modelId) {
|
|
|
1820
1820
|
|
|
1821
1821
|
//#endregion
|
|
1822
1822
|
export { getToken as A, NotGitRepoError as B, getAllAgentConfigs as C, clearAuthData as D, TokenExpiredError as E, saveAuthData as F, DEFAULT_IGNORE_PATTERNS as G, RepoSourceError as H, getMapEntry as I, VERSION as K, getProjectMapPath as L, isLoggedIn as M, loadAuthData as N, getAuthPath as O, refreshAccessToken as P, resolveRepoKey as R, getAgentConfig as S, NotLoggedInError as T, getReferenceFileNameForSource as U, PathNotFoundError as V, parseRepoInput as W, parseDependencies as _, discoverRepos as a, agents as b, pruneRepos as c, matchDependenciesToReferences as d, matchDependenciesToReferencesWithRemoteCheck as f, detectManifestType as g, resolveFromNpm as h, validateProviderModel as i, getTokenOrNull as j, getAuthStatus as k, updateAllRepos as l, resolveDependencyRepo as m, listProviders as n, gcRepos as o, FALLBACK_MAPPINGS as p, listProvidersWithModels as r, getRepoStatus as s, getProvider as t, isReferenceInstalled as u, installGlobalSkill as v, AuthError as w, detectInstalledAgents as x, installReference as y, searchMap as z };
|
|
1823
|
-
//# sourceMappingURL=public-
|
|
1823
|
+
//# sourceMappingURL=public-CjA2mMwu.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-DbZeh2Mr.mjs","names":["GlobalMapSchema","ProjectMapSchema"],"sources":["../src/constants.ts","../src/repo-source.ts","../src/map.ts","../src/auth.ts","../src/agents.ts","../src/reference.ts","../src/manifest.ts","../src/dep-mappings.ts","../src/reference-matcher.ts","../src/repo-manager.ts","../src/models.ts"],"sourcesContent":["/**\n * SDK Constants\n */\n\n/** SDK version - must match package.json */\nexport const VERSION = \"0.3.0\";\n\n/**\n * Default patterns to ignore when scanning repositories.\n * Includes directories, binary files, IDE configs, and build outputs.\n */\nexport const DEFAULT_IGNORE_PATTERNS = [\n\t\".git\",\n\t\".git/**\",\n\t\".svn\",\n\t\".hg\",\n\n\t\"node_modules\",\n\t\"node_modules/**\",\n\t\"vendor\",\n\t\"vendor/**\",\n\t\".pnpm\",\n\t\".yarn\",\n\n\t\"dist\",\n\t\"dist/**\",\n\t\"build\",\n\t\"build/**\",\n\t\"out\",\n\t\"out/**\",\n\t\".next\",\n\t\".nuxt\",\n\t\".output\",\n\t\"target\",\n\t\"__pycache__\",\n\t\"*.pyc\",\n\n\t\".vscode\",\n\t\".vscode/**\",\n\t\".idea\",\n\t\".idea/**\",\n\t\"*.swp\",\n\t\"*.swo\",\n\t\".DS_Store\",\n\n\t\"*.jpg\",\n\t\"*.jpeg\",\n\t\"*.png\",\n\t\"*.gif\",\n\t\"*.ico\",\n\t\"*.webp\",\n\t\"*.svg\",\n\t\"*.bmp\",\n\t\"*.tiff\",\n\t\"*.mp4\",\n\t\"*.webm\",\n\t\"*.mov\",\n\t\"*.avi\",\n\t\"*.mkv\",\n\t\"*.mp3\",\n\t\"*.wav\",\n\t\"*.flac\",\n\t\"*.ogg\",\n\t\"*.pdf\",\n\t\"*.zip\",\n\t\"*.tar\",\n\t\"*.gz\",\n\t\"*.rar\",\n\t\"*.7z\",\n\t\"*.exe\",\n\t\"*.dll\",\n\t\"*.so\",\n\t\"*.dylib\",\n\t\"*.bin\",\n\t\"*.wasm\",\n\t\"*.woff\",\n\t\"*.woff2\",\n\t\"*.ttf\",\n\t\"*.eot\",\n\t\"*.otf\",\n\n\t\"package-lock.json\",\n\t\"yarn.lock\",\n\t\"pnpm-lock.yaml\",\n\t\"bun.lockb\",\n\t\"Cargo.lock\",\n\t\"Gemfile.lock\",\n\t\"poetry.lock\",\n\t\"composer.lock\",\n\t\"go.sum\",\n\n\t\"coverage\",\n\t\"coverage/**\",\n\t\".nyc_output\",\n\t\".coverage\",\n\t\"htmlcov\",\n\n\t\"*.log\",\n\t\"logs\",\n\t\"tmp\",\n\t\"temp\",\n\t\".tmp\",\n\t\".temp\",\n\t\".cache\",\n\n\t\".env\",\n\t\".env.*\",\n\t\"*.pem\",\n\t\"*.key\",\n] as const;\n","/**\n * Repository source parsing utilities\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { basename } from \"node:path\";\nimport type { GitProvider, LocalRepoSource, RemoteRepoSource, RepoSource } from \"@offworld/types\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { expandTilde } from \"./paths.js\";\n\nexport class RepoSourceError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RepoSourceError\";\n\t}\n}\n\nexport class PathNotFoundError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Path does not exist: ${path}`);\n\t\tthis.name = \"PathNotFoundError\";\n\t}\n}\n\nexport class NotGitRepoError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Directory is not a git repository: ${path}`);\n\t\tthis.name = \"NotGitRepoError\";\n\t}\n}\n\nconst PROVIDER_HOSTS: Record<string, GitProvider> = {\n\t\"github.com\": \"github\",\n\t\"gitlab.com\": \"gitlab\",\n\t\"bitbucket.org\": \"bitbucket\",\n};\n\nconst HTTPS_URL_REGEX =\n\t/^https?:\\/\\/(github\\.com|gitlab\\.com|bitbucket\\.org)\\/([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SSH_URL_REGEX = /^git@(github\\.com|gitlab\\.com|bitbucket\\.org):([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SHORT_FORMAT_REGEX = /^([^/:@]+)\\/([^/:@]+)$/;\n\n/**\n * Generates a short hash of a path for local repo identification\n */\nfunction hashPath(path: string): string {\n\treturn createHash(\"sha256\").update(path).digest(\"hex\").slice(0, 12);\n}\n\n/**\n * Builds a clone URL for a remote repository\n */\nfunction buildCloneUrl(provider: GitProvider, owner: string, repo: string): string {\n\tconst hosts: Record<GitProvider, string> = {\n\t\tgithub: \"github.com\",\n\t\tgitlab: \"gitlab.com\",\n\t\tbitbucket: \"bitbucket.org\",\n\t};\n\treturn `https://${hosts[provider]}/${owner}/${repo}.git`;\n}\n\n/**\n * Parses a remote repository from HTTPS URL format\n */\nfunction parseHttpsUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(HTTPS_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from SSH URL format\n */\nfunction parseSshUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SSH_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from short format (owner/repo)\n * Defaults to GitHub as provider\n */\nfunction parseShortFormat(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SHORT_FORMAT_REGEX);\n\tif (!match) return null;\n\n\tconst [, owner, repo] = match;\n\tif (!owner || !repo) return null;\n\n\tconst provider: GitProvider = \"github\";\n\tconst host = \"github.com\";\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a local repository path\n * Validates that the path exists and contains a .git directory\n */\nfunction parseLocalPath(input: string): LocalRepoSource {\n\tconst absolutePath = resolve(expandTilde(input));\n\n\tif (!existsSync(absolutePath)) {\n\t\tthrow new PathNotFoundError(absolutePath);\n\t}\n\n\tconst stats = statSync(absolutePath);\n\tif (!stats.isDirectory()) {\n\t\tthrow new RepoSourceError(`Path is not a directory: ${absolutePath}`);\n\t}\n\n\tconst gitPath = resolve(absolutePath, \".git\");\n\tif (!existsSync(gitPath)) {\n\t\tthrow new NotGitRepoError(absolutePath);\n\t}\n\n\tconst name = basename(absolutePath);\n\tconst hash = hashPath(absolutePath);\n\n\treturn {\n\t\ttype: \"local\",\n\t\tpath: absolutePath,\n\t\tname,\n\t\tqualifiedName: `local:${hash}`,\n\t};\n}\n\n/**\n * Determines if input looks like a local path\n */\nfunction isLocalPath(input: string): boolean {\n\treturn input.startsWith(\".\") || input.startsWith(\"/\") || input.startsWith(\"~\");\n}\n\n/**\n * Parses a repository input and returns a structured RepoSource\n *\n * Supported formats:\n * - owner/repo (short format, defaults to GitHub)\n * - https://github.com/owner/repo\n * - https://gitlab.com/owner/repo\n * - https://bitbucket.org/owner/repo\n * - git@github.com:owner/repo.git (SSH format)\n * - . (current directory as local repo)\n * - /absolute/path (local repo)\n *\n * @throws PathNotFoundError if local path doesn't exist\n * @throws NotGitRepoError if local path is not a git repository\n * @throws RepoSourceError for other parsing failures\n */\nexport function parseRepoInput(input: string): RepoSource {\n\tconst trimmed = input.trim();\n\n\tconst httpsResult = parseHttpsUrl(trimmed);\n\tif (httpsResult) return httpsResult;\n\n\tconst sshResult = parseSshUrl(trimmed);\n\tif (sshResult) return sshResult;\n\n\tif (isLocalPath(trimmed)) {\n\t\treturn parseLocalPath(trimmed);\n\t}\n\n\tconst shortResult = parseShortFormat(trimmed);\n\tif (shortResult) return shortResult;\n\n\tthrow new RepoSourceError(\n\t\t`Unable to parse repository input: ${input}. ` +\n\t\t\t\"Expected formats: owner/repo, https://github.com/owner/repo, git@github.com:owner/repo.git, or a local path\",\n\t);\n}\n\nexport function getReferenceFileNameForSource(source: RepoSource): string {\n\tif (source.type === \"remote\") {\n\t\treturn toReferenceFileName(source.fullName);\n\t}\n\treturn toReferenceFileName(source.name);\n}\n","/**\n * Map query helpers for fast routing without reading full map.json\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type {\n\tGlobalMap,\n\tGlobalMapRepoEntry,\n\tProjectMap,\n\tProjectMapRepoEntry,\n} from \"@offworld/types\";\nimport { GlobalMapSchema, ProjectMapSchema } from \"@offworld/types/schemas\";\nimport { Paths } from \"./paths.js\";\n\nexport interface MapEntry {\n\tscope: \"project\" | \"global\";\n\tqualifiedName: string;\n\tentry: GlobalMapRepoEntry | ProjectMapRepoEntry;\n}\n\nexport interface SearchResult {\n\tqualifiedName: string;\n\tfullName: string;\n\tlocalPath: string;\n\tprimary: string;\n\tkeywords: string[];\n\tscore: number;\n}\n\nexport interface GetMapEntryOptions {\n\tpreferProject?: boolean;\n\tcwd?: string;\n}\n\nexport interface SearchMapOptions {\n\tlimit?: number;\n\tcwd?: string;\n}\n\nfunction readGlobalMapSafe(): GlobalMap | null {\n\tconst mapPath = Paths.offworldGlobalMapPath;\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn GlobalMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction readProjectMapSafe(cwd: string): ProjectMap | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn ProjectMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Normalize input to match against repo keys.\n * Accepts: github.com:owner/repo, owner/repo, repo\n */\nfunction normalizeInput(input: string): { provider?: string; fullName: string; repoName: string } {\n\tconst trimmed = input.trim().toLowerCase();\n\n\tif (trimmed.includes(\":\")) {\n\t\tconst parts = trimmed.split(\":\", 2);\n\t\tconst provider = parts[0];\n\t\tconst fullName = parts[1] ?? \"\";\n\t\tconst repoName = fullName.split(\"/\").pop() ?? fullName;\n\t\treturn { provider, fullName, repoName };\n\t}\n\n\tif (trimmed.includes(\"/\")) {\n\t\tconst repoName = trimmed.split(\"/\").pop() ?? trimmed;\n\t\treturn { fullName: trimmed, repoName };\n\t}\n\n\treturn { fullName: trimmed, repoName: trimmed };\n}\n\n/**\n * Tokenize a string for search matching.\n * Lowercase, strip @, split on /_- and whitespace.\n */\nfunction tokenize(str: string): string[] {\n\treturn str\n\t\t.toLowerCase()\n\t\t.replace(/@/g, \"\")\n\t\t.split(/[/_\\-\\s]+/)\n\t\t.filter(Boolean);\n}\n\n/**\n * Resolve an input string to a qualified repo key in a map.\n *\n * @param input - Accepts github.com:owner/repo, owner/repo, or repo name\n * @param map - A global or project map\n * @returns The matching qualified name or null\n */\nexport function resolveRepoKey(input: string, map: GlobalMap | ProjectMap): string | null {\n\tconst { provider, fullName, repoName } = normalizeInput(input);\n\tconst keys = Object.keys(map.repos);\n\n\tif (provider) {\n\t\tconst qualifiedKey = `${provider}:${fullName}`;\n\t\tif (keys.includes(qualifiedKey)) {\n\t\t\treturn qualifiedKey;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyFullName = key.includes(\":\") ? key.split(\":\")[1] : key;\n\t\tif (keyFullName?.toLowerCase() === fullName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyRepoName = key.split(\"/\").pop()?.toLowerCase();\n\t\tif (keyRepoName === repoName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Get a map entry for a repo, preferring project map if available.\n *\n * @param input - Repo identifier (github.com:owner/repo, owner/repo, or repo)\n * @param options - Options for lookup\n * @returns Entry with scope and qualified name, or null if not found\n */\nexport function getMapEntry(input: string, options: GetMapEntryOptions = {}): MapEntry | null {\n\tconst { preferProject = true, cwd = process.cwd() } = options;\n\n\tconst projectMap = preferProject ? readProjectMapSafe(cwd) : null;\n\tconst globalMap = readGlobalMapSafe();\n\n\tif (projectMap) {\n\t\tconst key = resolveRepoKey(input, projectMap);\n\t\tif (key && projectMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"project\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: projectMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\tif (globalMap) {\n\t\tconst key = resolveRepoKey(input, globalMap);\n\t\tif (key && globalMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"global\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: globalMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Search the map for repos matching a term.\n *\n * Scoring:\n * - Exact fullName match: 100\n * - Keyword hit: 50 per keyword\n * - Partial contains in fullName: 25\n * - Partial contains in keywords: 10\n *\n * @param term - Search term\n * @param options - Search options\n * @returns Sorted list of matches\n */\nexport function searchMap(term: string, options: SearchMapOptions = {}): SearchResult[] {\n\tconst { limit = 10 } = options;\n\n\tconst globalMap = readGlobalMapSafe();\n\tif (!globalMap) return [];\n\n\tconst termTokens = tokenize(term);\n\tconst termLower = term.toLowerCase();\n\tconst results: SearchResult[] = [];\n\n\tfor (const qualifiedName of Object.keys(globalMap.repos)) {\n\t\tconst entry = globalMap.repos[qualifiedName];\n\t\tif (!entry) continue;\n\n\t\tconst fullName = qualifiedName.includes(\":\")\n\t\t\t? (qualifiedName.split(\":\")[1] ?? qualifiedName)\n\t\t\t: qualifiedName;\n\t\tconst fullNameLower = fullName.toLowerCase();\n\t\tconst keywords = entry.keywords ?? [];\n\t\tconst keywordsLower = keywords.map((k) => k.toLowerCase());\n\n\t\tlet score = 0;\n\n\t\tif (fullNameLower === termLower) {\n\t\t\tscore += 100;\n\t\t}\n\n\t\tfor (const token of termTokens) {\n\t\t\tif (keywordsLower.includes(token)) {\n\t\t\t\tscore += 50;\n\t\t\t}\n\t\t}\n\n\t\tif (fullNameLower.includes(termLower) && score < 100) {\n\t\t\tscore += 25;\n\t\t}\n\n\t\tfor (const kw of keywordsLower) {\n\t\t\tif (kw.includes(termLower)) {\n\t\t\t\tscore += 10;\n\t\t\t}\n\t\t}\n\n\t\tconst fullNameTokens = tokenize(fullName);\n\t\tfor (const token of termTokens) {\n\t\t\tif (fullNameTokens.includes(token)) {\n\t\t\t\tscore += 30;\n\t\t\t}\n\t\t}\n\n\t\tif (score > 0) {\n\t\t\tresults.push({\n\t\t\t\tqualifiedName,\n\t\t\t\tfullName,\n\t\t\t\tlocalPath: entry.localPath,\n\t\t\t\tprimary: entry.primary,\n\t\t\t\tkeywords,\n\t\t\t\tscore,\n\t\t\t});\n\t\t}\n\t}\n\n\tresults.sort((a, b) => {\n\t\tif (b.score !== a.score) return b.score - a.score;\n\t\treturn a.fullName.localeCompare(b.fullName);\n\t});\n\n\treturn results.slice(0, limit);\n}\n\n/**\n * Get the project map path if it exists in cwd.\n */\nexport function getProjectMapPath(cwd: string = process.cwd()): string | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\treturn existsSync(mapPath) ? mapPath : null;\n}\n","/**\n * Authentication utilities for offworld CLI\n */\n\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport { WorkOSTokenResponseSchema } from \"@offworld/types\";\nimport { Paths } from \"./paths\";\n\nconst AuthDataSchema = z.object({\n\ttoken: z.string(),\n\texpiresAt: z.string().optional(),\n\tworkosId: z.string().optional(),\n\trefreshToken: z.string().optional(),\n\temail: z.string().optional(),\n});\n\nexport interface AuthData {\n\ttoken: string;\n\texpiresAt?: string;\n\tworkosId?: string;\n\trefreshToken?: string;\n\temail?: string;\n}\n\n/** Authentication status */\nexport interface AuthStatus {\n\tisLoggedIn: boolean;\n\temail?: string;\n\tworkosId?: string;\n\texpiresAt?: string;\n}\n\nexport class AuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class NotLoggedInError extends AuthError {\n\tconstructor(message = \"Not logged in. Please run 'ow auth login' first.\") {\n\t\tsuper(message);\n\t\tthis.name = \"NotLoggedInError\";\n\t}\n}\n\nexport class TokenExpiredError extends AuthError {\n\tconstructor(message = \"Session expired. Please run 'ow auth login' again.\") {\n\t\tsuper(message);\n\t\tthis.name = \"TokenExpiredError\";\n\t}\n}\n\nfunction extractJwtExpiration(token: string): string | undefined {\n\ttry {\n\t\tconst parts = token.split(\".\");\n\t\tif (parts.length !== 3) return undefined;\n\n\t\tconst payload = parts[1];\n\t\tif (!payload) return undefined;\n\n\t\tconst decoded = JSON.parse(Buffer.from(payload, \"base64\").toString(\"utf-8\"));\n\t\tif (typeof decoded.exp !== \"number\") return undefined;\n\n\t\treturn new Date(decoded.exp * 1000).toISOString();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function getAuthPath(): string {\n\treturn Paths.authFile;\n}\n\nexport function saveAuthData(data: AuthData): void {\n\tconst authPath = getAuthPath();\n\tconst authDir = dirname(authPath);\n\n\tif (!existsSync(authDir)) {\n\t\tmkdirSync(authDir, { recursive: true });\n\t}\n\n\twriteFileSync(authPath, JSON.stringify(data, null, 2), \"utf-8\");\n\tchmodSync(authPath, 0o600);\n}\n\n/**\n * Loads authentication data from ~/.local/share/offworld/auth.json\n * Returns null if file doesn't exist or is invalid\n */\nexport function loadAuthData(): AuthData | null {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(authPath, \"utf-8\");\n\t\tconst json = JSON.parse(content);\n\t\tconst parsed = AuthDataSchema.safeParse(json);\n\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn parsed.data;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Clears stored authentication data\n * @returns true if auth file was deleted, false if it didn't exist\n */\nexport function clearAuthData(): boolean {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tunlinkSync(authPath);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function getToken(): Promise<string> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\tthrow new NotLoggedInError();\n\t}\n\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new TokenExpiredError();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new TokenExpiredError();\n\t\t}\n\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\treturn data.token;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn data.token;\n}\n\n/**\n * Gets the current authentication token, or null if not logged in\n * Does not throw errors\n */\nexport async function getTokenOrNull(): Promise<string | null> {\n\ttry {\n\t\treturn await getToken();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function isLoggedIn(): Promise<boolean> {\n\treturn (await getTokenOrNull()) !== null;\n}\n\nexport async function getAuthStatus(): Promise<AuthStatus> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\treturn { isLoggedIn: false };\n\t}\n\n\t// Extract expiration from JWT if not already saved (mirrors getToken() logic)\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\t// Token already expired - attempt refresh\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\treturn { isLoggedIn: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { isLoggedIn: false };\n\t\t}\n\n\t\t// Proactive refresh: token expires within 1 minute\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\t// Refresh failed, but token still valid - return current data\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tworkosId: data.workosId,\n\t\t\t\t\t\texpiresAt: expiresAtStr,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tisLoggedIn: true,\n\t\temail: data.email,\n\t\tworkosId: data.workosId,\n\t\texpiresAt: expiresAtStr,\n\t};\n}\n\nconst WORKOS_API = \"https://api.workos.com\";\n\n// Production WorkOS client ID - dev can override via WORKOS_CLIENT_ID env var\nconst PRODUCTION_WORKOS_CLIENT_ID = \"client_01KFAD76TNGN02AP96982HG35E\";\n\nfunction getWorkosClientId(): string {\n\treturn process.env.WORKOS_CLIENT_ID ?? PRODUCTION_WORKOS_CLIENT_ID;\n}\n\nexport async function refreshAccessToken(): Promise<AuthData> {\n\tconst data = loadAuthData();\n\n\tif (!data?.refreshToken) {\n\t\tthrow new AuthError(\"No refresh token available. Please log in again.\");\n\t}\n\n\ttry {\n\t\tconst response = await fetch(`${WORKOS_API}/user_management/authenticate`, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\trefresh_token: data.refreshToken,\n\t\t\t\tclient_id: getWorkosClientId(),\n\t\t\t}),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst error = await response.text();\n\t\t\tthrow new AuthError(`Token refresh failed: ${error}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\t\tconst tokenData = WorkOSTokenResponseSchema.parse(json);\n\n\t\tconst newAuthData: AuthData = {\n\t\t\ttoken: tokenData.access_token,\n\t\t\temail: tokenData.user.email,\n\t\t\tworkosId: tokenData.user.id,\n\t\t\trefreshToken: tokenData.refresh_token,\n\t\t\texpiresAt: tokenData.expires_at\n\t\t\t\t? new Date(tokenData.expires_at * 1000).toISOString()\n\t\t\t\t: extractJwtExpiration(tokenData.access_token),\n\t\t};\n\n\t\tsaveAuthData(newAuthData);\n\t\treturn newAuthData;\n\t} catch (error) {\n\t\tif (error instanceof AuthError) throw error;\n\t\tthrow new AuthError(\n\t\t\t`Failed to refresh token: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n","/**\n * Agent Registry & Auto-Detection\n *\n * Centralized registry of supported AI coding agents with their\n * skill directory locations and detection functions.\n */\n\nimport { existsSync } from \"node:fs\";\nimport type { Agent } from \"@offworld/types\";\nimport { expandTilde } from \"./paths\";\n\nexport interface AgentConfig {\n\t/** Agent identifier (matches AgentSchema enum) */\n\tname: Agent;\n\t/** Human-readable name for display */\n\tdisplayName: string;\n\t/** Project-level skill directory (relative path) */\n\tskillsDir: string;\n\t/** User-level skill directory (absolute with ~) */\n\tglobalSkillsDir: string;\n\t/** Check if this agent is installed on the system */\n\tdetectInstalled: () => boolean;\n}\n\nexport const agents: Record<Agent, AgentConfig> = {\n\topencode: {\n\t\tname: \"opencode\",\n\t\tdisplayName: \"OpenCode\",\n\t\tskillsDir: \".opencode/skills\",\n\t\tglobalSkillsDir: \"~/.config/opencode/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/opencode\")),\n\t},\n\t\"claude-code\": {\n\t\tname: \"claude-code\",\n\t\tdisplayName: \"Claude Code\",\n\t\tskillsDir: \".claude/skills\",\n\t\tglobalSkillsDir: \"~/.claude/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.claude\")),\n\t},\n\tcodex: {\n\t\tname: \"codex\",\n\t\tdisplayName: \"Codex (OpenAI)\",\n\t\tskillsDir: \".codex/skills\",\n\t\tglobalSkillsDir: \"~/.codex/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.codex\")),\n\t},\n\tamp: {\n\t\tname: \"amp\",\n\t\tdisplayName: \"Amp\",\n\t\tskillsDir: \".agents/skills\",\n\t\tglobalSkillsDir: \"~/.config/agents/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/amp\")),\n\t},\n\tantigravity: {\n\t\tname: \"antigravity\",\n\t\tdisplayName: \"Antigravity\",\n\t\tskillsDir: \".agent/skills\",\n\t\tglobalSkillsDir: \"~/.gemini/antigravity/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.gemini/antigravity\")),\n\t},\n\tcursor: {\n\t\tname: \"cursor\",\n\t\tdisplayName: \"Cursor\",\n\t\tskillsDir: \".cursor/skills\",\n\t\tglobalSkillsDir: \"~/.cursor/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.cursor\")),\n\t},\n};\n\n/**\n * Detect which agents are installed on the system.\n * Checks for the existence of each agent's config directory.\n *\n * @returns Array of installed agent identifiers\n */\nexport function detectInstalledAgents(): Agent[] {\n\tconst installed: Agent[] = [];\n\n\tfor (const config of Object.values(agents)) {\n\t\tif (config.detectInstalled()) {\n\t\t\tinstalled.push(config.name);\n\t\t}\n\t}\n\n\treturn installed;\n}\n\n/**\n * Get the configuration for a specific agent.\n *\n * @param type - Agent identifier\n * @returns AgentConfig for the specified agent\n */\nexport function getAgentConfig(type: Agent): AgentConfig {\n\treturn agents[type];\n}\n\n/**\n * Get all agent configurations as an array.\n *\n * @returns Array of all agent configurations\n */\nexport function getAllAgentConfigs(): AgentConfig[] {\n\treturn Object.values(agents);\n}\n","import {\n\tmkdirSync,\n\twriteFileSync,\n\treadFileSync,\n\tlstatSync,\n\tunlinkSync,\n\trmSync,\n\tsymlinkSync,\n\texistsSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport { loadConfig, toMetaDirName, toReferenceFileName } from \"./config.js\";\nimport { agents } from \"./agents.js\";\nimport { expandTilde, Paths } from \"./paths.js\";\nimport { readGlobalMap, writeGlobalMap } from \"./index-manager.js\";\n\nconst PackageJsonKeywordsSchema = z.object({\n\tname: z.string().optional(),\n\tkeywords: z.array(z.string()).optional(),\n});\n\nexport interface InstallReferenceMeta {\n\t/** ISO timestamp when the reference was generated */\n\treferenceUpdatedAt: string;\n\t/** Git commit SHA at time of generation */\n\tcommitSha: string;\n\t/** SDK version used for generation */\n\tversion: string;\n}\n\nfunction normalizeKeyword(value: string): string[] {\n\tconst trimmed = value.trim();\n\tif (!trimmed) return [];\n\tconst normalized = trimmed.toLowerCase();\n\tconst tokens = new Set<string>();\n\n\tconst addToken = (token: string): void => {\n\t\tconst cleaned = token.trim().toLowerCase();\n\t\tif (cleaned.length < 2) return;\n\t\ttokens.add(cleaned);\n\t};\n\n\taddToken(normalized);\n\taddToken(normalized.replaceAll(\"/\", \"-\"));\n\taddToken(normalized.replaceAll(\"/\", \"\"));\n\n\tfor (const token of normalized.split(/[\\s/_-]+/)) {\n\t\taddToken(token);\n\t}\n\n\tif (normalized.startsWith(\"@\")) {\n\t\taddToken(normalized.slice(1));\n\t}\n\n\treturn Array.from(tokens);\n}\n\nfunction deriveKeywords(fullName: string, localPath: string, referenceContent: string): string[] {\n\tconst keywords = new Set<string>();\n\n\tconst addKeywords = (value: string): void => {\n\t\tfor (const token of normalizeKeyword(value)) {\n\t\t\tkeywords.add(token);\n\t\t}\n\t};\n\n\taddKeywords(fullName);\n\n\tconst headingMatch = referenceContent.match(/^#\\s+(.+)$/m);\n\tif (headingMatch?.[1]) {\n\t\taddKeywords(headingMatch[1]);\n\t}\n\n\tconst packageJsonPath = join(localPath, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\t\tconst json = JSON.parse(content);\n\t\t\tconst parsed = PackageJsonKeywordsSchema.safeParse(json);\n\n\t\t\tif (parsed.success) {\n\t\t\t\tif (parsed.data.name) {\n\t\t\t\t\taddKeywords(parsed.data.name);\n\t\t\t\t}\n\n\t\t\t\tif (parsed.data.keywords) {\n\t\t\t\t\tfor (const keyword of parsed.data.keywords) {\n\t\t\t\t\t\taddKeywords(keyword);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\treturn Array.from(keywords);\n}\n\n/**\n * Ensure a symlink exists, removing any existing file/directory at the path\n */\nfunction ensureSymlink(target: string, linkPath: string): void {\n\ttry {\n\t\tconst stat = lstatSync(linkPath);\n\t\tif (stat.isSymbolicLink()) {\n\t\t\tunlinkSync(linkPath);\n\t\t} else if (stat.isDirectory()) {\n\t\t\trmSync(linkPath, { recursive: true });\n\t\t} else {\n\t\t\tunlinkSync(linkPath);\n\t\t}\n\t} catch {}\n\n\tconst linkDir = join(linkPath, \"..\");\n\tmkdirSync(linkDir, { recursive: true });\n\tsymlinkSync(target, linkPath, \"dir\");\n}\n\n/**\n * Static template for the global SKILL.md file.\n * This is the single routing skill that all agents see.\n */\nconst GLOBAL_SKILL_TEMPLATE = `---\nname: offworld\ndescription: Routes queries to Offworld reference files. Find and read per-repo references for dependency knowledge.\nallowed-tools: Bash(ow:*) Read\n---\n\n# Offworld Reference Router\n\nUse \\`ow\\` to locate and read Offworld reference files for dependencies.\n\n## What This Does\n\n- Finds references for libraries and repos\n- Returns paths for reference files and local clones\n- Helps you read the right context fast\n\n## When to Use\n\n- You need docs or patterns for a dependency\n- You want the verified reference instead of web search\n- You are about to work inside a repo clone\n\n## Prerequisites\n\nCheck that the CLI is available:\n\n\\`\\`\\`bash\now --version\n\\`\\`\\`\n\nIf \\`ow\\` is not available, install it:\n\n\\`\\`\\`bash\ncurl -fsSL https://offworld.sh/install | bash\n\\`\\`\\`\n\n## Setup\n\nInitialize Offworld once per machine:\n\n\\`\\`\\`bash\now init\n\\`\\`\\`\n\nFor a specific project, build a project map:\n\n\\`\\`\\`bash\now project init\n\\`\\`\\`\n\n## Usage\n\n**Find a reference:**\n\\`\\`\\`bash\now map search <term> # search by name or keyword\now map show <repo> # get info for specific repo\n\\`\\`\\`\n\n**Get paths for tools:**\n\\`\\`\\`bash\now map show <repo> --ref # reference file path (use with Read)\now map show <repo> --path # clone directory path\n\\`\\`\\`\n\n**Example workflow:**\n\\`\\`\\`bash\n# 1. Find the repo\now map search zod\n\n# 2. Get reference path\now map show colinhacks/zod --ref\n# Output: /Users/.../.local/share/offworld/skill/offworld/references/colinhacks-zod.md\n\n# 3. Read the reference with the path from step 2\n\\`\\`\\`\n\n## If Reference Not Found\n\n\\`\\`\\`bash\now pull <owner/repo> # clone + generate reference\now project init # scan project deps, install references\n\\`\\`\\`\n\n## Notes\n\n- Project map (\\`.offworld/map.json\\`) takes precedence over global map when present\n- Reference files are markdown with API docs, patterns, best practices\n- Clone paths useful for exploring source code after reading reference\n\n## Additional Resources\n\n- Docs: https://offworld.sh/cli\n`;\n\n/**\n * Ensures the global SKILL.md exists and symlinks the offworld/ directory to all agent skill directories.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/SKILL.md (static routing template)\n * - ~/.local/share/offworld/skill/offworld/assets/ (for map.json)\n * - ~/.local/share/offworld/skill/offworld/references/ (for reference files)\n * - Symlinks entire offworld/ directory to each agent's skill directory\n */\nexport function installGlobalSkill(): void {\n\tconst config = loadConfig();\n\n\tmkdirSync(Paths.offworldSkillDir, { recursive: true });\n\tmkdirSync(Paths.offworldAssetsDir, { recursive: true });\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\n\tconst skillPath = join(Paths.offworldSkillDir, \"SKILL.md\");\n\tif (!existsSync(skillPath)) {\n\t\twriteFileSync(skillPath, GLOBAL_SKILL_TEMPLATE, \"utf-8\");\n\t}\n\n\tconst configuredAgents = config.agents ?? [];\n\tfor (const agentName of configuredAgents) {\n\t\tconst agentConfig = agents[agentName];\n\t\tif (agentConfig) {\n\t\t\tconst agentSkillDir = expandTilde(join(agentConfig.globalSkillsDir, \"offworld\"));\n\t\t\tensureSymlink(Paths.offworldSkillDir, agentSkillDir);\n\t\t}\n\t}\n}\n\n/**\n * Install a reference file for a specific repository.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/references/{owner-repo}.md\n * - ~/.local/share/offworld/meta/{owner-repo}/meta.json\n * - Updates global map with reference info\n *\n * @param qualifiedName - Qualified key for map storage (e.g., \"github.com:owner/repo\" or \"local:name\")\n * @param fullName - Full repo name for file naming (e.g., \"owner/repo\")\n * @param localPath - Absolute path to the cloned repository\n * @param referenceContent - The generated reference markdown content\n * @param meta - Metadata about the generation (referenceUpdatedAt, commitSha, version)\n * @param keywords - Optional array of keywords for search/routing\n */\nexport function installReference(\n\tqualifiedName: string,\n\tfullName: string,\n\tlocalPath: string,\n\treferenceContent: string,\n\tmeta: InstallReferenceMeta,\n\tkeywords?: string[],\n): void {\n\tinstallGlobalSkill();\n\n\tconst referenceFileName = toReferenceFileName(fullName);\n\tconst metaDirName = toMetaDirName(fullName);\n\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\twriteFileSync(referencePath, referenceContent, \"utf-8\");\n\n\tconst metaDir = join(Paths.metaDir, metaDirName);\n\tmkdirSync(metaDir, { recursive: true });\n\tconst metaJson = JSON.stringify(meta, null, 2);\n\twriteFileSync(join(metaDir, \"meta.json\"), metaJson, \"utf-8\");\n\n\tconst map = readGlobalMap();\n\tconst existingEntry = map.repos[qualifiedName];\n\tconst legacyProviderMap: Record<string, string> = {\n\t\t\"github.com\": \"github\",\n\t\t\"gitlab.com\": \"gitlab\",\n\t\t\"bitbucket.org\": \"bitbucket\",\n\t};\n\tconst [host] = qualifiedName.split(\":\");\n\tconst legacyProvider = host ? legacyProviderMap[host] : undefined;\n\tconst legacyQualifiedName = legacyProvider ? `${legacyProvider}:${fullName}` : undefined;\n\tconst legacyEntry = legacyQualifiedName ? map.repos[legacyQualifiedName] : undefined;\n\n\tconst references = [...(existingEntry?.references ?? []), ...(legacyEntry?.references ?? [])];\n\tif (!references.includes(referenceFileName)) {\n\t\treferences.push(referenceFileName);\n\t}\n\n\tconst derivedKeywords = keywords ?? deriveKeywords(fullName, localPath, referenceContent);\n\tconst keywordsSet = new Set<string>([\n\t\t...(existingEntry?.keywords ?? []),\n\t\t...(legacyEntry?.keywords ?? []),\n\t\t...derivedKeywords,\n\t]);\n\n\tmap.repos[qualifiedName] = {\n\t\tlocalPath,\n\t\treferences,\n\t\tprimary: referenceFileName,\n\t\tkeywords: Array.from(keywordsSet),\n\t\tupdatedAt: new Date().toISOString(),\n\t};\n\n\tif (legacyQualifiedName && legacyQualifiedName in map.repos) {\n\t\tdelete map.repos[legacyQualifiedName];\n\t}\n\n\twriteGlobalMap(map);\n}\n","/**\n * Dependency manifest parsing for multiple package ecosystems\n */\n\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport type ManifestType = \"npm\" | \"python\" | \"rust\" | \"go\" | \"unknown\";\n\nexport interface Dependency {\n\tname: string;\n\tversion?: string;\n\tdev: boolean;\n}\n\nconst DEFAULT_IGNORED_DIRS = new Set([\n\t\".git\",\n\t\".offworld\",\n\t\".turbo\",\n\t\"build\",\n\t\"dist\",\n\t\"node_modules\",\n\t\"out\",\n]);\n\n/**\n * Detects the manifest type in a directory\n */\nexport function detectManifestType(dir: string): ManifestType {\n\tif (existsSync(join(dir, \"package.json\"))) return \"npm\";\n\tif (existsSync(join(dir, \"pyproject.toml\"))) return \"python\";\n\tif (existsSync(join(dir, \"Cargo.toml\"))) return \"rust\";\n\tif (existsSync(join(dir, \"go.mod\"))) return \"go\";\n\tif (existsSync(join(dir, \"requirements.txt\"))) return \"python\";\n\treturn \"unknown\";\n}\n\n/**\n * Parses dependencies from manifest files\n */\nexport function parseDependencies(dir: string): Dependency[] {\n\tconst type = detectManifestType(dir);\n\n\tswitch (type) {\n\t\tcase \"npm\":\n\t\t\treturn parseNpmDependencies(dir);\n\t\tcase \"python\":\n\t\t\treturn existsSync(join(dir, \"pyproject.toml\"))\n\t\t\t\t? parsePyprojectToml(join(dir, \"pyproject.toml\"))\n\t\t\t\t: parseRequirementsTxt(join(dir, \"requirements.txt\"));\n\t\tcase \"rust\":\n\t\t\treturn parseCargoToml(join(dir, \"Cargo.toml\"));\n\t\tcase \"go\":\n\t\t\treturn parseGoMod(join(dir, \"go.mod\"));\n\t\tdefault:\n\t\t\treturn [];\n\t}\n}\n\nfunction parseNpmDependencies(dir: string): Dependency[] {\n\tconst rootPath = join(dir, \"package.json\");\n\tconst rootDeps = parsePackageJson(rootPath);\n\tconst workspaceDeps = parseWorkspaceDependencies(dir);\n\treturn mergeDependencies(rootDeps, workspaceDeps).sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction parseWorkspaceDependencies(dir: string): Dependency[] {\n\tconst workspacePatterns = getWorkspacePatterns(dir);\n\tif (workspacePatterns.length === 0) return [];\n\n\tconst packageJsonPaths = resolveWorkspacePackageJsonPaths(dir, workspacePatterns);\n\tconst deps: Dependency[] = [];\n\tfor (const path of packageJsonPaths) {\n\t\tdeps.push(...parsePackageJson(path));\n\t}\n\n\treturn mergeDependencies([], deps);\n}\n\nfunction getWorkspacePatterns(dir: string): string[] {\n\tconst patterns = new Set<string>();\n\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\tconst rootJson = readJson(packageJsonPath);\n\t\tconst workspaces = rootJson?.workspaces;\n\t\tif (Array.isArray(workspaces)) {\n\t\t\tfor (const pattern of workspaces) {\n\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t}\n\t\t} else if (workspaces && typeof workspaces === \"object\") {\n\t\t\tconst packagesField = (workspaces as { packages?: unknown }).packages;\n\t\t\tif (Array.isArray(packagesField)) {\n\t\t\t\tfor (const pattern of packagesField) {\n\t\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst pnpmWorkspacePath = existsSync(join(dir, \"pnpm-workspace.yaml\"))\n\t\t? join(dir, \"pnpm-workspace.yaml\")\n\t\t: existsSync(join(dir, \"pnpm-workspace.yml\"))\n\t\t\t? join(dir, \"pnpm-workspace.yml\")\n\t\t\t: null;\n\n\tif (pnpmWorkspacePath) {\n\t\tfor (const pattern of parsePnpmWorkspacePackages(pnpmWorkspacePath)) {\n\t\t\tpatterns.add(pattern);\n\t\t}\n\t}\n\n\treturn Array.from(patterns);\n}\n\nfunction resolveWorkspacePackageJsonPaths(dir: string, patterns: string[]): string[] {\n\tconst includePatterns = patterns.filter((pattern) => !pattern.startsWith(\"!\"));\n\tconst excludePatterns = patterns\n\t\t.filter((pattern) => pattern.startsWith(\"!\"))\n\t\t.map((pattern) => pattern.slice(1));\n\n\tif (includePatterns.length === 0) return [];\n\n\tconst includeRegexes = includePatterns.map(patternToRegex);\n\tconst excludeRegexes = excludePatterns.map(patternToRegex);\n\n\tconst matches: string[] = [];\n\tconst directories = walkDirectories(dir);\n\n\tfor (const relativePath of directories) {\n\t\tif (!includeRegexes.some((regex) => regex.test(relativePath))) continue;\n\t\tif (excludeRegexes.some((regex) => regex.test(relativePath))) continue;\n\n\t\tconst packageJsonPath = join(dir, relativePath, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tmatches.push(packageJsonPath);\n\t\t}\n\t}\n\n\treturn Array.from(new Set(matches));\n}\n\nfunction walkDirectories(root: string): string[] {\n\tconst results: string[] = [];\n\tconst stack: string[] = [\"\"];\n\n\twhile (stack.length > 0) {\n\t\tconst relativePath = stack.pop();\n\t\tconst currentPath = relativePath ? join(root, relativePath) : root;\n\n\t\tlet entries: Dirent[];\n\t\ttry {\n\t\t\tentries = readdirSync(currentPath, { withFileTypes: true }) as Dirent[];\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory()) continue;\n\t\t\tif (DEFAULT_IGNORED_DIRS.has(entry.name)) continue;\n\n\t\t\tconst nextRelative = relativePath ? `${relativePath}/${entry.name}` : entry.name;\n\t\t\tresults.push(nextRelative);\n\t\t\tstack.push(nextRelative);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction patternToRegex(pattern: string): RegExp {\n\tlet normalized = pattern.trim().replace(/\\\\/g, \"/\");\n\tif (normalized.startsWith(\"./\")) normalized = normalized.slice(2);\n\tif (normalized.endsWith(\"/\")) normalized = normalized.slice(0, -1);\n\n\tconst escaped = normalized.replace(/[.+^${}()|[\\]\\\\*]/g, \"\\\\$&\");\n\tconst withGlob = escaped.replace(/\\\\\\*\\\\\\*/g, \".*\").replace(/\\\\\\*/g, \"[^/]+\");\n\n\treturn new RegExp(`^${withGlob}$`);\n}\n\nfunction parsePnpmWorkspacePackages(path: string): string[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst patterns: string[] = [];\n\t\tlet inPackages = false;\n\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tif (/^packages\\s*:/.test(trimmed)) {\n\t\t\t\tinPackages = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!inPackages) continue;\n\n\t\t\tconst entryMatch = trimmed.match(/^-\\s*(.+)$/);\n\t\t\tif (entryMatch?.[1]) {\n\t\t\t\tconst value = entryMatch[1].trim().replace(/^['\"]|['\"]$/g, \"\");\n\t\t\t\tif (value) patterns.push(value);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!line.startsWith(\" \") && !line.startsWith(\"\\t\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn patterns;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nfunction readJson(path: string): Record<string, unknown> | null {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\treturn JSON.parse(content) as Record<string, unknown>;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction mergeDependencies(base: Dependency[], incoming: Dependency[]): Dependency[] {\n\tconst map = new Map<string, Dependency>();\n\n\tfor (const dep of [...base, ...incoming]) {\n\t\tconst existing = map.get(dep.name);\n\t\tif (!existing) {\n\t\t\tmap.set(dep.name, { ...dep });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst dev = existing.dev && dep.dev;\n\t\tconst version = existing.version ?? dep.version;\n\t\tmap.set(dep.name, { name: dep.name, version, dev });\n\t}\n\n\treturn Array.from(map.values());\n}\n\n/**\n * Parse package.json dependencies\n */\nfunction parsePackageJson(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst pkg = JSON.parse(content);\n\t\tconst deps: Dependency[] = [];\n\n\t\tif (pkg.dependencies && typeof pkg.dependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.dependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.devDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: true });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.peerDependencies && typeof pkg.peerDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.peerDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.optionalDependencies && typeof pkg.optionalDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.optionalDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse pyproject.toml dependencies\n */\nfunction parsePyprojectToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[project\\.dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/[\"']([a-zA-Z0-9_-]+)(?:[>=<~!]+([^\"']+))?[\"']/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse Cargo.toml dependencies\n */\nfunction parseCargoToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst simpleMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*\"([^\"]+)\"/);\n\t\t\tconst tableMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*{.*version\\s*=\\s*\"([^\"]+)\"/);\n\n\t\t\tif (simpleMatch?.[1] && simpleMatch[2]) {\n\t\t\t\tdeps.push({ name: simpleMatch[1], version: simpleMatch[2], dev: false });\n\t\t\t} else if (tableMatch?.[1] && tableMatch[2]) {\n\t\t\t\tdeps.push({ name: tableMatch[1], version: tableMatch[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse go.mod dependencies\n */\nfunction parseGoMod(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst requireSection = content.match(/require\\s*\\(([\\s\\S]*?)\\)/);\n\t\tif (!requireSection?.[1]) {\n\t\t\tconst singleRequire = content.match(/require\\s+([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (singleRequire?.[1] && singleRequire[2]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: singleRequire[1],\n\t\t\t\t\tversion: singleRequire[2],\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn deps;\n\t\t}\n\n\t\tconst lines = requireSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/^\\s*([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (match?.[1] && match[2]) {\n\t\t\t\tdeps.push({ name: match[1], version: match[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse requirements.txt dependencies\n */\nfunction parseRequirementsTxt(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst lines = content.split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tconst match = trimmed.match(/^([a-zA-Z0-9_-]+)(?:[>=<~!]+(.+))?/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n","/**\n * Dependency name to GitHub repo resolution:\n * 1. Query npm registry for repository.url\n * 2. Fall back to FALLBACK_MAPPINGS for packages missing repository field\n * 3. Return unknown (caller handles)\n */\n\nimport { NpmPackageResponseSchema } from \"@offworld/types\";\n\nexport type ResolvedDep = {\n\tdep: string;\n\trepo: string | null;\n\tsource: \"npm\" | \"fallback\" | \"unknown\";\n};\n\n/**\n * Fallback mappings for packages where npm registry doesn't have repository.url.\n * Only add packages here that genuinely don't have the field set.\n */\nexport const FALLBACK_MAPPINGS: Record<string, string> = {\n\t\"@convex-dev/react-query\": \"get-convex/convex-react-query\",\n\t\"@opencode-ai/sdk\": \"anomalyco/opencode-sdk-js\",\n};\n\n/**\n * Parse GitHub repo from various git URL formats.\n * Handles:\n * - git+https://github.com/owner/repo.git\n * - https://github.com/owner/repo\n * - git://github.com/owner/repo.git\n * - github:owner/repo\n */\nfunction parseGitHubUrl(url: string): string | null {\n\tconst patterns = [\n\t\t/github\\.com[/:]([\\w-]+)\\/([\\w.-]+?)(?:\\.git)?$/,\n\t\t/^github:([\\w-]+)\\/([\\w.-]+)$/,\n\t];\n\n\tfor (const pattern of patterns) {\n\t\tconst match = url.match(pattern);\n\t\tif (match) {\n\t\t\treturn `${match[1]}/${match[2]}`;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Fallback to npm registry to extract repository.url.\n * Returns null if package not found, no repo field, or not a GitHub repo.\n */\nexport async function resolveFromNpm(packageName: string): Promise<string | null> {\n\ttry {\n\t\tconst res = await fetch(`https://registry.npmjs.org/${packageName}`);\n\t\tif (!res.ok) return null;\n\n\t\tconst json = await res.json();\n\t\tconst result = NpmPackageResponseSchema.safeParse(json);\n\t\tif (!result.success) return null;\n\n\t\tconst repoUrl = result.data.repository?.url;\n\t\tif (!repoUrl) return null;\n\n\t\treturn parseGitHubUrl(repoUrl);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Resolution order:\n * 1. Query npm registry for repository.url\n * 2. Check FALLBACK_MAPPINGS for packages missing repository field\n * 3. Return unknown\n */\nexport async function resolveDependencyRepo(dep: string): Promise<ResolvedDep> {\n\tconst npmRepo = await resolveFromNpm(dep);\n\tif (npmRepo) {\n\t\treturn { dep, repo: npmRepo, source: \"npm\" };\n\t}\n\n\tif (dep in FALLBACK_MAPPINGS) {\n\t\treturn { dep, repo: FALLBACK_MAPPINGS[dep] ?? null, source: \"fallback\" };\n\t}\n\n\treturn { dep, repo: null, source: \"unknown\" };\n}\n","/**\n * Reference matching utilities for dependency resolution\n *\n * Maps dependencies to their reference status (installed, remote, generate, unknown)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\nimport type { ResolvedDep } from \"./dep-mappings.js\";\n\nexport type ReferenceStatus = \"installed\" | \"remote\" | \"generate\" | \"unknown\";\n\nexport interface ReferenceMatch {\n\t/** Dependency name */\n\tdep: string;\n\t/** GitHub repo (owner/repo) or null if unknown */\n\trepo: string | null;\n\t/** Reference availability status */\n\tstatus: ReferenceStatus;\n\t/** Resolution source: 'npm' | 'fallback' | 'unknown' */\n\tsource: \"npm\" | \"fallback\" | \"unknown\";\n}\n\n/**\n * Check if a reference is installed locally.\n * A reference is considered installed if {owner-repo}.md exists in offworld/references/.\n *\n * @param repo - Repo name in owner/repo format\n * @returns true if reference is installed locally\n */\nexport function isReferenceInstalled(repo: string): boolean {\n\tconst referenceFileName = toReferenceFileName(repo);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\treturn existsSync(referencePath);\n}\n\n/**\n * Match dependencies to their reference availability status.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Array of reference matches with status\n */\nexport function matchDependenciesToReferences(resolvedDeps: ResolvedDep[]): ReferenceMatch[] {\n\treturn resolvedDeps.map((dep) => {\n\t\tif (!dep.repo) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: null,\n\t\t\t\tstatus: \"unknown\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: dep.repo,\n\t\t\t\tstatus: \"installed\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tdep: dep.dep,\n\t\t\trepo: dep.repo,\n\t\t\tstatus: \"generate\",\n\t\t\tsource: dep.source,\n\t\t};\n\t});\n}\n\n/**\n * Match dependencies to their reference availability status with remote check.\n * This is async because it checks the remote server for each dependency.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Promise of array of reference matches with status\n */\nexport async function matchDependenciesToReferencesWithRemoteCheck(\n\tresolvedDeps: ResolvedDep[],\n): Promise<ReferenceMatch[]> {\n\tconst { checkRemote } = await import(\"./sync.js\");\n\tconst results = await Promise.all(\n\t\tresolvedDeps.map(async (dep) => {\n\t\t\tif (!dep.repo) {\n\t\t\t\treturn {\n\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\trepo: null,\n\t\t\t\t\tstatus: \"unknown\" as const,\n\t\t\t\t\tsource: dep.source,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\t\treturn {\n\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\trepo: dep.repo,\n\t\t\t\t\tstatus: \"installed\" as const,\n\t\t\t\t\tsource: dep.source,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst remote = await checkRemote(dep.repo);\n\t\t\t\tif (remote.exists) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\t\trepo: dep.repo,\n\t\t\t\t\t\tstatus: \"remote\" as const,\n\t\t\t\t\t\tsource: dep.source,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Network error - fall through to generate\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: dep.repo,\n\t\t\t\tstatus: \"generate\" as const,\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn results;\n}\n","import { existsSync, statSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { updateRepo, GitError } from \"./clone.js\";\nimport { readGlobalMap, removeGlobalMapEntry, upsertGlobalMapEntry } from \"./index-manager.js\";\nimport { loadConfig, getRepoRoot } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\n\nexport interface RepoStatusSummary {\n\ttotal: number;\n\twithReference: number;\n\tmissing: number;\n\tdiskBytes: number;\n}\n\nexport interface RepoStatusOptions {\n\tonProgress?: (current: number, total: number, repo: string) => void;\n}\n\nexport interface UpdateAllOptions {\n\tpattern?: string;\n\tdryRun?: boolean;\n\t/** Convert shallow clones to full clones */\n\tunshallow?: boolean;\n\tonProgress?: (\n\t\trepo: string,\n\t\tstatus: \"updating\" | \"updated\" | \"skipped\" | \"error\" | \"unshallowed\",\n\t\tmessage?: string,\n\t) => void;\n}\n\nexport interface UpdateAllResult {\n\tupdated: string[];\n\tskipped: string[];\n\tunshallowed: string[];\n\terrors: Array<{ repo: string; error: string }>;\n}\n\nexport interface PruneOptions {\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string) => void;\n}\n\nexport interface PruneResult {\n\tremovedFromIndex: string[];\n\torphanedDirs: string[];\n}\n\nexport interface GcOptions {\n\tolderThanDays?: number;\n\twithoutReference?: boolean;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string, sizeBytes?: number) => void;\n}\n\nexport interface GcResult {\n\tremoved: Array<{ repo: string; reason: string; sizeBytes: number }>;\n\tfreedBytes: number;\n}\n\nfunction getDirSize(dirPath: string): number {\n\tif (!existsSync(dirPath)) return 0;\n\n\tlet size = 0;\n\ttry {\n\t\tconst entries = readdirSync(dirPath, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(dirPath, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tsize += getDirSize(fullPath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tsize += statSync(fullPath).size;\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn size;\n}\n\nfunction getLastAccessTime(dirPath: string): Date | null {\n\tif (!existsSync(dirPath)) return null;\n\n\tlet latestTime: Date | null = null;\n\ttry {\n\t\tconst stat = statSync(dirPath);\n\t\tlatestTime = stat.mtime;\n\n\t\tconst fetchHead = join(dirPath, \".git\", \"FETCH_HEAD\");\n\t\tif (existsSync(fetchHead)) {\n\t\t\tconst fetchStat = statSync(fetchHead);\n\t\t\tif (!latestTime || fetchStat.mtime > latestTime) {\n\t\t\t\tlatestTime = fetchStat.mtime;\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn latestTime;\n}\n\nfunction matchesPattern(name: string, pattern: string): boolean {\n\tif (!pattern || pattern === \"*\") return true;\n\n\tconst regex = new RegExp(\n\t\t\"^\" +\n\t\t\tpattern\n\t\t\t\t.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\t\t\t\t.replace(/\\*/g, \".*\")\n\t\t\t\t.replace(/\\?/g, \".\") +\n\t\t\t\"$\",\n\t\t\"i\",\n\t);\n\treturn regex.test(name);\n}\n\nconst yieldToEventLoop = () => new Promise<void>((resolve) => setImmediate(resolve));\n\nexport async function getRepoStatus(options: RepoStatusOptions = {}): Promise<RepoStatusSummary> {\n\tconst { onProgress } = options;\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst total = qualifiedNames.length;\n\n\tlet withReference = 0;\n\tlet missing = 0;\n\tlet diskBytes = 0;\n\n\tfor (let i = 0; i < qualifiedNames.length; i++) {\n\t\tconst qualifiedName = qualifiedNames[i]!;\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tonProgress?.(i + 1, total, qualifiedName);\n\n\t\tawait yieldToEventLoop();\n\n\t\tconst exists = existsSync(entry.localPath);\n\n\t\tif (!exists) {\n\t\t\tmissing++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.references.length > 0) {\n\t\t\twithReference++;\n\t\t}\n\n\t\tdiskBytes += getDirSize(entry.localPath);\n\t}\n\n\treturn {\n\t\ttotal,\n\t\twithReference,\n\t\tmissing,\n\t\tdiskBytes,\n\t};\n}\n\nexport async function updateAllRepos(options: UpdateAllOptions = {}): Promise<UpdateAllResult> {\n\tconst { pattern, dryRun = false, unshallow = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst updated: string[] = [];\n\tconst skipped: string[] = [];\n\tconst unshallowed: string[] = [];\n\tconst errors: Array<{ repo: string; error: string }> = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\n\t\tif (pattern && !matchesPattern(qualifiedName, pattern)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tskipped.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"skipped\", \"missing on disk\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tupdated.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"updated\", \"would update\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tonProgress?.(qualifiedName, \"updating\");\n\t\ttry {\n\t\t\tconst result = await updateRepo(qualifiedName, { unshallow });\n\t\t\tif (result.unshallowed) {\n\t\t\t\tunshallowed.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"unshallowed\", \"converted to full clone\");\n\t\t\t}\n\t\t\tif (result.updated) {\n\t\t\t\tupdated.push(qualifiedName);\n\t\t\t\tonProgress?.(\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\t\"updated\",\n\t\t\t\t\t`${result.previousSha.slice(0, 7)} → ${result.currentSha.slice(0, 7)}`,\n\t\t\t\t);\n\t\t\t} else if (!result.unshallowed) {\n\t\t\t\tskipped.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"skipped\", \"already up to date\");\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof GitError ? err.message : String(err);\n\t\t\terrors.push({ repo: qualifiedName, error: message });\n\t\t\tonProgress?.(qualifiedName, \"error\", message);\n\t\t}\n\t}\n\n\treturn { updated, skipped, unshallowed, errors };\n}\n\nexport async function pruneRepos(options: PruneOptions = {}): Promise<PruneResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removedFromIndex: string[] = [];\n\tconst orphanedDirs: string[] = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tonProgress?.(qualifiedName, \"missing on disk\");\n\t\t\tremovedFromIndex.push(qualifiedName);\n\n\t\t\tif (!dryRun) {\n\t\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst config = loadConfig();\n\tconst repoRoot = getRepoRoot(config);\n\n\tif (existsSync(repoRoot)) {\n\t\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\t\ttry {\n\t\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\t\tfor (const provider of providers) {\n\t\t\t\tif (!provider.isDirectory()) continue;\n\t\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\t\tfor (const owner of owners) {\n\t\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\t\tif (!indexedPaths.has(repoPath)) {\n\t\t\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\t\t\tonProgress?.(fullName, \"not in map\");\n\t\t\t\t\t\t\torphanedDirs.push(repoPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\treturn { removedFromIndex, orphanedDirs };\n}\n\nexport async function gcRepos(options: GcOptions = {}): Promise<GcResult> {\n\tconst { olderThanDays, withoutReference = false, dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removed: Array<{ repo: string; reason: string; sizeBytes: number }> = [];\n\tlet freedBytes = 0;\n\n\tconst now = new Date();\n\tconst cutoffDate = olderThanDays\n\t\t? new Date(now.getTime() - olderThanDays * 24 * 60 * 60 * 1000)\n\t\t: null;\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) continue;\n\n\t\tlet shouldRemove = false;\n\t\tlet reason = \"\";\n\n\t\tif (cutoffDate) {\n\t\t\tconst lastAccess = getLastAccessTime(entry.localPath);\n\t\t\tif (lastAccess && lastAccess < cutoffDate) {\n\t\t\t\tshouldRemove = true;\n\t\t\t\treason = `not accessed in ${olderThanDays}+ days`;\n\t\t\t}\n\t\t}\n\n\t\tif (withoutReference && entry.references.length === 0) {\n\t\t\tshouldRemove = true;\n\t\t\treason = reason ? `${reason}, no reference` : \"no reference\";\n\t\t}\n\n\t\tif (!shouldRemove) continue;\n\n\t\tconst sizeBytes = getDirSize(entry.localPath);\n\t\tonProgress?.(qualifiedName, reason, sizeBytes);\n\n\t\tif (!dryRun) {\n\t\t\trmSync(entry.localPath, { recursive: true, force: true });\n\n\t\t\tfor (const refFile of entry.references) {\n\t\t\t\tconst refPath = join(Paths.offworldReferencesDir, refFile);\n\t\t\t\tif (existsSync(refPath)) {\n\t\t\t\t\trmSync(refPath, { force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (entry.primary) {\n\t\t\t\tconst metaDirName = entry.primary.replace(/\\.md$/, \"\");\n\t\t\t\tconst metaPath = join(Paths.metaDir, metaDirName);\n\t\t\t\tif (existsSync(metaPath)) {\n\t\t\t\t\trmSync(metaPath, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t}\n\n\t\tremoved.push({ repo: qualifiedName, reason, sizeBytes });\n\t\tfreedBytes += sizeBytes;\n\t}\n\n\treturn { removed, freedBytes };\n}\n\nexport interface DiscoverOptions {\n\trepoRoot?: string;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, provider: string) => void;\n}\n\nexport interface DiscoverResult {\n\tdiscovered: Array<{ fullName: string; qualifiedName: string; localPath: string }>;\n\talreadyIndexed: number;\n}\n\nexport async function discoverRepos(options: DiscoverOptions = {}): Promise<DiscoverResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst config = loadConfig();\n\tconst repoRoot = options.repoRoot ?? getRepoRoot(config);\n\tconst discovered: Array<{ fullName: string; qualifiedName: string; localPath: string }> = [];\n\tlet alreadyIndexed = 0;\n\n\tif (!existsSync(repoRoot)) {\n\t\treturn { discovered, alreadyIndexed };\n\t}\n\n\tconst map = readGlobalMap();\n\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\ttry {\n\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\tfor (const provider of providers) {\n\t\t\tif (!provider.isDirectory()) continue;\n\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\tconst providerHostMap: Record<string, string> = {\n\t\t\t\tgithub: \"github.com\",\n\t\t\t\tgitlab: \"gitlab.com\",\n\t\t\t\tbitbucket: \"bitbucket.org\",\n\t\t\t};\n\t\t\tconst providerHost = providerHostMap[provider.name] ?? provider.name;\n\n\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\tfor (const owner of owners) {\n\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\tif (indexedPaths.has(repoPath)) {\n\t\t\t\t\t\talreadyIndexed++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\tconst qualifiedName = `${providerHost}:${fullName}`;\n\n\t\t\t\t\tonProgress?.(fullName, providerHost);\n\n\t\t\t\t\tif (!dryRun) {\n\t\t\t\t\t\tupsertGlobalMapEntry(qualifiedName, {\n\t\t\t\t\t\t\tlocalPath: repoPath,\n\t\t\t\t\t\t\treferences: [],\n\t\t\t\t\t\t\tprimary: \"\",\n\t\t\t\t\t\t\tkeywords: [],\n\t\t\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tdiscovered.push({ fullName, qualifiedName, localPath: repoPath });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\n\treturn { discovered, alreadyIndexed };\n}\n","import { ModelsDevDataSchema, type ModelsDevProvider } from \"@offworld/types\";\n\nconst MODELS_DEV_URL = \"https://models.dev/api.json\";\n\n/**\n * Simplified provider info for CLI display\n */\nexport interface ProviderInfo {\n\tid: string;\n\tname: string;\n\tenv: string[];\n}\n\n/**\n * Simplified model info for CLI display\n */\nexport interface ModelInfo {\n\tid: string;\n\tname: string;\n\treasoning: boolean;\n\texperimental?: boolean;\n\tstatus?: \"alpha\" | \"beta\" | \"deprecated\";\n}\n\n/**\n * Full provider with models for CLI display\n */\nexport interface ProviderWithModels extends ProviderInfo {\n\tmodels: ModelInfo[];\n}\n\nlet cachedData: Record<string, ModelsDevProvider> | null = null;\nlet cacheTime = 0;\nconst CACHE_TTL_MS = 5 * 60 * 1000;\n\n/**\n * Fetch raw data from models.dev with caching\n */\nasync function fetchModelsDevData(): Promise<Record<string, ModelsDevProvider>> {\n\tconst now = Date.now();\n\tif (cachedData && now - cacheTime < CACHE_TTL_MS) {\n\t\treturn cachedData;\n\t}\n\n\tconst res = await fetch(MODELS_DEV_URL, {\n\t\tsignal: AbortSignal.timeout(10_000),\n\t});\n\n\tif (!res.ok) {\n\t\tthrow new Error(`Failed to fetch models.dev: ${res.status} ${res.statusText}`);\n\t}\n\n\tconst json = await res.json();\n\tconst parsed = ModelsDevDataSchema.safeParse(json);\n\tif (!parsed.success) {\n\t\tthrow new Error(`Invalid models.dev response: ${parsed.error.message}`);\n\t}\n\tcachedData = parsed.data;\n\tcacheTime = now;\n\treturn cachedData;\n}\n\n/**\n * List all available providers from models.dev\n */\nexport async function listProviders(): Promise<ProviderInfo[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Get a specific provider with all its models\n */\nexport async function getProvider(providerId: string): Promise<ProviderWithModels | null> {\n\tconst data = await fetchModelsDevData();\n\tconst provider = data[providerId];\n\n\tif (!provider) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tid: provider.id,\n\t\tname: provider.name,\n\t\tenv: provider.env ?? [],\n\t\tmodels: Object.values(provider.models)\n\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t.map((m) => ({\n\t\t\t\tid: m.id,\n\t\t\t\tname: m.name,\n\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\texperimental: m.experimental,\n\t\t\t\tstatus: m.status,\n\t\t\t}))\n\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t};\n}\n\n/**\n * Get all providers with their models\n */\nexport async function listProvidersWithModels(): Promise<ProviderWithModels[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t\tmodels: Object.values(p.models)\n\t\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t\t.map((m) => ({\n\t\t\t\t\tid: m.id,\n\t\t\t\t\tname: m.name,\n\t\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\t\texperimental: m.experimental,\n\t\t\t\t\tstatus: m.status,\n\t\t\t\t}))\n\t\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Validate that a provider/model combination exists\n */\nexport async function validateProviderModel(\n\tproviderId: string,\n\tmodelId: string,\n): Promise<{ valid: boolean; error?: string }> {\n\tconst provider = await getProvider(providerId);\n\n\tif (!provider) {\n\t\tconst providers = await listProviders();\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Provider \"${providerId}\" not found. Available: ${providers\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((p) => p.id)\n\t\t\t\t.join(\", \")}${providers.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\tconst model = provider.models.find((m) => m.id === modelId);\n\tif (!model) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Model \"${modelId}\" not found for provider \"${providerId}\". Available: ${provider.models\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((m) => m.id)\n\t\t\t\t.join(\", \")}${provider.models.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\treturn { valid: true };\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,UAAU;;;;;AAMvB,MAAa,0BAA0B;CACtC;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAC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,cAAc,EAAE,KAAK,CAAC;EAC9C;;;;;AAMF,eAAsB,0BAAyD;CAC9E,MAAM,OAAO,MAAM,oBAAoB;AAEvC,QAAO,OAAO,OAAO,KAAK,CACxB,KAAK,OAAO;EACZ,IAAI,EAAE;EACN,MAAM,EAAE;EACR,KAAK,EAAE,OAAO,EAAE;EAChB,QAAQ,OAAO,OAAO,EAAE,OAAO,CAC7B,QAAQ,MAAM,EAAE,WAAW,aAAa,CACxC,KAAK,OAAO;GACZ,IAAI,EAAE;GACN,MAAM,EAAE;GACR,WAAW,EAAE,aAAa;GAC1B,cAAc,EAAE;GAChB,QAAQ,EAAE;GACV,EAAE,CACF,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;EAC9C,EAAE,CACF,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;;;;;AAM/C,eAAsB,sBACrB,YACA,SAC8C;CAC9C,MAAM,WAAW,MAAM,YAAY,WAAW;AAE9C,KAAI,CAAC,UAAU;EACd,MAAM,YAAY,MAAM,eAAe;AACvC,SAAO;GACN,OAAO;GACP,OAAO,aAAa,WAAW,0BAA0B,UACvD,MAAM,GAAG,GAAG,CACZ,KAAK,MAAM,EAAE,GAAG,CAChB,KAAK,KAAK,GAAG,UAAU,SAAS,KAAK,QAAQ;GAC/C;;AAIF,KAAI,CADU,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,QAAQ,CAE1D,QAAO;EACN,OAAO;EACP,OAAO,UAAU,QAAQ,4BAA4B,WAAW,gBAAgB,SAAS,OACvF,MAAM,GAAG,GAAG,CACZ,KAAK,MAAM,EAAE,GAAG,CAChB,KAAK,KAAK,GAAG,SAAS,OAAO,SAAS,KAAK,QAAQ;EACrD;AAGF,QAAO,EAAE,OAAO,MAAM"}
|
|
1
|
+
{"version":3,"file":"public-CjA2mMwu.mjs","names":["GlobalMapSchema","ProjectMapSchema"],"sources":["../src/constants.ts","../src/repo-source.ts","../src/map.ts","../src/auth.ts","../src/agents.ts","../src/reference.ts","../src/manifest.ts","../src/dep-mappings.ts","../src/reference-matcher.ts","../src/repo-manager.ts","../src/models.ts"],"sourcesContent":["/**\n * SDK Constants\n */\n\n/** SDK version - must match package.json */\nexport const VERSION = \"0.3.1\";\n\n/**\n * Default patterns to ignore when scanning repositories.\n * Includes directories, binary files, IDE configs, and build outputs.\n */\nexport const DEFAULT_IGNORE_PATTERNS = [\n\t\".git\",\n\t\".git/**\",\n\t\".svn\",\n\t\".hg\",\n\n\t\"node_modules\",\n\t\"node_modules/**\",\n\t\"vendor\",\n\t\"vendor/**\",\n\t\".pnpm\",\n\t\".yarn\",\n\n\t\"dist\",\n\t\"dist/**\",\n\t\"build\",\n\t\"build/**\",\n\t\"out\",\n\t\"out/**\",\n\t\".next\",\n\t\".nuxt\",\n\t\".output\",\n\t\"target\",\n\t\"__pycache__\",\n\t\"*.pyc\",\n\n\t\".vscode\",\n\t\".vscode/**\",\n\t\".idea\",\n\t\".idea/**\",\n\t\"*.swp\",\n\t\"*.swo\",\n\t\".DS_Store\",\n\n\t\"*.jpg\",\n\t\"*.jpeg\",\n\t\"*.png\",\n\t\"*.gif\",\n\t\"*.ico\",\n\t\"*.webp\",\n\t\"*.svg\",\n\t\"*.bmp\",\n\t\"*.tiff\",\n\t\"*.mp4\",\n\t\"*.webm\",\n\t\"*.mov\",\n\t\"*.avi\",\n\t\"*.mkv\",\n\t\"*.mp3\",\n\t\"*.wav\",\n\t\"*.flac\",\n\t\"*.ogg\",\n\t\"*.pdf\",\n\t\"*.zip\",\n\t\"*.tar\",\n\t\"*.gz\",\n\t\"*.rar\",\n\t\"*.7z\",\n\t\"*.exe\",\n\t\"*.dll\",\n\t\"*.so\",\n\t\"*.dylib\",\n\t\"*.bin\",\n\t\"*.wasm\",\n\t\"*.woff\",\n\t\"*.woff2\",\n\t\"*.ttf\",\n\t\"*.eot\",\n\t\"*.otf\",\n\n\t\"package-lock.json\",\n\t\"yarn.lock\",\n\t\"pnpm-lock.yaml\",\n\t\"bun.lockb\",\n\t\"Cargo.lock\",\n\t\"Gemfile.lock\",\n\t\"poetry.lock\",\n\t\"composer.lock\",\n\t\"go.sum\",\n\n\t\"coverage\",\n\t\"coverage/**\",\n\t\".nyc_output\",\n\t\".coverage\",\n\t\"htmlcov\",\n\n\t\"*.log\",\n\t\"logs\",\n\t\"tmp\",\n\t\"temp\",\n\t\".tmp\",\n\t\".temp\",\n\t\".cache\",\n\n\t\".env\",\n\t\".env.*\",\n\t\"*.pem\",\n\t\"*.key\",\n] as const;\n","/**\n * Repository source parsing utilities\n */\n\nimport { createHash } from \"node:crypto\";\nimport { existsSync, statSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { basename } from \"node:path\";\nimport type { GitProvider, LocalRepoSource, RemoteRepoSource, RepoSource } from \"@offworld/types\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { expandTilde } from \"./paths.js\";\n\nexport class RepoSourceError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RepoSourceError\";\n\t}\n}\n\nexport class PathNotFoundError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Path does not exist: ${path}`);\n\t\tthis.name = \"PathNotFoundError\";\n\t}\n}\n\nexport class NotGitRepoError extends RepoSourceError {\n\tconstructor(path: string) {\n\t\tsuper(`Directory is not a git repository: ${path}`);\n\t\tthis.name = \"NotGitRepoError\";\n\t}\n}\n\nconst PROVIDER_HOSTS: Record<string, GitProvider> = {\n\t\"github.com\": \"github\",\n\t\"gitlab.com\": \"gitlab\",\n\t\"bitbucket.org\": \"bitbucket\",\n};\n\nconst HTTPS_URL_REGEX =\n\t/^https?:\\/\\/(github\\.com|gitlab\\.com|bitbucket\\.org)\\/([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SSH_URL_REGEX = /^git@(github\\.com|gitlab\\.com|bitbucket\\.org):([^/]+)\\/([^/]+?)(?:\\.git)?$/;\nconst SHORT_FORMAT_REGEX = /^([^/:@]+)\\/([^/:@]+)$/;\n\n/**\n * Generates a short hash of a path for local repo identification\n */\nfunction hashPath(path: string): string {\n\treturn createHash(\"sha256\").update(path).digest(\"hex\").slice(0, 12);\n}\n\n/**\n * Builds a clone URL for a remote repository\n */\nfunction buildCloneUrl(provider: GitProvider, owner: string, repo: string): string {\n\tconst hosts: Record<GitProvider, string> = {\n\t\tgithub: \"github.com\",\n\t\tgitlab: \"gitlab.com\",\n\t\tbitbucket: \"bitbucket.org\",\n\t};\n\treturn `https://${hosts[provider]}/${owner}/${repo}.git`;\n}\n\n/**\n * Parses a remote repository from HTTPS URL format\n */\nfunction parseHttpsUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(HTTPS_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from SSH URL format\n */\nfunction parseSshUrl(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SSH_URL_REGEX);\n\tif (!match) return null;\n\n\tconst [, host, owner, repo] = match;\n\tif (!host || !owner || !repo) return null;\n\n\tconst provider = PROVIDER_HOSTS[host];\n\tif (!provider) return null;\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a remote repository from short format (owner/repo)\n * Defaults to GitHub as provider\n */\nfunction parseShortFormat(input: string): RemoteRepoSource | null {\n\tconst match = input.match(SHORT_FORMAT_REGEX);\n\tif (!match) return null;\n\n\tconst [, owner, repo] = match;\n\tif (!owner || !repo) return null;\n\n\tconst provider: GitProvider = \"github\";\n\tconst host = \"github.com\";\n\n\tconst ownerLower = owner.toLowerCase();\n\tconst repoLower = repo.toLowerCase();\n\treturn {\n\t\ttype: \"remote\",\n\t\tprovider,\n\t\towner: ownerLower,\n\t\trepo: repoLower,\n\t\tfullName: `${ownerLower}/${repoLower}`,\n\t\tqualifiedName: `${host}:${ownerLower}/${repoLower}`,\n\t\tcloneUrl: buildCloneUrl(provider, ownerLower, repoLower),\n\t};\n}\n\n/**\n * Parses a local repository path\n * Validates that the path exists and contains a .git directory\n */\nfunction parseLocalPath(input: string): LocalRepoSource {\n\tconst absolutePath = resolve(expandTilde(input));\n\n\tif (!existsSync(absolutePath)) {\n\t\tthrow new PathNotFoundError(absolutePath);\n\t}\n\n\tconst stats = statSync(absolutePath);\n\tif (!stats.isDirectory()) {\n\t\tthrow new RepoSourceError(`Path is not a directory: ${absolutePath}`);\n\t}\n\n\tconst gitPath = resolve(absolutePath, \".git\");\n\tif (!existsSync(gitPath)) {\n\t\tthrow new NotGitRepoError(absolutePath);\n\t}\n\n\tconst name = basename(absolutePath);\n\tconst hash = hashPath(absolutePath);\n\n\treturn {\n\t\ttype: \"local\",\n\t\tpath: absolutePath,\n\t\tname,\n\t\tqualifiedName: `local:${hash}`,\n\t};\n}\n\n/**\n * Determines if input looks like a local path\n */\nfunction isLocalPath(input: string): boolean {\n\treturn input.startsWith(\".\") || input.startsWith(\"/\") || input.startsWith(\"~\");\n}\n\n/**\n * Parses a repository input and returns a structured RepoSource\n *\n * Supported formats:\n * - owner/repo (short format, defaults to GitHub)\n * - https://github.com/owner/repo\n * - https://gitlab.com/owner/repo\n * - https://bitbucket.org/owner/repo\n * - git@github.com:owner/repo.git (SSH format)\n * - . (current directory as local repo)\n * - /absolute/path (local repo)\n *\n * @throws PathNotFoundError if local path doesn't exist\n * @throws NotGitRepoError if local path is not a git repository\n * @throws RepoSourceError for other parsing failures\n */\nexport function parseRepoInput(input: string): RepoSource {\n\tconst trimmed = input.trim();\n\n\tconst httpsResult = parseHttpsUrl(trimmed);\n\tif (httpsResult) return httpsResult;\n\n\tconst sshResult = parseSshUrl(trimmed);\n\tif (sshResult) return sshResult;\n\n\tif (isLocalPath(trimmed)) {\n\t\treturn parseLocalPath(trimmed);\n\t}\n\n\tconst shortResult = parseShortFormat(trimmed);\n\tif (shortResult) return shortResult;\n\n\tthrow new RepoSourceError(\n\t\t`Unable to parse repository input: ${input}. ` +\n\t\t\t\"Expected formats: owner/repo, https://github.com/owner/repo, git@github.com:owner/repo.git, or a local path\",\n\t);\n}\n\nexport function getReferenceFileNameForSource(source: RepoSource): string {\n\tif (source.type === \"remote\") {\n\t\treturn toReferenceFileName(source.fullName);\n\t}\n\treturn toReferenceFileName(source.name);\n}\n","/**\n * Map query helpers for fast routing without reading full map.json\n */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport type {\n\tGlobalMap,\n\tGlobalMapRepoEntry,\n\tProjectMap,\n\tProjectMapRepoEntry,\n} from \"@offworld/types\";\nimport { GlobalMapSchema, ProjectMapSchema } from \"@offworld/types/schemas\";\nimport { Paths } from \"./paths.js\";\n\nexport interface MapEntry {\n\tscope: \"project\" | \"global\";\n\tqualifiedName: string;\n\tentry: GlobalMapRepoEntry | ProjectMapRepoEntry;\n}\n\nexport interface SearchResult {\n\tqualifiedName: string;\n\tfullName: string;\n\tlocalPath: string;\n\tprimary: string;\n\tkeywords: string[];\n\tscore: number;\n}\n\nexport interface GetMapEntryOptions {\n\tpreferProject?: boolean;\n\tcwd?: string;\n}\n\nexport interface SearchMapOptions {\n\tlimit?: number;\n\tcwd?: string;\n}\n\nfunction readGlobalMapSafe(): GlobalMap | null {\n\tconst mapPath = Paths.offworldGlobalMapPath;\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn GlobalMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction readProjectMapSafe(cwd: string): ProjectMap | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\tif (!existsSync(mapPath)) return null;\n\n\ttry {\n\t\tconst content = readFileSync(mapPath, \"utf-8\");\n\t\treturn ProjectMapSchema.parse(JSON.parse(content));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Normalize input to match against repo keys.\n * Accepts: github.com:owner/repo, owner/repo, repo\n */\nfunction normalizeInput(input: string): { provider?: string; fullName: string; repoName: string } {\n\tconst trimmed = input.trim().toLowerCase();\n\n\tif (trimmed.includes(\":\")) {\n\t\tconst parts = trimmed.split(\":\", 2);\n\t\tconst provider = parts[0];\n\t\tconst fullName = parts[1] ?? \"\";\n\t\tconst repoName = fullName.split(\"/\").pop() ?? fullName;\n\t\treturn { provider, fullName, repoName };\n\t}\n\n\tif (trimmed.includes(\"/\")) {\n\t\tconst repoName = trimmed.split(\"/\").pop() ?? trimmed;\n\t\treturn { fullName: trimmed, repoName };\n\t}\n\n\treturn { fullName: trimmed, repoName: trimmed };\n}\n\n/**\n * Tokenize a string for search matching.\n * Lowercase, strip @, split on /_- and whitespace.\n */\nfunction tokenize(str: string): string[] {\n\treturn str\n\t\t.toLowerCase()\n\t\t.replace(/@/g, \"\")\n\t\t.split(/[/_\\-\\s]+/)\n\t\t.filter(Boolean);\n}\n\n/**\n * Resolve an input string to a qualified repo key in a map.\n *\n * @param input - Accepts github.com:owner/repo, owner/repo, or repo name\n * @param map - A global or project map\n * @returns The matching qualified name or null\n */\nexport function resolveRepoKey(input: string, map: GlobalMap | ProjectMap): string | null {\n\tconst { provider, fullName, repoName } = normalizeInput(input);\n\tconst keys = Object.keys(map.repos);\n\n\tif (provider) {\n\t\tconst qualifiedKey = `${provider}:${fullName}`;\n\t\tif (keys.includes(qualifiedKey)) {\n\t\t\treturn qualifiedKey;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyFullName = key.includes(\":\") ? key.split(\":\")[1] : key;\n\t\tif (keyFullName?.toLowerCase() === fullName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\tfor (const key of keys) {\n\t\tconst keyRepoName = key.split(\"/\").pop()?.toLowerCase();\n\t\tif (keyRepoName === repoName) {\n\t\t\treturn key;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Get a map entry for a repo, preferring project map if available.\n *\n * @param input - Repo identifier (github.com:owner/repo, owner/repo, or repo)\n * @param options - Options for lookup\n * @returns Entry with scope and qualified name, or null if not found\n */\nexport function getMapEntry(input: string, options: GetMapEntryOptions = {}): MapEntry | null {\n\tconst { preferProject = true, cwd = process.cwd() } = options;\n\n\tconst projectMap = preferProject ? readProjectMapSafe(cwd) : null;\n\tconst globalMap = readGlobalMapSafe();\n\n\tif (projectMap) {\n\t\tconst key = resolveRepoKey(input, projectMap);\n\t\tif (key && projectMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"project\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: projectMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\tif (globalMap) {\n\t\tconst key = resolveRepoKey(input, globalMap);\n\t\tif (key && globalMap.repos[key]) {\n\t\t\treturn {\n\t\t\t\tscope: \"global\",\n\t\t\t\tqualifiedName: key,\n\t\t\t\tentry: globalMap.repos[key],\n\t\t\t};\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Search the map for repos matching a term.\n *\n * Scoring:\n * - Exact fullName match: 100\n * - Keyword hit: 50 per keyword\n * - Partial contains in fullName: 25\n * - Partial contains in keywords: 10\n *\n * @param term - Search term\n * @param options - Search options\n * @returns Sorted list of matches\n */\nexport function searchMap(term: string, options: SearchMapOptions = {}): SearchResult[] {\n\tconst { limit = 10 } = options;\n\n\tconst globalMap = readGlobalMapSafe();\n\tif (!globalMap) return [];\n\n\tconst termTokens = tokenize(term);\n\tconst termLower = term.toLowerCase();\n\tconst results: SearchResult[] = [];\n\n\tfor (const qualifiedName of Object.keys(globalMap.repos)) {\n\t\tconst entry = globalMap.repos[qualifiedName];\n\t\tif (!entry) continue;\n\n\t\tconst fullName = qualifiedName.includes(\":\")\n\t\t\t? (qualifiedName.split(\":\")[1] ?? qualifiedName)\n\t\t\t: qualifiedName;\n\t\tconst fullNameLower = fullName.toLowerCase();\n\t\tconst keywords = entry.keywords ?? [];\n\t\tconst keywordsLower = keywords.map((k) => k.toLowerCase());\n\n\t\tlet score = 0;\n\n\t\tif (fullNameLower === termLower) {\n\t\t\tscore += 100;\n\t\t}\n\n\t\tfor (const token of termTokens) {\n\t\t\tif (keywordsLower.includes(token)) {\n\t\t\t\tscore += 50;\n\t\t\t}\n\t\t}\n\n\t\tif (fullNameLower.includes(termLower) && score < 100) {\n\t\t\tscore += 25;\n\t\t}\n\n\t\tfor (const kw of keywordsLower) {\n\t\t\tif (kw.includes(termLower)) {\n\t\t\t\tscore += 10;\n\t\t\t}\n\t\t}\n\n\t\tconst fullNameTokens = tokenize(fullName);\n\t\tfor (const token of termTokens) {\n\t\t\tif (fullNameTokens.includes(token)) {\n\t\t\t\tscore += 30;\n\t\t\t}\n\t\t}\n\n\t\tif (score > 0) {\n\t\t\tresults.push({\n\t\t\t\tqualifiedName,\n\t\t\t\tfullName,\n\t\t\t\tlocalPath: entry.localPath,\n\t\t\t\tprimary: entry.primary,\n\t\t\t\tkeywords,\n\t\t\t\tscore,\n\t\t\t});\n\t\t}\n\t}\n\n\tresults.sort((a, b) => {\n\t\tif (b.score !== a.score) return b.score - a.score;\n\t\treturn a.fullName.localeCompare(b.fullName);\n\t});\n\n\treturn results.slice(0, limit);\n}\n\n/**\n * Get the project map path if it exists in cwd.\n */\nexport function getProjectMapPath(cwd: string = process.cwd()): string | null {\n\tconst mapPath = resolve(cwd, \".offworld/map.json\");\n\treturn existsSync(mapPath) ? mapPath : null;\n}\n","/**\n * Authentication utilities for offworld CLI\n */\n\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport { z } from \"zod\";\nimport { WorkOSTokenResponseSchema } from \"@offworld/types\";\nimport { Paths } from \"./paths\";\n\nconst AuthDataSchema = z.object({\n\ttoken: z.string(),\n\texpiresAt: z.string().optional(),\n\tworkosId: z.string().optional(),\n\trefreshToken: z.string().optional(),\n\temail: z.string().optional(),\n});\n\nexport interface AuthData {\n\ttoken: string;\n\texpiresAt?: string;\n\tworkosId?: string;\n\trefreshToken?: string;\n\temail?: string;\n}\n\n/** Authentication status */\nexport interface AuthStatus {\n\tisLoggedIn: boolean;\n\temail?: string;\n\tworkosId?: string;\n\texpiresAt?: string;\n}\n\nexport class AuthError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"AuthError\";\n\t}\n}\n\nexport class NotLoggedInError extends AuthError {\n\tconstructor(message = \"Not logged in. Please run 'ow auth login' first.\") {\n\t\tsuper(message);\n\t\tthis.name = \"NotLoggedInError\";\n\t}\n}\n\nexport class TokenExpiredError extends AuthError {\n\tconstructor(message = \"Session expired. Please run 'ow auth login' again.\") {\n\t\tsuper(message);\n\t\tthis.name = \"TokenExpiredError\";\n\t}\n}\n\nfunction extractJwtExpiration(token: string): string | undefined {\n\ttry {\n\t\tconst parts = token.split(\".\");\n\t\tif (parts.length !== 3) return undefined;\n\n\t\tconst payload = parts[1];\n\t\tif (!payload) return undefined;\n\n\t\tconst decoded = JSON.parse(Buffer.from(payload, \"base64\").toString(\"utf-8\"));\n\t\tif (typeof decoded.exp !== \"number\") return undefined;\n\n\t\treturn new Date(decoded.exp * 1000).toISOString();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function getAuthPath(): string {\n\treturn Paths.authFile;\n}\n\nexport function saveAuthData(data: AuthData): void {\n\tconst authPath = getAuthPath();\n\tconst authDir = dirname(authPath);\n\n\tif (!existsSync(authDir)) {\n\t\tmkdirSync(authDir, { recursive: true });\n\t}\n\n\twriteFileSync(authPath, JSON.stringify(data, null, 2), \"utf-8\");\n\tchmodSync(authPath, 0o600);\n}\n\n/**\n * Loads authentication data from ~/.local/share/offworld/auth.json\n * Returns null if file doesn't exist or is invalid\n */\nexport function loadAuthData(): AuthData | null {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(authPath, \"utf-8\");\n\t\tconst json = JSON.parse(content);\n\t\tconst parsed = AuthDataSchema.safeParse(json);\n\n\t\tif (!parsed.success) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn parsed.data;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Clears stored authentication data\n * @returns true if auth file was deleted, false if it didn't exist\n */\nexport function clearAuthData(): boolean {\n\tconst authPath = getAuthPath();\n\n\tif (!existsSync(authPath)) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tunlinkSync(authPath);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function getToken(): Promise<string> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\tthrow new NotLoggedInError();\n\t}\n\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new TokenExpiredError();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new TokenExpiredError();\n\t\t}\n\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn refreshed.token;\n\t\t\t\t} catch {\n\t\t\t\t\treturn data.token;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn data.token;\n}\n\n/**\n * Gets the current authentication token, or null if not logged in\n * Does not throw errors\n */\nexport async function getTokenOrNull(): Promise<string | null> {\n\ttry {\n\t\treturn await getToken();\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function isLoggedIn(): Promise<boolean> {\n\treturn (await getTokenOrNull()) !== null;\n}\n\nexport async function getAuthStatus(): Promise<AuthStatus> {\n\tconst data = loadAuthData();\n\n\tif (!data) {\n\t\treturn { isLoggedIn: false };\n\t}\n\n\t// Extract expiration from JWT if not already saved (mirrors getToken() logic)\n\tlet expiresAtStr = data.expiresAt;\n\tif (!expiresAtStr) {\n\t\texpiresAtStr = extractJwtExpiration(data.token);\n\t\tif (expiresAtStr) {\n\t\t\tdata.expiresAt = expiresAtStr;\n\t\t\tsaveAuthData(data);\n\t\t}\n\t}\n\n\tif (expiresAtStr) {\n\t\tconst expiresAt = new Date(expiresAtStr);\n\t\tconst now = new Date();\n\t\tconst oneMinute = 60 * 1000;\n\n\t\t// Token already expired - attempt refresh\n\t\tif (expiresAt <= now) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\treturn { isLoggedIn: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { isLoggedIn: false };\n\t\t}\n\n\t\t// Proactive refresh: token expires within 1 minute\n\t\tif (expiresAt.getTime() - now.getTime() < oneMinute) {\n\t\t\tif (data.refreshToken) {\n\t\t\t\ttry {\n\t\t\t\t\tconst refreshed = await refreshAccessToken();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: refreshed.email,\n\t\t\t\t\t\tworkosId: refreshed.workosId,\n\t\t\t\t\t\texpiresAt: refreshed.expiresAt,\n\t\t\t\t\t};\n\t\t\t\t} catch {\n\t\t\t\t\t// Refresh failed, but token still valid - return current data\n\t\t\t\t\treturn {\n\t\t\t\t\t\tisLoggedIn: true,\n\t\t\t\t\t\temail: data.email,\n\t\t\t\t\t\tworkosId: data.workosId,\n\t\t\t\t\t\texpiresAt: expiresAtStr,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tisLoggedIn: true,\n\t\temail: data.email,\n\t\tworkosId: data.workosId,\n\t\texpiresAt: expiresAtStr,\n\t};\n}\n\nconst WORKOS_API = \"https://api.workos.com\";\n\n// Production WorkOS client ID - dev can override via WORKOS_CLIENT_ID env var\nconst PRODUCTION_WORKOS_CLIENT_ID = \"client_01KFAD76TNGN02AP96982HG35E\";\n\nfunction getWorkosClientId(): string {\n\treturn process.env.WORKOS_CLIENT_ID ?? PRODUCTION_WORKOS_CLIENT_ID;\n}\n\nexport async function refreshAccessToken(): Promise<AuthData> {\n\tconst data = loadAuthData();\n\n\tif (!data?.refreshToken) {\n\t\tthrow new AuthError(\"No refresh token available. Please log in again.\");\n\t}\n\n\ttry {\n\t\tconst response = await fetch(`${WORKOS_API}/user_management/authenticate`, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tgrant_type: \"refresh_token\",\n\t\t\t\trefresh_token: data.refreshToken,\n\t\t\t\tclient_id: getWorkosClientId(),\n\t\t\t}),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst error = await response.text();\n\t\t\tthrow new AuthError(`Token refresh failed: ${error}`);\n\t\t}\n\n\t\tconst json = await response.json();\n\t\tconst tokenData = WorkOSTokenResponseSchema.parse(json);\n\n\t\tconst newAuthData: AuthData = {\n\t\t\ttoken: tokenData.access_token,\n\t\t\temail: tokenData.user.email,\n\t\t\tworkosId: tokenData.user.id,\n\t\t\trefreshToken: tokenData.refresh_token,\n\t\t\texpiresAt: tokenData.expires_at\n\t\t\t\t? new Date(tokenData.expires_at * 1000).toISOString()\n\t\t\t\t: extractJwtExpiration(tokenData.access_token),\n\t\t};\n\n\t\tsaveAuthData(newAuthData);\n\t\treturn newAuthData;\n\t} catch (error) {\n\t\tif (error instanceof AuthError) throw error;\n\t\tthrow new AuthError(\n\t\t\t`Failed to refresh token: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n","/**\n * Agent Registry & Auto-Detection\n *\n * Centralized registry of supported AI coding agents with their\n * skill directory locations and detection functions.\n */\n\nimport { existsSync } from \"node:fs\";\nimport type { Agent } from \"@offworld/types\";\nimport { expandTilde } from \"./paths\";\n\nexport interface AgentConfig {\n\t/** Agent identifier (matches AgentSchema enum) */\n\tname: Agent;\n\t/** Human-readable name for display */\n\tdisplayName: string;\n\t/** Project-level skill directory (relative path) */\n\tskillsDir: string;\n\t/** User-level skill directory (absolute with ~) */\n\tglobalSkillsDir: string;\n\t/** Check if this agent is installed on the system */\n\tdetectInstalled: () => boolean;\n}\n\nexport const agents: Record<Agent, AgentConfig> = {\n\topencode: {\n\t\tname: \"opencode\",\n\t\tdisplayName: \"OpenCode\",\n\t\tskillsDir: \".opencode/skills\",\n\t\tglobalSkillsDir: \"~/.config/opencode/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/opencode\")),\n\t},\n\t\"claude-code\": {\n\t\tname: \"claude-code\",\n\t\tdisplayName: \"Claude Code\",\n\t\tskillsDir: \".claude/skills\",\n\t\tglobalSkillsDir: \"~/.claude/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.claude\")),\n\t},\n\tcodex: {\n\t\tname: \"codex\",\n\t\tdisplayName: \"Codex (OpenAI)\",\n\t\tskillsDir: \".codex/skills\",\n\t\tglobalSkillsDir: \"~/.codex/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.codex\")),\n\t},\n\tamp: {\n\t\tname: \"amp\",\n\t\tdisplayName: \"Amp\",\n\t\tskillsDir: \".agents/skills\",\n\t\tglobalSkillsDir: \"~/.config/agents/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.config/amp\")),\n\t},\n\tantigravity: {\n\t\tname: \"antigravity\",\n\t\tdisplayName: \"Antigravity\",\n\t\tskillsDir: \".agent/skills\",\n\t\tglobalSkillsDir: \"~/.gemini/antigravity/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.gemini/antigravity\")),\n\t},\n\tcursor: {\n\t\tname: \"cursor\",\n\t\tdisplayName: \"Cursor\",\n\t\tskillsDir: \".cursor/skills\",\n\t\tglobalSkillsDir: \"~/.cursor/skills\",\n\t\tdetectInstalled: () => existsSync(expandTilde(\"~/.cursor\")),\n\t},\n};\n\n/**\n * Detect which agents are installed on the system.\n * Checks for the existence of each agent's config directory.\n *\n * @returns Array of installed agent identifiers\n */\nexport function detectInstalledAgents(): Agent[] {\n\tconst installed: Agent[] = [];\n\n\tfor (const config of Object.values(agents)) {\n\t\tif (config.detectInstalled()) {\n\t\t\tinstalled.push(config.name);\n\t\t}\n\t}\n\n\treturn installed;\n}\n\n/**\n * Get the configuration for a specific agent.\n *\n * @param type - Agent identifier\n * @returns AgentConfig for the specified agent\n */\nexport function getAgentConfig(type: Agent): AgentConfig {\n\treturn agents[type];\n}\n\n/**\n * Get all agent configurations as an array.\n *\n * @returns Array of all agent configurations\n */\nexport function getAllAgentConfigs(): AgentConfig[] {\n\treturn Object.values(agents);\n}\n","import {\n\tmkdirSync,\n\twriteFileSync,\n\treadFileSync,\n\tlstatSync,\n\tunlinkSync,\n\trmSync,\n\tsymlinkSync,\n\texistsSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { z } from \"zod\";\nimport { loadConfig, toMetaDirName, toReferenceFileName } from \"./config.js\";\nimport { agents } from \"./agents.js\";\nimport { expandTilde, Paths } from \"./paths.js\";\nimport { readGlobalMap, writeGlobalMap } from \"./index-manager.js\";\n\nconst PackageJsonKeywordsSchema = z.object({\n\tname: z.string().optional(),\n\tkeywords: z.array(z.string()).optional(),\n});\n\nexport interface InstallReferenceMeta {\n\t/** ISO timestamp when the reference was generated */\n\treferenceUpdatedAt: string;\n\t/** Git commit SHA at time of generation */\n\tcommitSha: string;\n\t/** SDK version used for generation */\n\tversion: string;\n}\n\nfunction normalizeKeyword(value: string): string[] {\n\tconst trimmed = value.trim();\n\tif (!trimmed) return [];\n\tconst normalized = trimmed.toLowerCase();\n\tconst tokens = new Set<string>();\n\n\tconst addToken = (token: string): void => {\n\t\tconst cleaned = token.trim().toLowerCase();\n\t\tif (cleaned.length < 2) return;\n\t\ttokens.add(cleaned);\n\t};\n\n\taddToken(normalized);\n\taddToken(normalized.replaceAll(\"/\", \"-\"));\n\taddToken(normalized.replaceAll(\"/\", \"\"));\n\n\tfor (const token of normalized.split(/[\\s/_-]+/)) {\n\t\taddToken(token);\n\t}\n\n\tif (normalized.startsWith(\"@\")) {\n\t\taddToken(normalized.slice(1));\n\t}\n\n\treturn Array.from(tokens);\n}\n\nfunction deriveKeywords(fullName: string, localPath: string, referenceContent: string): string[] {\n\tconst keywords = new Set<string>();\n\n\tconst addKeywords = (value: string): void => {\n\t\tfor (const token of normalizeKeyword(value)) {\n\t\t\tkeywords.add(token);\n\t\t}\n\t};\n\n\taddKeywords(fullName);\n\n\tconst headingMatch = referenceContent.match(/^#\\s+(.+)$/m);\n\tif (headingMatch?.[1]) {\n\t\taddKeywords(headingMatch[1]);\n\t}\n\n\tconst packageJsonPath = join(localPath, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\ttry {\n\t\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\t\tconst json = JSON.parse(content);\n\t\t\tconst parsed = PackageJsonKeywordsSchema.safeParse(json);\n\n\t\t\tif (parsed.success) {\n\t\t\t\tif (parsed.data.name) {\n\t\t\t\t\taddKeywords(parsed.data.name);\n\t\t\t\t}\n\n\t\t\t\tif (parsed.data.keywords) {\n\t\t\t\t\tfor (const keyword of parsed.data.keywords) {\n\t\t\t\t\t\taddKeywords(keyword);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\treturn Array.from(keywords);\n}\n\n/**\n * Ensure a symlink exists, removing any existing file/directory at the path\n */\nfunction ensureSymlink(target: string, linkPath: string): void {\n\ttry {\n\t\tconst stat = lstatSync(linkPath);\n\t\tif (stat.isSymbolicLink()) {\n\t\t\tunlinkSync(linkPath);\n\t\t} else if (stat.isDirectory()) {\n\t\t\trmSync(linkPath, { recursive: true });\n\t\t} else {\n\t\t\tunlinkSync(linkPath);\n\t\t}\n\t} catch {}\n\n\tconst linkDir = join(linkPath, \"..\");\n\tmkdirSync(linkDir, { recursive: true });\n\tsymlinkSync(target, linkPath, \"dir\");\n}\n\n/**\n * Static template for the global SKILL.md file.\n * This is the single routing skill that all agents see.\n */\nconst GLOBAL_SKILL_TEMPLATE = `---\nname: offworld\ndescription: Routes queries to Offworld reference files. Find and read per-repo references for dependency knowledge.\nallowed-tools: Bash(ow:*) Read\n---\n\n# Offworld Reference Router\n\nUse \\`ow\\` to locate and read Offworld reference files for dependencies.\n\n## What This Does\n\n- Finds references for libraries and repos\n- Returns paths for reference files and local clones\n- Helps you read the right context fast\n\n## When to Use\n\n- You need docs or patterns for a dependency\n- You want the verified reference instead of web search\n- You are about to work inside a repo clone\n\n## Prerequisites\n\nCheck that the CLI is available:\n\n\\`\\`\\`bash\now --version\n\\`\\`\\`\n\nIf \\`ow\\` is not available, install it:\n\n\\`\\`\\`bash\ncurl -fsSL https://offworld.sh/install | bash\n\\`\\`\\`\n\n## Setup\n\nInitialize Offworld once per machine:\n\n\\`\\`\\`bash\now init\n\\`\\`\\`\n\nFor a specific project, build a project map:\n\n\\`\\`\\`bash\now project init\n\\`\\`\\`\n\n## Usage\n\n**Find a reference:**\n\\`\\`\\`bash\now map search <term> # search by name or keyword\now map show <repo> # get info for specific repo\n\\`\\`\\`\n\n**Get paths for tools:**\n\\`\\`\\`bash\now map show <repo> --ref # reference file path (use with Read)\now map show <repo> --path # clone directory path\n\\`\\`\\`\n\n**Example workflow:**\n\\`\\`\\`bash\n# 1. Find the repo\now map search zod\n\n# 2. Get reference path\now map show colinhacks/zod --ref\n# Output: /Users/.../.local/share/offworld/skill/offworld/references/colinhacks-zod.md\n\n# 3. Read the reference with the path from step 2\n\\`\\`\\`\n\n## If Reference Not Found\n\n\\`\\`\\`bash\now pull <owner/repo> # clone + generate reference\now project init # scan project deps, install references\n\\`\\`\\`\n\n## Notes\n\n- Project map (\\`.offworld/map.json\\`) takes precedence over global map when present\n- Reference files are markdown with API docs, patterns, best practices\n- Clone paths useful for exploring source code after reading reference\n\n## Additional Resources\n\n- Docs: https://offworld.sh/cli\n`;\n\n/**\n * Ensures the global SKILL.md exists and symlinks the offworld/ directory to all agent skill directories.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/SKILL.md (static routing template)\n * - ~/.local/share/offworld/skill/offworld/assets/ (for map.json)\n * - ~/.local/share/offworld/skill/offworld/references/ (for reference files)\n * - Symlinks entire offworld/ directory to each agent's skill directory\n */\nexport function installGlobalSkill(): void {\n\tconst config = loadConfig();\n\n\tmkdirSync(Paths.offworldSkillDir, { recursive: true });\n\tmkdirSync(Paths.offworldAssetsDir, { recursive: true });\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\n\tconst skillPath = join(Paths.offworldSkillDir, \"SKILL.md\");\n\tif (!existsSync(skillPath)) {\n\t\twriteFileSync(skillPath, GLOBAL_SKILL_TEMPLATE, \"utf-8\");\n\t}\n\n\tconst configuredAgents = config.agents ?? [];\n\tfor (const agentName of configuredAgents) {\n\t\tconst agentConfig = agents[agentName];\n\t\tif (agentConfig) {\n\t\t\tconst agentSkillDir = expandTilde(join(agentConfig.globalSkillsDir, \"offworld\"));\n\t\t\tensureSymlink(Paths.offworldSkillDir, agentSkillDir);\n\t\t}\n\t}\n}\n\n/**\n * Install a reference file for a specific repository.\n *\n * Creates:\n * - ~/.local/share/offworld/skill/offworld/references/{owner-repo}.md\n * - ~/.local/share/offworld/meta/{owner-repo}/meta.json\n * - Updates global map with reference info\n *\n * @param qualifiedName - Qualified key for map storage (e.g., \"github.com:owner/repo\" or \"local:name\")\n * @param fullName - Full repo name for file naming (e.g., \"owner/repo\")\n * @param localPath - Absolute path to the cloned repository\n * @param referenceContent - The generated reference markdown content\n * @param meta - Metadata about the generation (referenceUpdatedAt, commitSha, version)\n * @param keywords - Optional array of keywords for search/routing\n */\nexport function installReference(\n\tqualifiedName: string,\n\tfullName: string,\n\tlocalPath: string,\n\treferenceContent: string,\n\tmeta: InstallReferenceMeta,\n\tkeywords?: string[],\n): void {\n\tinstallGlobalSkill();\n\n\tconst referenceFileName = toReferenceFileName(fullName);\n\tconst metaDirName = toMetaDirName(fullName);\n\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\tmkdirSync(Paths.offworldReferencesDir, { recursive: true });\n\twriteFileSync(referencePath, referenceContent, \"utf-8\");\n\n\tconst metaDir = join(Paths.metaDir, metaDirName);\n\tmkdirSync(metaDir, { recursive: true });\n\tconst metaJson = JSON.stringify(meta, null, 2);\n\twriteFileSync(join(metaDir, \"meta.json\"), metaJson, \"utf-8\");\n\n\tconst map = readGlobalMap();\n\tconst existingEntry = map.repos[qualifiedName];\n\tconst legacyProviderMap: Record<string, string> = {\n\t\t\"github.com\": \"github\",\n\t\t\"gitlab.com\": \"gitlab\",\n\t\t\"bitbucket.org\": \"bitbucket\",\n\t};\n\tconst [host] = qualifiedName.split(\":\");\n\tconst legacyProvider = host ? legacyProviderMap[host] : undefined;\n\tconst legacyQualifiedName = legacyProvider ? `${legacyProvider}:${fullName}` : undefined;\n\tconst legacyEntry = legacyQualifiedName ? map.repos[legacyQualifiedName] : undefined;\n\n\tconst references = [...(existingEntry?.references ?? []), ...(legacyEntry?.references ?? [])];\n\tif (!references.includes(referenceFileName)) {\n\t\treferences.push(referenceFileName);\n\t}\n\n\tconst derivedKeywords = keywords ?? deriveKeywords(fullName, localPath, referenceContent);\n\tconst keywordsSet = new Set<string>([\n\t\t...(existingEntry?.keywords ?? []),\n\t\t...(legacyEntry?.keywords ?? []),\n\t\t...derivedKeywords,\n\t]);\n\n\tmap.repos[qualifiedName] = {\n\t\tlocalPath,\n\t\treferences,\n\t\tprimary: referenceFileName,\n\t\tkeywords: Array.from(keywordsSet),\n\t\tupdatedAt: new Date().toISOString(),\n\t};\n\n\tif (legacyQualifiedName && legacyQualifiedName in map.repos) {\n\t\tdelete map.repos[legacyQualifiedName];\n\t}\n\n\twriteGlobalMap(map);\n}\n","/**\n * Dependency manifest parsing for multiple package ecosystems\n */\n\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport type ManifestType = \"npm\" | \"python\" | \"rust\" | \"go\" | \"unknown\";\n\nexport interface Dependency {\n\tname: string;\n\tversion?: string;\n\tdev: boolean;\n}\n\nconst DEFAULT_IGNORED_DIRS = new Set([\n\t\".git\",\n\t\".offworld\",\n\t\".turbo\",\n\t\"build\",\n\t\"dist\",\n\t\"node_modules\",\n\t\"out\",\n]);\n\n/**\n * Detects the manifest type in a directory\n */\nexport function detectManifestType(dir: string): ManifestType {\n\tif (existsSync(join(dir, \"package.json\"))) return \"npm\";\n\tif (existsSync(join(dir, \"pyproject.toml\"))) return \"python\";\n\tif (existsSync(join(dir, \"Cargo.toml\"))) return \"rust\";\n\tif (existsSync(join(dir, \"go.mod\"))) return \"go\";\n\tif (existsSync(join(dir, \"requirements.txt\"))) return \"python\";\n\treturn \"unknown\";\n}\n\n/**\n * Parses dependencies from manifest files\n */\nexport function parseDependencies(dir: string): Dependency[] {\n\tconst type = detectManifestType(dir);\n\n\tswitch (type) {\n\t\tcase \"npm\":\n\t\t\treturn parseNpmDependencies(dir);\n\t\tcase \"python\":\n\t\t\treturn existsSync(join(dir, \"pyproject.toml\"))\n\t\t\t\t? parsePyprojectToml(join(dir, \"pyproject.toml\"))\n\t\t\t\t: parseRequirementsTxt(join(dir, \"requirements.txt\"));\n\t\tcase \"rust\":\n\t\t\treturn parseCargoToml(join(dir, \"Cargo.toml\"));\n\t\tcase \"go\":\n\t\t\treturn parseGoMod(join(dir, \"go.mod\"));\n\t\tdefault:\n\t\t\treturn [];\n\t}\n}\n\nfunction parseNpmDependencies(dir: string): Dependency[] {\n\tconst rootPath = join(dir, \"package.json\");\n\tconst rootDeps = parsePackageJson(rootPath);\n\tconst workspaceDeps = parseWorkspaceDependencies(dir);\n\treturn mergeDependencies(rootDeps, workspaceDeps).sort((a, b) => a.name.localeCompare(b.name));\n}\n\nfunction parseWorkspaceDependencies(dir: string): Dependency[] {\n\tconst workspacePatterns = getWorkspacePatterns(dir);\n\tif (workspacePatterns.length === 0) return [];\n\n\tconst packageJsonPaths = resolveWorkspacePackageJsonPaths(dir, workspacePatterns);\n\tconst deps: Dependency[] = [];\n\tfor (const path of packageJsonPaths) {\n\t\tdeps.push(...parsePackageJson(path));\n\t}\n\n\treturn mergeDependencies([], deps);\n}\n\nfunction getWorkspacePatterns(dir: string): string[] {\n\tconst patterns = new Set<string>();\n\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\tconst rootJson = readJson(packageJsonPath);\n\t\tconst workspaces = rootJson?.workspaces;\n\t\tif (Array.isArray(workspaces)) {\n\t\t\tfor (const pattern of workspaces) {\n\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t}\n\t\t} else if (workspaces && typeof workspaces === \"object\") {\n\t\t\tconst packagesField = (workspaces as { packages?: unknown }).packages;\n\t\t\tif (Array.isArray(packagesField)) {\n\t\t\t\tfor (const pattern of packagesField) {\n\t\t\t\t\tif (typeof pattern === \"string\") patterns.add(pattern);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tconst pnpmWorkspacePath = existsSync(join(dir, \"pnpm-workspace.yaml\"))\n\t\t? join(dir, \"pnpm-workspace.yaml\")\n\t\t: existsSync(join(dir, \"pnpm-workspace.yml\"))\n\t\t\t? join(dir, \"pnpm-workspace.yml\")\n\t\t\t: null;\n\n\tif (pnpmWorkspacePath) {\n\t\tfor (const pattern of parsePnpmWorkspacePackages(pnpmWorkspacePath)) {\n\t\t\tpatterns.add(pattern);\n\t\t}\n\t}\n\n\treturn Array.from(patterns);\n}\n\nfunction resolveWorkspacePackageJsonPaths(dir: string, patterns: string[]): string[] {\n\tconst includePatterns = patterns.filter((pattern) => !pattern.startsWith(\"!\"));\n\tconst excludePatterns = patterns\n\t\t.filter((pattern) => pattern.startsWith(\"!\"))\n\t\t.map((pattern) => pattern.slice(1));\n\n\tif (includePatterns.length === 0) return [];\n\n\tconst includeRegexes = includePatterns.map(patternToRegex);\n\tconst excludeRegexes = excludePatterns.map(patternToRegex);\n\n\tconst matches: string[] = [];\n\tconst directories = walkDirectories(dir);\n\n\tfor (const relativePath of directories) {\n\t\tif (!includeRegexes.some((regex) => regex.test(relativePath))) continue;\n\t\tif (excludeRegexes.some((regex) => regex.test(relativePath))) continue;\n\n\t\tconst packageJsonPath = join(dir, relativePath, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tmatches.push(packageJsonPath);\n\t\t}\n\t}\n\n\treturn Array.from(new Set(matches));\n}\n\nfunction walkDirectories(root: string): string[] {\n\tconst results: string[] = [];\n\tconst stack: string[] = [\"\"];\n\n\twhile (stack.length > 0) {\n\t\tconst relativePath = stack.pop();\n\t\tconst currentPath = relativePath ? join(root, relativePath) : root;\n\n\t\tlet entries: Dirent[];\n\t\ttry {\n\t\t\tentries = readdirSync(currentPath, { withFileTypes: true }) as Dirent[];\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory()) continue;\n\t\t\tif (DEFAULT_IGNORED_DIRS.has(entry.name)) continue;\n\n\t\t\tconst nextRelative = relativePath ? `${relativePath}/${entry.name}` : entry.name;\n\t\t\tresults.push(nextRelative);\n\t\t\tstack.push(nextRelative);\n\t\t}\n\t}\n\n\treturn results;\n}\n\nfunction patternToRegex(pattern: string): RegExp {\n\tlet normalized = pattern.trim().replace(/\\\\/g, \"/\");\n\tif (normalized.startsWith(\"./\")) normalized = normalized.slice(2);\n\tif (normalized.endsWith(\"/\")) normalized = normalized.slice(0, -1);\n\n\tconst escaped = normalized.replace(/[.+^${}()|[\\]\\\\*]/g, \"\\\\$&\");\n\tconst withGlob = escaped.replace(/\\\\\\*\\\\\\*/g, \".*\").replace(/\\\\\\*/g, \"[^/]+\");\n\n\treturn new RegExp(`^${withGlob}$`);\n}\n\nfunction parsePnpmWorkspacePackages(path: string): string[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst patterns: string[] = [];\n\t\tlet inPackages = false;\n\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tif (/^packages\\s*:/.test(trimmed)) {\n\t\t\t\tinPackages = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!inPackages) continue;\n\n\t\t\tconst entryMatch = trimmed.match(/^-\\s*(.+)$/);\n\t\t\tif (entryMatch?.[1]) {\n\t\t\t\tconst value = entryMatch[1].trim().replace(/^['\"]|['\"]$/g, \"\");\n\t\t\t\tif (value) patterns.push(value);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!line.startsWith(\" \") && !line.startsWith(\"\\t\")) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn patterns;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nfunction readJson(path: string): Record<string, unknown> | null {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\treturn JSON.parse(content) as Record<string, unknown>;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction mergeDependencies(base: Dependency[], incoming: Dependency[]): Dependency[] {\n\tconst map = new Map<string, Dependency>();\n\n\tfor (const dep of [...base, ...incoming]) {\n\t\tconst existing = map.get(dep.name);\n\t\tif (!existing) {\n\t\t\tmap.set(dep.name, { ...dep });\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst dev = existing.dev && dep.dev;\n\t\tconst version = existing.version ?? dep.version;\n\t\tmap.set(dep.name, { name: dep.name, version, dev });\n\t}\n\n\treturn Array.from(map.values());\n}\n\n/**\n * Parse package.json dependencies\n */\nfunction parsePackageJson(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst pkg = JSON.parse(content);\n\t\tconst deps: Dependency[] = [];\n\n\t\tif (pkg.dependencies && typeof pkg.dependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.dependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.devDependencies && typeof pkg.devDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.devDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: true });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.peerDependencies && typeof pkg.peerDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.peerDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\tif (pkg.optionalDependencies && typeof pkg.optionalDependencies === \"object\") {\n\t\t\tfor (const [name, version] of Object.entries(pkg.optionalDependencies)) {\n\t\t\t\tdeps.push({ name, version: version as string, dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse pyproject.toml dependencies\n */\nfunction parsePyprojectToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[project\\.dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/[\"']([a-zA-Z0-9_-]+)(?:[>=<~!]+([^\"']+))?[\"']/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse Cargo.toml dependencies\n */\nfunction parseCargoToml(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst depsSection = content.match(/\\[dependencies\\]([\\s\\S]*?)(?=\\[|$)/);\n\t\tif (!depsSection?.[1]) return [];\n\n\t\tconst lines = depsSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst simpleMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*\"([^\"]+)\"/);\n\t\t\tconst tableMatch = line.match(/^([a-zA-Z0-9_-]+)\\s*=\\s*{.*version\\s*=\\s*\"([^\"]+)\"/);\n\n\t\t\tif (simpleMatch?.[1] && simpleMatch[2]) {\n\t\t\t\tdeps.push({ name: simpleMatch[1], version: simpleMatch[2], dev: false });\n\t\t\t} else if (tableMatch?.[1] && tableMatch[2]) {\n\t\t\t\tdeps.push({ name: tableMatch[1], version: tableMatch[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse go.mod dependencies\n */\nfunction parseGoMod(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst requireSection = content.match(/require\\s*\\(([\\s\\S]*?)\\)/);\n\t\tif (!requireSection?.[1]) {\n\t\t\tconst singleRequire = content.match(/require\\s+([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (singleRequire?.[1] && singleRequire[2]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: singleRequire[1],\n\t\t\t\t\tversion: singleRequire[2],\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn deps;\n\t\t}\n\n\t\tconst lines = requireSection[1].split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst match = line.match(/^\\s*([^\\s]+)\\s+([^\\s]+)/);\n\t\t\tif (match?.[1] && match[2]) {\n\t\t\t\tdeps.push({ name: match[1], version: match[2], dev: false });\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/**\n * Parse requirements.txt dependencies\n */\nfunction parseRequirementsTxt(path: string): Dependency[] {\n\ttry {\n\t\tconst content = readFileSync(path, \"utf-8\");\n\t\tconst deps: Dependency[] = [];\n\n\t\tconst lines = content.split(\"\\n\");\n\t\tfor (const line of lines) {\n\t\t\tconst trimmed = line.trim();\n\t\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\t\tconst match = trimmed.match(/^([a-zA-Z0-9_-]+)(?:[>=<~!]+(.+))?/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tdeps.push({\n\t\t\t\t\tname: match[1],\n\t\t\t\t\tversion: match[2]?.trim(),\n\t\t\t\t\tdev: false,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn deps;\n\t} catch {\n\t\treturn [];\n\t}\n}\n","/**\n * Dependency name to GitHub repo resolution:\n * 1. Query npm registry for repository.url\n * 2. Fall back to FALLBACK_MAPPINGS for packages missing repository field\n * 3. Return unknown (caller handles)\n */\n\nimport { NpmPackageResponseSchema } from \"@offworld/types\";\n\nexport type ResolvedDep = {\n\tdep: string;\n\trepo: string | null;\n\tsource: \"npm\" | \"fallback\" | \"unknown\";\n};\n\n/**\n * Fallback mappings for packages where npm registry doesn't have repository.url.\n * Only add packages here that genuinely don't have the field set.\n */\nexport const FALLBACK_MAPPINGS: Record<string, string> = {\n\t\"@convex-dev/react-query\": \"get-convex/convex-react-query\",\n\t\"@opencode-ai/sdk\": \"anomalyco/opencode-sdk-js\",\n};\n\n/**\n * Parse GitHub repo from various git URL formats.\n * Handles:\n * - git+https://github.com/owner/repo.git\n * - https://github.com/owner/repo\n * - git://github.com/owner/repo.git\n * - github:owner/repo\n */\nfunction parseGitHubUrl(url: string): string | null {\n\tconst patterns = [\n\t\t/github\\.com[/:]([\\w-]+)\\/([\\w.-]+?)(?:\\.git)?$/,\n\t\t/^github:([\\w-]+)\\/([\\w.-]+)$/,\n\t];\n\n\tfor (const pattern of patterns) {\n\t\tconst match = url.match(pattern);\n\t\tif (match) {\n\t\t\treturn `${match[1]}/${match[2]}`;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Fallback to npm registry to extract repository.url.\n * Returns null if package not found, no repo field, or not a GitHub repo.\n */\nexport async function resolveFromNpm(packageName: string): Promise<string | null> {\n\ttry {\n\t\tconst res = await fetch(`https://registry.npmjs.org/${packageName}`);\n\t\tif (!res.ok) return null;\n\n\t\tconst json = await res.json();\n\t\tconst result = NpmPackageResponseSchema.safeParse(json);\n\t\tif (!result.success) return null;\n\n\t\tconst repoUrl = result.data.repository?.url;\n\t\tif (!repoUrl) return null;\n\n\t\treturn parseGitHubUrl(repoUrl);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * Resolution order:\n * 1. Query npm registry for repository.url\n * 2. Check FALLBACK_MAPPINGS for packages missing repository field\n * 3. Return unknown\n */\nexport async function resolveDependencyRepo(dep: string): Promise<ResolvedDep> {\n\tconst npmRepo = await resolveFromNpm(dep);\n\tif (npmRepo) {\n\t\treturn { dep, repo: npmRepo, source: \"npm\" };\n\t}\n\n\tif (dep in FALLBACK_MAPPINGS) {\n\t\treturn { dep, repo: FALLBACK_MAPPINGS[dep] ?? null, source: \"fallback\" };\n\t}\n\n\treturn { dep, repo: null, source: \"unknown\" };\n}\n","/**\n * Reference matching utilities for dependency resolution\n *\n * Maps dependencies to their reference status (installed, remote, generate, unknown)\n */\n\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { toReferenceFileName } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\nimport type { ResolvedDep } from \"./dep-mappings.js\";\n\nexport type ReferenceStatus = \"installed\" | \"remote\" | \"generate\" | \"unknown\";\n\nexport interface ReferenceMatch {\n\t/** Dependency name */\n\tdep: string;\n\t/** GitHub repo (owner/repo) or null if unknown */\n\trepo: string | null;\n\t/** Reference availability status */\n\tstatus: ReferenceStatus;\n\t/** Resolution source: 'npm' | 'fallback' | 'unknown' */\n\tsource: \"npm\" | \"fallback\" | \"unknown\";\n}\n\n/**\n * Check if a reference is installed locally.\n * A reference is considered installed if {owner-repo}.md exists in offworld/references/.\n *\n * @param repo - Repo name in owner/repo format\n * @returns true if reference is installed locally\n */\nexport function isReferenceInstalled(repo: string): boolean {\n\tconst referenceFileName = toReferenceFileName(repo);\n\tconst referencePath = join(Paths.offworldReferencesDir, referenceFileName);\n\treturn existsSync(referencePath);\n}\n\n/**\n * Match dependencies to their reference availability status.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Array of reference matches with status\n */\nexport function matchDependenciesToReferences(resolvedDeps: ResolvedDep[]): ReferenceMatch[] {\n\treturn resolvedDeps.map((dep) => {\n\t\tif (!dep.repo) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: null,\n\t\t\t\tstatus: \"unknown\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: dep.repo,\n\t\t\t\tstatus: \"installed\",\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tdep: dep.dep,\n\t\t\trepo: dep.repo,\n\t\t\tstatus: \"generate\",\n\t\t\tsource: dep.source,\n\t\t};\n\t});\n}\n\n/**\n * Match dependencies to their reference availability status with remote check.\n * This is async because it checks the remote server for each dependency.\n *\n * Status logic:\n * - installed: {owner-repo}.md exists in offworld/references/\n * - remote: Reference exists on offworld.sh (quick pull)\n * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)\n * - unknown: No GitHub repo found\n *\n * @param resolvedDeps - Array of resolved dependencies with repo info\n * @returns Promise of array of reference matches with status\n */\nexport async function matchDependenciesToReferencesWithRemoteCheck(\n\tresolvedDeps: ResolvedDep[],\n): Promise<ReferenceMatch[]> {\n\tconst { checkRemote } = await import(\"./sync.js\");\n\tconst results = await Promise.all(\n\t\tresolvedDeps.map(async (dep) => {\n\t\t\tif (!dep.repo) {\n\t\t\t\treturn {\n\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\trepo: null,\n\t\t\t\t\tstatus: \"unknown\" as const,\n\t\t\t\t\tsource: dep.source,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (isReferenceInstalled(dep.repo)) {\n\t\t\t\treturn {\n\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\trepo: dep.repo,\n\t\t\t\t\tstatus: \"installed\" as const,\n\t\t\t\t\tsource: dep.source,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst remote = await checkRemote(dep.repo);\n\t\t\t\tif (remote.exists) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdep: dep.dep,\n\t\t\t\t\t\trepo: dep.repo,\n\t\t\t\t\t\tstatus: \"remote\" as const,\n\t\t\t\t\t\tsource: dep.source,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Network error - fall through to generate\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdep: dep.dep,\n\t\t\t\trepo: dep.repo,\n\t\t\t\tstatus: \"generate\" as const,\n\t\t\t\tsource: dep.source,\n\t\t\t};\n\t\t}),\n\t);\n\n\treturn results;\n}\n","import { existsSync, statSync, readdirSync, rmSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { updateRepo, GitError } from \"./clone.js\";\nimport { readGlobalMap, removeGlobalMapEntry, upsertGlobalMapEntry } from \"./index-manager.js\";\nimport { loadConfig, getRepoRoot } from \"./config.js\";\nimport { Paths } from \"./paths.js\";\n\nexport interface RepoStatusSummary {\n\ttotal: number;\n\twithReference: number;\n\tmissing: number;\n\tdiskBytes: number;\n}\n\nexport interface RepoStatusOptions {\n\tonProgress?: (current: number, total: number, repo: string) => void;\n}\n\nexport interface UpdateAllOptions {\n\tpattern?: string;\n\tdryRun?: boolean;\n\t/** Convert shallow clones to full clones */\n\tunshallow?: boolean;\n\tonProgress?: (\n\t\trepo: string,\n\t\tstatus: \"updating\" | \"updated\" | \"skipped\" | \"error\" | \"unshallowed\",\n\t\tmessage?: string,\n\t) => void;\n}\n\nexport interface UpdateAllResult {\n\tupdated: string[];\n\tskipped: string[];\n\tunshallowed: string[];\n\terrors: Array<{ repo: string; error: string }>;\n}\n\nexport interface PruneOptions {\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string) => void;\n}\n\nexport interface PruneResult {\n\tremovedFromIndex: string[];\n\torphanedDirs: string[];\n}\n\nexport interface GcOptions {\n\tolderThanDays?: number;\n\twithoutReference?: boolean;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, reason: string, sizeBytes?: number) => void;\n}\n\nexport interface GcResult {\n\tremoved: Array<{ repo: string; reason: string; sizeBytes: number }>;\n\tfreedBytes: number;\n}\n\nfunction getDirSize(dirPath: string): number {\n\tif (!existsSync(dirPath)) return 0;\n\n\tlet size = 0;\n\ttry {\n\t\tconst entries = readdirSync(dirPath, { withFileTypes: true });\n\t\tfor (const entry of entries) {\n\t\t\tconst fullPath = join(dirPath, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tsize += getDirSize(fullPath);\n\t\t\t} else if (entry.isFile()) {\n\t\t\t\ttry {\n\t\t\t\t\tsize += statSync(fullPath).size;\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn size;\n}\n\nfunction getLastAccessTime(dirPath: string): Date | null {\n\tif (!existsSync(dirPath)) return null;\n\n\tlet latestTime: Date | null = null;\n\ttry {\n\t\tconst stat = statSync(dirPath);\n\t\tlatestTime = stat.mtime;\n\n\t\tconst fetchHead = join(dirPath, \".git\", \"FETCH_HEAD\");\n\t\tif (existsSync(fetchHead)) {\n\t\t\tconst fetchStat = statSync(fetchHead);\n\t\t\tif (!latestTime || fetchStat.mtime > latestTime) {\n\t\t\t\tlatestTime = fetchStat.mtime;\n\t\t\t}\n\t\t}\n\t} catch {}\n\treturn latestTime;\n}\n\nfunction matchesPattern(name: string, pattern: string): boolean {\n\tif (!pattern || pattern === \"*\") return true;\n\n\tconst regex = new RegExp(\n\t\t\"^\" +\n\t\t\tpattern\n\t\t\t\t.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\")\n\t\t\t\t.replace(/\\*/g, \".*\")\n\t\t\t\t.replace(/\\?/g, \".\") +\n\t\t\t\"$\",\n\t\t\"i\",\n\t);\n\treturn regex.test(name);\n}\n\nconst yieldToEventLoop = () => new Promise<void>((resolve) => setImmediate(resolve));\n\nexport async function getRepoStatus(options: RepoStatusOptions = {}): Promise<RepoStatusSummary> {\n\tconst { onProgress } = options;\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst total = qualifiedNames.length;\n\n\tlet withReference = 0;\n\tlet missing = 0;\n\tlet diskBytes = 0;\n\n\tfor (let i = 0; i < qualifiedNames.length; i++) {\n\t\tconst qualifiedName = qualifiedNames[i]!;\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tonProgress?.(i + 1, total, qualifiedName);\n\n\t\tawait yieldToEventLoop();\n\n\t\tconst exists = existsSync(entry.localPath);\n\n\t\tif (!exists) {\n\t\t\tmissing++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.references.length > 0) {\n\t\t\twithReference++;\n\t\t}\n\n\t\tdiskBytes += getDirSize(entry.localPath);\n\t}\n\n\treturn {\n\t\ttotal,\n\t\twithReference,\n\t\tmissing,\n\t\tdiskBytes,\n\t};\n}\n\nexport async function updateAllRepos(options: UpdateAllOptions = {}): Promise<UpdateAllResult> {\n\tconst { pattern, dryRun = false, unshallow = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst updated: string[] = [];\n\tconst skipped: string[] = [];\n\tconst unshallowed: string[] = [];\n\tconst errors: Array<{ repo: string; error: string }> = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\n\t\tif (pattern && !matchesPattern(qualifiedName, pattern)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tskipped.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"skipped\", \"missing on disk\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (dryRun) {\n\t\t\tupdated.push(qualifiedName);\n\t\t\tonProgress?.(qualifiedName, \"updated\", \"would update\");\n\t\t\tcontinue;\n\t\t}\n\n\t\tonProgress?.(qualifiedName, \"updating\");\n\t\ttry {\n\t\t\tconst result = await updateRepo(qualifiedName, { unshallow });\n\t\t\tif (result.unshallowed) {\n\t\t\t\tunshallowed.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"unshallowed\", \"converted to full clone\");\n\t\t\t}\n\t\t\tif (result.updated) {\n\t\t\t\tupdated.push(qualifiedName);\n\t\t\t\tonProgress?.(\n\t\t\t\t\tqualifiedName,\n\t\t\t\t\t\"updated\",\n\t\t\t\t\t`${result.previousSha.slice(0, 7)} → ${result.currentSha.slice(0, 7)}`,\n\t\t\t\t);\n\t\t\t} else if (!result.unshallowed) {\n\t\t\t\tskipped.push(qualifiedName);\n\t\t\t\tonProgress?.(qualifiedName, \"skipped\", \"already up to date\");\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof GitError ? err.message : String(err);\n\t\t\terrors.push({ repo: qualifiedName, error: message });\n\t\t\tonProgress?.(qualifiedName, \"error\", message);\n\t\t}\n\t}\n\n\treturn { updated, skipped, unshallowed, errors };\n}\n\nexport async function pruneRepos(options: PruneOptions = {}): Promise<PruneResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removedFromIndex: string[] = [];\n\tconst orphanedDirs: string[] = [];\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) {\n\t\t\tonProgress?.(qualifiedName, \"missing on disk\");\n\t\t\tremovedFromIndex.push(qualifiedName);\n\n\t\t\tif (!dryRun) {\n\t\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst config = loadConfig();\n\tconst repoRoot = getRepoRoot(config);\n\n\tif (existsSync(repoRoot)) {\n\t\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\t\ttry {\n\t\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\t\tfor (const provider of providers) {\n\t\t\t\tif (!provider.isDirectory()) continue;\n\t\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\t\tfor (const owner of owners) {\n\t\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\t\tif (!indexedPaths.has(repoPath)) {\n\t\t\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\t\t\tonProgress?.(fullName, \"not in map\");\n\t\t\t\t\t\t\torphanedDirs.push(repoPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t}\n\n\treturn { removedFromIndex, orphanedDirs };\n}\n\nexport async function gcRepos(options: GcOptions = {}): Promise<GcResult> {\n\tconst { olderThanDays, withoutReference = false, dryRun = false, onProgress } = options;\n\n\tconst map = readGlobalMap();\n\tconst qualifiedNames = Object.keys(map.repos);\n\tconst removed: Array<{ repo: string; reason: string; sizeBytes: number }> = [];\n\tlet freedBytes = 0;\n\n\tconst now = new Date();\n\tconst cutoffDate = olderThanDays\n\t\t? new Date(now.getTime() - olderThanDays * 24 * 60 * 60 * 1000)\n\t\t: null;\n\n\tfor (const qualifiedName of qualifiedNames) {\n\t\tconst entry = map.repos[qualifiedName]!;\n\t\tawait yieldToEventLoop();\n\n\t\tif (!existsSync(entry.localPath)) continue;\n\n\t\tlet shouldRemove = false;\n\t\tlet reason = \"\";\n\n\t\tif (cutoffDate) {\n\t\t\tconst lastAccess = getLastAccessTime(entry.localPath);\n\t\t\tif (lastAccess && lastAccess < cutoffDate) {\n\t\t\t\tshouldRemove = true;\n\t\t\t\treason = `not accessed in ${olderThanDays}+ days`;\n\t\t\t}\n\t\t}\n\n\t\tif (withoutReference && entry.references.length === 0) {\n\t\t\tshouldRemove = true;\n\t\t\treason = reason ? `${reason}, no reference` : \"no reference\";\n\t\t}\n\n\t\tif (!shouldRemove) continue;\n\n\t\tconst sizeBytes = getDirSize(entry.localPath);\n\t\tonProgress?.(qualifiedName, reason, sizeBytes);\n\n\t\tif (!dryRun) {\n\t\t\trmSync(entry.localPath, { recursive: true, force: true });\n\n\t\t\tfor (const refFile of entry.references) {\n\t\t\t\tconst refPath = join(Paths.offworldReferencesDir, refFile);\n\t\t\t\tif (existsSync(refPath)) {\n\t\t\t\t\trmSync(refPath, { force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (entry.primary) {\n\t\t\t\tconst metaDirName = entry.primary.replace(/\\.md$/, \"\");\n\t\t\t\tconst metaPath = join(Paths.metaDir, metaDirName);\n\t\t\t\tif (existsSync(metaPath)) {\n\t\t\t\t\trmSync(metaPath, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tremoveGlobalMapEntry(qualifiedName);\n\t\t}\n\n\t\tremoved.push({ repo: qualifiedName, reason, sizeBytes });\n\t\tfreedBytes += sizeBytes;\n\t}\n\n\treturn { removed, freedBytes };\n}\n\nexport interface DiscoverOptions {\n\trepoRoot?: string;\n\tdryRun?: boolean;\n\tonProgress?: (repo: string, provider: string) => void;\n}\n\nexport interface DiscoverResult {\n\tdiscovered: Array<{ fullName: string; qualifiedName: string; localPath: string }>;\n\talreadyIndexed: number;\n}\n\nexport async function discoverRepos(options: DiscoverOptions = {}): Promise<DiscoverResult> {\n\tconst { dryRun = false, onProgress } = options;\n\n\tconst config = loadConfig();\n\tconst repoRoot = options.repoRoot ?? getRepoRoot(config);\n\tconst discovered: Array<{ fullName: string; qualifiedName: string; localPath: string }> = [];\n\tlet alreadyIndexed = 0;\n\n\tif (!existsSync(repoRoot)) {\n\t\treturn { discovered, alreadyIndexed };\n\t}\n\n\tconst map = readGlobalMap();\n\tconst indexedPaths = new Set(Object.values(map.repos).map((r) => r.localPath));\n\n\ttry {\n\t\tconst providers = readdirSync(repoRoot, { withFileTypes: true });\n\t\tfor (const provider of providers) {\n\t\t\tif (!provider.isDirectory()) continue;\n\t\t\tconst providerPath = join(repoRoot, provider.name);\n\n\t\t\tconst providerHostMap: Record<string, string> = {\n\t\t\t\tgithub: \"github.com\",\n\t\t\t\tgitlab: \"gitlab.com\",\n\t\t\t\tbitbucket: \"bitbucket.org\",\n\t\t\t};\n\t\t\tconst providerHost = providerHostMap[provider.name] ?? provider.name;\n\n\t\t\tconst owners = readdirSync(providerPath, { withFileTypes: true });\n\t\t\tfor (const owner of owners) {\n\t\t\t\tif (!owner.isDirectory()) continue;\n\t\t\t\tconst ownerPath = join(providerPath, owner.name);\n\n\t\t\t\tconst repoNames = readdirSync(ownerPath, { withFileTypes: true });\n\t\t\t\tfor (const repoName of repoNames) {\n\t\t\t\t\tawait yieldToEventLoop();\n\n\t\t\t\t\tif (!repoName.isDirectory()) continue;\n\t\t\t\t\tconst repoPath = join(ownerPath, repoName.name);\n\n\t\t\t\t\tif (!existsSync(join(repoPath, \".git\"))) continue;\n\n\t\t\t\t\tif (indexedPaths.has(repoPath)) {\n\t\t\t\t\t\talreadyIndexed++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst fullName = `${owner.name}/${repoName.name}`;\n\t\t\t\t\tconst qualifiedName = `${providerHost}:${fullName}`;\n\n\t\t\t\t\tonProgress?.(fullName, providerHost);\n\n\t\t\t\t\tif (!dryRun) {\n\t\t\t\t\t\tupsertGlobalMapEntry(qualifiedName, {\n\t\t\t\t\t\t\tlocalPath: repoPath,\n\t\t\t\t\t\t\treferences: [],\n\t\t\t\t\t\t\tprimary: \"\",\n\t\t\t\t\t\t\tkeywords: [],\n\t\t\t\t\t\t\tupdatedAt: new Date().toISOString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tdiscovered.push({ fullName, qualifiedName, localPath: repoPath });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch {}\n\n\treturn { discovered, alreadyIndexed };\n}\n","import { ModelsDevDataSchema, type ModelsDevProvider } from \"@offworld/types\";\n\nconst MODELS_DEV_URL = \"https://models.dev/api.json\";\n\n/**\n * Simplified provider info for CLI display\n */\nexport interface ProviderInfo {\n\tid: string;\n\tname: string;\n\tenv: string[];\n}\n\n/**\n * Simplified model info for CLI display\n */\nexport interface ModelInfo {\n\tid: string;\n\tname: string;\n\treasoning: boolean;\n\texperimental?: boolean;\n\tstatus?: \"alpha\" | \"beta\" | \"deprecated\";\n}\n\n/**\n * Full provider with models for CLI display\n */\nexport interface ProviderWithModels extends ProviderInfo {\n\tmodels: ModelInfo[];\n}\n\nlet cachedData: Record<string, ModelsDevProvider> | null = null;\nlet cacheTime = 0;\nconst CACHE_TTL_MS = 5 * 60 * 1000;\n\n/**\n * Fetch raw data from models.dev with caching\n */\nasync function fetchModelsDevData(): Promise<Record<string, ModelsDevProvider>> {\n\tconst now = Date.now();\n\tif (cachedData && now - cacheTime < CACHE_TTL_MS) {\n\t\treturn cachedData;\n\t}\n\n\tconst res = await fetch(MODELS_DEV_URL, {\n\t\tsignal: AbortSignal.timeout(10_000),\n\t});\n\n\tif (!res.ok) {\n\t\tthrow new Error(`Failed to fetch models.dev: ${res.status} ${res.statusText}`);\n\t}\n\n\tconst json = await res.json();\n\tconst parsed = ModelsDevDataSchema.safeParse(json);\n\tif (!parsed.success) {\n\t\tthrow new Error(`Invalid models.dev response: ${parsed.error.message}`);\n\t}\n\tcachedData = parsed.data;\n\tcacheTime = now;\n\treturn cachedData;\n}\n\n/**\n * List all available providers from models.dev\n */\nexport async function listProviders(): Promise<ProviderInfo[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Get a specific provider with all its models\n */\nexport async function getProvider(providerId: string): Promise<ProviderWithModels | null> {\n\tconst data = await fetchModelsDevData();\n\tconst provider = data[providerId];\n\n\tif (!provider) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tid: provider.id,\n\t\tname: provider.name,\n\t\tenv: provider.env ?? [],\n\t\tmodels: Object.values(provider.models)\n\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t.map((m) => ({\n\t\t\t\tid: m.id,\n\t\t\t\tname: m.name,\n\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\texperimental: m.experimental,\n\t\t\t\tstatus: m.status,\n\t\t\t}))\n\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t};\n}\n\n/**\n * Get all providers with their models\n */\nexport async function listProvidersWithModels(): Promise<ProviderWithModels[]> {\n\tconst data = await fetchModelsDevData();\n\n\treturn Object.values(data)\n\t\t.map((p) => ({\n\t\t\tid: p.id,\n\t\t\tname: p.name,\n\t\t\tenv: p.env ?? [],\n\t\t\tmodels: Object.values(p.models)\n\t\t\t\t.filter((m) => m.status !== \"deprecated\")\n\t\t\t\t.map((m) => ({\n\t\t\t\t\tid: m.id,\n\t\t\t\t\tname: m.name,\n\t\t\t\t\treasoning: m.reasoning ?? false,\n\t\t\t\t\texperimental: m.experimental,\n\t\t\t\t\tstatus: m.status,\n\t\t\t\t}))\n\t\t\t\t.sort((a, b) => a.name.localeCompare(b.name)),\n\t\t}))\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\n/**\n * Validate that a provider/model combination exists\n */\nexport async function validateProviderModel(\n\tproviderId: string,\n\tmodelId: string,\n): Promise<{ valid: boolean; error?: string }> {\n\tconst provider = await getProvider(providerId);\n\n\tif (!provider) {\n\t\tconst providers = await listProviders();\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Provider \"${providerId}\" not found. Available: ${providers\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((p) => p.id)\n\t\t\t\t.join(\", \")}${providers.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\tconst model = provider.models.find((m) => m.id === modelId);\n\tif (!model) {\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terror: `Model \"${modelId}\" not found for provider \"${providerId}\". Available: ${provider.models\n\t\t\t\t.slice(0, 10)\n\t\t\t\t.map((m) => m.id)\n\t\t\t\t.join(\", \")}${provider.models.length > 10 ? \"...\" : \"\"}`,\n\t\t};\n\t}\n\n\treturn { valid: true };\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,UAAU;;;;;AAMvB,MAAa,0BAA0B;CACtC;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;;;;;;;ACjGD,IAAa,kBAAb,cAAqC,MAAM;CAC1C,YAAY,SAAiB;AAC5B,QAAM,QAAQ;AACd,OA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B,QAAQ,EAAE;GACV,EAAE,CACF,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;EAC9C,EAAE,CACF,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC;;;;;AAM/C,eAAsB,sBACrB,YACA,SAC8C;CAC9C,MAAM,WAAW,MAAM,YAAY,WAAW;AAE9C,KAAI,CAAC,UAAU;EACd,MAAM,YAAY,MAAM,eAAe;AACvC,SAAO;GACN,OAAO;GACP,OAAO,aAAa,WAAW,0BAA0B,UACvD,MAAM,GAAG,GAAG,CACZ,KAAK,MAAM,EAAE,GAAG,CAChB,KAAK,KAAK,GAAG,UAAU,SAAS,KAAK,QAAQ;GAC/C;;AAIF,KAAI,CADU,SAAS,OAAO,MAAM,MAAM,EAAE,OAAO,QAAQ,CAE1D,QAAO;EACN,OAAO;EACP,OAAO,UAAU,QAAQ,4BAA4B,WAAW,gBAAgB,SAAS,OACvF,MAAM,GAAG,GAAG,CACZ,KAAK,MAAM,EAAE,GAAG,CAChB,KAAK,KAAK,GAAG,SAAS,OAAO,SAAS,KAAK,QAAQ;EACrD;AAGF,QAAO,EAAE,OAAO,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@offworld/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Core SDK for Offworld - clone repos, generate references, sync with offworld.sh",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -82,14 +82,14 @@
|
|
|
82
82
|
"zod": "^4.3.6"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@types/node": "^25.0
|
|
85
|
+
"@types/node": "^25.2.0",
|
|
86
86
|
"tsdown": "^0.20.1",
|
|
87
87
|
"typescript": "^5.9.3",
|
|
88
88
|
"vitest": "^4.0.18"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@opencode-ai/sdk": "^1.1.36",
|
|
92
|
-
"convex": "^1.31.
|
|
92
|
+
"convex": "^1.31.7"
|
|
93
93
|
},
|
|
94
94
|
"peerDependenciesMeta": {
|
|
95
95
|
"@opencode-ai/sdk": {
|