diff --git a/README.md b/README.md index 3e60a219..6b5cf7ab 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,31 @@ Skills follow the [Agent Skills](https://agentskills.io) open format—a simple, ![SkillKit Demo](https://raw.githubusercontent.com/rohitg00/skillkit/main/skillkit.gif) +## Interactive TUI + +Manage all your skills with a beautiful terminal interface: + +```bash +skillkit ui +# or simply +skillkit +``` + +![SkillKit TUI](docs/img/skillkit-ui.png) + +**Features:** +- Browse 33+ skill repositories +- Install skills with one keystroke +- Multi-agent installation support +- View installed skills +- Sync across agents +- Responsive design for all terminal sizes + +**Navigation:** +- `h` Home | `b` Browse | `l` List | `s` Sync | `,` Config +- `↑↓` Navigate | `Enter` Select | `Esc` Back | `q` Quit +- `m` Multi-agent selection | `r` Refresh/Back + ### Compatible With | Agent | Status | @@ -35,6 +60,7 @@ Skills follow the [Agent Skills](https://agentskills.io) open format—a simple, ## Features +- **Interactive TUI**: Beautiful terminal interface for managing skills - **Multi-Agent Support**: Works with 17+ AI coding agents out of the box - **Multi-Platform Git**: GitHub, GitLab, Bitbucket, and local paths - **CI/CD Friendly**: Non-interactive flags for automation (`--skills`, `--all`, `--yes`) @@ -53,6 +79,9 @@ npx skillkit ## Quick Start ```bash +# Launch interactive TUI +skillkit ui + # Initialize in your project (auto-detects agent) skillkit init @@ -95,6 +124,34 @@ skillkit install vercel-labs/agent-skills/skills ## Commands +### `skillkit ui` / `skillkit` + +Launch the interactive Terminal User Interface (TUI) for managing skills. + +```bash +skillkit ui # Explicit TUI launch +skillkit # Launch TUI if no arguments provided +``` + +**TUI Features:** +- **Browse**: Discover skills from 33+ repositories +- **List**: View all installed skills +- **Sync**: Sync skills across multiple agents +- **Settings**: Configure SkillKit preferences + +**Keyboard Shortcuts:** +- `h` - Home screen +- `b` - Browse skills marketplace +- `l` - List installed skills +- `s` - Sync skills across agents +- `,` - Settings +- `↑↓` - Navigate lists +- `Enter` - Select / Install +- `m` - Multi-agent selection (when viewing skills) +- `r` - Refresh / Go back +- `Esc` - Return to home +- `q` - Quit + ### `skillkit install ` Install skills from various sources. diff --git a/docs/img/skillkit-ui-.png b/docs/img/skillkit-ui-.png new file mode 100644 index 00000000..dd5ba730 Binary files /dev/null and b/docs/img/skillkit-ui-.png differ diff --git a/docs/img/skillkit-ui.png b/docs/img/skillkit-ui.png new file mode 100644 index 00000000..7c01d440 Binary files /dev/null and b/docs/img/skillkit-ui.png differ diff --git a/docs/img/skillkit.png b/docs/img/skillkit.png new file mode 100644 index 00000000..d0ca3ff1 Binary files /dev/null and b/docs/img/skillkit.png differ diff --git a/package-lock.json b/package-lock.json index 0822058f..a30adcdd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,24 @@ { "name": "skillkit", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "skillkit", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "dependencies": { "chalk": "^5.3.0", "clipanion": "^4.0.0-rc.4", "got": "^14.4.1", + "ink": "^5.0.1", + "ink-select-input": "^6.0.0", + "ink-spinner": "^5.0.0", + "ink-text-input": "^6.0.0", "isomorphic-git": "^1.27.1", "ora": "^8.1.0", + "react": "^18.3.1", "yaml": "^2.6.1", "zod": "^3.24.1" }, @@ -23,6 +28,7 @@ }, "devDependencies": { "@types/node": "^22.10.5", + "@types/react": "^18.3.18", "tsup": "^8.3.5", "typescript": "^5.7.2", "vitest": "^2.1.8" @@ -31,6 +37,19 @@ "node": ">=18.0.0" } }, + "node_modules/@alcalzone/ansi-tokenize": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.1.3.tgz", + "integrity": "sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "is-fullwidth-code-point": "^4.0.0" + }, + "engines": { + "node": ">=14.13.1" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.2.tgz", @@ -909,6 +928,24 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/prop-types": { + "version": "15.7.15", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", + "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.3.27", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.27.tgz", + "integrity": "sha512-cisd7gxkzjBKU2GgdYrTdtQx1SORymWyaAFhaxQPK9bYO9ot3Y5OikQRvY0VYQtvwjeQnizCINJAenh/V7MK2w==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.2.2" + } + }, "node_modules/@vitest/expect": { "version": "2.1.9", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz", @@ -1061,6 +1098,21 @@ "node": ">=0.4.0" } }, + "node_modules/ansi-escapes": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-7.2.0.tgz", + "integrity": "sha512-g6LhBsl+GBPRWGWsBtutpzBYuIIdBkLEvad5C/va/74Db018+5TZiyA26cZJAr3Rft5lprVqOIPxf5Vid6tqAw==", + "license": "MIT", + "dependencies": { + "environment": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ansi-regex": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", @@ -1073,6 +1125,18 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, + "node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", @@ -1096,6 +1160,18 @@ "integrity": "sha512-Az2ZTpuytrtqENulXwO3GGv1Bztugx6TT37NIo7imr/Qo0gsYiGtSdBa2B6fsXhTpVZDNfu1Qn3pk531e3q+nQ==", "license": "MIT" }, + "node_modules/auto-bind": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/auto-bind/-/auto-bind-5.0.1.tgz", + "integrity": "sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1328,6 +1404,18 @@ "integrity": "sha512-bLSptAy2P0s6hU4PzuIMKmMJJSE6gLXGH1cntDu7bWJUksvuM+7ReOK61mozULErYvP6a15rnYl0zFDef+pyPw==", "license": "Apache-2.0" }, + "node_modules/cli-boxes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", + "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", @@ -1355,6 +1443,38 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cli-truncate": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-4.0.0.tgz", + "integrity": "sha512-nPdaFdQ0h/GEigbPClz11D0v/ZJEwxmeVZGeMo3Z5StPtUTkA9o1lD6QwoirYiSDzbcwn2XcjwmCp68W1IS4TA==", + "license": "MIT", + "dependencies": { + "slice-ansi": "^5.0.0", + "string-width": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cli-truncate/node_modules/slice-ansi": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz", + "integrity": "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.0.0", + "is-fullwidth-code-point": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, "node_modules/clipanion": { "version": "4.0.0-rc.4", "resolved": "https://registry.npmjs.org/clipanion/-/clipanion-4.0.0-rc.4.tgz", @@ -1370,6 +1490,18 @@ "typanion": "*" } }, + "node_modules/code-excerpt": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/code-excerpt/-/code-excerpt-4.0.0.tgz", + "integrity": "sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==", + "license": "MIT", + "dependencies": { + "convert-to-spaces": "^2.0.1" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", @@ -1397,6 +1529,15 @@ "node": "^14.18.0 || >=16.10.0" } }, + "node_modules/convert-to-spaces": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/convert-to-spaces/-/convert-to-spaces-2.0.1.tgz", + "integrity": "sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/crc-32": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", @@ -1409,6 +1550,13 @@ "node": ">=0.8" } }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "devOptional": true, + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1495,6 +1643,18 @@ "integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==", "license": "MIT" }, + "node_modules/environment": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -1532,6 +1692,16 @@ "node": ">= 0.4" } }, + "node_modules/es-toolkit": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.44.0.tgz", + "integrity": "sha512-6penXeZalaV88MM3cGkFZZfOoLGWshWWfdy0tWw/RlVVyhvMaWSBTOvXNeiW3e5FwdS5ePW0LGEu17zT139ktg==", + "license": "MIT", + "workspaces": [ + "docs", + "benchmarks" + ] + }, "node_modules/esbuild": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.2.tgz", @@ -1574,6 +1744,15 @@ "@esbuild/win32-x64": "0.27.2" } }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -1630,6 +1809,21 @@ } } }, + "node_modules/figures": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz", + "integrity": "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==", + "license": "MIT", + "dependencies": { + "is-unicode-supported": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/fix-dts-default-cjs-exports": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fix-dts-default-cjs-exports/-/fix-dts-default-cjs-exports-1.0.1.tgz", @@ -1892,12 +2086,174 @@ "node": ">= 4" } }, + "node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/ink": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/ink/-/ink-5.2.1.tgz", + "integrity": "sha512-BqcUyWrG9zq5HIwW6JcfFHsIYebJkWWb4fczNah1goUO0vv5vneIlfwuS85twyJ5hYR/y18FlAYUxrO9ChIWVg==", + "license": "MIT", + "dependencies": { + "@alcalzone/ansi-tokenize": "^0.1.3", + "ansi-escapes": "^7.0.0", + "ansi-styles": "^6.2.1", + "auto-bind": "^5.0.1", + "chalk": "^5.3.0", + "cli-boxes": "^3.0.0", + "cli-cursor": "^4.0.0", + "cli-truncate": "^4.0.0", + "code-excerpt": "^4.0.0", + "es-toolkit": "^1.22.0", + "indent-string": "^5.0.0", + "is-in-ci": "^1.0.0", + "patch-console": "^2.0.0", + "react-reconciler": "^0.29.0", + "scheduler": "^0.23.0", + "signal-exit": "^3.0.7", + "slice-ansi": "^7.1.0", + "stack-utils": "^2.0.6", + "string-width": "^7.2.0", + "type-fest": "^4.27.0", + "widest-line": "^5.0.0", + "wrap-ansi": "^9.0.0", + "ws": "^8.18.0", + "yoga-layout": "~3.2.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "react": ">=18.0.0", + "react-devtools-core": "^4.19.1" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react-devtools-core": { + "optional": true + } + } + }, + "node_modules/ink-select-input": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ink-select-input/-/ink-select-input-6.2.0.tgz", + "integrity": "sha512-304fZXxkpYxJ9si5lxRCaX01GNlmPBgOZumXXRnPYbHW/iI31cgQynqk2tRypGLOF1cMIwPUzL2LSm6q4I5rQQ==", + "license": "MIT", + "dependencies": { + "figures": "^6.1.0", + "to-rotated": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "ink": ">=5.0.0", + "react": ">=18.0.0" + } + }, + "node_modules/ink-spinner": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ink-spinner/-/ink-spinner-5.0.0.tgz", + "integrity": "sha512-EYEasbEjkqLGyPOUc8hBJZNuC5GvXGMLu0w5gdTNskPc7Izc5vO3tdQEYnzvshucyGCBXc86ig0ujXPMWaQCdA==", + "license": "MIT", + "dependencies": { + "cli-spinners": "^2.7.0" + }, + "engines": { + "node": ">=14.16" + }, + "peerDependencies": { + "ink": ">=4.0.0", + "react": ">=18.0.0" + } + }, + "node_modules/ink-text-input": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ink-text-input/-/ink-text-input-6.0.0.tgz", + "integrity": "sha512-Fw64n7Yha5deb1rHY137zHTAbSTNelUKuB5Kkk2HACXEtwIHBCf9OH2tP/LQ9fRYTl1F0dZgbW0zPnZk6FA9Lw==", + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "type-fest": "^4.18.2" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "ink": ">=5", + "react": ">=18" + } + }, + "node_modules/ink/node_modules/cli-cursor": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", + "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "license": "MIT", + "dependencies": { + "restore-cursor": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ink/node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ink/node_modules/restore-cursor": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", + "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "license": "MIT", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ink/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "license": "ISC" + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -1910,6 +2266,33 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-fullwidth-code-point": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz", + "integrity": "sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-in-ci": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-in-ci/-/is-in-ci-1.0.0.tgz", + "integrity": "sha512-eUuAjybVTHMYWm/U+vBO1sY/JOCgoPCXRxzdju0K+K0BiGW0SChEL1MLC0PoCIR1OlPo5YAp8HuQoUlsWEICwg==", + "license": "MIT", + "bin": { + "is-in-ci": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-interactive": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", @@ -2002,6 +2385,12 @@ "node": ">=10" } }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, "node_modules/keyv": { "version": "5.5.5", "resolved": "https://registry.npmjs.org/keyv/-/keyv-5.5.5.tgz", @@ -2069,6 +2458,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/loupe": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", @@ -2107,6 +2508,15 @@ "node": ">= 0.4" } }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/mimic-function": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz", @@ -2284,6 +2694,15 @@ "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "license": "(MIT AND Zlib)" }, + "node_modules/patch-console": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/patch-console/-/patch-console-2.0.0.tgz", + "integrity": "sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -2454,6 +2873,34 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-reconciler": { + "version": "0.29.2", + "resolved": "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.29.2.tgz", + "integrity": "sha512-zZQqIiYgDCTP/f1N/mAR10nJGrPD2ZR+jDSEsKWJHYC7Cm2wodlwbR3upZRdC3cjIjSlTLNVyO7Iu0Yy7t2AYg==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "engines": { + "node": ">=0.10.0" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, "node_modules/readable-stream": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", @@ -2596,6 +3043,15 @@ ], "license": "MIT" }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/set-function-length": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", @@ -2724,6 +3180,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/slice-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-7.1.2.tgz", + "integrity": "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "is-fullwidth-code-point": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/slice-ansi/node_modules/is-fullwidth-code-point": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-5.1.0.tgz", + "integrity": "sha512-5XHYaSyiqADb4RnZ1Bdad6cPp8Toise4TzEjcOYDHZkTCbKgiUl7WTUCpNWHuxmDt91wnsZBc9xinNzopv3JMQ==", + "license": "MIT", + "dependencies": { + "get-east-asian-width": "^1.3.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/source-map": { "version": "0.7.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", @@ -2744,6 +3231,18 @@ "node": ">=0.10.0" } }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -2932,6 +3431,18 @@ "node": ">= 0.4" } }, + "node_modules/to-rotated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-rotated/-/to-rotated-1.0.0.tgz", + "integrity": "sha512-KsEID8AfgUy+pxVRLsWp0VzCa69wxzUDZnzGbyIST/bcgcrMvTYoFBX/QORH4YApoD89EDuUovx4BTdpOn319Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -3696,12 +4207,65 @@ "node": ">=8" } }, + "node_modules/widest-line": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-5.0.0.tgz", + "integrity": "sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA==", + "license": "MIT", + "dependencies": { + "string-width": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/wrap-ansi": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.2.tgz", + "integrity": "sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "license": "ISC" }, + "node_modules/ws": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", + "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/yaml": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", @@ -3717,6 +4281,12 @@ "url": "https://github.com/sponsors/eemeli" } }, + "node_modules/yoga-layout": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/yoga-layout/-/yoga-layout-3.2.1.tgz", + "integrity": "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==", + "license": "MIT" + }, "node_modules/zod": { "version": "3.25.76", "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", diff --git a/package.json b/package.json index 857f3726..0f039559 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skillkit", - "version": "1.1.0", + "version": "1.2.0", "description": "Universal skills loader for AI coding agents - supports Claude Code, Codex, Cursor, Antigravity, OpenCode, Gemini CLI and more", "type": "module", "main": "./dist/index.js", @@ -60,13 +60,19 @@ "chalk": "^5.3.0", "clipanion": "^4.0.0-rc.4", "got": "^14.4.1", + "ink": "^5.0.1", + "ink-select-input": "^6.0.0", + "ink-spinner": "^5.0.0", + "ink-text-input": "^6.0.0", "isomorphic-git": "^1.27.1", "ora": "^8.1.0", + "react": "^18.3.1", "yaml": "^2.6.1", "zod": "^3.24.1" }, "devDependencies": { "@types/node": "^22.10.5", + "@types/react": "^18.3.18", "tsup": "^8.3.5", "typescript": "^5.7.2", "vitest": "^2.1.8" diff --git a/src/cli.ts b/src/cli.ts index 3369a412..2566aa4b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -12,12 +12,13 @@ import { InitCommand, ValidateCommand, CreateCommand, + UICommand, } from './commands/index.js'; const cli = new Cli({ binaryLabel: 'skillkit', binaryName: 'skillkit', - binaryVersion: '1.0.0', + binaryVersion: '1.1.0', }); cli.register(Builtins.HelpCommand); @@ -34,5 +35,6 @@ cli.register(RemoveCommand); cli.register(InitCommand); cli.register(ValidateCommand); cli.register(CreateCommand); +cli.register(UICommand); cli.runExit(process.argv.slice(2)); diff --git a/src/commands/index.ts b/src/commands/index.ts index eb3cf566..f4bd764f 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -7,4 +7,5 @@ export { UpdateCommand } from './update.js'; export { RemoveCommand } from './remove.js'; export { InitCommand } from './init.js'; export { ValidateCommand } from './validate.js'; -export { CreateCommand } from './create.js'; \ No newline at end of file +export { CreateCommand } from './create.js'; +export { UICommand } from './ui.js'; \ No newline at end of file diff --git a/src/commands/install.ts b/src/commands/install.ts index 8afdaf10..2ff259f5 100644 --- a/src/commands/install.ts +++ b/src/commands/install.ts @@ -163,57 +163,57 @@ export class InstallCommand extends Command { const adapter = getAdapter(agentType); const installDir = getInstallDir(this.global, agentType); - if (!existsSync(installDir)) { - mkdirSync(installDir, { recursive: true }); - } + if (!existsSync(installDir)) { + mkdirSync(installDir, { recursive: true }); + } if (targetAgents.length > 1) { console.log(chalk.cyan(`\nInstalling to ${adapter.name}...`)); } - let installed = 0; - for (const skill of skillsToInstall) { - const skillName = skill.name; - const sourcePath = skill.path; - const targetPath = join(installDir, skillName); + let installed = 0; + for (const skill of skillsToInstall) { + const skillName = skill.name; + const sourcePath = skill.path; + const targetPath = join(installDir, skillName); - if (existsSync(targetPath) && !this.force) { - console.log(chalk.yellow(` Skipping ${skillName} (already exists, use --force to overwrite)`)); - continue; + if (existsSync(targetPath) && !this.force) { + console.log(chalk.yellow(` Skipping ${skillName} (already exists, use --force to overwrite)`)); + continue; + } + + const securityRoot = result.tempRoot || result.path; + if (!isPathInside(sourcePath, securityRoot)) { + console.log(chalk.red(` Skipping ${skillName} (path traversal detected)`)); + continue; + } + + spinner.start(`Installing ${skillName}...`); + + try { + if (existsSync(targetPath)) { + rmSync(targetPath, { recursive: true, force: true }); } - const securityRoot = result.tempRoot || result.path; - if (!isPathInside(sourcePath, securityRoot)) { - console.log(chalk.red(` Skipping ${skillName} (path traversal detected)`)); - continue; - } + cpSync(sourcePath, targetPath, { recursive: true, dereference: true }); - spinner.start(`Installing ${skillName}...`); + const metadata: SkillMetadata = { + name: skillName, + description: '', + source: this.source, + sourceType: providerAdapter.type, + subpath: skillName, + installedAt: new Date().toISOString(), + enabled: true, + }; + saveSkillMetadata(targetPath, metadata); - try { - if (existsSync(targetPath)) { - rmSync(targetPath, { recursive: true, force: true }); - } - - cpSync(sourcePath, targetPath, { recursive: true, dereference: true }); - - const metadata: SkillMetadata = { - name: skillName, - description: '', - source: this.source, - sourceType: providerAdapter.type, - subpath: skillName, - installedAt: new Date().toISOString(), - enabled: true, - }; - saveSkillMetadata(targetPath, metadata); - - spinner.succeed(chalk.green(`Installed ${skillName}`)); - installed++; - } catch (error) { - spinner.fail(chalk.red(`Failed to install ${skillName}`)); - console.error(chalk.dim(error instanceof Error ? error.message : String(error))); - } + spinner.succeed(chalk.green(`Installed ${skillName}`)); + installed++; + } catch (error) { + spinner.fail(chalk.red(`Failed to install ${skillName}`)); + console.error(chalk.dim(error instanceof Error ? error.message : String(error))); + } } totalInstalled += installed; diff --git a/src/commands/ui.ts b/src/commands/ui.ts new file mode 100644 index 00000000..da6275ed --- /dev/null +++ b/src/commands/ui.ts @@ -0,0 +1,19 @@ +import { Command } from 'clipanion'; + +export class UICommand extends Command { + static override paths = [['ui'], ['tui']]; + + static override usage = Command.Usage({ + description: 'Launch the interactive TUI (Terminal User Interface)', + examples: [ + ['Open interactive TUI', '$0 ui'], + ['Alias for TUI', '$0 tui'], + ], + }); + + async execute(): Promise { + const { startTUI } = await import('../tui/index.js'); + await startTUI(); + return 0; + } +} diff --git a/src/tui/App.tsx b/src/tui/App.tsx new file mode 100644 index 00000000..d47b178a --- /dev/null +++ b/src/tui/App.tsx @@ -0,0 +1,58 @@ +import React, { useState } from 'react'; +import { Box, Text, useInput, useApp, useStdout } from 'ink'; +import { Sidebar } from './components/Sidebar.js'; +import { Home } from './screens/Home.js'; +import { Browse } from './screens/Browse.js'; +import { Installed } from './screens/Installed.js'; +import { Sync } from './screens/Sync.js'; +import { Settings } from './screens/Settings.js'; + +export type Screen = 'home' | 'browse' | 'installed' | 'sync' | 'settings'; + +export function App() { + const [screen, setScreen] = useState('home'); + const { exit } = useApp(); + const { stdout } = useStdout(); + + const cols = stdout?.columns || 80; + const rows = stdout?.rows || 24; + const showSidebar = cols >= 70; + + useInput((input, key) => { + if (input === 'q') { + exit(); + return; + } + if (key.escape) { + setScreen('home'); + return; + } + if (input === 'h') setScreen('home'); + if (input === 'b') setScreen('browse'); + if (input === 'l') setScreen('installed'); + if (input === 's') setScreen('sync'); + if (input === ',') setScreen('settings'); + }); + + const renderScreen = () => { + switch (screen) { + case 'home': return ; + case 'browse': return ; + case 'installed': return ; + case 'sync': return ; + case 'settings': return ; + } + }; + + return ( + + + {showSidebar && } + + {renderScreen()} + + + h Home b Browse l List s Sync , Config Esc Back q Quit + + ); +} diff --git a/src/tui/components/Header.tsx b/src/tui/components/Header.tsx new file mode 100644 index 00000000..47e64445 --- /dev/null +++ b/src/tui/components/Header.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { Box, Text } from 'ink'; +import { colors, symbols } from '../theme.js'; + +interface HeaderProps { + title: string; + subtitle?: string; + count?: number; +} + +export function Header({ title, subtitle, count }: HeaderProps) { + return ( + + + + {title.toUpperCase()} + + {count !== undefined && ( + + {symbols.star} {count} + + )} + + {subtitle && ( + + {subtitle} + + )} + + ); +} diff --git a/src/tui/components/SearchInput.tsx b/src/tui/components/SearchInput.tsx new file mode 100644 index 00000000..9b6fe596 --- /dev/null +++ b/src/tui/components/SearchInput.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { Box, Text } from 'ink'; +import TextInput from 'ink-text-input'; +import { colors, symbols } from '../theme.js'; + +interface SearchInputProps { + value: string; + onChange: (value: string) => void; + placeholder?: string; + isFocused?: boolean; +} + +export function SearchInput({ + value, + onChange, + placeholder = 'Search skills...', + isFocused = false, +}: SearchInputProps) { + return ( + + 🔍 + {isFocused ? ( + + ) : ( + + {value || placeholder} + + )} + + / + + ); +} diff --git a/src/tui/components/Sidebar.tsx b/src/tui/components/Sidebar.tsx new file mode 100644 index 00000000..c5b106b0 --- /dev/null +++ b/src/tui/components/Sidebar.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { Box, Text } from 'ink'; +import { colors, symbols } from '../theme.js'; +import type { Screen } from '../App.js'; + +interface SidebarProps { + screen: Screen; + onNavigate: (screen: Screen) => void; + isCompact?: boolean; +} + +const NAV: { id: Screen; label: string }[] = [ + { id: 'home', label: 'Home' }, + { id: 'browse', label: 'Browse' }, + { id: 'installed', label: 'List' }, + { id: 'sync', label: 'Sync' }, + { id: 'settings', label: 'Config' }, +]; + +export function Sidebar({ screen }: SidebarProps) { + return ( + + {colors.primary('SkillKit')} + + {NAV.slice(0, 2).map((item) => ( + + {screen === item.id ? symbols.bullet : ' '}{item.label} + + ))} + + + + {NAV.slice(2).map((item) => ( + + {screen === item.id ? symbols.bullet : ' '}{item.label} + + ))} + + + + ? Help + q Quit + + ); +} diff --git a/src/tui/components/SkillList.tsx b/src/tui/components/SkillList.tsx new file mode 100644 index 00000000..fd6eb296 --- /dev/null +++ b/src/tui/components/SkillList.tsx @@ -0,0 +1,104 @@ +import React from 'react'; +import { Box, Text } from 'ink'; +import { colors, symbols } from '../theme.js'; + +export interface SkillItem { + name: string; + description?: string; + source?: string; + installs?: number; + enabled?: boolean; +} + +interface SkillListProps { + skills: SkillItem[]; + selectedIndex: number; + showInstalls?: boolean; + showRank?: boolean; + showSource?: boolean; + maxVisible?: number; +} + +function formatInstalls(count: number): string { + if (count >= 1000) { + return `${(count / 1000).toFixed(1)}K`; + } + return String(count); +} + +export function SkillList({ + skills, + selectedIndex, + showInstalls = false, + showRank = false, + showSource = true, + maxVisible = 10, +}: SkillListProps) { + if (skills.length === 0) { + return ( + + + No skills found + + + ); + } + + const startIndex = Math.max(0, selectedIndex - Math.floor(maxVisible / 2)); + const visibleSkills = skills.slice(startIndex, startIndex + maxVisible); + const actualStartIndex = startIndex; + + return ( + + {showRank && ( + + + {' # SKILL'} + {showSource && ' SOURCE'} + {showInstalls && ' INSTALLS'} + + + )} + + {visibleSkills.map((skill, idx) => { + const realIndex = actualStartIndex + idx; + const isSelected = realIndex === selectedIndex; + const skillName = skill.name.padEnd(28).slice(0, 28); + const sourceName = skill.source ? skill.source.slice(0, 25) : ''; + + return ( + + + {isSelected ? symbols.pointer : ' '} + {showRank ? String(realIndex + 1).padStart(2, ' ') : ''} + {' '} + {skillName} + + {showSource && ( + + {' '}{sourceName} + + )} + {showInstalls && skill.installs !== undefined && ( + + {formatInstalls(skill.installs).padStart(8)} + + )} + + ); + })} + + {skills.length > maxVisible && ( + + + Showing {startIndex + 1}-{Math.min(startIndex + maxVisible, skills.length)} of {skills.length} + + + )} + + ); +} diff --git a/src/tui/components/StatusBar.tsx b/src/tui/components/StatusBar.tsx new file mode 100644 index 00000000..3430df69 --- /dev/null +++ b/src/tui/components/StatusBar.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { Box, Text } from 'ink'; +import { colors, symbols } from '../theme.js'; + +interface Shortcut { + key: string; + label: string; +} + +interface StatusBarProps { + shortcuts: Shortcut[]; + message?: string; +} + +export function StatusBar({ shortcuts, message }: StatusBarProps) { + return ( + + + {shortcuts.map((shortcut, idx) => ( + + + {shortcut.key} + + {shortcut.label} + + ))} + + + {message && ( + + {symbols.check} {message} + + )} + + ); +} diff --git a/src/tui/components/index.ts b/src/tui/components/index.ts new file mode 100644 index 00000000..8c4fd602 --- /dev/null +++ b/src/tui/components/index.ts @@ -0,0 +1,5 @@ +export { Sidebar } from './Sidebar.js'; +export { Header } from './Header.js'; +export { SkillList, type SkillItem } from './SkillList.js'; +export { StatusBar } from './StatusBar.js'; +export { SearchInput } from './SearchInput.js'; diff --git a/src/tui/hooks/index.ts b/src/tui/hooks/index.ts new file mode 100644 index 00000000..70531be3 --- /dev/null +++ b/src/tui/hooks/index.ts @@ -0,0 +1,3 @@ +export { useSkills, useSkillStats } from './useSkills.js'; +export { useMarketplace } from './useMarketplace.js'; +export { useKeyboard, useListNavigation } from './useKeyboard.js'; diff --git a/src/tui/hooks/useKeyboard.ts b/src/tui/hooks/useKeyboard.ts new file mode 100644 index 00000000..4e745f9a --- /dev/null +++ b/src/tui/hooks/useKeyboard.ts @@ -0,0 +1,88 @@ +import { useState, useCallback, useEffect } from 'react'; +import { useInput, useApp } from 'ink'; +import { type Screen, navItems } from '../theme.js'; + +interface UseKeyboardOptions { + onNavigate?: (screen: Screen) => void; + onSelect?: () => void; + onSearch?: () => void; + onInstall?: () => void; + onBack?: () => void; + onUp?: () => void; + onDown?: () => void; + disabled?: boolean; +} + +export function useKeyboard(options: UseKeyboardOptions = {}) { + const { exit } = useApp(); + + useInput((input, key) => { + if (options.disabled) return; + + if (input === 'q' || (key.ctrl && input === 'c')) { + exit(); + return; + } + + if (key.escape && options.onBack) { + options.onBack(); + return; + } + + if (key.return && options.onSelect) { + options.onSelect(); + return; + } + + if (key.upArrow && options.onUp) { + options.onUp(); + return; + } + + if (key.downArrow && options.onDown) { + options.onDown(); + return; + } + + if (input === '/' && options.onSearch) { + options.onSearch(); + return; + } + + if (input === 'i' && options.onInstall) { + options.onInstall(); + return; + } + + for (const item of navItems) { + if (input === item.shortcut && options.onNavigate) { + options.onNavigate(item.id); + return; + } + } + }); +} + +export function useListNavigation(listLength: number, initialIndex = 0) { + const [selectedIndex, setSelectedIndex] = useState(initialIndex); + + useEffect(() => { + if (selectedIndex >= listLength && listLength > 0) { + setSelectedIndex(listLength - 1); + } + }, [listLength, selectedIndex]); + + const moveUp = useCallback(() => { + setSelectedIndex((prev) => Math.max(0, prev - 1)); + }, []); + + const moveDown = useCallback(() => { + setSelectedIndex((prev) => Math.min(listLength - 1, prev + 1)); + }, [listLength]); + + const reset = useCallback(() => { + setSelectedIndex(0); + }, []); + + return { selectedIndex, setSelectedIndex, moveUp, moveDown, reset }; +} diff --git a/src/tui/hooks/useMarketplace.ts b/src/tui/hooks/useMarketplace.ts new file mode 100644 index 00000000..5123b694 --- /dev/null +++ b/src/tui/hooks/useMarketplace.ts @@ -0,0 +1,183 @@ +import { useState, useCallback, useEffect } from 'react'; +import { detectProvider } from '../../providers/index.js'; +import type { SkillItem } from '../components/SkillList.js'; + +export interface RepoInfo { + source: string; + name: string; +} + +const POPULAR_REPOS: RepoInfo[] = [ + { source: 'anthropics/skills', name: 'Anthropic Official' }, + { source: 'vercel-labs/agent-skills', name: 'Vercel Labs' }, + { source: 'expo/skills', name: 'Expo / React Native' }, + { source: 'remotion-dev/skills', name: 'Remotion Video' }, + { source: 'ComposioHQ/awesome-claude-skills', name: 'Composio Awesome' }, + { source: 'travisvn/awesome-claude-skills', name: 'Travis Awesome' }, + { source: 'mhattingpete/claude-skills-marketplace', name: 'Skills Marketplace' }, + { source: 'coreyhaines31/marketingskills', name: 'Marketing Skills' }, + { source: 'obra/superpowers', name: 'Superpowers TDD' }, + { source: 'softaworks/agent-toolkit', name: 'Softaworks Toolkit' }, + { source: 'wshobson/agents', name: 'Dev Patterns' }, + { source: 'langgenius/dify', name: 'Dify Frontend' }, + { source: 'trailofbits/skills', name: 'Trail of Bits Security' }, + { source: 'better-auth/skills', name: 'Better Auth' }, + { source: 'onmax/nuxt-skills', name: 'Nuxt / Vue' }, + { source: 'hyf0/vue-skills', name: 'Vue Best Practices' }, + { source: 'jezweb/claude-skills', name: 'Cloudflare / TanStack' }, + { source: 'elysiajs/skills', name: 'ElysiaJS / Bun' }, + { source: 'kadajett/agent-nestjs-skills', name: 'NestJS' }, + { source: 'callstackincubator/agent-skills', name: 'React Native' }, + { source: 'cloudai-x/threejs-skills', name: 'Three.js' }, + { source: 'emalorenzo/three-agent-skills', name: 'Three.js Advanced' }, + { source: 'dimillian/skills', name: 'SwiftUI iOS' }, + { source: 'stripe/ai', name: 'Stripe Payments' }, + { source: 'waynesutton/convexskills', name: 'Convex Backend' }, + { source: 'kepano/obsidian-skills', name: 'Obsidian Notes' }, + { source: 'jimliu/baoyu-skills', name: 'Baoyu Tools' }, + { source: 'giuseppe-trisciuoglio/developer-kit', name: 'Shadcn / Radix' }, + { source: 'openrouterteam/agent-skills', name: 'OpenRouter SDK' }, + { source: 'intellectronica/agent-skills', name: 'Context7' }, + { source: 'boristane/agent-skills', name: 'Logging Patterns' }, + { source: 'f/awesome-chatgpt-prompts', name: 'ChatGPT Prompts' }, + { source: 'rohitg00/openskills', name: 'OpenSkills' }, +]; + +interface FetchedSkill { + name: string; + source: string; + repoName: string; + description?: string; +} + +interface UseMarketplaceResult { + skills: SkillItem[]; + loading: boolean; + error: string | null; + totalCount: number; + repos: RepoInfo[]; + currentRepo: string | null; + refresh: () => void; + search: (query: string) => void; + fetchRepo: (source: string) => Promise; + fetchAllRepos: () => Promise; +} + +export function useMarketplace(): UseMarketplaceResult { + const [allSkills, setAllSkills] = useState([]); + const [filteredSkills, setFilteredSkills] = useState([]); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + const [currentRepo, setCurrentRepo] = useState(null); + const [fetchedRepos, setFetchedRepos] = useState>(new Set()); + + const fetchRepo = useCallback(async (source: string) => { + if (fetchedRepos.has(source)) return; + + setLoading(true); + setError(null); + setCurrentRepo(source); + + try { + const provider = detectProvider(source); + if (!provider) { + throw new Error(`Could not detect provider for: ${source}`); + } + + const result = await provider.clone(source, '', { depth: 1 }); + + if (!result.success || !result.discoveredSkills) { + throw new Error(result.error || 'Failed to fetch skills'); + } + + const repoName = POPULAR_REPOS.find(r => r.source === source)?.name || source; + const newSkills: FetchedSkill[] = result.discoveredSkills.map(skill => ({ + name: skill.name, + source: source, + repoName: repoName, + description: skill.description, + })); + + setAllSkills(prev => { + const updated = [...prev, ...newSkills]; + return updated.sort((a, b) => a.name.localeCompare(b.name)); + }); + + setFetchedRepos(prev => new Set([...prev, source])); + + if (result.tempRoot) { + const { rmSync } = await import('node:fs'); + rmSync(result.tempRoot, { recursive: true, force: true }); + } + } catch (err) { + setError(err instanceof Error ? err.message : 'Failed to fetch repository'); + } finally { + setLoading(false); + setCurrentRepo(null); + } + }, [fetchedRepos]); + + const fetchAllRepos = useCallback(async () => { + setLoading(true); + setError(null); + + for (const repo of POPULAR_REPOS) { + if (!fetchedRepos.has(repo.source)) { + setCurrentRepo(repo.source); + try { + await fetchRepo(repo.source); + } catch { + } + } + } + + setLoading(false); + setCurrentRepo(null); + }, [fetchRepo, fetchedRepos]); + + const search = useCallback((query: string) => { + if (!query.trim()) { + setFilteredSkills(allSkills); + } else { + const lowerQuery = query.toLowerCase(); + setFilteredSkills( + allSkills.filter( + (s) => + s.name.toLowerCase().includes(lowerQuery) || + s.source.toLowerCase().includes(lowerQuery) || + s.repoName.toLowerCase().includes(lowerQuery) || + s.description?.toLowerCase().includes(lowerQuery) + ) + ); + } + }, [allSkills]); + + const refresh = useCallback(() => { + setFetchedRepos(new Set()); + setAllSkills([]); + setFilteredSkills([]); + }, []); + + useEffect(() => { + setFilteredSkills(allSkills); + }, [allSkills]); + + const skills: SkillItem[] = filteredSkills.map((s) => ({ + name: s.name, + description: s.description || s.repoName, + source: s.source, + })); + + return { + skills, + loading, + error, + totalCount: allSkills.length, + repos: POPULAR_REPOS, + currentRepo, + refresh, + search, + fetchRepo, + fetchAllRepos, + }; +} diff --git a/src/tui/hooks/useSkills.ts b/src/tui/hooks/useSkills.ts new file mode 100644 index 00000000..ec18bd8d --- /dev/null +++ b/src/tui/hooks/useSkills.ts @@ -0,0 +1,64 @@ +import { useState, useEffect } from 'react'; +import { getSearchDirs } from '../../core/config.js'; +import { findAllSkills } from '../../core/skills.js'; +import type { SkillItem } from '../components/SkillList.js'; + +interface UseSkillsResult { + skills: SkillItem[]; + loading: boolean; + error: string | null; + refresh: () => void; +} + +export function useSkills(): UseSkillsResult { + const [skills, setSkills] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + const refresh = () => { + setLoading(true); + setError(null); + + try { + const searchDirs = getSearchDirs(); + const foundSkills = findAllSkills(searchDirs); + + const skillItems: SkillItem[] = foundSkills.map((s) => ({ + name: s.name, + description: s.description, + source: s.source, + enabled: s.enabled, + })); + + setSkills(skillItems); + } catch (err) { + setError(err instanceof Error ? err.message : 'Failed to load skills'); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + refresh(); + }, []); + + return { skills, loading, error, refresh }; +} + +interface UseSkillStatsResult { + projectCount: number; + globalCount: number; + enabledCount: number; + agentCount: number; +} + +export function useSkillStats(): UseSkillStatsResult { + const { skills } = useSkills(); + + return { + projectCount: skills.length, + globalCount: 0, + enabledCount: skills.filter((s) => s.enabled !== false).length, + agentCount: 1, + }; +} diff --git a/src/tui/index.tsx b/src/tui/index.tsx new file mode 100644 index 00000000..6e1461c7 --- /dev/null +++ b/src/tui/index.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import { render } from 'ink'; +import { App } from './App.js'; + +export function startTUI() { + const { waitUntilExit } = render(); + return waitUntilExit(); +} diff --git a/src/tui/screens/Browse.tsx b/src/tui/screens/Browse.tsx new file mode 100644 index 00000000..5bbc20f8 --- /dev/null +++ b/src/tui/screens/Browse.tsx @@ -0,0 +1,223 @@ +import React, { useState } from 'react'; +import { existsSync, mkdirSync, cpSync, rmSync } from 'node:fs'; +import { join } from 'node:path'; +import { Box, Text, useInput } from 'ink'; +import { colors, symbols } from '../theme.js'; +import { useMarketplace } from '../hooks/useMarketplace.js'; +import { detectProvider } from '../../providers/index.js'; +import { detectAgent, getAdapter, getAllAdapters } from '../../agents/index.js'; +import { getInstallDir, saveSkillMetadata } from '../../core/config.js'; +import type { SkillMetadata, AgentType } from '../../core/types.js'; + +type View = 'repos' | 'skills' | 'agents'; + +interface Props { + cols?: number; + rows?: number; +} + +export function Browse({ rows = 24 }: Props) { + const { repos, skills, loading, currentRepo, fetchRepo, fetchAllRepos } = useMarketplace(); + const [view, setView] = useState('repos'); + const [sel, setSel] = useState(0); + const [installing, setInstalling] = useState(null); + const [message, setMessage] = useState(null); + const [selectedSkill, setSelectedSkill] = useState<{ name: string; source: string } | null>(null); + const [agents, setAgents] = useState<{ type: AgentType; name: string; detected: boolean }[]>([]); + + const items = view === 'repos' ? repos : view === 'skills' ? skills : agents; + const maxVisible = Math.max(5, rows - 8); + const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), items.length - maxVisible)); + const visible = items.slice(start, start + maxVisible); + + const showAgentSelection = async (skillName: string, source: string) => { + setSelectedSkill({ name: skillName, source }); + const adapters = getAllAdapters(); + const agentList: typeof agents = []; + for (const a of adapters) { + agentList.push({ + type: a.type as AgentType, + name: a.name, + detected: await a.isDetected(), + }); + } + setAgents(agentList); + setView('agents'); + setSel(0); + }; + + const installSkill = async (skillName: string, source: string, agentType?: AgentType) => { + setInstalling(skillName); + setMessage(null); + + try { + const provider = detectProvider(source); + if (!provider) { + setMessage(`Error: Unknown provider for ${source}`); + setInstalling(null); + return; + } + + const result = await provider.clone(source, '', { depth: 1 }); + + if (!result.success || !result.discoveredSkills) { + setMessage(`Error: ${result.error || 'Failed to fetch'}`); + setInstalling(null); + return; + } + + const skill = result.discoveredSkills.find(s => s.name === skillName); + if (!skill) { + setMessage(`Error: Skill ${skillName} not found`); + setInstalling(null); + return; + } + + const targetAgentType = agentType || await detectAgent(); + const adapter = getAdapter(targetAgentType); + const installDir = getInstallDir(false, targetAgentType); + + if (!existsSync(installDir)) { + mkdirSync(installDir, { recursive: true }); + } + + const targetPath = join(installDir, skillName); + + if (existsSync(targetPath)) { + rmSync(targetPath, { recursive: true, force: true }); + } + + cpSync(skill.path, targetPath, { recursive: true, dereference: true }); + + const metadata: SkillMetadata = { + name: skillName, + description: skill.description || '', + source: source, + sourceType: provider.type, + subpath: skillName, + installedAt: new Date().toISOString(), + enabled: true, + }; + saveSkillMetadata(targetPath, metadata); + + if (result.tempRoot) { + rmSync(result.tempRoot, { recursive: true, force: true }); + } + + setMessage(`✓ Installed ${skillName} to ${adapter.name}`); + if (!agentType) { + setView('skills'); + } + } catch (err) { + setMessage(`Error: ${err instanceof Error ? err.message : 'Unknown error'}`); + } finally { + setInstalling(null); + if (agentType) { + setSelectedSkill(null); + } + } + }; + + useInput((input, key) => { + if (loading || installing) return; + + if (key.upArrow) setSel(i => Math.max(0, i - 1)); + else if (key.downArrow) setSel(i => Math.min(items.length - 1, i + 1)); + else if (key.return) { + if (view === 'repos' && repos[sel]) { + fetchRepo(repos[sel].source); + setView('skills'); + setSel(0); + setMessage(null); + } else if (view === 'skills' && skills[sel]?.source) { + installSkill(skills[sel].name, skills[sel].source); + } else if (view === 'agents' && agents[sel]) { + installSkill(selectedSkill!.name, selectedSkill!.source, agents[sel].type); + } + } + else if (input === 'm' && view === 'skills' && skills[sel]?.source) { + showAgentSelection(skills[sel].name, skills[sel].source!); + } + else if (input === 'r') { + if (view === 'skills') { + setView('repos'); + setSel(0); + setMessage(null); + } else if (view === 'agents') { + setView('skills'); + setSel(0); + } + } + else if (input === 'a' && view === 'repos') { + fetchAllRepos(); + setView('skills'); + setSel(0); + } + }); + + if (view === 'agents') { + return ( + + {colors.primary('SELECT AGENT')} + Install "{selectedSkill?.name}" to which agent? + (All agents supported - directory created if needed) + + + {visible.map((agent, i) => { + const idx = start + i; + const isSel = idx === sel; + const a = agent as typeof agents[0]; + const status = a.detected ? '(ready)' : '(will create)'; + return ( + + {isSel ? symbols.pointer : ' '} {a.name.padEnd(20)} {colors.secondaryDim(status)} + + ); + })} + + + + Enter=install to selected agent r=back q=quit + + + ); + } + + return ( + + {colors.primary(view === 'repos' ? 'REPOSITORIES' : 'SKILLS')} + {loading && Loading {currentRepo}...} + {installing && Installing {installing}...} + {message && {message}} + {items.length} items + + + {start > 0 && ↑ {start} more} + {visible.map((item, i) => { + const idx = start + i; + const isSel = idx === sel; + const name = view === 'repos' + ? (item as typeof repos[0]).name + : (item as typeof skills[0]).name; + const src = view === 'repos' + ? (item as typeof repos[0]).source + : (item as typeof skills[0]).source || ''; + return ( + + {isSel ? symbols.pointer : ' '}{name.padEnd(25)} {colors.secondaryDim(src)} + + ); + })} + {start + maxVisible < items.length && ↓ {items.length - start - maxVisible} more} + + + + + {view === 'repos' + ? 'Enter=fetch a=all q=quit' + : 'Enter=quick install m=choose agent r=back q=quit'} + + + + ); +} diff --git a/src/tui/screens/Home.tsx b/src/tui/screens/Home.tsx new file mode 100644 index 00000000..43991745 --- /dev/null +++ b/src/tui/screens/Home.tsx @@ -0,0 +1,82 @@ +import React, { useState, useEffect } from 'react'; +import { Box, Text } from 'ink'; +import { colors, logo } from '../theme.js'; +import type { Screen } from '../App.js'; + +interface HomeProps { + onNavigate: (screen: Screen) => void; + cols?: number; + rows?: number; +} + +const CHARS = '01█▓▒░╔╗╚╝║═'; + +const logoSmall = ` +╔═╗╦╔═╦╦ ╦ ╦╔═╦╔╦╗ +╚═╗╠╩╗║║ ║ ╠╩╗║ ║ +╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩ +`.trim(); + +function scramble(target: string, progress: number): string { + return target.split('\n').map(line => { + return line.split('').map((char, i) => { + if (char === ' ') return char; + if (progress > (i / line.length) * 100) return char; + return CHARS[Math.floor(Math.random() * CHARS.length)]; + }).join(''); + }).join('\n'); +} + +export function Home({ cols = 80, rows = 24 }: HomeProps) { + const [progress, setProgress] = useState(0); + const [display, setDisplay] = useState(''); + + const useLogo = cols < 80 ? logoSmall : logo; + + useEffect(() => { + if (progress >= 100) { + setDisplay(useLogo); + return; + } + const t = setInterval(() => { + setProgress(p => { + const next = p + 12; + setDisplay(scramble(useLogo, next)); + return next; + }); + }, 35); + return () => clearInterval(t); + }, [progress, useLogo]); + + return ( + + {colors.primary(display || useLogo)} + + + Manage AI agent skills from your terminal. + + + + Quick Actions: + [b] Browse skills marketplace + [l] View installed skills + [s] Sync skills across agents + [,] Settings + + + {rows >= 18 && ( + + Navigation: + ↑↓ Navigate lists + Enter Select / Confirm + Esc Go back / Home + q Quit + + )} + + + v1.1.0 - Works with 17 AI agents + + + ); +} diff --git a/src/tui/screens/Installed.tsx b/src/tui/screens/Installed.tsx new file mode 100644 index 00000000..ba3f454b --- /dev/null +++ b/src/tui/screens/Installed.tsx @@ -0,0 +1,59 @@ +import React, { useState } from 'react'; +import { Box, Text, useInput } from 'ink'; +import { colors, symbols } from '../theme.js'; +import { useSkills } from '../hooks/useSkills.js'; + +interface Props { + cols?: number; + rows?: number; +} + +export function Installed({ rows = 24 }: Props) { + const { skills, loading, refresh, remove } = useSkills(); + const [sel, setSel] = useState(0); + + const maxVisible = Math.max(5, rows - 6); + const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), skills.length - maxVisible)); + const visible = skills.slice(start, start + maxVisible); + + useInput((input, key) => { + if (loading) return; + if (key.upArrow) setSel(i => Math.max(0, i - 1)); + else if (key.downArrow) setSel(i => Math.min(skills.length - 1, i + 1)); + else if (input === 'r') refresh(); + else if (input === 'd' && skills[sel]) remove(skills[sel].name); + }); + + return ( + + {colors.primary('INSTALLED SKILLS')} + {skills.length} skills + + {loading && Loading...} + + {!loading && skills.length === 0 && ( + No skills installed. Press b to browse. + )} + + {!loading && skills.length > 0 && ( + + {start > 0 && ↑ {start} more} + {visible.map((skill, i) => { + const idx = start + i; + const isSel = idx === sel; + return ( + + {isSel ? symbols.pointer : ' '}{skill.name.padEnd(30)} {skill.agent && colors.secondaryDim(skill.agent)} + + ); + })} + {start + maxVisible < skills.length && ↓ {skills.length - start - maxVisible} more} + + )} + + + r=refresh d=delete q=quit + + + ); +} diff --git a/src/tui/screens/Settings.tsx b/src/tui/screens/Settings.tsx new file mode 100644 index 00000000..315ebcaf --- /dev/null +++ b/src/tui/screens/Settings.tsx @@ -0,0 +1,45 @@ +import React, { useState } from 'react'; +import { Box, Text, useInput } from 'ink'; +import { colors, symbols } from '../theme.js'; + +interface Props { + cols?: number; + rows?: number; +} + +const SETTINGS = [ + { id: 'agent', label: 'Default Agent', value: 'auto-detect' }, + { id: 'sync', label: 'Auto Sync', value: 'disabled' }, + { id: 'cache', label: 'Cache Dir', value: '~/.skillkit/cache' }, +]; + +export function Settings({}: Props) { + const [sel, setSel] = useState(0); + + useInput((_, key) => { + if (key.upArrow) setSel(i => Math.max(0, i - 1)); + else if (key.downArrow) setSel(i => Math.min(SETTINGS.length - 1, i + 1)); + }); + + return ( + + {colors.primary('SETTINGS')} + Configure SkillKit + + + {SETTINGS.map((s, i) => { + const isSel = i === sel; + return ( + + {isSel ? symbols.pointer : ' '}{s.label.padEnd(16)} {colors.secondaryDim(s.value)} + + ); + })} + + + + Enter=edit q=quit + + + ); +} diff --git a/src/tui/screens/Sync.tsx b/src/tui/screens/Sync.tsx new file mode 100644 index 00000000..46b921e6 --- /dev/null +++ b/src/tui/screens/Sync.tsx @@ -0,0 +1,78 @@ +import React, { useState, useEffect } from 'react'; +import { Box, Text, useInput } from 'ink'; +import { colors, symbols } from '../theme.js'; +import { getAllAdapters } from '../../agents/index.js'; + +interface AgentStatus { + name: string; + type: string; + detected: boolean; +} + +interface Props { + cols?: number; + rows?: number; +} + +export function Sync({ rows = 24 }: Props) { + const [agents, setAgents] = useState([]); + const [loading, setLoading] = useState(true); + const [sel, setSel] = useState(0); + const [syncing, setSyncing] = useState(false); + + const maxVisible = Math.max(5, rows - 6); + const start = Math.max(0, Math.min(sel - Math.floor(maxVisible / 2), agents.length - maxVisible)); + const visible = agents.slice(start, start + maxVisible); + + useEffect(() => { + (async () => { + const adapters = getAllAdapters(); + const s: AgentStatus[] = []; + for (const a of adapters) { + s.push({ name: a.name, type: a.type, detected: await a.isDetected() }); + } + setAgents(s); + setLoading(false); + })(); + }, []); + + useInput((input, key) => { + if (loading || syncing) return; + if (key.upArrow) setSel(i => Math.max(0, i - 1)); + else if (key.downArrow) setSel(i => Math.min(agents.length - 1, i + 1)); + else if (input === 'a') { setSyncing(true); setTimeout(() => setSyncing(false), 500); } + else if (key.return && agents[sel]?.detected) { setSyncing(true); setTimeout(() => setSyncing(false), 300); } + }); + + const detected = agents.filter(a => a.detected).length; + + return ( + + {colors.primary('SYNC SKILLS')} + {detected}/{agents.length} agents detected + + {loading && Detecting agents...} + {syncing && Syncing...} + + {!loading && !syncing && ( + + {start > 0 && ↑ {start} more} + {visible.map((agent, i) => { + const idx = start + i; + const isSel = idx === sel; + return ( + + {isSel ? symbols.pointer : ' '}{agent.detected ? symbols.checkboxOn : symbols.checkboxOff} {agent.name.padEnd(20)} {agent.detected ? 'Ready' : 'N/A'} + + ); + })} + {start + maxVisible < agents.length && ↓ {agents.length - start - maxVisible} more} + + )} + + + Enter=sync a=all q=quit + + + ); +} diff --git a/src/tui/screens/index.ts b/src/tui/screens/index.ts new file mode 100644 index 00000000..766dfc92 --- /dev/null +++ b/src/tui/screens/index.ts @@ -0,0 +1,5 @@ +export { Home } from './Home.js'; +export { Browse } from './Browse.js'; +export { Installed } from './Installed.js'; +export { Sync } from './Sync.js'; +export { Settings } from './Settings.js'; diff --git a/src/tui/theme.ts b/src/tui/theme.ts new file mode 100644 index 00000000..0c43c95d --- /dev/null +++ b/src/tui/theme.ts @@ -0,0 +1,28 @@ +import chalk from 'chalk'; + +export const colors = { + primary: chalk.white, + secondary: chalk.white, + secondaryDim: chalk.dim.white, + success: chalk.white, + danger: chalk.white, + warning: chalk.white, + background: chalk.bgBlack, +}; + +export const symbols = { + pointer: chalk.white('❯'), + bullet: '●', + checkboxOn: chalk.white('✔'), + checkboxOff: chalk.dim('✖'), + spinner: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], +}; + +export const logo = ` +███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗ +██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝ +███████╗█████╔╝ ██║██║ ██║ █████╔╝ ██║ ██║ +╚════██║██╔═██╗ ██║██║ ██║ ██╔═██╗ ██║ ██║ +███████║██║ ██╗██║███████╗███████╗██║ ██╗██║ ██║ +╚══════╝╚═╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ +`; diff --git a/tsconfig.json b/tsconfig.json index bffce88e..5b141f1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "module": "ESNext", "moduleResolution": "bundler", "lib": ["ES2022"], + "jsx": "react-jsx", "outDir": "./dist", "rootDir": "./src", "strict": true, diff --git a/tsup.config.ts b/tsup.config.ts index 71ba42ad..a4ec5790 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -14,6 +14,10 @@ export default defineConfig({ splitting: false, skipNodeModulesBundle: true, platform: 'node', - // Remove banner - npm handles shebang via package.json bin field - // For local dev, use: node dist/cli.js + esbuildOptions(options) { + options.jsx = 'automatic'; + }, + loader: { + '.tsx': 'tsx', + }, });