mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-15 01:12:11 +00:00
Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07349e6107 | ||
|
|
5ef00e8c6a | ||
|
|
c5e5e657dd | ||
|
|
69e1e5c507 | ||
|
|
481f1b9188 | ||
|
|
d4f5832554 | ||
|
|
ca3275ba92 | ||
|
|
d577add8a0 | ||
|
|
90bd065f7e | ||
|
|
219f05b160 | ||
|
|
c8091ee8a8 | ||
|
|
63f367e1d6 | ||
|
|
e701d7b713 | ||
|
|
79bd1f1d6c | ||
|
|
ac51cc0236 | ||
|
|
b9c23dc00e | ||
|
|
f4e96995bc | ||
|
|
33165db598 | ||
|
|
4c10e4847b | ||
|
|
8d68b55333 | ||
|
|
251de1f540 | ||
|
|
123f60fa93 | ||
|
|
643faf71c8 |
@@ -34,7 +34,7 @@ jobs:
|
||||
- name: Typecheck packages
|
||||
run: |
|
||||
bunx tsc -p packages/schema/tsconfig.json --noEmit
|
||||
bunx tsc -p packages/clawdhub/tsconfig.json --noEmit
|
||||
bunx tsc -p packages/molthub/tsconfig.json --noEmit
|
||||
|
||||
- name: Build
|
||||
run: bun run build
|
||||
|
||||
@@ -40,5 +40,6 @@
|
||||
- OAuth: GitHub OAuth App credentials required for login.
|
||||
|
||||
## Convex Ops (Gotchas)
|
||||
- New Convex functions must be pushed before `convex run`: use `bunx convex dev --once` (dev) or `bunx convex deploy --prod` (prod).
|
||||
- New Convex functions must be pushed before `convex run`: use `bunx convex dev --once` (dev) or `bunx convex deploy` (prod).
|
||||
- For non-interactive prod deploys, use `bunx convex deploy -y` to skip confirmation.
|
||||
- If `bunx convex run --env-file .env.local ...` returns `401 MissingAccessToken` despite `bunx convex login`, workaround: omit `--env-file` and use `--deployment-name <name>` / `--prod`.
|
||||
|
||||
+7
-7
@@ -26,7 +26,7 @@
|
||||
|
||||
### Added
|
||||
- Web: dynamic OG image cards for skills (name, description, version).
|
||||
- CLI: auto-scan Clawdbot skill roots (per-agent workspaces, shared skills, extraDirs).
|
||||
- CLI: auto-scan Moltbot skill roots (per-agent workspaces, shared skills, extraDirs).
|
||||
- Web: import skills from public GitHub URLs (auto-detect `SKILL.md`, smart file selection, provenance).
|
||||
- Web/API: SoulHub (SOUL.md registry) with v1 endpoints and first-run auto-seed.
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
- Registry: make SoulHub auto-seed idempotent and non-user-owned.
|
||||
- Registry: keep GitHub backup state + publish backups intact (thanks @joshp123, #1).
|
||||
- CLI/Registry: restore fork lineage on sync + clamp bulk list queries (thanks @joshp123, #1).
|
||||
- CLI: default workdir falls back to Clawdbot workspace (override with `--workdir` / `CLAWDHUB_WORKDIR`).
|
||||
- CLI: default workdir falls back to Moltbot workspace (override with `--workdir` / `MOLTHUB_WORKDIR`).
|
||||
|
||||
## 0.0.6 - 2026-01-07
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
## 0.0.5 - 2026-01-06
|
||||
|
||||
### Added
|
||||
- Telemetry: track installs via `clawdhub sync` (logged-in only), per root, with 120-day staleness.
|
||||
- Telemetry: track installs via `molthub sync` (logged-in only), per root, with 120-day staleness.
|
||||
- Skills: show current + all-time installs; sort by installs.
|
||||
- Profile: private "Installed" tab with JSON export + delete telemetry controls.
|
||||
- Docs: add `docs/telemetry.md` (what we track + how to opt out).
|
||||
@@ -60,7 +60,7 @@
|
||||
- Web: dashboard for managing your published skills (thanks @dbhurley!).
|
||||
|
||||
### Changed
|
||||
- CLI: telemetry opt-out via `CLAWDHUB_DISABLE_TELEMETRY=1`.
|
||||
- CLI: telemetry opt-out via `MOLTHUB_DISABLE_TELEMETRY=1`.
|
||||
- Web: move theme picker into mobile menu.
|
||||
|
||||
### Fixed
|
||||
@@ -89,7 +89,7 @@
|
||||
- Web: improved mobile responsiveness (nav menu, skill detail layout, install command overflow).
|
||||
- Web: upload now unwraps folder picks so `SKILL.md` can be at the bundle root.
|
||||
- Registry: cap embedding payload size to avoid model context errors.
|
||||
- CLI: ignore legacy `auth.clawdhub.com` registry and prefer site discovery.
|
||||
- CLI: ignore legacy `auth.molthub.com` registry and prefer site discovery.
|
||||
|
||||
### Changed
|
||||
- Web: homepage search now expands into full search mode with live results + highlighted toggle.
|
||||
@@ -108,8 +108,8 @@
|
||||
### Fixed
|
||||
- CLI sync: wrap note output to avoid terminal overflow; cap list lengths.
|
||||
- CLI sync: label fallback scans as fallback locations.
|
||||
- CLI package: bundle schema internally (no external `clawdhub-schema` publish).
|
||||
- Repo: mark `clawdhub-schema` as private to prevent publishing.
|
||||
- CLI package: bundle schema internally (no external `molthub-schema` publish).
|
||||
- Repo: mark `molthub-schema` as private to prevent publishing.
|
||||
|
||||
## 0.0.2 - 2026-01-04
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# ClawdHub
|
||||
# MoltHub
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/clawdbot/clawdhub/actions/workflows/ci.yml?branch=main"><img src="https://img.shields.io/github/actions/workflow/status/clawdbot/clawdhub/ci.yml?branch=main&style=for-the-badge" alt="CI status"></a>
|
||||
<a href="https://discord.gg/clawd"><img src="https://img.shields.io/discord/1456350064065904867?label=Discord&logo=discord&logoColor=white&color=5865F2&style=for-the-badge" alt="Discord"></a>
|
||||
<a href="https://github.com/moltbot/molthub/actions/workflows/ci.yml?branch=main"><img src="https://img.shields.io/github/actions/workflow/status/moltbot/molthub/ci.yml?branch=main&style=for-the-badge" alt="CI status"></a>
|
||||
<a href="https://discord.gg/molt"><img src="https://img.shields.io/discord/1456350064065904867?label=Discord&logo=discord&logoColor=white&color=5865F2&style=for-the-badge" alt="Discord"></a>
|
||||
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
|
||||
</p>
|
||||
|
||||
ClawdHub is the **public skill registry for Clawdbot**: publish, version, and search text-based agent skills (a `SKILL.md` plus supporting files).
|
||||
MoltHub is the **public skill registry for Moltbot**: publish, version, and search text-based agent skills (a `SKILL.md` plus supporting files).
|
||||
It’s designed for fast browsing + a CLI-friendly API, with moderation hooks and vector search.
|
||||
|
||||
onlycrabs.ai is the **SOUL.md registry**: publish and share system lore the same way you publish skills.
|
||||
|
||||
Live: `https://clawdhub.com`
|
||||
Live: `https://molthub.com`
|
||||
onlycrabs.ai: `https://onlycrabs.ai`
|
||||
|
||||
## What you can do
|
||||
@@ -27,7 +27,7 @@ onlycrabs.ai: `https://onlycrabs.ai`
|
||||
|
||||
- Entry point is host-based: `onlycrabs.ai`.
|
||||
- On the onlycrabs.ai host, the home page and nav default to souls.
|
||||
- On ClawdHub, souls live under `/souls`.
|
||||
- On MoltHub, souls live under `/souls`.
|
||||
- Soul bundles only accept `SOUL.md` for now (no extra files).
|
||||
|
||||
## How it works (high level)
|
||||
@@ -35,15 +35,15 @@ onlycrabs.ai: `https://onlycrabs.ai`
|
||||
- Web app: TanStack Start (React, Vite/Nitro).
|
||||
- Backend: Convex (DB + file storage + HTTP actions) + Convex Auth (GitHub OAuth).
|
||||
- Search: OpenAI embeddings (`text-embedding-3-small`) + Convex vector search.
|
||||
- API schema + routes: `packages/schema` (`clawdhub-schema`).
|
||||
- API schema + routes: `packages/schema` (`molthub-schema`).
|
||||
|
||||
## Telemetry
|
||||
|
||||
ClawdHub tracks minimal **install telemetry** (to compute install counts) when you run `clawdhub sync` while logged in.
|
||||
MoltHub tracks minimal **install telemetry** (to compute install counts) when you run `molthub sync` while logged in.
|
||||
Disable via:
|
||||
|
||||
```bash
|
||||
export CLAWDHUB_DISABLE_TELEMETRY=1
|
||||
export MOLTHUB_DISABLE_TELEMETRY=1
|
||||
```
|
||||
|
||||
Details: `docs/telemetry.md`.
|
||||
@@ -95,7 +95,7 @@ This writes `JWT_PRIVATE_KEY` + `JWKS` to the deployment and prints values for y
|
||||
|
||||
## Nix plugins (nixmode skills)
|
||||
|
||||
ClawdHub can store a nix-clawdbot plugin pointer in SKILL frontmatter so the registry knows which
|
||||
MoltHub can store a nix-moltbot plugin pointer in SKILL frontmatter so the registry knows which
|
||||
Nix package bundle to install. A nix plugin is different from a regular skill pack: it bundles the
|
||||
skill pack, the CLI binary, and its config flags/requirements together.
|
||||
|
||||
@@ -105,15 +105,15 @@ Add this to `SKILL.md`:
|
||||
---
|
||||
name: peekaboo
|
||||
description: Capture and automate macOS UI with the Peekaboo CLI.
|
||||
metadata: {"clawdbot":{"nix":{"plugin":"github:clawdbot/nix-steipete-tools?dir=tools/peekaboo","systems":["aarch64-darwin"]}}}
|
||||
metadata: {"moltbot":{"nix":{"plugin":"github:moltbot/nix-steipete-tools?dir=tools/peekaboo","systems":["aarch64-darwin"]}}}
|
||||
---
|
||||
```
|
||||
|
||||
Install via nix-clawdbot:
|
||||
Install via nix-moltbot:
|
||||
|
||||
```nix
|
||||
programs.clawdbot.plugins = [
|
||||
{ source = "github:clawdbot/nix-steipete-tools?dir=tools/peekaboo"; }
|
||||
programs.moltbot.plugins = [
|
||||
{ source = "github:moltbot/nix-steipete-tools?dir=tools/peekaboo"; }
|
||||
];
|
||||
```
|
||||
|
||||
@@ -123,7 +123,7 @@ You can also declare config requirements + an example snippet:
|
||||
---
|
||||
name: padel
|
||||
description: Check padel court availability and manage bookings via Playtomic.
|
||||
metadata: {"clawdbot":{"config":{"requiredEnv":["PADEL_AUTH_FILE"],"stateDirs":[".config/padel"],"example":"config = { env = { PADEL_AUTH_FILE = \\\"/run/agenix/padel-auth\\\"; }; };"}}}
|
||||
metadata: {"moltbot":{"config":{"requiredEnv":["PADEL_AUTH_FILE"],"stateDirs":[".config/padel"],"example":"config = { env = { PADEL_AUTH_FILE = \\\"/run/agenix/padel-auth\\\"; }; };"}}}
|
||||
---
|
||||
```
|
||||
|
||||
@@ -133,11 +133,11 @@ To show CLI help (recommended for nix plugins), include the `cli --help` output:
|
||||
---
|
||||
name: padel
|
||||
description: Check padel court availability and manage bookings via Playtomic.
|
||||
metadata: {"clawdbot":{"cliHelp":"padel --help\\nUsage: padel [command]\\n"}}
|
||||
metadata: {"moltbot":{"cliHelp":"padel --help\\nUsage: padel [command]\\n"}}
|
||||
---
|
||||
```
|
||||
|
||||
`metadata.clawdbot` is preferred, but `metadata.clawdis` is accepted as an alias for compatibility.
|
||||
`metadata.moltbot` is preferred, but `metadata.moltbot` is accepted as an alias for compatibility.
|
||||
|
||||
## Scripts
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"configVersion": 0,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "clawdhub",
|
||||
"name": "molthub",
|
||||
"dependencies": {
|
||||
"@auth/core": "^0.37.4",
|
||||
"@convex-dev/auth": "^0.0.90",
|
||||
@@ -21,12 +21,13 @@
|
||||
"@tanstack/react-start": "^1.152.0",
|
||||
"@tanstack/router-plugin": "^1.151.6",
|
||||
"@vercel/analytics": "^1.6.1",
|
||||
"clawdhub-schema": "workspace:*",
|
||||
"clsx": "^2.1.1",
|
||||
"convex": "^1.31.5",
|
||||
"convex": "^1.31.6",
|
||||
"convex-helpers": "^0.1.111",
|
||||
"fflate": "^0.8.2",
|
||||
"h3": "2.0.1-rc.8",
|
||||
"lucide-react": "^0.562.0",
|
||||
"molthub-schema": "workspace:*",
|
||||
"monaco-editor": "^0.55.1",
|
||||
"nitro": "^3.0.1-alpha.1",
|
||||
"react": "^19.2.3",
|
||||
@@ -52,6 +53,7 @@
|
||||
"@vitejs/plugin-react": "^5.1.2",
|
||||
"@vitest/coverage-v8": "^4.0.17",
|
||||
"jsdom": "^27.4.0",
|
||||
"only-allow": "^1.2.1",
|
||||
"oxlint": "^1.39.0",
|
||||
"oxlint-tsgolint": "^0.11.1",
|
||||
"typescript": "^5.9.3",
|
||||
@@ -59,11 +61,11 @@
|
||||
"vitest": "^4.0.17",
|
||||
},
|
||||
},
|
||||
"packages/clawdhub": {
|
||||
"name": "clawdhub",
|
||||
"packages/molthub": {
|
||||
"name": "molthub",
|
||||
"version": "0.3.0",
|
||||
"bin": {
|
||||
"clawdhub": "bin/clawdhub.js",
|
||||
"molthub": "bin/molthub.js",
|
||||
},
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^0.11.0",
|
||||
@@ -84,7 +86,7 @@
|
||||
},
|
||||
},
|
||||
"packages/schema": {
|
||||
"name": "clawdhub-schema",
|
||||
"name": "molthub-schema",
|
||||
"version": "0.0.2",
|
||||
"dependencies": {
|
||||
"arktype": "^2.1.29",
|
||||
@@ -721,10 +723,6 @@
|
||||
|
||||
"chokidar": ["chokidar@3.6.0", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
|
||||
|
||||
"clawdhub": ["clawdhub@workspace:packages/clawdhub"],
|
||||
|
||||
"clawdhub-schema": ["clawdhub-schema@workspace:packages/schema"],
|
||||
|
||||
"cli-cursor": ["cli-cursor@5.0.0", "", { "dependencies": { "restore-cursor": "^5.0.0" } }, "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw=="],
|
||||
|
||||
"cli-spinners": ["cli-spinners@3.3.0", "", {}, "sha512-/+40ljC3ONVnYIttjMWrlL51nItDAbBrq2upN8BPyvGU/2n5Oxw3tbNwORCaNuNqLJnxGqOfjUuhsv7l5Q4IsQ=="],
|
||||
@@ -739,7 +737,9 @@
|
||||
|
||||
"convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
|
||||
|
||||
"convex": ["convex@1.31.5", "", { "dependencies": { "esbuild": "0.27.0", "prettier": "^3.0.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-E1IuJKFwMCHDToNGukBPs6c7RFaarR3t8chLF9n98TM5/Tgmj8lM6l7sKM1aJ3VwqGaB4wbeUAPY8osbCOXBhQ=="],
|
||||
"convex": ["convex@1.31.6", "", { "dependencies": { "esbuild": "0.27.0", "prettier": "^3.0.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-9cIsOzepa3s9DURRF+fZHxbNuzLgilg9XGQCc45v0Xx4FemqeIezpPFSJF9WHC9ckk43TDUUXLecvLVt9djPkw=="],
|
||||
|
||||
"convex-helpers": ["convex-helpers@0.1.111", "", { "peerDependencies": { "@standard-schema/spec": "^1.0.0", "convex": "^1.25.4", "hono": "^4.0.5", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": "^5.5", "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["@standard-schema/spec", "hono", "react", "typescript", "zod"], "bin": { "convex-helpers": "bin.cjs" } }, "sha512-0O59Ohi8HVc3+KULxSC6JHsw8cQJyc8gZ7OAfNRVX7T5Wy6LhPx3l8veYN9avKg7UiPlO7m1eBiQMHKclIyXyQ=="],
|
||||
|
||||
"cookie": ["cookie@1.1.1", "", {}, "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ=="],
|
||||
|
||||
@@ -1059,6 +1059,10 @@
|
||||
|
||||
"mimic-function": ["mimic-function@5.0.1", "", {}, "sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA=="],
|
||||
|
||||
"molthub": ["molthub@workspace:packages/molthub"],
|
||||
|
||||
"molthub-schema": ["molthub-schema@workspace:packages/schema"],
|
||||
|
||||
"monaco-editor": ["monaco-editor@0.55.1", "", { "dependencies": { "dompurify": "3.2.7", "marked": "14.0.0" } }, "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A=="],
|
||||
|
||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
@@ -1085,6 +1089,8 @@
|
||||
|
||||
"onetime": ["onetime@7.0.0", "", { "dependencies": { "mimic-function": "^5.0.0" } }, "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ=="],
|
||||
|
||||
"only-allow": ["only-allow@1.2.2", "", { "dependencies": { "which-pm-runs": "1.1.0" }, "bin": { "only-allow": "bin.js" } }, "sha512-uxyNYDsCh5YIJ780G7hC5OHjVUr9reHsbZNMM80L9tZlTpb3hUzb36KXgW4ZUGtJKQnGA3xegmWg1BxhWV0jJA=="],
|
||||
|
||||
"ora": ["ora@9.0.0", "", { "dependencies": { "chalk": "^5.6.2", "cli-cursor": "^5.0.0", "cli-spinners": "^3.2.0", "is-interactive": "^2.0.0", "is-unicode-supported": "^2.1.0", "log-symbols": "^7.0.1", "stdin-discarder": "^0.2.2", "string-width": "^8.1.0", "strip-ansi": "^7.1.2" } }, "sha512-m0pg2zscbYgWbqRR6ABga5c3sZdEon7bSgjnlXC64kxtxLOyjRcbbUkLj7HFyy/FTD+P2xdBWu8snGhYI0jc4A=="],
|
||||
|
||||
"oxc-minify": ["oxc-minify@0.96.0", "", { "optionalDependencies": { "@oxc-minify/binding-android-arm64": "0.96.0", "@oxc-minify/binding-darwin-arm64": "0.96.0", "@oxc-minify/binding-darwin-x64": "0.96.0", "@oxc-minify/binding-freebsd-x64": "0.96.0", "@oxc-minify/binding-linux-arm-gnueabihf": "0.96.0", "@oxc-minify/binding-linux-arm-musleabihf": "0.96.0", "@oxc-minify/binding-linux-arm64-gnu": "0.96.0", "@oxc-minify/binding-linux-arm64-musl": "0.96.0", "@oxc-minify/binding-linux-riscv64-gnu": "0.96.0", "@oxc-minify/binding-linux-s390x-gnu": "0.96.0", "@oxc-minify/binding-linux-x64-gnu": "0.96.0", "@oxc-minify/binding-linux-x64-musl": "0.96.0", "@oxc-minify/binding-wasm32-wasi": "0.96.0", "@oxc-minify/binding-win32-arm64-msvc": "0.96.0", "@oxc-minify/binding-win32-x64-msvc": "0.96.0" } }, "sha512-dXeeGrfPJJ4rMdw+NrqiCRtbzVX2ogq//R0Xns08zql2HjV3Zi2SBJ65saqfDaJzd2bcHqvGWH+M44EQCHPAcA=="],
|
||||
@@ -1319,6 +1325,8 @@
|
||||
|
||||
"whatwg-url": ["whatwg-url@15.1.0", "", { "dependencies": { "tr46": "^6.0.0", "webidl-conversions": "^8.0.0" } }, "sha512-2ytDk0kiEj/yu90JOAp44PVPUkO9+jVhyf+SybKlRHSDlvOOZhdPIrr7xTH64l4WixO2cP+wQIcgujkGBPPz6g=="],
|
||||
|
||||
"which-pm-runs": ["which-pm-runs@1.1.0", "", {}, "sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA=="],
|
||||
|
||||
"why-is-node-running": ["why-is-node-running@2.3.0", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": { "why-is-node-running": "cli.js" } }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
|
||||
|
||||
"ws": ["ws@8.18.3", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg=="],
|
||||
|
||||
Vendored
+10
@@ -12,6 +12,7 @@ import type * as auth from "../auth.js";
|
||||
import type * as comments from "../comments.js";
|
||||
import type * as crons from "../crons.js";
|
||||
import type * as devSeed from "../devSeed.js";
|
||||
import type * as devSeedExtra from "../devSeedExtra.js";
|
||||
import type * as downloads from "../downloads.js";
|
||||
import type * as githubBackups from "../githubBackups.js";
|
||||
import type * as githubBackupsNode from "../githubBackupsNode.js";
|
||||
@@ -24,12 +25,15 @@ import type * as httpApiV1 from "../httpApiV1.js";
|
||||
import type * as leaderboards from "../leaderboards.js";
|
||||
import type * as lib_access from "../lib/access.js";
|
||||
import type * as lib_apiTokenAuth from "../lib/apiTokenAuth.js";
|
||||
import type * as lib_badges from "../lib/badges.js";
|
||||
import type * as lib_changelog from "../lib/changelog.js";
|
||||
import type * as lib_embeddings from "../lib/embeddings.js";
|
||||
import type * as lib_githubBackup from "../lib/githubBackup.js";
|
||||
import type * as lib_githubImport from "../lib/githubImport.js";
|
||||
import type * as lib_githubSoulBackup from "../lib/githubSoulBackup.js";
|
||||
import type * as lib_leaderboards from "../lib/leaderboards.js";
|
||||
import type * as lib_moderation from "../lib/moderation.js";
|
||||
import type * as lib_public from "../lib/public.js";
|
||||
import type * as lib_searchText from "../lib/searchText.js";
|
||||
import type * as lib_skillBackfill from "../lib/skillBackfill.js";
|
||||
import type * as lib_skillPublish from "../lib/skillPublish.js";
|
||||
@@ -44,6 +48,7 @@ import type * as rateLimits from "../rateLimits.js";
|
||||
import type * as search from "../search.js";
|
||||
import type * as seed from "../seed.js";
|
||||
import type * as seedSouls from "../seedSouls.js";
|
||||
import type * as skillStatEvents from "../skillStatEvents.js";
|
||||
import type * as skills from "../skills.js";
|
||||
import type * as soulComments from "../soulComments.js";
|
||||
import type * as soulDownloads from "../soulDownloads.js";
|
||||
@@ -68,6 +73,7 @@ declare const fullApi: ApiFromModules<{
|
||||
comments: typeof comments;
|
||||
crons: typeof crons;
|
||||
devSeed: typeof devSeed;
|
||||
devSeedExtra: typeof devSeedExtra;
|
||||
downloads: typeof downloads;
|
||||
githubBackups: typeof githubBackups;
|
||||
githubBackupsNode: typeof githubBackupsNode;
|
||||
@@ -80,12 +86,15 @@ declare const fullApi: ApiFromModules<{
|
||||
leaderboards: typeof leaderboards;
|
||||
"lib/access": typeof lib_access;
|
||||
"lib/apiTokenAuth": typeof lib_apiTokenAuth;
|
||||
"lib/badges": typeof lib_badges;
|
||||
"lib/changelog": typeof lib_changelog;
|
||||
"lib/embeddings": typeof lib_embeddings;
|
||||
"lib/githubBackup": typeof lib_githubBackup;
|
||||
"lib/githubImport": typeof lib_githubImport;
|
||||
"lib/githubSoulBackup": typeof lib_githubSoulBackup;
|
||||
"lib/leaderboards": typeof lib_leaderboards;
|
||||
"lib/moderation": typeof lib_moderation;
|
||||
"lib/public": typeof lib_public;
|
||||
"lib/searchText": typeof lib_searchText;
|
||||
"lib/skillBackfill": typeof lib_skillBackfill;
|
||||
"lib/skillPublish": typeof lib_skillPublish;
|
||||
@@ -100,6 +109,7 @@ declare const fullApi: ApiFromModules<{
|
||||
search: typeof search;
|
||||
seed: typeof seed;
|
||||
seedSouls: typeof seedSouls;
|
||||
skillStatEvents: typeof skillStatEvents;
|
||||
skills: typeof skills;
|
||||
soulComments: typeof soulComments;
|
||||
soulDownloads: typeof soulDownloads;
|
||||
|
||||
+5
-4
@@ -1,7 +1,8 @@
|
||||
import { v } from 'convex/values'
|
||||
import type { Doc } from './_generated/dataModel'
|
||||
import { mutation, query } from './_generated/server'
|
||||
import { assertRole, requireUser } from './lib/access'
|
||||
import { assertModerator, requireUser } from './lib/access'
|
||||
import { type PublicUser, toPublicUser } from './lib/public'
|
||||
|
||||
export const listBySkill = query({
|
||||
args: { skillId: v.id('skills'), limit: v.optional(v.number()) },
|
||||
@@ -13,10 +14,10 @@ export const listBySkill = query({
|
||||
.order('desc')
|
||||
.take(limit)
|
||||
|
||||
const results: Array<{ comment: Doc<'comments'>; user: Doc<'users'> | null }> = []
|
||||
const results: Array<{ comment: Doc<'comments'>; user: PublicUser | null }> = []
|
||||
for (const comment of comments) {
|
||||
if (comment.softDeletedAt) continue
|
||||
const user = await ctx.db.get(comment.userId)
|
||||
const user = toPublicUser(await ctx.db.get(comment.userId))
|
||||
results.push({ comment, user })
|
||||
}
|
||||
return results
|
||||
@@ -59,7 +60,7 @@ export const remove = mutation({
|
||||
|
||||
const isOwner = comment.userId === user._id
|
||||
if (!isOwner) {
|
||||
assertRole(user, ['admin', 'moderator'])
|
||||
assertModerator(user)
|
||||
}
|
||||
|
||||
await ctx.db.patch(comment._id, {
|
||||
|
||||
@@ -24,4 +24,11 @@ crons.interval(
|
||||
{ batchSize: 200, maxBatches: 5 },
|
||||
)
|
||||
|
||||
crons.interval(
|
||||
'skill-stat-events',
|
||||
{ minutes: 15 },
|
||||
internal.skillStatEvents.processSkillStatEventsAction,
|
||||
{},
|
||||
)
|
||||
|
||||
export default crons
|
||||
|
||||
+12
-12
@@ -3,7 +3,7 @@ import { internal } from './_generated/api'
|
||||
import type { ActionCtx } from './_generated/server'
|
||||
import { internalAction, internalMutation } from './_generated/server'
|
||||
import { EMBEDDING_DIMENSIONS } from './lib/embeddings'
|
||||
import { parseClawdisMetadata, parseFrontmatter } from './lib/skills'
|
||||
import { parseFrontmatter, parseMoltbotMetadata } from './lib/skills'
|
||||
|
||||
type SeedSkillSpec = {
|
||||
slug: string
|
||||
@@ -32,7 +32,7 @@ const SEED_SKILLS: SeedSkillSpec[] = [
|
||||
summary: 'Check padel court availability and manage bookings via Playtomic.',
|
||||
version: '0.1.0',
|
||||
metadata: {
|
||||
clawdbot: {
|
||||
moltbot: {
|
||||
nix: {
|
||||
plugin: 'github:joshp123/padel-cli',
|
||||
systems: ['aarch64-darwin', 'x86_64-linux'],
|
||||
@@ -74,7 +74,7 @@ description: Check padel court availability and manage bookings via the padel CL
|
||||
## CLI
|
||||
|
||||
\`\`\`bash
|
||||
padel # On PATH (clawdbot plugin bundle)
|
||||
padel # On PATH (moltbot plugin bundle)
|
||||
\`\`\`
|
||||
|
||||
## Venues
|
||||
@@ -110,7 +110,7 @@ Only the authorized booker can confirm bookings. If the requester is not authori
|
||||
summary: 'Operate GoHome via gRPC discovery, metrics, and Grafana dashboards.',
|
||||
version: '0.1.0',
|
||||
metadata: {
|
||||
clawdbot: {
|
||||
moltbot: {
|
||||
nix: {
|
||||
plugin: 'github:joshp123/gohome',
|
||||
systems: ['x86_64-linux', 'aarch64-linux'],
|
||||
@@ -141,7 +141,7 @@ Flags:
|
||||
},
|
||||
rawSkillMd: `---
|
||||
name: gohome
|
||||
description: Use when Clawdbot needs to test or operate GoHome via gRPC discovery, metrics, and Grafana.
|
||||
description: Use when Moltbot needs to test or operate GoHome via gRPC discovery, metrics, and Grafana.
|
||||
---
|
||||
|
||||
# GoHome Skill
|
||||
@@ -183,7 +183,7 @@ Only call write RPCs after explicit user approval.
|
||||
summary: 'Teach Mandarin with the xuezh engine for review, speaking, and audits.',
|
||||
version: '0.1.0',
|
||||
metadata: {
|
||||
clawdbot: {
|
||||
moltbot: {
|
||||
nix: {
|
||||
plugin: 'github:joshp123/xuezh',
|
||||
systems: ['aarch64-darwin', 'x86_64-linux'],
|
||||
@@ -258,7 +258,7 @@ async function seedNixSkillsHandler(
|
||||
for (const spec of SEED_SKILLS) {
|
||||
const skillMd = injectMetadata(spec.rawSkillMd, spec.metadata)
|
||||
const frontmatter = parseFrontmatter(skillMd)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
const storageId = await ctx.storage.store(new Blob([skillMd], { type: 'text/markdown' }))
|
||||
|
||||
const result: SeedMutationResult = await ctx.runMutation(internal.devSeed.seedSkillMutation, {
|
||||
@@ -266,7 +266,7 @@ async function seedNixSkillsHandler(
|
||||
storageId,
|
||||
metadata: spec.metadata,
|
||||
frontmatter,
|
||||
clawdis,
|
||||
moltbot,
|
||||
skillMd,
|
||||
slug: spec.slug,
|
||||
displayName: spec.displayName,
|
||||
@@ -296,7 +296,7 @@ async function seedPadelSkillHandler(
|
||||
|
||||
const skillMd = injectMetadata(spec.rawSkillMd, spec.metadata)
|
||||
const frontmatter = parseFrontmatter(skillMd)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
const storageId = await ctx.storage.store(new Blob([skillMd], { type: 'text/markdown' }))
|
||||
|
||||
return (await ctx.runMutation(internal.devSeed.seedSkillMutation, {
|
||||
@@ -304,7 +304,7 @@ async function seedPadelSkillHandler(
|
||||
storageId,
|
||||
metadata: spec.metadata,
|
||||
frontmatter,
|
||||
clawdis,
|
||||
moltbot,
|
||||
skillMd,
|
||||
slug: spec.slug,
|
||||
displayName: spec.displayName,
|
||||
@@ -326,7 +326,7 @@ export const seedSkillMutation = internalMutation({
|
||||
storageId: v.id('_storage'),
|
||||
metadata: v.any(),
|
||||
frontmatter: v.any(),
|
||||
clawdis: v.any(),
|
||||
moltbot: v.any(),
|
||||
skillMd: v.string(),
|
||||
slug: v.string(),
|
||||
displayName: v.string(),
|
||||
@@ -418,7 +418,7 @@ export const seedSkillMutation = internalMutation({
|
||||
parsed: {
|
||||
frontmatter: args.frontmatter,
|
||||
metadata: args.metadata,
|
||||
clawdis: args.clawdis,
|
||||
moltbot: args.moltbot,
|
||||
},
|
||||
createdBy: userId,
|
||||
createdAt: now,
|
||||
|
||||
@@ -0,0 +1,541 @@
|
||||
/**
|
||||
* Extra seed skills for pagination testing.
|
||||
*
|
||||
* This file contains 50 placeholder skills to test pagination behavior.
|
||||
* Run with: bunx convex run internal.devSeedExtra.seedExtraSkillsInternal
|
||||
* Or with reset: bunx convex run internal.devSeedExtra.seedExtraSkillsInternal '{"reset": true}'
|
||||
*/
|
||||
|
||||
import { v } from 'convex/values'
|
||||
import { internal } from './_generated/api'
|
||||
import type { Id } from './_generated/dataModel'
|
||||
import type { ActionCtx } from './_generated/server'
|
||||
import { internalAction, internalMutation } from './_generated/server'
|
||||
import { parseFrontmatter, parseMoltbotMetadata } from './lib/skills'
|
||||
|
||||
type SeedSkillSpec = {
|
||||
slug: string
|
||||
displayName: string
|
||||
summary: string
|
||||
version: string
|
||||
metadata: Record<string, unknown>
|
||||
rawSkillMd: string
|
||||
}
|
||||
|
||||
function makeSkill(
|
||||
slug: string,
|
||||
displayName: string,
|
||||
summary: string,
|
||||
envVars: string[] = [],
|
||||
commands: string[] = ['help', 'status', 'run'],
|
||||
): SeedSkillSpec {
|
||||
const cliHelp = `${slug} - ${summary}
|
||||
|
||||
Usage:
|
||||
${slug} [command]
|
||||
|
||||
Commands:
|
||||
${commands.map((cmd) => ` ${cmd.padEnd(12)} Run ${cmd} operation`).join('\n')}
|
||||
|
||||
Flags:
|
||||
-h, --help Show help
|
||||
--json Output as JSON
|
||||
`
|
||||
|
||||
const rawSkillMd = `---
|
||||
name: ${slug}
|
||||
description: ${summary}
|
||||
---
|
||||
|
||||
# ${displayName}
|
||||
|
||||
## CLI
|
||||
|
||||
\`\`\`bash
|
||||
${commands.map((cmd) => `${slug} ${cmd}`).join('\n')}
|
||||
\`\`\`
|
||||
|
||||
## Usage
|
||||
|
||||
Use this skill to ${summary.toLowerCase()}.
|
||||
`
|
||||
|
||||
return {
|
||||
slug,
|
||||
displayName,
|
||||
summary,
|
||||
version: '0.1.0',
|
||||
metadata: {
|
||||
moltbot: {
|
||||
nix: {
|
||||
plugin: `github:example/${slug}`,
|
||||
systems: ['aarch64-darwin', 'x86_64-linux'],
|
||||
},
|
||||
config: {
|
||||
requiredEnv: envVars,
|
||||
},
|
||||
cliHelp,
|
||||
},
|
||||
},
|
||||
rawSkillMd,
|
||||
}
|
||||
}
|
||||
|
||||
// 50 placeholder skills for pagination testing
|
||||
const EXTRA_SEED_SKILLS: SeedSkillSpec[] = [
|
||||
// DevOps & Infrastructure (10)
|
||||
makeSkill(
|
||||
'kubectl-helper',
|
||||
'Kubectl Helper',
|
||||
'Simplified kubectl commands for common Kubernetes operations.',
|
||||
['KUBECONFIG'],
|
||||
['pods', 'logs', 'exec', 'describe', 'apply'],
|
||||
),
|
||||
makeSkill(
|
||||
'terraform-runner',
|
||||
'Terraform Runner',
|
||||
'Execute Terraform plans and applies with safety checks.',
|
||||
['TF_VAR_region', 'AWS_PROFILE'],
|
||||
['plan', 'apply', 'destroy', 'output', 'state'],
|
||||
),
|
||||
makeSkill(
|
||||
'ansible-exec',
|
||||
'Ansible Exec',
|
||||
'Run Ansible playbooks and ad-hoc commands.',
|
||||
['ANSIBLE_INVENTORY'],
|
||||
['playbook', 'adhoc', 'inventory', 'facts', 'vault'],
|
||||
),
|
||||
makeSkill(
|
||||
'docker-compose-mgr',
|
||||
'Docker Compose Manager',
|
||||
'Manage Docker Compose stacks and services.',
|
||||
['DOCKER_HOST'],
|
||||
['up', 'down', 'logs', 'ps', 'restart'],
|
||||
),
|
||||
makeSkill(
|
||||
'k9s-wrapper',
|
||||
'K9s Wrapper',
|
||||
'Interactive Kubernetes cluster management via K9s.',
|
||||
['KUBECONFIG'],
|
||||
['launch', 'contexts', 'namespaces', 'pods', 'logs'],
|
||||
),
|
||||
makeSkill(
|
||||
'helm-charts',
|
||||
'Helm Charts',
|
||||
'Manage Helm chart deployments and releases.',
|
||||
['KUBECONFIG', 'HELM_REPO'],
|
||||
['install', 'upgrade', 'rollback', 'list', 'search'],
|
||||
),
|
||||
makeSkill(
|
||||
'prometheus-alerts',
|
||||
'Prometheus Alerts',
|
||||
'Query Prometheus metrics and manage alerting rules.',
|
||||
['PROMETHEUS_URL'],
|
||||
['query', 'alerts', 'rules', 'targets', 'status'],
|
||||
),
|
||||
makeSkill(
|
||||
'grafana-dash',
|
||||
'Grafana Dashboards',
|
||||
'Create and manage Grafana dashboards programmatically.',
|
||||
['GRAFANA_URL', 'GRAFANA_API_KEY'],
|
||||
['list', 'export', 'import', 'create', 'delete'],
|
||||
),
|
||||
makeSkill(
|
||||
'nginx-config',
|
||||
'Nginx Config',
|
||||
'Generate and validate Nginx configuration files.',
|
||||
['NGINX_CONF_DIR'],
|
||||
['generate', 'validate', 'reload', 'test', 'sites'],
|
||||
),
|
||||
makeSkill(
|
||||
'jenkins-jobs',
|
||||
'Jenkins Jobs',
|
||||
'Manage Jenkins jobs and pipelines.',
|
||||
['JENKINS_URL', 'JENKINS_TOKEN'],
|
||||
['list', 'build', 'status', 'logs', 'config'],
|
||||
),
|
||||
|
||||
// Productivity (8)
|
||||
makeSkill(
|
||||
'todoist-sync',
|
||||
'Todoist Sync',
|
||||
'Sync and manage Todoist tasks from the command line.',
|
||||
['TODOIST_API_TOKEN'],
|
||||
['list', 'add', 'complete', 'projects', 'labels'],
|
||||
),
|
||||
makeSkill(
|
||||
'notion-backup',
|
||||
'Notion Backup',
|
||||
'Export and backup Notion workspaces.',
|
||||
['NOTION_TOKEN'],
|
||||
['export', 'backup', 'restore', 'pages', 'databases'],
|
||||
),
|
||||
makeSkill(
|
||||
'gcal-manager',
|
||||
'Google Calendar Manager',
|
||||
'Manage Google Calendar events and schedules.',
|
||||
['GOOGLE_CREDENTIALS_FILE'],
|
||||
['events', 'create', 'delete', 'calendars', 'reminders'],
|
||||
),
|
||||
makeSkill(
|
||||
'time-tracker',
|
||||
'Time Tracker',
|
||||
'Track time spent on projects and tasks.',
|
||||
['TIMETRACK_DB'],
|
||||
['start', 'stop', 'status', 'report', 'projects'],
|
||||
),
|
||||
makeSkill(
|
||||
'email-digest',
|
||||
'Email Digest',
|
||||
'Generate email digests and summaries.',
|
||||
['IMAP_SERVER', 'IMAP_USER'],
|
||||
['fetch', 'digest', 'search', 'folders', 'unread'],
|
||||
),
|
||||
makeSkill(
|
||||
'habit-tracker',
|
||||
'Habit Tracker',
|
||||
'Track daily habits and streaks.',
|
||||
['HABITS_DB'],
|
||||
['log', 'streak', 'stats', 'habits', 'remind'],
|
||||
),
|
||||
makeSkill(
|
||||
'bookmark-sync',
|
||||
'Bookmark Sync',
|
||||
'Sync bookmarks across browsers and devices.',
|
||||
['BOOKMARKS_DIR'],
|
||||
['sync', 'export', 'import', 'search', 'tags'],
|
||||
),
|
||||
makeSkill(
|
||||
'notes-export',
|
||||
'Notes Export',
|
||||
'Export notes to various formats.',
|
||||
['NOTES_DIR'],
|
||||
['export', 'convert', 'search', 'list', 'tags'],
|
||||
),
|
||||
|
||||
// Media & Entertainment (6)
|
||||
makeSkill(
|
||||
'spotify-ctl',
|
||||
'Spotify Control',
|
||||
'Control Spotify playback from the terminal.',
|
||||
['SPOTIFY_CLIENT_ID', 'SPOTIFY_CLIENT_SECRET'],
|
||||
['play', 'pause', 'next', 'prev', 'search'],
|
||||
),
|
||||
makeSkill(
|
||||
'plex-manager',
|
||||
'Plex Manager',
|
||||
'Manage Plex media libraries and playback.',
|
||||
['PLEX_URL', 'PLEX_TOKEN'],
|
||||
['libraries', 'scan', 'search', 'play', 'sessions'],
|
||||
),
|
||||
makeSkill(
|
||||
'ytdl-wrapper',
|
||||
'YouTube Downloader',
|
||||
'Download videos from YouTube and other platforms.',
|
||||
['YTDL_OUTPUT_DIR'],
|
||||
['download', 'info', 'playlist', 'audio', 'formats'],
|
||||
),
|
||||
makeSkill(
|
||||
'podcast-dl',
|
||||
'Podcast Downloader',
|
||||
'Download and manage podcast episodes.',
|
||||
['PODCAST_DIR'],
|
||||
['subscribe', 'download', 'list', 'play', 'search'],
|
||||
),
|
||||
makeSkill(
|
||||
'audiobook-player',
|
||||
'Audiobook Player',
|
||||
'Manage and play audiobook collections.',
|
||||
['AUDIOBOOK_DIR'],
|
||||
['play', 'pause', 'bookmark', 'list', 'progress'],
|
||||
),
|
||||
makeSkill(
|
||||
'music-lib',
|
||||
'Music Library',
|
||||
'Organize and query local music libraries.',
|
||||
['MUSIC_DIR'],
|
||||
['scan', 'search', 'play', 'playlist', 'stats'],
|
||||
),
|
||||
|
||||
// Smart Home (8)
|
||||
makeSkill(
|
||||
'hass-control',
|
||||
'Home Assistant Control',
|
||||
'Control Home Assistant entities and automations.',
|
||||
['HASS_URL', 'HASS_TOKEN'],
|
||||
['entities', 'services', 'automations', 'scenes', 'history'],
|
||||
),
|
||||
makeSkill(
|
||||
'zigbee-mqtt',
|
||||
'Zigbee2MQTT',
|
||||
'Manage Zigbee devices via MQTT.',
|
||||
['MQTT_BROKER', 'ZIGBEE_TOPIC'],
|
||||
['devices', 'pair', 'remove', 'rename', 'groups'],
|
||||
),
|
||||
makeSkill(
|
||||
'tasmota-ctl',
|
||||
'Tasmota Control',
|
||||
'Control Tasmota-flashed devices.',
|
||||
['TASMOTA_HOSTS'],
|
||||
['status', 'power', 'config', 'update', 'backup'],
|
||||
),
|
||||
makeSkill(
|
||||
'esphome-mgr',
|
||||
'ESPHome Manager',
|
||||
'Manage ESPHome device configurations.',
|
||||
['ESPHOME_DIR'],
|
||||
['compile', 'upload', 'logs', 'dashboard', 'config'],
|
||||
),
|
||||
makeSkill(
|
||||
'mqtt-broker',
|
||||
'MQTT Broker',
|
||||
'Interact with MQTT brokers for IoT messaging.',
|
||||
['MQTT_BROKER', 'MQTT_USER'],
|
||||
['pub', 'sub', 'topics', 'clients', 'stats'],
|
||||
),
|
||||
makeSkill(
|
||||
'hue-lights',
|
||||
'Philips Hue',
|
||||
'Control Philips Hue lights and scenes.',
|
||||
['HUE_BRIDGE_IP', 'HUE_API_KEY'],
|
||||
['lights', 'scenes', 'groups', 'schedules', 'sensors'],
|
||||
),
|
||||
makeSkill(
|
||||
'smart-thermo',
|
||||
'Smart Thermostat',
|
||||
'Control smart thermostats and HVAC systems.',
|
||||
['THERMOSTAT_API_KEY'],
|
||||
['status', 'set', 'schedule', 'history', 'zones'],
|
||||
),
|
||||
makeSkill(
|
||||
'cam-viewer',
|
||||
'Camera Viewer',
|
||||
'View and manage security camera feeds.',
|
||||
['CAMERA_URLS'],
|
||||
['list', 'snapshot', 'stream', 'record', 'events'],
|
||||
),
|
||||
|
||||
// Finance (5)
|
||||
makeSkill(
|
||||
'budget-track',
|
||||
'Budget Tracker',
|
||||
'Track budgets and spending across categories.',
|
||||
['BUDGET_DB'],
|
||||
['summary', 'add', 'categories', 'report', 'goals'],
|
||||
),
|
||||
makeSkill(
|
||||
'crypto-watch',
|
||||
'Crypto Watcher',
|
||||
'Monitor cryptocurrency prices and portfolios.',
|
||||
['CRYPTO_API_KEY'],
|
||||
['prices', 'portfolio', 'alerts', 'history', 'convert'],
|
||||
),
|
||||
makeSkill(
|
||||
'stock-alerts',
|
||||
'Stock Alerts',
|
||||
'Set up stock price alerts and notifications.',
|
||||
['STOCK_API_KEY'],
|
||||
['quote', 'watch', 'alerts', 'portfolio', 'news'],
|
||||
),
|
||||
makeSkill(
|
||||
'expense-cat',
|
||||
'Expense Categorizer',
|
||||
'Automatically categorize expenses.',
|
||||
['EXPENSE_DB'],
|
||||
['import', 'categorize', 'report', 'rules', 'export'],
|
||||
),
|
||||
makeSkill(
|
||||
'invoice-gen',
|
||||
'Invoice Generator',
|
||||
'Generate and manage invoices.',
|
||||
['INVOICE_DIR', 'COMPANY_INFO'],
|
||||
['create', 'list', 'send', 'paid', 'overdue'],
|
||||
),
|
||||
|
||||
// Communication (5)
|
||||
makeSkill(
|
||||
'slack-bot',
|
||||
'Slack Bot',
|
||||
'Interact with Slack channels and messages.',
|
||||
['SLACK_TOKEN'],
|
||||
['send', 'channels', 'users', 'search', 'files'],
|
||||
),
|
||||
makeSkill(
|
||||
'discord-mgr',
|
||||
'Discord Manager',
|
||||
'Manage Discord servers and messages.',
|
||||
['DISCORD_TOKEN'],
|
||||
['send', 'servers', 'channels', 'members', 'roles'],
|
||||
),
|
||||
makeSkill(
|
||||
'telegram-bot',
|
||||
'Telegram Bot',
|
||||
'Send and receive Telegram messages.',
|
||||
['TELEGRAM_BOT_TOKEN'],
|
||||
['send', 'receive', 'chats', 'files', 'inline'],
|
||||
),
|
||||
makeSkill(
|
||||
'matrix-cli',
|
||||
'Matrix CLI',
|
||||
'Interact with Matrix chat rooms.',
|
||||
['MATRIX_HOMESERVER', 'MATRIX_TOKEN'],
|
||||
['send', 'rooms', 'join', 'leave', 'sync'],
|
||||
),
|
||||
makeSkill(
|
||||
'irc-bridge',
|
||||
'IRC Bridge',
|
||||
'Bridge IRC channels to other platforms.',
|
||||
['IRC_SERVER', 'IRC_NICK'],
|
||||
['connect', 'join', 'send', 'channels', 'users'],
|
||||
),
|
||||
|
||||
// Data & Analytics (5)
|
||||
makeSkill(
|
||||
'pg-queries',
|
||||
'PostgreSQL Queries',
|
||||
'Execute PostgreSQL queries and manage databases.',
|
||||
['DATABASE_URL'],
|
||||
['query', 'tables', 'schema', 'backup', 'restore'],
|
||||
),
|
||||
makeSkill(
|
||||
'clickhouse-ql',
|
||||
'ClickHouse Queries',
|
||||
'Run ClickHouse analytics queries.',
|
||||
['CLICKHOUSE_URL'],
|
||||
['query', 'tables', 'insert', 'system', 'optimize'],
|
||||
),
|
||||
makeSkill(
|
||||
'redis-cli',
|
||||
'Redis CLI',
|
||||
'Interact with Redis cache and data structures.',
|
||||
['REDIS_URL'],
|
||||
['get', 'set', 'keys', 'info', 'flush'],
|
||||
),
|
||||
makeSkill(
|
||||
'elastic-search',
|
||||
'Elasticsearch',
|
||||
'Search and manage Elasticsearch indices.',
|
||||
['ELASTICSEARCH_URL'],
|
||||
['search', 'index', 'mapping', 'cluster', 'aliases'],
|
||||
),
|
||||
makeSkill(
|
||||
'mongo-shell',
|
||||
'MongoDB Shell',
|
||||
'Query and manage MongoDB collections.',
|
||||
['MONGODB_URI'],
|
||||
['find', 'insert', 'update', 'delete', 'aggregate'],
|
||||
),
|
||||
|
||||
// Security (3)
|
||||
makeSkill(
|
||||
'vault-secrets',
|
||||
'Vault Secrets',
|
||||
'Manage secrets in HashiCorp Vault.',
|
||||
['VAULT_ADDR', 'VAULT_TOKEN'],
|
||||
['read', 'write', 'list', 'delete', 'seal'],
|
||||
),
|
||||
makeSkill(
|
||||
'gpg-keys',
|
||||
'GPG Keys',
|
||||
'Manage GPG keys and encryption.',
|
||||
['GNUPGHOME'],
|
||||
['list', 'generate', 'export', 'import', 'encrypt'],
|
||||
),
|
||||
makeSkill(
|
||||
'ssh-rotate',
|
||||
'SSH Key Rotator',
|
||||
'Rotate and manage SSH keys.',
|
||||
['SSH_KEY_DIR'],
|
||||
['generate', 'rotate', 'deploy', 'list', 'revoke'],
|
||||
),
|
||||
]
|
||||
|
||||
function injectMetadata(rawSkillMd: string, metadata: Record<string, unknown>) {
|
||||
const frontmatterEnd = rawSkillMd.indexOf('\n---', 3)
|
||||
if (frontmatterEnd === -1) return rawSkillMd
|
||||
return `${rawSkillMd.slice(0, frontmatterEnd)}\nmetadata: ${JSON.stringify(
|
||||
metadata,
|
||||
)}${rawSkillMd.slice(frontmatterEnd)}`
|
||||
}
|
||||
|
||||
function randomStats() {
|
||||
return {
|
||||
downloads: Math.floor(Math.random() * 5000),
|
||||
stars: Math.floor(Math.random() * 500),
|
||||
installsCurrent: Math.floor(Math.random() * 200),
|
||||
installsAllTime: Math.floor(Math.random() * 1000),
|
||||
}
|
||||
}
|
||||
|
||||
export const applyRandomStats = internalMutation({
|
||||
args: {
|
||||
skillId: v.id('skills'),
|
||||
stats: v.object({
|
||||
downloads: v.number(),
|
||||
stars: v.number(),
|
||||
installsCurrent: v.number(),
|
||||
installsAllTime: v.number(),
|
||||
}),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.patch(args.skillId, {
|
||||
statsDownloads: args.stats.downloads,
|
||||
statsStars: args.stats.stars,
|
||||
statsInstallsCurrent: args.stats.installsCurrent,
|
||||
statsInstallsAllTime: args.stats.installsAllTime,
|
||||
stats: {
|
||||
downloads: args.stats.downloads,
|
||||
stars: args.stats.stars,
|
||||
installsCurrent: args.stats.installsCurrent,
|
||||
installsAllTime: args.stats.installsAllTime,
|
||||
versions: 1,
|
||||
comments: 0,
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
export const seedExtraSkillsInternal = internalAction({
|
||||
args: {
|
||||
reset: v.optional(v.boolean()),
|
||||
},
|
||||
handler: async (ctx: ActionCtx, args) => {
|
||||
const results: Array<{ slug: string; ok: boolean; skipped?: boolean }> = []
|
||||
|
||||
for (const spec of EXTRA_SEED_SKILLS) {
|
||||
const skillMd = injectMetadata(spec.rawSkillMd, spec.metadata)
|
||||
const frontmatter = parseFrontmatter(skillMd)
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
const storageId = await ctx.storage.store(new Blob([skillMd], { type: 'text/markdown' }))
|
||||
|
||||
const result = (await ctx.runMutation(internal.devSeed.seedSkillMutation, {
|
||||
reset: args.reset,
|
||||
storageId,
|
||||
metadata: spec.metadata,
|
||||
frontmatter,
|
||||
moltbot,
|
||||
skillMd,
|
||||
slug: spec.slug,
|
||||
displayName: spec.displayName,
|
||||
summary: spec.summary,
|
||||
version: spec.version,
|
||||
})) as { ok: boolean; skipped?: boolean; skillId?: string }
|
||||
|
||||
// Apply random stats after creation (only if not skipped)
|
||||
if (result.skillId && !result.skipped) {
|
||||
const stats = randomStats()
|
||||
await ctx.runMutation(internal.devSeedExtra.applyRandomStats, {
|
||||
skillId: result.skillId as Id<'skills'>,
|
||||
stats,
|
||||
})
|
||||
}
|
||||
|
||||
results.push({ slug: spec.slug, ok: result.ok, skipped: result.skipped })
|
||||
}
|
||||
|
||||
const created = results.filter((r) => !r.skipped).length
|
||||
const skipped = results.filter((r) => r.skipped).length
|
||||
|
||||
return { ok: true, total: results.length, created, skipped }
|
||||
},
|
||||
})
|
||||
+4
-7
@@ -2,7 +2,7 @@ import { v } from 'convex/values'
|
||||
import { zipSync } from 'fflate'
|
||||
import { api } from './_generated/api'
|
||||
import { httpAction, mutation } from './_generated/server'
|
||||
import { applySkillStatDeltas, bumpDailySkillStats } from './lib/skillStats'
|
||||
import { insertStatEvent } from './skillStatEvents'
|
||||
|
||||
export const downloadZip = httpAction(async (ctx, request) => {
|
||||
const url = new URL(request.url)
|
||||
@@ -70,12 +70,9 @@ export const increment = mutation({
|
||||
handler: async (ctx, args) => {
|
||||
const skill = await ctx.db.get(args.skillId)
|
||||
if (!skill) return
|
||||
const now = Date.now()
|
||||
const patch = applySkillStatDeltas(skill, { downloads: 1 })
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: now,
|
||||
await insertStatEvent(ctx, {
|
||||
skillId: skill._id,
|
||||
kind: 'download',
|
||||
})
|
||||
await bumpDailySkillStats(ctx, { skillId: skill._id, now, downloads: 1 })
|
||||
},
|
||||
})
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { ApiRoutes, LegacyApiRoutes } from 'clawdhub-schema'
|
||||
import { httpRouter } from 'convex/server'
|
||||
import { ApiRoutes, LegacyApiRoutes } from 'molthub-schema'
|
||||
import { auth } from './auth'
|
||||
import { downloadZip } from './downloads'
|
||||
import {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import {
|
||||
CliSkillDeleteRequestSchema,
|
||||
CliTelemetrySyncRequestSchema,
|
||||
parseArk,
|
||||
} from 'clawdhub-schema'
|
||||
} from 'molthub-schema'
|
||||
import { api, internal } from './_generated/api'
|
||||
import type { Id } from './_generated/dataModel'
|
||||
import type { ActionCtx } from './_generated/server'
|
||||
|
||||
+25
-2
@@ -1,4 +1,4 @@
|
||||
import { CliPublishRequestSchema, parseArk } from 'clawdhub-schema'
|
||||
import { CliPublishRequestSchema, parseArk } from 'molthub-schema'
|
||||
import { api, internal } from './_generated/api'
|
||||
import type { Doc, Id } from './_generated/dataModel'
|
||||
import type { ActionCtx } from './_generated/server'
|
||||
@@ -59,7 +59,7 @@ type GetBySlugResult = {
|
||||
updatedAt: number
|
||||
} | null
|
||||
latestVersion: Doc<'skillVersions'> | null
|
||||
owner: { handle?: string; displayName?: string; image?: string } | null
|
||||
owner: { _id: Id<'users'>; handle?: string; displayName?: string; image?: string } | null
|
||||
} | null
|
||||
|
||||
type ListVersionsResult = {
|
||||
@@ -267,6 +267,7 @@ async function skillsGetRouterV1Handler(ctx: ActionCtx, request: Request) {
|
||||
owner: result.owner
|
||||
? {
|
||||
handle: result.owner.handle ?? null,
|
||||
userId: result.owner._id,
|
||||
displayName: result.owner.displayName ?? null,
|
||||
image: result.owner.image ?? null,
|
||||
}
|
||||
@@ -374,6 +375,10 @@ async function skillsGetRouterV1Handler(ctx: ActionCtx, request: Request) {
|
||||
if (!blob) return text('File missing in storage', 410, rate.headers)
|
||||
const textContent = await blob.text()
|
||||
|
||||
const isSvg =
|
||||
file.contentType?.toLowerCase().includes('svg') ||
|
||||
file.path.toLowerCase().endsWith('.svg')
|
||||
|
||||
const headers = mergeHeaders(rate.headers, {
|
||||
'Content-Type': file.contentType
|
||||
? `${file.contentType}; charset=utf-8`
|
||||
@@ -382,6 +387,13 @@ async function skillsGetRouterV1Handler(ctx: ActionCtx, request: Request) {
|
||||
ETag: file.sha256,
|
||||
'X-Content-SHA256': file.sha256,
|
||||
'X-Content-Size': String(file.size),
|
||||
'X-Content-Type-Options': 'nosniff',
|
||||
'X-Frame-Options': 'DENY',
|
||||
// For any text response that a browser might try to render, lock it down.
|
||||
// In particular, this prevents SVG <foreignObject> script execution from
|
||||
// reading localStorage tokens on this origin.
|
||||
'Content-Security-Policy': "default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
|
||||
...(isSvg ? { 'Content-Disposition': 'attachment' } : {}),
|
||||
})
|
||||
return new Response(textContent, { status: 200, headers })
|
||||
}
|
||||
@@ -983,6 +995,10 @@ async function soulsGetRouterV1Handler(ctx: ActionCtx, request: Request) {
|
||||
|
||||
void ctx.runMutation(api.soulDownloads.increment, { soulId: soulResult.soul._id })
|
||||
|
||||
const isSvg =
|
||||
file.contentType?.toLowerCase().includes('svg') ||
|
||||
file.path.toLowerCase().endsWith('.svg')
|
||||
|
||||
const headers = mergeHeaders(rate.headers, {
|
||||
'Content-Type': file.contentType
|
||||
? `${file.contentType}; charset=utf-8`
|
||||
@@ -991,6 +1007,13 @@ async function soulsGetRouterV1Handler(ctx: ActionCtx, request: Request) {
|
||||
ETag: file.sha256,
|
||||
'X-Content-SHA256': file.sha256,
|
||||
'X-Content-Size': String(file.size),
|
||||
'X-Content-Type-Options': 'nosniff',
|
||||
'X-Frame-Options': 'DENY',
|
||||
// For any text response that a browser might try to render, lock it down.
|
||||
// In particular, this prevents SVG <foreignObject> script execution from
|
||||
// reading localStorage tokens on this origin.
|
||||
'Content-Security-Policy': "default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
|
||||
...(isSvg ? { 'Content-Disposition': 'attachment' } : {}),
|
||||
})
|
||||
return new Response(textContent, { status: 200, headers })
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,5 +1,5 @@
|
||||
import { getAuthUserId } from '@convex-dev/auth/server'
|
||||
import { api } from '../_generated/api'
|
||||
import { internal } from '../_generated/api'
|
||||
import type { Doc } from '../_generated/dataModel'
|
||||
import type { ActionCtx, MutationCtx, QueryCtx } from '../_generated/server'
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function requireUser(ctx: MutationCtx | QueryCtx) {
|
||||
export async function requireUserFromAction(ctx: ActionCtx) {
|
||||
const userId = await getAuthUserId(ctx)
|
||||
if (!userId) throw new Error('Unauthorized')
|
||||
const user = await ctx.runQuery(api.users.getById, { userId })
|
||||
const user = await ctx.runQuery(internal.users.getByIdInternal, { userId })
|
||||
if (!user || user.deletedAt) throw new Error('User not found')
|
||||
return { userId, user: user as Doc<'users'> }
|
||||
}
|
||||
@@ -26,3 +26,11 @@ export function assertRole(user: Doc<'users'>, allowed: Role[]) {
|
||||
throw new Error('Forbidden')
|
||||
}
|
||||
}
|
||||
|
||||
export function assertAdmin(user: Doc<'users'>) {
|
||||
assertRole(user, ['admin'])
|
||||
}
|
||||
|
||||
export function assertModerator(user: Doc<'users'>) {
|
||||
assertRole(user, ['admin', 'moderator'])
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { Doc, Id } from '../_generated/dataModel'
|
||||
import type { QueryCtx } from '../_generated/server'
|
||||
|
||||
type BadgeKind = Doc<'skillBadges'>['kind']
|
||||
|
||||
export type SkillBadgeMap = Partial<Record<BadgeKind, { byUserId: Id<'users'>; at: number }>>
|
||||
|
||||
export type SkillBadgeSource = { badges?: SkillBadgeMap | null }
|
||||
|
||||
type BadgeCtx = Pick<QueryCtx, 'db'>
|
||||
|
||||
export function isSkillHighlighted(skill: SkillBadgeSource) {
|
||||
return Boolean(skill.badges?.highlighted)
|
||||
}
|
||||
|
||||
export function isSkillOfficial(skill: SkillBadgeSource) {
|
||||
return Boolean(skill.badges?.official)
|
||||
}
|
||||
|
||||
export function isSkillDeprecated(skill: SkillBadgeSource) {
|
||||
return Boolean(skill.badges?.deprecated)
|
||||
}
|
||||
|
||||
export function buildBadgeMap(records: Doc<'skillBadges'>[]): SkillBadgeMap {
|
||||
return records.reduce<SkillBadgeMap>((acc, record) => {
|
||||
acc[record.kind] = { byUserId: record.byUserId, at: record.at }
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
|
||||
export async function getSkillBadgeMap(
|
||||
ctx: BadgeCtx,
|
||||
skillId: Id<'skills'>,
|
||||
): Promise<SkillBadgeMap> {
|
||||
const records = await ctx.db
|
||||
.query('skillBadges')
|
||||
.withIndex('by_skill', (q) => q.eq('skillId', skillId))
|
||||
.collect()
|
||||
return buildBadgeMap(records)
|
||||
}
|
||||
|
||||
export async function getSkillBadgeMaps(
|
||||
ctx: BadgeCtx,
|
||||
skillIds: Array<Id<'skills'>>,
|
||||
): Promise<Map<Id<'skills'>, SkillBadgeMap>> {
|
||||
const entries = await Promise.all(
|
||||
skillIds.map(async (skillId) => [skillId, await getSkillBadgeMap(ctx, skillId)] as const),
|
||||
)
|
||||
return new Map(entries)
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import type { Id } from '../_generated/dataModel'
|
||||
import type { ActionCtx } from '../_generated/server'
|
||||
|
||||
const GITHUB_API = 'https://api.github.com'
|
||||
const DEFAULT_REPO = 'clawdbot/skills'
|
||||
const DEFAULT_REPO = 'moltbot/skills'
|
||||
const DEFAULT_ROOT = 'skills'
|
||||
const META_FILENAME = '_meta.json'
|
||||
const USER_AGENT = 'clawdhub/skills-backup'
|
||||
const USER_AGENT = 'molthub/skills-backup'
|
||||
|
||||
type BackupFile = {
|
||||
path: string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TEXT_FILE_EXTENSION_SET } from 'clawdhub-schema'
|
||||
import { zipSync } from 'fflate'
|
||||
import { TEXT_FILE_EXTENSION_SET } from 'molthub-schema'
|
||||
import semver from 'semver'
|
||||
import { parseFrontmatter } from './skills'
|
||||
|
||||
@@ -118,7 +118,7 @@ async function resolveRefCommit(parsed: GitHubImportUrl, ref: string, fetcher: t
|
||||
const response = await fetcher(apiUrl, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.github+json',
|
||||
'User-Agent': 'clawdhub/github-import',
|
||||
'User-Agent': 'molthub/github-import',
|
||||
},
|
||||
})
|
||||
if (!response.ok) throw new Error('GitHub ref not found')
|
||||
@@ -156,7 +156,7 @@ export async function fetchGitHubZipBytes(
|
||||
const maxZipBytes = limits?.maxZipBytes ?? 25 * 1024 * 1024
|
||||
const url = `https://${CODELOAD_HOST}/${resolved.owner}/${resolved.repo}/zip/${resolved.commit}`
|
||||
const response = await fetcher(url, {
|
||||
headers: { 'User-Agent': 'clawdhub/github-import' },
|
||||
headers: { 'User-Agent': 'molthub/github-import' },
|
||||
})
|
||||
if (!response.ok) throw new Error('GitHub archive download failed')
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import type { Id } from '../_generated/dataModel'
|
||||
import type { ActionCtx } from '../_generated/server'
|
||||
|
||||
const GITHUB_API = 'https://api.github.com'
|
||||
const DEFAULT_REPO = 'clawdbot/souls'
|
||||
const DEFAULT_REPO = 'moltbot/souls'
|
||||
const DEFAULT_ROOT = 'souls'
|
||||
const META_FILENAME = '_meta.json'
|
||||
const USER_AGENT = 'clawdhub/souls-backup'
|
||||
const USER_AGENT = 'molthub/souls-backup'
|
||||
|
||||
type BackupFile = {
|
||||
path: string
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { Doc } from '../_generated/dataModel'
|
||||
|
||||
const FLAG_RULES: Array<{ flag: string; pattern: RegExp }> = [
|
||||
// Known-bad / known-suspicious identifiers.
|
||||
// NOTE: keep these narrowly scoped; use staff review to confirm removals.
|
||||
{ flag: 'blocked.malware', pattern: /(keepcold131\/ClawdAuthenticatorTool|ClawdAuthenticatorTool)/i },
|
||||
|
||||
{ flag: 'suspicious.keyword', pattern: /(malware|stealer|phish|phishing|keylogger)/i },
|
||||
{ flag: 'suspicious.secrets', pattern: /(api[-_ ]?key|token|password|private key|secret)/i },
|
||||
{ flag: 'suspicious.crypto', pattern: /(wallet|seed phrase|mnemonic|crypto)/i },
|
||||
{ flag: 'suspicious.webhook', pattern: /(discord\.gg|webhook|hooks\.slack)/i },
|
||||
{ flag: 'suspicious.script', pattern: /(curl[^\n]+\|\s*(sh|bash))/i },
|
||||
{ flag: 'suspicious.url_shortener', pattern: /(bit\.ly|tinyurl\.com|t\.co|goo\.gl|is\.gd)/i },
|
||||
]
|
||||
|
||||
export function deriveModerationFlags({
|
||||
skill,
|
||||
parsed,
|
||||
files,
|
||||
}: {
|
||||
skill: Pick<Doc<'skills'>, 'slug' | 'displayName' | 'summary'>
|
||||
parsed: Doc<'skillVersions'>['parsed']
|
||||
files: Doc<'skillVersions'>['files']
|
||||
}) {
|
||||
const text = [
|
||||
skill.slug,
|
||||
skill.displayName,
|
||||
skill.summary ?? '',
|
||||
JSON.stringify(parsed?.frontmatter ?? {}),
|
||||
JSON.stringify(parsed?.metadata ?? {}),
|
||||
JSON.stringify((parsed as { moltbot?: unknown } | undefined)?.moltbot ?? {}),
|
||||
...files.map((file) => file.path),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join('\n')
|
||||
|
||||
const flags = new Set<string>()
|
||||
|
||||
for (const rule of FLAG_RULES) {
|
||||
if (rule.pattern.test(text)) {
|
||||
flags.add(rule.flag)
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(flags)
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import type { Doc } from '../_generated/dataModel'
|
||||
|
||||
export type PublicUser = Pick<
|
||||
Doc<'users'>,
|
||||
'_id' | '_creationTime' | 'handle' | 'name' | 'displayName' | 'image' | 'bio'
|
||||
>
|
||||
|
||||
export type PublicSkill = Pick<
|
||||
Doc<'skills'>,
|
||||
| '_id'
|
||||
| '_creationTime'
|
||||
| 'slug'
|
||||
| 'displayName'
|
||||
| 'summary'
|
||||
| 'ownerUserId'
|
||||
| 'canonicalSkillId'
|
||||
| 'forkOf'
|
||||
| 'latestVersionId'
|
||||
| 'tags'
|
||||
| 'badges'
|
||||
| 'stats'
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
>
|
||||
|
||||
export type PublicSoul = Pick<
|
||||
Doc<'souls'>,
|
||||
| '_id'
|
||||
| '_creationTime'
|
||||
| 'slug'
|
||||
| 'displayName'
|
||||
| 'summary'
|
||||
| 'ownerUserId'
|
||||
| 'latestVersionId'
|
||||
| 'tags'
|
||||
| 'stats'
|
||||
| 'createdAt'
|
||||
| 'updatedAt'
|
||||
>
|
||||
|
||||
export function toPublicUser(user: Doc<'users'> | null | undefined): PublicUser | null {
|
||||
if (!user || user.deletedAt) return null
|
||||
return {
|
||||
_id: user._id,
|
||||
_creationTime: user._creationTime,
|
||||
handle: user.handle,
|
||||
name: user.name,
|
||||
displayName: user.displayName,
|
||||
image: user.image,
|
||||
bio: user.bio,
|
||||
}
|
||||
}
|
||||
|
||||
export function toPublicSkill(skill: Doc<'skills'> | null | undefined): PublicSkill | null {
|
||||
if (!skill || skill.softDeletedAt) return null
|
||||
if (skill.moderationStatus && skill.moderationStatus !== 'active') return null
|
||||
if (skill.moderationFlags?.includes('blocked.malware')) return null
|
||||
return {
|
||||
_id: skill._id,
|
||||
_creationTime: skill._creationTime,
|
||||
slug: skill.slug,
|
||||
displayName: skill.displayName,
|
||||
summary: skill.summary,
|
||||
ownerUserId: skill.ownerUserId,
|
||||
canonicalSkillId: skill.canonicalSkillId,
|
||||
forkOf: skill.forkOf,
|
||||
latestVersionId: skill.latestVersionId,
|
||||
tags: skill.tags,
|
||||
badges: skill.badges,
|
||||
stats: skill.stats,
|
||||
createdAt: skill.createdAt,
|
||||
updatedAt: skill.updatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
export function toPublicSoul(soul: Doc<'souls'> | null | undefined): PublicSoul | null {
|
||||
if (!soul || soul.softDeletedAt) return null
|
||||
if (soul.moderationStatus && soul.moderationStatus !== 'active') return null
|
||||
if (soul.moderationFlags?.includes('blocked.malware')) return null
|
||||
return {
|
||||
_id: soul._id,
|
||||
_creationTime: soul._creationTime,
|
||||
slug: soul.slug,
|
||||
displayName: soul.displayName,
|
||||
summary: soul.summary,
|
||||
ownerUserId: soul.ownerUserId,
|
||||
latestVersionId: soul.latestVersionId,
|
||||
tags: soul.tags,
|
||||
stats: soul.stats,
|
||||
createdAt: soul.createdAt,
|
||||
updatedAt: soul.updatedAt,
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@ import {
|
||||
getFrontmatterMetadata,
|
||||
getFrontmatterValue,
|
||||
type ParsedSkillFrontmatter,
|
||||
parseClawdisMetadata,
|
||||
parseFrontmatter,
|
||||
parseMoltbotMetadata,
|
||||
} from './skills'
|
||||
|
||||
export type ParsedSkillData = {
|
||||
frontmatter: ParsedSkillFrontmatter
|
||||
metadata?: unknown
|
||||
clawdis?: unknown
|
||||
moltbot?: unknown
|
||||
}
|
||||
|
||||
export type SkillSummaryBackfillPatch = {
|
||||
@@ -25,8 +25,8 @@ export function buildSkillSummaryBackfillPatch(args: {
|
||||
const frontmatter = parseFrontmatter(args.readmeText)
|
||||
const summary = getFrontmatterValue(frontmatter, 'description') ?? undefined
|
||||
const metadata = getFrontmatterMetadata(frontmatter)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
const parsed: ParsedSkillData = { frontmatter, metadata, clawdis }
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
const parsed: ParsedSkillData = { frontmatter, metadata, moltbot }
|
||||
|
||||
const patch: SkillSummaryBackfillPatch = {}
|
||||
if (summary && summary !== args.currentSummary) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { __test } from './skillPublish'
|
||||
describe('skillPublish', () => {
|
||||
it('merges github source into metadata', () => {
|
||||
const merged = __test.mergeSourceIntoMetadata(
|
||||
{ clawdis: { emoji: 'x' } },
|
||||
{ moltbot: { emoji: 'x' } },
|
||||
{
|
||||
kind: 'github',
|
||||
url: 'https://github.com/a/b',
|
||||
@@ -15,7 +15,7 @@ describe('skillPublish', () => {
|
||||
importedAt: 123,
|
||||
},
|
||||
)
|
||||
expect((merged as Record<string, unknown>).clawdis).toEqual({ emoji: 'x' })
|
||||
expect((merged as Record<string, unknown>).moltbot).toEqual({ emoji: 'x' })
|
||||
const source = (merged as Record<string, unknown>).source
|
||||
expect(source).toEqual(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -3,15 +3,17 @@ import semver from 'semver'
|
||||
import { api, internal } from '../_generated/api'
|
||||
import type { Doc, Id } from '../_generated/dataModel'
|
||||
import type { ActionCtx, MutationCtx } from '../_generated/server'
|
||||
import { getSkillBadgeMap, isSkillHighlighted } from './badges'
|
||||
import { generateChangelogForPublish } from './changelog'
|
||||
import { generateEmbedding } from './embeddings'
|
||||
import type { PublicUser } from './public'
|
||||
import {
|
||||
buildEmbeddingText,
|
||||
getFrontmatterMetadata,
|
||||
hashSkillFiles,
|
||||
isTextFile,
|
||||
parseClawdisMetadata,
|
||||
parseFrontmatter,
|
||||
parseMoltbotMetadata,
|
||||
sanitizePath,
|
||||
} from './skills'
|
||||
import type { WebhookSkillPayload } from './webhooks'
|
||||
@@ -95,7 +97,7 @@ export async function publishVersionForUser(
|
||||
|
||||
const readmeText = await fetchText(ctx, readmeFile.storageId)
|
||||
const frontmatter = parseFrontmatter(readmeText)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
const metadata = mergeSourceIntoMetadata(getFrontmatterMetadata(frontmatter), args.source)
|
||||
|
||||
const otherFiles = [] as Array<{ path: string; content: string }>
|
||||
@@ -159,12 +161,14 @@ export async function publishVersionForUser(
|
||||
parsed: {
|
||||
frontmatter,
|
||||
metadata,
|
||||
clawdis,
|
||||
moltbot,
|
||||
},
|
||||
embedding,
|
||||
})) as PublishResult
|
||||
|
||||
const owner = (await ctx.runQuery(api.users.getById, { userId })) as Doc<'users'> | null
|
||||
const owner = (await ctx.runQuery(internal.users.getByIdInternal, {
|
||||
userId,
|
||||
})) as Doc<'users'> | null
|
||||
const ownerHandle = owner?.handle ?? owner?.displayName ?? owner?.name ?? 'unknown'
|
||||
|
||||
void ctx.scheduler
|
||||
@@ -216,13 +220,14 @@ export async function queueHighlightedWebhook(ctx: MutationCtx, skillId: Id<'ski
|
||||
const owner = await ctx.db.get(skill.ownerUserId)
|
||||
const latestVersion = skill.latestVersionId ? await ctx.db.get(skill.latestVersionId) : null
|
||||
|
||||
const badges = await getSkillBadgeMap(ctx, skillId)
|
||||
const payload: WebhookSkillPayload = {
|
||||
slug: skill.slug,
|
||||
displayName: skill.displayName,
|
||||
summary: skill.summary ?? undefined,
|
||||
version: latestVersion?.version ?? undefined,
|
||||
ownerHandle: owner?.handle ?? owner?.name ?? undefined,
|
||||
batch: skill.batch ?? undefined,
|
||||
highlighted: isSkillHighlighted({ badges }),
|
||||
tags: Object.keys(skill.tags ?? {}),
|
||||
}
|
||||
|
||||
@@ -259,7 +264,7 @@ async function schedulePublishWebhook(
|
||||
) {
|
||||
const result = (await ctx.runQuery(api.skills.getBySlug, {
|
||||
slug: params.slug,
|
||||
})) as { skill: Doc<'skills'>; owner: Doc<'users'> | null } | null
|
||||
})) as { skill: Doc<'skills'>; owner: PublicUser | null } | null
|
||||
if (!result?.skill) return
|
||||
|
||||
const payload: WebhookSkillPayload = {
|
||||
@@ -268,7 +273,7 @@ async function schedulePublishWebhook(
|
||||
summary: result.skill.summary ?? undefined,
|
||||
version: params.version,
|
||||
ownerHandle: result.owner?.handle ?? result.owner?.name ?? undefined,
|
||||
batch: result.skill.batch ?? undefined,
|
||||
highlighted: isSkillHighlighted(result.skill),
|
||||
tags: Object.keys(result.skill.tags ?? {}),
|
||||
}
|
||||
|
||||
|
||||
+43
-43
@@ -5,8 +5,8 @@ import {
|
||||
getFrontmatterValue,
|
||||
hashSkillFiles,
|
||||
isTextFile,
|
||||
parseClawdisMetadata,
|
||||
parseFrontmatter,
|
||||
parseMoltbotMetadata,
|
||||
sanitizePath,
|
||||
} from './skills'
|
||||
|
||||
@@ -51,89 +51,89 @@ describe('skills utils', () => {
|
||||
expect(getFrontmatterValue(frontmatter, 'count')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('parses clawdis metadata', () => {
|
||||
it('parses moltbot metadata', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: {"clawdis":{"requires":{"bins":["rg"]},"emoji":"🦞"}}\n---\nBody`,
|
||||
`---\nmetadata: {"moltbot":{"requires":{"bins":["rg"]},"emoji":"🦞"}}\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.emoji).toBe('🦞')
|
||||
expect(clawdis?.requires?.bins).toEqual(['rg'])
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.emoji).toBe('🦞')
|
||||
expect(moltbot?.requires?.bins).toEqual(['rg'])
|
||||
})
|
||||
|
||||
it('ignores invalid clawdis metadata', () => {
|
||||
it('ignores invalid moltbot metadata', () => {
|
||||
const frontmatter = parseFrontmatter(`---\nmetadata: not-json\n---\nBody`)
|
||||
expect(parseClawdisMetadata(frontmatter)).toBeUndefined()
|
||||
expect(parseMoltbotMetadata(frontmatter)).toBeUndefined()
|
||||
})
|
||||
|
||||
it('accepts metadata as YAML object (no JSON string)', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata:\n clawdis:\n emoji: "🦞"\n requires:\n bins:\n - rg\n---\nBody`,
|
||||
`---\nmetadata:\n moltbot:\n emoji: "🦞"\n requires:\n bins:\n - rg\n---\nBody`,
|
||||
)
|
||||
expect(getFrontmatterMetadata(frontmatter)).toEqual({
|
||||
clawdis: { emoji: '🦞', requires: { bins: ['rg'] } },
|
||||
moltbot: { emoji: '🦞', requires: { bins: ['rg'] } },
|
||||
})
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.emoji).toBe('🦞')
|
||||
expect(clawdis?.requires?.bins).toEqual(['rg'])
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.emoji).toBe('🦞')
|
||||
expect(moltbot?.requires?.bins).toEqual(['rg'])
|
||||
})
|
||||
|
||||
it('accepts clawdis as top-level YAML key', () => {
|
||||
it('accepts moltbot as top-level YAML key', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nclawdis:\n emoji: "🦞"\n requires:\n anyBins: [rg, fd]\n---\nBody`,
|
||||
`---\nmoltbot:\n emoji: "🦞"\n requires:\n anyBins: [rg, fd]\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.emoji).toBe('🦞')
|
||||
expect(clawdis?.requires?.anyBins).toEqual(['rg', 'fd'])
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.emoji).toBe('🦞')
|
||||
expect(moltbot?.requires?.anyBins).toEqual(['rg', 'fd'])
|
||||
})
|
||||
|
||||
it('accepts legacy metadata JSON string (quoted)', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: '{"clawdis":{"emoji":"🦞","requires":{"bins":["rg"]}}}'\n---\nBody`,
|
||||
`---\nmetadata: '{"moltbot":{"emoji":"🦞","requires":{"bins":["rg"]}}}'\n---\nBody`,
|
||||
)
|
||||
const metadata = getFrontmatterMetadata(frontmatter)
|
||||
expect(metadata).toEqual({ clawdis: { emoji: '🦞', requires: { bins: ['rg'] } } })
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.emoji).toBe('🦞')
|
||||
expect(clawdis?.requires?.bins).toEqual(['rg'])
|
||||
expect(metadata).toEqual({ moltbot: { emoji: '🦞', requires: { bins: ['rg'] } } })
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.emoji).toBe('🦞')
|
||||
expect(moltbot?.requires?.bins).toEqual(['rg'])
|
||||
})
|
||||
|
||||
it('parses clawdis install specs and os', () => {
|
||||
it('parses moltbot install specs and os', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: {"clawdis":{"install":[{"kind":"brew","formula":"rg"},{"kind":"nope"},{"kind":"node","package":"x"}],"os":"macos,linux","requires":{"anyBins":["rg","fd"]}}}\n---\nBody`,
|
||||
`---\nmetadata: {"moltbot":{"install":[{"kind":"brew","formula":"rg"},{"kind":"nope"},{"kind":"node","package":"x"}],"os":"macos,linux","requires":{"anyBins":["rg","fd"]}}}\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.install?.map((entry) => entry.kind)).toEqual(['brew', 'node'])
|
||||
expect(clawdis?.os).toEqual(['macos', 'linux'])
|
||||
expect(clawdis?.requires?.anyBins).toEqual(['rg', 'fd'])
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.install?.map((entry) => entry.kind)).toEqual(['brew', 'node'])
|
||||
expect(moltbot?.os).toEqual(['macos', 'linux'])
|
||||
expect(moltbot?.requires?.anyBins).toEqual(['rg', 'fd'])
|
||||
})
|
||||
|
||||
it('parses clawdbot metadata with nix plugin pointer', () => {
|
||||
it('parses moltbot metadata with nix plugin pointer', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: {"clawdbot":{"nix":{"plugin":"github:clawdbot/nix-steipete-tools?dir=tools/peekaboo","systems":["aarch64-darwin"]}}}\n---\nBody`,
|
||||
`---\nmetadata: {"moltbot":{"nix":{"plugin":"github:moltbot/nix-steipete-tools?dir=tools/peekaboo","systems":["aarch64-darwin"]}}}\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.nix?.plugin).toBe('github:clawdbot/nix-steipete-tools?dir=tools/peekaboo')
|
||||
expect(clawdis?.nix?.systems).toEqual(['aarch64-darwin'])
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.nix?.plugin).toBe('github:moltbot/nix-steipete-tools?dir=tools/peekaboo')
|
||||
expect(moltbot?.nix?.systems).toEqual(['aarch64-darwin'])
|
||||
})
|
||||
|
||||
it('parses clawdbot config requirements with example', () => {
|
||||
it('parses moltbot config requirements with example', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: {"clawdbot":{"config":{"requiredEnv":["PADEL_AUTH_FILE"],"stateDirs":[".config/padel"],"example":"config = { env = { PADEL_AUTH_FILE = \\"/run/agenix/padel-auth\\"; }; };"}}}\n---\nBody`,
|
||||
`---\nmetadata: {"moltbot":{"config":{"requiredEnv":["PADEL_AUTH_FILE"],"stateDirs":[".config/padel"],"example":"config = { env = { PADEL_AUTH_FILE = \\"/run/agenix/padel-auth\\"; }; };"}}}\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.config?.requiredEnv).toEqual(['PADEL_AUTH_FILE'])
|
||||
expect(clawdis?.config?.stateDirs).toEqual(['.config/padel'])
|
||||
expect(clawdis?.config?.example).toBe(
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.config?.requiredEnv).toEqual(['PADEL_AUTH_FILE'])
|
||||
expect(moltbot?.config?.stateDirs).toEqual(['.config/padel'])
|
||||
expect(moltbot?.config?.example).toBe(
|
||||
'config = { env = { PADEL_AUTH_FILE = "/run/agenix/padel-auth"; }; };',
|
||||
)
|
||||
})
|
||||
|
||||
it('parses cli help output', () => {
|
||||
const frontmatter = parseFrontmatter(
|
||||
`---\nmetadata: {"clawdbot":{"cliHelp":"padel --help\\nUsage: padel [command]\\n"}}\n---\nBody`,
|
||||
`---\nmetadata: {"moltbot":{"cliHelp":"padel --help\\nUsage: padel [command]\\n"}}\n---\nBody`,
|
||||
)
|
||||
const clawdis = parseClawdisMetadata(frontmatter)
|
||||
expect(clawdis?.cliHelp).toBe('padel --help\nUsage: padel [command]')
|
||||
const moltbot = parseMoltbotMetadata(frontmatter)
|
||||
expect(moltbot?.cliHelp).toBe('padel --help\nUsage: padel [command]')
|
||||
})
|
||||
|
||||
it('sanitizes file paths', () => {
|
||||
|
||||
+29
-32
@@ -1,17 +1,17 @@
|
||||
import {
|
||||
type ClawdbotConfigSpec,
|
||||
type ClawdisSkillMetadata,
|
||||
ClawdisSkillMetadataSchema,
|
||||
isTextContentType,
|
||||
type MoltbotConfigSpec,
|
||||
type MoltbotSkillMetadata,
|
||||
MoltbotSkillMetadataSchema,
|
||||
type NixPluginSpec,
|
||||
parseArk,
|
||||
type SkillInstallSpec,
|
||||
TEXT_FILE_EXTENSION_SET,
|
||||
} from 'clawdhub-schema'
|
||||
} from 'molthub-schema'
|
||||
import { parse as parseYaml } from 'yaml'
|
||||
|
||||
export type ParsedSkillFrontmatter = Record<string, unknown>
|
||||
export type { ClawdisSkillMetadata, SkillInstallSpec }
|
||||
export type { MoltbotSkillMetadata, SkillInstallSpec }
|
||||
|
||||
const FRONTMATTER_START = '---'
|
||||
const DEFAULT_EMBEDDING_MAX_CHARS = 12_000
|
||||
@@ -59,42 +59,39 @@ export function getFrontmatterMetadata(frontmatter: ParsedSkillFrontmatter) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function parseClawdisMetadata(frontmatter: ParsedSkillFrontmatter) {
|
||||
export function parseMoltbotMetadata(frontmatter: ParsedSkillFrontmatter) {
|
||||
const metadata = getFrontmatterMetadata(frontmatter)
|
||||
const metadataRecord =
|
||||
metadata && typeof metadata === 'object' && !Array.isArray(metadata)
|
||||
? (metadata as Record<string, unknown>)
|
||||
: undefined
|
||||
const clawdbotMeta = metadataRecord?.clawdbot
|
||||
const clawdisMeta = metadataRecord?.clawdis
|
||||
const moltbotMeta = metadataRecord?.moltbot
|
||||
const metadataSource =
|
||||
clawdbotMeta && typeof clawdbotMeta === 'object' && !Array.isArray(clawdbotMeta)
|
||||
? (clawdbotMeta as Record<string, unknown>)
|
||||
: clawdisMeta && typeof clawdisMeta === 'object' && !Array.isArray(clawdisMeta)
|
||||
? (clawdisMeta as Record<string, unknown>)
|
||||
: undefined
|
||||
const clawdisRaw = metadataSource ?? frontmatter.clawdis
|
||||
if (!clawdisRaw || typeof clawdisRaw !== 'object' || Array.isArray(clawdisRaw)) return undefined
|
||||
moltbotMeta && typeof moltbotMeta === 'object' && !Array.isArray(moltbotMeta)
|
||||
? (moltbotMeta as Record<string, unknown>)
|
||||
: undefined
|
||||
const moltbotRaw = metadataSource ?? frontmatter.moltbot
|
||||
if (!moltbotRaw || typeof moltbotRaw !== 'object' || Array.isArray(moltbotRaw)) return undefined
|
||||
|
||||
try {
|
||||
const clawdisObj = clawdisRaw as Record<string, unknown>
|
||||
const moltbotObj = moltbotRaw as Record<string, unknown>
|
||||
const requiresRaw =
|
||||
typeof clawdisObj.requires === 'object' && clawdisObj.requires !== null
|
||||
? (clawdisObj.requires as Record<string, unknown>)
|
||||
typeof moltbotObj.requires === 'object' && moltbotObj.requires !== null
|
||||
? (moltbotObj.requires as Record<string, unknown>)
|
||||
: undefined
|
||||
const installRaw = Array.isArray(clawdisObj.install) ? (clawdisObj.install as unknown[]) : []
|
||||
const installRaw = Array.isArray(moltbotObj.install) ? (moltbotObj.install as unknown[]) : []
|
||||
const install = installRaw
|
||||
.map((entry) => parseInstallSpec(entry))
|
||||
.filter((entry): entry is SkillInstallSpec => Boolean(entry))
|
||||
const osRaw = normalizeStringList(clawdisObj.os)
|
||||
const osRaw = normalizeStringList(moltbotObj.os)
|
||||
|
||||
const metadata: ClawdisSkillMetadata = {}
|
||||
if (typeof clawdisObj.always === 'boolean') metadata.always = clawdisObj.always
|
||||
if (typeof clawdisObj.emoji === 'string') metadata.emoji = clawdisObj.emoji
|
||||
if (typeof clawdisObj.homepage === 'string') metadata.homepage = clawdisObj.homepage
|
||||
if (typeof clawdisObj.skillKey === 'string') metadata.skillKey = clawdisObj.skillKey
|
||||
if (typeof clawdisObj.primaryEnv === 'string') metadata.primaryEnv = clawdisObj.primaryEnv
|
||||
if (typeof clawdisObj.cliHelp === 'string') metadata.cliHelp = clawdisObj.cliHelp
|
||||
const metadata: MoltbotSkillMetadata = {}
|
||||
if (typeof moltbotObj.always === 'boolean') metadata.always = moltbotObj.always
|
||||
if (typeof moltbotObj.emoji === 'string') metadata.emoji = moltbotObj.emoji
|
||||
if (typeof moltbotObj.homepage === 'string') metadata.homepage = moltbotObj.homepage
|
||||
if (typeof moltbotObj.skillKey === 'string') metadata.skillKey = moltbotObj.skillKey
|
||||
if (typeof moltbotObj.primaryEnv === 'string') metadata.primaryEnv = moltbotObj.primaryEnv
|
||||
if (typeof moltbotObj.cliHelp === 'string') metadata.cliHelp = moltbotObj.cliHelp
|
||||
if (osRaw.length > 0) metadata.os = osRaw
|
||||
|
||||
if (requiresRaw) {
|
||||
@@ -112,12 +109,12 @@ export function parseClawdisMetadata(frontmatter: ParsedSkillFrontmatter) {
|
||||
}
|
||||
|
||||
if (install.length > 0) metadata.install = install
|
||||
const nix = parseNixPluginSpec(clawdisObj.nix)
|
||||
const nix = parseNixPluginSpec(moltbotObj.nix)
|
||||
if (nix) metadata.nix = nix
|
||||
const config = parseClawdbotConfigSpec(clawdisObj.config)
|
||||
const config = parseMoltbotConfigSpec(moltbotObj.config)
|
||||
if (config) metadata.config = config
|
||||
|
||||
return parseArk(ClawdisSkillMetadataSchema, metadata, 'Clawdis metadata')
|
||||
return parseArk(MoltbotSkillMetadataSchema, metadata, 'Moltbot metadata')
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
@@ -250,13 +247,13 @@ function parseNixPluginSpec(input: unknown): NixPluginSpec | undefined {
|
||||
return spec
|
||||
}
|
||||
|
||||
function parseClawdbotConfigSpec(input: unknown): ClawdbotConfigSpec | undefined {
|
||||
function parseMoltbotConfigSpec(input: unknown): MoltbotConfigSpec | undefined {
|
||||
if (!input || typeof input !== 'object') return undefined
|
||||
const raw = input as Record<string, unknown>
|
||||
const requiredEnv = normalizeStringList(raw.requiredEnv)
|
||||
const stateDirs = normalizeStringList(raw.stateDirs)
|
||||
const example = typeof raw.example === 'string' ? raw.example.trim() : ''
|
||||
const spec: ClawdbotConfigSpec = {}
|
||||
const spec: MoltbotConfigSpec = {}
|
||||
if (requiredEnv.length > 0) spec.requiredEnv = requiredEnv
|
||||
if (stateDirs.length > 0) spec.stateDirs = stateDirs
|
||||
if (example) spec.example = example
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ConvexError } from 'convex/values'
|
||||
import semver from 'semver'
|
||||
import { api, internal } from '../_generated/api'
|
||||
import { internal } from '../_generated/api'
|
||||
import type { Doc, Id } from '../_generated/dataModel'
|
||||
import type { ActionCtx } from '../_generated/server'
|
||||
import { generateEmbedding } from './embeddings'
|
||||
@@ -171,7 +171,9 @@ export async function publishSoulVersionForUser(
|
||||
embedding,
|
||||
})) as PublishResult
|
||||
|
||||
const owner = (await ctx.runQuery(api.users.getById, { userId })) as Doc<'users'> | null
|
||||
const owner = (await ctx.runQuery(internal.users.getByIdInternal, {
|
||||
userId,
|
||||
})) as Doc<'users'> | null
|
||||
const ownerHandle = owner?.handle ?? owner?.name ?? userId
|
||||
|
||||
void ctx.scheduler
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('webhook config', () => {
|
||||
delete process.env.SITE_URL
|
||||
process.env.DISCORD_WEBHOOK_URL = 'https://example.com'
|
||||
const config = getWebhookConfig()
|
||||
expect(config.siteUrl).toBe('https://clawdhub.com')
|
||||
expect(config.siteUrl).toBe('https://molthub.com')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -36,11 +36,11 @@ describe('webhook filtering', () => {
|
||||
const config = {
|
||||
url: 'https://example.com',
|
||||
highlightedOnly: true,
|
||||
siteUrl: 'https://clawdhub.com',
|
||||
siteUrl: 'https://molthub.com',
|
||||
}
|
||||
const allowed = shouldSendWebhook(
|
||||
'skill.publish',
|
||||
{ slug: 'demo', displayName: 'Demo', batch: 'latest' },
|
||||
{ slug: 'demo', displayName: 'Demo', highlighted: false },
|
||||
config,
|
||||
)
|
||||
expect(allowed).toBe(false)
|
||||
@@ -50,11 +50,11 @@ describe('webhook filtering', () => {
|
||||
const config = {
|
||||
url: 'https://example.com',
|
||||
highlightedOnly: true,
|
||||
siteUrl: 'https://clawdhub.com',
|
||||
siteUrl: 'https://molthub.com',
|
||||
}
|
||||
const allowed = shouldSendWebhook(
|
||||
'skill.highlighted',
|
||||
{ slug: 'demo', displayName: 'Demo', batch: 'latest' },
|
||||
{ slug: 'demo', displayName: 'Demo', highlighted: true },
|
||||
config,
|
||||
)
|
||||
expect(allowed).toBe(true)
|
||||
@@ -65,9 +65,9 @@ describe('payload building', () => {
|
||||
it('builds canonical url with owner', () => {
|
||||
const url = buildSkillUrl(
|
||||
{ slug: 'beeper', displayName: 'Beeper', ownerHandle: 'KrauseFx' },
|
||||
'https://clawdhub.com',
|
||||
'https://molthub.com',
|
||||
)
|
||||
expect(url).toBe('https://clawdhub.com/KrauseFx/beeper')
|
||||
expect(url).toBe('https://molthub.com/KrauseFx/beeper')
|
||||
})
|
||||
|
||||
it('builds a publish embed', () => {
|
||||
@@ -81,7 +81,7 @@ describe('payload building', () => {
|
||||
ownerHandle: 'steipete',
|
||||
tags: ['latest', 'discord'],
|
||||
},
|
||||
{ url: 'https://example.com', highlightedOnly: false, siteUrl: 'https://clawdhub.com' },
|
||||
{ url: 'https://example.com', highlightedOnly: false, siteUrl: 'https://molthub.com' },
|
||||
)
|
||||
const embed = payload.embeds[0]
|
||||
expect(embed.title).toBe('Demo Skill')
|
||||
|
||||
@@ -6,7 +6,7 @@ export type WebhookSkillPayload = {
|
||||
summary?: string
|
||||
version?: string
|
||||
ownerHandle?: string
|
||||
batch?: string
|
||||
highlighted?: boolean
|
||||
tags?: string[]
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export type WebhookConfig = {
|
||||
siteUrl: string
|
||||
}
|
||||
|
||||
const DEFAULT_SITE_URL = 'https://clawdhub.com'
|
||||
const DEFAULT_SITE_URL = 'https://molthub.com'
|
||||
|
||||
export function getWebhookConfig(env: NodeJS.ProcessEnv = process.env): WebhookConfig {
|
||||
const url = env.DISCORD_WEBHOOK_URL?.trim() || null
|
||||
@@ -33,7 +33,7 @@ export function shouldSendWebhook(
|
||||
if (!config.url) return false
|
||||
if (!config.highlightedOnly) return true
|
||||
if (event === 'skill.highlighted') return true
|
||||
return skill.batch === 'highlighted'
|
||||
return Boolean(skill.highlighted)
|
||||
}
|
||||
|
||||
export function buildDiscordPayload(
|
||||
@@ -72,7 +72,7 @@ export function buildDiscordPayload(
|
||||
},
|
||||
],
|
||||
footer: {
|
||||
text: 'ClawdHub',
|
||||
text: 'MoltHub',
|
||||
},
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
@@ -89,9 +89,9 @@ export function buildSkillUrl(skill: WebhookSkillPayload, siteUrl: string) {
|
||||
function buildDescription(event: WebhookEvent, skill: WebhookSkillPayload) {
|
||||
const summary = (skill.summary ?? '').trim()
|
||||
if (summary) return truncate(summary, 200)
|
||||
if (event === 'skill.highlighted') return 'Newly highlighted skill on ClawdHub.'
|
||||
if (skill.version) return `New version v${skill.version} published on ClawdHub.`
|
||||
return 'New skill published on ClawdHub.'
|
||||
if (event === 'skill.highlighted') return 'Newly highlighted skill on MoltHub.'
|
||||
if (skill.version) return `New version v${skill.version} published on MoltHub.`
|
||||
return 'New skill published on MoltHub.'
|
||||
}
|
||||
|
||||
function parseBoolean(value?: string) {
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('maintenance backfill', () => {
|
||||
parsed: {
|
||||
frontmatter: { description: 'Hello world.' },
|
||||
metadata: undefined,
|
||||
clawdis: undefined,
|
||||
moltbot: undefined,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
+367
-1
@@ -100,7 +100,7 @@ export const applySkillBackfillPatchInternal = internalMutation({
|
||||
v.object({
|
||||
frontmatter: v.record(v.string(), v.any()),
|
||||
metadata: v.optional(v.any()),
|
||||
clawdis: v.optional(v.any()),
|
||||
moltbot: v.optional(v.any()),
|
||||
}),
|
||||
),
|
||||
},
|
||||
@@ -265,6 +265,34 @@ type FingerprintBackfillPageResult = {
|
||||
isDone: boolean
|
||||
}
|
||||
|
||||
type BadgeBackfillStats = {
|
||||
skillsScanned: number
|
||||
skillsPatched: number
|
||||
highlightsPatched: number
|
||||
}
|
||||
|
||||
type SkillBadgeTableBackfillStats = {
|
||||
skillsScanned: number
|
||||
recordsInserted: number
|
||||
}
|
||||
|
||||
type BadgeBackfillPageItem = {
|
||||
skillId: Id<'skills'>
|
||||
ownerUserId: Id<'users'>
|
||||
createdAt?: number
|
||||
updatedAt?: number
|
||||
batch?: string
|
||||
badges?: Doc<'skills'>['badges']
|
||||
}
|
||||
|
||||
type BadgeBackfillPageResult = {
|
||||
items: BadgeBackfillPageItem[]
|
||||
cursor: string | null
|
||||
isDone: boolean
|
||||
}
|
||||
|
||||
type BadgeKind = Doc<'skillBadges'>['kind']
|
||||
|
||||
export const getSkillFingerprintBackfillPageInternal = internalQuery({
|
||||
args: {
|
||||
cursor: v.optional(v.string()),
|
||||
@@ -467,6 +495,344 @@ export const scheduleBackfillSkillFingerprints: ReturnType<typeof action> = acti
|
||||
},
|
||||
})
|
||||
|
||||
export const getSkillBadgeBackfillPageInternal = internalQuery({
|
||||
args: {
|
||||
cursor: v.optional(v.string()),
|
||||
batchSize: v.optional(v.number()),
|
||||
},
|
||||
handler: async (ctx, args): Promise<BadgeBackfillPageResult> => {
|
||||
const batchSize = clampInt(args.batchSize ?? DEFAULT_BATCH_SIZE, 1, MAX_BATCH_SIZE)
|
||||
const { page, isDone, continueCursor } = await ctx.db
|
||||
.query('skills')
|
||||
.order('asc')
|
||||
.paginate({ cursor: args.cursor ?? null, numItems: batchSize })
|
||||
|
||||
const items: BadgeBackfillPageItem[] = page.map((skill) => ({
|
||||
skillId: skill._id,
|
||||
ownerUserId: skill.ownerUserId,
|
||||
createdAt: skill.createdAt ?? undefined,
|
||||
updatedAt: skill.updatedAt ?? undefined,
|
||||
batch: skill.batch ?? undefined,
|
||||
badges: skill.badges ?? undefined,
|
||||
}))
|
||||
|
||||
return { items, cursor: continueCursor, isDone }
|
||||
},
|
||||
})
|
||||
|
||||
export const applySkillBadgeBackfillPatchInternal = internalMutation({
|
||||
args: {
|
||||
skillId: v.id('skills'),
|
||||
badges: v.optional(
|
||||
v.object({
|
||||
redactionApproved: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
highlighted: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
official: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
deprecated: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.patch(args.skillId, { badges: args.badges ?? undefined, updatedAt: Date.now() })
|
||||
return { ok: true as const }
|
||||
},
|
||||
})
|
||||
|
||||
export const upsertSkillBadgeRecordInternal = internalMutation({
|
||||
args: {
|
||||
skillId: v.id('skills'),
|
||||
kind: v.union(
|
||||
v.literal('highlighted'),
|
||||
v.literal('official'),
|
||||
v.literal('deprecated'),
|
||||
v.literal('redactionApproved'),
|
||||
),
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const existing = await ctx.db
|
||||
.query('skillBadges')
|
||||
.withIndex('by_skill_kind', (q) => q.eq('skillId', args.skillId).eq('kind', args.kind))
|
||||
.unique()
|
||||
if (existing) return { inserted: false as const }
|
||||
await ctx.db.insert('skillBadges', {
|
||||
skillId: args.skillId,
|
||||
kind: args.kind,
|
||||
byUserId: args.byUserId,
|
||||
at: args.at,
|
||||
})
|
||||
return { inserted: true as const }
|
||||
},
|
||||
})
|
||||
|
||||
export type BadgeBackfillActionArgs = {
|
||||
dryRun?: boolean
|
||||
batchSize?: number
|
||||
maxBatches?: number
|
||||
}
|
||||
|
||||
export type BadgeBackfillActionResult = { ok: true; stats: BadgeBackfillStats }
|
||||
|
||||
export async function backfillSkillBadgesInternalHandler(
|
||||
ctx: ActionCtx,
|
||||
args: BadgeBackfillActionArgs,
|
||||
): Promise<BadgeBackfillActionResult> {
|
||||
const dryRun = Boolean(args.dryRun)
|
||||
const batchSize = clampInt(args.batchSize ?? DEFAULT_BATCH_SIZE, 1, MAX_BATCH_SIZE)
|
||||
const maxBatches = clampInt(args.maxBatches ?? DEFAULT_MAX_BATCHES, 1, MAX_MAX_BATCHES)
|
||||
|
||||
const totals: BadgeBackfillStats = {
|
||||
skillsScanned: 0,
|
||||
skillsPatched: 0,
|
||||
highlightsPatched: 0,
|
||||
}
|
||||
|
||||
let cursor: string | null = null
|
||||
let isDone = false
|
||||
|
||||
for (let i = 0; i < maxBatches; i++) {
|
||||
const page = (await ctx.runQuery(internal.maintenance.getSkillBadgeBackfillPageInternal, {
|
||||
cursor: cursor ?? undefined,
|
||||
batchSize,
|
||||
})) as BadgeBackfillPageResult
|
||||
|
||||
cursor = page.cursor
|
||||
isDone = page.isDone
|
||||
|
||||
for (const item of page.items) {
|
||||
totals.skillsScanned++
|
||||
|
||||
const shouldHighlight = item.batch === 'highlighted' && !item.badges?.highlighted
|
||||
if (!shouldHighlight) continue
|
||||
|
||||
totals.skillsPatched++
|
||||
totals.highlightsPatched++
|
||||
|
||||
if (dryRun) continue
|
||||
|
||||
const at = item.updatedAt ?? item.createdAt ?? Date.now()
|
||||
await ctx.runMutation(internal.maintenance.applySkillBadgeBackfillPatchInternal, {
|
||||
skillId: item.skillId,
|
||||
badges: {
|
||||
...item.badges,
|
||||
highlighted: {
|
||||
byUserId: item.ownerUserId,
|
||||
at,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if (isDone) break
|
||||
}
|
||||
|
||||
if (!isDone) {
|
||||
throw new ConvexError('Backfill incomplete (maxBatches reached)')
|
||||
}
|
||||
|
||||
return { ok: true as const, stats: totals }
|
||||
}
|
||||
|
||||
export const backfillSkillBadgesInternal = internalAction({
|
||||
args: {
|
||||
dryRun: v.optional(v.boolean()),
|
||||
batchSize: v.optional(v.number()),
|
||||
maxBatches: v.optional(v.number()),
|
||||
},
|
||||
handler: backfillSkillBadgesInternalHandler,
|
||||
})
|
||||
|
||||
export const backfillSkillBadges: ReturnType<typeof action> = action({
|
||||
args: {
|
||||
dryRun: v.optional(v.boolean()),
|
||||
batchSize: v.optional(v.number()),
|
||||
maxBatches: v.optional(v.number()),
|
||||
},
|
||||
handler: async (ctx, args): Promise<BadgeBackfillActionResult> => {
|
||||
const { user } = await requireUserFromAction(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
return ctx.runAction(
|
||||
internal.maintenance.backfillSkillBadgesInternal,
|
||||
args,
|
||||
) as Promise<BadgeBackfillActionResult>
|
||||
},
|
||||
})
|
||||
|
||||
export const scheduleBackfillSkillBadges: ReturnType<typeof action> = action({
|
||||
args: { dryRun: v.optional(v.boolean()) },
|
||||
handler: async (ctx, args) => {
|
||||
const { user } = await requireUserFromAction(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
await ctx.scheduler.runAfter(0, internal.maintenance.backfillSkillBadgesInternal, {
|
||||
dryRun: Boolean(args.dryRun),
|
||||
batchSize: DEFAULT_BATCH_SIZE,
|
||||
maxBatches: DEFAULT_MAX_BATCHES,
|
||||
})
|
||||
return { ok: true as const }
|
||||
},
|
||||
})
|
||||
|
||||
export type SkillBadgeTableBackfillActionResult = {
|
||||
ok: true
|
||||
stats: SkillBadgeTableBackfillStats
|
||||
}
|
||||
|
||||
export async function backfillSkillBadgeTableInternalHandler(
|
||||
ctx: ActionCtx,
|
||||
args: BadgeBackfillActionArgs,
|
||||
): Promise<SkillBadgeTableBackfillActionResult> {
|
||||
const dryRun = Boolean(args.dryRun)
|
||||
const batchSize = clampInt(args.batchSize ?? DEFAULT_BATCH_SIZE, 1, MAX_BATCH_SIZE)
|
||||
const maxBatches = clampInt(args.maxBatches ?? DEFAULT_MAX_BATCHES, 1, MAX_MAX_BATCHES)
|
||||
|
||||
const totals: SkillBadgeTableBackfillStats = {
|
||||
skillsScanned: 0,
|
||||
recordsInserted: 0,
|
||||
}
|
||||
|
||||
let cursor: string | null = null
|
||||
let isDone = false
|
||||
|
||||
for (let i = 0; i < maxBatches; i++) {
|
||||
const page = (await ctx.runQuery(internal.maintenance.getSkillBadgeBackfillPageInternal, {
|
||||
cursor: cursor ?? undefined,
|
||||
batchSize,
|
||||
})) as BadgeBackfillPageResult
|
||||
|
||||
cursor = page.cursor
|
||||
isDone = page.isDone
|
||||
|
||||
for (const item of page.items) {
|
||||
totals.skillsScanned++
|
||||
const badges = item.badges ?? {}
|
||||
const entries: Array<{ kind: BadgeKind; byUserId: Id<'users'>; at: number }> = []
|
||||
|
||||
if (badges.redactionApproved) {
|
||||
entries.push({
|
||||
kind: 'redactionApproved',
|
||||
byUserId: badges.redactionApproved.byUserId,
|
||||
at: badges.redactionApproved.at,
|
||||
})
|
||||
}
|
||||
|
||||
if (badges.official) {
|
||||
entries.push({
|
||||
kind: 'official',
|
||||
byUserId: badges.official.byUserId,
|
||||
at: badges.official.at,
|
||||
})
|
||||
}
|
||||
|
||||
if (badges.deprecated) {
|
||||
entries.push({
|
||||
kind: 'deprecated',
|
||||
byUserId: badges.deprecated.byUserId,
|
||||
at: badges.deprecated.at,
|
||||
})
|
||||
}
|
||||
|
||||
const highlighted =
|
||||
badges.highlighted ??
|
||||
(item.batch === 'highlighted'
|
||||
? {
|
||||
byUserId: item.ownerUserId,
|
||||
at: item.updatedAt ?? item.createdAt ?? Date.now(),
|
||||
}
|
||||
: undefined)
|
||||
|
||||
if (highlighted) {
|
||||
entries.push({
|
||||
kind: 'highlighted',
|
||||
byUserId: highlighted.byUserId,
|
||||
at: highlighted.at,
|
||||
})
|
||||
}
|
||||
|
||||
if (dryRun) continue
|
||||
|
||||
for (const entry of entries) {
|
||||
const result = await ctx.runMutation(internal.maintenance.upsertSkillBadgeRecordInternal, {
|
||||
skillId: item.skillId,
|
||||
kind: entry.kind,
|
||||
byUserId: entry.byUserId,
|
||||
at: entry.at,
|
||||
})
|
||||
if (result.inserted) {
|
||||
totals.recordsInserted++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isDone) break
|
||||
}
|
||||
|
||||
if (!isDone) {
|
||||
throw new ConvexError('Backfill incomplete (maxBatches reached)')
|
||||
}
|
||||
|
||||
return { ok: true as const, stats: totals }
|
||||
}
|
||||
|
||||
export const backfillSkillBadgeTableInternal = internalAction({
|
||||
args: {
|
||||
dryRun: v.optional(v.boolean()),
|
||||
batchSize: v.optional(v.number()),
|
||||
maxBatches: v.optional(v.number()),
|
||||
},
|
||||
handler: backfillSkillBadgeTableInternalHandler,
|
||||
})
|
||||
|
||||
export const backfillSkillBadgeTable: ReturnType<typeof action> = action({
|
||||
args: {
|
||||
dryRun: v.optional(v.boolean()),
|
||||
batchSize: v.optional(v.number()),
|
||||
maxBatches: v.optional(v.number()),
|
||||
},
|
||||
handler: async (ctx, args): Promise<SkillBadgeTableBackfillActionResult> => {
|
||||
const { user } = await requireUserFromAction(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
return ctx.runAction(
|
||||
internal.maintenance.backfillSkillBadgeTableInternal,
|
||||
args,
|
||||
) as Promise<SkillBadgeTableBackfillActionResult>
|
||||
},
|
||||
})
|
||||
|
||||
export const scheduleBackfillSkillBadgeTable: ReturnType<typeof action> = action({
|
||||
args: { dryRun: v.optional(v.boolean()) },
|
||||
handler: async (ctx, args) => {
|
||||
const { user } = await requireUserFromAction(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
await ctx.scheduler.runAfter(0, internal.maintenance.backfillSkillBadgeTableInternal, {
|
||||
dryRun: Boolean(args.dryRun),
|
||||
batchSize: DEFAULT_BATCH_SIZE,
|
||||
maxBatches: DEFAULT_MAX_BATCHES,
|
||||
})
|
||||
return { ok: true as const }
|
||||
},
|
||||
})
|
||||
|
||||
function clampInt(value: number, min: number, max: number) {
|
||||
const rounded = Math.trunc(value)
|
||||
if (!Number.isFinite(rounded)) return min
|
||||
|
||||
+93
-1
@@ -3,6 +3,8 @@ import { defineSchema, defineTable } from 'convex/server'
|
||||
import { v } from 'convex/values'
|
||||
import { EMBEDDING_DIMENSIONS } from './lib/embeddings'
|
||||
|
||||
const authSchema = authTables as unknown as Record<string, ReturnType<typeof defineTable>>
|
||||
|
||||
const users = defineTable({
|
||||
name: v.optional(v.string()),
|
||||
image: v.optional(v.string()),
|
||||
@@ -47,7 +49,36 @@ const skills = defineTable({
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
highlighted: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
official: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
deprecated: v.optional(
|
||||
v.object({
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
moderationStatus: v.optional(
|
||||
v.union(v.literal('active'), v.literal('hidden'), v.literal('removed')),
|
||||
),
|
||||
moderationNotes: v.optional(v.string()),
|
||||
moderationReason: v.optional(v.string()),
|
||||
moderationFlags: v.optional(v.array(v.string())),
|
||||
lastReviewedAt: v.optional(v.number()),
|
||||
hiddenAt: v.optional(v.number()),
|
||||
hiddenBy: v.optional(v.id('users')),
|
||||
reportCount: v.optional(v.number()),
|
||||
lastReportedAt: v.optional(v.number()),
|
||||
batch: v.optional(v.string()),
|
||||
statsDownloads: v.optional(v.number()),
|
||||
statsStars: v.optional(v.number()),
|
||||
@@ -72,6 +103,7 @@ const skills = defineTable({
|
||||
.index('by_stats_installs_current', ['statsInstallsCurrent', 'updatedAt'])
|
||||
.index('by_stats_installs_all_time', ['statsInstallsAllTime', 'updatedAt'])
|
||||
.index('by_batch', ['batch'])
|
||||
.index('by_active_updated', ['softDeletedAt', 'updatedAt'])
|
||||
|
||||
const souls = defineTable({
|
||||
slug: v.string(),
|
||||
@@ -112,6 +144,7 @@ const skillVersions = defineTable({
|
||||
parsed: v.object({
|
||||
frontmatter: v.record(v.string(), v.any()),
|
||||
metadata: v.optional(v.any()),
|
||||
moltbot: v.optional(v.any()),
|
||||
clawdis: v.optional(v.any()),
|
||||
}),
|
||||
createdBy: v.id('users'),
|
||||
@@ -139,6 +172,7 @@ const soulVersions = defineTable({
|
||||
parsed: v.object({
|
||||
frontmatter: v.record(v.string(), v.any()),
|
||||
metadata: v.optional(v.any()),
|
||||
clawdis: v.optional(v.any()),
|
||||
}),
|
||||
createdBy: v.id('users'),
|
||||
createdAt: v.number(),
|
||||
@@ -157,6 +191,21 @@ const skillVersionFingerprints = defineTable({
|
||||
.index('by_fingerprint', ['fingerprint'])
|
||||
.index('by_skill_fingerprint', ['skillId', 'fingerprint'])
|
||||
|
||||
const skillBadges = defineTable({
|
||||
skillId: v.id('skills'),
|
||||
kind: v.union(
|
||||
v.literal('highlighted'),
|
||||
v.literal('official'),
|
||||
v.literal('deprecated'),
|
||||
v.literal('redactionApproved'),
|
||||
),
|
||||
byUserId: v.id('users'),
|
||||
at: v.number(),
|
||||
})
|
||||
.index('by_skill', ['skillId'])
|
||||
.index('by_skill_kind', ['skillId', 'kind'])
|
||||
.index('by_kind_at', ['kind', 'at'])
|
||||
|
||||
const soulVersionFingerprints = defineTable({
|
||||
soulId: v.id('souls'),
|
||||
versionId: v.id('soulVersions'),
|
||||
@@ -217,6 +266,35 @@ const skillStatBackfillState = defineTable({
|
||||
updatedAt: v.number(),
|
||||
}).index('by_key', ['key'])
|
||||
|
||||
const skillStatEvents = defineTable({
|
||||
skillId: v.id('skills'),
|
||||
kind: v.union(
|
||||
v.literal('download'),
|
||||
v.literal('star'),
|
||||
v.literal('unstar'),
|
||||
v.literal('install_new'),
|
||||
v.literal('install_reactivate'),
|
||||
v.literal('install_deactivate'),
|
||||
v.literal('install_clear'),
|
||||
),
|
||||
delta: v.optional(
|
||||
v.object({
|
||||
allTime: v.number(),
|
||||
current: v.number(),
|
||||
}),
|
||||
),
|
||||
occurredAt: v.number(),
|
||||
processedAt: v.optional(v.number()),
|
||||
})
|
||||
.index('by_unprocessed', ['processedAt'])
|
||||
.index('by_skill', ['skillId'])
|
||||
|
||||
const skillStatUpdateCursors = defineTable({
|
||||
key: v.string(),
|
||||
cursorCreationTime: v.optional(v.number()),
|
||||
updatedAt: v.number(),
|
||||
}).index('by_key', ['key'])
|
||||
|
||||
const soulEmbeddings = defineTable({
|
||||
soulId: v.id('souls'),
|
||||
versionId: v.id('soulVersions'),
|
||||
@@ -246,6 +324,16 @@ const comments = defineTable({
|
||||
.index('by_skill', ['skillId'])
|
||||
.index('by_user', ['userId'])
|
||||
|
||||
const skillReports = defineTable({
|
||||
skillId: v.id('skills'),
|
||||
userId: v.id('users'),
|
||||
reason: v.optional(v.string()),
|
||||
createdAt: v.number(),
|
||||
})
|
||||
.index('by_skill', ['skillId'])
|
||||
.index('by_user', ['userId'])
|
||||
.index('by_skill_user', ['skillId', 'userId'])
|
||||
|
||||
const soulComments = defineTable({
|
||||
soulId: v.id('souls'),
|
||||
userId: v.id('users'),
|
||||
@@ -353,20 +441,24 @@ const userSkillRootInstalls = defineTable({
|
||||
.index('by_skill', ['skillId'])
|
||||
|
||||
export default defineSchema({
|
||||
...authTables,
|
||||
...authSchema,
|
||||
users,
|
||||
skills,
|
||||
souls,
|
||||
skillVersions,
|
||||
soulVersions,
|
||||
skillVersionFingerprints,
|
||||
skillBadges,
|
||||
soulVersionFingerprints,
|
||||
skillEmbeddings,
|
||||
soulEmbeddings,
|
||||
skillDailyStats,
|
||||
skillLeaderboards,
|
||||
skillStatBackfillState,
|
||||
skillStatEvents,
|
||||
skillStatUpdateCursors,
|
||||
comments,
|
||||
skillReports,
|
||||
soulComments,
|
||||
stars,
|
||||
soulStars,
|
||||
|
||||
+46
-12
@@ -2,12 +2,14 @@ import { v } from 'convex/values'
|
||||
import { internal } from './_generated/api'
|
||||
import type { Doc, Id } from './_generated/dataModel'
|
||||
import { action, internalQuery } from './_generated/server'
|
||||
import { getSkillBadgeMaps, isSkillHighlighted, type SkillBadgeMap } from './lib/badges'
|
||||
import { generateEmbedding } from './lib/embeddings'
|
||||
import { toPublicSkill, toPublicSoul } from './lib/public'
|
||||
import { matchesExactTokens, tokenize } from './lib/searchText'
|
||||
|
||||
type HydratedEntry = {
|
||||
embeddingId: Id<'skillEmbeddings'>
|
||||
skill: Doc<'skills'> | null
|
||||
skill: NonNullable<ReturnType<typeof toPublicSkill>>
|
||||
version: Doc<'skillVersions'> | null
|
||||
ownerHandle: string | null
|
||||
}
|
||||
@@ -60,15 +62,27 @@ export const searchSkills: ReturnType<typeof action> = action({
|
||||
results.map((result) => [result._id, result._score]),
|
||||
)
|
||||
|
||||
const badgeMapEntries = (await ctx.runQuery(internal.search.getSkillBadgeMapsInternal, {
|
||||
skillIds: hydrated.map((entry) => entry.skill._id),
|
||||
})) as Array<[Id<'skills'>, SkillBadgeMap]>
|
||||
const badgeMapBySkillId = new Map(badgeMapEntries)
|
||||
const hydratedWithBadges = hydrated.map((entry) => ({
|
||||
...entry,
|
||||
skill: {
|
||||
...entry.skill,
|
||||
badges: badgeMapBySkillId.get(entry.skill._id) ?? {},
|
||||
},
|
||||
}))
|
||||
|
||||
const filtered = args.highlightedOnly
|
||||
? hydrated.filter((entry) => entry.skill?.batch === 'highlighted')
|
||||
: hydrated
|
||||
? hydratedWithBadges.filter((entry) => isSkillHighlighted(entry.skill))
|
||||
: hydratedWithBadges
|
||||
|
||||
exactMatches = filtered.filter((entry) =>
|
||||
matchesExactTokens(queryTokens, [
|
||||
entry.skill?.displayName,
|
||||
entry.skill?.slug,
|
||||
entry.skill?.summary,
|
||||
entry.skill.displayName,
|
||||
entry.skill.slug,
|
||||
entry.skill.summary,
|
||||
]),
|
||||
)
|
||||
|
||||
@@ -91,6 +105,14 @@ export const searchSkills: ReturnType<typeof action> = action({
|
||||
},
|
||||
})
|
||||
|
||||
export const getBadgeMapsForSkills = internalQuery({
|
||||
args: { skillIds: v.array(v.id('skills')) },
|
||||
handler: async (ctx, args): Promise<Array<[Id<'skills'>, SkillBadgeMap]>> => {
|
||||
const badgeMap = await getSkillBadgeMaps(ctx, args.skillIds)
|
||||
return Array.from(badgeMap.entries())
|
||||
},
|
||||
})
|
||||
|
||||
export const hydrateResults = internalQuery({
|
||||
args: { embeddingIds: v.array(v.id('skillEmbeddings')) },
|
||||
handler: async (ctx, args): Promise<HydratedEntry[]> => {
|
||||
@@ -116,7 +138,9 @@ export const hydrateResults = internalQuery({
|
||||
ctx.db.get(embedding.versionId),
|
||||
getOwnerHandle(skill.ownerUserId),
|
||||
])
|
||||
return { embeddingId, skill, version, ownerHandle }
|
||||
const publicSkill = toPublicSkill(skill)
|
||||
if (!publicSkill) return null
|
||||
return { embeddingId, skill: publicSkill, version, ownerHandle }
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -126,7 +150,7 @@ export const hydrateResults = internalQuery({
|
||||
|
||||
type HydratedSoulEntry = {
|
||||
embeddingId: Id<'soulEmbeddings'>
|
||||
soul: Doc<'souls'> | null
|
||||
soul: NonNullable<ReturnType<typeof toPublicSoul>>
|
||||
version: Doc<'soulVersions'> | null
|
||||
}
|
||||
|
||||
@@ -174,9 +198,9 @@ export const searchSouls: ReturnType<typeof action> = action({
|
||||
|
||||
exactMatches = hydrated.filter((entry) =>
|
||||
matchesExactTokens(queryTokens, [
|
||||
entry.soul?.displayName,
|
||||
entry.soul?.slug,
|
||||
entry.soul?.summary,
|
||||
entry.soul.displayName,
|
||||
entry.soul.slug,
|
||||
entry.soul.summary,
|
||||
]),
|
||||
)
|
||||
|
||||
@@ -210,11 +234,21 @@ export const hydrateSoulResults = internalQuery({
|
||||
const soul = await ctx.db.get(embedding.soulId)
|
||||
if (soul?.softDeletedAt) continue
|
||||
const version = await ctx.db.get(embedding.versionId)
|
||||
entries.push({ embeddingId, soul, version })
|
||||
const publicSoul = toPublicSoul(soul)
|
||||
if (!publicSoul) continue
|
||||
entries.push({ embeddingId, soul: publicSoul, version })
|
||||
}
|
||||
|
||||
return entries
|
||||
},
|
||||
})
|
||||
|
||||
export const getSkillBadgeMapsInternal = internalQuery({
|
||||
args: { skillIds: v.array(v.id('skills')) },
|
||||
handler: async (ctx, args) => {
|
||||
const badgeMap = await getSkillBadgeMaps(ctx, args.skillIds)
|
||||
return Array.from(badgeMap.entries())
|
||||
},
|
||||
})
|
||||
|
||||
export const __test = { getNextCandidateLimit }
|
||||
|
||||
+11
-11
File diff suppressed because one or more lines are too long
@@ -0,0 +1,568 @@
|
||||
/**
|
||||
* Skill Stat Events - Event-sourced stats processing for skills
|
||||
*
|
||||
* Instead of updating skill stats synchronously in the hot path (which can cause
|
||||
* contention when multiple users download/star/install the same skill), we insert
|
||||
* lightweight event records and process them in batches via a cron job.
|
||||
*
|
||||
* Flow:
|
||||
* 1. User action (download, star, install) → insertStatEvent() writes to skillStatEvents table
|
||||
* 2. Cron job runs every 5 minutes → processSkillStatEventsInternal() processes batches
|
||||
* 3. Events are aggregated per-skill to minimize database operations
|
||||
* 4. Stats are applied to skill documents and daily stats tables
|
||||
* 5. Events are marked as processed (kept forever for auditing)
|
||||
*/
|
||||
|
||||
import { v } from 'convex/values'
|
||||
import { internal } from './_generated/api'
|
||||
import type { Doc, Id } from './_generated/dataModel'
|
||||
import type { MutationCtx } from './_generated/server'
|
||||
import { internalAction, internalMutation, internalQuery } from './_generated/server'
|
||||
import { applySkillStatDeltas, bumpDailySkillStats } from './lib/skillStats'
|
||||
|
||||
/**
|
||||
* Event types that affect skill stats:
|
||||
*
|
||||
* - download: User downloaded skill as zip (+1 downloads)
|
||||
* - star: User starred the skill (+1 stars)
|
||||
* - unstar: User removed their star (-1 stars)
|
||||
* - install_new: First time this user installed this skill (+1 installsAllTime, +1 installsCurrent)
|
||||
* - install_reactivate: User re-added skill after removing it (+1 installsCurrent only)
|
||||
* - install_deactivate: User removed skill from all projects (-1 installsCurrent)
|
||||
* - install_clear: User cleared all telemetry data (custom delta for both allTime and current)
|
||||
*/
|
||||
export type StatEventKind =
|
||||
| 'download'
|
||||
| 'star'
|
||||
| 'unstar'
|
||||
| 'install_new'
|
||||
| 'install_reactivate'
|
||||
| 'install_deactivate'
|
||||
| 'install_clear'
|
||||
|
||||
/**
|
||||
* Insert a stat event to be processed later by the cron job.
|
||||
*
|
||||
* This is called from the hot path (downloads, stars, telemetry) instead of
|
||||
* directly updating skill stats. It's a single insert with no read-modify-write
|
||||
* cycle, so it's fast and doesn't contend with other operations on the same skill.
|
||||
*
|
||||
* @param ctx - Mutation context
|
||||
* @param params.skillId - The skill being affected
|
||||
* @param params.kind - Type of event (download, star, install_new, etc.)
|
||||
* @param params.occurredAt - When the event happened (defaults to now). Important for
|
||||
* daily stats bucketing - we want downloads at 11:55 PM Monday
|
||||
* to count toward Monday's stats even if processed on Tuesday.
|
||||
* @param params.delta - Only used for install_clear events, specifies exact delta amounts
|
||||
*/
|
||||
export async function insertStatEvent(
|
||||
ctx: MutationCtx,
|
||||
params: {
|
||||
skillId: Id<'skills'>
|
||||
kind: StatEventKind
|
||||
occurredAt?: number
|
||||
delta?: { allTime: number; current: number }
|
||||
},
|
||||
) {
|
||||
await ctx.db.insert('skillStatEvents', {
|
||||
skillId: params.skillId,
|
||||
kind: params.kind,
|
||||
delta: params.delta,
|
||||
occurredAt: params.occurredAt ?? Date.now(),
|
||||
processedAt: undefined,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregated deltas for a single skill after processing multiple events.
|
||||
*
|
||||
* When we process a batch of 100 events, many might be for the same skill.
|
||||
* Instead of updating the skill document once per event, we aggregate all
|
||||
* events for each skill and apply a single update.
|
||||
*
|
||||
* The downloadEvents and installNewEvents arrays store the original timestamps
|
||||
* so we can update daily stats with the correct day bucket for each event.
|
||||
*/
|
||||
type AggregatedDeltas = {
|
||||
downloads: number
|
||||
stars: number
|
||||
installsAllTime: number
|
||||
installsCurrent: number
|
||||
/** Original timestamps for each download event (for daily stats bucketing) */
|
||||
downloadEvents: number[]
|
||||
/** Original timestamps for each new install event (for daily stats bucketing) */
|
||||
installNewEvents: number[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregate multiple events for a single skill into net deltas.
|
||||
*
|
||||
* Example: If a skill has these events in the batch:
|
||||
* - download (Mon 11pm)
|
||||
* - download (Tue 1am)
|
||||
* - star
|
||||
* - unstar
|
||||
* - star
|
||||
*
|
||||
* The result would be:
|
||||
* - downloads: 2
|
||||
* - stars: 1 (net: +1 -1 +1 = +1)
|
||||
* - downloadEvents: [<Mon 11pm timestamp>, <Tue 1am timestamp>]
|
||||
*
|
||||
* This aggregation reduces the number of database operations from N events
|
||||
* to 1 skill update + N daily stat updates (which themselves may coalesce
|
||||
* if multiple events fall on the same day).
|
||||
*/
|
||||
function aggregateEvents(events: Doc<'skillStatEvents'>[]): AggregatedDeltas {
|
||||
const result: AggregatedDeltas = {
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsAllTime: 0,
|
||||
installsCurrent: 0,
|
||||
downloadEvents: [],
|
||||
installNewEvents: [],
|
||||
}
|
||||
|
||||
for (const event of events) {
|
||||
switch (event.kind) {
|
||||
case 'download':
|
||||
result.downloads += 1
|
||||
result.downloadEvents.push(event.occurredAt)
|
||||
break
|
||||
case 'star':
|
||||
result.stars += 1
|
||||
break
|
||||
case 'unstar':
|
||||
result.stars -= 1
|
||||
break
|
||||
case 'install_new':
|
||||
// New user installing for the first time: count toward both lifetime and current
|
||||
result.installsAllTime += 1
|
||||
result.installsCurrent += 1
|
||||
result.installNewEvents.push(event.occurredAt)
|
||||
break
|
||||
case 'install_reactivate':
|
||||
// User re-added skill after removing: only affects current count
|
||||
result.installsCurrent += 1
|
||||
break
|
||||
case 'install_deactivate':
|
||||
// User removed skill from all projects: only affects current count
|
||||
result.installsCurrent -= 1
|
||||
break
|
||||
case 'install_clear':
|
||||
// User cleared telemetry: uses custom delta values (typically negative)
|
||||
if (event.delta) {
|
||||
result.installsAllTime += event.delta.allTime
|
||||
result.installsCurrent += event.delta.current
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a batch of unprocessed stat events.
|
||||
*
|
||||
* Called by cron every 5 minutes. Processes up to batchSize events (default 100).
|
||||
* If the batch is full, schedules an immediate follow-up run to drain the queue.
|
||||
*
|
||||
* Processing steps:
|
||||
* 1. Query unprocessed events (processedAt is undefined)
|
||||
* 2. Group events by skillId to minimize skill document fetches
|
||||
* 3. For each skill:
|
||||
* a. Fetch the skill document once
|
||||
* b. Aggregate all events for this skill into net deltas
|
||||
* c. Apply deltas to skill stats (downloads, stars, installs)
|
||||
* d. Update daily stats for trending (using original event timestamps)
|
||||
* e. Mark all events as processed
|
||||
* 4. If batch was full, schedule another run immediately
|
||||
*
|
||||
* Aggregation levels:
|
||||
* - Level 1: Batch of 100 events from the queue
|
||||
* - Level 2: Group by skillId (e.g., 100 events → 30 unique skills)
|
||||
* - Level 3: Aggregate events per skill (e.g., 5 events → 1 skill update)
|
||||
* - Level 4: Daily stats may coalesce (e.g., 3 downloads same day → 1 upsert)
|
||||
*/
|
||||
export const processSkillStatEventsInternal = internalMutation({
|
||||
args: { batchSize: v.optional(v.number()) },
|
||||
handler: async (ctx, args) => {
|
||||
const batchSize = args.batchSize ?? 100
|
||||
const now = Date.now()
|
||||
|
||||
// Level 1: Fetch a batch of unprocessed events
|
||||
const events = await ctx.db
|
||||
.query('skillStatEvents')
|
||||
.withIndex('by_unprocessed', (q) => q.eq('processedAt', undefined))
|
||||
.take(batchSize)
|
||||
|
||||
if (events.length === 0) {
|
||||
return { processed: 0 }
|
||||
}
|
||||
|
||||
// Level 2: Group events by skillId to minimize database reads
|
||||
// Instead of fetching the same skill document multiple times,
|
||||
// we fetch it once and process all its events together
|
||||
const eventsBySkill = new Map<Id<'skills'>, Doc<'skillStatEvents'>[]>()
|
||||
for (const event of events) {
|
||||
const existing = eventsBySkill.get(event.skillId) ?? []
|
||||
existing.push(event)
|
||||
eventsBySkill.set(event.skillId, existing)
|
||||
}
|
||||
|
||||
// Process each skill's events
|
||||
for (const [skillId, skillEvents] of eventsBySkill) {
|
||||
const skill = await ctx.db.get(skillId)
|
||||
|
||||
// Skill was deleted - just mark events as processed
|
||||
if (!skill) {
|
||||
for (const event of skillEvents) {
|
||||
await ctx.db.patch(event._id, { processedAt: now })
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Level 3: Aggregate all events for this skill into net deltas
|
||||
// e.g., 3 downloads + 2 stars - 1 unstar → { downloads: 3, stars: 1 }
|
||||
const deltas = aggregateEvents(skillEvents)
|
||||
|
||||
// Apply aggregated deltas to skill stats (single update per skill)
|
||||
if (
|
||||
deltas.downloads !== 0 ||
|
||||
deltas.stars !== 0 ||
|
||||
deltas.installsAllTime !== 0 ||
|
||||
deltas.installsCurrent !== 0
|
||||
) {
|
||||
const patch = applySkillStatDeltas(skill, {
|
||||
downloads: deltas.downloads,
|
||||
stars: deltas.stars,
|
||||
installsAllTime: deltas.installsAllTime,
|
||||
installsCurrent: deltas.installsCurrent,
|
||||
})
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: now,
|
||||
})
|
||||
}
|
||||
|
||||
// Update daily stats for trending/leaderboards
|
||||
// We use the ORIGINAL event timestamp (occurredAt) so that:
|
||||
// - A download at Mon 11:55 PM counts toward Monday's stats
|
||||
// - Even if the cron processes it on Tuesday
|
||||
//
|
||||
// Level 4: bumpDailySkillStats does its own coalescing - multiple
|
||||
// events on the same day will update the same daily record
|
||||
for (const occurredAt of deltas.downloadEvents) {
|
||||
await bumpDailySkillStats(ctx, { skillId, now: occurredAt, downloads: 1 })
|
||||
}
|
||||
for (const occurredAt of deltas.installNewEvents) {
|
||||
await bumpDailySkillStats(ctx, { skillId, now: occurredAt, installs: 1 })
|
||||
}
|
||||
|
||||
// Mark all events for this skill as processed
|
||||
for (const event of skillEvents) {
|
||||
await ctx.db.patch(event._id, { processedAt: now })
|
||||
}
|
||||
}
|
||||
|
||||
// If we hit the batch limit, there may be more events waiting.
|
||||
// Schedule an immediate follow-up run to drain the queue.
|
||||
// This ensures high-volume periods don't create a backlog.
|
||||
if (events.length === batchSize) {
|
||||
await ctx.scheduler.runAfter(0, internal.skillStatEvents.processSkillStatEventsInternal, {
|
||||
batchSize,
|
||||
})
|
||||
}
|
||||
|
||||
return { processed: events.length }
|
||||
},
|
||||
})
|
||||
|
||||
// ============================================================================
|
||||
// Action-based processing (cursor-based, runs outside transaction window)
|
||||
// ============================================================================
|
||||
|
||||
const CURSOR_KEY = 'skill_stat_events'
|
||||
const EVENT_BATCH_SIZE = 500
|
||||
const MAX_SKILLS_PER_RUN = 500
|
||||
|
||||
/**
|
||||
* Fetch a batch of events after the given cursor (by _creationTime).
|
||||
* Returns events sorted by _creationTime ascending.
|
||||
*/
|
||||
export const getUnprocessedEventBatch = internalQuery({
|
||||
args: {
|
||||
cursorCreationTime: v.optional(v.number()),
|
||||
limit: v.optional(v.number()),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const limit = args.limit ?? EVENT_BATCH_SIZE
|
||||
const cursor = args.cursorCreationTime
|
||||
|
||||
// Query events after the cursor using the built-in creation time index
|
||||
const events = await ctx.db
|
||||
.query('skillStatEvents')
|
||||
.withIndex('by_creation_time', (q) =>
|
||||
cursor !== undefined ? q.gt('_creationTime', cursor) : q,
|
||||
)
|
||||
.take(limit)
|
||||
return events
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* Get the current cursor position from the cursors table.
|
||||
*/
|
||||
export const getStatEventCursor = internalQuery({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
const cursor = await ctx.db
|
||||
.query('skillStatUpdateCursors')
|
||||
.withIndex('by_key', (q) => q.eq('key', CURSOR_KEY))
|
||||
.unique()
|
||||
return cursor?.cursorCreationTime
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* Validator for skill deltas passed to the mutation.
|
||||
*/
|
||||
const skillDeltaValidator = v.object({
|
||||
skillId: v.id('skills'),
|
||||
downloads: v.number(),
|
||||
stars: v.number(),
|
||||
installsAllTime: v.number(),
|
||||
installsCurrent: v.number(),
|
||||
downloadEvents: v.array(v.number()),
|
||||
installNewEvents: v.array(v.number()),
|
||||
})
|
||||
|
||||
/**
|
||||
* Apply aggregated stats to skills and update the cursor.
|
||||
* This is a single atomic mutation that:
|
||||
* 1. Updates all affected skills with their aggregated deltas
|
||||
* 2. Updates daily stats for trending
|
||||
* 3. Advances the cursor to the new position
|
||||
*/
|
||||
export const applyAggregatedStatsAndUpdateCursor = internalMutation({
|
||||
args: {
|
||||
skillDeltas: v.array(skillDeltaValidator),
|
||||
newCursor: v.number(),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const now = Date.now()
|
||||
|
||||
// Process each skill's aggregated deltas
|
||||
for (const delta of args.skillDeltas) {
|
||||
const skill = await ctx.db.get(delta.skillId)
|
||||
|
||||
// Skill was deleted - skip
|
||||
if (!skill) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Apply aggregated deltas to skill stats
|
||||
if (
|
||||
delta.downloads !== 0 ||
|
||||
delta.stars !== 0 ||
|
||||
delta.installsAllTime !== 0 ||
|
||||
delta.installsCurrent !== 0
|
||||
) {
|
||||
const patch = applySkillStatDeltas(skill, {
|
||||
downloads: delta.downloads,
|
||||
stars: delta.stars,
|
||||
installsAllTime: delta.installsAllTime,
|
||||
installsCurrent: delta.installsCurrent,
|
||||
})
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: now,
|
||||
})
|
||||
}
|
||||
|
||||
// Update daily stats for trending/leaderboards
|
||||
for (const occurredAt of delta.downloadEvents) {
|
||||
await bumpDailySkillStats(ctx, { skillId: delta.skillId, now: occurredAt, downloads: 1 })
|
||||
}
|
||||
for (const occurredAt of delta.installNewEvents) {
|
||||
await bumpDailySkillStats(ctx, { skillId: delta.skillId, now: occurredAt, installs: 1 })
|
||||
}
|
||||
}
|
||||
|
||||
// Update cursor position (upsert)
|
||||
const existingCursor = await ctx.db
|
||||
.query('skillStatUpdateCursors')
|
||||
.withIndex('by_key', (q) => q.eq('key', CURSOR_KEY))
|
||||
.unique()
|
||||
|
||||
if (existingCursor) {
|
||||
await ctx.db.patch(existingCursor._id, {
|
||||
cursorCreationTime: args.newCursor,
|
||||
updatedAt: now,
|
||||
})
|
||||
} else {
|
||||
await ctx.db.insert('skillStatUpdateCursors', {
|
||||
key: CURSOR_KEY,
|
||||
cursorCreationTime: args.newCursor,
|
||||
updatedAt: now,
|
||||
})
|
||||
}
|
||||
|
||||
return { skillsUpdated: args.skillDeltas.length }
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* Action that processes skill stat events in batches outside the transaction window.
|
||||
*
|
||||
* Algorithm:
|
||||
* 1. Get current cursor position
|
||||
* 2. Fetch events in batches of 500, aggregating as we go
|
||||
* 3. Stop when we have >= 500 unique skills OR run out of events
|
||||
* 4. Call mutation to apply all deltas and update cursor atomically
|
||||
* 5. Self-schedule if we stopped due to skill limit (not exhaustion)
|
||||
*/
|
||||
export const processSkillStatEventsAction = internalAction({
|
||||
args: {},
|
||||
handler: async (ctx) => {
|
||||
// Get current cursor position (convert null to undefined for consistency)
|
||||
const cursorResult = await ctx.runQuery(internal.skillStatEvents.getStatEventCursor)
|
||||
let cursor: number | undefined = cursorResult ?? undefined
|
||||
|
||||
console.log(`[STAT-AGG] Starting aggregation, cursor=${cursor ?? 'none'}`)
|
||||
|
||||
// Aggregated deltas per skill
|
||||
const aggregatedBySkill = new Map<
|
||||
Id<'skills'>,
|
||||
{
|
||||
downloads: number
|
||||
stars: number
|
||||
installsAllTime: number
|
||||
installsCurrent: number
|
||||
downloadEvents: number[]
|
||||
installNewEvents: number[]
|
||||
}
|
||||
>()
|
||||
|
||||
let maxCreationTime: number | undefined = cursor
|
||||
let exhausted = false
|
||||
let totalEventsFetched = 0
|
||||
|
||||
// Fetch and aggregate until we have enough skills or run out of events
|
||||
while (aggregatedBySkill.size < MAX_SKILLS_PER_RUN) {
|
||||
const events = await ctx.runQuery(internal.skillStatEvents.getUnprocessedEventBatch, {
|
||||
cursorCreationTime: cursor,
|
||||
limit: EVENT_BATCH_SIZE,
|
||||
})
|
||||
|
||||
if (events.length === 0) {
|
||||
exhausted = true
|
||||
break
|
||||
}
|
||||
|
||||
totalEventsFetched += events.length
|
||||
const skillsBefore = aggregatedBySkill.size
|
||||
|
||||
// Aggregate events into per-skill deltas
|
||||
for (const event of events) {
|
||||
let skillDelta = aggregatedBySkill.get(event.skillId)
|
||||
if (!skillDelta) {
|
||||
skillDelta = {
|
||||
downloads: 0,
|
||||
stars: 0,
|
||||
installsAllTime: 0,
|
||||
installsCurrent: 0,
|
||||
downloadEvents: [],
|
||||
installNewEvents: [],
|
||||
}
|
||||
aggregatedBySkill.set(event.skillId, skillDelta)
|
||||
}
|
||||
|
||||
// Apply event to aggregated deltas
|
||||
switch (event.kind) {
|
||||
case 'download':
|
||||
skillDelta.downloads += 1
|
||||
skillDelta.downloadEvents.push(event.occurredAt)
|
||||
break
|
||||
case 'star':
|
||||
skillDelta.stars += 1
|
||||
break
|
||||
case 'unstar':
|
||||
skillDelta.stars -= 1
|
||||
break
|
||||
case 'install_new':
|
||||
skillDelta.installsAllTime += 1
|
||||
skillDelta.installsCurrent += 1
|
||||
skillDelta.installNewEvents.push(event.occurredAt)
|
||||
break
|
||||
case 'install_reactivate':
|
||||
skillDelta.installsCurrent += 1
|
||||
break
|
||||
case 'install_deactivate':
|
||||
skillDelta.installsCurrent -= 1
|
||||
break
|
||||
case 'install_clear':
|
||||
if (event.delta) {
|
||||
skillDelta.installsAllTime += event.delta.allTime
|
||||
skillDelta.installsCurrent += event.delta.current
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
// Track highest _creationTime seen
|
||||
if (maxCreationTime === undefined || event._creationTime > maxCreationTime) {
|
||||
maxCreationTime = event._creationTime
|
||||
}
|
||||
}
|
||||
|
||||
// Update cursor for next batch fetch
|
||||
cursor = events[events.length - 1]._creationTime
|
||||
|
||||
console.log(
|
||||
`[STAT-AGG] Fetched ${events.length} events, ${aggregatedBySkill.size - skillsBefore} new skills (${aggregatedBySkill.size} total)`,
|
||||
)
|
||||
|
||||
// If we got fewer than requested, we've exhausted the events
|
||||
if (events.length < EVENT_BATCH_SIZE) {
|
||||
exhausted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If we have nothing to process, we're done
|
||||
if (aggregatedBySkill.size === 0 || maxCreationTime === undefined) {
|
||||
console.log('[STAT-AGG] No events to process, done')
|
||||
return { processed: 0, skillsUpdated: 0, exhausted: true }
|
||||
}
|
||||
|
||||
// Convert map to array for mutation
|
||||
const skillDeltas = Array.from(aggregatedBySkill.entries()).map(([skillId, delta]) => ({
|
||||
skillId,
|
||||
...delta,
|
||||
}))
|
||||
|
||||
console.log(
|
||||
`[STAT-AGG] Running mutation for ${skillDeltas.length} skills (${totalEventsFetched} total events)`,
|
||||
)
|
||||
|
||||
// Apply all deltas and update cursor atomically
|
||||
await ctx.runMutation(internal.skillStatEvents.applyAggregatedStatsAndUpdateCursor, {
|
||||
skillDeltas,
|
||||
newCursor: maxCreationTime,
|
||||
})
|
||||
|
||||
// Self-schedule if we stopped because of skill limit, not exhaustion
|
||||
if (!exhausted) {
|
||||
console.log('[STAT-AGG] More events remaining, self-scheduling')
|
||||
await ctx.scheduler.runAfter(0, internal.skillStatEvents.processSkillStatEventsAction, {})
|
||||
} else {
|
||||
console.log('[STAT-AGG] All events processed, done')
|
||||
}
|
||||
|
||||
return {
|
||||
skillsUpdated: skillDeltas.length,
|
||||
exhausted,
|
||||
}
|
||||
},
|
||||
})
|
||||
+782
-49
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
import { v } from 'convex/values'
|
||||
import type { Doc } from './_generated/dataModel'
|
||||
import { mutation, query } from './_generated/server'
|
||||
import { assertRole, requireUser } from './lib/access'
|
||||
import { assertModerator, requireUser } from './lib/access'
|
||||
import { type PublicUser, toPublicUser } from './lib/public'
|
||||
|
||||
export const listBySoul = query({
|
||||
args: { soulId: v.id('souls'), limit: v.optional(v.number()) },
|
||||
@@ -13,10 +14,10 @@ export const listBySoul = query({
|
||||
.order('desc')
|
||||
.take(limit)
|
||||
|
||||
const results: Array<{ comment: Doc<'soulComments'>; user: Doc<'users'> | null }> = []
|
||||
const results: Array<{ comment: Doc<'soulComments'>; user: PublicUser | null }> = []
|
||||
for (const comment of comments) {
|
||||
if (comment.softDeletedAt) continue
|
||||
const user = await ctx.db.get(comment.userId)
|
||||
const user = toPublicUser(await ctx.db.get(comment.userId))
|
||||
results.push({ comment, user })
|
||||
}
|
||||
return results
|
||||
@@ -59,7 +60,7 @@ export const remove = mutation({
|
||||
|
||||
const isOwner = comment.userId === user._id
|
||||
if (!isOwner) {
|
||||
assertRole(user, ['admin', 'moderator'])
|
||||
assertModerator(user)
|
||||
}
|
||||
|
||||
await ctx.db.patch(comment._id, {
|
||||
|
||||
+5
-3
@@ -1,7 +1,7 @@
|
||||
import { v } from 'convex/values'
|
||||
import type { Doc } from './_generated/dataModel'
|
||||
import { mutation, query } from './_generated/server'
|
||||
import { requireUser } from './lib/access'
|
||||
import { toPublicSoul } from './lib/public'
|
||||
|
||||
export const isStarred = query({
|
||||
args: { soulId: v.id('souls') },
|
||||
@@ -59,10 +59,12 @@ export const listByUser = query({
|
||||
.order('desc')
|
||||
.take(limit)
|
||||
|
||||
const souls: Doc<'souls'>[] = []
|
||||
const souls: NonNullable<ReturnType<typeof toPublicSoul>>[] = []
|
||||
for (const star of stars) {
|
||||
const soul = await ctx.db.get(star.soulId)
|
||||
if (soul) souls.push(soul)
|
||||
const publicSoul = toPublicSoul(soul)
|
||||
if (!publicSoul) continue
|
||||
souls.push(publicSoul)
|
||||
}
|
||||
return souls
|
||||
},
|
||||
|
||||
+25
-9
@@ -2,7 +2,8 @@ import { ConvexError, v } from 'convex/values'
|
||||
import { internal } from './_generated/api'
|
||||
import type { Doc, Id } from './_generated/dataModel'
|
||||
import { action, internalMutation, internalQuery, mutation, query } from './_generated/server'
|
||||
import { assertRole, requireUser, requireUserFromAction } from './lib/access'
|
||||
import { assertModerator, requireUser, requireUserFromAction } from './lib/access'
|
||||
import { toPublicSoul, toPublicUser } from './lib/public'
|
||||
import { getFrontmatterValue, hashSkillFiles } from './lib/skills'
|
||||
import { generateSoulChangelogPreview } from './lib/soulChangelog'
|
||||
import { fetchText, type PublishResult, publishSoulVersionForUser } from './lib/soulPublish'
|
||||
@@ -27,9 +28,11 @@ export const getBySlug = query({
|
||||
const soul = matches[0] ?? null
|
||||
if (!soul || soul.softDeletedAt) return null
|
||||
const latestVersion = soul.latestVersionId ? await ctx.db.get(soul.latestVersionId) : null
|
||||
const owner = await ctx.db.get(soul.ownerUserId)
|
||||
const owner = toPublicUser(await ctx.db.get(soul.ownerUserId))
|
||||
const publicSoul = toPublicSoul(soul)
|
||||
if (!publicSoul) return null
|
||||
|
||||
return { soul, latestVersion, owner }
|
||||
return { soul: publicSoul, latestVersion, owner }
|
||||
},
|
||||
})
|
||||
|
||||
@@ -59,13 +62,21 @@ export const list = query({
|
||||
.withIndex('by_owner', (q) => q.eq('ownerUserId', ownerUserId))
|
||||
.order('desc')
|
||||
.take(limit * 5)
|
||||
return entries.filter((soul) => !soul.softDeletedAt).slice(0, limit)
|
||||
return entries
|
||||
.filter((soul) => !soul.softDeletedAt)
|
||||
.slice(0, limit)
|
||||
.map((soul) => toPublicSoul(soul))
|
||||
.filter((soul): soul is NonNullable<typeof soul> => Boolean(soul))
|
||||
}
|
||||
const entries = await ctx.db
|
||||
.query('souls')
|
||||
.order('desc')
|
||||
.take(limit * 5)
|
||||
return entries.filter((soul) => !soul.softDeletedAt).slice(0, limit)
|
||||
return entries
|
||||
.filter((soul) => !soul.softDeletedAt)
|
||||
.slice(0, limit)
|
||||
.map((soul) => toPublicSoul(soul))
|
||||
.filter((soul): soul is NonNullable<typeof soul> => Boolean(soul))
|
||||
},
|
||||
})
|
||||
|
||||
@@ -82,12 +93,17 @@ export const listPublicPage = query({
|
||||
.order('desc')
|
||||
.paginate({ cursor: args.cursor ?? null, numItems: limit })
|
||||
|
||||
const items: Array<{ soul: Doc<'souls'>; latestVersion: Doc<'soulVersions'> | null }> = []
|
||||
const items: Array<{
|
||||
soul: NonNullable<ReturnType<typeof toPublicSoul>>
|
||||
latestVersion: Doc<'soulVersions'> | null
|
||||
}> = []
|
||||
|
||||
for (const soul of page) {
|
||||
if (soul.softDeletedAt) continue
|
||||
const latestVersion = soul.latestVersionId ? await ctx.db.get(soul.latestVersionId) : null
|
||||
items.push({ soul, latestVersion })
|
||||
const publicSoul = toPublicSoul(soul)
|
||||
if (!publicSoul) continue
|
||||
items.push({ soul: publicSoul, latestVersion })
|
||||
}
|
||||
|
||||
return { items, nextCursor: isDone ? null : continueCursor }
|
||||
@@ -309,7 +325,7 @@ export const updateTags = mutation({
|
||||
const soul = await ctx.db.get(args.soulId)
|
||||
if (!soul) throw new Error('Soul not found')
|
||||
if (soul.ownerUserId !== user._id) {
|
||||
assertRole(user, ['admin', 'moderator'])
|
||||
assertModerator(user)
|
||||
}
|
||||
|
||||
const nextTags = { ...soul.tags }
|
||||
@@ -506,7 +522,7 @@ export const setSoulSoftDeletedInternal = internalMutation({
|
||||
if (!soul) throw new Error('Soul not found')
|
||||
|
||||
if (soul.ownerUserId !== args.userId) {
|
||||
assertRole(user, ['admin', 'moderator'])
|
||||
assertModerator(user)
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
|
||||
+10
-21
@@ -1,8 +1,8 @@
|
||||
import { v } from 'convex/values'
|
||||
import type { Doc } from './_generated/dataModel'
|
||||
import { internalMutation, mutation, query } from './_generated/server'
|
||||
import { requireUser } from './lib/access'
|
||||
import { applySkillStatDeltas } from './lib/skillStats'
|
||||
import { toPublicSkill } from './lib/public'
|
||||
import { insertStatEvent } from './skillStatEvents'
|
||||
|
||||
export const isStarred = query({
|
||||
args: { skillId: v.id('skills') },
|
||||
@@ -30,11 +30,7 @@ export const toggle = mutation({
|
||||
|
||||
if (existing) {
|
||||
await ctx.db.delete(existing._id)
|
||||
const patch = applySkillStatDeltas(skill, { stars: -1 })
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: Date.now(),
|
||||
})
|
||||
await insertStatEvent(ctx, { skillId: skill._id, kind: 'unstar' })
|
||||
return { starred: false }
|
||||
}
|
||||
|
||||
@@ -44,10 +40,7 @@ export const toggle = mutation({
|
||||
createdAt: Date.now(),
|
||||
})
|
||||
|
||||
await ctx.db.patch(skill._id, {
|
||||
...applySkillStatDeltas(skill, { stars: 1 }),
|
||||
updatedAt: Date.now(),
|
||||
})
|
||||
await insertStatEvent(ctx, { skillId: skill._id, kind: 'star' })
|
||||
|
||||
return { starred: true }
|
||||
},
|
||||
@@ -62,10 +55,12 @@ export const listByUser = query({
|
||||
.withIndex('by_user', (q) => q.eq('userId', args.userId))
|
||||
.order('desc')
|
||||
.take(limit)
|
||||
const skills: Doc<'skills'>[] = []
|
||||
const skills: NonNullable<ReturnType<typeof toPublicSkill>>[] = []
|
||||
for (const star of stars) {
|
||||
const skill = await ctx.db.get(star.skillId)
|
||||
if (skill) skills.push(skill)
|
||||
const publicSkill = toPublicSkill(skill)
|
||||
if (!publicSkill) continue
|
||||
skills.push(publicSkill)
|
||||
}
|
||||
return skills
|
||||
},
|
||||
@@ -88,10 +83,7 @@ export const addStarInternal = internalMutation({
|
||||
createdAt: Date.now(),
|
||||
})
|
||||
|
||||
await ctx.db.patch(skill._id, {
|
||||
...applySkillStatDeltas(skill, { stars: 1 }),
|
||||
updatedAt: Date.now(),
|
||||
})
|
||||
await insertStatEvent(ctx, { skillId: skill._id, kind: 'star' })
|
||||
|
||||
return { ok: true as const, starred: true, alreadyStarred: false }
|
||||
},
|
||||
@@ -109,10 +101,7 @@ export const removeStarInternal = internalMutation({
|
||||
if (!existing) return { ok: true as const, unstarred: false, alreadyUnstarred: true }
|
||||
|
||||
await ctx.db.delete(existing._id)
|
||||
await ctx.db.patch(skill._id, {
|
||||
...applySkillStatDeltas(skill, { stars: -1 }),
|
||||
updatedAt: Date.now(),
|
||||
})
|
||||
await insertStatEvent(ctx, { skillId: skill._id, kind: 'unstar' })
|
||||
|
||||
return { ok: true as const, unstarred: true, alreadyUnstarred: false }
|
||||
},
|
||||
|
||||
+29
-29
@@ -4,7 +4,7 @@ import type { Id } from './_generated/dataModel'
|
||||
import type { MutationCtx, QueryCtx } from './_generated/server'
|
||||
import { internalMutation, mutation, query } from './_generated/server'
|
||||
import { requireUser } from './lib/access'
|
||||
import { applySkillStatDeltas, bumpDailySkillStats } from './lib/skillStats'
|
||||
import { insertStatEvent } from './skillStatEvents'
|
||||
|
||||
const TELEMETRY_STALE_MS = 120 * 24 * 60 * 60 * 1000
|
||||
|
||||
@@ -88,7 +88,13 @@ export const getMyInstalled = query({
|
||||
lastSeenAt: number
|
||||
expiredAt?: number
|
||||
skills: Array<{
|
||||
skill: { slug: string; displayName: string; summary?: string; stats: unknown }
|
||||
skill: {
|
||||
slug: string
|
||||
displayName: string
|
||||
summary?: string
|
||||
stats: unknown
|
||||
ownerUserId: Id<'users'>
|
||||
}
|
||||
firstSeenAt: number
|
||||
lastSeenAt: number
|
||||
lastVersion?: string
|
||||
@@ -105,7 +111,13 @@ export const getMyInstalled = query({
|
||||
|
||||
const filtered = includeRemoved ? installs : installs.filter((entry) => !entry.removedAt)
|
||||
const skills: Array<{
|
||||
skill: { slug: string; displayName: string; summary?: string; stats: unknown }
|
||||
skill: {
|
||||
slug: string
|
||||
displayName: string
|
||||
summary?: string
|
||||
stats: unknown
|
||||
ownerUserId: Id<'users'>
|
||||
}
|
||||
firstSeenAt: number
|
||||
lastSeenAt: number
|
||||
lastVersion?: string
|
||||
@@ -121,6 +133,7 @@ export const getMyInstalled = query({
|
||||
displayName: skill.displayName,
|
||||
summary: skill.summary,
|
||||
stats: skill.stats,
|
||||
ownerUserId: skill.ownerUserId,
|
||||
},
|
||||
firstSeenAt: entry.firstSeenAt,
|
||||
lastSeenAt: entry.lastSeenAt,
|
||||
@@ -158,13 +171,13 @@ async function clearTelemetryForUser(ctx: MutationCtx, params: { userId: Id<'use
|
||||
await ctx.db.delete(entry._id)
|
||||
continue
|
||||
}
|
||||
const patch = applySkillStatDeltas(skill, {
|
||||
installsCurrent: entry.activeRoots > 0 ? -1 : 0,
|
||||
installsAllTime: -1,
|
||||
})
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: Date.now(),
|
||||
await insertStatEvent(ctx, {
|
||||
skillId: skill._id,
|
||||
kind: 'install_clear',
|
||||
delta: {
|
||||
allTime: -1,
|
||||
current: entry.activeRoots > 0 ? -1 : 0,
|
||||
},
|
||||
})
|
||||
await ctx.db.delete(entry._id)
|
||||
}
|
||||
@@ -371,25 +384,12 @@ async function bumpSkillInstallCounts(
|
||||
ctx: MutationCtx,
|
||||
params: { skillId: Id<'skills'>; deltaAllTime: number; deltaCurrent: number },
|
||||
) {
|
||||
const skill = await ctx.db.get(params.skillId)
|
||||
if (!skill) return
|
||||
const now = Date.now()
|
||||
const patch = applySkillStatDeltas(skill, {
|
||||
installsAllTime: params.deltaAllTime,
|
||||
installsCurrent: params.deltaCurrent,
|
||||
})
|
||||
|
||||
await ctx.db.patch(skill._id, {
|
||||
...patch,
|
||||
updatedAt: now,
|
||||
})
|
||||
|
||||
if (params.deltaAllTime > 0) {
|
||||
await bumpDailySkillStats(ctx, {
|
||||
skillId: params.skillId,
|
||||
now,
|
||||
installs: params.deltaAllTime,
|
||||
})
|
||||
if (params.deltaAllTime === 1 && params.deltaCurrent === 1) {
|
||||
await insertStatEvent(ctx, { skillId: params.skillId, kind: 'install_new' })
|
||||
} else if (params.deltaAllTime === 0 && params.deltaCurrent === 1) {
|
||||
await insertStatEvent(ctx, { skillId: params.skillId, kind: 'install_reactivate' })
|
||||
} else if (params.deltaAllTime === 0 && params.deltaCurrent === -1) {
|
||||
await insertStatEvent(ctx, { skillId: params.skillId, kind: 'install_deactivate' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-5
@@ -1,13 +1,19 @@
|
||||
import { getAuthUserId } from '@convex-dev/auth/server'
|
||||
import { v } from 'convex/values'
|
||||
import { internal } from './_generated/api'
|
||||
import { mutation, query } from './_generated/server'
|
||||
import { assertRole, requireUser } from './lib/access'
|
||||
import { internalQuery, mutation, query } from './_generated/server'
|
||||
import { assertAdmin, requireUser } from './lib/access'
|
||||
import { toPublicUser } from './lib/public'
|
||||
|
||||
const DEFAULT_ROLE = 'user'
|
||||
const ADMIN_HANDLE = 'steipete'
|
||||
|
||||
export const getById = query({
|
||||
args: { userId: v.id('users') },
|
||||
handler: async (ctx, args) => toPublicUser(await ctx.db.get(args.userId)),
|
||||
})
|
||||
|
||||
export const getByIdInternal = internalQuery({
|
||||
args: { userId: v.id('users') },
|
||||
handler: async (ctx, args) => ctx.db.get(args.userId),
|
||||
})
|
||||
@@ -78,7 +84,7 @@ export const list = query({
|
||||
args: { limit: v.optional(v.number()) },
|
||||
handler: async (ctx, args) => {
|
||||
const { user } = await requireUser(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
assertAdmin(user)
|
||||
const limit = args.limit ?? 50
|
||||
return ctx.db.query('users').order('desc').take(limit)
|
||||
},
|
||||
@@ -87,10 +93,11 @@ export const list = query({
|
||||
export const getByHandle = query({
|
||||
args: { handle: v.string() },
|
||||
handler: async (ctx, args) => {
|
||||
return ctx.db
|
||||
const user = await ctx.db
|
||||
.query('users')
|
||||
.withIndex('handle', (q) => q.eq('handle', args.handle))
|
||||
.unique()
|
||||
return toPublicUser(user)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -101,7 +108,7 @@ export const setRole = mutation({
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const { user } = await requireUser(ctx)
|
||||
assertRole(user, ['admin'])
|
||||
assertAdmin(user)
|
||||
await ctx.db.patch(args.userId, { role: args.role, updatedAt: Date.now() })
|
||||
await ctx.db.insert('auditLogs', {
|
||||
actorUserId: user._id,
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ export const sendDiscordWebhook = internalAction({
|
||||
summary: v.optional(v.string()),
|
||||
version: v.optional(v.string()),
|
||||
ownerHandle: v.optional(v.string()),
|
||||
batch: v.optional(v.string()),
|
||||
highlighted: v.optional(v.boolean()),
|
||||
tags: v.optional(v.array(v.string())),
|
||||
}),
|
||||
},
|
||||
@@ -21,7 +21,7 @@ export const sendDiscordWebhook = internalAction({
|
||||
event: args.event,
|
||||
slug: args.skill.slug,
|
||||
version: args.skill.version ?? null,
|
||||
batch: args.skill.batch ?? null,
|
||||
highlighted: args.skill.highlighted ?? false,
|
||||
highlightedOnly: config.highlightedOnly,
|
||||
}
|
||||
if (!shouldSendWebhook(args.event, args.skill, config)) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ Reading order (new contributor):
|
||||
Feature/ops docs (already present):
|
||||
|
||||
- `docs/spec.md`: product + implementation spec (data model + flows).
|
||||
- `docs/telemetry.md`: what `clawdhub sync` reports; opt-out.
|
||||
- `docs/telemetry.md`: what `molthub sync` reports; opt-out.
|
||||
- `docs/webhook.md`: Discord webhook events/payload.
|
||||
- `docs/diffing.md`: version-to-version diff UI spec.
|
||||
- `docs/manual-testing.md`: CLI smoke scripts.
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ read_when:
|
||||
|
||||
# API v1
|
||||
|
||||
Base: `https://clawdhub.com`
|
||||
Base: `https://molthub.com`
|
||||
|
||||
OpenAPI: `/api/v1/openapi.json`
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ read_when:
|
||||
|
||||
- Web app: TanStack Start (React) under `src/`.
|
||||
- Backend: Convex under `convex/` (DB, storage, actions, HTTP routes).
|
||||
- CLI: `packages/clawdhub/` (published as `clawdhub`).
|
||||
- Shared schemas/routes: `packages/schema/` (`clawdhub-schema`).
|
||||
- CLI: `packages/molthub/` (published as `molthub`).
|
||||
- Shared schemas/routes: `packages/schema/` (`molthub-schema`).
|
||||
|
||||
## Data + storage
|
||||
|
||||
@@ -38,8 +38,8 @@ read_when:
|
||||
- Download zip via `/api/v1/download?slug=...&version=...`.
|
||||
- Extract into `./skills/<slug>` (default).
|
||||
- Persist install state:
|
||||
- `./.clawdhub/lock.json` (per workdir)
|
||||
- `./skills/<slug>/.clawdhub/origin.json` (per skill folder)
|
||||
- `./.molthub/lock.json` (per workdir)
|
||||
- `./skills/<slug>/.molthub/origin.json` (per skill folder)
|
||||
|
||||
### Update (CLI)
|
||||
|
||||
|
||||
+4
-4
@@ -23,7 +23,7 @@ The CLI uses a long-lived API token (Bearer token) for publish/sync/delete.
|
||||
|
||||
### Browser flow (default)
|
||||
|
||||
`clawdhub login` does:
|
||||
`molthub login` does:
|
||||
|
||||
1. Starts a loopback HTTP server on `127.0.0.1` (random port).
|
||||
2. Opens `<site>/cli/auth?redirect_uri=http://127.0.0.1:<port>/callback&state=...`.
|
||||
@@ -35,18 +35,18 @@ The CLI uses a long-lived API token (Bearer token) for publish/sync/delete.
|
||||
Create a token in the web UI (Settings → API tokens) and paste it:
|
||||
|
||||
```bash
|
||||
clawdhub login --token clh_...
|
||||
molthub login --token clh_...
|
||||
```
|
||||
|
||||
### Token storage
|
||||
|
||||
Default global config path:
|
||||
|
||||
- macOS: `~/Library/Application Support/clawdhub/config.json`
|
||||
- macOS: `~/Library/Application Support/molthub/config.json`
|
||||
|
||||
Override:
|
||||
|
||||
- `CLAWDHUB_CONFIG_PATH=/path/to/config.json`
|
||||
- `MOLTHUB_CONFIG_PATH=/path/to/config.json`
|
||||
|
||||
### Revocation
|
||||
|
||||
|
||||
+18
-18
@@ -7,41 +7,41 @@ read_when:
|
||||
|
||||
# CLI
|
||||
|
||||
CLI package: `packages/clawdhub/` (bin: `clawdhub`).
|
||||
CLI package: `packages/molthub/` (bin: `molthub`).
|
||||
|
||||
From this repo you can run it via the wrapper script:
|
||||
|
||||
```bash
|
||||
bun clawdhub --help
|
||||
bun molthub --help
|
||||
```
|
||||
|
||||
## Global flags
|
||||
|
||||
- `--workdir <dir>`: working directory (default: cwd; falls back to Clawdbot workspace if configured)
|
||||
- `--workdir <dir>`: working directory (default: cwd; falls back to Moltbot workspace if configured)
|
||||
- `--dir <dir>`: install dir under workdir (default: `skills`)
|
||||
- `--site <url>`: base URL for browser login (default: `https://clawdhub.com`)
|
||||
- `--registry <url>`: API base URL (default: discovered, else `https://clawdhub.com`)
|
||||
- `--site <url>`: base URL for browser login (default: `https://molthub.com`)
|
||||
- `--registry <url>`: API base URL (default: discovered, else `https://molthub.com`)
|
||||
- `--no-input`: disable prompts
|
||||
|
||||
Env equivalents:
|
||||
|
||||
- `CLAWDHUB_SITE`
|
||||
- `CLAWDHUB_REGISTRY`
|
||||
- `CLAWDHUB_WORKDIR`
|
||||
- `MOLTHUB_SITE`
|
||||
- `MOLTHUB_REGISTRY`
|
||||
- `MOLTHUB_WORKDIR`
|
||||
|
||||
## Config file
|
||||
|
||||
Stores your API token + cached registry URL.
|
||||
|
||||
- macOS: `~/Library/Application Support/clawdhub/config.json`
|
||||
- override: `CLAWDHUB_CONFIG_PATH`
|
||||
- macOS: `~/Library/Application Support/molthub/config.json`
|
||||
- override: `MOLTHUB_CONFIG_PATH`
|
||||
|
||||
## Commands
|
||||
|
||||
### `login` / `auth login`
|
||||
|
||||
- Default: opens browser to `<site>/cli/auth` and completes via loopback callback.
|
||||
- Headless: `clawdhub login --token clh_...`
|
||||
- Headless: `molthub login --token clh_...`
|
||||
|
||||
### `whoami`
|
||||
|
||||
@@ -72,12 +72,12 @@ Stores your API token + cached registry URL.
|
||||
- Downloads zip via `/api/v1/download`.
|
||||
- Extracts into `<workdir>/<dir>/<slug>`.
|
||||
- Writes:
|
||||
- `<workdir>/.clawdhub/lock.json`
|
||||
- `<skill>/.clawdhub/origin.json`
|
||||
- `<workdir>/.molthub/lock.json`
|
||||
- `<skill>/.molthub/origin.json`
|
||||
|
||||
### `list`
|
||||
|
||||
- Reads `<workdir>/.clawdhub/lock.json`.
|
||||
- Reads `<workdir>/.molthub/lock.json`.
|
||||
|
||||
### `update [slug]` / `update --all`
|
||||
|
||||
@@ -96,12 +96,12 @@ Stores your API token + cached registry URL.
|
||||
|
||||
- Scans for local skill folders and publishes new/changed ones.
|
||||
- Roots can be any folder: a skills directory or a single skill folder with `SKILL.md`.
|
||||
- Auto-adds Clawdbot skill roots when `~/.clawdbot/clawdbot.json` is present:
|
||||
- Auto-adds Moltbot skill roots when `~/.moltbot/moltbot.json` is present:
|
||||
- `agent.workspace/skills` (main agent)
|
||||
- `routing.agents.*.workspace/skills` (per-agent)
|
||||
- `~/.clawdbot/skills` (shared)
|
||||
- `~/.moltbot/skills` (shared)
|
||||
- `skills.load.extraDirs` (shared packs)
|
||||
- Respects `CLAWDBOT_CONFIG_PATH` and `CLAWDBOT_STATE_DIR`.
|
||||
- Respects `MOLTBOT_CONFIG_PATH` and `MOLTBOT_STATE_DIR`.
|
||||
- Flags:
|
||||
- `--root <dir...>` extra scan roots
|
||||
- `--all` upload without prompting
|
||||
@@ -113,5 +113,5 @@ Stores your API token + cached registry URL.
|
||||
|
||||
Telemetry:
|
||||
|
||||
- Sent during `sync` when logged in, unless `CLAWDHUB_DISABLE_TELEMETRY=1`.
|
||||
- Sent during `sync` when logged in, unless `MOLTHUB_DISABLE_TELEMETRY=1`.
|
||||
- Details: `docs/telemetry.md`.
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ read_when:
|
||||
|
||||
# Deploy
|
||||
|
||||
ClawdHub is two deployables:
|
||||
MoltHub is two deployables:
|
||||
|
||||
- Web app (TanStack Start) → typically Vercel.
|
||||
- Convex backend → Convex deployment (serves `/api/...` routes).
|
||||
@@ -55,12 +55,12 @@ For self-host:
|
||||
|
||||
The CLI can discover the API base from:
|
||||
|
||||
- `/.well-known/clawdhub.json`
|
||||
- `/.well-known/molthub.json`
|
||||
|
||||
If you don’t serve that file, users must set:
|
||||
|
||||
```bash
|
||||
export CLAWDHUB_REGISTRY=https://your-site.example
|
||||
export MOLTHUB_REGISTRY=https://your-site.example
|
||||
```
|
||||
|
||||
## 5) Post-deploy checks
|
||||
@@ -73,6 +73,6 @@ curl -i "https://<site>/api/v1/skills/gifgrep"
|
||||
Then:
|
||||
|
||||
```bash
|
||||
clawdhub login --site https://<site>
|
||||
clawdhub whoami
|
||||
molthub login --site https://<site>
|
||||
molthub whoami
|
||||
```
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ read_when:
|
||||
## Goals
|
||||
- Compare any file between two versions.
|
||||
- Default compare: `latest` vs `previous` (SemVer precedence).
|
||||
- UX feels native to ClawdHub (theme + typography + motion).
|
||||
- UX feels native to MoltHub (theme + typography + motion).
|
||||
- Inline or side-by-side toggle.
|
||||
- Public access.
|
||||
|
||||
@@ -57,7 +57,7 @@ Optional helper action:
|
||||
- Feed into Monaco diff editor.
|
||||
|
||||
## Monaco theming
|
||||
- Define `clawdhub-light` / `clawdhub-dark` via `monaco.editor.defineTheme`.
|
||||
- Define `molthub-light` / `molthub-dark` via `monaco.editor.defineTheme`.
|
||||
- Derive colors from CSS variables on `document.documentElement`:
|
||||
- `--surface`, `--surface-muted`, `--ink`, `--ink-soft`, `--line`, `--accent`.
|
||||
- Apply theme on load + when theme changes (`data-theme`).
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ read_when:
|
||||
|
||||
# HTTP API
|
||||
|
||||
Base URL: `https://clawdhub.com` (default).
|
||||
Base URL: `https://molthub.com` (default).
|
||||
|
||||
All v1 paths are under `/api/v1/...` and implemented by Convex HTTP routes (`convex/http.ts`).
|
||||
Legacy `/api/...` and `/api/cli/...` remain for compatibility (see `DEPRECATIONS.md`).
|
||||
@@ -172,16 +172,16 @@ Still supported for older CLI versions:
|
||||
|
||||
See `DEPRECATIONS.md` for removal plan.
|
||||
|
||||
## Registry discovery (`/.well-known/clawdhub.json`)
|
||||
## Registry discovery (`/.well-known/molthub.json`)
|
||||
|
||||
The CLI can discover registry/auth settings from the site:
|
||||
|
||||
- `/.well-known/clawdhub.json` (JSON)
|
||||
- `/.well-known/molthub.json` (JSON)
|
||||
|
||||
Schema:
|
||||
|
||||
```json
|
||||
{ "apiBase": "https://clawdhub.com", "authBase": "https://clawdhub.com", "minCliVersion": "0.0.5" }
|
||||
{ "apiBase": "https://molthub.com", "authBase": "https://molthub.com", "minCliVersion": "0.0.5" }
|
||||
```
|
||||
|
||||
If you self-host, serve this file (or set `CLAWDHUB_REGISTRY` explicitly).
|
||||
If you self-host, serve this file (or set `MOLTHUB_REGISTRY` explicitly).
|
||||
|
||||
+20
-20
@@ -8,53 +8,53 @@ read_when:
|
||||
# Manual testing (CLI)
|
||||
|
||||
## Setup
|
||||
- Ensure logged in: `bun clawdhub whoami` (or `bun clawdhub login`).
|
||||
- Ensure logged in: `bun molthub whoami` (or `bun molthub login`).
|
||||
- Optional: set env
|
||||
- `CLAWDHUB_SITE=https://clawdhub.com`
|
||||
- `CLAWDHUB_REGISTRY=https://clawdhub.com`
|
||||
- `MOLTHUB_SITE=https://molthub.com`
|
||||
- `MOLTHUB_REGISTRY=https://molthub.com`
|
||||
|
||||
## Smoke
|
||||
- `bun clawdhub --help`
|
||||
- `bun clawdhub --cli-version`
|
||||
- `bun clawdhub whoami`
|
||||
- `bun molthub --help`
|
||||
- `bun molthub --cli-version`
|
||||
- `bun molthub whoami`
|
||||
|
||||
## Search
|
||||
- `bun clawdhub search gif --limit 5`
|
||||
- `bun molthub search gif --limit 5`
|
||||
|
||||
## Install / list / update
|
||||
- `mkdir -p /tmp/clawdhub-manual && cd /tmp/clawdhub-manual`
|
||||
- `bunx clawdhub@beta install gifgrep --force`
|
||||
- `bunx clawdhub@beta list`
|
||||
- `bunx clawdhub@beta update gifgrep --force`
|
||||
- `mkdir -p /tmp/molthub-manual && cd /tmp/molthub-manual`
|
||||
- `bunx molthub@beta install gifgrep --force`
|
||||
- `bunx molthub@beta list`
|
||||
- `bunx molthub@beta update gifgrep --force`
|
||||
|
||||
## Publish (changelog optional)
|
||||
- `mkdir -p /tmp/clawdhub-skill-demo/SKILL && cd /tmp/clawdhub-skill-demo`
|
||||
- `mkdir -p /tmp/molthub-skill-demo/SKILL && cd /tmp/molthub-skill-demo`
|
||||
- Create files:
|
||||
- `SKILL.md`
|
||||
- `notes.md`
|
||||
- Publish:
|
||||
- `bun clawdhub publish . --slug clawdhub-manual-<ts> --name "Manual <ts>" --version 1.0.0 --tags latest`
|
||||
- `bun molthub publish . --slug molthub-manual-<ts> --name "Manual <ts>" --version 1.0.0 --tags latest`
|
||||
- Publish update with empty changelog:
|
||||
- `bun clawdhub publish . --slug clawdhub-manual-<ts> --name "Manual <ts>" --version 1.0.1 --tags latest`
|
||||
- `bun molthub publish . --slug molthub-manual-<ts> --name "Manual <ts>" --version 1.0.1 --tags latest`
|
||||
|
||||
## Delete / undelete (owner/admin)
|
||||
- `bun clawdhub delete clawdhub-manual-<ts> --yes`
|
||||
- `bun molthub delete molthub-manual-<ts> --yes`
|
||||
- Verify hidden:
|
||||
- `curl -i "https://clawdhub.com/api/v1/skills/clawdhub-manual-<ts>"`
|
||||
- `curl -i "https://molthub.com/api/v1/skills/molthub-manual-<ts>"`
|
||||
- Restore:
|
||||
- `bun clawdhub undelete clawdhub-manual-<ts> --yes`
|
||||
- `bun molthub undelete molthub-manual-<ts> --yes`
|
||||
- Cleanup:
|
||||
- `bun clawdhub delete clawdhub-manual-<ts> --yes`
|
||||
- `bun molthub delete molthub-manual-<ts> --yes`
|
||||
|
||||
## Sync
|
||||
- `bun clawdhub sync --dry-run --all`
|
||||
- `bun molthub sync --dry-run --all`
|
||||
|
||||
## Playwright (menu smoke)
|
||||
|
||||
Run against prod:
|
||||
|
||||
```
|
||||
PLAYWRIGHT_BASE_URL=https://clawdhub.com bun run test:pw
|
||||
PLAYWRIGHT_BASE_URL=https://molthub.com bun run test:pw
|
||||
```
|
||||
|
||||
Run against a local preview server:
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ Example (starter):
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "ClawdHub",
|
||||
"name": "MoltHub",
|
||||
"logo": "public/logo.svg",
|
||||
"navigation": [
|
||||
{ "group": "Start", "pages": ["docs/README", "docs/quickstart"] },
|
||||
|
||||
+14
-14
@@ -51,29 +51,29 @@ Then paste the printed `JWT_PRIVATE_KEY` + `JWKS` into `.env.local` (and ensure
|
||||
From this repo:
|
||||
|
||||
```bash
|
||||
bun clawdhub --help
|
||||
bun clawdhub login
|
||||
bun clawdhub whoami
|
||||
bun clawdhub search gif --limit 5
|
||||
bun molthub --help
|
||||
bun molthub login
|
||||
bun molthub whoami
|
||||
bun molthub search gif --limit 5
|
||||
```
|
||||
|
||||
Install a skill into `./skills/<slug>` (if Clawdbot is configured, installs into that workspace instead):
|
||||
Install a skill into `./skills/<slug>` (if Moltbot is configured, installs into that workspace instead):
|
||||
|
||||
```bash
|
||||
bun clawdhub install <slug>
|
||||
bun clawdhub list
|
||||
bun molthub install <slug>
|
||||
bun molthub list
|
||||
```
|
||||
|
||||
You can also install into any folder:
|
||||
|
||||
```bash
|
||||
bun clawdhub install <slug> --workdir /tmp/clawdhub-demo --dir skills
|
||||
bun molthub install <slug> --workdir /tmp/molthub-demo --dir skills
|
||||
```
|
||||
|
||||
Update:
|
||||
|
||||
```bash
|
||||
bun clawdhub update --all
|
||||
bun molthub update --all
|
||||
```
|
||||
|
||||
## 4) Publish a skill
|
||||
@@ -81,7 +81,7 @@ bun clawdhub update --all
|
||||
Create a folder containing `SKILL.md` (required) plus any supporting text files:
|
||||
|
||||
```bash
|
||||
mkdir -p /tmp/clawdhub-skill-demo && cd /tmp/clawdhub-skill-demo
|
||||
mkdir -p /tmp/molthub-skill-demo && cd /tmp/molthub-skill-demo
|
||||
cat > SKILL.md <<'EOF'
|
||||
---
|
||||
name: Demo Skill
|
||||
@@ -97,8 +97,8 @@ EOF
|
||||
Publish:
|
||||
|
||||
```bash
|
||||
bun clawdhub publish . \
|
||||
--slug clawdhub-demo-$(date +%s) \
|
||||
bun molthub publish . \
|
||||
--slug molthub-demo-$(date +%s) \
|
||||
--name "Demo $(date +%s)" \
|
||||
--version 1.0.0 \
|
||||
--tags latest \
|
||||
@@ -110,11 +110,11 @@ bun clawdhub publish . \
|
||||
`sync` scans for local skill folders and publishes the ones that aren’t “synced” yet.
|
||||
|
||||
```bash
|
||||
bun clawdhub sync
|
||||
bun molthub sync
|
||||
```
|
||||
|
||||
Dry run + non-interactive:
|
||||
|
||||
```bash
|
||||
bun clawdhub sync --all --dry-run --no-input
|
||||
bun molthub sync --all --dry-run --no-input
|
||||
```
|
||||
|
||||
@@ -18,16 +18,16 @@ Required:
|
||||
Optional:
|
||||
|
||||
- any supporting *text-based* files (see “Allowed files”)
|
||||
- `.clawdhubignore` (ignore patterns for publish/sync)
|
||||
- `.molthubignore` (ignore patterns for publish/sync)
|
||||
- `.gitignore` (also honored)
|
||||
|
||||
Local install metadata (written by the CLI):
|
||||
|
||||
- `<skill>/.clawdhub/origin.json`
|
||||
- `<skill>/.molthub/origin.json`
|
||||
|
||||
Workdir install state (written by the CLI):
|
||||
|
||||
- `<workdir>/.clawdhub/lock.json`
|
||||
- `<workdir>/.molthub/lock.json`
|
||||
|
||||
## `SKILL.md`
|
||||
|
||||
|
||||
+18
-12
@@ -1,18 +1,18 @@
|
||||
---
|
||||
summary: "ClawdHub spec: skills registry, versioning, vector search, moderation"
|
||||
summary: "MoltHub spec: skills registry, versioning, vector search, moderation"
|
||||
read_when:
|
||||
- Bootstrapping ClawdHub
|
||||
- Bootstrapping MoltHub
|
||||
- Implementing schema/auth/search/versioning
|
||||
- Reviewing API and upload/download flows
|
||||
---
|
||||
|
||||
# ClawdHub — product + implementation spec (v1)
|
||||
# MoltHub — product + implementation spec (v1)
|
||||
|
||||
## Goals
|
||||
- onlycrabs.ai mode for sharing `SOUL.md` bundles (host-based entry point).
|
||||
- Minimal, fast SPA for browsing and publishing agent skills.
|
||||
- Skills stored in Convex (files + metadata + versions + stats).
|
||||
- GitHub OAuth login; GitHub App backs up skills to `clawdbot/skills`.
|
||||
- GitHub OAuth login; GitHub App backs up skills to `moltbot/skills`.
|
||||
- Vector-based search over skill text + metadata.
|
||||
- Versioning, tags (`latest` + user tags), changelog, rollback (tag movement).
|
||||
- Public read access; upload requires auth.
|
||||
@@ -29,7 +29,7 @@ read_when:
|
||||
- `handle` (GitHub login)
|
||||
- `name`, `bio`
|
||||
- `avatarUrl` (GitHub, fallback gravatar)
|
||||
- `role`: `admin | moderator | user`
|
||||
- `role`: `admin | moderator | user` (moderators can soft-delete and flag; admins can hard-delete + change owners)
|
||||
- `createdAt`, `updatedAt`
|
||||
|
||||
### Skill
|
||||
@@ -40,9 +40,14 @@ read_when:
|
||||
- `latestVersionId`
|
||||
- `latestTagVersionId` (for `latest` tag)
|
||||
- `tags` map: `{ tag -> versionId }`
|
||||
- `badges`: `{ redactionApproved?: { byUserId, at } }`
|
||||
- `badges`: `{ redactionApproved?: { byUserId, at }, highlighted?: { byUserId, at }, official?: { byUserId, at }, deprecated?: { byUserId, at } }`
|
||||
- `official` marks admin-verified/official skills.
|
||||
- `deprecated` marks skills that should not be used for new integrations.
|
||||
- `moderationStatus`: `active | hidden | removed`
|
||||
- `moderationFlags`: `string[]` (automatic detection)
|
||||
- `moderationNotes`, `moderationReason`
|
||||
- `hiddenAt`, `hiddenBy`, `lastReviewedAt`, `reportCount`
|
||||
- `stats`: `{ downloads, stars, versions, comments }`
|
||||
- `status`: `active` only (soft-delete on version/comment only)
|
||||
- `createdAt`, `updatedAt`
|
||||
|
||||
### SkillVersion
|
||||
@@ -58,12 +63,12 @@ read_when:
|
||||
- `softDeletedAt` (nullable)
|
||||
|
||||
### Parsed Skill Metadata
|
||||
From SKILL.md frontmatter + AgentSkills + Clawdis extensions:
|
||||
From SKILL.md frontmatter + AgentSkills + Moltbot extensions:
|
||||
- `name`, `description`, `homepage`, `website`, `url`, `emoji`
|
||||
- `metadata.clawdis`: `always`, `skillKey`, `primaryEnv`, `emoji`, `homepage`, `os`,
|
||||
- `metadata.moltbot`: `always`, `skillKey`, `primaryEnv`, `emoji`, `homepage`, `os`,
|
||||
`requires` (`bins`, `anyBins`, `env`, `config`), `install[]`, `nix` (`plugin`, `systems`),
|
||||
`config` (`requiredEnv`, `stateDirs`, `example`), `cliHelp` (string; `cli --help` output)
|
||||
- `metadata.clawdbot`: alias of `metadata.clawdis` (preferred for nix-clawdbot plugin pointers)
|
||||
- `metadata.moltbot`: alias of `metadata.moltbot` (preferred for nix-moltbot plugin pointers)
|
||||
- Nix plugins are different from regular skills; they bundle the skill pack, the CLI binary, and config flags/requirements together.
|
||||
- `metadata` in frontmatter is YAML (object) preferred; legacy JSON-string accepted.
|
||||
|
||||
@@ -118,7 +123,8 @@ From SKILL.md frontmatter + AgentSkills + Clawdis extensions:
|
||||
## Auth + roles
|
||||
- Convex Auth with GitHub OAuth App.
|
||||
- Default role `user`; bootstrap `steipete` to `admin` on first login.
|
||||
- Admin UI to promote/demote roles; all changes logged.
|
||||
- Management console: moderators can hide/restore skills + mark duplicates; admins can change owners, approve badges, and hard-delete.
|
||||
- Role changes are admin-only and audited.
|
||||
|
||||
## Upload flow (50MB per version)
|
||||
1) Client requests upload session.
|
||||
@@ -151,7 +157,7 @@ Seed data lives in `convex/seed.ts` for local dev.
|
||||
- Soft-delete versions; downloads remain for non-deleted versions only.
|
||||
|
||||
## UI (SPA)
|
||||
- Home: search + filters + trending/featured + “Highlighted” batch.
|
||||
- Home: search + filters + trending/featured + “Highlighted” badge.
|
||||
- Skill detail: README render, files list, version history, tags, stats, badges.
|
||||
- Upload/edit: file picker + version + tag + changelog.
|
||||
- Account settings: name + delete account (soft delete).
|
||||
|
||||
+8
-8
@@ -1,5 +1,5 @@
|
||||
---
|
||||
summary: 'Install telemetry collected via `clawdhub sync` + opt-out.'
|
||||
summary: 'Install telemetry collected via `molthub sync` + opt-out.'
|
||||
read_when:
|
||||
- Working on telemetry / privacy controls
|
||||
- Questions about what data is collected
|
||||
@@ -7,22 +7,22 @@ read_when:
|
||||
|
||||
# Telemetry
|
||||
|
||||
ClawdHub uses **minimal telemetry** to compute **install counts** (what’s actually in use) and to power better sorting/filtering.
|
||||
This is based on the CLI `clawdhub sync` command.
|
||||
MoltHub uses **minimal telemetry** to compute **install counts** (what’s actually in use) and to power better sorting/filtering.
|
||||
This is based on the CLI `molthub sync` command.
|
||||
|
||||
## When telemetry is collected
|
||||
|
||||
Telemetry is only sent when:
|
||||
|
||||
- You are **logged in** in the CLI (we already require auth for sync/publish flows).
|
||||
- You run `clawdhub sync`.
|
||||
- You run `molthub sync`.
|
||||
- Telemetry is **not disabled** (see “How to disable” below).
|
||||
|
||||
If you are not logged in, nothing is reported.
|
||||
|
||||
## What we collect
|
||||
|
||||
On each `clawdhub sync`, the CLI reports a **full snapshot** of what it found, grouped by scan root (“folder/root”).
|
||||
On each `molthub sync`, the CLI reports a **full snapshot** of what it found, grouped by scan root (“folder/root”).
|
||||
|
||||
For each root we store:
|
||||
|
||||
@@ -70,7 +70,7 @@ This is evaluated lazily (on the next telemetry report) to avoid background jobs
|
||||
|
||||
## Transparency + user controls
|
||||
|
||||
ClawdHub provides a private “Installed” tab on your own profile:
|
||||
MoltHub provides a private “Installed” tab on your own profile:
|
||||
|
||||
- Shows the exact roots + installed skills we store.
|
||||
- Includes a **JSON export** view.
|
||||
@@ -85,7 +85,7 @@ Deleting your account also deletes your telemetry data.
|
||||
Set the environment variable:
|
||||
|
||||
```bash
|
||||
export CLAWDHUB_DISABLE_TELEMETRY=1
|
||||
export MOLTHUB_DISABLE_TELEMETRY=1
|
||||
```
|
||||
|
||||
With this set, the CLI will not send telemetry during `clawdhub sync`.
|
||||
With this set, the CLI will not send telemetry during `molthub sync`.
|
||||
|
||||
@@ -6,16 +6,16 @@ read_when:
|
||||
|
||||
# Troubleshooting
|
||||
|
||||
## `clawdhub login` opens browser but never completes
|
||||
## `molthub login` opens browser but never completes
|
||||
|
||||
- Ensure your browser can reach `http://127.0.0.1:<port>/callback` (local firewalls/VPNs can interfere).
|
||||
- Use headless mode:
|
||||
- create a token in the web UI (Settings → API tokens)
|
||||
- `clawdhub login --token clh_...`
|
||||
- `molthub login --token clh_...`
|
||||
|
||||
## `whoami` / `publish` returns `Unauthorized` (401)
|
||||
|
||||
- Token missing or revoked: check your config file (`CLAWDHUB_CONFIG_PATH` override?).
|
||||
- Token missing or revoked: check your config file (`MOLTHUB_CONFIG_PATH` override?).
|
||||
- Ensure requests include `Authorization: Bearer ...` (CLI does this automatically).
|
||||
|
||||
## `publish` fails with `OPENAI_API_KEY is not configured`
|
||||
@@ -28,11 +28,11 @@ read_when:
|
||||
- `sync` looks for folders containing `SKILL.md` (or `skill.md`).
|
||||
- It scans:
|
||||
- workdir first
|
||||
- then fallback roots (legacy `~/clawdis/skills`, `~/clawdbot/skills`, etc.)
|
||||
- then fallback roots (legacy `~/moltbot/skills`, `~/moltbot/skills`, etc.)
|
||||
- Provide explicit roots:
|
||||
|
||||
```bash
|
||||
clawdhub sync --root /path/to/skills
|
||||
molthub sync --root /path/to/skills
|
||||
```
|
||||
|
||||
## `update` refuses due to “local changes (no match)”
|
||||
@@ -40,8 +40,8 @@ clawdhub sync --root /path/to/skills
|
||||
- Your local files don’t match any published fingerprint.
|
||||
- Options:
|
||||
- keep local edits; skip updating
|
||||
- overwrite: `clawdhub update <slug> --force`
|
||||
- publish as fork: copy to new folder/slug then `clawdhub publish ... --fork-of upstream@version`
|
||||
- overwrite: `molthub update <slug> --force`
|
||||
- publish as fork: copy to new folder/slug then `molthub publish ... --fork-of upstream@version`
|
||||
|
||||
## `GET /api/*` works locally but not on Vercel
|
||||
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ read_when:
|
||||
|
||||
# Webhooks (Discord)
|
||||
|
||||
ClawdHub can post Discord embeds when skills are published or highlighted.
|
||||
MoltHub can post Discord embeds when skills are published or highlighted.
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -14,7 +14,7 @@ Set the webhook URL in the Convex environment:
|
||||
|
||||
- `DISCORD_WEBHOOK_URL` (required): Discord webhook URL.
|
||||
- `DISCORD_WEBHOOK_HIGHLIGHTED_ONLY` (optional): `true` to only send for highlighted skills.
|
||||
- `SITE_URL` (optional): Base site URL for links (default `https://clawdhub.com`).
|
||||
- `SITE_URL` (optional): Base site URL for links (default `https://molthub.com`).
|
||||
|
||||
## Events
|
||||
|
||||
@@ -38,13 +38,13 @@ Discord receives a JSON payload with a single embed:
|
||||
{
|
||||
"title": "Demo Skill",
|
||||
"description": "Nice skill",
|
||||
"url": "https://clawdhub.com/owner/demo-skill",
|
||||
"url": "https://molthub.com/owner/demo-skill",
|
||||
"fields": [
|
||||
{ "name": "Version", "value": "v1.2.3", "inline": true },
|
||||
{ "name": "Owner", "value": "@owner", "inline": true },
|
||||
{ "name": "Tags", "value": "latest, discord", "inline": false }
|
||||
],
|
||||
"footer": { "text": "ClawdHub" }
|
||||
"footer": { "text": "MoltHub" }
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ test('header menu routes render', async ({ page }) => {
|
||||
|
||||
if (label === 'Search') {
|
||||
await expect(page).toHaveURL(/\/?(\?|$)/)
|
||||
await expect(page.locator('h1', { hasText: 'ClawdHub' })).toBeVisible()
|
||||
await expect(page.locator('h1', { hasText: 'MoltHub' })).toBeVisible()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -4,16 +4,16 @@ import { spawnSync } from 'node:child_process'
|
||||
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { unzipSync } from 'fflate'
|
||||
import {
|
||||
ApiRoutes,
|
||||
ApiV1SearchResponseSchema,
|
||||
ApiV1WhoamiResponseSchema,
|
||||
parseArk,
|
||||
} from 'clawdhub-schema'
|
||||
import { unzipSync } from 'fflate'
|
||||
} from 'molthub-schema'
|
||||
import { Agent, setGlobalDispatcher } from 'undici'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { readGlobalConfig } from '../packages/clawdhub/src/config'
|
||||
import { readGlobalConfig } from '../packages/molthub/src/config'
|
||||
|
||||
const REQUEST_TIMEOUT_MS = 15_000
|
||||
|
||||
@@ -29,13 +29,13 @@ try {
|
||||
}
|
||||
|
||||
function mustGetToken() {
|
||||
const fromEnv = process.env.CLAWDHUB_E2E_TOKEN?.trim()
|
||||
const fromEnv = process.env.MOLTHUB_E2E_TOKEN?.trim()
|
||||
if (fromEnv) return fromEnv
|
||||
return null
|
||||
}
|
||||
|
||||
async function makeTempConfig(registry: string, token: string | null) {
|
||||
const dir = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-'))
|
||||
const dir = await mkdtemp(join(tmpdir(), 'molthub-e2e-'))
|
||||
const path = join(dir, 'config.json')
|
||||
await writeFile(
|
||||
path,
|
||||
@@ -55,9 +55,9 @@ async function fetchWithTimeout(input: RequestInfo | URL, init?: RequestInit) {
|
||||
}
|
||||
}
|
||||
|
||||
describe('clawdhub e2e', () => {
|
||||
describe('molthub e2e', () => {
|
||||
it('prints CLI version via --cli-version', async () => {
|
||||
const result = spawnSync('bun', ['clawdhub', '--cli-version'], {
|
||||
const result = spawnSync('bun', ['molthub', '--cli-version'], {
|
||||
cwd: process.cwd(),
|
||||
encoding: 'utf8',
|
||||
})
|
||||
@@ -66,7 +66,7 @@ describe('clawdhub e2e', () => {
|
||||
})
|
||||
|
||||
it('search endpoint returns a results array (schema parse)', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const url = new URL(ApiRoutes.search, registry)
|
||||
url.searchParams.set('q', 'gif')
|
||||
url.searchParams.set('limit', '5')
|
||||
@@ -81,17 +81,17 @@ describe('clawdhub e2e', () => {
|
||||
})
|
||||
|
||||
it('cli search does not error on multi-result responses', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const site = process.env.MOLTHUB_SITE?.trim() || 'https://molthub.com'
|
||||
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
|
||||
|
||||
const cfg = await makeTempConfig(registry, token)
|
||||
try {
|
||||
const workdir = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-workdir-'))
|
||||
const workdir = await mkdtemp(join(tmpdir(), 'molthub-e2e-workdir-'))
|
||||
const result = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'search',
|
||||
'gif',
|
||||
'--limit',
|
||||
@@ -105,7 +105,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -119,11 +119,11 @@ describe('clawdhub e2e', () => {
|
||||
})
|
||||
|
||||
it('assumes a logged-in user (whoami succeeds)', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const site = process.env.MOLTHUB_SITE?.trim() || 'https://molthub.com'
|
||||
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
|
||||
if (!token) {
|
||||
throw new Error('Missing token. Set CLAWDHUB_E2E_TOKEN or run: bun clawdhub auth login')
|
||||
throw new Error('Missing token. Set MOLTHUB_E2E_TOKEN or run: bun molthub auth login')
|
||||
}
|
||||
|
||||
const cfg = await makeTempConfig(registry, token)
|
||||
@@ -142,10 +142,10 @@ describe('clawdhub e2e', () => {
|
||||
|
||||
const result = spawnSync(
|
||||
'bun',
|
||||
['clawdhub', 'whoami', '--site', site, '--registry', registry],
|
||||
['molthub', 'whoami', '--site', site, '--registry', registry],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -157,15 +157,15 @@ describe('clawdhub e2e', () => {
|
||||
})
|
||||
|
||||
it('sync dry-run finds skills from an explicit root', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const site = process.env.MOLTHUB_SITE?.trim() || 'https://molthub.com'
|
||||
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
|
||||
if (!token) {
|
||||
throw new Error('Missing token. Set CLAWDHUB_E2E_TOKEN or run: bun clawdhub auth login')
|
||||
throw new Error('Missing token. Set MOLTHUB_E2E_TOKEN or run: bun molthub auth login')
|
||||
}
|
||||
|
||||
const cfg = await makeTempConfig(registry, token)
|
||||
const root = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-sync-'))
|
||||
const root = await mkdtemp(join(tmpdir(), 'molthub-e2e-sync-'))
|
||||
try {
|
||||
const skillDir = join(root, 'cool-skill')
|
||||
await mkdir(skillDir, { recursive: true })
|
||||
@@ -174,7 +174,7 @@ describe('clawdhub e2e', () => {
|
||||
const result = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'sync',
|
||||
'--dry-run',
|
||||
'--all',
|
||||
@@ -187,7 +187,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -200,19 +200,19 @@ describe('clawdhub e2e', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('sync dry-run finds skills from clawdbot.json roots', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
|
||||
it('sync dry-run finds skills from moltbot.json roots', async () => {
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const site = process.env.MOLTHUB_SITE?.trim() || 'https://molthub.com'
|
||||
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
|
||||
if (!token) {
|
||||
throw new Error('Missing token. Set CLAWDHUB_E2E_TOKEN or run: bun clawdhub auth login')
|
||||
throw new Error('Missing token. Set MOLTHUB_E2E_TOKEN or run: bun molthub auth login')
|
||||
}
|
||||
|
||||
const cfg = await makeTempConfig(registry, token)
|
||||
const root = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-clawdbot-'))
|
||||
const root = await mkdtemp(join(tmpdir(), 'molthub-e2e-moltbot-'))
|
||||
const stateDir = join(root, 'state')
|
||||
const configPath = join(root, 'clawdbot.json')
|
||||
const workspace = join(root, 'clawd-work')
|
||||
const configPath = join(root, 'moltbot.json')
|
||||
const workspace = join(root, 'molt-work')
|
||||
const skillsRoot = join(workspace, 'skills')
|
||||
const skillDir = join(skillsRoot, 'auto-skill')
|
||||
|
||||
@@ -232,15 +232,15 @@ describe('clawdhub e2e', () => {
|
||||
|
||||
const result = spawnSync(
|
||||
'bun',
|
||||
['clawdhub', 'sync', '--dry-run', '--all', '--site', site, '--registry', registry],
|
||||
['molthub', 'sync', '--dry-run', '--all', '--site', site, '--registry', registry],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: {
|
||||
...process.env,
|
||||
CLAWDHUB_CONFIG_PATH: cfg.path,
|
||||
CLAWDHUB_DISABLE_TELEMETRY: '1',
|
||||
CLAWDBOT_CONFIG_PATH: configPath,
|
||||
CLAWDBOT_STATE_DIR: stateDir,
|
||||
MOLTHUB_CONFIG_PATH: cfg.path,
|
||||
MOLTHUB_DISABLE_TELEMETRY: '1',
|
||||
MOLTBOT_CONFIG_PATH: configPath,
|
||||
MOLTBOT_STATE_DIR: stateDir,
|
||||
},
|
||||
encoding: 'utf8',
|
||||
},
|
||||
@@ -256,16 +256,16 @@ describe('clawdhub e2e', () => {
|
||||
})
|
||||
|
||||
it('publishes, deletes, and undeletes a skill (logged-in)', async () => {
|
||||
const registry = process.env.CLAWDHUB_REGISTRY?.trim() || 'https://clawdhub.com'
|
||||
const site = process.env.CLAWDHUB_SITE?.trim() || 'https://clawdhub.com'
|
||||
const registry = process.env.MOLTHUB_REGISTRY?.trim() || 'https://molthub.com'
|
||||
const site = process.env.MOLTHUB_SITE?.trim() || 'https://molthub.com'
|
||||
const token = mustGetToken() ?? (await readGlobalConfig())?.token ?? null
|
||||
if (!token) {
|
||||
throw new Error('Missing token. Set CLAWDHUB_E2E_TOKEN or run: bun clawdhub auth login')
|
||||
throw new Error('Missing token. Set MOLTHUB_E2E_TOKEN or run: bun molthub auth login')
|
||||
}
|
||||
|
||||
const cfg = await makeTempConfig(registry, token)
|
||||
const workdir = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-publish-'))
|
||||
const installWorkdir = await mkdtemp(join(tmpdir(), 'clawdhub-e2e-install-'))
|
||||
const workdir = await mkdtemp(join(tmpdir(), 'molthub-e2e-publish-'))
|
||||
const installWorkdir = await mkdtemp(join(tmpdir(), 'molthub-e2e-install-'))
|
||||
const slug = `e2e-${Date.now()}`
|
||||
const skillDir = join(workdir, slug)
|
||||
|
||||
@@ -276,7 +276,7 @@ describe('clawdhub e2e', () => {
|
||||
const publish1 = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'publish',
|
||||
skillDir,
|
||||
'--slug',
|
||||
@@ -296,7 +296,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -306,7 +306,7 @@ describe('clawdhub e2e', () => {
|
||||
const publish2 = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'publish',
|
||||
skillDir,
|
||||
'--slug',
|
||||
@@ -326,7 +326,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -345,7 +345,7 @@ describe('clawdhub e2e', () => {
|
||||
const install = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'install',
|
||||
slug,
|
||||
'--version',
|
||||
@@ -360,7 +360,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -368,10 +368,10 @@ describe('clawdhub e2e', () => {
|
||||
|
||||
const list = spawnSync(
|
||||
'bun',
|
||||
['clawdhub', 'list', '--site', site, '--registry', registry, '--workdir', installWorkdir],
|
||||
['molthub', 'list', '--site', site, '--registry', registry, '--workdir', installWorkdir],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -381,7 +381,7 @@ describe('clawdhub e2e', () => {
|
||||
const update = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'update',
|
||||
slug,
|
||||
'--force',
|
||||
@@ -394,7 +394,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -409,7 +409,7 @@ describe('clawdhub e2e', () => {
|
||||
const del = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'delete',
|
||||
slug,
|
||||
'--yes',
|
||||
@@ -422,7 +422,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -439,7 +439,7 @@ describe('clawdhub e2e', () => {
|
||||
const undelete = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'undelete',
|
||||
slug,
|
||||
'--yes',
|
||||
@@ -452,7 +452,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
@@ -466,7 +466,7 @@ describe('clawdhub e2e', () => {
|
||||
const cleanup = spawnSync(
|
||||
'bun',
|
||||
[
|
||||
'clawdhub',
|
||||
'molthub',
|
||||
'delete',
|
||||
slug,
|
||||
'--yes',
|
||||
@@ -479,7 +479,7 @@ describe('clawdhub e2e', () => {
|
||||
],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, CLAWDHUB_CONFIG_PATH: cfg.path, CLAWDHUB_DISABLE_TELEMETRY: '1' },
|
||||
env: { ...process.env, MOLTHUB_CONFIG_PATH: cfg.path, MOLTHUB_DISABLE_TELEMETRY: '1' },
|
||||
encoding: 'utf8',
|
||||
},
|
||||
)
|
||||
+3
-3
@@ -3,9 +3,9 @@ import { existsSync } from 'node:fs'
|
||||
import { stat } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const distCliUrl = new URL('./packages/clawdhub/dist/cli.js', import.meta.url)
|
||||
const distCliUrl = new URL('./packages/molthub/dist/cli.js', import.meta.url)
|
||||
const distCliPath = fileURLToPath(distCliUrl)
|
||||
const srcRootPath = fileURLToPath(new URL('./packages/clawdhub/src/', import.meta.url))
|
||||
const srcRootPath = fileURLToPath(new URL('./packages/molthub/src/', import.meta.url))
|
||||
|
||||
const shouldBuild = await (async () => {
|
||||
if (!existsSync(distCliPath)) return true
|
||||
@@ -19,7 +19,7 @@ const shouldBuild = await (async () => {
|
||||
})()
|
||||
|
||||
if (shouldBuild) {
|
||||
const proc = Bun.spawn(['bunx', 'tsc', '-p', 'packages/clawdhub/tsconfig.json'], {
|
||||
const proc = Bun.spawn(['bunx', 'tsc', '-p', 'packages/molthub/tsconfig.json'], {
|
||||
stdin: 'inherit',
|
||||
stdout: 'inherit',
|
||||
stderr: 'inherit',
|
||||
+7
-4
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "clawdhub",
|
||||
"name": "molthub",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"preinstall": "bunx only-allow bun",
|
||||
"dev": "bun --bun vite dev --port 3000",
|
||||
"build": "bun --bun vite build",
|
||||
"preview": "bun --bun vite preview",
|
||||
@@ -20,7 +21,7 @@
|
||||
"convex:deploy": "bunx convex deploy --typecheck=disable --yes",
|
||||
"lint": "bun run lint:biome && bun run lint:oxlint",
|
||||
"lint:biome": "biome check .",
|
||||
"lint:oxlint": "oxlint --type-aware --tsconfig ./tsconfig.oxlint.json ./src ./convex ./packages/clawdhub/src ./packages/schema/src",
|
||||
"lint:oxlint": "oxlint --type-aware --tsconfig ./tsconfig.oxlint.json ./src ./convex ./packages/molthub/src ./packages/schema/src",
|
||||
"format": "biome format --write ."
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -40,9 +41,10 @@
|
||||
"@tanstack/react-start": "^1.152.0",
|
||||
"@tanstack/router-plugin": "^1.151.6",
|
||||
"@vercel/analytics": "^1.6.1",
|
||||
"clawdhub-schema": "workspace:*",
|
||||
"molthub-schema": "workspace:*",
|
||||
"clsx": "^2.1.1",
|
||||
"convex": "^1.31.5",
|
||||
"convex": "^1.31.6",
|
||||
"convex-helpers": "^0.1.111",
|
||||
"fflate": "^0.8.2",
|
||||
"h3": "2.0.1-rc.8",
|
||||
"lucide-react": "^0.562.0",
|
||||
@@ -71,6 +73,7 @@
|
||||
"@vitejs/plugin-react": "^5.1.2",
|
||||
"@vitest/coverage-v8": "^4.0.17",
|
||||
"jsdom": "^27.4.0",
|
||||
"only-allow": "^1.2.1",
|
||||
"oxlint": "^1.39.0",
|
||||
"oxlint-tsgolint": "^0.11.1",
|
||||
"typescript": "^5.9.3",
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# `clawdhub`
|
||||
|
||||
ClawdHub CLI — install, update, search, and publish agent skills as folders.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# From this repo (shortcut script at repo root)
|
||||
bun clawdhub --help
|
||||
|
||||
# Once published to npm
|
||||
# npm i -g clawdhub
|
||||
```
|
||||
|
||||
## Auth (publish)
|
||||
|
||||
```bash
|
||||
clawdhub login
|
||||
# or
|
||||
clawdhub auth login
|
||||
|
||||
# Headless / token paste
|
||||
# or (token paste / headless)
|
||||
clawdhub login --token clh_...
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- Browser login opens `https://clawdhub.com/cli/auth` and completes via a loopback callback.
|
||||
- Token stored in `~/Library/Application Support/clawdhub/config.json` on macOS (override via `CLAWDHUB_CONFIG_PATH`).
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
clawdhub search "postgres backups"
|
||||
clawdhub install my-skill-pack
|
||||
clawdhub update --all
|
||||
clawdhub update --all --no-input --force
|
||||
clawdhub publish ./my-skill-pack --slug my-skill-pack --name "My Skill Pack" --version 1.2.0 --changelog "Fixes + docs"
|
||||
```
|
||||
|
||||
## Sync (upload local skills)
|
||||
|
||||
```bash
|
||||
# Start anywhere; scans workdir first, then legacy Clawdis/Clawd locations.
|
||||
clawdhub sync
|
||||
|
||||
# Explicit roots + non-interactive dry-run
|
||||
clawdhub sync --root ../clawdis/skills --all --dry-run
|
||||
```
|
||||
|
||||
## Defaults
|
||||
|
||||
- Site: `https://clawdhub.com` (override via `--site` or `CLAWDHUB_SITE`)
|
||||
- Registry: discovered from `/.well-known/clawdhub.json` on the site (override via `--registry` or `CLAWDHUB_REGISTRY`)
|
||||
- Workdir: current directory (falls back to Clawdbot workspace if configured; override via `--workdir` or `CLAWDHUB_WORKDIR`)
|
||||
- Install dir: `./skills` under workdir (override via `--dir`)
|
||||
@@ -0,0 +1,57 @@
|
||||
# `molthub`
|
||||
|
||||
MoltHub CLI — install, update, search, and publish agent skills as folders.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# From this repo (shortcut script at repo root)
|
||||
bun molthub --help
|
||||
|
||||
# Once published to npm
|
||||
# npm i -g molthub
|
||||
```
|
||||
|
||||
## Auth (publish)
|
||||
|
||||
```bash
|
||||
molthub login
|
||||
# or
|
||||
molthub auth login
|
||||
|
||||
# Headless / token paste
|
||||
# or (token paste / headless)
|
||||
molthub login --token clh_...
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- Browser login opens `https://molthub.com/cli/auth` and completes via a loopback callback.
|
||||
- Token stored in `~/Library/Application Support/molthub/config.json` on macOS (override via `MOLTHUB_CONFIG_PATH`).
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
molthub search "postgres backups"
|
||||
molthub install my-skill-pack
|
||||
molthub update --all
|
||||
molthub update --all --no-input --force
|
||||
molthub publish ./my-skill-pack --slug my-skill-pack --name "My Skill Pack" --version 1.2.0 --changelog "Fixes + docs"
|
||||
```
|
||||
|
||||
## Sync (upload local skills)
|
||||
|
||||
```bash
|
||||
# Start anywhere; scans workdir first, then legacy Moltbot/Molt locations.
|
||||
molthub sync
|
||||
|
||||
# Explicit roots + non-interactive dry-run
|
||||
molthub sync --root ../moltbot/skills --all --dry-run
|
||||
```
|
||||
|
||||
## Defaults
|
||||
|
||||
- Site: `https://molthub.com` (override via `--site` or `MOLTHUB_SITE`)
|
||||
- Registry: discovered from `/.well-known/molthub.json` on the site (override via `--registry` or `MOLTHUB_REGISTRY`)
|
||||
- Workdir: current directory (falls back to Moltbot workspace if configured; override via `--workdir` or `MOLTHUB_WORKDIR`)
|
||||
- Install dir: `./skills` under workdir (override via `--dir`)
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "clawdhub",
|
||||
"name": "molthub",
|
||||
"version": "0.3.0",
|
||||
"description": "ClawdHub CLI \\u2014 install, update, search, and publish agent skills.",
|
||||
"description": "MoltHub CLI \\u2014 install, update, search, and publish agent skills.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"clawdhub": "bin/clawdhub.js"
|
||||
"molthub": "bin/molthub.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
+1
-1
@@ -60,7 +60,7 @@ describe('browserAuth', () => {
|
||||
const response = await fetch(server.redirectUri)
|
||||
expect(response.status).toBe(200)
|
||||
const text = await response.text()
|
||||
expect(text).toContain('ClawdHub CLI Login')
|
||||
expect(text).toContain('MoltHub CLI Login')
|
||||
server.close()
|
||||
})
|
||||
|
||||
@@ -127,7 +127,7 @@ const CALLBACK_HTML = `<!doctype html>
|
||||
<html lang="en">
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>ClawdHub CLI Login</title>
|
||||
<title>MoltHub CLI Login</title>
|
||||
<style>
|
||||
:root { color-scheme: light dark; }
|
||||
body { font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; padding: 24px; }
|
||||
@@ -3,7 +3,6 @@ import { stat } from 'node:fs/promises'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { Command } from 'commander'
|
||||
import { getCliBuildLabel, getCliVersion } from './cli/buildInfo.js'
|
||||
import { resolveClawdbotDefaultWorkspace } from './cli/clawdbotConfig.js'
|
||||
import { cmdLoginFlow, cmdLogout, cmdWhoami } from './cli/commands/auth.js'
|
||||
import { cmdDeleteSkill, cmdUndeleteSkill } from './cli/commands/delete.js'
|
||||
import { cmdPublish } from './cli/commands/publish.js'
|
||||
@@ -12,15 +11,16 @@ import { cmdStarSkill } from './cli/commands/star.js'
|
||||
import { cmdSync } from './cli/commands/sync.js'
|
||||
import { cmdUnstarSkill } from './cli/commands/unstar.js'
|
||||
import { configureCommanderHelp, styleEnvBlock, styleTitle } from './cli/helpStyle.js'
|
||||
import { resolveMoltbotDefaultWorkspace } from './cli/moltbotConfig.js'
|
||||
import { DEFAULT_REGISTRY, DEFAULT_SITE } from './cli/registry.js'
|
||||
import type { GlobalOpts } from './cli/types.js'
|
||||
import { fail } from './cli/ui.js'
|
||||
import { readGlobalConfig } from './config.js'
|
||||
|
||||
const program = new Command()
|
||||
.name('clawdhub')
|
||||
.name('molthub')
|
||||
.description(
|
||||
`${styleTitle(`ClawdHub CLI ${getCliBuildLabel()}`)}\n${styleEnvBlock(
|
||||
`${styleTitle(`MoltHub CLI ${getCliBuildLabel()}`)}\n${styleEnvBlock(
|
||||
'install, update, search, and publish agent skills.',
|
||||
)}`,
|
||||
)
|
||||
@@ -34,7 +34,7 @@ const program = new Command()
|
||||
.showSuggestionAfterError()
|
||||
.addHelpText(
|
||||
'after',
|
||||
styleEnvBlock('\nEnv:\n CLAWDHUB_SITE\n CLAWDHUB_REGISTRY\n CLAWDHUB_WORKDIR\n'),
|
||||
styleEnvBlock('\nEnv:\n MOLTHUB_SITE\n MOLTHUB_REGISTRY\n MOLTHUB_WORKDIR\n'),
|
||||
)
|
||||
|
||||
configureCommanderHelp(program)
|
||||
@@ -43,9 +43,9 @@ async function resolveGlobalOpts(): Promise<GlobalOpts> {
|
||||
const raw = program.opts<{ workdir?: string; dir?: string; site?: string; registry?: string }>()
|
||||
const workdir = await resolveWorkdir(raw.workdir)
|
||||
const dir = resolve(workdir, raw.dir ?? 'skills')
|
||||
const site = raw.site ?? process.env.CLAWDHUB_SITE ?? DEFAULT_SITE
|
||||
const registrySource = raw.registry ? 'cli' : process.env.CLAWDHUB_REGISTRY ? 'env' : 'default'
|
||||
const registry = raw.registry ?? process.env.CLAWDHUB_REGISTRY ?? DEFAULT_REGISTRY
|
||||
const site = raw.site ?? process.env.MOLTHUB_SITE ?? DEFAULT_SITE
|
||||
const registrySource = raw.registry ? 'cli' : process.env.MOLTHUB_REGISTRY ? 'env' : 'default'
|
||||
const registry = raw.registry ?? process.env.MOLTHUB_REGISTRY ?? DEFAULT_REGISTRY
|
||||
return { workdir, dir, site, registry, registrySource }
|
||||
}
|
||||
|
||||
@@ -56,21 +56,21 @@ function isInputAllowed() {
|
||||
|
||||
async function resolveWorkdir(explicit?: string) {
|
||||
if (explicit?.trim()) return resolve(explicit.trim())
|
||||
const envWorkdir = process.env.CLAWDHUB_WORKDIR?.trim()
|
||||
const envWorkdir = process.env.MOLTHUB_WORKDIR?.trim()
|
||||
if (envWorkdir) return resolve(envWorkdir)
|
||||
|
||||
const cwd = resolve(process.cwd())
|
||||
const hasMarker = await hasClawdhubMarker(cwd)
|
||||
const hasMarker = await hasMolthubMarker(cwd)
|
||||
if (hasMarker) return cwd
|
||||
|
||||
const clawdbotWorkspace = await resolveClawdbotDefaultWorkspace()
|
||||
return clawdbotWorkspace ? resolve(clawdbotWorkspace) : cwd
|
||||
const moltbotWorkspace = await resolveMoltbotDefaultWorkspace()
|
||||
return moltbotWorkspace ? resolve(moltbotWorkspace) : cwd
|
||||
}
|
||||
|
||||
async function hasClawdhubMarker(workdir: string) {
|
||||
const lockfile = join(workdir, '.clawdhub', 'lock.json')
|
||||
async function hasMolthubMarker(workdir: string) {
|
||||
const lockfile = join(workdir, '.molthub', 'lock.json')
|
||||
if (await pathExists(lockfile)) return true
|
||||
const markerDir = join(workdir, '.clawdhub')
|
||||
const markerDir = join(workdir, '.molthub')
|
||||
return pathExists(markerDir)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ function shortCommit(value: string) {
|
||||
|
||||
export function getCliCommit() {
|
||||
const candidates = [
|
||||
process.env.CLAWDHUB_COMMIT,
|
||||
process.env.MOLTHUB_COMMIT,
|
||||
process.env.VERCEL_GIT_COMMIT_SHA,
|
||||
process.env.GITHUB_SHA,
|
||||
process.env.COMMIT_SHA,
|
||||
+2
-2
@@ -47,7 +47,7 @@ export async function cmdLogin(
|
||||
) {
|
||||
if (!tokenFlag && !inputAllowed) fail('Token required (use --token or remove --no-input)')
|
||||
|
||||
const token = tokenFlag || (await promptHidden('ClawdHub token: '))
|
||||
const token = tokenFlag || (await promptHidden('MoltHub token: '))
|
||||
if (!token) fail('Token required')
|
||||
|
||||
const registry = await getRegistry(opts, { cache: true })
|
||||
@@ -79,7 +79,7 @@ export async function cmdLogout(opts: GlobalOpts) {
|
||||
export async function cmdWhoami(opts: GlobalOpts) {
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
const registry = await getRegistry(opts, { cache: true })
|
||||
|
||||
const spinner = createSpinner('Checking token')
|
||||
+4
-4
@@ -4,11 +4,11 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { GlobalOpts } from '../types'
|
||||
|
||||
vi.mock('../../config.js', () => ({
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://clawdhub.com', token: 'tkn' })),
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://molthub.com', token: 'tkn' })),
|
||||
}))
|
||||
|
||||
vi.mock('../registry.js', () => ({
|
||||
getRegistry: vi.fn(async () => 'https://clawdhub.com'),
|
||||
getRegistry: vi.fn(async () => 'https://molthub.com'),
|
||||
}))
|
||||
|
||||
const mockApiRequest = vi.fn()
|
||||
@@ -35,8 +35,8 @@ function makeOpts(): GlobalOpts {
|
||||
return {
|
||||
workdir: '/work',
|
||||
dir: '/work/skills',
|
||||
site: 'https://clawdhub.com',
|
||||
registry: 'https://clawdhub.com',
|
||||
site: 'https://molthub.com',
|
||||
registry: 'https://molthub.com',
|
||||
registrySource: 'default',
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import { createSpinner, fail, formatError, isInteractive, promptConfirm } from '
|
||||
async function requireToken() {
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
return token
|
||||
}
|
||||
|
||||
+5
-5
@@ -7,10 +7,10 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { GlobalOpts } from '../types'
|
||||
|
||||
vi.mock('../../config.js', () => ({
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://clawdhub.com', token: 'tkn' })),
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://molthub.com', token: 'tkn' })),
|
||||
}))
|
||||
|
||||
const mockGetRegistry = vi.fn(async (_opts: unknown, _params?: unknown) => 'https://clawdhub.com')
|
||||
const mockGetRegistry = vi.fn(async (_opts: unknown, _params?: unknown) => 'https://molthub.com')
|
||||
vi.mock('../registry.js', () => ({
|
||||
getRegistry: (opts: unknown, params?: unknown) => mockGetRegistry(opts, params),
|
||||
}))
|
||||
@@ -34,7 +34,7 @@ vi.mock('../ui.js', () => ({
|
||||
const { cmdPublish } = await import('./publish')
|
||||
|
||||
async function makeTmpWorkdir() {
|
||||
const root = await mkdtemp(join(tmpdir(), 'clawdhub-publish-'))
|
||||
const root = await mkdtemp(join(tmpdir(), 'molthub-publish-'))
|
||||
return root
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ function makeOpts(workdir: string): GlobalOpts {
|
||||
return {
|
||||
workdir,
|
||||
dir: join(workdir, 'skills'),
|
||||
site: 'https://clawdhub.com',
|
||||
registry: 'https://clawdhub.com',
|
||||
site: 'https://molthub.com',
|
||||
registry: 'https://molthub.com',
|
||||
registrySource: 'default',
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ export async function cmdPublish(
|
||||
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
const registry = await getRegistry(opts, { cache: true })
|
||||
|
||||
const slug = options.slug ?? sanitizeSlug(basename(folder))
|
||||
+3
-3
@@ -11,7 +11,7 @@ vi.mock('../../http.js', () => ({
|
||||
downloadZip: (...args: unknown[]) => mockDownloadZip(...args),
|
||||
}))
|
||||
|
||||
const mockGetRegistry = vi.fn(async () => 'https://clawdhub.com')
|
||||
const mockGetRegistry = vi.fn(async () => 'https://molthub.com')
|
||||
vi.mock('../registry.js', () => ({
|
||||
getRegistry: () => mockGetRegistry(),
|
||||
}))
|
||||
@@ -68,8 +68,8 @@ function makeOpts(): GlobalOpts {
|
||||
return {
|
||||
workdir: '/work',
|
||||
dir: '/work/skills',
|
||||
site: 'https://clawdhub.com',
|
||||
registry: 'https://clawdhub.com',
|
||||
site: 'https://molthub.com',
|
||||
registry: 'https://molthub.com',
|
||||
registrySource: 'default',
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import { createSpinner, fail, formatError, isInteractive, promptConfirm } from '
|
||||
async function requireToken() {
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
return token
|
||||
}
|
||||
|
||||
+12
-12
@@ -27,10 +27,10 @@ vi.mock('@clack/prompts', () => ({
|
||||
}))
|
||||
|
||||
vi.mock('../../config.js', () => ({
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://clawdhub.com', token: 'tkn' })),
|
||||
readGlobalConfig: vi.fn(async () => ({ registry: 'https://molthub.com', token: 'tkn' })),
|
||||
}))
|
||||
|
||||
const mockGetRegistry = vi.fn(async () => 'https://clawdhub.com')
|
||||
const mockGetRegistry = vi.fn(async () => 'https://molthub.com')
|
||||
vi.mock('../registry.js', () => ({
|
||||
getRegistry: () => mockGetRegistry(),
|
||||
}))
|
||||
@@ -57,15 +57,15 @@ vi.mock('../scanSkills.js', () => ({
|
||||
getFallbackSkillRoots: vi.fn(() => []),
|
||||
}))
|
||||
|
||||
const mockResolveClawdbotSkillRoots = vi.fn(
|
||||
const mockResolveMoltbotSkillRoots = vi.fn(
|
||||
async () =>
|
||||
({
|
||||
roots: [] as string[],
|
||||
labels: {} as Record<string, string>,
|
||||
}) as const,
|
||||
)
|
||||
vi.mock('../clawdbotConfig.js', () => ({
|
||||
resolveClawdbotSkillRoots: () => mockResolveClawdbotSkillRoots(),
|
||||
vi.mock('../moltbotConfig.js', () => ({
|
||||
resolveMoltbotSkillRoots: () => mockResolveMoltbotSkillRoots(),
|
||||
}))
|
||||
|
||||
vi.mock('../../skills.js', async () => {
|
||||
@@ -89,8 +89,8 @@ function makeOpts(): GlobalOpts {
|
||||
return {
|
||||
workdir: '/work',
|
||||
dir: '/work/skills',
|
||||
site: 'https://clawdhub.com',
|
||||
registry: 'https://clawdhub.com',
|
||||
site: 'https://molthub.com',
|
||||
registry: 'https://molthub.com',
|
||||
registrySource: 'default',
|
||||
}
|
||||
}
|
||||
@@ -230,9 +230,9 @@ describe('cmdSync', () => {
|
||||
expect(output).toMatch(/dup-skill/)
|
||||
})
|
||||
|
||||
it('prints labeled roots when clawdbot roots are detected', async () => {
|
||||
it('prints labeled roots when moltbot roots are detected', async () => {
|
||||
interactive = false
|
||||
mockResolveClawdbotSkillRoots.mockResolvedValueOnce({
|
||||
mockResolveMoltbotSkillRoots.mockResolvedValueOnce({
|
||||
roots: ['/auto'],
|
||||
labels: { '/auto': 'Agent: Work' },
|
||||
})
|
||||
@@ -290,9 +290,9 @@ describe('cmdSync', () => {
|
||||
expect(update.changelog).toBe('')
|
||||
})
|
||||
|
||||
it('skips telemetry when CLAWDHUB_DISABLE_TELEMETRY is set', async () => {
|
||||
it('skips telemetry when MOLTHUB_DISABLE_TELEMETRY is set', async () => {
|
||||
interactive = false
|
||||
process.env.CLAWDHUB_DISABLE_TELEMETRY = '1'
|
||||
process.env.MOLTHUB_DISABLE_TELEMETRY = '1'
|
||||
mockApiRequest.mockImplementation(async (_registry: string, args: { path: string }) => {
|
||||
if (args.path === '/api/v1/whoami') return { user: { handle: 'steipete' } }
|
||||
if (args.path.startsWith('/api/v1/resolve?')) {
|
||||
@@ -305,6 +305,6 @@ describe('cmdSync', () => {
|
||||
expect(
|
||||
mockApiRequest.mock.calls.some((call) => call[1]?.path === '/api/cli/telemetry/sync'),
|
||||
).toBe(false)
|
||||
delete process.env.CLAWDHUB_DISABLE_TELEMETRY
|
||||
delete process.env.MOLTHUB_DISABLE_TELEMETRY
|
||||
})
|
||||
})
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
import { intro, outro } from '@clack/prompts'
|
||||
import { readGlobalConfig } from '../../config.js'
|
||||
import { hashSkillFiles, listTextFiles, readSkillOrigin } from '../../skills.js'
|
||||
import { resolveClawdbotSkillRoots } from '../clawdbotConfig.js'
|
||||
import { resolveMoltbotSkillRoots } from '../moltbotConfig.js'
|
||||
import { getFallbackSkillRoots } from '../scanSkills.js'
|
||||
import type { GlobalOpts } from '../types.js'
|
||||
import { createSpinner, fail, formatError, isInteractive } from '../ui.js'
|
||||
@@ -30,22 +30,22 @@ import type { Candidate, LocalSkill, SyncOptions } from './syncTypes.js'
|
||||
|
||||
export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllowed: boolean) {
|
||||
const allowPrompt = isInteractive() && inputAllowed !== false
|
||||
intro('ClawdHub sync')
|
||||
intro('MoltHub sync')
|
||||
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
|
||||
const registry = await getRegistryWithAuth(opts, token)
|
||||
const selectedRoots = buildScanRoots(opts, options.root)
|
||||
const clawdbotRoots = await resolveClawdbotSkillRoots()
|
||||
const moltbotRoots = await resolveMoltbotSkillRoots()
|
||||
const combinedRoots = Array.from(
|
||||
new Set([...selectedRoots, ...clawdbotRoots.roots].map((root) => root.trim()).filter(Boolean)),
|
||||
new Set([...selectedRoots, ...moltbotRoots.roots].map((root) => root.trim()).filter(Boolean)),
|
||||
)
|
||||
const concurrency = normalizeConcurrency(options.concurrency)
|
||||
|
||||
const spinner = createSpinner('Scanning for local skills')
|
||||
const primaryScan = await scanRootsWithLabels(combinedRoots, clawdbotRoots.labels)
|
||||
const primaryScan = await scanRootsWithLabels(combinedRoots, moltbotRoots.labels)
|
||||
let scan = primaryScan
|
||||
let telemetryScan = primaryScan
|
||||
if (primaryScan.skills.length === 0) {
|
||||
@@ -55,7 +55,7 @@ export async function cmdSync(opts: GlobalOpts, options: SyncOptions, inputAllow
|
||||
telemetryScan = mergeScan(primaryScan, fallbackScan)
|
||||
scan = fallbackScan
|
||||
if (fallbackScan.skills.length === 0)
|
||||
fail('No skills found (checked workdir and known Clawdis/Clawd locations)')
|
||||
fail('No skills found (checked workdir and known Moltbot/Molt locations)')
|
||||
printSection(
|
||||
`No skills in workdir. Found ${fallbackScan.skills.length} in fallback locations.`,
|
||||
formatList(fallbackScan.rootsWithSkills, 10),
|
||||
+1
-1
@@ -58,7 +58,7 @@ export async function reportTelemetryIfEnabled(params: {
|
||||
}
|
||||
|
||||
function isTelemetryDisabled() {
|
||||
const raw = process.env.CLAWDHUB_DISABLE_TELEMETRY
|
||||
const raw = process.env.MOLTHUB_DISABLE_TELEMETRY
|
||||
if (!raw) return false
|
||||
return ['1', 'true', 'yes', 'on'].includes(raw.trim().toLowerCase())
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import { createSpinner, fail, formatError, isInteractive, promptConfirm } from '
|
||||
async function requireToken() {
|
||||
const cfg = await readGlobalConfig()
|
||||
const token = cfg?.token
|
||||
if (!token) fail('Not logged in. Run: clawdhub login')
|
||||
if (!token) fail('Not logged in. Run: molthub login')
|
||||
return token
|
||||
}
|
||||
|
||||
+39
-39
@@ -3,7 +3,7 @@ import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { afterEach, describe, expect, it } from 'vitest'
|
||||
import { resolveClawdbotDefaultWorkspace, resolveClawdbotSkillRoots } from './clawdbotConfig.js'
|
||||
import { resolveMoltbotDefaultWorkspace, resolveMoltbotSkillRoots } from './moltbotConfig.js'
|
||||
|
||||
const originalEnv = { ...process.env }
|
||||
|
||||
@@ -11,32 +11,32 @@ afterEach(() => {
|
||||
process.env = { ...originalEnv }
|
||||
})
|
||||
|
||||
describe('resolveClawdbotSkillRoots', () => {
|
||||
describe('resolveMoltbotSkillRoots', () => {
|
||||
it('reads JSON5 config and resolves per-agent + shared skill roots', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'clawdhub-clawdbot-'))
|
||||
const base = await mkdtemp(join(tmpdir(), 'molthub-moltbot-'))
|
||||
const home = join(base, 'home')
|
||||
const stateDir = join(base, 'state')
|
||||
const configPath = join(base, 'clawdbot.json')
|
||||
const configPath = join(base, 'moltbot.json')
|
||||
|
||||
process.env.HOME = home
|
||||
process.env.CLAWDBOT_STATE_DIR = stateDir
|
||||
process.env.CLAWDBOT_CONFIG_PATH = configPath
|
||||
process.env.MOLTBOT_STATE_DIR = stateDir
|
||||
process.env.MOLTBOT_CONFIG_PATH = configPath
|
||||
|
||||
const config = `{
|
||||
// JSON5 comments + trailing commas supported
|
||||
agents: {
|
||||
defaults: { workspace: '~/clawd-main', },
|
||||
defaults: { workspace: '~/molt-main', },
|
||||
list: [
|
||||
{ id: 'work', name: 'Work Bot', workspace: '~/clawd-work', },
|
||||
{ id: 'family', workspace: '~/clawd-family', },
|
||||
{ id: 'work', name: 'Work Bot', workspace: '~/molt-work', },
|
||||
{ id: 'family', workspace: '~/molt-family', },
|
||||
],
|
||||
},
|
||||
// legacy entries still supported
|
||||
agent: { workspace: '~/clawd-legacy', },
|
||||
agent: { workspace: '~/molt-legacy', },
|
||||
routing: {
|
||||
agents: {
|
||||
work: { name: 'Work Bot', workspace: '~/clawd-work', },
|
||||
family: { workspace: '~/clawd-family' },
|
||||
work: { name: 'Work Bot', workspace: '~/molt-work', },
|
||||
family: { workspace: '~/molt-family' },
|
||||
},
|
||||
},
|
||||
skills: {
|
||||
@@ -45,37 +45,37 @@ describe('resolveClawdbotSkillRoots', () => {
|
||||
}`
|
||||
await writeFile(configPath, config, 'utf8')
|
||||
|
||||
const { roots, labels } = await resolveClawdbotSkillRoots()
|
||||
const { roots, labels } = await resolveMoltbotSkillRoots()
|
||||
|
||||
const expectedRoots = [
|
||||
resolve(stateDir, 'skills'),
|
||||
resolve(home, 'clawd-main', 'skills'),
|
||||
resolve(home, 'clawd-work', 'skills'),
|
||||
resolve(home, 'clawd-family', 'skills'),
|
||||
resolve(home, 'molt-main', 'skills'),
|
||||
resolve(home, 'molt-work', 'skills'),
|
||||
resolve(home, 'molt-family', 'skills'),
|
||||
resolve(home, 'shared', 'skills'),
|
||||
resolve('/opt/skills'),
|
||||
]
|
||||
|
||||
expect(roots).toEqual(expect.arrayContaining(expectedRoots))
|
||||
expect(labels[resolve(stateDir, 'skills')]).toBe('Shared skills')
|
||||
expect(labels[resolve(home, 'clawd-main', 'skills')]).toBe('Agent: main')
|
||||
expect(labels[resolve(home, 'clawd-work', 'skills')]).toBe('Agent: Work Bot')
|
||||
expect(labels[resolve(home, 'clawd-family', 'skills')]).toBe('Agent: family')
|
||||
expect(labels[resolve(home, 'molt-main', 'skills')]).toBe('Agent: main')
|
||||
expect(labels[resolve(home, 'molt-work', 'skills')]).toBe('Agent: Work Bot')
|
||||
expect(labels[resolve(home, 'molt-family', 'skills')]).toBe('Agent: family')
|
||||
expect(labels[resolve(home, 'shared', 'skills')]).toBe('Extra: skills')
|
||||
expect(labels[resolve('/opt/skills')]).toBe('Extra: skills')
|
||||
})
|
||||
|
||||
it('resolves default workspace from agents.defaults and agents.list', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'clawdhub-clawdbot-default-'))
|
||||
const base = await mkdtemp(join(tmpdir(), 'molthub-moltbot-default-'))
|
||||
const home = join(base, 'home')
|
||||
const stateDir = join(base, 'state')
|
||||
const configPath = join(base, 'clawdbot.json')
|
||||
const configPath = join(base, 'moltbot.json')
|
||||
const workspaceMain = join(base, 'workspace-main')
|
||||
const workspaceList = join(base, 'workspace-list')
|
||||
|
||||
process.env.HOME = home
|
||||
process.env.CLAWDBOT_STATE_DIR = stateDir
|
||||
process.env.CLAWDBOT_CONFIG_PATH = configPath
|
||||
process.env.MOLTBOT_STATE_DIR = stateDir
|
||||
process.env.MOLTBOT_CONFIG_PATH = configPath
|
||||
|
||||
const config = `{
|
||||
agents: {
|
||||
@@ -87,19 +87,19 @@ describe('resolveClawdbotSkillRoots', () => {
|
||||
}`
|
||||
await writeFile(configPath, config, 'utf8')
|
||||
|
||||
const workspace = await resolveClawdbotDefaultWorkspace()
|
||||
const workspace = await resolveMoltbotDefaultWorkspace()
|
||||
expect(workspace).toBe(resolve(workspaceMain))
|
||||
})
|
||||
|
||||
it('falls back to default agent in agents.list when defaults missing', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'clawdhub-clawdbot-list-'))
|
||||
const base = await mkdtemp(join(tmpdir(), 'molthub-moltbot-list-'))
|
||||
const home = join(base, 'home')
|
||||
const configPath = join(base, 'clawdbot.json')
|
||||
const configPath = join(base, 'moltbot.json')
|
||||
const workspaceMain = join(base, 'workspace-main')
|
||||
const workspaceWork = join(base, 'workspace-work')
|
||||
|
||||
process.env.HOME = home
|
||||
process.env.CLAWDBOT_CONFIG_PATH = configPath
|
||||
process.env.MOLTBOT_CONFIG_PATH = configPath
|
||||
|
||||
const config = `{
|
||||
agents: {
|
||||
@@ -111,19 +111,19 @@ describe('resolveClawdbotSkillRoots', () => {
|
||||
}`
|
||||
await writeFile(configPath, config, 'utf8')
|
||||
|
||||
const workspace = await resolveClawdbotDefaultWorkspace()
|
||||
const workspace = await resolveMoltbotDefaultWorkspace()
|
||||
expect(workspace).toBe(resolve(workspaceMain))
|
||||
})
|
||||
|
||||
it('respects CLAWDBOT_STATE_DIR and CLAWDBOT_CONFIG_PATH overrides', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'clawdhub-clawdbot-override-'))
|
||||
it('respects MOLTBOT_STATE_DIR and MOLTBOT_CONFIG_PATH overrides', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'molthub-moltbot-override-'))
|
||||
const home = join(base, 'home')
|
||||
const stateDir = join(base, 'custom-state')
|
||||
const configPath = join(base, 'config', 'clawdbot.json')
|
||||
const configPath = join(base, 'config', 'moltbot.json')
|
||||
|
||||
process.env.HOME = home
|
||||
process.env.CLAWDBOT_STATE_DIR = stateDir
|
||||
process.env.CLAWDBOT_CONFIG_PATH = configPath
|
||||
process.env.MOLTBOT_STATE_DIR = stateDir
|
||||
process.env.MOLTBOT_CONFIG_PATH = configPath
|
||||
|
||||
const config = `{
|
||||
agent: { workspace: "${join(base, 'workspace-main')}" },
|
||||
@@ -131,7 +131,7 @@ describe('resolveClawdbotSkillRoots', () => {
|
||||
await mkdir(join(base, 'config'), { recursive: true })
|
||||
await writeFile(configPath, config, 'utf8')
|
||||
|
||||
const { roots, labels } = await resolveClawdbotSkillRoots()
|
||||
const { roots, labels } = await resolveMoltbotSkillRoots()
|
||||
|
||||
expect(roots).toEqual(
|
||||
expect.arrayContaining([
|
||||
@@ -144,14 +144,14 @@ describe('resolveClawdbotSkillRoots', () => {
|
||||
})
|
||||
|
||||
it('returns shared skills root when config is missing', async () => {
|
||||
const base = await mkdtemp(join(tmpdir(), 'clawdhub-clawdbot-missing-'))
|
||||
const base = await mkdtemp(join(tmpdir(), 'molthub-moltbot-missing-'))
|
||||
const stateDir = join(base, 'state')
|
||||
const configPath = join(base, 'missing', 'clawdbot.json')
|
||||
const configPath = join(base, 'missing', 'moltbot.json')
|
||||
|
||||
process.env.CLAWDBOT_STATE_DIR = stateDir
|
||||
process.env.CLAWDBOT_CONFIG_PATH = configPath
|
||||
process.env.MOLTBOT_STATE_DIR = stateDir
|
||||
process.env.MOLTBOT_CONFIG_PATH = configPath
|
||||
|
||||
const { roots, labels } = await resolveClawdbotSkillRoots()
|
||||
const { roots, labels } = await resolveMoltbotSkillRoots()
|
||||
|
||||
expect(roots).toEqual([resolve(stateDir, 'skills')])
|
||||
expect(labels[resolve(stateDir, 'skills')]).toBe('Shared skills')
|
||||
+16
-16
@@ -3,7 +3,7 @@ import { homedir } from 'node:os'
|
||||
import { basename, join, resolve } from 'node:path'
|
||||
import JSON5 from 'json5'
|
||||
|
||||
type ClawdbotConfig = {
|
||||
type MoltbotConfig = {
|
||||
agent?: { workspace?: string }
|
||||
agents?: {
|
||||
defaults?: { workspace?: string }
|
||||
@@ -30,20 +30,20 @@ type ClawdbotConfig = {
|
||||
}
|
||||
}
|
||||
|
||||
export type ClawdbotSkillRoots = {
|
||||
export type MoltbotSkillRoots = {
|
||||
roots: string[]
|
||||
labels: Record<string, string>
|
||||
}
|
||||
|
||||
export async function resolveClawdbotSkillRoots(): Promise<ClawdbotSkillRoots> {
|
||||
export async function resolveMoltbotSkillRoots(): Promise<MoltbotSkillRoots> {
|
||||
const roots: string[] = []
|
||||
const labels: Record<string, string> = {}
|
||||
|
||||
const stateDir = resolveClawdbotStateDir()
|
||||
const stateDir = resolveMoltbotStateDir()
|
||||
const sharedSkills = resolveUserPath(join(stateDir, 'skills'))
|
||||
pushRoot(roots, labels, sharedSkills, 'Shared skills')
|
||||
|
||||
const config = await readClawdbotConfig()
|
||||
const config = await readMoltbotConfig()
|
||||
if (!config) return { roots, labels }
|
||||
|
||||
const mainWorkspace = resolveUserPath(
|
||||
@@ -80,8 +80,8 @@ export async function resolveClawdbotSkillRoots(): Promise<ClawdbotSkillRoots> {
|
||||
return { roots, labels }
|
||||
}
|
||||
|
||||
export async function resolveClawdbotDefaultWorkspace(): Promise<string | null> {
|
||||
const config = await readClawdbotConfig()
|
||||
export async function resolveMoltbotDefaultWorkspace(): Promise<string | null> {
|
||||
const config = await readMoltbotConfig()
|
||||
if (!config) return null
|
||||
|
||||
const defaultsWorkspace = resolveUserPath(
|
||||
@@ -96,16 +96,16 @@ export async function resolveClawdbotDefaultWorkspace(): Promise<string | null>
|
||||
return listWorkspace || null
|
||||
}
|
||||
|
||||
function resolveClawdbotStateDir() {
|
||||
const override = process.env.CLAWDBOT_STATE_DIR?.trim()
|
||||
function resolveMoltbotStateDir() {
|
||||
const override = process.env.MOLTBOT_STATE_DIR?.trim()
|
||||
if (override) return resolveUserPath(override)
|
||||
return join(homedir(), '.clawdbot')
|
||||
return join(homedir(), '.moltbot')
|
||||
}
|
||||
|
||||
function resolveClawdbotConfigPath() {
|
||||
const override = process.env.CLAWDBOT_CONFIG_PATH?.trim()
|
||||
function resolveMoltbotConfigPath() {
|
||||
const override = process.env.MOLTBOT_CONFIG_PATH?.trim()
|
||||
if (override) return resolveUserPath(override)
|
||||
return join(resolveClawdbotStateDir(), 'clawdbot.json')
|
||||
return join(resolveMoltbotStateDir(), 'moltbot.json')
|
||||
}
|
||||
|
||||
function resolveUserPath(input: string) {
|
||||
@@ -117,12 +117,12 @@ function resolveUserPath(input: string) {
|
||||
return resolve(trimmed)
|
||||
}
|
||||
|
||||
async function readClawdbotConfig(): Promise<ClawdbotConfig | null> {
|
||||
async function readMoltbotConfig(): Promise<MoltbotConfig | null> {
|
||||
try {
|
||||
const raw = await readFile(resolveClawdbotConfigPath(), 'utf8')
|
||||
const raw = await readFile(resolveMoltbotConfigPath(), 'utf8')
|
||||
const parsed = JSON5.parse(raw)
|
||||
if (!parsed || typeof parsed !== 'object') return null
|
||||
return parsed as ClawdbotConfig
|
||||
return parsed as MoltbotConfig
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
+7
-7
@@ -22,7 +22,7 @@ function makeOpts(overrides: Partial<GlobalOpts> = {}): GlobalOpts {
|
||||
return {
|
||||
workdir: '/work',
|
||||
dir: '/work/skills',
|
||||
site: 'https://clawdhub.com',
|
||||
site: 'https://molthub.com',
|
||||
registry: DEFAULT_REGISTRY,
|
||||
registrySource: 'default',
|
||||
...overrides,
|
||||
@@ -37,8 +37,8 @@ beforeEach(() => {
|
||||
|
||||
describe('registry resolution', () => {
|
||||
it('prefers explicit registry over discovery/cache', async () => {
|
||||
readGlobalConfig.mockResolvedValue({ registry: 'https://auth.clawdhub.com' })
|
||||
discoverRegistryFromSite.mockResolvedValue({ apiBase: 'https://clawdhub.com' })
|
||||
readGlobalConfig.mockResolvedValue({ registry: 'https://auth.molthub.com' })
|
||||
discoverRegistryFromSite.mockResolvedValue({ apiBase: 'https://molthub.com' })
|
||||
|
||||
const registry = await resolveRegistry(
|
||||
makeOpts({ registry: 'https://custom.example', registrySource: 'cli' }),
|
||||
@@ -49,14 +49,14 @@ describe('registry resolution', () => {
|
||||
})
|
||||
|
||||
it('ignores legacy registry and updates cache from discovery', async () => {
|
||||
readGlobalConfig.mockResolvedValue({ registry: 'https://auth.clawdhub.com', token: 'tkn' })
|
||||
discoverRegistryFromSite.mockResolvedValue({ apiBase: 'https://clawdhub.com' })
|
||||
readGlobalConfig.mockResolvedValue({ registry: 'https://auth.molthub.com', token: 'tkn' })
|
||||
discoverRegistryFromSite.mockResolvedValue({ apiBase: 'https://molthub.com' })
|
||||
|
||||
const registry = await getRegistry(makeOpts(), { cache: true })
|
||||
|
||||
expect(registry).toBe('https://clawdhub.com')
|
||||
expect(registry).toBe('https://molthub.com')
|
||||
expect(writeGlobalConfig).toHaveBeenCalledWith({
|
||||
registry: 'https://clawdhub.com',
|
||||
registry: 'https://molthub.com',
|
||||
token: 'tkn',
|
||||
})
|
||||
})
|
||||
@@ -2,9 +2,9 @@ import { readGlobalConfig, writeGlobalConfig } from '../config.js'
|
||||
import { discoverRegistryFromSite } from '../discovery.js'
|
||||
import type { GlobalOpts } from './types.js'
|
||||
|
||||
export const DEFAULT_SITE = 'https://clawdhub.com'
|
||||
export const DEFAULT_REGISTRY = 'https://clawdhub.com'
|
||||
const LEGACY_REGISTRY_HOSTS = new Set(['auth.clawdhub.com'])
|
||||
export const DEFAULT_SITE = 'https://molthub.com'
|
||||
export const DEFAULT_REGISTRY = 'https://molthub.com'
|
||||
const LEGACY_REGISTRY_HOSTS = new Set(['auth.molthub.com'])
|
||||
|
||||
export async function resolveRegistry(opts: GlobalOpts) {
|
||||
const explicit = opts.registrySource !== 'default' ? opts.registry.trim() : ''
|
||||
+4
-4
@@ -7,7 +7,7 @@ import { describe, expect, it } from 'vitest'
|
||||
import { findSkillFolders, getFallbackSkillRoots } from './scanSkills'
|
||||
|
||||
async function makeTmpDir() {
|
||||
return mkdtemp(join(tmpdir(), 'clawdhub-scan-'))
|
||||
return mkdtemp(join(tmpdir(), 'molthub-scan-'))
|
||||
}
|
||||
|
||||
describe('scanSkills', () => {
|
||||
@@ -57,8 +57,8 @@ describe('scanSkills', () => {
|
||||
|
||||
it('includes known legacy roots', () => {
|
||||
const roots = getFallbackSkillRoots('/tmp/anywhere')
|
||||
expect(roots.some((p) => p.endsWith('/clawdis/skills'))).toBe(true)
|
||||
expect(roots.some((p) => p.endsWith('/clawd/skills'))).toBe(true)
|
||||
expect(roots.some((p) => p.endsWith('/clawdbot/skills'))).toBe(true)
|
||||
expect(roots.some((p) => p.endsWith('/moltbot/skills'))).toBe(true)
|
||||
expect(roots.some((p) => p.endsWith('/molt/skills'))).toBe(true)
|
||||
expect(roots.some((p) => p.endsWith('/moltbot/skills'))).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -33,32 +33,32 @@ export function getFallbackSkillRoots(workdir: string) {
|
||||
const home = homedir()
|
||||
const roots = [
|
||||
// adjacent repo installs
|
||||
resolve(workdir, '..', 'clawdis', 'skills'),
|
||||
resolve(workdir, '..', 'clawdis', 'Skills'),
|
||||
resolve(workdir, '..', 'clawdbot', 'skills'),
|
||||
resolve(workdir, '..', 'clawdbot', 'Skills'),
|
||||
resolve(workdir, '..', 'moltbot', 'skills'),
|
||||
resolve(workdir, '..', 'moltbot', 'Skills'),
|
||||
resolve(workdir, '..', 'moltbot', 'skills'),
|
||||
resolve(workdir, '..', 'moltbot', 'Skills'),
|
||||
|
||||
// legacy locations
|
||||
resolve(home, 'clawd', 'skills'),
|
||||
resolve(home, 'clawd', 'Skills'),
|
||||
resolve(home, '.clawd', 'skills'),
|
||||
resolve(home, '.clawd', 'Skills'),
|
||||
resolve(home, 'molt', 'skills'),
|
||||
resolve(home, 'molt', 'Skills'),
|
||||
resolve(home, '.molt', 'skills'),
|
||||
resolve(home, '.molt', 'Skills'),
|
||||
|
||||
resolve(home, 'clawdbot', 'skills'),
|
||||
resolve(home, 'clawdbot', 'Skills'),
|
||||
resolve(home, '.clawdbot', 'skills'),
|
||||
resolve(home, '.clawdbot', 'Skills'),
|
||||
resolve(home, 'moltbot', 'skills'),
|
||||
resolve(home, 'moltbot', 'Skills'),
|
||||
resolve(home, '.moltbot', 'skills'),
|
||||
resolve(home, '.moltbot', 'Skills'),
|
||||
|
||||
resolve(home, 'clawdis', 'skills'),
|
||||
resolve(home, 'clawdis', 'Skills'),
|
||||
resolve(home, '.clawdis', 'skills'),
|
||||
resolve(home, '.clawdis', 'Skills'),
|
||||
resolve(home, 'moltbot', 'skills'),
|
||||
resolve(home, 'moltbot', 'Skills'),
|
||||
resolve(home, '.moltbot', 'skills'),
|
||||
resolve(home, '.moltbot', 'Skills'),
|
||||
|
||||
// macOS App Support legacy
|
||||
resolve(home, 'Library', 'Application Support', 'clawdbot', 'skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'clawdbot', 'Skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'clawdis', 'skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'clawdis', 'Skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'moltbot', 'skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'moltbot', 'Skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'moltbot', 'skills'),
|
||||
resolve(home, 'Library', 'Application Support', 'moltbot', 'Skills'),
|
||||
]
|
||||
return Array.from(new Set(roots))
|
||||
}
|
||||
@@ -4,19 +4,19 @@ import { dirname, join, resolve } from 'node:path'
|
||||
import { type GlobalConfig, GlobalConfigSchema, parseArk } from './schema/index.js'
|
||||
|
||||
export function getGlobalConfigPath() {
|
||||
const override = process.env.CLAWDHUB_CONFIG_PATH?.trim()
|
||||
const override = process.env.MOLTHUB_CONFIG_PATH?.trim()
|
||||
if (override) return resolve(override)
|
||||
const home = homedir()
|
||||
if (process.platform === 'darwin') {
|
||||
return join(home, 'Library', 'Application Support', 'clawdhub', 'config.json')
|
||||
return join(home, 'Library', 'Application Support', 'molthub', 'config.json')
|
||||
}
|
||||
const xdg = process.env.XDG_CONFIG_HOME
|
||||
if (xdg) return join(xdg, 'clawdhub', 'config.json')
|
||||
if (xdg) return join(xdg, 'molthub', 'config.json')
|
||||
if (process.platform === 'win32') {
|
||||
const appData = process.env.APPDATA
|
||||
if (appData) return join(appData, 'clawdhub', 'config.json')
|
||||
if (appData) return join(appData, 'molthub', 'config.json')
|
||||
}
|
||||
return join(home, '.config', 'clawdhub', 'config.json')
|
||||
return join(home, '.config', 'molthub', 'config.json')
|
||||
}
|
||||
|
||||
export async function readGlobalConfig(): Promise<GlobalConfig | null> {
|
||||
@@ -1,7 +1,7 @@
|
||||
import { parseArk, WellKnownConfigSchema } from './schema/index.js'
|
||||
|
||||
export async function discoverRegistryFromSite(siteUrl: string) {
|
||||
const url = new URL('/.well-known/clawdhub.json', siteUrl)
|
||||
const url = new URL('/.well-known/molthub.json', siteUrl)
|
||||
const response = await fetch(url.toString(), {
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/json' },
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user