@algochad/archcoder 2.0.2
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 +113 -0
- package/bin/cli-entry.js +55 -0
- package/bin/cli-output.js +145 -0
- package/bin/cli.js +5108 -0
- package/bin/cli.test.js +56 -0
- package/dist/apple-touch-icon-120x120.png +0 -0
- package/dist/apple-touch-icon-152x152.png +0 -0
- package/dist/apple-touch-icon-167x167.png +0 -0
- package/dist/apple-touch-icon-180x180.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/apple-touch-icon.svg +67 -0
- package/dist/assets/MultiRunWindow-BZp3MjJP.js +1 -0
- package/dist/assets/SettingsWindow-DoGYXpX7.js +1 -0
- package/dist/assets/TerminalView-BN7BR5Ff.js +3 -0
- package/dist/assets/TimelineDialog-ZQ33oVQR.js +1 -0
- package/dist/assets/ToolOutputDialog-Blv3pnug.js +16 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/assets/index-CtCEGYrr.css +1 -0
- package/dist/assets/index-o_d2wtWC.js +48 -0
- package/dist/assets/main-5QGBtzdq.css +1 -0
- package/dist/assets/main-B6oiMU86.js +8033 -0
- package/dist/assets/vendor--DbVqbJpV.css +1 -0
- package/dist/assets/vendor-.bun-HTKwyaEM.js +10086 -0
- package/dist/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/assets/worker-bqd4RMrj.js +155 -0
- package/dist/favicon-16.png +0 -0
- package/dist/favicon-32.png +0 -0
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +67 -0
- package/dist/index.html +533 -0
- package/dist/logo-dark-192x192.png +0 -0
- package/dist/logo-dark-512x512.svg +16 -0
- package/dist/logo-light-192x192.png +0 -0
- package/dist/logo-light-512x512.svg +16 -0
- package/dist/pwa-192.png +0 -0
- package/dist/pwa-512.png +0 -0
- package/dist/pwa-maskable-192.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/site.webmanifest +22 -0
- package/dist/sw.js +1 -0
- package/package.json +107 -0
- package/public/apple-touch-icon-120x120.png +0 -0
- package/public/apple-touch-icon-152x152.png +0 -0
- package/public/apple-touch-icon-167x167.png +0 -0
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/apple-touch-icon.svg +67 -0
- package/public/favicon-16.png +0 -0
- package/public/favicon-32.png +0 -0
- package/public/favicon.png +0 -0
- package/public/favicon.svg +67 -0
- package/public/logo-dark-192x192.png +0 -0
- package/public/logo-dark-512x512.svg +16 -0
- package/public/logo-light-192x192.png +0 -0
- package/public/logo-light-512x512.svg +16 -0
- package/public/pwa-192.png +0 -0
- package/public/pwa-512.png +0 -0
- package/public/pwa-maskable-192.png +0 -0
- package/public/pwa-maskable-512.png +0 -0
- package/public/site.webmanifest +22 -0
- package/server/TERMINAL_INPUT_WS_PROTOCOL.md +44 -0
- package/server/index.d.ts +37 -0
- package/server/index.js +14694 -0
- package/server/lib/cloudflare-tunnel.js +650 -0
- package/server/lib/git/DOCUMENTATION.md +146 -0
- package/server/lib/git/credentials.js +74 -0
- package/server/lib/git/identity-storage.js +110 -0
- package/server/lib/git/index.js +6 -0
- package/server/lib/git/service.js +3117 -0
- package/server/lib/github/DOCUMENTATION.md +170 -0
- package/server/lib/github/auth.js +307 -0
- package/server/lib/github/device-flow.js +50 -0
- package/server/lib/github/index.js +24 -0
- package/server/lib/github/octokit.js +10 -0
- package/server/lib/github/pr-status.js +478 -0
- package/server/lib/github/repo/index.js +55 -0
- package/server/lib/installer/desktop.js +289 -0
- package/server/lib/installer/download.js +208 -0
- package/server/lib/installer/index.js +45 -0
- package/server/lib/installer/platform.js +100 -0
- package/server/lib/notifications/DOCUMENTATION.md +61 -0
- package/server/lib/notifications/index.js +1 -0
- package/server/lib/notifications/message.js +49 -0
- package/server/lib/notifications/message.test.js +59 -0
- package/server/lib/opencode/DOCUMENTATION.md +59 -0
- package/server/lib/opencode/agents.js +634 -0
- package/server/lib/opencode/auth.js +81 -0
- package/server/lib/opencode/commands.js +339 -0
- package/server/lib/opencode/index.js +66 -0
- package/server/lib/opencode/mcp.js +206 -0
- package/server/lib/opencode/providers.js +96 -0
- package/server/lib/opencode/shared.js +527 -0
- package/server/lib/opencode/skills.js +480 -0
- package/server/lib/opencode/tunnel-auth.js +591 -0
- package/server/lib/opencode/ui-auth.js +510 -0
- package/server/lib/package-manager.js +505 -0
- package/server/lib/quota/DOCUMENTATION.md +55 -0
- package/server/lib/quota/index.js +24 -0
- package/server/lib/quota/providers/claude.js +107 -0
- package/server/lib/quota/providers/codex.js +113 -0
- package/server/lib/quota/providers/copilot.js +165 -0
- package/server/lib/quota/providers/google/api.js +92 -0
- package/server/lib/quota/providers/google/auth.js +108 -0
- package/server/lib/quota/providers/google/index.js +124 -0
- package/server/lib/quota/providers/google/transforms.js +109 -0
- package/server/lib/quota/providers/index.js +152 -0
- package/server/lib/quota/providers/interface.js +55 -0
- package/server/lib/quota/providers/kimi.js +108 -0
- package/server/lib/quota/providers/minimax-cn-coding-plan.js +15 -0
- package/server/lib/quota/providers/minimax-coding-plan.js +15 -0
- package/server/lib/quota/providers/minimax-shared.js +136 -0
- package/server/lib/quota/providers/nanogpt.js +124 -0
- package/server/lib/quota/providers/ollama-cloud.js +112 -0
- package/server/lib/quota/providers/openai.js +91 -0
- package/server/lib/quota/providers/openrouter.js +92 -0
- package/server/lib/quota/providers/zai.js +91 -0
- package/server/lib/quota/utils/auth.js +46 -0
- package/server/lib/quota/utils/formatters.js +76 -0
- package/server/lib/quota/utils/index.js +10 -0
- package/server/lib/quota/utils/transformers.js +55 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +178 -0
- package/server/lib/skills-catalog/cache.js +32 -0
- package/server/lib/skills-catalog/clawdhub/api.js +158 -0
- package/server/lib/skills-catalog/clawdhub/index.js +30 -0
- package/server/lib/skills-catalog/clawdhub/install.js +238 -0
- package/server/lib/skills-catalog/clawdhub/scan.js +113 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -0
- package/server/lib/skills-catalog/git.js +77 -0
- package/server/lib/skills-catalog/index.js +42 -0
- package/server/lib/skills-catalog/install.js +294 -0
- package/server/lib/skills-catalog/scan.js +221 -0
- package/server/lib/skills-catalog/source.js +85 -0
- package/server/lib/terminal/DOCUMENTATION.md +114 -0
- package/server/lib/terminal/index.js +12 -0
- package/server/lib/terminal/input-ws-protocol.js +66 -0
- package/server/lib/terminal/input-ws-protocol.test.js +138 -0
- package/server/lib/tts/DOCUMENTATION.md +134 -0
- package/server/lib/tts/index.js +16 -0
- package/server/lib/tts/service.js +162 -0
- package/server/lib/tts/summarization.js +171 -0
- package/server/lib/tunnels/index.js +166 -0
- package/server/lib/tunnels/providers/cloudflare.js +260 -0
- package/server/lib/tunnels/registry.js +51 -0
- package/server/lib/tunnels/types.js +219 -0
- package/server/lib/utils/lru.js +107 -0
- package/server/lib/utils/sse.js +121 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Skills Catalog Module Documentation
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
This module provides skill discovery, scanning, and installation capabilities for OpenCode. It supports multiple skill sources including GitHub repositories and the ClawdHub registry, with caching and conflict resolution for skill installation.
|
|
5
|
+
|
|
6
|
+
## Entrypoints and structure
|
|
7
|
+
- `packages/web/server/lib/skills-catalog/`: Skills catalog module directory containing all skill-related functionality.
|
|
8
|
+
- `cache.js`: In-memory cache for scan results with TTL support.
|
|
9
|
+
- `curated-sources.js`: Predefined skill sources (Anthropic, ClawdHub).
|
|
10
|
+
- `git.js`: Git operations helpers for cloning and auth error detection.
|
|
11
|
+
- `install.js`: Skills installation from GitHub repositories.
|
|
12
|
+
- `scan.js`: Skills scanning from GitHub repositories.
|
|
13
|
+
- `source.js`: Source string parsing for GitHub repositories.
|
|
14
|
+
- `clawdhub/`: ClawdHub registry integration.
|
|
15
|
+
- `index.js`: Public API exports for ClawdHub.
|
|
16
|
+
- `scan.js`: Scanning ClawdHub registry with pagination.
|
|
17
|
+
- `install.js`: Installation from ClawdHub (ZIP download).
|
|
18
|
+
- `api.js`: ClawdHub API client with rate limiting.
|
|
19
|
+
|
|
20
|
+
## Public API
|
|
21
|
+
|
|
22
|
+
The following functions are exported and used by the web server:
|
|
23
|
+
|
|
24
|
+
### Cache (`cache.js`)
|
|
25
|
+
- `getCacheKey({ normalizedRepo, subpath, identityId })`: Generate cache key for scan results.
|
|
26
|
+
- `getCachedScan(key)`: Retrieve cached scan result if not expired.
|
|
27
|
+
- `setCachedScan(key, value, ttlMs)`: Store scan result with TTL (default 30 minutes).
|
|
28
|
+
- `clearCache()`: Clear all cached scan results.
|
|
29
|
+
|
|
30
|
+
### Curated Sources (`curated-sources.js`)
|
|
31
|
+
- `getCuratedSkillsSources()`: Return list of curated skill sources (Anthropic, ClawdHub).
|
|
32
|
+
- `CURATED_SKILLS_SOURCES`: Constant array of predefined sources.
|
|
33
|
+
|
|
34
|
+
### Source Parsing (`source.js`)
|
|
35
|
+
- `parseSkillRepoSource(source, { subpath })`: Parse GitHub repository source string into structured object with SSH/HTTPS clone URLs, normalized repo, and effective subpath. Supports SSH URLs, HTTPS URLs, and shorthand `owner/repo[/subpath]` format.
|
|
36
|
+
|
|
37
|
+
### Git Repository Scanning (`scan.js`)
|
|
38
|
+
- `scanSkillsRepository({ source, subpath, defaultSubpath, identity })`: Scan GitHub repository for skills by cloning and analyzing SKILL.md files. Returns array of skill items with metadata.
|
|
39
|
+
|
|
40
|
+
### Git Repository Installation (`install.js`)
|
|
41
|
+
- `installSkillsFromRepository({ source, subpath, defaultSubpath, identity, scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from GitHub repository. Supports user/project scopes, opencode/agents targets, conflict resolution (prompt/skipAll/overwriteAll), and sparse checkout for efficiency.
|
|
42
|
+
|
|
43
|
+
### ClawdHub Integration (`clawdhub/index.js`)
|
|
44
|
+
- `isClawdHubSource(source)`: Check if source string refers to ClawdHub.
|
|
45
|
+
- `scanClawdHub()`: Scan entire ClawdHub registry for all skills (paginated, max 20 pages).
|
|
46
|
+
- `scanClawdHubPage({ cursor })`: Scan a single page of ClawdHub results with cursor-based pagination.
|
|
47
|
+
- `installSkillsFromClawdHub({ scope, targetSource, workingDirectory, userSkillDir, selections, conflictPolicy, conflictDecisions })`: Install skills from ClawdHub by downloading ZIP files.
|
|
48
|
+
- `fetchClawdHubSkills({ cursor })`: Fetch paginated skills list from ClawdHub API.
|
|
49
|
+
- `fetchClawdHubSkillVersion(slug, version)`: Fetch specific skill version details.
|
|
50
|
+
- `fetchClawdHubSkillInfo(slug)`: Fetch skill metadata without version details.
|
|
51
|
+
- `downloadClawdHubSkill(slug, version)`: Download skill package as ZIP buffer.
|
|
52
|
+
|
|
53
|
+
### ClawdHub Constants (`clawdhub/index.js`)
|
|
54
|
+
- `CLAWDHUB_SOURCE_ID`: Source identifier for curated sources.
|
|
55
|
+
- `CLAWDHUB_SOURCE_STRING`: Source string format.
|
|
56
|
+
|
|
57
|
+
## Internal Helpers
|
|
58
|
+
|
|
59
|
+
The following functions are internal helpers used by exported functions:
|
|
60
|
+
|
|
61
|
+
### Git Helpers (`git.js`)
|
|
62
|
+
- `runGit(args, options)`: Execute git command with optional SSH identity, timeout, and max buffer. Returns `{ ok, stdout, stderr, message, code, signal }`.
|
|
63
|
+
- `looksLikeAuthError(message)`: Detect if error message indicates authentication failure (permission denied, publickey, etc.).
|
|
64
|
+
- `assertGitAvailable()`: Check if git is available in PATH.
|
|
65
|
+
|
|
66
|
+
### Skill Name Validation (used in `install.js`, `scan.js`, `clawdhub/install.js`)
|
|
67
|
+
- `validateSkillName(skillName)`: Validate skill name against pattern `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars, lowercase alphanumeric with hyphens).
|
|
68
|
+
|
|
69
|
+
### File System Helpers (`install.js`, `scan.js`, `clawdhub/install.js`)
|
|
70
|
+
- `safeRm(dir)`: Safely remove directory recursively (ignores errors).
|
|
71
|
+
- `ensureDir(dirPath)`: Ensure directory exists with recursive creation.
|
|
72
|
+
- `copyDirectoryNoSymlinks(srcDir, dstDir)`: Copy directory contents without symlinks, with path traversal protection.
|
|
73
|
+
- `normalizeUserSkillDir(userSkillDir)`: Normalize user skill directory path (handles legacy `~/.config/opencode/skill` → `~/.config/opencode/skills` migration).
|
|
74
|
+
|
|
75
|
+
### Git Clone Helpers (`install.js`, `scan.js`)
|
|
76
|
+
- `cloneRepo({ cloneUrl, identity, tempDir })`: Clone GitHub repository with preferred partial clone (`--filter=blob:none`) and fallback. Uses non-interactive mode.
|
|
77
|
+
|
|
78
|
+
### SKILL.md Parsing (`scan.js`)
|
|
79
|
+
- `parseSkillMd(content)`: Parse YAML frontmatter from SKILL.md content. Returns `{ ok, frontmatter, warnings }`.
|
|
80
|
+
|
|
81
|
+
### Path Helpers (`install.js`)
|
|
82
|
+
- `toFsPath(repoDir, repoRelPosixPath)`: Convert POSIX path to filesystem path.
|
|
83
|
+
- `getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName })`: Determine target installation directory based on scope (user/project), targetSource (opencode/agents), and skill name.
|
|
84
|
+
|
|
85
|
+
### ClawdHub API Helpers (`clawdhub/api.js`)
|
|
86
|
+
- `rateLimitedFetch(url, options)`: Fetch with rate limiting (120 req/min limit, 100ms delay between requests, exponential backoff on 429/500 errors).
|
|
87
|
+
- `mapClawdHubItem(item)`: Transform ClawdHub API response to SkillsCatalogItem format.
|
|
88
|
+
|
|
89
|
+
## Response Contracts
|
|
90
|
+
|
|
91
|
+
### Scan Skills Repository Response
|
|
92
|
+
- `ok`: Boolean indicating success.
|
|
93
|
+
- `normalizedRepo`: Normalized GitHub repo string (`owner/repo`).
|
|
94
|
+
- `effectiveSubpath`: Effective subpath used for scanning (may be from source string or defaultSubpath).
|
|
95
|
+
- `items`: Array of skill items with `{ repoSource, repoSubpath, skillDir, skillName, frontmatterName, description, installable, warnings }`.
|
|
96
|
+
- `error`: Error object with `{ kind, message }` on failure.
|
|
97
|
+
|
|
98
|
+
### Install Skills Response
|
|
99
|
+
- `ok`: Boolean indicating success.
|
|
100
|
+
- `installed`: Array of installed skills with `{ skillName, scope, source }`.
|
|
101
|
+
- `skipped`: Array of skipped skills with `{ skillName, reason }`.
|
|
102
|
+
- `error`: Error object with `{ kind, message, conflicts? }` on failure. Kinds: `authRequired`, `networkError`, `conflicts`, `invalidSource`, `unknown`.
|
|
103
|
+
|
|
104
|
+
### ClawdHub Scan Response
|
|
105
|
+
- `ok`: Boolean indicating success.
|
|
106
|
+
- `items`: Array of skill items with ClawdHub-specific metadata in `clawdhub` property.
|
|
107
|
+
- `nextCursor`: Pagination cursor for next page (only for `scanClawdHubPage`).
|
|
108
|
+
- `error`: Error object with `{ kind, message }` on failure.
|
|
109
|
+
|
|
110
|
+
### Parse Source Response
|
|
111
|
+
- `ok`: Boolean indicating success.
|
|
112
|
+
- `host`: GitHub host (`github.com`).
|
|
113
|
+
- `owner`: Repository owner.
|
|
114
|
+
- `repo`: Repository name.
|
|
115
|
+
- `cloneUrlSsh`: SSH clone URL.
|
|
116
|
+
- `cloneUrlHttps`: HTTPS clone URL.
|
|
117
|
+
- `effectiveSubpath`: Subpath for scanning (from source string or options).
|
|
118
|
+
- `normalizedRepo`: Normalized repo string (`owner/repo`).
|
|
119
|
+
- `error`: Error object with `{ kind, message }` on failure.
|
|
120
|
+
|
|
121
|
+
## Notes for Contributors
|
|
122
|
+
|
|
123
|
+
### Adding a New Skill Source
|
|
124
|
+
1. Create a new subdirectory under `packages/web/server/lib/skills-catalog/` (e.g., `newsource/`).
|
|
125
|
+
2. Implement `scan.js` with a function that returns `{ ok, items, error? }` matching the SkillsCatalogItem contract.
|
|
126
|
+
3. Implement `install.js` with a function that accepts selections and returns `{ ok, installed, skipped, error? }`.
|
|
127
|
+
4. Add the source to `CURATED_SKILLS_SOURCES` in `curated-sources.js` if it should appear in the default catalog.
|
|
128
|
+
5. Update `packages/web/server/index.js` to import and wire up the new source.
|
|
129
|
+
|
|
130
|
+
### Skill Name Validation
|
|
131
|
+
- All skill names must match `/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/` (1-64 chars).
|
|
132
|
+
- Skill names are derived from directory basenames for GitHub repos and slugs for ClawdHub.
|
|
133
|
+
- Invalid names result in non-installable skills with appropriate warnings.
|
|
134
|
+
|
|
135
|
+
### Git Cloning Strategy
|
|
136
|
+
- Use sparse checkout to minimize clone size: `sparse-checkout init`, `sparse-checkout set`, `checkout HEAD`.
|
|
137
|
+
- Preferred clone uses `--depth=1 --filter=blob:none` for partial clone with fallback to `--depth=1`.
|
|
138
|
+
- Always use non-interactive mode (`GIT_TERMINAL_PROMPT=0`) to avoid hangs.
|
|
139
|
+
- SSH keys are injected via `core.sshCommand` in git config.
|
|
140
|
+
|
|
141
|
+
### Conflict Resolution
|
|
142
|
+
- Installation checks for existing skills before downloading/cloning.
|
|
143
|
+
- Three conflict policies: `prompt`, `skipAll`, `overwriteAll`.
|
|
144
|
+
- Per-skill decisions override global policy via `conflictDecisions` map.
|
|
145
|
+
- Conflict response includes `{ skillName, scope, source }` for each conflict.
|
|
146
|
+
|
|
147
|
+
### ClawdHub Integration
|
|
148
|
+
- ClawdHub API base URL: `https://clawdhub.com/api/v1`.
|
|
149
|
+
- Pagination uses cursor-based approach with `MAX_PAGES=20` safety limit.
|
|
150
|
+
- Rate limiting: 120 req/min with 100ms delay between requests.
|
|
151
|
+
- Downloaded skills are extracted from ZIP files using `adm-zip`.
|
|
152
|
+
- Always validate `SKILL.md` exists before installation.
|
|
153
|
+
|
|
154
|
+
### Cache Management
|
|
155
|
+
- Cache keys include `normalizedRepo`, `subpath`, and `identityId` for isolation.
|
|
156
|
+
- Default TTL is 30 minutes; can be overridden via `ttlMs` parameter.
|
|
157
|
+
- Cache is in-memory (not persisted across restarts).
|
|
158
|
+
|
|
159
|
+
### Security Considerations
|
|
160
|
+
- Path traversal protection in `copyDirectoryNoSymlinks`: resolves real paths and checks containment.
|
|
161
|
+
- Symlinks are explicitly rejected to prevent escape from skill directory.
|
|
162
|
+
- SSH key paths are trimmed but not escaped in `git.js` (assumes safe input from profiles).
|
|
163
|
+
- Temporary directories are cleaned up in `finally` blocks.
|
|
164
|
+
|
|
165
|
+
### Error Handling
|
|
166
|
+
- All exported functions return `{ ok, ... }` result objects, not throw.
|
|
167
|
+
- Error kinds: `authRequired`, `networkError`, `conflicts`, `invalidSource`, `unknown`.
|
|
168
|
+
- Use `looksLikeAuthError` to detect SSH/HTTPS auth failures for better UX.
|
|
169
|
+
- Log errors to console for debugging but return structured errors to callers.
|
|
170
|
+
|
|
171
|
+
### Testing
|
|
172
|
+
- Run `bun run type-check`, `bun run lint`, and `bun run build` before finalizing changes.
|
|
173
|
+
- Consider edge cases: non-existent repos, private repos without auth, missing SKILL.md files, invalid skill names, conflicts, network failures.
|
|
174
|
+
|
|
175
|
+
## Verification Commands
|
|
176
|
+
- Type-check: `bun run type-check`
|
|
177
|
+
- Lint: `bun run lint`
|
|
178
|
+
- Build: `bun run build`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createLruMap } from '../utils/lru.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TTL_MS = 30 * 60 * 1000;
|
|
4
|
+
const MAX_CACHE_ENTRIES = 50;
|
|
5
|
+
|
|
6
|
+
const cache = createLruMap(MAX_CACHE_ENTRIES);
|
|
7
|
+
|
|
8
|
+
export function getCacheKey({ normalizedRepo, subpath, identityId }) {
|
|
9
|
+
const safeRepo = String(normalizedRepo || '').trim();
|
|
10
|
+
const safeSubpath = String(subpath || '').trim();
|
|
11
|
+
const safeIdentity = String(identityId || '').trim();
|
|
12
|
+
return `${safeRepo}::${safeSubpath}::${safeIdentity}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getCachedScan(key) {
|
|
16
|
+
const entry = cache.get(key);
|
|
17
|
+
if (!entry) return null;
|
|
18
|
+
if (Date.now() >= entry.expiresAt) {
|
|
19
|
+
cache.delete(key);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return entry.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function setCachedScan(key, value, ttlMs = DEFAULT_TTL_MS) {
|
|
26
|
+
const ttl = Number.isFinite(ttlMs) ? ttlMs : DEFAULT_TTL_MS;
|
|
27
|
+
cache.set(key, { expiresAt: Date.now() + ttl, value });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function clearCache() {
|
|
31
|
+
cache.clear();
|
|
32
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawdHub API client
|
|
3
|
+
*
|
|
4
|
+
* ClawdHub is a public skill registry at https://clawdhub.com
|
|
5
|
+
* This client provides methods to fetch skills list and download skill packages.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const CLAWDHUB_API_BASE = 'https://clawdhub.com/api/v1';
|
|
9
|
+
const CLAWDHUB_PAGE_LIMIT = 25;
|
|
10
|
+
|
|
11
|
+
// Rate limiting: ClawdHub allows 120 requests/minute
|
|
12
|
+
const RATE_LIMIT_DELAY_MS = 100;
|
|
13
|
+
let lastRequestTime = 0;
|
|
14
|
+
|
|
15
|
+
async function rateLimitedFetch(url, options = {}) {
|
|
16
|
+
const maxAttempts = 10;
|
|
17
|
+
|
|
18
|
+
let lastResponse = null;
|
|
19
|
+
|
|
20
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
21
|
+
const now = Date.now();
|
|
22
|
+
const elapsed = now - lastRequestTime;
|
|
23
|
+
if (elapsed < RATE_LIMIT_DELAY_MS) {
|
|
24
|
+
await new Promise((resolve) => setTimeout(resolve, RATE_LIMIT_DELAY_MS - elapsed));
|
|
25
|
+
}
|
|
26
|
+
lastRequestTime = Date.now();
|
|
27
|
+
|
|
28
|
+
const response = await fetch(url, {
|
|
29
|
+
...options,
|
|
30
|
+
headers: {
|
|
31
|
+
Accept: 'application/json',
|
|
32
|
+
'User-Agent': 'ArchCoder/1.0',
|
|
33
|
+
...options.headers,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
lastResponse = response;
|
|
38
|
+
|
|
39
|
+
if (response.status === 429 || response.status >= 500) {
|
|
40
|
+
if (attempt < maxAttempts - 1) {
|
|
41
|
+
const waitMs = 50 * (attempt + 1);
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return response;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return lastResponse;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Fetch paginated list of skills from ClawdHub
|
|
55
|
+
* @param {Object} options
|
|
56
|
+
* @param {string} [options.cursor] - Pagination cursor from previous response
|
|
57
|
+
* @returns {Promise<{ items: Array, nextCursor?: string }>}
|
|
58
|
+
*/
|
|
59
|
+
export async function fetchClawdHubSkills({ cursor } = {}) {
|
|
60
|
+
const url = cursor
|
|
61
|
+
? `${CLAWDHUB_API_BASE}/skills?cursor=${encodeURIComponent(cursor)}&limit=${CLAWDHUB_PAGE_LIMIT}`
|
|
62
|
+
: `${CLAWDHUB_API_BASE}/skills?limit=${CLAWDHUB_PAGE_LIMIT}`;
|
|
63
|
+
|
|
64
|
+
const response = await rateLimitedFetch(url);
|
|
65
|
+
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
const text = await response.text().catch(() => '');
|
|
68
|
+
throw new Error(`ClawdHub API error (${response.status}): ${text || response.statusText}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const data = await response.json();
|
|
72
|
+
const nextCursor =
|
|
73
|
+
(typeof data.nextCursor === 'string' && data.nextCursor) ||
|
|
74
|
+
(typeof data.next_cursor === 'string' && data.next_cursor) ||
|
|
75
|
+
(typeof data.next === 'string' && data.next) ||
|
|
76
|
+
(typeof data.cursor === 'string' && data.cursor) ||
|
|
77
|
+
null;
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
items: data.items || [],
|
|
81
|
+
nextCursor,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Fetch details for a specific skill version
|
|
87
|
+
* @param {string} slug - Skill slug/identifier
|
|
88
|
+
* @param {string} [version='latest'] - Version string or 'latest'
|
|
89
|
+
* @returns {Promise<{ skill: Object, version: Object }>}
|
|
90
|
+
*/
|
|
91
|
+
export async function fetchClawdHubSkillVersion(slug, version = 'latest') {
|
|
92
|
+
// For 'latest', we need to first get the skill metadata to find the latest version
|
|
93
|
+
if (version === 'latest') {
|
|
94
|
+
const skillResponse = await rateLimitedFetch(`${CLAWDHUB_API_BASE}/skills/${encodeURIComponent(slug)}`);
|
|
95
|
+
if (!skillResponse.ok) {
|
|
96
|
+
throw new Error(`ClawdHub skill not found: ${slug}`);
|
|
97
|
+
}
|
|
98
|
+
const skillData = await skillResponse.json();
|
|
99
|
+
const latestVersion = skillData.skill?.tags?.latest || skillData.latestVersion?.version;
|
|
100
|
+
if (!latestVersion) {
|
|
101
|
+
throw new Error(`No latest version found for skill: ${slug}`);
|
|
102
|
+
}
|
|
103
|
+
version = latestVersion;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const url = `${CLAWDHUB_API_BASE}/skills/${encodeURIComponent(slug)}/versions/${encodeURIComponent(version)}`;
|
|
107
|
+
const response = await rateLimitedFetch(url);
|
|
108
|
+
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
const text = await response.text().catch(() => '');
|
|
111
|
+
throw new Error(`ClawdHub version error (${response.status}): ${text || response.statusText}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return response.json();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Download a skill package as a ZIP buffer
|
|
119
|
+
* @param {string} slug - Skill slug/identifier
|
|
120
|
+
* @param {string} version - Specific version string
|
|
121
|
+
* @returns {Promise<ArrayBuffer>} - ZIP file contents
|
|
122
|
+
*/
|
|
123
|
+
export async function downloadClawdHubSkill(slug, version) {
|
|
124
|
+
const versionParam = typeof version === 'string' && version !== 'latest'
|
|
125
|
+
? `&version=${encodeURIComponent(version)}`
|
|
126
|
+
: '&tag=latest';
|
|
127
|
+
const url = `${CLAWDHUB_API_BASE}/download?slug=${encodeURIComponent(slug)}${versionParam}`;
|
|
128
|
+
|
|
129
|
+
const response = await rateLimitedFetch(url, {
|
|
130
|
+
headers: {
|
|
131
|
+
Accept: 'application/zip',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
const text = await response.text().catch(() => '');
|
|
137
|
+
throw new Error(`ClawdHub download error (${response.status}): ${text || response.statusText}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return response.arrayBuffer();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get skill metadata without version details
|
|
145
|
+
* @param {string} slug - Skill slug/identifier
|
|
146
|
+
* @returns {Promise<Object>}
|
|
147
|
+
*/
|
|
148
|
+
export async function fetchClawdHubSkillInfo(slug) {
|
|
149
|
+
const url = `${CLAWDHUB_API_BASE}/skills/${encodeURIComponent(slug)}`;
|
|
150
|
+
const response = await rateLimitedFetch(url);
|
|
151
|
+
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
const text = await response.text().catch(() => '');
|
|
154
|
+
throw new Error(`ClawdHub skill error (${response.status}): ${text || response.statusText}`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return response.json();
|
|
158
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawdHub integration module
|
|
3
|
+
*
|
|
4
|
+
* Provides skill browsing and installation from the ClawdHub registry.
|
|
5
|
+
* https://clawdhub.com
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { scanClawdHub, scanClawdHubPage } from './scan.js';
|
|
9
|
+
export { installSkillsFromClawdHub } from './install.js';
|
|
10
|
+
export {
|
|
11
|
+
fetchClawdHubSkills,
|
|
12
|
+
fetchClawdHubSkillVersion,
|
|
13
|
+
fetchClawdHubSkillInfo,
|
|
14
|
+
downloadClawdHubSkill,
|
|
15
|
+
} from './api.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Check if a source string refers to ClawdHub
|
|
19
|
+
* @param {string} source
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
export function isClawdHubSource(source) {
|
|
23
|
+
return typeof source === 'string' && source.startsWith('clawdhub:');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* ClawdHub source identifier used in curated sources
|
|
28
|
+
*/
|
|
29
|
+
export const CLAWDHUB_SOURCE_ID = 'clawdhub';
|
|
30
|
+
export const CLAWDHUB_SOURCE_STRING = 'clawdhub:registry';
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClawdHub skill installation
|
|
3
|
+
*
|
|
4
|
+
* Downloads skills from ClawdHub as ZIP files and extracts them
|
|
5
|
+
* to the appropriate skill directory.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import os from 'os';
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import AdmZip from 'adm-zip';
|
|
12
|
+
|
|
13
|
+
import { downloadClawdHubSkill, fetchClawdHubSkillInfo } from './api.js';
|
|
14
|
+
|
|
15
|
+
const SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
|
|
16
|
+
|
|
17
|
+
function normalizeUserSkillDir(userSkillDir) {
|
|
18
|
+
if (!userSkillDir) return null;
|
|
19
|
+
const legacySkillDir = path.join(os.homedir(), '.config', 'opencode', 'skill');
|
|
20
|
+
const pluralSkillDir = path.join(os.homedir(), '.config', 'opencode', 'skills');
|
|
21
|
+
if (userSkillDir === legacySkillDir) {
|
|
22
|
+
if (fs.existsSync(legacySkillDir) && !fs.existsSync(pluralSkillDir)) return legacySkillDir;
|
|
23
|
+
return pluralSkillDir;
|
|
24
|
+
}
|
|
25
|
+
return userSkillDir;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function validateSkillName(skillName) {
|
|
29
|
+
if (typeof skillName !== 'string') return false;
|
|
30
|
+
if (skillName.length < 1 || skillName.length > 64) return false;
|
|
31
|
+
return SKILL_NAME_PATTERN.test(skillName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function safeRm(dir) {
|
|
35
|
+
try {
|
|
36
|
+
await fs.promises.rm(dir, { recursive: true, force: true });
|
|
37
|
+
} catch {
|
|
38
|
+
// ignore
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function ensureDir(dirPath) {
|
|
43
|
+
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName }) {
|
|
47
|
+
const source = targetSource === 'agents' ? 'agents' : 'opencode';
|
|
48
|
+
|
|
49
|
+
if (scope === 'user') {
|
|
50
|
+
if (source === 'agents') {
|
|
51
|
+
return path.join(os.homedir(), '.agents', 'skills', skillName);
|
|
52
|
+
}
|
|
53
|
+
return path.join(userSkillDir, skillName);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!workingDirectory) {
|
|
57
|
+
throw new Error('workingDirectory is required for project installs');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (source === 'agents') {
|
|
61
|
+
return path.join(workingDirectory, '.agents', 'skills', skillName);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return path.join(workingDirectory, '.opencode', 'skills', skillName);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Install skills from ClawdHub registry
|
|
69
|
+
* @param {Object} options
|
|
70
|
+
* @param {string} options.scope - 'user' or 'project'
|
|
71
|
+
* @param {string} [options.targetSource] - 'opencode' or 'agents'
|
|
72
|
+
* @param {string} [options.workingDirectory] - Required for project scope
|
|
73
|
+
* @param {string} options.userSkillDir - User skills directory
|
|
74
|
+
* @param {Array} options.selections - Array of { skillDir, clawdhub: { slug, version } }
|
|
75
|
+
* @param {string} [options.conflictPolicy] - 'prompt', 'skipAll', or 'overwriteAll'
|
|
76
|
+
* @param {Object} [options.conflictDecisions] - Per-skill conflict decisions
|
|
77
|
+
* @returns {Promise<{ ok: boolean, installed?: Array, skipped?: Array, error?: Object }>}
|
|
78
|
+
*/
|
|
79
|
+
export async function installSkillsFromClawdHub({
|
|
80
|
+
scope,
|
|
81
|
+
targetSource,
|
|
82
|
+
workingDirectory,
|
|
83
|
+
userSkillDir,
|
|
84
|
+
selections,
|
|
85
|
+
conflictPolicy,
|
|
86
|
+
conflictDecisions,
|
|
87
|
+
} = {}) {
|
|
88
|
+
if (scope !== 'user' && scope !== 'project') {
|
|
89
|
+
return { ok: false, error: { kind: 'invalidSource', message: 'Invalid scope' } };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (targetSource !== undefined && targetSource !== 'opencode' && targetSource !== 'agents') {
|
|
93
|
+
return { ok: false, error: { kind: 'invalidSource', message: 'Invalid target source' } };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!userSkillDir) {
|
|
97
|
+
return { ok: false, error: { kind: 'unknown', message: 'userSkillDir is required' } };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const normalizedUserSkillDir = normalizeUserSkillDir(userSkillDir);
|
|
101
|
+
if (normalizedUserSkillDir) {
|
|
102
|
+
userSkillDir = normalizedUserSkillDir;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (scope === 'project' && !workingDirectory) {
|
|
106
|
+
return { ok: false, error: { kind: 'invalidSource', message: 'Project installs require a directory parameter' } };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const requestedSkills = Array.isArray(selections) ? selections : [];
|
|
110
|
+
if (requestedSkills.length === 0) {
|
|
111
|
+
return { ok: false, error: { kind: 'invalidSource', message: 'No skills selected for installation' } };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Build installation plans
|
|
115
|
+
const skillPlans = requestedSkills.map((sel) => {
|
|
116
|
+
const slug = sel.clawdhub?.slug || sel.skillDir;
|
|
117
|
+
const version = sel.clawdhub?.version || 'latest';
|
|
118
|
+
return {
|
|
119
|
+
slug,
|
|
120
|
+
version,
|
|
121
|
+
installable: validateSkillName(slug),
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Check for conflicts before downloading
|
|
126
|
+
const conflicts = [];
|
|
127
|
+
for (const plan of skillPlans) {
|
|
128
|
+
if (!plan.installable) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const targetDir = getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName: plan.slug });
|
|
133
|
+
if (fs.existsSync(targetDir)) {
|
|
134
|
+
const decision = conflictDecisions?.[plan.slug];
|
|
135
|
+
const hasAutoPolicy = conflictPolicy === 'skipAll' || conflictPolicy === 'overwriteAll';
|
|
136
|
+
if (!decision && !hasAutoPolicy) {
|
|
137
|
+
conflicts.push({ skillName: plan.slug, scope, source: targetSource === 'agents' ? 'agents' : 'opencode' });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (conflicts.length > 0) {
|
|
143
|
+
return {
|
|
144
|
+
ok: false,
|
|
145
|
+
error: {
|
|
146
|
+
kind: 'conflicts',
|
|
147
|
+
message: 'Some skills already exist in the selected scope',
|
|
148
|
+
conflicts,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const installed = [];
|
|
154
|
+
const skipped = [];
|
|
155
|
+
|
|
156
|
+
for (const plan of skillPlans) {
|
|
157
|
+
if (!plan.installable) {
|
|
158
|
+
skipped.push({ skillName: plan.slug, reason: 'Invalid skill name' });
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
// Resolve 'latest' version if needed
|
|
164
|
+
let resolvedVersion = plan.version;
|
|
165
|
+
if (resolvedVersion === 'latest') {
|
|
166
|
+
try {
|
|
167
|
+
const info = await fetchClawdHubSkillInfo(plan.slug);
|
|
168
|
+
const latest = info.skill?.tags?.latest || info.latestVersion?.version || null;
|
|
169
|
+
if (latest) {
|
|
170
|
+
resolvedVersion = latest;
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
// ignore
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (resolvedVersion === 'latest') {
|
|
177
|
+
skipped.push({ skillName: plan.slug, reason: 'Unable to resolve latest version' });
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const targetDir = getTargetSkillDir({ scope, targetSource, workingDirectory, userSkillDir, skillName: plan.slug });
|
|
183
|
+
const exists = fs.existsSync(targetDir);
|
|
184
|
+
|
|
185
|
+
// Determine conflict resolution
|
|
186
|
+
let decision = conflictDecisions?.[plan.slug] || null;
|
|
187
|
+
if (!decision) {
|
|
188
|
+
if (exists && conflictPolicy === 'skipAll') decision = 'skip';
|
|
189
|
+
if (exists && conflictPolicy === 'overwriteAll') decision = 'overwrite';
|
|
190
|
+
if (!exists) decision = 'overwrite'; // No conflict, proceed
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (exists && decision === 'skip') {
|
|
194
|
+
skipped.push({ skillName: plan.slug, reason: 'Already installed (skipped)' });
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (exists && decision === 'overwrite') {
|
|
199
|
+
await safeRm(targetDir);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Download the skill ZIP
|
|
203
|
+
const zipBuffer = await downloadClawdHubSkill(plan.slug, resolvedVersion);
|
|
204
|
+
|
|
205
|
+
// Extract to a temp directory first for validation
|
|
206
|
+
const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `clawdhub-${plan.slug}-`));
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
const zip = new AdmZip(Buffer.from(zipBuffer));
|
|
210
|
+
zip.extractAllTo(tempDir, true);
|
|
211
|
+
|
|
212
|
+
// Verify SKILL.md exists
|
|
213
|
+
const skillMdPath = path.join(tempDir, 'SKILL.md');
|
|
214
|
+
if (!fs.existsSync(skillMdPath)) {
|
|
215
|
+
skipped.push({ skillName: plan.slug, reason: 'SKILL.md not found in downloaded package' });
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Move to target directory
|
|
220
|
+
await ensureDir(path.dirname(targetDir));
|
|
221
|
+
await fs.promises.rename(tempDir, targetDir);
|
|
222
|
+
|
|
223
|
+
installed.push({ skillName: plan.slug, scope, source: targetSource === 'agents' ? 'agents' : 'opencode' });
|
|
224
|
+
} catch (extractError) {
|
|
225
|
+
await safeRm(tempDir);
|
|
226
|
+
throw extractError;
|
|
227
|
+
}
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(`Failed to install ClawdHub skill "${plan.slug}":`, error);
|
|
230
|
+
skipped.push({
|
|
231
|
+
skillName: plan.slug,
|
|
232
|
+
reason: error instanceof Error ? error.message : 'Failed to download or extract skill',
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return { ok: true, installed, skipped };
|
|
238
|
+
}
|