@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/dist/index.d.mts CHANGED
@@ -1,953 +1,2 @@
1
- import { Agent, Config, Config as Config$1, FileIndex, FileIndexEntry, FileRole, GlobalMap, GlobalMap as GlobalMap$1, GlobalMapRepoEntry, GlobalMapRepoEntry as GlobalMapRepoEntry$1, ProjectMap, ProjectMap as ProjectMap$1, ProjectMapRepoEntry, ProjectMapRepoEntry as ProjectMapRepoEntry$1, RemoteRepoSource, RepoSource, RepoSource as RepoSource$1 } from "@offworld/types";
2
-
3
- //#region src/constants.d.ts
4
- /**
5
- * SDK Constants
6
- */
7
- /** SDK version - must match package.json */
8
- declare const VERSION = "0.2.2";
9
- /**
10
- * Default patterns to ignore when scanning repositories.
11
- * Includes directories, binary files, IDE configs, and build outputs.
12
- */
13
- declare const DEFAULT_IGNORE_PATTERNS: readonly [".git", ".git/**", ".svn", ".hg", "node_modules", "node_modules/**", "vendor", "vendor/**", ".pnpm", ".yarn", "dist", "dist/**", "build", "build/**", "out", "out/**", ".next", ".nuxt", ".output", "target", "__pycache__", "*.pyc", ".vscode", ".vscode/**", ".idea", ".idea/**", "*.swp", "*.swo", ".DS_Store", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.ico", "*.webp", "*.svg", "*.bmp", "*.tiff", "*.mp4", "*.webm", "*.mov", "*.avi", "*.mkv", "*.mp3", "*.wav", "*.flac", "*.ogg", "*.pdf", "*.zip", "*.tar", "*.gz", "*.rar", "*.7z", "*.exe", "*.dll", "*.so", "*.dylib", "*.bin", "*.wasm", "*.woff", "*.woff2", "*.ttf", "*.eot", "*.otf", "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "Cargo.lock", "Gemfile.lock", "poetry.lock", "composer.lock", "go.sum", "coverage", "coverage/**", ".nyc_output", ".coverage", "htmlcov", "*.log", "logs", "tmp", "temp", ".tmp", ".temp", ".cache", ".env", ".env.*", "*.pem", "*.key"];
14
- //#endregion
15
- //#region src/config.d.ts
16
- /**
17
- * Returns the repository root directory.
18
- * Uses configured repoRoot or defaults to ~/ow
19
- */
20
- declare function getMetaRoot(): string;
21
- declare function getRepoRoot(config?: Config$1): string;
22
- /**
23
- * Returns the path for a specific repository.
24
- * Format: {repoRoot}/{provider}/{owner}/{repo}
25
- *
26
- * @param fullName - The repo identifier in "owner/repo" format
27
- * @param provider - Git provider (defaults to "github")
28
- * @param config - Optional config for custom repoRoot
29
- */
30
- declare function getRepoPath(fullName: string, provider?: "github" | "gitlab" | "bitbucket", config?: Config$1): string;
31
- /**
32
- * Convert owner/repo format to meta directory name.
33
- * Collapses owner==repo (e.g., better-auth/better-auth -> better-auth)
34
- */
35
- declare function toMetaDirName(repoName: string): string;
36
- /**
37
- * Convert owner/repo format to reference filename.
38
- * Collapses redundant owner/repo pairs by checking if repo name is contained in owner:
39
- * - honojs/hono -> hono.md (hono is in honojs)
40
- * - get-convex/convex-backend -> convex-backend.md (convex is in get-convex)
41
- * - tanstack/query -> tanstack-query.md (query is not in tanstack)
42
- */
43
- declare function toReferenceFileName(repoName: string): string;
44
- declare function toReferenceName(repoName: string): string;
45
- declare function getReferencePath(fullName: string): string;
46
- declare function getMetaPath(fullName: string): string;
47
- /**
48
- * Returns the path to the configuration file
49
- * Uses XDG Base Directory specification
50
- */
51
- declare function getConfigPath(): string;
52
- /**
53
- * Loads configuration from ~/.config/offworld/offworld.json
54
- * Returns defaults if file doesn't exist
55
- */
56
- declare function loadConfig(): Config$1;
57
- /**
58
- * Saves configuration to ~/.config/offworld/offworld.json
59
- * Creates directory if it doesn't exist
60
- * Merges with existing config
61
- */
62
- declare function saveConfig(updates: Partial<Config$1>): Config$1;
63
- //#endregion
64
- //#region src/paths.d.ts
65
- /**
66
- * XDG-based directory paths for offworld CLI
67
- * Uses xdg-basedir package for cross-platform compatibility (Linux/macOS)
68
- */
69
- /**
70
- * Main namespace for all XDG-compliant paths
71
- */
72
- declare const Paths: {
73
- /**
74
- * XDG_CONFIG_HOME/offworld
75
- * Fallback: ~/.config/offworld
76
- */
77
- readonly config: string;
78
- /**
79
- * XDG_DATA_HOME/offworld
80
- * Fallback: ~/.local/share/offworld
81
- */
82
- readonly data: string;
83
- /**
84
- * XDG_STATE_HOME/offworld
85
- * Fallback: ~/.local/state/offworld
86
- */
87
- readonly state: string;
88
- /**
89
- * Configuration file path: ~/.config/offworld/offworld.json
90
- */
91
- readonly configFile: string;
92
- /**
93
- * Auth file path: ~/.local/share/offworld/auth.json
94
- */
95
- readonly authFile: string;
96
- /**
97
- * Meta directory: ~/.local/share/offworld/meta
98
- */
99
- readonly metaDir: string;
100
- /**
101
- * Default repo root: ~/ow
102
- */
103
- readonly defaultRepoRoot: string;
104
- /**
105
- * Offworld single-skill directory: ~/.local/share/offworld/skill/offworld
106
- */
107
- readonly offworldSkillDir: string;
108
- /**
109
- * Offworld references directory: ~/.local/share/offworld/skill/offworld/references
110
- */
111
- readonly offworldReferencesDir: string;
112
- /**
113
- * Offworld assets directory: ~/.local/share/offworld/skill/offworld/assets
114
- */
115
- readonly offworldAssetsDir: string;
116
- /**
117
- * Global map path: ~/.local/share/offworld/skill/offworld/assets/map.json
118
- */
119
- readonly offworldGlobalMapPath: string;
120
- };
121
- /**
122
- * Expands ~ to user's home directory (for backward compatibility)
123
- */
124
- declare function expandTilde(path: string): string;
125
- //#endregion
126
- //#region src/repo-source.d.ts
127
- declare class RepoSourceError extends Error {
128
- constructor(message: string);
129
- }
130
- declare class PathNotFoundError extends RepoSourceError {
131
- constructor(path: string);
132
- }
133
- declare class NotGitRepoError extends RepoSourceError {
134
- constructor(path: string);
135
- }
136
- /**
137
- * Parses a repository input and returns a structured RepoSource
138
- *
139
- * Supported formats:
140
- * - owner/repo (short format, defaults to GitHub)
141
- * - https://github.com/owner/repo
142
- * - https://gitlab.com/owner/repo
143
- * - https://bitbucket.org/owner/repo
144
- * - git@github.com:owner/repo.git (SSH format)
145
- * - . (current directory as local repo)
146
- * - /absolute/path (local repo)
147
- *
148
- * @throws PathNotFoundError if local path doesn't exist
149
- * @throws NotGitRepoError if local path is not a git repository
150
- * @throws RepoSourceError for other parsing failures
151
- */
152
- declare function parseRepoInput(input: string): RepoSource$1;
153
- declare function getReferenceFileNameForSource(source: RepoSource$1): string;
154
- //#endregion
155
- //#region src/index-manager.d.ts
156
- /**
157
- * Reads the global map from ~/.local/share/offworld/skill/offworld/assets/map.json
158
- * Returns empty map if file doesn't exist or is invalid
159
- */
160
- declare function readGlobalMap(): GlobalMap$1;
161
- /**
162
- * Writes the global map to ~/.local/share/offworld/skill/offworld/assets/map.json
163
- * Creates directory if it doesn't exist
164
- */
165
- declare function writeGlobalMap(map: GlobalMap$1): void;
166
- /**
167
- * Adds or updates a repo entry in the global map
168
- *
169
- * @param qualifiedName - The qualified repo name (owner/repo)
170
- * @param entry - The map entry to add/update
171
- */
172
- declare function upsertGlobalMapEntry(qualifiedName: string, entry: GlobalMapRepoEntry$1): void;
173
- /**
174
- * Removes a repo entry from the global map
175
- *
176
- * @param qualifiedName - The qualified repo name (owner/repo)
177
- * @returns true if repo was removed, false if not found
178
- */
179
- declare function removeGlobalMapEntry(qualifiedName: string): boolean;
180
- /**
181
- * Writes a project map to ./.offworld/map.json
182
- *
183
- * @param projectRoot - Absolute path to project root
184
- * @param entries - Map of qualified repo names to project map entries
185
- */
186
- declare function writeProjectMap(projectRoot: string, entries: Record<string, ProjectMapRepoEntry$1>): void;
187
- //#endregion
188
- //#region src/map.d.ts
189
- interface MapEntry {
190
- scope: "project" | "global";
191
- qualifiedName: string;
192
- entry: GlobalMapRepoEntry$1 | ProjectMapRepoEntry$1;
193
- }
194
- interface SearchResult {
195
- qualifiedName: string;
196
- fullName: string;
197
- localPath: string;
198
- primary: string;
199
- keywords: string[];
200
- score: number;
201
- }
202
- interface GetMapEntryOptions {
203
- preferProject?: boolean;
204
- cwd?: string;
205
- }
206
- interface SearchMapOptions {
207
- limit?: number;
208
- cwd?: string;
209
- }
210
- /**
211
- * Resolve an input string to a qualified repo key in a map.
212
- *
213
- * @param input - Accepts github.com:owner/repo, owner/repo, or repo name
214
- * @param map - A global or project map
215
- * @returns The matching qualified name or null
216
- */
217
- declare function resolveRepoKey(input: string, map: GlobalMap$1 | ProjectMap$1): string | null;
218
- /**
219
- * Get a map entry for a repo, preferring project map if available.
220
- *
221
- * @param input - Repo identifier (github.com:owner/repo, owner/repo, or repo)
222
- * @param options - Options for lookup
223
- * @returns Entry with scope and qualified name, or null if not found
224
- */
225
- declare function getMapEntry(input: string, options?: GetMapEntryOptions): MapEntry | null;
226
- /**
227
- * Search the map for repos matching a term.
228
- *
229
- * Scoring:
230
- * - Exact fullName match: 100
231
- * - Keyword hit: 50 per keyword
232
- * - Partial contains in fullName: 25
233
- * - Partial contains in keywords: 10
234
- *
235
- * @param term - Search term
236
- * @param options - Search options
237
- * @returns Sorted list of matches
238
- */
239
- declare function searchMap(term: string, options?: SearchMapOptions): SearchResult[];
240
- /**
241
- * Get the project map path if it exists in cwd.
242
- */
243
- declare function getProjectMapPath(cwd?: string): string | null;
244
- //#endregion
245
- //#region src/clone.d.ts
246
- declare class CloneError extends Error {
247
- constructor(message: string);
248
- }
249
- declare class RepoExistsError extends CloneError {
250
- constructor(path: string);
251
- }
252
- declare class RepoNotFoundError extends CloneError {
253
- constructor(qualifiedName: string);
254
- }
255
- declare class GitError extends CloneError {
256
- readonly command: string;
257
- readonly exitCode: number | null;
258
- constructor(message: string, command: string, exitCode: number | null);
259
- }
260
- interface CloneOptions {
261
- /** Use shallow clone (--depth 1) */
262
- shallow?: boolean;
263
- /** Clone specific branch */
264
- branch?: string;
265
- /** Custom config for repo root path */
266
- config?: Config$1;
267
- /** Force clone even if directory exists (removes existing) */
268
- force?: boolean;
269
- /** Use sparse checkout for large repos (only src/, lib/, packages/, docs/) */
270
- sparse?: boolean;
271
- }
272
- declare function getCommitSha(repoPath: string): string;
273
- declare function getCommitDistance(repoPath: string, olderSha: string, newerSha?: string): number | null;
274
- /**
275
- * Clone a remote repository to the local repo root.
276
- *
277
- * @param source - Remote repo source from parseRepoInput()
278
- * @param options - Clone options (shallow, branch, config)
279
- * @returns The local path where the repo was cloned
280
- * @throws RepoExistsError if repo already exists (unless force is true)
281
- * @throws GitError if clone fails
282
- */
283
- declare function cloneRepo(source: RemoteRepoSource, options?: CloneOptions): Promise<string>;
284
- declare function isShallowClone(repoPath: string): boolean;
285
- declare function unshallowRepo(repoPath: string): Promise<boolean>;
286
- interface UpdateResult {
287
- /** Whether any updates were fetched */
288
- updated: boolean;
289
- /** Previous commit SHA before update */
290
- previousSha: string;
291
- /** Current commit SHA after update */
292
- currentSha: string;
293
- /** Whether the repo was unshallowed */
294
- unshallowed?: boolean;
295
- }
296
- interface UpdateOptions {
297
- /** Convert shallow clone to full clone */
298
- unshallow?: boolean;
299
- }
300
- /**
301
- * Update a cloned repository by running git fetch and pull.
302
- *
303
- * @param qualifiedName - The qualified name of the repo (e.g., "github.com:owner/repo")
304
- * @param options - Update options
305
- * @returns Update result with commit SHAs
306
- * @throws RepoNotFoundError if repo not in index
307
- * @throws GitError if fetch/pull fails
308
- */
309
- declare function updateRepo(qualifiedName: string, options?: UpdateOptions): Promise<UpdateResult>;
310
- interface RemoveOptions {
311
- referenceOnly?: boolean;
312
- repoOnly?: boolean;
313
- }
314
- declare function removeRepo(qualifiedName: string, options?: RemoveOptions): Promise<boolean>;
315
- declare function listRepos(): string[];
316
- declare function isRepoCloned(qualifiedName: string): boolean;
317
- /**
318
- * Get the local path for a cloned repository.
319
- *
320
- * @param qualifiedName - The qualified name of the repo
321
- * @returns The local path or undefined if not cloned
322
- */
323
- declare function getClonedRepoPath(qualifiedName: string): string | undefined;
324
- //#endregion
325
- //#region src/ai/opencode.d.ts
326
- interface StreamPromptOptions {
327
- prompt: string;
328
- cwd: string;
329
- systemPrompt?: string;
330
- provider?: string;
331
- model?: string;
332
- /** Timeout in milliseconds. Set to 0 or undefined for no timeout. */
333
- timeoutMs?: number;
334
- onDebug?: (message: string) => void;
335
- onStream?: (text: string) => void;
336
- }
337
- interface StreamPromptResult {
338
- text: string;
339
- sessionId: string;
340
- durationMs: number;
341
- }
342
- declare function streamPrompt(options: StreamPromptOptions): Promise<StreamPromptResult>;
343
- //#endregion
344
- //#region src/ai/errors.d.ts
345
- /**
346
- * Base class for OpenCode reference errors
347
- */
348
- declare class OpenCodeReferenceError extends Error {
349
- readonly details?: unknown | undefined;
350
- readonly _tag: string;
351
- constructor(message: string, details?: unknown | undefined);
352
- }
353
- /**
354
- * Error when the @opencode-ai/sdk package is not installed or invalid
355
- */
356
- declare class OpenCodeSDKError extends OpenCodeReferenceError {
357
- readonly _tag: "OpenCodeSDKError";
358
- constructor(message?: string);
359
- }
360
- //#endregion
361
- //#region src/sync.d.ts
362
- declare class SyncError extends Error {
363
- constructor(message: string);
364
- }
365
- declare class NetworkError extends SyncError {
366
- readonly statusCode?: number | undefined;
367
- constructor(message: string, statusCode?: number | undefined);
368
- }
369
- declare class AuthenticationError extends SyncError {
370
- constructor(message?: string);
371
- }
372
- declare class RateLimitError extends SyncError {
373
- constructor(message?: string);
374
- }
375
- declare class ConflictError extends SyncError {
376
- readonly remoteCommitSha?: string | undefined;
377
- constructor(message?: string, remoteCommitSha?: string | undefined);
378
- }
379
- declare class CommitExistsError extends SyncError {
380
- constructor(message?: string);
381
- }
382
- declare class InvalidInputError extends SyncError {
383
- constructor(message: string);
384
- }
385
- declare class InvalidReferenceError extends SyncError {
386
- constructor(message: string);
387
- }
388
- declare class RepoNotFoundError$1 extends SyncError {
389
- constructor(message?: string);
390
- }
391
- declare class LowStarsError extends SyncError {
392
- constructor(message?: string);
393
- }
394
- declare class PrivateRepoError extends SyncError {
395
- constructor(message?: string);
396
- }
397
- declare class CommitNotFoundError extends SyncError {
398
- constructor(message?: string);
399
- }
400
- declare class GitHubError extends SyncError {
401
- constructor(message?: string);
402
- }
403
- declare class PushNotAllowedError extends SyncError {
404
- readonly reason: "local" | "not-github";
405
- constructor(message: string, reason: "local" | "not-github");
406
- }
407
- /** Reference data structure for sync operations */
408
- interface ReferenceData {
409
- fullName: string;
410
- referenceName: string;
411
- referenceDescription: string;
412
- referenceContent: string;
413
- commitSha: string;
414
- generatedAt: string;
415
- }
416
- /** Response from pull query */
417
- interface PullResponse {
418
- fullName: string;
419
- referenceName: string;
420
- referenceDescription: string;
421
- referenceContent: string;
422
- commitSha: string;
423
- generatedAt: string;
424
- }
425
- /** Response from check query */
426
- interface CheckResponse {
427
- exists: boolean;
428
- commitSha?: string;
429
- generatedAt?: string;
430
- }
431
- /** Response from push mutation */
432
- interface PushResponse {
433
- success: boolean;
434
- message?: string;
435
- }
436
- /** Staleness check result */
437
- interface StalenessResult {
438
- isStale: boolean;
439
- localCommitSha?: string;
440
- remoteCommitSha?: string;
441
- }
442
- /** Can push result */
443
- interface CanPushResult {
444
- allowed: boolean;
445
- reason?: string;
446
- stars?: number;
447
- }
448
- /**
449
- * Fetches reference from the remote server
450
- * @param fullName - Repository full name (owner/repo)
451
- * @returns Reference data or null if not found
452
- */
453
- declare function pullReference(fullName: string): Promise<PullResponse | null>;
454
- /**
455
- * Fetches a specific reference by name from the remote server
456
- * @param fullName - Repository full name (owner/repo)
457
- * @param referenceName - Specific reference name to pull
458
- * @returns Reference data or null if not found
459
- */
460
- declare function pullReferenceByName(fullName: string, referenceName: string): Promise<PullResponse | null>;
461
- /**
462
- * Pushes reference to the remote server
463
- * All validation happens server-side
464
- * @param reference - Reference data to push
465
- * @param token - Authentication token
466
- * @returns Push result
467
- */
468
- declare function pushReference(reference: ReferenceData, token: string): Promise<PushResponse>;
469
- /**
470
- * Checks if reference exists on remote server (lightweight check)
471
- * @param fullName - Repository full name (owner/repo)
472
- * @returns Check result
473
- */
474
- declare function checkRemote(fullName: string): Promise<CheckResponse>;
475
- /**
476
- * Checks if a specific reference exists on the remote server
477
- * @param fullName - Repository full name (owner/repo)
478
- * @param referenceName - Specific reference name to check
479
- * @returns Check result
480
- */
481
- declare function checkRemoteByName(fullName: string, referenceName: string): Promise<CheckResponse>;
482
- /**
483
- * Compares local vs remote commit SHA to check staleness
484
- * @param fullName - Repository full name (owner/repo)
485
- * @param localCommitSha - Local commit SHA
486
- * @returns Staleness result
487
- */
488
- declare function checkStaleness(fullName: string, localCommitSha: string): Promise<StalenessResult>;
489
- /** GitHub repository metadata */
490
- interface GitHubRepoMetadata {
491
- stars: number;
492
- description?: string;
493
- language?: string;
494
- defaultBranch: string;
495
- }
496
- /**
497
- * Fetches GitHub repository metadata
498
- * @param owner - Repository owner
499
- * @param repo - Repository name
500
- * @returns Repository metadata or null on error
501
- */
502
- declare function fetchGitHubMetadata(owner: string, repo: string): Promise<GitHubRepoMetadata | null>;
503
- /**
504
- * Fetches GitHub repository stars
505
- * @param owner - Repository owner
506
- * @param repo - Repository name
507
- * @returns Number of stars, or 0 on error
508
- */
509
- declare function fetchRepoStars(owner: string, repo: string): Promise<number>;
510
- /**
511
- * Checks if a repository can be pushed to offworld.sh (client-side quick checks)
512
- * Note: Star count and other validations happen server-side
513
- *
514
- * @param source - Repository source
515
- * @returns Can push result
516
- */
517
- declare function canPushToWeb(source: RepoSource$1): CanPushResult;
518
- /**
519
- * Validates that a source can be pushed and throws appropriate error if not
520
- * Note: This only does quick client-side checks. Full validation happens server-side.
521
- * @param source - Repository source
522
- * @throws PushNotAllowedError if push is not allowed
523
- */
524
- declare function validatePushAllowed(source: RepoSource$1): void;
525
- //#endregion
526
- //#region src/auth.d.ts
527
- /**
528
- * Authentication utilities for offworld CLI
529
- */
530
- interface AuthData {
531
- token: string;
532
- expiresAt?: string;
533
- workosId?: string;
534
- refreshToken?: string;
535
- email?: string;
536
- }
537
- /** Authentication status */
538
- interface AuthStatus {
539
- isLoggedIn: boolean;
540
- email?: string;
541
- workosId?: string;
542
- expiresAt?: string;
543
- }
544
- declare class AuthError extends Error {
545
- constructor(message: string);
546
- }
547
- declare class NotLoggedInError extends AuthError {
548
- constructor(message?: string);
549
- }
550
- declare class TokenExpiredError extends AuthError {
551
- constructor(message?: string);
552
- }
553
- declare function getAuthPath(): string;
554
- declare function saveAuthData(data: AuthData): void;
555
- /**
556
- * Loads authentication data from ~/.local/share/offworld/auth.json
557
- * Returns null if file doesn't exist or is invalid
558
- */
559
- declare function loadAuthData(): AuthData | null;
560
- /**
561
- * Clears stored authentication data
562
- * @returns true if auth file was deleted, false if it didn't exist
563
- */
564
- declare function clearAuthData(): boolean;
565
- declare function getToken(): Promise<string>;
566
- /**
567
- * Gets the current authentication token, or null if not logged in
568
- * Does not throw errors
569
- */
570
- declare function getTokenOrNull(): Promise<string | null>;
571
- declare function isLoggedIn(): Promise<boolean>;
572
- declare function getAuthStatus(): Promise<AuthStatus>;
573
- declare function refreshAccessToken(): Promise<AuthData>;
574
- //#endregion
575
- //#region src/generate.d.ts
576
- /**
577
- * This module provides a streamlined approach to generating reference files
578
- * by delegating all codebase exploration to the AI agent via OpenCode.
579
- */
580
- interface GenerateReferenceOptions {
581
- /** AI provider ID (e.g., "anthropic", "openai"). Defaults to config value. */
582
- provider?: string;
583
- /** AI model ID. Defaults to config value. */
584
- model?: string;
585
- /** Debug callback for detailed logging */
586
- onDebug?: (message: string) => void;
587
- /** Stream callback for real-time AI output */
588
- onStream?: (text: string) => void;
589
- }
590
- interface GenerateReferenceResult {
591
- /** The generated reference markdown content */
592
- referenceContent: string;
593
- /** The commit SHA at the time of generation */
594
- commitSha: string;
595
- }
596
- interface InstallReferenceMeta {
597
- /** ISO timestamp when the reference was generated */
598
- referenceUpdatedAt: string;
599
- /** Git commit SHA at time of generation */
600
- commitSha: string;
601
- /** SDK version used for generation */
602
- version: string;
603
- }
604
- /**
605
- * Generate a reference markdown file for a repository using AI.
606
- *
607
- * Opens an OpenCode session and instructs the AI agent to explore the codebase
608
- * using Read, Grep, and Glob tools, then produce a comprehensive reference.
609
- *
610
- * @param repoPath - Path to the repository to analyze
611
- * @param repoName - Qualified name of the repo (e.g., "tanstack/query" or "my-local-repo")
612
- * @param options - Generation options (provider, model, callbacks)
613
- * @returns The generated reference content and commit SHA
614
- */
615
- declare function generateReferenceWithAI(repoPath: string, repoName: string, options?: GenerateReferenceOptions): Promise<GenerateReferenceResult>;
616
- /**
617
- * Ensures the global SKILL.md exists and symlinks the offworld/ directory to all agent skill directories.
618
- *
619
- * Creates:
620
- * - ~/.local/share/offworld/skill/offworld/SKILL.md (static routing template)
621
- * - ~/.local/share/offworld/skill/offworld/assets/ (for map.json)
622
- * - ~/.local/share/offworld/skill/offworld/references/ (for reference files)
623
- * - Symlinks entire offworld/ directory to each agent's skill directory
624
- */
625
- declare function installGlobalSkill(): void;
626
- /**
627
- * Install a reference file for a specific repository.
628
- *
629
- * Creates:
630
- * - ~/.local/share/offworld/skill/offworld/references/{owner-repo}.md
631
- * - ~/.local/share/offworld/meta/{owner-repo}/meta.json
632
- * - Updates global map with reference info
633
- *
634
- * @param qualifiedName - Qualified key for map storage (e.g., "github.com:owner/repo" or "local:name")
635
- * @param fullName - Full repo name for file naming (e.g., "owner/repo")
636
- * @param localPath - Absolute path to the cloned repository
637
- * @param referenceContent - The generated reference markdown content
638
- * @param meta - Metadata about the generation (referenceUpdatedAt, commitSha, version)
639
- * @param keywords - Optional array of keywords for search/routing
640
- */
641
- declare function installReference(qualifiedName: string, fullName: string, localPath: string, referenceContent: string, meta: InstallReferenceMeta, keywords?: string[]): void;
642
- //#endregion
643
- //#region src/agents.d.ts
644
- interface AgentConfig {
645
- /** Agent identifier (matches AgentSchema enum) */
646
- name: Agent;
647
- /** Human-readable name for display */
648
- displayName: string;
649
- /** Project-level skill directory (relative path) */
650
- skillsDir: string;
651
- /** User-level skill directory (absolute with ~) */
652
- globalSkillsDir: string;
653
- /** Check if this agent is installed on the system */
654
- detectInstalled: () => boolean;
655
- }
656
- declare const agents: Record<Agent, AgentConfig>;
657
- /**
658
- * Detect which agents are installed on the system.
659
- * Checks for the existence of each agent's config directory.
660
- *
661
- * @returns Array of installed agent identifiers
662
- */
663
- declare function detectInstalledAgents(): Agent[];
664
- /**
665
- * Get the configuration for a specific agent.
666
- *
667
- * @param type - Agent identifier
668
- * @returns AgentConfig for the specified agent
669
- */
670
- declare function getAgentConfig(type: Agent): AgentConfig;
671
- /**
672
- * Get all agent configurations as an array.
673
- *
674
- * @returns Array of all agent configurations
675
- */
676
- declare function getAllAgentConfigs(): AgentConfig[];
677
- //#endregion
678
- //#region src/manifest.d.ts
679
- /**
680
- * Dependency manifest parsing for multiple package ecosystems
681
- */
682
- type ManifestType = "npm" | "python" | "rust" | "go" | "unknown";
683
- interface Dependency {
684
- name: string;
685
- version?: string;
686
- dev: boolean;
687
- }
688
- /**
689
- * Detects the manifest type in a directory
690
- */
691
- declare function detectManifestType(dir: string): ManifestType;
692
- /**
693
- * Parses dependencies from manifest files
694
- */
695
- declare function parseDependencies(dir: string): Dependency[];
696
- //#endregion
697
- //#region src/dep-mappings.d.ts
698
- /**
699
- * Dependency name to GitHub repo resolution:
700
- * 1. Query npm registry for repository.url
701
- * 2. Fall back to FALLBACK_MAPPINGS for packages missing repository field
702
- * 3. Return unknown (caller handles)
703
- */
704
- type ResolvedDep = {
705
- dep: string;
706
- repo: string | null;
707
- source: "npm" | "fallback" | "unknown";
708
- };
709
- /**
710
- * Fallback mappings for packages where npm registry doesn't have repository.url.
711
- * Only add packages here that genuinely don't have the field set.
712
- */
713
- declare const FALLBACK_MAPPINGS: Record<string, string>;
714
- /**
715
- * Fallback to npm registry to extract repository.url.
716
- * Returns null if package not found, no repo field, or not a GitHub repo.
717
- */
718
- declare function resolveFromNpm(packageName: string): Promise<string | null>;
719
- /**
720
- * Resolution order:
721
- * 1. Query npm registry for repository.url
722
- * 2. Check FALLBACK_MAPPINGS for packages missing repository field
723
- * 3. Return unknown
724
- */
725
- declare function resolveDependencyRepo(dep: string): Promise<ResolvedDep>;
726
- //#endregion
727
- //#region src/reference-matcher.d.ts
728
- type ReferenceStatus = "installed" | "remote" | "generate" | "unknown";
729
- interface ReferenceMatch {
730
- /** Dependency name */
731
- dep: string;
732
- /** GitHub repo (owner/repo) or null if unknown */
733
- repo: string | null;
734
- /** Reference availability status */
735
- status: ReferenceStatus;
736
- /** Resolution source: 'npm' | 'fallback' | 'unknown' */
737
- source: "npm" | "fallback" | "unknown";
738
- }
739
- /**
740
- * Check if a reference is installed locally.
741
- * A reference is considered installed if {owner-repo}.md exists in offworld/references/.
742
- *
743
- * @param repo - Repo name in owner/repo format
744
- * @returns true if reference is installed locally
745
- */
746
- declare function isReferenceInstalled(repo: string): boolean;
747
- /**
748
- * Match dependencies to their reference availability status.
749
- *
750
- * Status logic:
751
- * - installed: {owner-repo}.md exists in offworld/references/
752
- * - remote: Reference exists on offworld.sh (quick pull)
753
- * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)
754
- * - unknown: No GitHub repo found
755
- *
756
- * @param resolvedDeps - Array of resolved dependencies with repo info
757
- * @returns Array of reference matches with status
758
- */
759
- declare function matchDependenciesToReferences(resolvedDeps: ResolvedDep[]): ReferenceMatch[];
760
- /**
761
- * Match dependencies to their reference availability status with remote check.
762
- * This is async because it checks the remote server for each dependency.
763
- *
764
- * Status logic:
765
- * - installed: {owner-repo}.md exists in offworld/references/
766
- * - remote: Reference exists on offworld.sh (quick pull)
767
- * - generate: Has valid GitHub repo but needs AI generation (slow, uses tokens)
768
- * - unknown: No GitHub repo found
769
- *
770
- * @param resolvedDeps - Array of resolved dependencies with repo info
771
- * @returns Promise of array of reference matches with status
772
- */
773
- declare function matchDependenciesToReferencesWithRemoteCheck(resolvedDeps: ResolvedDep[]): Promise<ReferenceMatch[]>;
774
- //#endregion
775
- //#region src/agents-md.d.ts
776
- /**
777
- * AGENTS.md manipulation utilities
778
- *
779
- * Manages updating project AGENTS.md and agent-specific files with reference information.
780
- */
781
- interface InstalledReference {
782
- /** Dependency name */
783
- dependency: string;
784
- /** Reference identifier (matches reference file name without .md) */
785
- reference: string;
786
- /** Absolute path to reference file */
787
- path: string;
788
- }
789
- /**
790
- * Update or append Project References section in a markdown file.
791
- * If the section exists, replaces its content. Otherwise, appends to end.
792
- *
793
- * @param filePath - Path to markdown file
794
- * @param references - Array of installed references
795
- */
796
- declare function appendReferencesSection(filePath: string, references: InstalledReference[]): void;
797
- /**
798
- * Update AGENTS.md and agent-specific files with project references.
799
- * Creates files if they don't exist.
800
- *
801
- * @param projectRoot - Project root directory
802
- * @param references - Array of installed references to document
803
- */
804
- declare function updateAgentFiles(projectRoot: string, references: InstalledReference[]): void;
805
- //#endregion
806
- //#region src/repo-manager.d.ts
807
- interface RepoStatusSummary {
808
- total: number;
809
- withReference: number;
810
- missing: number;
811
- diskBytes: number;
812
- }
813
- interface RepoStatusOptions {
814
- onProgress?: (current: number, total: number, repo: string) => void;
815
- }
816
- interface UpdateAllOptions {
817
- pattern?: string;
818
- dryRun?: boolean;
819
- /** Convert shallow clones to full clones */
820
- unshallow?: boolean;
821
- onProgress?: (repo: string, status: "updating" | "updated" | "skipped" | "error" | "unshallowed", message?: string) => void;
822
- }
823
- interface UpdateAllResult {
824
- updated: string[];
825
- skipped: string[];
826
- unshallowed: string[];
827
- errors: Array<{
828
- repo: string;
829
- error: string;
830
- }>;
831
- }
832
- interface PruneOptions {
833
- dryRun?: boolean;
834
- onProgress?: (repo: string, reason: string) => void;
835
- }
836
- interface PruneResult {
837
- removedFromIndex: string[];
838
- orphanedDirs: string[];
839
- }
840
- interface GcOptions {
841
- olderThanDays?: number;
842
- withoutReference?: boolean;
843
- dryRun?: boolean;
844
- onProgress?: (repo: string, reason: string, sizeBytes?: number) => void;
845
- }
846
- interface GcResult {
847
- removed: Array<{
848
- repo: string;
849
- reason: string;
850
- sizeBytes: number;
851
- }>;
852
- freedBytes: number;
853
- }
854
- declare function getRepoStatus(options?: RepoStatusOptions): Promise<RepoStatusSummary>;
855
- declare function updateAllRepos(options?: UpdateAllOptions): Promise<UpdateAllResult>;
856
- declare function pruneRepos(options?: PruneOptions): Promise<PruneResult>;
857
- declare function gcRepos(options?: GcOptions): Promise<GcResult>;
858
- interface DiscoverOptions {
859
- repoRoot?: string;
860
- dryRun?: boolean;
861
- onProgress?: (repo: string, provider: string) => void;
862
- }
863
- interface DiscoverResult {
864
- discovered: Array<{
865
- fullName: string;
866
- qualifiedName: string;
867
- localPath: string;
868
- }>;
869
- alreadyIndexed: number;
870
- }
871
- declare function discoverRepos(options?: DiscoverOptions): Promise<DiscoverResult>;
872
- //#endregion
873
- //#region src/models.d.ts
874
- /**
875
- * Simplified provider info for CLI display
876
- */
877
- interface ProviderInfo {
878
- id: string;
879
- name: string;
880
- env: string[];
881
- }
882
- /**
883
- * Simplified model info for CLI display
884
- */
885
- interface ModelInfo {
886
- id: string;
887
- name: string;
888
- reasoning: boolean;
889
- experimental?: boolean;
890
- status?: "alpha" | "beta" | "deprecated";
891
- }
892
- /**
893
- * Full provider with models for CLI display
894
- */
895
- interface ProviderWithModels extends ProviderInfo {
896
- models: ModelInfo[];
897
- }
898
- /**
899
- * List all available providers from models.dev
900
- */
901
- declare function listProviders(): Promise<ProviderInfo[]>;
902
- /**
903
- * Get a specific provider with all its models
904
- */
905
- declare function getProvider(providerId: string): Promise<ProviderWithModels | null>;
906
- /**
907
- * Get all providers with their models
908
- */
909
- declare function listProvidersWithModels(): Promise<ProviderWithModels[]>;
910
- /**
911
- * Validate that a provider/model combination exists
912
- */
913
- declare function validateProviderModel(providerId: string, modelId: string): Promise<{
914
- valid: boolean;
915
- error?: string;
916
- }>;
917
- //#endregion
918
- //#region src/installation.d.ts
919
- /**
920
- * Installation utilities for upgrade/uninstall commands
921
- */
922
- type InstallMethod = "curl" | "npm" | "pnpm" | "bun" | "brew" | "unknown";
923
- /**
924
- * Detect how offworld was installed
925
- */
926
- declare function detectInstallMethod(): InstallMethod;
927
- /**
928
- * Get current installed version
929
- */
930
- declare function getCurrentVersion(): string;
931
- /**
932
- * Fetch latest version from appropriate source
933
- */
934
- declare function fetchLatestVersion(method?: InstallMethod): Promise<string | null>;
935
- /**
936
- * Execute upgrade for given method
937
- */
938
- declare function executeUpgrade(method: InstallMethod, version: string): Promise<void>;
939
- /**
940
- * Execute uninstall for given method
941
- */
942
- declare function executeUninstall(method: InstallMethod): Promise<void>;
943
- /**
944
- * Get shell config files to clean
945
- */
946
- declare function getShellConfigFiles(): string[];
947
- /**
948
- * Clean PATH entries from shell config
949
- */
950
- declare function cleanShellConfig(filePath: string): boolean;
951
- //#endregion
952
- export { type AgentConfig, type AuthData, AuthError, type AuthStatus, AuthenticationError, type CanPushResult, type CheckResponse, CloneError, type CloneOptions, CommitExistsError, CommitNotFoundError, type Config, ConflictError, DEFAULT_IGNORE_PATTERNS, type Dependency, type DiscoverOptions, type DiscoverResult, FALLBACK_MAPPINGS, type FileIndex, type FileIndexEntry, type FileRole, type GcOptions, type GcResult, type GenerateReferenceOptions, type GenerateReferenceResult, type GetMapEntryOptions, GitError, GitHubError, type GitHubRepoMetadata, type GlobalMap, type GlobalMapRepoEntry, type InstallMethod, type InstallReferenceMeta, type InstalledReference, InvalidInputError, InvalidReferenceError, LowStarsError, type ManifestType, type MapEntry, type ModelInfo, NetworkError, NotGitRepoError, NotLoggedInError, OpenCodeSDKError, PathNotFoundError, Paths, PrivateRepoError, type ProjectMap, type ProjectMapRepoEntry, type ProviderInfo, type ProviderWithModels, type PruneOptions, type PruneResult, type PullResponse, PushNotAllowedError, type PushResponse, RateLimitError, type ReferenceData, type ReferenceMatch, type ReferenceStatus, type RemoveOptions, RepoExistsError, RepoNotFoundError, type RepoSource, RepoSourceError, type RepoStatusOptions, type RepoStatusSummary, type ResolvedDep, type SearchMapOptions, type SearchResult, type StalenessResult, type StreamPromptOptions, type StreamPromptResult, SyncError, RepoNotFoundError$1 as SyncRepoNotFoundError, TokenExpiredError, type UpdateAllOptions, type UpdateAllResult, type UpdateOptions, type UpdateResult, VERSION, agents, appendReferencesSection, canPushToWeb, checkRemote, checkRemoteByName, checkStaleness, cleanShellConfig, clearAuthData, cloneRepo, detectInstallMethod, detectInstalledAgents, detectManifestType, discoverRepos, executeUninstall, executeUpgrade, expandTilde, fetchGitHubMetadata, fetchLatestVersion, fetchRepoStars, gcRepos, generateReferenceWithAI, getAgentConfig, getAllAgentConfigs, getAuthPath, getAuthStatus, getClonedRepoPath, getCommitDistance, getCommitSha, getConfigPath, getCurrentVersion, getMapEntry, getMetaPath, getMetaRoot, getProjectMapPath, getProvider, getReferenceFileNameForSource, getReferencePath, getRepoPath, getRepoRoot, getRepoStatus, getShellConfigFiles, getToken, getTokenOrNull, installGlobalSkill, installReference, isLoggedIn, isReferenceInstalled, isRepoCloned, isShallowClone, listProviders, listProvidersWithModels, listRepos, loadAuthData, loadConfig, matchDependenciesToReferences, matchDependenciesToReferencesWithRemoteCheck, parseDependencies, parseRepoInput, pruneRepos, pullReference, pullReferenceByName, pushReference, readGlobalMap, refreshAccessToken, removeGlobalMapEntry, removeRepo, resolveDependencyRepo, resolveFromNpm, resolveRepoKey, saveAuthData, saveConfig, searchMap, streamPrompt, toMetaDirName, toReferenceFileName, toReferenceName, unshallowRepo, updateAgentFiles, updateAllRepos, updateRepo, upsertGlobalMapEntry, validateProviderModel, validatePushAllowed, writeGlobalMap, writeProjectMap };
953
- //# sourceMappingURL=index.d.mts.map
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-MYVLaKUi.mjs";
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 };