@offworld/sdk 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -20
- package/dist/ai/index.d.mts +134 -0
- package/dist/ai/index.d.mts.map +1 -0
- package/dist/ai/index.mjs +924 -0
- package/dist/ai/index.mjs.map +1 -0
- package/dist/clone-DyLvmbJZ.mjs +364 -0
- package/dist/clone-DyLvmbJZ.mjs.map +1 -0
- package/dist/config-DW8J4gl5.mjs +174 -0
- package/dist/config-DW8J4gl5.mjs.map +1 -0
- package/dist/convex/_generated/api.d.ts +67 -0
- package/dist/convex/_generated/api.js +23 -0
- package/dist/convex/_generated/dataModel.d.ts +60 -0
- package/dist/convex/_generated/server.d.ts +143 -0
- package/dist/convex/_generated/server.js +93 -0
- package/dist/index.d.mts +2 -953
- package/dist/index.mjs +4 -3909
- package/dist/internal.d.mts +69 -0
- package/dist/internal.d.mts.map +1 -0
- package/dist/internal.mjs +326 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/public-DbZeh2Mr.mjs +1823 -0
- package/dist/public-DbZeh2Mr.mjs.map +1 -0
- package/dist/public-MYVLaKUi.d.mts +655 -0
- package/dist/public-MYVLaKUi.d.mts.map +1 -0
- package/dist/sync/index.d.mts +175 -0
- package/dist/sync/index.d.mts.map +1 -0
- package/dist/sync/index.mjs +4 -0
- package/dist/sync-DuLJ5wla.mjs +4 -0
- package/dist/sync-wcy5fJRb.mjs +372 -0
- package/dist/sync-wcy5fJRb.mjs.map +1 -0
- package/package.json +35 -6
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -10,26 +10,40 @@ Powers the CLI and web app with git clone management, AI reference generation, a
|
|
|
10
10
|
bun add @offworld/sdk
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
### Optional dependencies
|
|
14
|
+
|
|
15
|
+
- Sync: `bun add convex`
|
|
16
|
+
- AI: `bun add @opencode-ai/sdk`
|
|
17
|
+
|
|
18
|
+
### Entry points
|
|
19
|
+
|
|
20
|
+
- `@offworld/sdk` (core local functionality)
|
|
21
|
+
- `@offworld/sdk/sync` (Convex sync)
|
|
22
|
+
- `@offworld/sdk/ai` (AI generation)
|
|
23
|
+
- `@offworld/sdk/internal` (CLI-only helpers)
|
|
24
|
+
- `@offworld/sdk/convex/api` and `@offworld/sdk/convex/server` (Convex types)
|
|
25
|
+
|
|
13
26
|
## Modules
|
|
14
27
|
|
|
15
|
-
| Module | Description
|
|
16
|
-
| ---------------------- |
|
|
17
|
-
| `config.ts` | Config load/save, path utilities
|
|
18
|
-
| `paths.ts` | XDG-compliant path resolution
|
|
19
|
-
| `clone.ts` | Git clone/update/remove
|
|
20
|
-
| `index-manager.ts` | Global + project map management
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `agents
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
28
|
+
| Module | Description |
|
|
29
|
+
| ---------------------- | -------------------------------------------------- |
|
|
30
|
+
| `config.ts` | Config load/save, path utilities |
|
|
31
|
+
| `paths.ts` | XDG-compliant path resolution |
|
|
32
|
+
| `clone.ts` | Git clone/update/remove |
|
|
33
|
+
| `index-manager.ts` | Global + project map management |
|
|
34
|
+
| `reference.ts` | Reference install + SKILL.md |
|
|
35
|
+
| `generate.ts` | AI reference generation (`@offworld/sdk/ai`) |
|
|
36
|
+
| `sync.ts` | Convex client for push/pull (`@offworld/sdk/sync`) |
|
|
37
|
+
| `auth.ts` | WorkOS token management |
|
|
38
|
+
| `agents.ts` | Agent registry |
|
|
39
|
+
| `agents-md.ts` | AGENTS.md reference table generation (internal) |
|
|
40
|
+
| `repo-source.ts` | Parse repo input (URL, owner/repo, local) |
|
|
41
|
+
| `manifest.ts` | Dependency parsing (package.json, etc.) |
|
|
42
|
+
| `dep-mappings.ts` | npm package to GitHub repo resolution |
|
|
43
|
+
| `reference-matcher.ts` | Match deps to installed references |
|
|
44
|
+
| `repo-manager.ts` | Bulk repo operations (update, prune, gc) |
|
|
45
|
+
| `models.ts` | AI provider/model registry |
|
|
46
|
+
| `installation.ts` | Upgrade/uninstall utilities |
|
|
33
47
|
|
|
34
48
|
## Usage
|
|
35
49
|
|
|
@@ -56,7 +70,8 @@ await removeRepo("owner/repo", { referenceOnly: true });
|
|
|
56
70
|
### Reference Generation
|
|
57
71
|
|
|
58
72
|
```typescript
|
|
59
|
-
import { generateReferenceWithAI
|
|
73
|
+
import { generateReferenceWithAI } from "@offworld/sdk/ai";
|
|
74
|
+
import { installReference } from "@offworld/sdk";
|
|
60
75
|
|
|
61
76
|
const result = await generateReferenceWithAI(repoPath, { model: "claude-sonnet-4-20250514" });
|
|
62
77
|
await installReference("owner/repo", result.referenceContent, result.commitSha);
|
|
@@ -75,7 +90,7 @@ await writeProjectMap(cwd, projectMap);
|
|
|
75
90
|
### Sync (Push/Pull)
|
|
76
91
|
|
|
77
92
|
```typescript
|
|
78
|
-
import { pullReference, pushReference, checkRemote } from "@offworld/sdk";
|
|
93
|
+
import { pullReference, pushReference, checkRemote } from "@offworld/sdk/sync";
|
|
79
94
|
|
|
80
95
|
const ref = await pullReference("owner/repo");
|
|
81
96
|
await pushReference("owner/repo", referenceData);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
//#region src/ai/opencode.d.ts
|
|
2
|
+
declare const DEFAULT_AI_PROVIDER = "opencode";
|
|
3
|
+
declare const DEFAULT_AI_MODEL = "claude-opus-4-5";
|
|
4
|
+
interface StreamPromptOptions {
|
|
5
|
+
prompt: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
systemPrompt?: string;
|
|
8
|
+
provider?: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
/** Timeout in milliseconds. Set to 0 or undefined for no timeout. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
onDebug?: (message: string) => void;
|
|
13
|
+
onStream?: (text: string) => void;
|
|
14
|
+
}
|
|
15
|
+
interface StreamPromptResult {
|
|
16
|
+
text: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
durationMs: number;
|
|
19
|
+
}
|
|
20
|
+
declare function streamPrompt(options: StreamPromptOptions): Promise<StreamPromptResult>;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/ai/errors.d.ts
|
|
23
|
+
/**
|
|
24
|
+
* Base class for OpenCode reference errors
|
|
25
|
+
*/
|
|
26
|
+
declare class OpenCodeReferenceError extends Error {
|
|
27
|
+
readonly details?: unknown | undefined;
|
|
28
|
+
readonly _tag: string;
|
|
29
|
+
constructor(message: string, details?: unknown | undefined);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error when the @opencode-ai/sdk package is not installed or invalid
|
|
33
|
+
*/
|
|
34
|
+
declare class OpenCodeSDKError extends OpenCodeReferenceError {
|
|
35
|
+
readonly _tag: "OpenCodeSDKError";
|
|
36
|
+
constructor(message?: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Error when the requested provider is not found
|
|
40
|
+
*/
|
|
41
|
+
declare class InvalidProviderError extends OpenCodeReferenceError {
|
|
42
|
+
readonly providerID: string;
|
|
43
|
+
readonly availableProviders: string[];
|
|
44
|
+
readonly _tag: "InvalidProviderError";
|
|
45
|
+
readonly hint: string;
|
|
46
|
+
constructor(providerID: string, availableProviders: string[]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error when the provider exists but is not connected/authenticated
|
|
50
|
+
*/
|
|
51
|
+
declare class ProviderNotConnectedError extends OpenCodeReferenceError {
|
|
52
|
+
readonly providerID: string;
|
|
53
|
+
readonly connectedProviders: string[];
|
|
54
|
+
readonly _tag: "ProviderNotConnectedError";
|
|
55
|
+
readonly hint: string;
|
|
56
|
+
constructor(providerID: string, connectedProviders: string[]);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error when the requested model is not found for a provider
|
|
60
|
+
*/
|
|
61
|
+
declare class InvalidModelError extends OpenCodeReferenceError {
|
|
62
|
+
readonly modelID: string;
|
|
63
|
+
readonly providerID: string;
|
|
64
|
+
readonly availableModels: string[];
|
|
65
|
+
readonly _tag: "InvalidModelError";
|
|
66
|
+
readonly hint: string;
|
|
67
|
+
constructor(modelID: string, providerID: string, availableModels: string[]);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Error when the OpenCode server fails to start
|
|
71
|
+
*/
|
|
72
|
+
declare class ServerStartError extends OpenCodeReferenceError {
|
|
73
|
+
readonly port?: number | undefined;
|
|
74
|
+
readonly _tag: "ServerStartError";
|
|
75
|
+
readonly hint: string;
|
|
76
|
+
constructor(message: string, port?: number | undefined, details?: unknown);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Error when a session operation fails
|
|
80
|
+
*/
|
|
81
|
+
declare class SessionError extends OpenCodeReferenceError {
|
|
82
|
+
readonly sessionId?: string | undefined;
|
|
83
|
+
readonly sessionState?: string | undefined;
|
|
84
|
+
readonly _tag: "SessionError";
|
|
85
|
+
readonly hint: string;
|
|
86
|
+
constructor(message: string, sessionId?: string | undefined, sessionState?: string | undefined, details?: unknown);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Error when a request times out
|
|
90
|
+
*/
|
|
91
|
+
declare class TimeoutError extends OpenCodeReferenceError {
|
|
92
|
+
readonly timeoutMs: number;
|
|
93
|
+
readonly operation: string;
|
|
94
|
+
readonly _tag: "TimeoutError";
|
|
95
|
+
readonly hint: string;
|
|
96
|
+
constructor(timeoutMs: number, operation?: string);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/generate.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* This module provides a streamlined approach to generating reference files
|
|
102
|
+
* by delegating all codebase exploration to the AI agent via OpenCode.
|
|
103
|
+
*/
|
|
104
|
+
interface GenerateReferenceOptions {
|
|
105
|
+
/** AI provider ID (e.g., "anthropic", "openai"). Defaults to config value. */
|
|
106
|
+
provider?: string;
|
|
107
|
+
/** AI model ID. Defaults to config value. */
|
|
108
|
+
model?: string;
|
|
109
|
+
/** Debug callback for detailed logging */
|
|
110
|
+
onDebug?: (message: string) => void;
|
|
111
|
+
/** Stream callback for real-time AI output */
|
|
112
|
+
onStream?: (text: string) => void;
|
|
113
|
+
}
|
|
114
|
+
interface GenerateReferenceResult {
|
|
115
|
+
/** The generated reference markdown content */
|
|
116
|
+
referenceContent: string;
|
|
117
|
+
/** The commit SHA at the time of generation */
|
|
118
|
+
commitSha: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generate a reference markdown file for a repository using AI.
|
|
122
|
+
*
|
|
123
|
+
* Opens an OpenCode session and instructs the AI agent to explore the codebase
|
|
124
|
+
* using Read, Grep, and Glob tools, then produce a comprehensive reference.
|
|
125
|
+
*
|
|
126
|
+
* @param repoPath - Path to the repository to analyze
|
|
127
|
+
* @param repoName - Qualified name of the repo (e.g., "tanstack/query" or "my-local-repo")
|
|
128
|
+
* @param options - Generation options (provider, model, callbacks)
|
|
129
|
+
* @returns The generated reference content and commit SHA
|
|
130
|
+
*/
|
|
131
|
+
declare function generateReferenceWithAI(repoPath: string, repoName: string, options?: GenerateReferenceOptions): Promise<GenerateReferenceResult>;
|
|
132
|
+
//#endregion
|
|
133
|
+
export { DEFAULT_AI_MODEL, DEFAULT_AI_PROVIDER, type GenerateReferenceOptions, type GenerateReferenceResult, InvalidModelError, InvalidProviderError, OpenCodeReferenceError, OpenCodeSDKError, ProviderNotConnectedError, ServerStartError, SessionError, type StreamPromptOptions, type StreamPromptResult, TimeoutError, generateReferenceWithAI, streamPrompt };
|
|
134
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/ai/opencode.ts","../../src/ai/errors.ts","../../src/gener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