corporateai 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +10 -0
- package/.env.example +3 -0
- package/.github/workflows/publish-cli.yml +49 -0
- package/.mailmap +1 -0
- package/AGENTS.md +148 -0
- package/CONTRIBUTING.md +75 -0
- package/Dockerfile +59 -0
- package/Dockerfile.onboard-smoke +42 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/cli/esbuild.config.mjs +11 -0
- package/cli/package.json +24 -0
- package/cli/scripts/build-cli.mjs +5 -0
- package/cli/src/index.ts +27 -0
- package/docker-compose.quickstart.yml +18 -0
- package/docker-compose.untrusted-review.yml +33 -0
- package/docker-compose.yml +38 -0
- package/package.json +56 -0
- package/patches/embedded-postgres@18.1.0-beta.16.patch +0 -0
- package/pnpm-workspace.yaml +4 -0
- package/releases/.gitkeep +0 -0
- package/releases/v0.0.1.md +36 -0
- package/releases/v0.2.7.md +15 -0
- package/releases/v0.3.0.md +54 -0
- package/releases/v0.3.1.md +55 -0
- package/releases/v2026.318.0.md +66 -0
- package/releases/v2026.325.0.md +78 -0
- package/report/2026-03-13-08-46-token-optimization-implementation.md +48 -0
- package/scripts/backup-db.sh +17 -0
- package/scripts/build-npm.sh +80 -0
- package/scripts/check-forbidden-tokens.mjs +115 -0
- package/scripts/clean-onboard-git.sh +14 -0
- package/scripts/clean-onboard-npm.sh +13 -0
- package/scripts/clean-onboard-ref.sh +86 -0
- package/scripts/create-github-release.sh +99 -0
- package/scripts/dev-runner-paths.mjs +38 -0
- package/scripts/dev-runner.mjs +606 -0
- package/scripts/docker-onboard-smoke.sh +306 -0
- package/scripts/ensure-plugin-build-deps.mjs +47 -0
- package/scripts/generate-company-assets.ts +365 -0
- package/scripts/generate-npm-package-json.mjs +113 -0
- package/scripts/generate-org-chart-images.ts +694 -0
- package/scripts/generate-org-chart-satori-comparison.ts +225 -0
- package/scripts/generate-ui-package-json.mjs +31 -0
- package/scripts/kill-dev.sh +71 -0
- package/scripts/migrate-inline-env-secrets.ts +126 -0
- package/scripts/prepare-server-ui-dist.sh +22 -0
- package/scripts/provision-worktree.sh +333 -0
- package/scripts/release-lib.sh +306 -0
- package/scripts/release-package-map.mjs +169 -0
- package/scripts/release.sh +312 -0
- package/scripts/rollback-latest.sh +111 -0
- package/scripts/smoke/openclaw-docker-ui.sh +329 -0
- package/scripts/smoke/openclaw-gateway-e2e.sh +954 -0
- package/scripts/smoke/openclaw-join.sh +295 -0
- package/scripts/smoke/openclaw-sse-standalone.sh +146 -0
- package/scripts/workspace-compat.mjs +60 -0
- package/server/CHANGELOG.md +130 -0
- package/server/package.json +96 -0
- package/server/scripts/copy-onboarding-assets.mjs +10 -0
- package/server/scripts/dev-watch.ts +33 -0
- package/server/src/__tests__/activity-routes.test.ts +70 -0
- package/server/src/__tests__/adapter-models.test.ts +105 -0
- package/server/src/__tests__/adapter-session-codecs.test.ts +194 -0
- package/server/src/__tests__/agent-auth-jwt.test.ts +79 -0
- package/server/src/__tests__/agent-instructions-routes.test.ts +318 -0
- package/server/src/__tests__/agent-instructions-service.test.ts +361 -0
- package/server/src/__tests__/agent-permissions-routes.test.ts +275 -0
- package/server/src/__tests__/agent-shortname-collision.test.ts +69 -0
- package/server/src/__tests__/agent-skill-contract.test.ts +50 -0
- package/server/src/__tests__/agent-skills-routes.test.ts +462 -0
- package/server/src/__tests__/app-hmr-port.test.ts +19 -0
- package/server/src/__tests__/approval-routes-idempotency.test.ts +110 -0
- package/server/src/__tests__/approvals-service.test.ts +107 -0
- package/server/src/__tests__/assets.test.ts +250 -0
- package/server/src/__tests__/attachment-types.test.ts +97 -0
- package/server/src/__tests__/board-mutation-guard.test.ts +105 -0
- package/server/src/__tests__/budgets-service.test.ts +311 -0
- package/server/src/__tests__/claude-local-adapter-environment.test.ts +92 -0
- package/server/src/__tests__/claude-local-adapter.test.ts +31 -0
- package/server/src/__tests__/claude-local-skill-sync.test.ts +111 -0
- package/server/src/__tests__/cli-auth-routes.test.ts +230 -0
- package/server/src/__tests__/codex-local-adapter-environment.test.ts +143 -0
- package/server/src/__tests__/codex-local-adapter.test.ts +253 -0
- package/server/src/__tests__/codex-local-execute.test.ts +391 -0
- package/server/src/__tests__/codex-local-skill-injection.test.ts +175 -0
- package/server/src/__tests__/codex-local-skill-sync.test.ts +123 -0
- package/server/src/__tests__/companies-route-path-guard.test.ts +56 -0
- package/server/src/__tests__/company-branding-route.test.ts +196 -0
- package/server/src/__tests__/company-portability-routes.test.ts +175 -0
- package/server/src/__tests__/company-portability.test.ts +2186 -0
- package/server/src/__tests__/company-skills-routes.test.ts +113 -0
- package/server/src/__tests__/company-skills.test.ts +229 -0
- package/server/src/__tests__/costs-service.test.ts +226 -0
- package/server/src/__tests__/cursor-local-adapter-environment.test.ts +196 -0
- package/server/src/__tests__/cursor-local-adapter.test.ts +406 -0
- package/server/src/__tests__/cursor-local-execute.test.ts +263 -0
- package/server/src/__tests__/cursor-local-skill-injection.test.ts +104 -0
- package/server/src/__tests__/cursor-local-skill-sync.test.ts +145 -0
- package/server/src/__tests__/dev-runner-paths.test.ts +25 -0
- package/server/src/__tests__/dev-server-status.test.ts +66 -0
- package/server/src/__tests__/dev-watch-ignore.test.ts +42 -0
- package/server/src/__tests__/documents.test.ts +29 -0
- package/server/src/__tests__/error-handler.test.ts +53 -0
- package/server/src/__tests__/execution-workspace-policy.test.ts +170 -0
- package/server/src/__tests__/forbidden-tokens.test.ts +77 -0
- package/server/src/__tests__/gemini-local-adapter-environment.test.ts +135 -0
- package/server/src/__tests__/gemini-local-adapter.test.ts +190 -0
- package/server/src/__tests__/gemini-local-execute.test.ts +172 -0
- package/server/src/__tests__/gemini-local-skill-sync.test.ts +90 -0
- package/server/src/__tests__/health.test.ts +16 -0
- package/server/src/__tests__/heartbeat-process-recovery.test.ts +256 -0
- package/server/src/__tests__/heartbeat-run-summary.test.ts +33 -0
- package/server/src/__tests__/heartbeat-workspace-session.test.ts +334 -0
- package/server/src/__tests__/helpers/embedded-postgres.ts +7 -0
- package/server/src/__tests__/hire-hook.test.ts +181 -0
- package/server/src/__tests__/instance-settings-routes.test.ts +156 -0
- package/server/src/__tests__/invite-accept-gateway-defaults.test.ts +119 -0
- package/server/src/__tests__/invite-accept-replay.test.ts +92 -0
- package/server/src/__tests__/invite-expiry.test.ts +10 -0
- package/server/src/__tests__/invite-join-grants.test.ts +57 -0
- package/server/src/__tests__/invite-join-manager.test.ts +33 -0
- package/server/src/__tests__/invite-onboarding-text.test.ts +116 -0
- package/server/src/__tests__/issue-comment-reopen-routes.test.ts +146 -0
- package/server/src/__tests__/issue-goal-fallback.test.ts +99 -0
- package/server/src/__tests__/issues-checkout-wakeup.test.ts +48 -0
- package/server/src/__tests__/issues-goal-context-routes.test.ts +187 -0
- package/server/src/__tests__/issues-service.test.ts +317 -0
- package/server/src/__tests__/issues-user-context.test.ts +113 -0
- package/server/src/__tests__/log-redaction.test.ts +74 -0
- package/server/src/__tests__/monthly-spend-service.test.ts +90 -0
- package/server/src/__tests__/normalize-agent-mention-token.test.ts +41 -0
- package/server/src/__tests__/openclaw-gateway-adapter.test.ts +626 -0
- package/server/src/__tests__/openclaw-invite-prompt-route.test.ts +192 -0
- package/server/src/__tests__/opencode-local-adapter-environment.test.ts +97 -0
- package/server/src/__tests__/opencode-local-adapter.test.ts +226 -0
- package/server/src/__tests__/opencode-local-skill-sync.test.ts +91 -0
- package/server/src/__tests__/paperclip-env.test.ts +58 -0
- package/server/src/__tests__/paperclip-skill-utils.test.ts +63 -0
- package/server/src/__tests__/pi-local-adapter-environment.test.ts +102 -0
- package/server/src/__tests__/pi-local-skill-sync.test.ts +95 -0
- package/server/src/__tests__/plugin-dev-watcher.test.ts +68 -0
- package/server/src/__tests__/plugin-worker-manager.test.ts +43 -0
- package/server/src/__tests__/private-hostname-guard.test.ts +56 -0
- package/server/src/__tests__/project-shortname-resolution.test.ts +45 -0
- package/server/src/__tests__/quota-windows-service.test.ts +56 -0
- package/server/src/__tests__/quota-windows.test.ts +1109 -0
- package/server/src/__tests__/redaction.test.ts +66 -0
- package/server/src/__tests__/routines-e2e.test.ts +276 -0
- package/server/src/__tests__/routines-routes.test.ts +271 -0
- package/server/src/__tests__/routines-service.test.ts +424 -0
- package/server/src/__tests__/storage-local-provider.test.ts +78 -0
- package/server/src/__tests__/ui-branding.test.ts +82 -0
- package/server/src/__tests__/work-products.test.ts +95 -0
- package/server/src/__tests__/workspace-runtime.test.ts +1131 -0
- package/server/src/__tests__/worktree-config.test.ts +426 -0
- package/server/src/adapters/codex-models.ts +105 -0
- package/server/src/adapters/cursor-models.ts +171 -0
- package/server/src/adapters/http/execute.ts +42 -0
- package/server/src/adapters/http/index.ts +21 -0
- package/server/src/adapters/http/test.ts +116 -0
- package/server/src/adapters/index.ts +18 -0
- package/server/src/adapters/process/execute.ts +77 -0
- package/server/src/adapters/process/index.ts +24 -0
- package/server/src/adapters/process/test.ts +89 -0
- package/server/src/adapters/registry.ts +225 -0
- package/server/src/adapters/server-utils-compat.ts +57 -0
- package/server/src/adapters/types.ts +30 -0
- package/server/src/adapters/utils.ts +48 -0
- package/server/src/agent-auth-jwt.ts +141 -0
- package/server/src/app.ts +321 -0
- package/server/src/attachment-types.ts +74 -0
- package/server/src/auth/better-auth.ts +148 -0
- package/server/src/board-claim.ts +150 -0
- package/server/src/config-file.ts +17 -0
- package/server/src/config.ts +260 -0
- package/server/src/dev-server-status.ts +103 -0
- package/server/src/dev-watch-ignore.ts +36 -0
- package/server/src/errors.ts +34 -0
- package/server/src/home-paths.ts +95 -0
- package/server/src/index.ts +799 -0
- package/server/src/log-redaction.ts +146 -0
- package/server/src/middleware/auth.ts +178 -0
- package/server/src/middleware/board-mutation-guard.ts +66 -0
- package/server/src/middleware/error-handler.ts +71 -0
- package/server/src/middleware/index.ts +3 -0
- package/server/src/middleware/logger.ts +90 -0
- package/server/src/middleware/private-hostname-guard.ts +92 -0
- package/server/src/middleware/validate.ts +9 -0
- package/server/src/onboarding-assets/ceo/AGENTS.md +54 -0
- package/server/src/onboarding-assets/ceo/HEARTBEAT.md +72 -0
- package/server/src/onboarding-assets/ceo/SOUL.md +33 -0
- package/server/src/onboarding-assets/ceo/TOOLS.md +3 -0
- package/server/src/onboarding-assets/default/AGENTS.md +3 -0
- package/server/src/paths.ts +34 -0
- package/server/src/realtime/live-events-ws.ts +274 -0
- package/server/src/redaction.ts +59 -0
- package/server/src/routes/access.ts +2888 -0
- package/server/src/routes/activity.ts +89 -0
- package/server/src/routes/agents.ts +2313 -0
- package/server/src/routes/approvals.ts +346 -0
- package/server/src/routes/assets.ts +341 -0
- package/server/src/routes/authz.ts +52 -0
- package/server/src/routes/companies.ts +343 -0
- package/server/src/routes/company-skills.ts +300 -0
- package/server/src/routes/costs.ts +335 -0
- package/server/src/routes/dashboard.ts +19 -0
- package/server/src/routes/execution-workspaces.ts +182 -0
- package/server/src/routes/goals.ts +107 -0
- package/server/src/routes/health.ts +94 -0
- package/server/src/routes/index.ts +17 -0
- package/server/src/routes/instance-settings.ts +95 -0
- package/server/src/routes/issues-checkout-wakeup.ts +14 -0
- package/server/src/routes/issues.ts +1680 -0
- package/server/src/routes/llms.ts +86 -0
- package/server/src/routes/org-chart-svg.ts +777 -0
- package/server/src/routes/plugin-ui-static.ts +497 -0
- package/server/src/routes/plugins.ts +2220 -0
- package/server/src/routes/projects.ts +295 -0
- package/server/src/routes/routines.ts +300 -0
- package/server/src/routes/secrets.ts +166 -0
- package/server/src/routes/sidebar-badges.ts +52 -0
- package/server/src/secrets/external-stub-providers.ts +32 -0
- package/server/src/secrets/local-encrypted-provider.ts +135 -0
- package/server/src/secrets/provider-registry.ts +31 -0
- package/server/src/secrets/types.ts +23 -0
- package/server/src/services/access.ts +381 -0
- package/server/src/services/activity-log.ts +95 -0
- package/server/src/services/activity.ts +164 -0
- package/server/src/services/agent-instructions.ts +735 -0
- package/server/src/services/agent-permissions.ts +27 -0
- package/server/src/services/agents.ts +694 -0
- package/server/src/services/approvals.ts +273 -0
- package/server/src/services/assets.ts +23 -0
- package/server/src/services/board-auth.ts +355 -0
- package/server/src/services/budgets.ts +959 -0
- package/server/src/services/companies.ts +313 -0
- package/server/src/services/company-export-readme.ts +173 -0
- package/server/src/services/company-portability.ts +4263 -0
- package/server/src/services/company-skills.ts +2356 -0
- package/server/src/services/costs.ts +365 -0
- package/server/src/services/cron.ts +373 -0
- package/server/src/services/dashboard.ts +110 -0
- package/server/src/services/default-agent-instructions.ts +27 -0
- package/server/src/services/documents.ts +434 -0
- package/server/src/services/execution-workspace-policy.ts +210 -0
- package/server/src/services/execution-workspaces.ts +100 -0
- package/server/src/services/finance.ts +135 -0
- package/server/src/services/goals.ts +81 -0
- package/server/src/services/heartbeat-run-summary.ts +35 -0
- package/server/src/services/heartbeat.ts +3863 -0
- package/server/src/services/hire-hook.ts +114 -0
- package/server/src/services/index.ts +32 -0
- package/server/src/services/instance-settings.ts +138 -0
- package/server/src/services/issue-approvals.ts +175 -0
- package/server/src/services/issue-assignment-wakeup.ts +48 -0
- package/server/src/services/issue-goal-fallback.ts +56 -0
- package/server/src/services/issues.ts +1828 -0
- package/server/src/services/live-events.ts +55 -0
- package/server/src/services/plugin-capability-validator.ts +450 -0
- package/server/src/services/plugin-config-validator.ts +55 -0
- package/server/src/services/plugin-dev-watcher.ts +339 -0
- package/server/src/services/plugin-event-bus.ts +413 -0
- package/server/src/services/plugin-host-service-cleanup.ts +59 -0
- package/server/src/services/plugin-host-services.ts +1132 -0
- package/server/src/services/plugin-job-coordinator.ts +261 -0
- package/server/src/services/plugin-job-scheduler.ts +753 -0
- package/server/src/services/plugin-job-store.ts +466 -0
- package/server/src/services/plugin-lifecycle.ts +822 -0
- package/server/src/services/plugin-loader.ts +1955 -0
- package/server/src/services/plugin-log-retention.ts +87 -0
- package/server/src/services/plugin-manifest-validator.ts +164 -0
- package/server/src/services/plugin-registry.ts +683 -0
- package/server/src/services/plugin-runtime-sandbox.ts +222 -0
- package/server/src/services/plugin-secrets-handler.ts +355 -0
- package/server/src/services/plugin-state-store.ts +238 -0
- package/server/src/services/plugin-stream-bus.ts +81 -0
- package/server/src/services/plugin-tool-dispatcher.ts +449 -0
- package/server/src/services/plugin-tool-registry.ts +450 -0
- package/server/src/services/plugin-worker-manager.ts +1343 -0
- package/server/src/services/projects.ts +860 -0
- package/server/src/services/quota-windows.ts +65 -0
- package/server/src/services/routines.ts +1269 -0
- package/server/src/services/run-log-store.ts +156 -0
- package/server/src/services/secrets.ts +370 -0
- package/server/src/services/sidebar-badges.ts +56 -0
- package/server/src/services/work-products.ts +124 -0
- package/server/src/services/workspace-operation-log-store.ts +156 -0
- package/server/src/services/workspace-operations.ts +262 -0
- package/server/src/services/workspace-runtime.ts +1565 -0
- package/server/src/startup-banner.ts +176 -0
- package/server/src/storage/index.ts +35 -0
- package/server/src/storage/local-disk-provider.ts +89 -0
- package/server/src/storage/provider-registry.ts +18 -0
- package/server/src/storage/s3-provider.ts +153 -0
- package/server/src/storage/service.ts +131 -0
- package/server/src/storage/types.ts +63 -0
- package/server/src/ui-branding.ts +217 -0
- package/server/src/version.ts +10 -0
- package/server/src/worktree-config.ts +468 -0
- package/server/tsconfig.json +9 -0
- package/server/vitest.config.ts +7 -0
- package/skills/paperclip/SKILL.md +365 -0
- package/skills/paperclip/references/api-reference.md +647 -0
- package/skills/paperclip/references/company-skills.md +193 -0
- package/skills/paperclip-create-agent/SKILL.md +142 -0
- package/skills/paperclip-create-agent/references/api-reference.md +105 -0
- package/skills/paperclip-create-plugin/SKILL.md +102 -0
- package/skills/para-memory-files/SKILL.md +104 -0
- package/skills/para-memory-files/references/schemas.md +35 -0
- package/tests/e2e/onboarding.spec.ts +142 -0
- package/tests/e2e/playwright.config.ts +35 -0
- package/tests/release-smoke/docker-auth-onboarding.spec.ts +141 -0
- package/tests/release-smoke/playwright.config.ts +28 -0
- package/tsconfig.base.json +18 -0
- package/tsconfig.json +18 -0
- package/ui/README.md +12 -0
- package/ui/components.json +21 -0
- package/ui/index.html +47 -0
- package/ui/package.json +73 -0
- package/ui/public/android-chrome-192x192.png +0 -0
- package/ui/public/android-chrome-512x512.png +0 -0
- package/ui/public/apple-touch-icon.png +0 -0
- package/ui/public/brands/opencode-logo-dark-square.svg +18 -0
- package/ui/public/brands/opencode-logo-light-square.svg +18 -0
- package/ui/public/favicon-16x16.png +0 -0
- package/ui/public/favicon-32x32.png +0 -0
- package/ui/public/favicon.ico +0 -0
- package/ui/public/favicon.svg +9 -0
- package/ui/public/site.webmanifest +30 -0
- package/ui/public/sprites/1-D-1.png +0 -0
- package/ui/public/sprites/1-D-2.png +0 -0
- package/ui/public/sprites/1-D-3.png +0 -0
- package/ui/public/sprites/1-L-1.png +0 -0
- package/ui/public/sprites/1-R-1.png +0 -0
- package/ui/public/sprites/10-D-1.png +0 -0
- package/ui/public/sprites/10-D-2.png +0 -0
- package/ui/public/sprites/10-D-3.png +0 -0
- package/ui/public/sprites/10-L-1.png +0 -0
- package/ui/public/sprites/10-R-1.png +0 -0
- package/ui/public/sprites/11-D-1.png +0 -0
- package/ui/public/sprites/11-D-2.png +0 -0
- package/ui/public/sprites/11-D-3.png +0 -0
- package/ui/public/sprites/11-L-1.png +0 -0
- package/ui/public/sprites/11-R-1.png +0 -0
- package/ui/public/sprites/12-D-1.png +0 -0
- package/ui/public/sprites/12-D-2.png +0 -0
- package/ui/public/sprites/12-D-3.png +0 -0
- package/ui/public/sprites/12-L-1.png +0 -0
- package/ui/public/sprites/12-R-1.png +0 -0
- package/ui/public/sprites/13-D-1.png +0 -0
- package/ui/public/sprites/13-D-2.png +0 -0
- package/ui/public/sprites/13-D-3.png +0 -0
- package/ui/public/sprites/13-L-1.png +0 -0
- package/ui/public/sprites/13-R-1.png +0 -0
- package/ui/public/sprites/14-D-1.png +0 -0
- package/ui/public/sprites/14-D-2.png +0 -0
- package/ui/public/sprites/14-D-3.png +0 -0
- package/ui/public/sprites/14-L-1.png +0 -0
- package/ui/public/sprites/14-R-1.png +0 -0
- package/ui/public/sprites/2-D-1.png +0 -0
- package/ui/public/sprites/2-D-2.png +0 -0
- package/ui/public/sprites/2-D-3.png +0 -0
- package/ui/public/sprites/2-L-1.png +0 -0
- package/ui/public/sprites/2-R-1.png +0 -0
- package/ui/public/sprites/3-D-1.png +0 -0
- package/ui/public/sprites/3-D-2.png +0 -0
- package/ui/public/sprites/3-D-3.png +0 -0
- package/ui/public/sprites/3-L-1.png +0 -0
- package/ui/public/sprites/3-R-1.png +0 -0
- package/ui/public/sprites/4-D-1.png +0 -0
- package/ui/public/sprites/4-D-2.png +0 -0
- package/ui/public/sprites/4-D-3.png +0 -0
- package/ui/public/sprites/4-L-1.png +0 -0
- package/ui/public/sprites/4-R-1.png +0 -0
- package/ui/public/sprites/5-D-1.png +0 -0
- package/ui/public/sprites/5-D-2.png +0 -0
- package/ui/public/sprites/5-D-3.png +0 -0
- package/ui/public/sprites/5-L-1.png +0 -0
- package/ui/public/sprites/5-R-1.png +0 -0
- package/ui/public/sprites/6-D-1.png +0 -0
- package/ui/public/sprites/6-D-2.png +0 -0
- package/ui/public/sprites/6-D-3.png +0 -0
- package/ui/public/sprites/6-L-1.png +0 -0
- package/ui/public/sprites/6-R-1.png +0 -0
- package/ui/public/sprites/7-D-1.png +0 -0
- package/ui/public/sprites/7-D-2.png +0 -0
- package/ui/public/sprites/7-D-3.png +0 -0
- package/ui/public/sprites/7-L-1.png +0 -0
- package/ui/public/sprites/7-R-1.png +0 -0
- package/ui/public/sprites/8-D-1.png +0 -0
- package/ui/public/sprites/8-D-2.png +0 -0
- package/ui/public/sprites/8-D-3.png +0 -0
- package/ui/public/sprites/8-L-1.png +0 -0
- package/ui/public/sprites/8-R-1.png +0 -0
- package/ui/public/sprites/9-D-1.png +0 -0
- package/ui/public/sprites/9-D-2.png +0 -0
- package/ui/public/sprites/9-D-3.png +0 -0
- package/ui/public/sprites/9-L-1.png +0 -0
- package/ui/public/sprites/9-R-1.png +0 -0
- package/ui/public/sprites/ceo-lobster.png +0 -0
- package/ui/public/sw.js +42 -0
- package/ui/public/worktree-favicon-16x16.png +0 -0
- package/ui/public/worktree-favicon-32x32.png +0 -0
- package/ui/public/worktree-favicon.ico +0 -0
- package/ui/public/worktree-favicon.svg +9 -0
- package/ui/src/App.tsx +354 -0
- package/ui/src/adapters/claude-local/config-fields.tsx +138 -0
- package/ui/src/adapters/claude-local/index.ts +13 -0
- package/ui/src/adapters/codex-local/config-fields.tsx +104 -0
- package/ui/src/adapters/codex-local/index.ts +13 -0
- package/ui/src/adapters/cursor/config-fields.tsx +49 -0
- package/ui/src/adapters/cursor/index.ts +13 -0
- package/ui/src/adapters/gemini-local/config-fields.tsx +51 -0
- package/ui/src/adapters/gemini-local/index.ts +13 -0
- package/ui/src/adapters/http/build-config.ts +9 -0
- package/ui/src/adapters/http/config-fields.tsx +38 -0
- package/ui/src/adapters/http/index.ts +12 -0
- package/ui/src/adapters/http/parse-stdout.ts +5 -0
- package/ui/src/adapters/index.ts +9 -0
- package/ui/src/adapters/local-workspace-runtime-fields.tsx +5 -0
- package/ui/src/adapters/openclaw-gateway/config-fields.tsx +237 -0
- package/ui/src/adapters/openclaw-gateway/index.ts +13 -0
- package/ui/src/adapters/opencode-local/config-fields.tsx +72 -0
- package/ui/src/adapters/opencode-local/index.ts +13 -0
- package/ui/src/adapters/pi-local/config-fields.tsx +49 -0
- package/ui/src/adapters/pi-local/index.ts +13 -0
- package/ui/src/adapters/process/build-config.ts +18 -0
- package/ui/src/adapters/process/config-fields.tsx +77 -0
- package/ui/src/adapters/process/index.ts +12 -0
- package/ui/src/adapters/process/parse-stdout.ts +5 -0
- package/ui/src/adapters/registry.ts +34 -0
- package/ui/src/adapters/runtime-json-fields.tsx +122 -0
- package/ui/src/adapters/transcript.test.ts +30 -0
- package/ui/src/adapters/transcript.ts +62 -0
- package/ui/src/adapters/types.ts +34 -0
- package/ui/src/api/access.ts +160 -0
- package/ui/src/api/activity.ts +37 -0
- package/ui/src/api/agents.ts +194 -0
- package/ui/src/api/approvals.ts +25 -0
- package/ui/src/api/assets.ts +30 -0
- package/ui/src/api/auth.ts +74 -0
- package/ui/src/api/budgets.ts +21 -0
- package/ui/src/api/client.ts +50 -0
- package/ui/src/api/companies.ts +59 -0
- package/ui/src/api/companySkills.ts +55 -0
- package/ui/src/api/costs.ts +60 -0
- package/ui/src/api/dashboard.ts +7 -0
- package/ui/src/api/execution-workspaces.ts +27 -0
- package/ui/src/api/goals.ts +12 -0
- package/ui/src/api/health.ts +41 -0
- package/ui/src/api/heartbeats.ts +62 -0
- package/ui/src/api/index.ts +18 -0
- package/ui/src/api/instanceSettings.ts +19 -0
- package/ui/src/api/issues.ts +115 -0
- package/ui/src/api/plugins.ts +424 -0
- package/ui/src/api/projects.ts +34 -0
- package/ui/src/api/routines.ts +59 -0
- package/ui/src/api/secrets.ts +26 -0
- package/ui/src/api/sidebarBadges.ts +7 -0
- package/ui/src/components/AccountingModelCard.tsx +69 -0
- package/ui/src/components/ActiveAgentsPanel.tsx +157 -0
- package/ui/src/components/ActivityCharts.tsx +264 -0
- package/ui/src/components/ActivityRow.tsx +147 -0
- package/ui/src/components/AgentActionButtons.tsx +51 -0
- package/ui/src/components/AgentConfigForm.tsx +1468 -0
- package/ui/src/components/AgentIconPicker.tsx +81 -0
- package/ui/src/components/AgentProperties.tsx +107 -0
- package/ui/src/components/ApprovalCard.tsx +107 -0
- package/ui/src/components/ApprovalPayload.tsx +134 -0
- package/ui/src/components/AsciiArtAnimation.tsx +355 -0
- package/ui/src/components/BillerSpendCard.tsx +146 -0
- package/ui/src/components/BreadcrumbBar.tsx +113 -0
- package/ui/src/components/BudgetIncidentCard.tsx +101 -0
- package/ui/src/components/BudgetPolicyCard.tsx +220 -0
- package/ui/src/components/BudgetSidebarMarker.tsx +13 -0
- package/ui/src/components/ClaudeSubscriptionPanel.tsx +141 -0
- package/ui/src/components/CodexSubscriptionPanel.tsx +158 -0
- package/ui/src/components/CommandPalette.tsx +239 -0
- package/ui/src/components/CommentThread.tsx +503 -0
- package/ui/src/components/CompanyPatternIcon.tsx +212 -0
- package/ui/src/components/CompanyRail.tsx +329 -0
- package/ui/src/components/CompanySwitcher.tsx +81 -0
- package/ui/src/components/CopyText.tsx +56 -0
- package/ui/src/components/DevRestartBanner.tsx +89 -0
- package/ui/src/components/EmptyState.tsx +27 -0
- package/ui/src/components/EntityRow.tsx +69 -0
- package/ui/src/components/FilterBar.tsx +39 -0
- package/ui/src/components/FinanceBillerCard.tsx +45 -0
- package/ui/src/components/FinanceKindCard.tsx +44 -0
- package/ui/src/components/FinanceTimelineCard.tsx +72 -0
- package/ui/src/components/GoalProperties.tsx +165 -0
- package/ui/src/components/GoalTree.tsx +118 -0
- package/ui/src/components/Identity.tsx +39 -0
- package/ui/src/components/InlineEditor.tsx +248 -0
- package/ui/src/components/InlineEntitySelector.tsx +206 -0
- package/ui/src/components/InstanceSidebar.tsx +53 -0
- package/ui/src/components/IssueDocumentsSection.tsx +892 -0
- package/ui/src/components/IssueProperties.tsx +621 -0
- package/ui/src/components/IssueRow.tsx +149 -0
- package/ui/src/components/IssueWorkspaceCard.tsx +404 -0
- package/ui/src/components/IssuesList.tsx +889 -0
- package/ui/src/components/JsonSchemaForm.tsx +1048 -0
- package/ui/src/components/KanbanBoard.tsx +275 -0
- package/ui/src/components/Layout.tsx +441 -0
- package/ui/src/components/LiveRunWidget.tsx +160 -0
- package/ui/src/components/MarkdownBody.test.tsx +50 -0
- package/ui/src/components/MarkdownBody.tsx +152 -0
- package/ui/src/components/MarkdownEditor.tsx +622 -0
- package/ui/src/components/MetricCard.tsx +53 -0
- package/ui/src/components/MobileBottomNav.tsx +123 -0
- package/ui/src/components/NewAgentDialog.tsx +223 -0
- package/ui/src/components/NewGoalDialog.tsx +283 -0
- package/ui/src/components/NewIssueDialog.tsx +1473 -0
- package/ui/src/components/NewProjectDialog.tsx +451 -0
- package/ui/src/components/OnboardingWizard.tsx +1392 -0
- package/ui/src/components/OpenCodeLogoIcon.tsx +22 -0
- package/ui/src/components/PackageFileTree.tsx +318 -0
- package/ui/src/components/PageSkeleton.tsx +180 -0
- package/ui/src/components/PageTabBar.tsx +45 -0
- package/ui/src/components/PathInstructionsModal.tsx +143 -0
- package/ui/src/components/PriorityIcon.tsx +77 -0
- package/ui/src/components/ProjectProperties.tsx +1127 -0
- package/ui/src/components/PropertiesPanel.tsx +29 -0
- package/ui/src/components/ProviderQuotaCard.tsx +417 -0
- package/ui/src/components/QuotaBar.tsx +65 -0
- package/ui/src/components/ReportsToPicker.tsx +127 -0
- package/ui/src/components/ScheduleEditor.tsx +344 -0
- package/ui/src/components/ScrollToBottom.tsx +79 -0
- package/ui/src/components/Sidebar.tsx +130 -0
- package/ui/src/components/SidebarAgents.tsx +146 -0
- package/ui/src/components/SidebarNavItem.tsx +92 -0
- package/ui/src/components/SidebarProjects.tsx +234 -0
- package/ui/src/components/SidebarSection.tsx +17 -0
- package/ui/src/components/StatusBadge.tsx +15 -0
- package/ui/src/components/StatusIcon.tsx +71 -0
- package/ui/src/components/SwipeToArchive.tsx +152 -0
- package/ui/src/components/ToastViewport.tsx +99 -0
- package/ui/src/components/WorktreeBanner.tsx +25 -0
- package/ui/src/components/agent-config-defaults.ts +31 -0
- package/ui/src/components/agent-config-primitives.tsx +476 -0
- package/ui/src/components/transcript/RunTranscriptView.test.tsx +84 -0
- package/ui/src/components/transcript/RunTranscriptView.tsx +1015 -0
- package/ui/src/components/transcript/useLiveRunTranscripts.ts +297 -0
- package/ui/src/components/ui/avatar.tsx +107 -0
- package/ui/src/components/ui/badge.tsx +48 -0
- package/ui/src/components/ui/breadcrumb.tsx +109 -0
- package/ui/src/components/ui/button.tsx +64 -0
- package/ui/src/components/ui/card.tsx +92 -0
- package/ui/src/components/ui/checkbox.tsx +32 -0
- package/ui/src/components/ui/collapsible.tsx +33 -0
- package/ui/src/components/ui/command.tsx +194 -0
- package/ui/src/components/ui/dialog.tsx +156 -0
- package/ui/src/components/ui/dropdown-menu.tsx +257 -0
- package/ui/src/components/ui/input.tsx +21 -0
- package/ui/src/components/ui/label.tsx +22 -0
- package/ui/src/components/ui/popover.tsx +88 -0
- package/ui/src/components/ui/scroll-area.tsx +56 -0
- package/ui/src/components/ui/select.tsx +188 -0
- package/ui/src/components/ui/separator.tsx +28 -0
- package/ui/src/components/ui/sheet.tsx +143 -0
- package/ui/src/components/ui/skeleton.tsx +13 -0
- package/ui/src/components/ui/tabs.tsx +89 -0
- package/ui/src/components/ui/textarea.tsx +18 -0
- package/ui/src/components/ui/tooltip.tsx +57 -0
- package/ui/src/components/visual-office/AgentAvatar.tsx +99 -0
- package/ui/src/components/visual-office/OfficeViewExact.tsx +417 -0
- package/ui/src/components/visual-office/i18n.ts +52 -0
- package/ui/src/components/visual-office/office-view/CliUsagePanel.tsx +240 -0
- package/ui/src/components/visual-office/office-view/VirtualPadOverlay.tsx +104 -0
- package/ui/src/components/visual-office/office-view/buildScene-break-room.ts +248 -0
- package/ui/src/components/visual-office/office-view/buildScene-ceo-hallway.ts +345 -0
- package/ui/src/components/visual-office/office-view/buildScene-department-agent.ts +242 -0
- package/ui/src/components/visual-office/office-view/buildScene-departments.ts +360 -0
- package/ui/src/components/visual-office/office-view/buildScene-final-layers.ts +113 -0
- package/ui/src/components/visual-office/office-view/buildScene-types.ts +91 -0
- package/ui/src/components/visual-office/office-view/buildScene.ts +232 -0
- package/ui/src/components/visual-office/office-view/drawing-core.ts +374 -0
- package/ui/src/components/visual-office/office-view/drawing-furniture-a.ts +338 -0
- package/ui/src/components/visual-office/office-view/drawing-furniture-b.ts +241 -0
- package/ui/src/components/visual-office/office-view/model.ts +301 -0
- package/ui/src/components/visual-office/office-view/officeTicker.ts +455 -0
- package/ui/src/components/visual-office/office-view/officeTickerRoomAndDelivery.ts +133 -0
- package/ui/src/components/visual-office/office-view/themes-locale.ts +460 -0
- package/ui/src/components/visual-office/office-view/useCliUsage.ts +37 -0
- package/ui/src/components/visual-office/office-view/useOfficeDeliveryEffects.ts +465 -0
- package/ui/src/components/visual-office/office-view/useOfficePixiRuntime.ts +282 -0
- package/ui/src/components/visual-office/types.ts +123 -0
- package/ui/src/context/BreadcrumbContext.tsx +44 -0
- package/ui/src/context/CompanyContext.tsx +151 -0
- package/ui/src/context/DialogContext.tsx +135 -0
- package/ui/src/context/LiveUpdatesProvider.test.ts +119 -0
- package/ui/src/context/LiveUpdatesProvider.tsx +760 -0
- package/ui/src/context/PanelContext.tsx +73 -0
- package/ui/src/context/SidebarContext.tsx +43 -0
- package/ui/src/context/ThemeContext.tsx +83 -0
- package/ui/src/context/ToastContext.tsx +172 -0
- package/ui/src/fixtures/runTranscriptFixtures.ts +226 -0
- package/ui/src/hooks/useAgentOrder.ts +105 -0
- package/ui/src/hooks/useAutosaveIndicator.ts +72 -0
- package/ui/src/hooks/useCompanyPageMemory.test.ts +90 -0
- package/ui/src/hooks/useCompanyPageMemory.ts +79 -0
- package/ui/src/hooks/useDateRange.ts +120 -0
- package/ui/src/hooks/useInboxBadge.ts +132 -0
- package/ui/src/hooks/useKeyboardShortcuts.ts +40 -0
- package/ui/src/hooks/useProjectOrder.ts +106 -0
- package/ui/src/index.css +770 -0
- package/ui/src/lib/agent-icons.ts +99 -0
- package/ui/src/lib/agent-order.ts +107 -0
- package/ui/src/lib/agent-skills-state.test.ts +90 -0
- package/ui/src/lib/agent-skills-state.ts +41 -0
- package/ui/src/lib/assignees.test.ts +92 -0
- package/ui/src/lib/assignees.ts +82 -0
- package/ui/src/lib/color-contrast.ts +107 -0
- package/ui/src/lib/company-export-selection.test.ts +41 -0
- package/ui/src/lib/company-export-selection.ts +57 -0
- package/ui/src/lib/company-page-memory.ts +65 -0
- package/ui/src/lib/company-portability-sidebar.test.ts +101 -0
- package/ui/src/lib/company-portability-sidebar.ts +62 -0
- package/ui/src/lib/company-routes.ts +88 -0
- package/ui/src/lib/company-selection.test.ts +34 -0
- package/ui/src/lib/company-selection.ts +18 -0
- package/ui/src/lib/groupBy.ts +11 -0
- package/ui/src/lib/inbox.test.ts +404 -0
- package/ui/src/lib/inbox.ts +292 -0
- package/ui/src/lib/instance-settings.test.ts +26 -0
- package/ui/src/lib/instance-settings.ts +25 -0
- package/ui/src/lib/issueDetailBreadcrumb.ts +24 -0
- package/ui/src/lib/legacy-agent-config.test.ts +40 -0
- package/ui/src/lib/legacy-agent-config.ts +17 -0
- package/ui/src/lib/mention-aware-link-node.test.ts +50 -0
- package/ui/src/lib/mention-aware-link-node.ts +67 -0
- package/ui/src/lib/mention-chips.ts +168 -0
- package/ui/src/lib/mention-deletion.test.ts +87 -0
- package/ui/src/lib/mention-deletion.ts +143 -0
- package/ui/src/lib/model-utils.ts +16 -0
- package/ui/src/lib/onboarding-goal.test.ts +22 -0
- package/ui/src/lib/onboarding-goal.ts +18 -0
- package/ui/src/lib/onboarding-launch.test.ts +131 -0
- package/ui/src/lib/onboarding-launch.ts +54 -0
- package/ui/src/lib/onboarding-route.test.ts +80 -0
- package/ui/src/lib/onboarding-route.ts +51 -0
- package/ui/src/lib/portable-files.ts +42 -0
- package/ui/src/lib/project-order.ts +71 -0
- package/ui/src/lib/queryKeys.ts +140 -0
- package/ui/src/lib/recent-assignees.ts +36 -0
- package/ui/src/lib/router.tsx +76 -0
- package/ui/src/lib/routine-trigger-patch.test.ts +72 -0
- package/ui/src/lib/routine-trigger-patch.ts +31 -0
- package/ui/src/lib/status-colors.ts +108 -0
- package/ui/src/lib/timeAgo.ts +31 -0
- package/ui/src/lib/utils.ts +168 -0
- package/ui/src/lib/worktree-branding.ts +65 -0
- package/ui/src/lib/zip.test.ts +289 -0
- package/ui/src/lib/zip.ts +284 -0
- package/ui/src/main.tsx +67 -0
- package/ui/src/pages/Activity.tsx +141 -0
- package/ui/src/pages/AgentDetail.tsx +4053 -0
- package/ui/src/pages/Agents.tsx +415 -0
- package/ui/src/pages/ApprovalDetail.tsx +369 -0
- package/ui/src/pages/Approvals.tsx +132 -0
- package/ui/src/pages/Auth.tsx +180 -0
- package/ui/src/pages/BoardClaim.tsx +125 -0
- package/ui/src/pages/CliAuth.tsx +184 -0
- package/ui/src/pages/Companies.tsx +297 -0
- package/ui/src/pages/CompanyExport.tsx +1019 -0
- package/ui/src/pages/CompanyImport.tsx +1355 -0
- package/ui/src/pages/CompanySettings.tsx +661 -0
- package/ui/src/pages/CompanySkills.tsx +1171 -0
- package/ui/src/pages/Costs.tsx +1103 -0
- package/ui/src/pages/Dashboard.tsx +388 -0
- package/ui/src/pages/DesignGuide.tsx +1330 -0
- package/ui/src/pages/ExecutionWorkspaceDetail.tsx +82 -0
- package/ui/src/pages/GoalDetail.tsx +197 -0
- package/ui/src/pages/Goals.tsx +63 -0
- package/ui/src/pages/Inbox.tsx +1291 -0
- package/ui/src/pages/InstanceExperimentalSettings.tsx +139 -0
- package/ui/src/pages/InstanceGeneralSettings.tsx +104 -0
- package/ui/src/pages/InstanceSettings.tsx +284 -0
- package/ui/src/pages/InviteLanding.tsx +320 -0
- package/ui/src/pages/IssueDetail.tsx +1201 -0
- package/ui/src/pages/Issues.tsx +116 -0
- package/ui/src/pages/MyIssues.tsx +72 -0
- package/ui/src/pages/NewAgent.tsx +353 -0
- package/ui/src/pages/NotFound.tsx +66 -0
- package/ui/src/pages/Org.tsx +132 -0
- package/ui/src/pages/OrgChart.tsx +447 -0
- package/ui/src/pages/PluginManager.tsx +510 -0
- package/ui/src/pages/PluginPage.tsx +156 -0
- package/ui/src/pages/PluginSettings.tsx +836 -0
- package/ui/src/pages/ProjectDetail.tsx +633 -0
- package/ui/src/pages/Projects.tsx +87 -0
- package/ui/src/pages/RoutineDetail.tsx +1022 -0
- package/ui/src/pages/Routines.tsx +661 -0
- package/ui/src/pages/RunTranscriptUxLab.tsx +334 -0
- package/ui/src/pages/VisualOffice.tsx +243 -0
- package/ui/src/plugins/bridge-init.ts +69 -0
- package/ui/src/plugins/bridge.ts +476 -0
- package/ui/src/plugins/launchers.tsx +834 -0
- package/ui/src/plugins/slots.tsx +855 -0
- package/ui/tsconfig.json +21 -0
- package/ui/vite.config.ts +23 -0
- package/ui/vitest.config.ts +14 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,1171 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState, type SVGProps } from "react";
|
|
2
|
+
import { Link, useNavigate, useParams } from "@/lib/router";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import type {
|
|
5
|
+
CompanySkillCreateRequest,
|
|
6
|
+
CompanySkillDetail,
|
|
7
|
+
CompanySkillFileDetail,
|
|
8
|
+
CompanySkillFileInventoryEntry,
|
|
9
|
+
CompanySkillListItem,
|
|
10
|
+
CompanySkillProjectScanResult,
|
|
11
|
+
CompanySkillSourceBadge,
|
|
12
|
+
CompanySkillUpdateStatus,
|
|
13
|
+
} from "@corporateai/shared";
|
|
14
|
+
import { companySkillsApi } from "../api/companySkills";
|
|
15
|
+
import { useCompany } from "../context/CompanyContext";
|
|
16
|
+
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
17
|
+
import { useToast } from "../context/ToastContext";
|
|
18
|
+
import { queryKeys } from "../lib/queryKeys";
|
|
19
|
+
import { EmptyState } from "../components/EmptyState";
|
|
20
|
+
import { MarkdownBody } from "../components/MarkdownBody";
|
|
21
|
+
import { MarkdownEditor } from "../components/MarkdownEditor";
|
|
22
|
+
import { PageSkeleton } from "../components/PageSkeleton";
|
|
23
|
+
import {
|
|
24
|
+
Dialog,
|
|
25
|
+
DialogContent,
|
|
26
|
+
DialogDescription,
|
|
27
|
+
DialogFooter,
|
|
28
|
+
DialogHeader,
|
|
29
|
+
DialogTitle,
|
|
30
|
+
} from "@/components/ui/dialog";
|
|
31
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
|
32
|
+
import { cn } from "../lib/utils";
|
|
33
|
+
import { Button } from "@/components/ui/button";
|
|
34
|
+
import { Input } from "@/components/ui/input";
|
|
35
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
36
|
+
import {
|
|
37
|
+
Boxes,
|
|
38
|
+
ChevronDown,
|
|
39
|
+
ChevronRight,
|
|
40
|
+
Code2,
|
|
41
|
+
Eye,
|
|
42
|
+
FileCode2,
|
|
43
|
+
FileText,
|
|
44
|
+
Folder,
|
|
45
|
+
FolderOpen,
|
|
46
|
+
Github,
|
|
47
|
+
Link2,
|
|
48
|
+
ExternalLink,
|
|
49
|
+
Paperclip,
|
|
50
|
+
Pencil,
|
|
51
|
+
Plus,
|
|
52
|
+
RefreshCw,
|
|
53
|
+
Save,
|
|
54
|
+
Search,
|
|
55
|
+
} from "lucide-react";
|
|
56
|
+
|
|
57
|
+
type SkillTreeNode = {
|
|
58
|
+
name: string;
|
|
59
|
+
path: string | null;
|
|
60
|
+
kind: "dir" | "file";
|
|
61
|
+
fileKind?: CompanySkillFileInventoryEntry["kind"];
|
|
62
|
+
children: SkillTreeNode[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const SKILL_TREE_BASE_INDENT = 16;
|
|
66
|
+
const SKILL_TREE_STEP_INDENT = 24;
|
|
67
|
+
const SKILL_TREE_ROW_HEIGHT_CLASS = "min-h-9";
|
|
68
|
+
|
|
69
|
+
function VercelMark(props: SVGProps<SVGSVGElement>) {
|
|
70
|
+
return (
|
|
71
|
+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" {...props}>
|
|
72
|
+
<path d="M12 4 21 19H3z" />
|
|
73
|
+
</svg>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function stripFrontmatter(markdown: string) {
|
|
78
|
+
const normalized = markdown.replace(/\r\n/g, "\n");
|
|
79
|
+
if (!normalized.startsWith("---\n")) return normalized.trim();
|
|
80
|
+
const closing = normalized.indexOf("\n---\n", 4);
|
|
81
|
+
if (closing < 0) return normalized.trim();
|
|
82
|
+
return normalized.slice(closing + 5).trim();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function splitFrontmatter(markdown: string): { frontmatter: string | null; body: string } {
|
|
86
|
+
const normalized = markdown.replace(/\r\n/g, "\n");
|
|
87
|
+
if (!normalized.startsWith("---\n")) {
|
|
88
|
+
return { frontmatter: null, body: normalized };
|
|
89
|
+
}
|
|
90
|
+
const closing = normalized.indexOf("\n---\n", 4);
|
|
91
|
+
if (closing < 0) {
|
|
92
|
+
return { frontmatter: null, body: normalized };
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
frontmatter: normalized.slice(4, closing).trim(),
|
|
96
|
+
body: normalized.slice(closing + 5).trimStart(),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function mergeFrontmatter(markdown: string, body: string) {
|
|
101
|
+
const parsed = splitFrontmatter(markdown);
|
|
102
|
+
if (!parsed.frontmatter) return body;
|
|
103
|
+
return ["---", parsed.frontmatter, "---", "", body].join("\n");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function buildTree(entries: CompanySkillFileInventoryEntry[]) {
|
|
107
|
+
const root: SkillTreeNode = { name: "", path: null, kind: "dir", children: [] };
|
|
108
|
+
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const segments = entry.path.split("/").filter(Boolean);
|
|
111
|
+
let current = root;
|
|
112
|
+
let currentPath = "";
|
|
113
|
+
for (const [index, segment] of segments.entries()) {
|
|
114
|
+
currentPath = currentPath ? `${currentPath}/${segment}` : segment;
|
|
115
|
+
const isLeaf = index === segments.length - 1;
|
|
116
|
+
let next = current.children.find((child) => child.name === segment);
|
|
117
|
+
if (!next) {
|
|
118
|
+
next = {
|
|
119
|
+
name: segment,
|
|
120
|
+
path: isLeaf ? entry.path : currentPath,
|
|
121
|
+
kind: isLeaf ? "file" : "dir",
|
|
122
|
+
fileKind: isLeaf ? entry.kind : undefined,
|
|
123
|
+
children: [],
|
|
124
|
+
};
|
|
125
|
+
current.children.push(next);
|
|
126
|
+
}
|
|
127
|
+
current = next;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function sortNode(node: SkillTreeNode) {
|
|
132
|
+
node.children.sort((left, right) => {
|
|
133
|
+
if (left.kind !== right.kind) return left.kind === "dir" ? -1 : 1;
|
|
134
|
+
if (left.name === "SKILL.md") return -1;
|
|
135
|
+
if (right.name === "SKILL.md") return 1;
|
|
136
|
+
return left.name.localeCompare(right.name);
|
|
137
|
+
});
|
|
138
|
+
node.children.forEach(sortNode);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
sortNode(root);
|
|
142
|
+
return root.children;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function sourceMeta(sourceBadge: CompanySkillSourceBadge, sourceLabel: string | null) {
|
|
146
|
+
const normalizedLabel = sourceLabel?.toLowerCase() ?? "";
|
|
147
|
+
const isSkillsShManaged =
|
|
148
|
+
normalizedLabel.includes("skills.sh") || normalizedLabel.includes("vercel-labs/skills");
|
|
149
|
+
|
|
150
|
+
switch (sourceBadge) {
|
|
151
|
+
case "skills_sh":
|
|
152
|
+
return { icon: VercelMark, label: sourceLabel ?? "skills.sh", managedLabel: "skills.sh managed" };
|
|
153
|
+
case "github":
|
|
154
|
+
return isSkillsShManaged
|
|
155
|
+
? { icon: VercelMark, label: sourceLabel ?? "skills.sh", managedLabel: "skills.sh managed" }
|
|
156
|
+
: { icon: Github, label: sourceLabel ?? "GitHub", managedLabel: "GitHub managed" };
|
|
157
|
+
case "url":
|
|
158
|
+
return { icon: Link2, label: sourceLabel ?? "URL", managedLabel: "URL managed" };
|
|
159
|
+
case "local":
|
|
160
|
+
return { icon: Folder, label: sourceLabel ?? "Folder", managedLabel: "Folder managed" };
|
|
161
|
+
case "paperclip":
|
|
162
|
+
return { icon: Paperclip, label: sourceLabel ?? "Corporate", managedLabel: "Corporate managed" };
|
|
163
|
+
default:
|
|
164
|
+
return { icon: Boxes, label: sourceLabel ?? "Catalog", managedLabel: "Catalog managed" };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function shortRef(ref: string | null | undefined) {
|
|
169
|
+
if (!ref) return null;
|
|
170
|
+
return ref.slice(0, 7);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function formatProjectScanSummary(result: CompanySkillProjectScanResult) {
|
|
174
|
+
const parts = [
|
|
175
|
+
`${result.discovered} found`,
|
|
176
|
+
`${result.imported.length} imported`,
|
|
177
|
+
`${result.updated.length} updated`,
|
|
178
|
+
];
|
|
179
|
+
if (result.conflicts.length > 0) parts.push(`${result.conflicts.length} conflicts`);
|
|
180
|
+
if (result.skipped.length > 0) parts.push(`${result.skipped.length} skipped`);
|
|
181
|
+
return `${parts.join(", ")} across ${result.scannedWorkspaces} workspace${result.scannedWorkspaces === 1 ? "" : "s"}.`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function fileIcon(kind: CompanySkillFileInventoryEntry["kind"]) {
|
|
185
|
+
if (kind === "script" || kind === "reference") return FileCode2;
|
|
186
|
+
return FileText;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function encodeSkillFilePath(filePath: string) {
|
|
190
|
+
return filePath.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function decodeSkillFilePath(filePath: string | undefined) {
|
|
194
|
+
if (!filePath) return "SKILL.md";
|
|
195
|
+
return filePath
|
|
196
|
+
.split("/")
|
|
197
|
+
.filter(Boolean)
|
|
198
|
+
.map((segment) => {
|
|
199
|
+
try {
|
|
200
|
+
return decodeURIComponent(segment);
|
|
201
|
+
} catch {
|
|
202
|
+
return segment;
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
.join("/");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function parseSkillRoute(routePath: string | undefined) {
|
|
209
|
+
const segments = (routePath ?? "").split("/").filter(Boolean);
|
|
210
|
+
if (segments.length === 0) {
|
|
211
|
+
return { skillId: null, filePath: "SKILL.md" };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const [rawSkillId, rawMode, ...rest] = segments;
|
|
215
|
+
const skillId = rawSkillId ? decodeURIComponent(rawSkillId) : null;
|
|
216
|
+
if (!skillId) {
|
|
217
|
+
return { skillId: null, filePath: "SKILL.md" };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (rawMode === "files") {
|
|
221
|
+
return {
|
|
222
|
+
skillId,
|
|
223
|
+
filePath: decodeSkillFilePath(rest.join("/")),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return { skillId, filePath: "SKILL.md" };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function skillRoute(skillId: string, filePath?: string | null) {
|
|
231
|
+
return filePath ? `/skills/${skillId}/files/${encodeSkillFilePath(filePath)}` : `/skills/${skillId}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function parentDirectoryPaths(filePath: string) {
|
|
235
|
+
const segments = filePath.split("/").filter(Boolean);
|
|
236
|
+
const parents: string[] = [];
|
|
237
|
+
for (let index = 0; index < segments.length - 1; index += 1) {
|
|
238
|
+
parents.push(segments.slice(0, index + 1).join("/"));
|
|
239
|
+
}
|
|
240
|
+
return parents;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function NewSkillForm({
|
|
244
|
+
onCreate,
|
|
245
|
+
isPending,
|
|
246
|
+
onCancel,
|
|
247
|
+
}: {
|
|
248
|
+
onCreate: (payload: CompanySkillCreateRequest) => void;
|
|
249
|
+
isPending: boolean;
|
|
250
|
+
onCancel: () => void;
|
|
251
|
+
}) {
|
|
252
|
+
const [name, setName] = useState("");
|
|
253
|
+
const [slug, setSlug] = useState("");
|
|
254
|
+
const [description, setDescription] = useState("");
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div className="border-b border-border px-4 py-4">
|
|
258
|
+
<div className="space-y-3">
|
|
259
|
+
<Input
|
|
260
|
+
value={name}
|
|
261
|
+
onChange={(event) => setName(event.target.value)}
|
|
262
|
+
placeholder="Skill name"
|
|
263
|
+
className="h-9 rounded-none border-0 border-b border-border px-0 shadow-none focus-visible:ring-0"
|
|
264
|
+
/>
|
|
265
|
+
<Input
|
|
266
|
+
value={slug}
|
|
267
|
+
onChange={(event) => setSlug(event.target.value)}
|
|
268
|
+
placeholder="optional-shortname"
|
|
269
|
+
className="h-9 rounded-none border-0 border-b border-border px-0 shadow-none focus-visible:ring-0"
|
|
270
|
+
/>
|
|
271
|
+
<Textarea
|
|
272
|
+
value={description}
|
|
273
|
+
onChange={(event) => setDescription(event.target.value)}
|
|
274
|
+
placeholder="Short description"
|
|
275
|
+
className="min-h-20 rounded-none border-0 border-b border-border px-0 shadow-none focus-visible:ring-0"
|
|
276
|
+
/>
|
|
277
|
+
<div className="flex items-center justify-end gap-2">
|
|
278
|
+
<Button variant="ghost" size="sm" onClick={onCancel} disabled={isPending}>
|
|
279
|
+
Cancel
|
|
280
|
+
</Button>
|
|
281
|
+
<Button
|
|
282
|
+
size="sm"
|
|
283
|
+
onClick={() => onCreate({ name, slug: slug || null, description: description || null })}
|
|
284
|
+
disabled={isPending || name.trim().length === 0}
|
|
285
|
+
>
|
|
286
|
+
{isPending ? "Creating..." : "Create skill"}
|
|
287
|
+
</Button>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function SkillTree({
|
|
295
|
+
nodes,
|
|
296
|
+
skillId,
|
|
297
|
+
selectedPath,
|
|
298
|
+
expandedDirs,
|
|
299
|
+
onToggleDir,
|
|
300
|
+
onSelectPath,
|
|
301
|
+
depth = 0,
|
|
302
|
+
}: {
|
|
303
|
+
nodes: SkillTreeNode[];
|
|
304
|
+
skillId: string;
|
|
305
|
+
selectedPath: string;
|
|
306
|
+
expandedDirs: Set<string>;
|
|
307
|
+
onToggleDir: (path: string) => void;
|
|
308
|
+
onSelectPath: (path: string) => void;
|
|
309
|
+
depth?: number;
|
|
310
|
+
}) {
|
|
311
|
+
return (
|
|
312
|
+
<div>
|
|
313
|
+
{nodes.map((node) => {
|
|
314
|
+
const expanded = node.kind === "dir" && node.path ? expandedDirs.has(node.path) : false;
|
|
315
|
+
if (node.kind === "dir") {
|
|
316
|
+
return (
|
|
317
|
+
<div key={node.path ?? node.name}>
|
|
318
|
+
<div
|
|
319
|
+
className={cn(
|
|
320
|
+
"group grid w-full grid-cols-[minmax(0,1fr)_2.25rem] items-center gap-x-1 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",
|
|
321
|
+
SKILL_TREE_ROW_HEIGHT_CLASS,
|
|
322
|
+
)}
|
|
323
|
+
>
|
|
324
|
+
<button
|
|
325
|
+
type="button"
|
|
326
|
+
className="flex min-w-0 items-center gap-2 py-1 text-left"
|
|
327
|
+
style={{ paddingLeft: `${SKILL_TREE_BASE_INDENT + depth * SKILL_TREE_STEP_INDENT}px` }}
|
|
328
|
+
onClick={() => node.path && onToggleDir(node.path)}
|
|
329
|
+
>
|
|
330
|
+
<span className="flex h-4 w-4 shrink-0 items-center justify-center">
|
|
331
|
+
{expanded ? <FolderOpen className="h-3.5 w-3.5" /> : <Folder className="h-3.5 w-3.5" />}
|
|
332
|
+
</span>
|
|
333
|
+
<span className="truncate">{node.name}</span>
|
|
334
|
+
</button>
|
|
335
|
+
<button
|
|
336
|
+
type="button"
|
|
337
|
+
className="flex h-9 w-9 items-center justify-center self-center rounded-sm text-muted-foreground opacity-70 transition-[background-color,color,opacity] hover:bg-accent hover:text-foreground group-hover:opacity-100"
|
|
338
|
+
onClick={() => node.path && onToggleDir(node.path)}
|
|
339
|
+
>
|
|
340
|
+
{expanded ? <ChevronDown className="h-3.5 w-3.5" /> : <ChevronRight className="h-3.5 w-3.5" />}
|
|
341
|
+
</button>
|
|
342
|
+
</div>
|
|
343
|
+
{expanded && (
|
|
344
|
+
<SkillTree
|
|
345
|
+
nodes={node.children}
|
|
346
|
+
skillId={skillId}
|
|
347
|
+
selectedPath={selectedPath}
|
|
348
|
+
expandedDirs={expandedDirs}
|
|
349
|
+
onToggleDir={onToggleDir}
|
|
350
|
+
onSelectPath={onSelectPath}
|
|
351
|
+
depth={depth + 1}
|
|
352
|
+
/>
|
|
353
|
+
)}
|
|
354
|
+
</div>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const FileIcon = fileIcon(node.fileKind ?? "other");
|
|
359
|
+
return (
|
|
360
|
+
<Link
|
|
361
|
+
key={node.path ?? node.name}
|
|
362
|
+
className={cn(
|
|
363
|
+
"flex w-full items-center gap-2 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",
|
|
364
|
+
SKILL_TREE_ROW_HEIGHT_CLASS,
|
|
365
|
+
node.path === selectedPath && "text-foreground",
|
|
366
|
+
)}
|
|
367
|
+
style={{ paddingInlineStart: `${SKILL_TREE_BASE_INDENT + depth * SKILL_TREE_STEP_INDENT}px` }}
|
|
368
|
+
to={skillRoute(skillId, node.path)}
|
|
369
|
+
onClick={() => node.path && onSelectPath(node.path)}
|
|
370
|
+
>
|
|
371
|
+
<span className="flex h-4 w-4 shrink-0 items-center justify-center">
|
|
372
|
+
<FileIcon className="h-3.5 w-3.5" />
|
|
373
|
+
</span>
|
|
374
|
+
<span className="truncate">{node.name}</span>
|
|
375
|
+
</Link>
|
|
376
|
+
);
|
|
377
|
+
})}
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function SkillList({
|
|
383
|
+
skills,
|
|
384
|
+
selectedSkillId,
|
|
385
|
+
skillFilter,
|
|
386
|
+
expandedSkillId,
|
|
387
|
+
expandedDirs,
|
|
388
|
+
selectedPaths,
|
|
389
|
+
onToggleSkill,
|
|
390
|
+
onToggleDir,
|
|
391
|
+
onSelectSkill,
|
|
392
|
+
onSelectPath,
|
|
393
|
+
}: {
|
|
394
|
+
skills: CompanySkillListItem[];
|
|
395
|
+
selectedSkillId: string | null;
|
|
396
|
+
skillFilter: string;
|
|
397
|
+
expandedSkillId: string | null;
|
|
398
|
+
expandedDirs: Record<string, Set<string>>;
|
|
399
|
+
selectedPaths: Record<string, string>;
|
|
400
|
+
onToggleSkill: (skillId: string) => void;
|
|
401
|
+
onToggleDir: (skillId: string, path: string) => void;
|
|
402
|
+
onSelectSkill: (skillId: string) => void;
|
|
403
|
+
onSelectPath: (skillId: string, path: string) => void;
|
|
404
|
+
}) {
|
|
405
|
+
const filteredSkills = skills.filter((skill) => {
|
|
406
|
+
const haystack = `${skill.name} ${skill.key} ${skill.slug} ${skill.sourceLabel ?? ""}`.toLowerCase();
|
|
407
|
+
return haystack.includes(skillFilter.toLowerCase());
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
if (filteredSkills.length === 0) {
|
|
411
|
+
return (
|
|
412
|
+
<div className="px-4 py-6 text-sm text-muted-foreground">
|
|
413
|
+
No skills match this filter.
|
|
414
|
+
</div>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return (
|
|
419
|
+
<div>
|
|
420
|
+
{filteredSkills.map((skill) => {
|
|
421
|
+
const expanded = expandedSkillId === skill.id;
|
|
422
|
+
const tree = buildTree(skill.fileInventory);
|
|
423
|
+
const source = sourceMeta(skill.sourceBadge, skill.sourceLabel);
|
|
424
|
+
const SourceIcon = source.icon;
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<div key={skill.id} className="border-b border-border">
|
|
428
|
+
<div
|
|
429
|
+
className={cn(
|
|
430
|
+
"group grid grid-cols-[minmax(0,1fr)_2.25rem] items-center gap-x-1 px-3 py-1.5 hover:bg-accent/30",
|
|
431
|
+
skill.id === selectedSkillId && "text-foreground",
|
|
432
|
+
)}
|
|
433
|
+
>
|
|
434
|
+
<Link
|
|
435
|
+
to={skillRoute(skill.id)}
|
|
436
|
+
className="flex min-w-0 items-center self-stretch pr-2 text-left no-underline"
|
|
437
|
+
onClick={() => onSelectSkill(skill.id)}
|
|
438
|
+
>
|
|
439
|
+
<span className="flex min-w-0 items-center gap-2 self-center">
|
|
440
|
+
<Tooltip>
|
|
441
|
+
<TooltipTrigger asChild>
|
|
442
|
+
<span className="flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground opacity-75 transition-opacity group-hover:opacity-100">
|
|
443
|
+
<SourceIcon className="h-3.5 w-3.5" />
|
|
444
|
+
<span className="sr-only">{source.managedLabel}</span>
|
|
445
|
+
</span>
|
|
446
|
+
</TooltipTrigger>
|
|
447
|
+
<TooltipContent side="top">{source.managedLabel}</TooltipContent>
|
|
448
|
+
</Tooltip>
|
|
449
|
+
<span className="min-w-0 overflow-hidden text-[13px] font-medium leading-5 [display:-webkit-box] [-webkit-box-orient:vertical] [-webkit-line-clamp:3]">
|
|
450
|
+
{skill.name}
|
|
451
|
+
</span>
|
|
452
|
+
</span>
|
|
453
|
+
</Link>
|
|
454
|
+
<button
|
|
455
|
+
type="button"
|
|
456
|
+
className="flex h-9 w-9 shrink-0 items-center justify-center self-center rounded-sm text-muted-foreground opacity-80 transition-[background-color,color,opacity] hover:bg-accent hover:text-foreground group-hover:opacity-100"
|
|
457
|
+
onClick={() => onToggleSkill(skill.id)}
|
|
458
|
+
aria-label={expanded ? `Collapse ${skill.name}` : `Expand ${skill.name}`}
|
|
459
|
+
>
|
|
460
|
+
{expanded ? <ChevronDown className="h-3.5 w-3.5" /> : <ChevronRight className="h-3.5 w-3.5" />}
|
|
461
|
+
</button>
|
|
462
|
+
</div>
|
|
463
|
+
<div
|
|
464
|
+
aria-hidden={!expanded}
|
|
465
|
+
className={cn(
|
|
466
|
+
"grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)]",
|
|
467
|
+
expanded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0",
|
|
468
|
+
)}
|
|
469
|
+
>
|
|
470
|
+
<div className="min-h-0 overflow-hidden">
|
|
471
|
+
<SkillTree
|
|
472
|
+
nodes={tree}
|
|
473
|
+
skillId={skill.id}
|
|
474
|
+
selectedPath={selectedPaths[skill.id] ?? "SKILL.md"}
|
|
475
|
+
expandedDirs={expandedDirs[skill.id] ?? new Set<string>()}
|
|
476
|
+
onToggleDir={(path) => onToggleDir(skill.id, path)}
|
|
477
|
+
onSelectPath={(path) => onSelectPath(skill.id, path)}
|
|
478
|
+
depth={1}
|
|
479
|
+
/>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
);
|
|
484
|
+
})}
|
|
485
|
+
</div>
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function SkillPane({
|
|
490
|
+
loading,
|
|
491
|
+
detail,
|
|
492
|
+
file,
|
|
493
|
+
fileLoading,
|
|
494
|
+
updateStatus,
|
|
495
|
+
updateStatusLoading,
|
|
496
|
+
viewMode,
|
|
497
|
+
editMode,
|
|
498
|
+
draft,
|
|
499
|
+
setViewMode,
|
|
500
|
+
setEditMode,
|
|
501
|
+
setDraft,
|
|
502
|
+
onCheckUpdates,
|
|
503
|
+
checkUpdatesPending,
|
|
504
|
+
onInstallUpdate,
|
|
505
|
+
installUpdatePending,
|
|
506
|
+
onSave,
|
|
507
|
+
savePending,
|
|
508
|
+
}: {
|
|
509
|
+
loading: boolean;
|
|
510
|
+
detail: CompanySkillDetail | null | undefined;
|
|
511
|
+
file: CompanySkillFileDetail | null | undefined;
|
|
512
|
+
fileLoading: boolean;
|
|
513
|
+
updateStatus: CompanySkillUpdateStatus | null | undefined;
|
|
514
|
+
updateStatusLoading: boolean;
|
|
515
|
+
viewMode: "preview" | "code";
|
|
516
|
+
editMode: boolean;
|
|
517
|
+
draft: string;
|
|
518
|
+
setViewMode: (mode: "preview" | "code") => void;
|
|
519
|
+
setEditMode: (value: boolean) => void;
|
|
520
|
+
setDraft: (value: string) => void;
|
|
521
|
+
onCheckUpdates: () => void;
|
|
522
|
+
checkUpdatesPending: boolean;
|
|
523
|
+
onInstallUpdate: () => void;
|
|
524
|
+
installUpdatePending: boolean;
|
|
525
|
+
onSave: () => void;
|
|
526
|
+
savePending: boolean;
|
|
527
|
+
}) {
|
|
528
|
+
const { pushToast } = useToast();
|
|
529
|
+
|
|
530
|
+
if (!detail) {
|
|
531
|
+
if (loading) {
|
|
532
|
+
return <PageSkeleton variant="detail" />;
|
|
533
|
+
}
|
|
534
|
+
return (
|
|
535
|
+
<EmptyState
|
|
536
|
+
icon={Boxes}
|
|
537
|
+
message="Select a skill to inspect its files."
|
|
538
|
+
/>
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const source = sourceMeta(detail.sourceBadge, detail.sourceLabel);
|
|
543
|
+
const SourceIcon = source.icon;
|
|
544
|
+
const usedBy = detail.usedByAgents;
|
|
545
|
+
const body = file?.markdown ? stripFrontmatter(file.content) : file?.content ?? "";
|
|
546
|
+
const currentPin = shortRef(detail.sourceRef);
|
|
547
|
+
const latestPin = shortRef(updateStatus?.latestRef);
|
|
548
|
+
|
|
549
|
+
return (
|
|
550
|
+
<div className="min-w-0">
|
|
551
|
+
<div className="border-b border-border px-5 py-4">
|
|
552
|
+
<div className="flex flex-wrap items-start justify-between gap-4">
|
|
553
|
+
<div className="min-w-0">
|
|
554
|
+
<h1 className="flex items-center gap-2 truncate text-2xl font-semibold">
|
|
555
|
+
<SourceIcon className="h-5 w-5 shrink-0 text-muted-foreground" />
|
|
556
|
+
{detail.name}
|
|
557
|
+
</h1>
|
|
558
|
+
{detail.description && (
|
|
559
|
+
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">{detail.description}</p>
|
|
560
|
+
)}
|
|
561
|
+
</div>
|
|
562
|
+
{detail.editable ? (
|
|
563
|
+
<button
|
|
564
|
+
className="inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground"
|
|
565
|
+
onClick={() => setEditMode(!editMode)}
|
|
566
|
+
>
|
|
567
|
+
<Pencil className="h-3.5 w-3.5" />
|
|
568
|
+
{editMode ? "Stop editing" : "Edit"}
|
|
569
|
+
</button>
|
|
570
|
+
) : (
|
|
571
|
+
<div className="text-sm text-muted-foreground">{detail.editableReason}</div>
|
|
572
|
+
)}
|
|
573
|
+
</div>
|
|
574
|
+
|
|
575
|
+
<div className="mt-4 space-y-3 border-t border-border pt-4 text-sm">
|
|
576
|
+
<div className="flex flex-wrap items-center gap-x-6 gap-y-2">
|
|
577
|
+
<div className="flex items-center gap-2">
|
|
578
|
+
<span className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Source</span>
|
|
579
|
+
<span className="flex items-center gap-2">
|
|
580
|
+
<SourceIcon className="h-3.5 w-3.5 text-muted-foreground" />
|
|
581
|
+
{detail.sourcePath ? (
|
|
582
|
+
<button
|
|
583
|
+
className="truncate hover:text-foreground text-muted-foreground transition-colors cursor-pointer"
|
|
584
|
+
onClick={() => {
|
|
585
|
+
navigator.clipboard.writeText(detail.sourcePath!);
|
|
586
|
+
pushToast({ title: "Copied path to workspace" });
|
|
587
|
+
}}
|
|
588
|
+
>
|
|
589
|
+
{source.label}
|
|
590
|
+
</button>
|
|
591
|
+
) : (
|
|
592
|
+
<span className="truncate">{source.label}</span>
|
|
593
|
+
)}
|
|
594
|
+
</span>
|
|
595
|
+
</div>
|
|
596
|
+
{detail.sourceType === "github" && (
|
|
597
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
598
|
+
<span className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Pin</span>
|
|
599
|
+
<span className="font-mono text-xs">{currentPin ?? "untracked"}</span>
|
|
600
|
+
{updateStatus?.trackingRef && (
|
|
601
|
+
<span className="text-xs text-muted-foreground">tracking {updateStatus.trackingRef}</span>
|
|
602
|
+
)}
|
|
603
|
+
<Button
|
|
604
|
+
variant="ghost"
|
|
605
|
+
size="sm"
|
|
606
|
+
onClick={onCheckUpdates}
|
|
607
|
+
disabled={checkUpdatesPending || updateStatusLoading}
|
|
608
|
+
>
|
|
609
|
+
<RefreshCw className={cn("mr-1.5 h-3.5 w-3.5", (checkUpdatesPending || updateStatusLoading) && "animate-spin")} />
|
|
610
|
+
Check for updates
|
|
611
|
+
</Button>
|
|
612
|
+
{updateStatus?.supported && updateStatus.hasUpdate && (
|
|
613
|
+
<Button
|
|
614
|
+
size="sm"
|
|
615
|
+
onClick={onInstallUpdate}
|
|
616
|
+
disabled={installUpdatePending}
|
|
617
|
+
>
|
|
618
|
+
<RefreshCw className={cn("mr-1.5 h-3.5 w-3.5", installUpdatePending && "animate-spin")} />
|
|
619
|
+
Install update{latestPin ? ` ${latestPin}` : ""}
|
|
620
|
+
</Button>
|
|
621
|
+
)}
|
|
622
|
+
{updateStatus?.supported && !updateStatus.hasUpdate && !updateStatusLoading && (
|
|
623
|
+
<span className="text-xs text-muted-foreground">Up to date</span>
|
|
624
|
+
)}
|
|
625
|
+
{!updateStatus?.supported && updateStatus?.reason && (
|
|
626
|
+
<span className="text-xs text-muted-foreground">{updateStatus.reason}</span>
|
|
627
|
+
)}
|
|
628
|
+
</div>
|
|
629
|
+
)}
|
|
630
|
+
<div className="flex items-center gap-2">
|
|
631
|
+
<span className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Key</span>
|
|
632
|
+
<span className="font-mono text-xs">{detail.key}</span>
|
|
633
|
+
</div>
|
|
634
|
+
<div className="flex items-center gap-2">
|
|
635
|
+
<span className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Mode</span>
|
|
636
|
+
<span>{detail.editable ? "Editable" : "Read only"}</span>
|
|
637
|
+
</div>
|
|
638
|
+
</div>
|
|
639
|
+
<div className="flex flex-wrap items-start gap-x-3 gap-y-1">
|
|
640
|
+
<span className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">Used by</span>
|
|
641
|
+
{usedBy.length === 0 ? (
|
|
642
|
+
<span className="text-muted-foreground">No agents attached</span>
|
|
643
|
+
) : (
|
|
644
|
+
<div className="flex flex-wrap gap-x-3 gap-y-1">
|
|
645
|
+
{usedBy.map((agent) => (
|
|
646
|
+
<Link
|
|
647
|
+
key={agent.id}
|
|
648
|
+
to={`/agents/${agent.urlKey}/skills`}
|
|
649
|
+
className="text-foreground no-underline hover:underline"
|
|
650
|
+
>
|
|
651
|
+
{agent.name}
|
|
652
|
+
</Link>
|
|
653
|
+
))}
|
|
654
|
+
</div>
|
|
655
|
+
)}
|
|
656
|
+
</div>
|
|
657
|
+
</div>
|
|
658
|
+
</div>
|
|
659
|
+
|
|
660
|
+
<div className="border-b border-border px-5 py-3">
|
|
661
|
+
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
662
|
+
<div className="min-w-0">
|
|
663
|
+
<div className="truncate font-mono text-sm">{file?.path ?? "SKILL.md"}</div>
|
|
664
|
+
</div>
|
|
665
|
+
<div className="flex items-center gap-2">
|
|
666
|
+
{file?.markdown && !editMode && (
|
|
667
|
+
<div className="flex items-center border border-border">
|
|
668
|
+
<button
|
|
669
|
+
className={cn("px-3 py-1.5 text-sm", viewMode === "preview" && "text-foreground", viewMode !== "preview" && "text-muted-foreground")}
|
|
670
|
+
onClick={() => setViewMode("preview")}
|
|
671
|
+
>
|
|
672
|
+
<span className="flex items-center gap-1.5">
|
|
673
|
+
<Eye className="h-3.5 w-3.5" />
|
|
674
|
+
View
|
|
675
|
+
</span>
|
|
676
|
+
</button>
|
|
677
|
+
<button
|
|
678
|
+
className={cn("border-l border-border px-3 py-1.5 text-sm", viewMode === "code" && "text-foreground", viewMode !== "code" && "text-muted-foreground")}
|
|
679
|
+
onClick={() => setViewMode("code")}
|
|
680
|
+
>
|
|
681
|
+
<span className="flex items-center gap-1.5">
|
|
682
|
+
<Code2 className="h-3.5 w-3.5" />
|
|
683
|
+
Code
|
|
684
|
+
</span>
|
|
685
|
+
</button>
|
|
686
|
+
</div>
|
|
687
|
+
)}
|
|
688
|
+
{editMode && file?.editable && (
|
|
689
|
+
<>
|
|
690
|
+
<Button variant="ghost" size="sm" onClick={() => setEditMode(false)} disabled={savePending}>
|
|
691
|
+
Cancel
|
|
692
|
+
</Button>
|
|
693
|
+
<Button size="sm" onClick={onSave} disabled={savePending}>
|
|
694
|
+
<Save className="mr-1.5 h-3.5 w-3.5" />
|
|
695
|
+
{savePending ? "Saving..." : "Save"}
|
|
696
|
+
</Button>
|
|
697
|
+
</>
|
|
698
|
+
)}
|
|
699
|
+
</div>
|
|
700
|
+
</div>
|
|
701
|
+
</div>
|
|
702
|
+
|
|
703
|
+
<div className="min-h-[560px] px-5 py-5">
|
|
704
|
+
{fileLoading ? (
|
|
705
|
+
<PageSkeleton variant="detail" />
|
|
706
|
+
) : !file ? (
|
|
707
|
+
<div className="text-sm text-muted-foreground">Select a file to inspect.</div>
|
|
708
|
+
) : editMode && file.editable ? (
|
|
709
|
+
file.markdown ? (
|
|
710
|
+
<MarkdownEditor
|
|
711
|
+
value={draft}
|
|
712
|
+
onChange={setDraft}
|
|
713
|
+
bordered={false}
|
|
714
|
+
className="min-h-[520px]"
|
|
715
|
+
/>
|
|
716
|
+
) : (
|
|
717
|
+
<Textarea
|
|
718
|
+
value={draft}
|
|
719
|
+
onChange={(event) => setDraft(event.target.value)}
|
|
720
|
+
className="min-h-[520px] rounded-none border-0 bg-transparent px-0 py-0 font-mono text-sm shadow-none focus-visible:ring-0"
|
|
721
|
+
/>
|
|
722
|
+
)
|
|
723
|
+
) : file.markdown && viewMode === "preview" ? (
|
|
724
|
+
<MarkdownBody>{body}</MarkdownBody>
|
|
725
|
+
) : (
|
|
726
|
+
<pre className="overflow-x-auto whitespace-pre-wrap break-words border-0 bg-transparent p-0 font-mono text-sm text-foreground">
|
|
727
|
+
<code>{file.content}</code>
|
|
728
|
+
</pre>
|
|
729
|
+
)}
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
export function CompanySkills() {
|
|
736
|
+
const { "*": routePath } = useParams<{ "*": string }>();
|
|
737
|
+
const navigate = useNavigate();
|
|
738
|
+
const queryClient = useQueryClient();
|
|
739
|
+
const { selectedCompanyId } = useCompany();
|
|
740
|
+
const { setBreadcrumbs } = useBreadcrumbs();
|
|
741
|
+
const { pushToast } = useToast();
|
|
742
|
+
const [skillFilter, setSkillFilter] = useState("");
|
|
743
|
+
const [source, setSource] = useState("");
|
|
744
|
+
const [createOpen, setCreateOpen] = useState(false);
|
|
745
|
+
const [emptySourceHelpOpen, setEmptySourceHelpOpen] = useState(false);
|
|
746
|
+
const [expandedSkillId, setExpandedSkillId] = useState<string | null>(null);
|
|
747
|
+
const [expandedDirs, setExpandedDirs] = useState<Record<string, Set<string>>>({});
|
|
748
|
+
const [viewMode, setViewMode] = useState<"preview" | "code">("preview");
|
|
749
|
+
const [editMode, setEditMode] = useState(false);
|
|
750
|
+
const [draft, setDraft] = useState("");
|
|
751
|
+
const [displayedDetail, setDisplayedDetail] = useState<CompanySkillDetail | null>(null);
|
|
752
|
+
const [displayedFile, setDisplayedFile] = useState<CompanySkillFileDetail | null>(null);
|
|
753
|
+
const [scanStatusMessage, setScanStatusMessage] = useState<string | null>(null);
|
|
754
|
+
const parsedRoute = useMemo(() => parseSkillRoute(routePath), [routePath]);
|
|
755
|
+
const routeSkillId = parsedRoute.skillId;
|
|
756
|
+
const selectedPath = parsedRoute.filePath;
|
|
757
|
+
|
|
758
|
+
useEffect(() => {
|
|
759
|
+
setBreadcrumbs([
|
|
760
|
+
{ label: "Skills", href: "/skills" },
|
|
761
|
+
...(routeSkillId ? [{ label: "Detail" }] : []),
|
|
762
|
+
]);
|
|
763
|
+
}, [routeSkillId, setBreadcrumbs]);
|
|
764
|
+
|
|
765
|
+
const skillsQuery = useQuery({
|
|
766
|
+
queryKey: queryKeys.companySkills.list(selectedCompanyId ?? ""),
|
|
767
|
+
queryFn: () => companySkillsApi.list(selectedCompanyId!),
|
|
768
|
+
enabled: Boolean(selectedCompanyId),
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
const selectedSkillId = useMemo(() => {
|
|
772
|
+
if (!routeSkillId) return skillsQuery.data?.[0]?.id ?? null;
|
|
773
|
+
return routeSkillId;
|
|
774
|
+
}, [routeSkillId, skillsQuery.data]);
|
|
775
|
+
|
|
776
|
+
useEffect(() => {
|
|
777
|
+
if (routeSkillId || !selectedSkillId) return;
|
|
778
|
+
navigate(skillRoute(selectedSkillId), { replace: true });
|
|
779
|
+
}, [navigate, routeSkillId, selectedSkillId]);
|
|
780
|
+
|
|
781
|
+
const detailQuery = useQuery({
|
|
782
|
+
queryKey: queryKeys.companySkills.detail(selectedCompanyId ?? "", selectedSkillId ?? ""),
|
|
783
|
+
queryFn: () => companySkillsApi.detail(selectedCompanyId!, selectedSkillId!),
|
|
784
|
+
enabled: Boolean(selectedCompanyId && selectedSkillId),
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
const fileQuery = useQuery({
|
|
788
|
+
queryKey: queryKeys.companySkills.file(selectedCompanyId ?? "", selectedSkillId ?? "", selectedPath),
|
|
789
|
+
queryFn: () => companySkillsApi.file(selectedCompanyId!, selectedSkillId!, selectedPath),
|
|
790
|
+
enabled: Boolean(selectedCompanyId && selectedSkillId && selectedPath),
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
const updateStatusQuery = useQuery({
|
|
794
|
+
queryKey: queryKeys.companySkills.updateStatus(selectedCompanyId ?? "", selectedSkillId ?? ""),
|
|
795
|
+
queryFn: () => companySkillsApi.updateStatus(selectedCompanyId!, selectedSkillId!),
|
|
796
|
+
enabled: Boolean(
|
|
797
|
+
selectedCompanyId
|
|
798
|
+
&& selectedSkillId
|
|
799
|
+
&& (detailQuery.data?.sourceType === "github" || displayedDetail?.sourceType === "github"),
|
|
800
|
+
),
|
|
801
|
+
staleTime: 60_000,
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
useEffect(() => {
|
|
805
|
+
setExpandedSkillId(selectedSkillId);
|
|
806
|
+
}, [selectedSkillId]);
|
|
807
|
+
|
|
808
|
+
useEffect(() => {
|
|
809
|
+
if (!selectedSkillId || selectedPath === "SKILL.md") return;
|
|
810
|
+
const parents = parentDirectoryPaths(selectedPath);
|
|
811
|
+
if (parents.length === 0) return;
|
|
812
|
+
setExpandedDirs((current) => {
|
|
813
|
+
const next = new Set(current[selectedSkillId] ?? []);
|
|
814
|
+
let changed = false;
|
|
815
|
+
for (const parent of parents) {
|
|
816
|
+
if (!next.has(parent)) {
|
|
817
|
+
next.add(parent);
|
|
818
|
+
changed = true;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return changed ? { ...current, [selectedSkillId]: next } : current;
|
|
822
|
+
});
|
|
823
|
+
}, [selectedPath, selectedSkillId]);
|
|
824
|
+
|
|
825
|
+
useEffect(() => {
|
|
826
|
+
setEditMode(false);
|
|
827
|
+
}, [selectedSkillId, selectedPath]);
|
|
828
|
+
|
|
829
|
+
useEffect(() => {
|
|
830
|
+
if (detailQuery.data) {
|
|
831
|
+
setDisplayedDetail(detailQuery.data);
|
|
832
|
+
}
|
|
833
|
+
}, [detailQuery.data]);
|
|
834
|
+
|
|
835
|
+
useEffect(() => {
|
|
836
|
+
if (fileQuery.data) {
|
|
837
|
+
setDisplayedFile(fileQuery.data);
|
|
838
|
+
setDraft(fileQuery.data.markdown ? splitFrontmatter(fileQuery.data.content).body : fileQuery.data.content);
|
|
839
|
+
}
|
|
840
|
+
}, [fileQuery.data]);
|
|
841
|
+
|
|
842
|
+
useEffect(() => {
|
|
843
|
+
if (selectedSkillId) return;
|
|
844
|
+
setDisplayedDetail(null);
|
|
845
|
+
setDisplayedFile(null);
|
|
846
|
+
}, [selectedSkillId]);
|
|
847
|
+
|
|
848
|
+
const activeDetail = detailQuery.data ?? displayedDetail;
|
|
849
|
+
const activeFile = fileQuery.data ?? displayedFile;
|
|
850
|
+
|
|
851
|
+
const importSkill = useMutation({
|
|
852
|
+
mutationFn: (importSource: string) => companySkillsApi.importFromSource(selectedCompanyId!, importSource),
|
|
853
|
+
onSuccess: async (result) => {
|
|
854
|
+
await queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) });
|
|
855
|
+
if (result.imported[0]) navigate(skillRoute(result.imported[0].id));
|
|
856
|
+
pushToast({
|
|
857
|
+
tone: "success",
|
|
858
|
+
title: "Skills imported",
|
|
859
|
+
body: `${result.imported.length} skill${result.imported.length === 1 ? "" : "s"} added.`,
|
|
860
|
+
});
|
|
861
|
+
if (result.warnings[0]) {
|
|
862
|
+
pushToast({ tone: "warn", title: "Import warnings", body: result.warnings[0] });
|
|
863
|
+
}
|
|
864
|
+
setSource("");
|
|
865
|
+
},
|
|
866
|
+
onError: (error) => {
|
|
867
|
+
pushToast({
|
|
868
|
+
tone: "error",
|
|
869
|
+
title: "Skill import failed",
|
|
870
|
+
body: error instanceof Error ? error.message : "Failed to import skill source.",
|
|
871
|
+
});
|
|
872
|
+
},
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
const createSkill = useMutation({
|
|
876
|
+
mutationFn: (payload: CompanySkillCreateRequest) => companySkillsApi.create(selectedCompanyId!, payload),
|
|
877
|
+
onSuccess: async (skill) => {
|
|
878
|
+
await queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) });
|
|
879
|
+
navigate(skillRoute(skill.id));
|
|
880
|
+
setCreateOpen(false);
|
|
881
|
+
pushToast({
|
|
882
|
+
tone: "success",
|
|
883
|
+
title: "Skill created",
|
|
884
|
+
body: `${skill.name} is now editable in the Corporate workspace.`,
|
|
885
|
+
});
|
|
886
|
+
},
|
|
887
|
+
onError: (error) => {
|
|
888
|
+
pushToast({
|
|
889
|
+
tone: "error",
|
|
890
|
+
title: "Skill creation failed",
|
|
891
|
+
body: error instanceof Error ? error.message : "Failed to create skill.",
|
|
892
|
+
});
|
|
893
|
+
},
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
const scanProjects = useMutation({
|
|
897
|
+
mutationFn: () => companySkillsApi.scanProjects(selectedCompanyId!),
|
|
898
|
+
onMutate: () => {
|
|
899
|
+
setScanStatusMessage("Scanning project workspaces for skills...");
|
|
900
|
+
},
|
|
901
|
+
onSuccess: async (result) => {
|
|
902
|
+
setScanStatusMessage("Refreshing skills list...");
|
|
903
|
+
await queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) });
|
|
904
|
+
const summary = formatProjectScanSummary(result);
|
|
905
|
+
setScanStatusMessage(summary);
|
|
906
|
+
pushToast({
|
|
907
|
+
tone: "success",
|
|
908
|
+
title: "Project skill scan complete",
|
|
909
|
+
body: summary,
|
|
910
|
+
});
|
|
911
|
+
if (result.conflicts[0]) {
|
|
912
|
+
pushToast({
|
|
913
|
+
tone: "warn",
|
|
914
|
+
title: "Skill conflicts found",
|
|
915
|
+
body: result.conflicts[0].reason,
|
|
916
|
+
});
|
|
917
|
+
} else if (result.warnings[0]) {
|
|
918
|
+
pushToast({
|
|
919
|
+
tone: "warn",
|
|
920
|
+
title: "Scan warnings",
|
|
921
|
+
body: result.warnings[0],
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
onError: (error) => {
|
|
926
|
+
setScanStatusMessage(null);
|
|
927
|
+
pushToast({
|
|
928
|
+
tone: "error",
|
|
929
|
+
title: "Project skill scan failed",
|
|
930
|
+
body: error instanceof Error ? error.message : "Failed to scan project workspaces.",
|
|
931
|
+
});
|
|
932
|
+
},
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
const saveFile = useMutation({
|
|
936
|
+
mutationFn: () => companySkillsApi.updateFile(
|
|
937
|
+
selectedCompanyId!,
|
|
938
|
+
selectedSkillId!,
|
|
939
|
+
selectedPath,
|
|
940
|
+
activeFile?.markdown ? mergeFrontmatter(activeFile.content, draft) : draft,
|
|
941
|
+
),
|
|
942
|
+
onSuccess: async (result) => {
|
|
943
|
+
await Promise.all([
|
|
944
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) }),
|
|
945
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.detail(selectedCompanyId!, selectedSkillId!) }),
|
|
946
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.file(selectedCompanyId!, selectedSkillId!, selectedPath) }),
|
|
947
|
+
]);
|
|
948
|
+
setDraft(result.markdown ? splitFrontmatter(result.content).body : result.content);
|
|
949
|
+
setEditMode(false);
|
|
950
|
+
pushToast({
|
|
951
|
+
tone: "success",
|
|
952
|
+
title: "Skill saved",
|
|
953
|
+
body: result.path,
|
|
954
|
+
});
|
|
955
|
+
},
|
|
956
|
+
onError: (error) => {
|
|
957
|
+
pushToast({
|
|
958
|
+
tone: "error",
|
|
959
|
+
title: "Save failed",
|
|
960
|
+
body: error instanceof Error ? error.message : "Failed to save skill file.",
|
|
961
|
+
});
|
|
962
|
+
},
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
const installUpdate = useMutation({
|
|
966
|
+
mutationFn: () => companySkillsApi.installUpdate(selectedCompanyId!, selectedSkillId!),
|
|
967
|
+
onSuccess: async (skill) => {
|
|
968
|
+
await Promise.all([
|
|
969
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.list(selectedCompanyId!) }),
|
|
970
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.detail(selectedCompanyId!, selectedSkillId!) }),
|
|
971
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.updateStatus(selectedCompanyId!, selectedSkillId!) }),
|
|
972
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.companySkills.file(selectedCompanyId!, selectedSkillId!, selectedPath) }),
|
|
973
|
+
]);
|
|
974
|
+
navigate(skillRoute(skill.id, selectedPath));
|
|
975
|
+
pushToast({
|
|
976
|
+
tone: "success",
|
|
977
|
+
title: "Skill updated",
|
|
978
|
+
body: skill.sourceRef ? `Pinned to ${shortRef(skill.sourceRef)}` : skill.name,
|
|
979
|
+
});
|
|
980
|
+
},
|
|
981
|
+
onError: (error) => {
|
|
982
|
+
pushToast({
|
|
983
|
+
tone: "error",
|
|
984
|
+
title: "Update failed",
|
|
985
|
+
body: error instanceof Error ? error.message : "Failed to install skill update.",
|
|
986
|
+
});
|
|
987
|
+
},
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
if (!selectedCompanyId) {
|
|
991
|
+
return <EmptyState icon={Boxes} message="Select a company to manage skills." />;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
function handleAddSkillSource() {
|
|
995
|
+
const trimmedSource = source.trim();
|
|
996
|
+
if (trimmedSource.length === 0) {
|
|
997
|
+
setEmptySourceHelpOpen(true);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
importSkill.mutate(trimmedSource);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
return (
|
|
1004
|
+
<>
|
|
1005
|
+
<Dialog open={emptySourceHelpOpen} onOpenChange={setEmptySourceHelpOpen}>
|
|
1006
|
+
<DialogContent className="sm:max-w-md">
|
|
1007
|
+
<DialogHeader>
|
|
1008
|
+
<DialogTitle>Add a skill source</DialogTitle>
|
|
1009
|
+
<DialogDescription>
|
|
1010
|
+
Paste a local path, GitHub URL, or `skills.sh` command into the field first.
|
|
1011
|
+
</DialogDescription>
|
|
1012
|
+
</DialogHeader>
|
|
1013
|
+
<div className="space-y-3 text-sm">
|
|
1014
|
+
<a
|
|
1015
|
+
href="https://skills.sh"
|
|
1016
|
+
target="_blank"
|
|
1017
|
+
rel="noreferrer"
|
|
1018
|
+
className="flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40"
|
|
1019
|
+
>
|
|
1020
|
+
<span>
|
|
1021
|
+
<span className="block font-medium">Browse skills.sh</span>
|
|
1022
|
+
<span className="mt-1 block text-muted-foreground">
|
|
1023
|
+
Find install commands and paste one here.
|
|
1024
|
+
</span>
|
|
1025
|
+
</span>
|
|
1026
|
+
<ExternalLink className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />
|
|
1027
|
+
</a>
|
|
1028
|
+
<a
|
|
1029
|
+
href="https://github.com/search?q=SKILL.md&type=code"
|
|
1030
|
+
target="_blank"
|
|
1031
|
+
rel="noreferrer"
|
|
1032
|
+
className="flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40"
|
|
1033
|
+
>
|
|
1034
|
+
<span>
|
|
1035
|
+
<span className="block font-medium">Search GitHub</span>
|
|
1036
|
+
<span className="mt-1 block text-muted-foreground">
|
|
1037
|
+
Look for repositories with `SKILL.md`, then paste the repo URL here.
|
|
1038
|
+
</span>
|
|
1039
|
+
</span>
|
|
1040
|
+
<ExternalLink className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" />
|
|
1041
|
+
</a>
|
|
1042
|
+
</div>
|
|
1043
|
+
<DialogFooter showCloseButton />
|
|
1044
|
+
</DialogContent>
|
|
1045
|
+
</Dialog>
|
|
1046
|
+
|
|
1047
|
+
<div className="grid min-h-[calc(100vh-12rem)] gap-0 xl:grid-cols-[19rem_minmax(0,1fr)]">
|
|
1048
|
+
<aside className="border-r border-border">
|
|
1049
|
+
<div className="border-b border-border px-4 py-3">
|
|
1050
|
+
<div className="flex items-center justify-between gap-2">
|
|
1051
|
+
<div>
|
|
1052
|
+
<h1 className="text-base font-semibold">Skills</h1>
|
|
1053
|
+
<p className="text-xs text-muted-foreground">
|
|
1054
|
+
{skillsQuery.data?.length ?? 0} available
|
|
1055
|
+
</p>
|
|
1056
|
+
</div>
|
|
1057
|
+
<div className="flex items-center gap-1">
|
|
1058
|
+
<Button
|
|
1059
|
+
variant="ghost"
|
|
1060
|
+
size="icon-sm"
|
|
1061
|
+
onClick={() => scanProjects.mutate()}
|
|
1062
|
+
disabled={scanProjects.isPending}
|
|
1063
|
+
title="Scan project workspaces for skills"
|
|
1064
|
+
>
|
|
1065
|
+
<RefreshCw className={cn("h-4 w-4", scanProjects.isPending && "animate-spin")} />
|
|
1066
|
+
</Button>
|
|
1067
|
+
<Button variant="ghost" size="icon-sm" onClick={() => setCreateOpen((value) => !value)}>
|
|
1068
|
+
<Plus className="h-4 w-4" />
|
|
1069
|
+
</Button>
|
|
1070
|
+
</div>
|
|
1071
|
+
</div>
|
|
1072
|
+
|
|
1073
|
+
<div className="mt-3 flex items-center gap-2 border-b border-border pb-2">
|
|
1074
|
+
<Search className="h-4 w-4 text-muted-foreground" />
|
|
1075
|
+
<input
|
|
1076
|
+
value={skillFilter}
|
|
1077
|
+
onChange={(event) => setSkillFilter(event.target.value)}
|
|
1078
|
+
placeholder="Filter skills"
|
|
1079
|
+
className="w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
1080
|
+
/>
|
|
1081
|
+
</div>
|
|
1082
|
+
|
|
1083
|
+
<div className="mt-3 flex items-center gap-2 border-b border-border pb-2">
|
|
1084
|
+
<input
|
|
1085
|
+
value={source}
|
|
1086
|
+
onChange={(event) => setSource(event.target.value)}
|
|
1087
|
+
placeholder="Paste path, GitHub URL, or skills.sh command"
|
|
1088
|
+
className="w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
1089
|
+
/>
|
|
1090
|
+
<Button
|
|
1091
|
+
size="sm"
|
|
1092
|
+
variant="ghost"
|
|
1093
|
+
onClick={handleAddSkillSource}
|
|
1094
|
+
disabled={importSkill.isPending}
|
|
1095
|
+
>
|
|
1096
|
+
{importSkill.isPending ? <RefreshCw className="h-4 w-4 animate-spin" /> : "Add"}
|
|
1097
|
+
</Button>
|
|
1098
|
+
</div>
|
|
1099
|
+
{scanStatusMessage && (
|
|
1100
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
1101
|
+
{scanStatusMessage}
|
|
1102
|
+
</p>
|
|
1103
|
+
)}
|
|
1104
|
+
</div>
|
|
1105
|
+
|
|
1106
|
+
{createOpen && (
|
|
1107
|
+
<NewSkillForm
|
|
1108
|
+
onCreate={(payload) => createSkill.mutate(payload)}
|
|
1109
|
+
isPending={createSkill.isPending}
|
|
1110
|
+
onCancel={() => setCreateOpen(false)}
|
|
1111
|
+
/>
|
|
1112
|
+
)}
|
|
1113
|
+
|
|
1114
|
+
{skillsQuery.isLoading ? (
|
|
1115
|
+
<PageSkeleton variant="list" />
|
|
1116
|
+
) : skillsQuery.error ? (
|
|
1117
|
+
<div className="px-4 py-6 text-sm text-destructive">{skillsQuery.error.message}</div>
|
|
1118
|
+
) : (
|
|
1119
|
+
<SkillList
|
|
1120
|
+
skills={skillsQuery.data ?? []}
|
|
1121
|
+
selectedSkillId={selectedSkillId}
|
|
1122
|
+
skillFilter={skillFilter}
|
|
1123
|
+
expandedSkillId={expandedSkillId}
|
|
1124
|
+
expandedDirs={expandedDirs}
|
|
1125
|
+
selectedPaths={selectedSkillId ? { [selectedSkillId]: selectedPath } : {}}
|
|
1126
|
+
onToggleSkill={(currentSkillId) =>
|
|
1127
|
+
setExpandedSkillId((current) => current === currentSkillId ? null : currentSkillId)
|
|
1128
|
+
}
|
|
1129
|
+
onToggleDir={(currentSkillId, path) => {
|
|
1130
|
+
setExpandedDirs((current) => {
|
|
1131
|
+
const next = new Set(current[currentSkillId] ?? []);
|
|
1132
|
+
if (next.has(path)) next.delete(path);
|
|
1133
|
+
else next.add(path);
|
|
1134
|
+
return { ...current, [currentSkillId]: next };
|
|
1135
|
+
});
|
|
1136
|
+
}}
|
|
1137
|
+
onSelectSkill={(currentSkillId) => setExpandedSkillId(currentSkillId)}
|
|
1138
|
+
onSelectPath={() => {}}
|
|
1139
|
+
/>
|
|
1140
|
+
)}
|
|
1141
|
+
</aside>
|
|
1142
|
+
|
|
1143
|
+
<div className="min-w-0 pl-6">
|
|
1144
|
+
<SkillPane
|
|
1145
|
+
loading={skillsQuery.isLoading || detailQuery.isLoading}
|
|
1146
|
+
detail={activeDetail}
|
|
1147
|
+
file={activeFile}
|
|
1148
|
+
fileLoading={fileQuery.isLoading && !activeFile}
|
|
1149
|
+
updateStatus={updateStatusQuery.data}
|
|
1150
|
+
updateStatusLoading={updateStatusQuery.isLoading}
|
|
1151
|
+
viewMode={viewMode}
|
|
1152
|
+
editMode={editMode}
|
|
1153
|
+
draft={draft}
|
|
1154
|
+
setViewMode={setViewMode}
|
|
1155
|
+
setEditMode={setEditMode}
|
|
1156
|
+
setDraft={setDraft}
|
|
1157
|
+
onCheckUpdates={() => {
|
|
1158
|
+
void updateStatusQuery.refetch();
|
|
1159
|
+
}}
|
|
1160
|
+
checkUpdatesPending={updateStatusQuery.isFetching}
|
|
1161
|
+
onInstallUpdate={() => installUpdate.mutate()}
|
|
1162
|
+
installUpdatePending={installUpdate.isPending}
|
|
1163
|
+
onSave={() => saveFile.mutate()}
|
|
1164
|
+
savePending={saveFile.isPending}
|
|
1165
|
+
/>
|
|
1166
|
+
</div>
|
|
1167
|
+
</div>
|
|
1168
|
+
</>
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
|