mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-20 12:23:29 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9e31fedc8 | ||
|
|
12ed10d170 | ||
|
|
eebaa710f7 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "skillkit",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 13 more",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -206,6 +206,32 @@ export function Hero(): React.ReactElement {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Video Demo */}
|
||||
<div className="mt-8 sm:mt-10 animate-fade-in-delay">
|
||||
<div className="relative mx-auto max-w-3xl">
|
||||
<div className="absolute -inset-1 bg-gradient-to-r from-zinc-800 via-zinc-600 to-zinc-800 rounded-lg opacity-30 blur-xl"></div>
|
||||
<div className="relative border border-zinc-800 bg-black rounded-lg overflow-hidden">
|
||||
<div className="flex items-center gap-1.5 px-3 py-2 border-b border-zinc-800 bg-zinc-900/50">
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-red-500/80"></div>
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-yellow-500/80"></div>
|
||||
<div className="w-2.5 h-2.5 rounded-full bg-green-500/80"></div>
|
||||
<span className="ml-2 text-zinc-500 text-xs font-mono">skillkit demo</span>
|
||||
</div>
|
||||
<video
|
||||
className="w-full"
|
||||
autoPlay
|
||||
loop
|
||||
muted
|
||||
playsInline
|
||||
poster="/og-image.png"
|
||||
>
|
||||
<source src="/skillkit.mp4" type="video/mp4" />
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>{FADE_ANIMATION_STYLES}</style>
|
||||
|
||||
@@ -4,20 +4,24 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>SkillKit - Universal Skills for AI Coding Agents</title>
|
||||
<meta name="description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
<meta name="description" content="Write once, deploy to 32 AI coding agents. Skills for Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and more.">
|
||||
|
||||
<!-- Open Graph -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="https://skillkit.dev/">
|
||||
<meta property="og:url" content="https://agenstskills.com/">
|
||||
<meta property="og:title" content="SkillKit - Universal Skills for AI Coding Agents">
|
||||
<meta property="og:description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
<meta property="og:image" content="/og-image.png">
|
||||
<meta property="og:description" content="Write once, deploy to 32 AI coding agents. Skills for Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and more.">
|
||||
<meta property="og:image" content="https://agenstskills.com/og-image.png">
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta property="og:site_name" content="SkillKit">
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:url" content="https://agenstskills.com/">
|
||||
<meta name="twitter:title" content="SkillKit - Universal Skills for AI Coding Agents">
|
||||
<meta name="twitter:description" content="Portable, reusable skills that work across Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and 12 more AI coding agents.">
|
||||
<meta name="twitter:image" content="/og-image.png">
|
||||
<meta name="twitter:description" content="Write once, deploy to 32 AI coding agents. Skills for Claude Code, Cursor, Codex, Windsurf, GitHub Copilot, and more.">
|
||||
<meta name="twitter:image" content="https://agenstskills.com/og-image.png">
|
||||
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/agents",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Agent adapters for SkillKit - supports 32 AI coding agents",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/cli",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "CLI commands for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/core",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Core functionality for SkillKit - skill discovery, parsing, and translation",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/mcp-memory",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "MCP (Model Context Protocol) server for SkillKit persistent memory",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/memory",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "CozoDB-backed semantic memory with embeddings for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/mesh",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Peer mesh network for multi-machine agent distribution",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/messaging",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Inter-agent messaging system for SkillKit",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/resources",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Bundled resources for SkillKit - agents, commands, profiles, guidelines, and hooks",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@skillkit/tui",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Unified Terminal UI for SkillKit - Built on OpenTUI",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
@@ -21,15 +21,15 @@
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@skillkit/core": "workspace:*",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@opentui/core": "^0.1.75",
|
||||
"@opentui/react": "^0.1.75",
|
||||
"react": "^19.0.0"
|
||||
"@opentui/solid": "^0.1.75",
|
||||
"@skillkit/agents": "workspace:*",
|
||||
"@skillkit/core": "workspace:*",
|
||||
"solid-js": "^1.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@types/react": "^19.0.0",
|
||||
"esbuild-plugin-solid": "^0.6.0",
|
||||
"tsup": "^8.3.5",
|
||||
"typescript": "^5.7.2",
|
||||
"vitest": "^2.1.8"
|
||||
|
||||
+91
-67
@@ -1,9 +1,10 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { exec } from 'node:child_process';
|
||||
import { createSignal, createEffect, onCleanup, Show, Switch, Match } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { execFile } from 'node:child_process';
|
||||
import { type Screen, NAV_KEYS } from './state/types.js';
|
||||
import { Sidebar } from './components/Sidebar.js';
|
||||
import { Splash } from './components/Splash.js';
|
||||
import { Sidebar } from './components/Sidebar.js';
|
||||
import { StatusBar } from './components/StatusBar.js';
|
||||
import {
|
||||
Home, Browse, Installed, Marketplace, Settings, Recommend,
|
||||
Translate, Context, Memory, Team, Plugins, Methodology,
|
||||
@@ -13,23 +14,28 @@ import {
|
||||
const DOCS_URL = 'https://agenstskills.com/docs';
|
||||
|
||||
function openUrl(url: string): void {
|
||||
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
||||
exec(`${cmd} ${url}`);
|
||||
if (process.platform === 'win32') {
|
||||
execFile('cmd', ['/c', 'start', '', url]);
|
||||
} else {
|
||||
const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
||||
execFile(cmd, [url]);
|
||||
}
|
||||
}
|
||||
|
||||
interface AppProps {
|
||||
onExit?: (code?: number) => void;
|
||||
}
|
||||
|
||||
export function App({ onExit }: AppProps = {}) {
|
||||
const [showSplash, setShowSplash] = useState(true);
|
||||
const [screen, setScreen] = useState<Screen>('home');
|
||||
const [dimensions, setDimensions] = useState({
|
||||
export function App(props: AppProps) {
|
||||
const [showSplash, setShowSplash] = createSignal(true);
|
||||
const [currentScreen, setCurrentScreen] = createSignal<Screen>('home');
|
||||
const [showSidebar, setShowSidebar] = createSignal(true);
|
||||
const [dimensions, setDimensions] = createSignal({
|
||||
cols: process.stdout.columns || 80,
|
||||
rows: process.stdout.rows || 24,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const handleResize = () => {
|
||||
setDimensions({
|
||||
cols: process.stdout.columns || 80,
|
||||
@@ -37,28 +43,38 @@ export function App({ onExit }: AppProps = {}) {
|
||||
});
|
||||
};
|
||||
process.stdout.on('resize', handleResize);
|
||||
return () => { process.stdout.off('resize', handleResize); };
|
||||
}, []);
|
||||
onCleanup(() => {
|
||||
process.stdout.off('resize', handleResize);
|
||||
});
|
||||
});
|
||||
|
||||
const { cols, rows } = dimensions;
|
||||
const showSidebar = cols >= 60;
|
||||
const cols = () => dimensions().cols;
|
||||
const rows = () => dimensions().rows;
|
||||
const sidebarVisible = () => showSidebar() && cols() >= 80;
|
||||
const sidebarWidth = () => {
|
||||
if (!sidebarVisible()) return 0;
|
||||
if (cols() >= 100) return 24;
|
||||
return 18;
|
||||
};
|
||||
const statusBarHeight = 2;
|
||||
const contentHeight = () => rows() - statusBarHeight;
|
||||
|
||||
const handleNavigate = useCallback((newScreen: Screen) => {
|
||||
setScreen(newScreen);
|
||||
}, []);
|
||||
const handleNavigate = (newScreen: Screen) => {
|
||||
setCurrentScreen(newScreen);
|
||||
};
|
||||
|
||||
const handleSplashComplete = useCallback(() => {
|
||||
const handleSplashComplete = () => {
|
||||
setShowSplash(false);
|
||||
}, []);
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string; ctrl?: boolean }) => {
|
||||
if (showSplash) {
|
||||
useKeyboard((key: { name?: string; ctrl?: boolean; sequence?: string }) => {
|
||||
if (showSplash()) {
|
||||
setShowSplash(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.name === 'q' || (key.ctrl && key.name === 'c')) {
|
||||
onExit ? onExit(0) : process.exit(0);
|
||||
props.onExit ? props.onExit(0) : process.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,59 +83,67 @@ export function App({ onExit }: AppProps = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
const targetScreen = NAV_KEYS[key.name || ''];
|
||||
if (targetScreen) {
|
||||
setScreen(targetScreen);
|
||||
if (key.sequence === '\\') {
|
||||
setShowSidebar((v) => !v);
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.name === 'escape' && screen !== 'home') {
|
||||
setScreen('home');
|
||||
const targetScreen = NAV_KEYS[key.name || ''];
|
||||
if (targetScreen) {
|
||||
setCurrentScreen(targetScreen);
|
||||
}
|
||||
|
||||
if (key.name === 'escape' && currentScreen() !== 'home') {
|
||||
setCurrentScreen('home');
|
||||
}
|
||||
});
|
||||
|
||||
if (showSplash) {
|
||||
return <Splash onComplete={handleSplashComplete} duration={3000} />;
|
||||
}
|
||||
|
||||
const screenProps = {
|
||||
const screenProps = () => ({
|
||||
onNavigate: handleNavigate,
|
||||
cols: cols - (showSidebar ? 20 : 0),
|
||||
rows,
|
||||
};
|
||||
|
||||
const renderScreen = () => {
|
||||
switch (screen) {
|
||||
case 'home': return <Home {...screenProps} />;
|
||||
case 'browse': return <Browse {...screenProps} />;
|
||||
case 'installed': return <Installed {...screenProps} />;
|
||||
case 'marketplace': return <Marketplace {...screenProps} />;
|
||||
case 'settings': return <Settings {...screenProps} />;
|
||||
case 'recommend': return <Recommend {...screenProps} />;
|
||||
case 'translate': return <Translate {...screenProps} />;
|
||||
case 'context': return <Context {...screenProps} />;
|
||||
case 'memory': return <Memory {...screenProps} />;
|
||||
case 'team': return <Team {...screenProps} />;
|
||||
case 'plugins': return <Plugins {...screenProps} />;
|
||||
case 'methodology': return <Methodology {...screenProps} />;
|
||||
case 'plan': return <Plan {...screenProps} />;
|
||||
case 'workflow': return <Workflow {...screenProps} />;
|
||||
case 'execute': return <Execute {...screenProps} />;
|
||||
case 'history': return <History {...screenProps} />;
|
||||
case 'sync': return <Sync {...screenProps} />;
|
||||
case 'help': return <Help {...screenProps} />;
|
||||
case 'mesh': return <Mesh {...screenProps} />;
|
||||
case 'message': return <Message {...screenProps} />;
|
||||
default: return <Home {...screenProps} />;
|
||||
}
|
||||
};
|
||||
cols: Math.max(1, cols() - sidebarWidth() - 2),
|
||||
rows: Math.max(1, contentHeight() - 1),
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="row" height={rows}>
|
||||
{showSidebar && <Sidebar screen={screen} onNavigate={handleNavigate} />}
|
||||
<box flexDirection="column" flexGrow={1} marginLeft={showSidebar ? 1 : 0} paddingRight={1}>
|
||||
{renderScreen()}
|
||||
<Show when={!showSplash()} fallback={<Splash onComplete={handleSplashComplete} duration={3000} />}>
|
||||
<box flexDirection="column" height={rows()}>
|
||||
<box flexDirection="row" height={contentHeight()}>
|
||||
<Show when={sidebarVisible()}>
|
||||
<Sidebar
|
||||
screen={currentScreen()}
|
||||
onNavigate={handleNavigate}
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<box flexDirection="column" flexGrow={1} paddingX={1}>
|
||||
<Switch fallback={<Home {...screenProps()} />}>
|
||||
<Match when={currentScreen() === 'home'}><Home {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'browse'}><Browse {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'installed'}><Installed {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'marketplace'}><Marketplace {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'settings'}><Settings {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'recommend'}><Recommend {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'translate'}><Translate {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'context'}><Context {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'memory'}><Memory {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'team'}><Team {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'plugins'}><Plugins {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'methodology'}><Methodology {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'plan'}><Plan {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'workflow'}><Workflow {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'execute'}><Execute {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'history'}><History {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'sync'}><Sync {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'help'}><Help {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'mesh'}><Mesh {...screenProps()} /></Match>
|
||||
<Match when={currentScreen() === 'message'}><Message {...screenProps()} /></Match>
|
||||
</Switch>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
<StatusBar />
|
||||
</box>
|
||||
</box>
|
||||
</Show>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,32 @@
|
||||
/**
|
||||
* AgentGrid Component
|
||||
* Displays monochromatic agent logos in a grid layout
|
||||
*/
|
||||
import { Show, For, createMemo } from 'solid-js';
|
||||
import { AGENT_LOGOS, type AgentLogo } from '../theme/symbols.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface AgentGridProps {
|
||||
/** Maximum number of agents to display */
|
||||
maxVisible?: number;
|
||||
/** Show status indicators for detected agents */
|
||||
showStatus?: boolean;
|
||||
/** Agent types that are detected/active */
|
||||
detectedAgents?: string[];
|
||||
/** Number of columns in the grid */
|
||||
columns?: number;
|
||||
}
|
||||
|
||||
export function AgentGrid({
|
||||
maxVisible = 12,
|
||||
showStatus = true,
|
||||
detectedAgents = [],
|
||||
columns = 4,
|
||||
}: AgentGridProps) {
|
||||
const safeColumns = Math.max(1, columns);
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const visibleAgents = allAgents.slice(0, maxVisible);
|
||||
const hiddenCount = allAgents.length - maxVisible;
|
||||
export function AgentGrid(props: AgentGridProps) {
|
||||
const maxVisible = () => props.maxVisible ?? 12;
|
||||
const showStatus = () => props.showStatus ?? true;
|
||||
const detectedAgents = () => props.detectedAgents ?? [];
|
||||
const columns = () => Math.max(1, props.columns ?? 4);
|
||||
|
||||
const rows: [string, AgentLogo][][] = [];
|
||||
for (let i = 0; i < visibleAgents.length; i += safeColumns) {
|
||||
rows.push(visibleAgents.slice(i, i + safeColumns));
|
||||
}
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const visibleAgents = () => allAgents.slice(0, maxVisible());
|
||||
const hiddenCount = () => allAgents.length - maxVisible();
|
||||
|
||||
const rows = createMemo((): [string, AgentLogo][][] => {
|
||||
const result: [string, AgentLogo][][] = [];
|
||||
const visible = visibleAgents();
|
||||
for (let i = 0; i < visible.length; i += columns()) {
|
||||
result.push(visible.slice(i, i + columns()));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
@@ -38,31 +34,36 @@ export function AgentGrid({
|
||||
<b>Works with</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
{rows.map((row, rowIndex) => (
|
||||
<box key={`row-${rowIndex}`} flexDirection="row">
|
||||
{row.map(([agentType, agent]) => {
|
||||
const isDetected = detectedAgents.includes(agentType);
|
||||
const statusIcon = showStatus ? (isDetected ? '●' : '○') : '';
|
||||
const fg = isDetected ? terminalColors.accent : terminalColors.text;
|
||||
<For each={rows()}>
|
||||
{(row, rowIndex) => (
|
||||
<box flexDirection="row">
|
||||
<For each={row}>
|
||||
{([agentType, agent]) => {
|
||||
const isDetected = () => detectedAgents().includes(agentType);
|
||||
const statusIcon = () => (showStatus() ? (isDetected() ? '●' : '○') : '');
|
||||
const fg = () => (isDetected() ? terminalColors.accent : terminalColors.text);
|
||||
|
||||
return (
|
||||
<box key={agentType} width={18}>
|
||||
<text fg={fg}>
|
||||
{agent.icon} {agent.name}
|
||||
{showStatus && (
|
||||
<span fg={isDetected ? terminalColors.success : terminalColors.textMuted}>
|
||||
{' '}{statusIcon}
|
||||
</span>
|
||||
)}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
{hiddenCount > 0 && (
|
||||
<text fg={terminalColors.textMuted}>+{hiddenCount} more agents</text>
|
||||
)}
|
||||
return (
|
||||
<box width={18}>
|
||||
<text fg={fg()}>
|
||||
{agent.icon} {agent.name}
|
||||
<Show when={showStatus()}>
|
||||
<span fg={isDetected() ? terminalColors.success : terminalColors.textMuted}>
|
||||
{' '}
|
||||
{statusIcon()}
|
||||
</span>
|
||||
</Show>
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
<Show when={hiddenCount() > 0}>
|
||||
<text fg={terminalColors.textMuted}>+{hiddenCount()} more agents</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* AnimatedText Component
|
||||
* Text with fade/slide animations
|
||||
*/
|
||||
|
||||
import { Show, createSignal, createEffect, onCleanup } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { scrambleText } from '../theme/animations.js';
|
||||
|
||||
interface AnimatedTextProps {
|
||||
text: string;
|
||||
animation?: 'fadeIn' | 'typewriter' | 'scramble' | 'countUp' | 'none';
|
||||
duration?: number;
|
||||
delay?: number;
|
||||
color?: string;
|
||||
onComplete?: () => void;
|
||||
}
|
||||
|
||||
export function AnimatedText(props: AnimatedTextProps) {
|
||||
const [progress, setProgress] = createSignal(0);
|
||||
const [isComplete, setIsComplete] = createSignal(false);
|
||||
|
||||
const animation = () => props.animation ?? 'fadeIn';
|
||||
const duration = () => Math.max(1, props.duration ?? 500);
|
||||
const delay = () => Math.max(0, props.delay ?? 0);
|
||||
const color = () => props.color ?? terminalColors.text;
|
||||
|
||||
createEffect(() => {
|
||||
const anim = animation();
|
||||
const dur = duration();
|
||||
const dly = delay();
|
||||
|
||||
setProgress(0);
|
||||
setIsComplete(false);
|
||||
|
||||
if (anim === 'none') {
|
||||
setProgress(100);
|
||||
setIsComplete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
let delayTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let animationTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let startTime: number | undefined;
|
||||
let cancelled = false;
|
||||
|
||||
const animate = () => {
|
||||
if (cancelled) return;
|
||||
|
||||
const now = Date.now();
|
||||
if (!startTime) startTime = now;
|
||||
const elapsed = now - startTime;
|
||||
const p = Math.min((elapsed / dur) * 100, 100);
|
||||
|
||||
setProgress(p);
|
||||
|
||||
if (p < 100) {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
} else {
|
||||
setIsComplete(true);
|
||||
props.onComplete?.();
|
||||
}
|
||||
};
|
||||
|
||||
if (dly > 0) {
|
||||
delayTimeoutId = setTimeout(() => {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
}, dly);
|
||||
} else {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
}
|
||||
|
||||
onCleanup(() => {
|
||||
cancelled = true;
|
||||
if (delayTimeoutId) clearTimeout(delayTimeoutId);
|
||||
if (animationTimeoutId) clearTimeout(animationTimeoutId);
|
||||
});
|
||||
});
|
||||
|
||||
const displayText = () => {
|
||||
switch (animation()) {
|
||||
case 'typewriter': {
|
||||
const charCount = Math.floor((progress() / 100) * props.text.length);
|
||||
return props.text.slice(0, charCount);
|
||||
}
|
||||
case 'scramble': {
|
||||
return scrambleText(props.text, progress());
|
||||
}
|
||||
case 'countUp': {
|
||||
const num = parseFloat(props.text);
|
||||
if (!isNaN(num)) {
|
||||
return String(Math.round((progress() / 100) * num));
|
||||
}
|
||||
return props.text;
|
||||
}
|
||||
case 'fadeIn':
|
||||
case 'none':
|
||||
default:
|
||||
return props.text;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<text fg={color()}>
|
||||
{displayText()}
|
||||
<Show when={animation() === 'typewriter' && !isComplete()}>
|
||||
<text fg={terminalColors.accent}>▌</text>
|
||||
</Show>
|
||||
</text>
|
||||
);
|
||||
}
|
||||
|
||||
interface CountUpTextProps {
|
||||
value: number;
|
||||
duration?: number;
|
||||
delay?: number;
|
||||
prefix?: string;
|
||||
suffix?: string;
|
||||
color?: string;
|
||||
formatter?: (value: number) => string;
|
||||
}
|
||||
|
||||
export function CountUpText(props: CountUpTextProps) {
|
||||
const [displayValue, setDisplayValue] = createSignal(0);
|
||||
const duration = () => Math.max(1, props.duration ?? 1000);
|
||||
const delay = () => Math.max(0, props.delay ?? 0);
|
||||
const color = () => props.color ?? terminalColors.text;
|
||||
const formatter = () => props.formatter ?? ((v: number) => String(Math.round(v)));
|
||||
|
||||
createEffect(() => {
|
||||
const target = props.value;
|
||||
const dur = duration();
|
||||
const dly = delay();
|
||||
|
||||
setDisplayValue(0);
|
||||
|
||||
let delayTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let animationTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
let startTime: number | undefined;
|
||||
let cancelled = false;
|
||||
|
||||
const animate = () => {
|
||||
if (cancelled) return;
|
||||
|
||||
const now = Date.now();
|
||||
if (!startTime) startTime = now;
|
||||
const elapsed = now - startTime;
|
||||
const progress = Math.min(elapsed / dur, 1);
|
||||
const eased = 1 - Math.pow(1 - progress, 4);
|
||||
|
||||
setDisplayValue(eased * target);
|
||||
|
||||
if (progress < 1) {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
}
|
||||
};
|
||||
|
||||
if (dly > 0) {
|
||||
delayTimeoutId = setTimeout(() => {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
}, dly);
|
||||
} else {
|
||||
animationTimeoutId = setTimeout(animate, 16);
|
||||
}
|
||||
|
||||
onCleanup(() => {
|
||||
cancelled = true;
|
||||
if (delayTimeoutId) clearTimeout(delayTimeoutId);
|
||||
if (animationTimeoutId) clearTimeout(animationTimeoutId);
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<text fg={color()}>
|
||||
{props.prefix ?? ''}
|
||||
{formatter()(displayValue())}
|
||||
{props.suffix ?? ''}
|
||||
</text>
|
||||
);
|
||||
}
|
||||
|
||||
interface BlinkingTextProps {
|
||||
text: string;
|
||||
interval?: number;
|
||||
color?: string;
|
||||
blinkColor?: string;
|
||||
}
|
||||
|
||||
export function BlinkingText(props: BlinkingTextProps) {
|
||||
const [visible, setVisible] = createSignal(true);
|
||||
const interval = () => props.interval ?? 500;
|
||||
const color = () => props.color ?? terminalColors.text;
|
||||
const blinkColor = () => props.blinkColor ?? terminalColors.textMuted;
|
||||
|
||||
createEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setVisible((v) => !v);
|
||||
}, interval());
|
||||
|
||||
onCleanup(() => clearInterval(timer));
|
||||
});
|
||||
|
||||
return <text fg={visible() ? color() : blinkColor()}>{props.text}</text>;
|
||||
}
|
||||
|
||||
interface PulsingTextProps {
|
||||
text: string;
|
||||
color?: string;
|
||||
pulseColor?: string;
|
||||
interval?: number;
|
||||
}
|
||||
|
||||
export function PulsingText(props: PulsingTextProps) {
|
||||
const [phase, setPhase] = createSignal(0);
|
||||
const interval = () => props.interval ?? 100;
|
||||
const color = () => props.color ?? terminalColors.accent;
|
||||
const pulseColor = () => props.pulseColor ?? terminalColors.text;
|
||||
|
||||
createEffect(() => {
|
||||
const timer = setInterval(() => {
|
||||
setPhase((p) => (p + 1) % 20);
|
||||
}, interval());
|
||||
|
||||
onCleanup(() => clearInterval(timer));
|
||||
});
|
||||
|
||||
const currentColor = () => {
|
||||
const p = phase();
|
||||
if (p < 10) return color();
|
||||
return pulseColor();
|
||||
};
|
||||
|
||||
return <text fg={currentColor()}>{props.text}</text>;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { type Screen } from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
interface BottomStatusBarProps {
|
||||
currentScreen: Screen;
|
||||
}
|
||||
|
||||
const SCREEN_LABELS: Record<Screen, string> = {
|
||||
home: 'Home',
|
||||
browse: 'Browse',
|
||||
marketplace: 'Marketplace',
|
||||
installed: 'Installed',
|
||||
settings: 'Settings',
|
||||
recommend: 'Recommend',
|
||||
translate: 'Translate',
|
||||
context: 'Context',
|
||||
memory: 'Memory',
|
||||
team: 'Team',
|
||||
plugins: 'Plugins',
|
||||
methodology: 'Methodology',
|
||||
plan: 'Plan',
|
||||
workflow: 'Workflow',
|
||||
execute: 'Execute',
|
||||
history: 'History',
|
||||
sync: 'Sync',
|
||||
help: 'Help',
|
||||
mesh: 'Mesh',
|
||||
message: 'Message',
|
||||
};
|
||||
|
||||
export function BottomStatusBar(props: BottomStatusBarProps) {
|
||||
const version = getVersion();
|
||||
|
||||
return (
|
||||
<box
|
||||
flexDirection="row"
|
||||
height={1}
|
||||
borderTop
|
||||
borderColor={terminalColors.border}
|
||||
paddingX={1}
|
||||
>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>{symbols.brandIcon} skillkit</b> v{version}
|
||||
</text>
|
||||
<text fg={terminalColors.border}> {symbols.verticalLine} </text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{SCREEN_LABELS[props.currentScreen]}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.border}> {symbols.verticalLine} </text>
|
||||
<text fg={terminalColors.textMuted}>/ cmd h home m market q quit</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* Breadcrumb Component
|
||||
* Clickable breadcrumb navigation
|
||||
*/
|
||||
|
||||
import { For, Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export interface BreadcrumbItem {
|
||||
id: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
interface BreadcrumbProps {
|
||||
items: BreadcrumbItem[];
|
||||
separator?: string;
|
||||
hoveredId?: string | null;
|
||||
onNavigate?: (id: string) => void;
|
||||
}
|
||||
|
||||
export function Breadcrumb(props: BreadcrumbProps) {
|
||||
const separator = () => props.separator ?? ' / ';
|
||||
|
||||
const handleClick = (id: string) => {
|
||||
props.onNavigate?.(id);
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<For each={props.items}>
|
||||
{(item, index) => {
|
||||
const isLast = () => index() === props.items.length - 1;
|
||||
const isHovered = () => item.id === props.hoveredId;
|
||||
|
||||
const fg = () => {
|
||||
if (isLast()) return terminalColors.text;
|
||||
if (isHovered()) return terminalColors.accent;
|
||||
return terminalColors.textMuted;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<box
|
||||
flexDirection="row"
|
||||
onClick={() => handleClick(item.id)}
|
||||
>
|
||||
<Show when={item.icon}>
|
||||
<text fg={fg()}>{item.icon} </text>
|
||||
</Show>
|
||||
<text fg={fg()}>
|
||||
{isLast() ? <b>{item.label}</b> : item.label}
|
||||
</text>
|
||||
</box>
|
||||
<Show when={!isLast()}>
|
||||
<text fg={terminalColors.textMuted}>{separator()}</text>
|
||||
</Show>
|
||||
</>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface PathBreadcrumbProps {
|
||||
path: string;
|
||||
separator?: string;
|
||||
maxSegments?: number;
|
||||
hoveredSegment?: number | null;
|
||||
onNavigate?: (path: string, segmentIndex: number) => void;
|
||||
}
|
||||
|
||||
export function PathBreadcrumb(props: PathBreadcrumbProps) {
|
||||
const separator = () => props.separator ?? '/';
|
||||
const maxSegments = () => props.maxSegments ?? 5;
|
||||
|
||||
const segments = () => {
|
||||
const parts = props.path.split('/').filter(Boolean);
|
||||
if (parts.length <= maxSegments()) {
|
||||
return parts;
|
||||
}
|
||||
return ['...', ...parts.slice(-(maxSegments() - 1))];
|
||||
};
|
||||
|
||||
const getPathAtIndex = (index: number): string => {
|
||||
const parts = props.path.split('/').filter(Boolean);
|
||||
const segs = segments();
|
||||
let actualIndex: number;
|
||||
|
||||
if (segs[0] === '...') {
|
||||
const offset = parts.length - (segs.length - 1);
|
||||
actualIndex = offset + index - 1;
|
||||
} else {
|
||||
actualIndex = index;
|
||||
}
|
||||
|
||||
return '/' + parts.slice(0, actualIndex + 1).join('/');
|
||||
};
|
||||
|
||||
const handleClick = (segment: string, index: number) => {
|
||||
if (segment === '...') return;
|
||||
props.onNavigate?.(getPathAtIndex(index), index);
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>{separator()}</text>
|
||||
<For each={segments()}>
|
||||
{(segment, index) => {
|
||||
const isLast = () => index() === segments().length - 1;
|
||||
const isHovered = () => index() === props.hoveredSegment;
|
||||
const isEllipsis = () => segment === '...';
|
||||
|
||||
const fg = () => {
|
||||
if (isEllipsis()) return terminalColors.textMuted;
|
||||
if (isLast()) return terminalColors.text;
|
||||
if (isHovered()) return terminalColors.accent;
|
||||
return terminalColors.textMuted;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<text
|
||||
fg={fg()}
|
||||
onClick={() => handleClick(segment, index())}
|
||||
>
|
||||
{isLast() ? <b>{segment}</b> : segment}
|
||||
</text>
|
||||
<Show when={!isLast()}>
|
||||
<text fg={terminalColors.textMuted}>{separator()}</text>
|
||||
</Show>
|
||||
</>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface NavigationTrailProps {
|
||||
items: Array<{ screen: string; label: string }>;
|
||||
currentIndex: number;
|
||||
hoveredIndex?: number | null;
|
||||
}
|
||||
|
||||
export function NavigationTrail(props: NavigationTrailProps) {
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<For each={props.items}>
|
||||
{(item, index) => {
|
||||
const isCurrent = () => index() === props.currentIndex;
|
||||
const isPast = () => index() < props.currentIndex;
|
||||
const isHovered = () => index() === props.hoveredIndex;
|
||||
|
||||
const fg = () => {
|
||||
if (isCurrent()) return terminalColors.accent;
|
||||
if (isHovered()) return terminalColors.text;
|
||||
if (isPast()) return terminalColors.textSecondary;
|
||||
return terminalColors.textMuted;
|
||||
};
|
||||
|
||||
const indicator = () => {
|
||||
if (isCurrent()) return '●';
|
||||
if (isPast()) return '○';
|
||||
return '○';
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row" marginRight={2}>
|
||||
<text fg={fg()}>{indicator()} </text>
|
||||
<text fg={fg()}>{item.label}</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
/**
|
||||
* Button Component
|
||||
* Clickable button with hover/active states
|
||||
*/
|
||||
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
||||
export type ButtonSize = 'sm' | 'md' | 'lg';
|
||||
|
||||
interface ButtonProps {
|
||||
label: string;
|
||||
shortcut?: string;
|
||||
icon?: string;
|
||||
variant?: ButtonVariant;
|
||||
size?: ButtonSize;
|
||||
disabled?: boolean;
|
||||
focused?: boolean;
|
||||
pressed?: boolean;
|
||||
hovered?: boolean;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const VARIANT_COLORS: Record<
|
||||
ButtonVariant,
|
||||
{ fg: string; bg: string; border: string; hoverFg: string }
|
||||
> = {
|
||||
primary: {
|
||||
fg: terminalColors.text,
|
||||
bg: terminalColors.accent,
|
||||
border: terminalColors.accent,
|
||||
hoverFg: terminalColors.accent,
|
||||
},
|
||||
secondary: {
|
||||
fg: terminalColors.text,
|
||||
bg: terminalColors.surface,
|
||||
border: terminalColors.border,
|
||||
hoverFg: terminalColors.text,
|
||||
},
|
||||
ghost: {
|
||||
fg: terminalColors.textSecondary,
|
||||
bg: 'transparent',
|
||||
border: 'transparent',
|
||||
hoverFg: terminalColors.text,
|
||||
},
|
||||
danger: {
|
||||
fg: terminalColors.text,
|
||||
bg: terminalColors.error,
|
||||
border: terminalColors.error,
|
||||
hoverFg: terminalColors.error,
|
||||
},
|
||||
};
|
||||
|
||||
export function Button(props: ButtonProps) {
|
||||
const variant = () => props.variant ?? 'secondary';
|
||||
const size = () => props.size ?? 'md';
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const focused = () => props.focused ?? false;
|
||||
const pressed = () => props.pressed ?? false;
|
||||
const hovered = () => props.hovered ?? false;
|
||||
|
||||
const colors = () => VARIANT_COLORS[variant()];
|
||||
|
||||
const fg = () => {
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
if (pressed()) return colors().hoverFg;
|
||||
if (hovered() || focused()) return colors().hoverFg;
|
||||
return colors().fg;
|
||||
};
|
||||
|
||||
const borderColor = () => {
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
if (focused()) return terminalColors.accent;
|
||||
return colors().border;
|
||||
};
|
||||
|
||||
const paddingX = () => {
|
||||
switch (size()) {
|
||||
case 'sm':
|
||||
return 1;
|
||||
case 'lg':
|
||||
return 3;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
const brackets = () => {
|
||||
if (variant() === 'ghost') return { left: '', right: '' };
|
||||
if (pressed()) return { left: '▸', right: '◂' };
|
||||
return { left: '[', right: ']' };
|
||||
};
|
||||
|
||||
const padding = ' '.repeat(paddingX());
|
||||
|
||||
const handleClick = () => {
|
||||
if (!disabled() && props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row" onClick={handleClick}>
|
||||
<text fg={borderColor()}>{brackets().left}</text>
|
||||
<text fg={fg()}>{padding}</text>
|
||||
<Show when={props.icon}>
|
||||
<text fg={fg()}>{props.icon} </text>
|
||||
</Show>
|
||||
<text fg={fg()}>{props.label}</text>
|
||||
<Show when={props.shortcut}>
|
||||
<text fg={terminalColors.textMuted}> ({props.shortcut})</text>
|
||||
</Show>
|
||||
<text fg={fg()}>{padding}</text>
|
||||
<text fg={borderColor()}>{brackets().right}</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface ButtonGroupProps {
|
||||
buttons: Array<{
|
||||
id: string;
|
||||
label: string;
|
||||
shortcut?: string;
|
||||
icon?: string;
|
||||
variant?: ButtonVariant;
|
||||
disabled?: boolean;
|
||||
onClick?: () => void;
|
||||
}>;
|
||||
selectedId?: string;
|
||||
focusedId?: string;
|
||||
direction?: 'horizontal' | 'vertical';
|
||||
gap?: number;
|
||||
}
|
||||
|
||||
export function ButtonGroup(props: ButtonGroupProps) {
|
||||
const direction = () => props.direction ?? 'horizontal';
|
||||
const gap = () => props.gap ?? 2;
|
||||
|
||||
return (
|
||||
<box flexDirection={direction() === 'horizontal' ? 'row' : 'column'}>
|
||||
{props.buttons.map((btn, index) => (
|
||||
<box
|
||||
marginRight={direction() === 'horizontal' && index < props.buttons.length - 1 ? gap() : 0}
|
||||
marginBottom={direction() === 'vertical' && index < props.buttons.length - 1 ? gap() : 0}
|
||||
>
|
||||
<Button
|
||||
label={btn.label}
|
||||
shortcut={btn.shortcut}
|
||||
icon={btn.icon}
|
||||
variant={btn.variant}
|
||||
disabled={btn.disabled}
|
||||
focused={btn.id === props.focusedId}
|
||||
hovered={btn.id === props.selectedId}
|
||||
onClick={btn.onClick}
|
||||
/>
|
||||
</box>
|
||||
))}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface IconButtonProps {
|
||||
icon: string;
|
||||
label?: string;
|
||||
disabled?: boolean;
|
||||
focused?: boolean;
|
||||
hovered?: boolean;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export function IconButton(props: IconButtonProps) {
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const focused = () => props.focused ?? false;
|
||||
const hovered = () => props.hovered ?? false;
|
||||
|
||||
const fg = () => {
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
if (focused() || hovered()) return terminalColors.accent;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!disabled() && props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row" onClick={handleClick}>
|
||||
<text fg={fg()}>{props.icon}</text>
|
||||
<Show when={props.label}>
|
||||
<text fg={fg()}> {props.label}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
/**
|
||||
* Clickable Component
|
||||
* Wrapper to make any element clickable with hover effects
|
||||
*/
|
||||
|
||||
import { type JSX, Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface ClickableProps {
|
||||
children: JSX.Element;
|
||||
onClick?: () => void;
|
||||
onDoubleClick?: () => void;
|
||||
onRightClick?: () => void;
|
||||
disabled?: boolean;
|
||||
hovered?: boolean;
|
||||
pressed?: boolean;
|
||||
focusable?: boolean;
|
||||
focused?: boolean;
|
||||
cursor?: string;
|
||||
hoverEffect?: 'highlight' | 'underline' | 'pointer' | 'none';
|
||||
}
|
||||
|
||||
export function Clickable(props: ClickableProps) {
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const hovered = () => props.hovered ?? false;
|
||||
const focused = () => props.focused ?? false;
|
||||
const hoverEffect = () => props.hoverEffect ?? 'highlight';
|
||||
|
||||
const showHighlight = () => {
|
||||
if (disabled()) return false;
|
||||
return hovered() || focused();
|
||||
};
|
||||
|
||||
const cursor = () => {
|
||||
if (disabled()) return '';
|
||||
if (hovered()) return props.cursor ?? '▸';
|
||||
return '';
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!disabled() && props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
const handleDoubleClick = () => {
|
||||
if (!disabled() && props.onDoubleClick) {
|
||||
props.onDoubleClick();
|
||||
}
|
||||
};
|
||||
|
||||
const handleRightClick = () => {
|
||||
if (!disabled() && props.onRightClick) {
|
||||
props.onRightClick();
|
||||
}
|
||||
};
|
||||
|
||||
const renderContent = () => {
|
||||
if (hoverEffect() === 'underline' && showHighlight()) {
|
||||
return <text>{props.children}</text>;
|
||||
}
|
||||
return props.children;
|
||||
};
|
||||
|
||||
return (
|
||||
<box
|
||||
flexDirection="row"
|
||||
onClick={handleClick}
|
||||
onDoubleClick={handleDoubleClick}
|
||||
onContextMenu={handleRightClick}
|
||||
>
|
||||
<Show when={hoverEffect() === 'pointer' && showHighlight()}>
|
||||
<text fg={terminalColors.accent}>{cursor()} </text>
|
||||
</Show>
|
||||
<box
|
||||
fg={hoverEffect() === 'highlight' && showHighlight() ? terminalColors.accent : undefined}
|
||||
>
|
||||
{renderContent()}
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface ClickableTextProps {
|
||||
children: string;
|
||||
onClick?: () => void;
|
||||
disabled?: boolean;
|
||||
hovered?: boolean;
|
||||
color?: string;
|
||||
hoverColor?: string;
|
||||
underlineOnHover?: boolean;
|
||||
}
|
||||
|
||||
export function ClickableText(props: ClickableTextProps) {
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const hovered = () => props.hovered ?? false;
|
||||
const underlineOnHover = () => props.underlineOnHover ?? false;
|
||||
|
||||
const color = () => {
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
if (hovered()) return props.hoverColor ?? terminalColors.accent;
|
||||
return props.color ?? terminalColors.text;
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!disabled() && props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<text fg={color()} onClick={handleClick}>
|
||||
{underlineOnHover() && hovered() ? (
|
||||
<u>{props.children}</u>
|
||||
) : (
|
||||
props.children
|
||||
)}
|
||||
</text>
|
||||
);
|
||||
}
|
||||
|
||||
interface ClickableRowProps {
|
||||
children: JSX.Element;
|
||||
selected?: boolean;
|
||||
hovered?: boolean;
|
||||
disabled?: boolean;
|
||||
showIndicator?: boolean;
|
||||
indicatorChar?: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export function ClickableRow(props: ClickableRowProps) {
|
||||
const selected = () => props.selected ?? false;
|
||||
const hovered = () => props.hovered ?? false;
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const showIndicator = () => props.showIndicator ?? true;
|
||||
const indicatorChar = () => props.indicatorChar ?? '▸';
|
||||
|
||||
const indicator = () => {
|
||||
if (!showIndicator()) return ' ';
|
||||
if (selected()) return `${indicatorChar()} `;
|
||||
if (hovered()) return '▹ ';
|
||||
return ' ';
|
||||
};
|
||||
|
||||
const fg = () => {
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
if (selected()) return terminalColors.accent;
|
||||
if (hovered()) return terminalColors.text;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!disabled() && props.onClick) {
|
||||
props.onClick();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row" onClick={handleClick}>
|
||||
<text fg={fg()}>{indicator()}</text>
|
||||
{props.children}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface InteractiveAreaProps {
|
||||
children: JSX.Element;
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
onMouseOver?: () => void;
|
||||
onMouseOut?: () => void;
|
||||
onClick?: () => void;
|
||||
onMouseDown?: () => void;
|
||||
onMouseUp?: () => void;
|
||||
}
|
||||
|
||||
export function InteractiveArea(props: InteractiveAreaProps) {
|
||||
return (
|
||||
<box
|
||||
flexDirection="column"
|
||||
width={props.width}
|
||||
height={props.height}
|
||||
style={{ left: props.x, top: props.y }}
|
||||
onMouseEnter={props.onMouseOver}
|
||||
onMouseLeave={props.onMouseOut}
|
||||
onClick={props.onClick}
|
||||
onMouseDown={props.onMouseDown}
|
||||
onMouseUp={props.onMouseUp}
|
||||
>
|
||||
{props.children}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* CodeBlock Component
|
||||
* Basic syntax highlighting for code display
|
||||
*/
|
||||
|
||||
import { For, Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface CodeBlockProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
showLineNumbers?: boolean;
|
||||
maxLines?: number;
|
||||
highlightLines?: number[];
|
||||
title?: string;
|
||||
}
|
||||
|
||||
const KEYWORDS = new Set([
|
||||
'const',
|
||||
'let',
|
||||
'var',
|
||||
'function',
|
||||
'return',
|
||||
'if',
|
||||
'else',
|
||||
'for',
|
||||
'while',
|
||||
'import',
|
||||
'export',
|
||||
'from',
|
||||
'class',
|
||||
'extends',
|
||||
'async',
|
||||
'await',
|
||||
'try',
|
||||
'catch',
|
||||
'throw',
|
||||
'new',
|
||||
'this',
|
||||
'true',
|
||||
'false',
|
||||
'null',
|
||||
'undefined',
|
||||
'type',
|
||||
'interface',
|
||||
]);
|
||||
|
||||
function tokenizeLine(line: string): Array<{ type: string; value: string }> {
|
||||
const tokens: Array<{ type: string; value: string }> = [];
|
||||
let remaining = line;
|
||||
|
||||
while (remaining.length > 0) {
|
||||
if (remaining.startsWith('//')) {
|
||||
tokens.push({ type: 'comment', value: remaining });
|
||||
break;
|
||||
}
|
||||
|
||||
const stringMatch = remaining.match(/^(['"`])(?:\\.|[^\\])*?\1/);
|
||||
if (stringMatch) {
|
||||
tokens.push({ type: 'string', value: stringMatch[0] });
|
||||
remaining = remaining.slice(stringMatch[0].length);
|
||||
continue;
|
||||
}
|
||||
|
||||
const numberMatch = remaining.match(/^\d+\.?\d*/);
|
||||
if (numberMatch) {
|
||||
tokens.push({ type: 'number', value: numberMatch[0] });
|
||||
remaining = remaining.slice(numberMatch[0].length);
|
||||
continue;
|
||||
}
|
||||
|
||||
const wordMatch = remaining.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*/);
|
||||
if (wordMatch) {
|
||||
const word = wordMatch[0];
|
||||
const type = KEYWORDS.has(word) ? 'keyword' : 'identifier';
|
||||
tokens.push({ type, value: word });
|
||||
remaining = remaining.slice(word.length);
|
||||
continue;
|
||||
}
|
||||
|
||||
const spaceMatch = remaining.match(/^\s+/);
|
||||
if (spaceMatch) {
|
||||
tokens.push({ type: 'space', value: spaceMatch[0] });
|
||||
remaining = remaining.slice(spaceMatch[0].length);
|
||||
continue;
|
||||
}
|
||||
|
||||
tokens.push({ type: 'punctuation', value: remaining[0] });
|
||||
remaining = remaining.slice(1);
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
function getTokenColor(type: string): string {
|
||||
switch (type) {
|
||||
case 'keyword':
|
||||
return terminalColors.accent;
|
||||
case 'string':
|
||||
return terminalColors.warning;
|
||||
case 'number':
|
||||
return terminalColors.info;
|
||||
case 'comment':
|
||||
return terminalColors.textMuted;
|
||||
default:
|
||||
return terminalColors.text;
|
||||
}
|
||||
}
|
||||
|
||||
export function CodeBlock(props: CodeBlockProps) {
|
||||
const showLineNumbers = () => props.showLineNumbers ?? true;
|
||||
const highlightLines = () => new Set(props.highlightLines ?? []);
|
||||
|
||||
const lines = () => {
|
||||
const allLines = props.code.split('\n');
|
||||
if (props.maxLines && allLines.length > props.maxLines) {
|
||||
return allLines.slice(0, props.maxLines);
|
||||
}
|
||||
return allLines;
|
||||
};
|
||||
|
||||
const lineNumberWidth = () => String(lines().length).length + 1;
|
||||
|
||||
const isTruncated = () => {
|
||||
const allLines = props.code.split('\n');
|
||||
return props.maxLines !== undefined && allLines.length > props.maxLines;
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<Show when={props.title}>
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{props.title}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<box
|
||||
flexDirection="column"
|
||||
borderStyle="round"
|
||||
borderColor={terminalColors.border}
|
||||
paddingX={1}
|
||||
>
|
||||
<For each={lines()}>
|
||||
{(line, index) => {
|
||||
const lineNum = index() + 1;
|
||||
const isHighlighted = highlightLines().has(lineNum);
|
||||
const tokens = tokenizeLine(line);
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<Show when={showLineNumbers()}>
|
||||
<text
|
||||
fg={isHighlighted ? terminalColors.accent : terminalColors.textMuted}
|
||||
width={lineNumberWidth()}
|
||||
>
|
||||
{isHighlighted ? '▸' : ' '}
|
||||
{String(lineNum).padStart(lineNumberWidth() - 1, ' ')}{' '}
|
||||
</text>
|
||||
</Show>
|
||||
<For each={tokens}>
|
||||
{(token) => (
|
||||
<text fg={isHighlighted ? terminalColors.accent : getTokenColor(token.type)}>
|
||||
{token.value}
|
||||
</text>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={isTruncated()}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
... {props.code.split('\n').length - (props.maxLines ?? 0)} more lines
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface InlineCodeProps {
|
||||
children: string;
|
||||
}
|
||||
|
||||
export function InlineCode(props: InlineCodeProps) {
|
||||
return (
|
||||
<text fg={terminalColors.accent}>
|
||||
`{props.children}`
|
||||
</text>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* DetailPane Component
|
||||
* Right-side detail panel with animated slide-in
|
||||
*/
|
||||
|
||||
import { Show, For, createSignal, createEffect, onCleanup, type JSX } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export interface DetailField {
|
||||
label: string;
|
||||
value: string | string[];
|
||||
color?: string;
|
||||
}
|
||||
|
||||
interface DetailPaneProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
icon?: string;
|
||||
fields?: DetailField[];
|
||||
content?: string;
|
||||
actions?: Array<{ key: string; label: string }>;
|
||||
width?: number;
|
||||
visible?: boolean;
|
||||
onClose?: () => void;
|
||||
children?: JSX.Element;
|
||||
}
|
||||
|
||||
export function DetailPane(props: DetailPaneProps) {
|
||||
const [slideProgress, setSlideProgress] = createSignal(0);
|
||||
const width = () => props.width ?? 30;
|
||||
const visible = () => props.visible ?? true;
|
||||
|
||||
createEffect(() => {
|
||||
if (visible()) {
|
||||
let frame = 0;
|
||||
let timeoutId: ReturnType<typeof setTimeout>;
|
||||
const animate = () => {
|
||||
frame++;
|
||||
const progress = Math.min(frame / 10, 1);
|
||||
setSlideProgress(progress);
|
||||
if (progress < 1) {
|
||||
timeoutId = setTimeout(animate, 16);
|
||||
}
|
||||
};
|
||||
timeoutId = setTimeout(animate, 16);
|
||||
onCleanup(() => clearTimeout(timeoutId));
|
||||
} else {
|
||||
setSlideProgress(0);
|
||||
}
|
||||
});
|
||||
|
||||
const effectiveWidth = () => Math.round(width() * slideProgress());
|
||||
|
||||
return (
|
||||
<Show when={visible() && slideProgress() > 0}>
|
||||
<box
|
||||
flexDirection="column"
|
||||
width={effectiveWidth()}
|
||||
borderStyle="round"
|
||||
borderColor={terminalColors.border}
|
||||
paddingX={1}
|
||||
paddingY={1}
|
||||
>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<Show when={props.icon}>
|
||||
<text fg={terminalColors.accent}>{props.icon} </text>
|
||||
</Show>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{props.title}</b>
|
||||
</text>
|
||||
<Show when={props.onClose}>
|
||||
<box onClick={() => props.onClose?.()}>
|
||||
<text fg={terminalColors.textMuted}> [x]</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={props.subtitle}>
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>{props.subtitle}</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={props.fields && props.fields.length > 0}>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<For each={props.fields}>
|
||||
{(field) => (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>{field.label}</text>
|
||||
<Show
|
||||
when={Array.isArray(field.value)}
|
||||
fallback={
|
||||
<text fg={field.color || terminalColors.text}>
|
||||
{field.value as string}
|
||||
</text>
|
||||
}
|
||||
>
|
||||
<For each={field.value as string[]}>
|
||||
{(val) => (
|
||||
<text fg={field.color || terminalColors.text}>• {val}</text>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={props.content}>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>{props.content}</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={props.children}>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
{props.children}
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={props.actions && props.actions.length > 0}>
|
||||
<text fg={terminalColors.textMuted}>─────</text>
|
||||
<For each={props.actions}>
|
||||
{(action) => (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<text fg={terminalColors.accent}>{action.key}</text> {action.label}
|
||||
</text>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* EmptyState Component
|
||||
* Consistent "no data" display
|
||||
*/
|
||||
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface EmptyStateProps {
|
||||
icon?: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
action?: {
|
||||
label: string;
|
||||
key?: string;
|
||||
};
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function EmptyState(props: EmptyStateProps) {
|
||||
const compact = () => props.compact ?? false;
|
||||
|
||||
return (
|
||||
<box flexDirection="column" alignItems="center" paddingY={compact() ? 1 : 3}>
|
||||
<Show when={props.icon}>
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{props.icon}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{props.title}
|
||||
</text>
|
||||
</box>
|
||||
|
||||
<Show when={props.description}>
|
||||
<text fg={terminalColors.textMuted}>{props.description}</text>
|
||||
</Show>
|
||||
|
||||
<Show when={props.action}>
|
||||
<box marginTop={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<Show when={props.action!.key}>
|
||||
<text fg={terminalColors.accent}>{props.action!.key}</text>{' '}
|
||||
</Show>
|
||||
{props.action!.label}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface LoadingStateProps {
|
||||
message?: string;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function LoadingState(props: LoadingStateProps) {
|
||||
const compact = () => props.compact ?? false;
|
||||
const message = () => props.message ?? 'Loading...';
|
||||
|
||||
return (
|
||||
<box flexDirection="column" alignItems="center" paddingY={compact() ? 1 : 3}>
|
||||
<text fg={terminalColors.accent}>⟳ {message()}</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface ErrorStateProps {
|
||||
title?: string;
|
||||
message: string;
|
||||
action?: {
|
||||
label: string;
|
||||
key?: string;
|
||||
};
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function ErrorState(props: ErrorStateProps) {
|
||||
const compact = () => props.compact ?? false;
|
||||
const title = () => props.title ?? 'Error';
|
||||
|
||||
return (
|
||||
<box flexDirection="column" alignItems="center" paddingY={compact() ? 1 : 3}>
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.error}>
|
||||
✗ {title()}
|
||||
</text>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>{props.message}</text>
|
||||
|
||||
<Show when={props.action}>
|
||||
<box marginTop={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<Show when={props.action!.key}>
|
||||
<text fg={terminalColors.accent}>{props.action!.key}</text>{' '}
|
||||
</Show>
|
||||
{props.action!.label}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* ErrorBoundary Component
|
||||
* Catch and display errors gracefully
|
||||
*/
|
||||
|
||||
import { ErrorBoundary as SolidErrorBoundary, type JSX, Show } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface ErrorBoundaryProps {
|
||||
children: JSX.Element;
|
||||
fallback?: JSX.Element | ((error: Error, reset: () => void) => JSX.Element);
|
||||
onError?: (error: Error) => void;
|
||||
}
|
||||
|
||||
function DefaultErrorFallback(props: { error: Error; reset: () => void }) {
|
||||
const errorMessage = () => {
|
||||
if (props.error instanceof Error) {
|
||||
return props.error.message;
|
||||
}
|
||||
return String(props.error);
|
||||
};
|
||||
|
||||
const errorStack = () => {
|
||||
if (props.error instanceof Error && props.error.stack) {
|
||||
const lines = props.error.stack.split('\n').slice(1, 4);
|
||||
return lines.join('\n');
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
useKeyboard((key) => {
|
||||
if (key.name === 'r') {
|
||||
props.reset();
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingY={2} paddingX={1}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.error}>✗ Something went wrong</text>
|
||||
</box>
|
||||
|
||||
<box
|
||||
flexDirection="column"
|
||||
borderStyle="round"
|
||||
borderColor={terminalColors.error}
|
||||
paddingX={1}
|
||||
paddingY={1}
|
||||
>
|
||||
<text fg={terminalColors.text}>{errorMessage()}</text>
|
||||
|
||||
<Show when={errorStack()}>
|
||||
<box marginTop={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{errorStack()}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box marginTop={1}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press <text fg={terminalColors.accent}>r</text> to retry or{' '}
|
||||
<text fg={terminalColors.accent}>Esc</text> to go back
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export function ErrorBoundary(props: ErrorBoundaryProps) {
|
||||
let handledErrorRef: Error | null = null;
|
||||
|
||||
const fallbackComponent = (error: Error, reset: () => void) => {
|
||||
if (props.onError && handledErrorRef !== error) {
|
||||
handledErrorRef = error;
|
||||
props.onError(error);
|
||||
}
|
||||
|
||||
const wrappedReset = () => {
|
||||
handledErrorRef = null;
|
||||
reset();
|
||||
};
|
||||
|
||||
if (typeof props.fallback === 'function') {
|
||||
return props.fallback(error, wrappedReset);
|
||||
}
|
||||
|
||||
if (props.fallback) {
|
||||
return props.fallback;
|
||||
}
|
||||
|
||||
return <DefaultErrorFallback error={error} reset={wrappedReset} />;
|
||||
};
|
||||
|
||||
return (
|
||||
<SolidErrorBoundary fallback={fallbackComponent}>
|
||||
{props.children}
|
||||
</SolidErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
interface TryProps {
|
||||
children: JSX.Element;
|
||||
catch?: JSX.Element;
|
||||
}
|
||||
|
||||
export function Try(props: TryProps) {
|
||||
return (
|
||||
<ErrorBoundary
|
||||
fallback={
|
||||
props.catch ?? (
|
||||
<text fg={terminalColors.error}>Error loading component</text>
|
||||
)
|
||||
}
|
||||
>
|
||||
{props.children}
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* FeatureList Component
|
||||
* Colored feature keywords with descriptions
|
||||
*/
|
||||
import { For } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface Feature {
|
||||
@@ -24,19 +21,25 @@ interface FeatureListProps {
|
||||
features?: Feature[];
|
||||
}
|
||||
|
||||
export function FeatureList({ features = FEATURES }: FeatureListProps) {
|
||||
export function FeatureList(props: FeatureListProps) {
|
||||
const features = () => props.features ?? FEATURES;
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}><b>Features</b></text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Features</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
{features.map((feat) => (
|
||||
<box key={feat.key} flexDirection="row">
|
||||
<text fg={terminalColors[feat.color]}>
|
||||
<b>{' '}{feat.label.padEnd(12)}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.description}</text>
|
||||
</box>
|
||||
))}
|
||||
<For each={features()}>
|
||||
{(feat) => (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors[feat.color]}>
|
||||
<b>{' '}{feat.label.padEnd(12)}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.description}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* FormField Component
|
||||
* Input with label and validation
|
||||
*/
|
||||
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface FormFieldProps {
|
||||
label: string;
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
error?: string;
|
||||
hint?: string;
|
||||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
focused?: boolean;
|
||||
type?: 'text' | 'password' | 'search';
|
||||
width?: number;
|
||||
}
|
||||
|
||||
export function FormField(props: FormFieldProps) {
|
||||
const type = () => props.type ?? 'text';
|
||||
const focused = () => props.focused ?? false;
|
||||
const disabled = () => props.disabled ?? false;
|
||||
const width = () => props.width ?? 30;
|
||||
|
||||
const displayValue = () => {
|
||||
if (type() === 'password') {
|
||||
return '•'.repeat(props.value.length);
|
||||
}
|
||||
return props.value;
|
||||
};
|
||||
|
||||
const borderColor = () => {
|
||||
if (props.error) return terminalColors.error;
|
||||
if (focused()) return terminalColors.accent;
|
||||
if (disabled()) return terminalColors.textMuted;
|
||||
return terminalColors.border;
|
||||
};
|
||||
|
||||
const labelColor = () => {
|
||||
if (props.error) return terminalColors.error;
|
||||
if (focused()) return terminalColors.accent;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text fg={labelColor()}>
|
||||
{props.label}
|
||||
<Show when={props.required}>
|
||||
<text fg={terminalColors.error}>*</text>
|
||||
</Show>
|
||||
</text>
|
||||
</box>
|
||||
|
||||
<box
|
||||
flexDirection="row"
|
||||
width={width()}
|
||||
borderStyle="round"
|
||||
borderColor={borderColor()}
|
||||
paddingX={1}
|
||||
>
|
||||
<Show when={type() === 'search'}>
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
</Show>
|
||||
<text fg={disabled() ? terminalColors.textMuted : terminalColors.text}>
|
||||
{displayValue() || (
|
||||
<text fg={terminalColors.textMuted}>{props.placeholder ?? ''}</text>
|
||||
)}
|
||||
</text>
|
||||
<Show when={focused()}>
|
||||
<text fg={terminalColors.accent}>▌</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={props.error}>
|
||||
<text fg={terminalColors.error}>✗ {props.error}</text>
|
||||
</Show>
|
||||
|
||||
<Show when={props.hint && !props.error}>
|
||||
<text fg={terminalColors.textMuted}>{props.hint}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface TextAreaFieldProps {
|
||||
label: string;
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
error?: string;
|
||||
rows?: number;
|
||||
width?: number;
|
||||
focused?: boolean;
|
||||
}
|
||||
|
||||
export function TextAreaField(props: TextAreaFieldProps) {
|
||||
const rows = () => props.rows ?? 3;
|
||||
const width = () => props.width ?? 40;
|
||||
const focused = () => props.focused ?? false;
|
||||
|
||||
const lines = () => props.value.split('\n').slice(0, rows());
|
||||
|
||||
const hasContent = () => props.value !== '' && props.value !== undefined;
|
||||
|
||||
const borderColor = () => {
|
||||
if (props.error) return terminalColors.error;
|
||||
if (focused()) return terminalColors.accent;
|
||||
return terminalColors.border;
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.textSecondary}>{props.label}</text>
|
||||
|
||||
<box
|
||||
flexDirection="column"
|
||||
width={width()}
|
||||
height={rows() + 2}
|
||||
borderStyle="round"
|
||||
borderColor={borderColor()}
|
||||
paddingX={1}
|
||||
>
|
||||
<Show
|
||||
when={hasContent()}
|
||||
fallback={<text fg={terminalColors.textMuted}>{props.placeholder ?? ''}</text>}
|
||||
>
|
||||
{lines().map((line) => (
|
||||
<text fg={terminalColors.text}>{line}</text>
|
||||
))}
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={props.error}>
|
||||
<text fg={terminalColors.error}>✗ {props.error}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface SelectFieldProps {
|
||||
label: string;
|
||||
value: string;
|
||||
options: Array<{ value: string; label: string }>;
|
||||
focused?: boolean;
|
||||
expanded?: boolean;
|
||||
selectedOptionIndex?: number;
|
||||
}
|
||||
|
||||
export function SelectField(props: SelectFieldProps) {
|
||||
const focused = () => props.focused ?? false;
|
||||
const expanded = () => props.expanded ?? false;
|
||||
|
||||
const selectedLabel = () => {
|
||||
const option = props.options.find((o) => o.value === props.value);
|
||||
return option?.label ?? props.value ?? 'Select...';
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.textSecondary}>{props.label}</text>
|
||||
|
||||
<box
|
||||
flexDirection="row"
|
||||
borderStyle="round"
|
||||
borderColor={focused() ? terminalColors.accent : terminalColors.border}
|
||||
paddingX={1}
|
||||
>
|
||||
<text fg={terminalColors.text}>{selectedLabel()}</text>
|
||||
<text fg={terminalColors.textMuted}> {expanded() ? '▲' : '▼'}</text>
|
||||
</box>
|
||||
|
||||
<Show when={expanded()}>
|
||||
<box
|
||||
flexDirection="column"
|
||||
borderStyle="round"
|
||||
borderColor={terminalColors.border}
|
||||
paddingX={1}
|
||||
>
|
||||
{props.options.map((option, index) => {
|
||||
const isSelected = index === props.selectedOptionIndex;
|
||||
return (
|
||||
<text
|
||||
fg={
|
||||
option.value === props.value
|
||||
? terminalColors.accent
|
||||
: isSelected
|
||||
? terminalColors.text
|
||||
: terminalColors.textSecondary
|
||||
}
|
||||
>
|
||||
{isSelected ? '▸ ' : ' '}
|
||||
{option.label}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
/**
|
||||
* Header Component
|
||||
* Screen header with title and optional badge/count
|
||||
*/
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface HeaderProps {
|
||||
title: string;
|
||||
@@ -13,23 +9,26 @@ interface HeaderProps {
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export function Header({ title, subtitle, count, badge, icon }: HeaderProps) {
|
||||
export function Header(props: HeaderProps) {
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row" gap={2}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{icon && `${icon} `}{title}</b>
|
||||
<b>
|
||||
{props.icon && `${props.icon} `}
|
||||
{props.title}
|
||||
</b>
|
||||
</text>
|
||||
{count !== undefined && (
|
||||
<text fg={terminalColors.textMuted}>({count})</text>
|
||||
)}
|
||||
{badge && (
|
||||
<text fg={terminalColors.accent}>[{badge}]</text>
|
||||
)}
|
||||
<Show when={props.count !== undefined}>
|
||||
<text fg={terminalColors.textMuted}>({props.count})</text>
|
||||
</Show>
|
||||
<Show when={props.badge}>
|
||||
<text fg={terminalColors.accent}>[{props.badge}]</text>
|
||||
</Show>
|
||||
</box>
|
||||
{subtitle && (
|
||||
<text fg={terminalColors.textSecondary}>{subtitle}</text>
|
||||
)}
|
||||
<Show when={props.subtitle}>
|
||||
<text fg={terminalColors.textSecondary}>{props.subtitle}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* HoverHighlight Component
|
||||
* Hover highlight effect for list items and buttons
|
||||
* Note: Terminal background colors are limited, so we use text color changes for highlighting
|
||||
*/
|
||||
|
||||
import { type JSX, Show, createSignal, createEffect } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface HoverHighlightProps {
|
||||
children: JSX.Element;
|
||||
isHovered?: boolean;
|
||||
isSelected?: boolean;
|
||||
isDisabled?: boolean;
|
||||
highlightColor?: string;
|
||||
selectedColor?: string;
|
||||
transitionMs?: number;
|
||||
}
|
||||
|
||||
export function HoverHighlight(props: HoverHighlightProps) {
|
||||
return <box>{props.children}</box>;
|
||||
}
|
||||
|
||||
interface HighlightableListItemProps {
|
||||
children: JSX.Element;
|
||||
index: number;
|
||||
selectedIndex?: number;
|
||||
hoveredIndex?: number | null;
|
||||
showPrefix?: boolean;
|
||||
prefixWidth?: number;
|
||||
}
|
||||
|
||||
export function HighlightableListItem(props: HighlightableListItemProps) {
|
||||
const showPrefix = () => props.showPrefix ?? true;
|
||||
const prefixWidth = () => props.prefixWidth ?? 3;
|
||||
|
||||
const isSelected = () => props.index === props.selectedIndex;
|
||||
const isHovered = () => props.index === props.hoveredIndex;
|
||||
|
||||
const prefix = () => {
|
||||
if (!showPrefix()) return '';
|
||||
if (isSelected()) return '▸ ';
|
||||
if (isHovered()) return '▹ ';
|
||||
return ' ';
|
||||
};
|
||||
|
||||
const fg = () => {
|
||||
if (isSelected()) return terminalColors.accent;
|
||||
if (isHovered()) return terminalColors.text;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<Show when={showPrefix()}>
|
||||
<text fg={fg()} width={prefixWidth()}>
|
||||
{prefix()}
|
||||
</text>
|
||||
</Show>
|
||||
{props.children}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface FocusRingProps {
|
||||
children: JSX.Element;
|
||||
isFocused?: boolean;
|
||||
ringColor?: string;
|
||||
}
|
||||
|
||||
export function FocusRing(props: FocusRingProps) {
|
||||
const ringColor = () => props.ringColor ?? terminalColors.accent;
|
||||
|
||||
return (
|
||||
<box
|
||||
borderStyle={props.isFocused ? 'round' : undefined}
|
||||
borderColor={props.isFocused ? ringColor() : undefined}
|
||||
>
|
||||
{props.children}
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface PressEffectProps {
|
||||
children: JSX.Element;
|
||||
isPressed?: boolean;
|
||||
pressColor?: string;
|
||||
}
|
||||
|
||||
export function PressEffect(props: PressEffectProps) {
|
||||
return <box>{props.children}</box>;
|
||||
}
|
||||
@@ -1,41 +1,36 @@
|
||||
/**
|
||||
* ProgressBar Component
|
||||
* Animated progress bar display
|
||||
*/
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
interface ProgressBarProps {
|
||||
progress: number; // 0-100
|
||||
progress: number;
|
||||
width?: number;
|
||||
showPercentage?: boolean;
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function ProgressBar({
|
||||
progress,
|
||||
width = 20,
|
||||
showPercentage = true,
|
||||
color = 'accent',
|
||||
}: ProgressBarProps) {
|
||||
const clampedProgress = Math.max(0, Math.min(100, progress));
|
||||
const filledWidth = Math.round((clampedProgress / 100) * width);
|
||||
const emptyWidth = width - filledWidth;
|
||||
export function ProgressBar(props: ProgressBarProps) {
|
||||
const width = () => Math.max(1, Math.round(props.width ?? 20));
|
||||
const safeProgress = () => (Number.isFinite(props.progress) ? props.progress : 0);
|
||||
const showPercentage = () => props.showPercentage ?? true;
|
||||
const color = () => props.color ?? 'accent';
|
||||
|
||||
const filled = symbols.progressFilled.repeat(filledWidth);
|
||||
const empty = symbols.progressEmpty.repeat(emptyWidth);
|
||||
const clampedProgress = () => Math.max(0, Math.min(100, safeProgress()));
|
||||
const filledWidth = () => Math.round((clampedProgress() / 100) * width());
|
||||
const emptyWidth = () => Math.max(0, width() - filledWidth());
|
||||
|
||||
const filled = () => symbols.progressFilled.repeat(filledWidth());
|
||||
const empty = () => symbols.progressEmpty.repeat(emptyWidth());
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text>
|
||||
<span fg={terminalColors[color]}>{filled}</span>
|
||||
<span fg={terminalColors.textMuted}>{empty}</span>
|
||||
<span fg={terminalColors[color()]}>{filled()}</span>
|
||||
<span fg={terminalColors.textMuted}>{empty()}</span>
|
||||
</text>
|
||||
{showPercentage && (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{Math.round(clampedProgress)}%
|
||||
</text>
|
||||
)}
|
||||
<Show when={showPercentage()}>
|
||||
<text fg={terminalColors.textSecondary}>{Math.round(clampedProgress())}%</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Show, For, createSignal } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols, AGENT_LOGOS } from '../theme/symbols.js';
|
||||
|
||||
interface RightSidebarProps {
|
||||
width: number;
|
||||
rows: number;
|
||||
}
|
||||
|
||||
const TOP_AGENTS = ['claude-code', 'cursor', 'codex'] as const;
|
||||
|
||||
export function RightSidebar(props: RightSidebarProps) {
|
||||
const [sections] = createSignal({
|
||||
context: true,
|
||||
agents: true,
|
||||
tasks: false,
|
||||
});
|
||||
|
||||
return (
|
||||
<box
|
||||
flexDirection="column"
|
||||
width={props.width}
|
||||
borderLeft
|
||||
borderColor={terminalColors.border}
|
||||
paddingLeft={1}
|
||||
>
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
{sections().context ? '▼' : '▸'} Context
|
||||
</text>
|
||||
<Show when={sections().context}>
|
||||
<text fg={terminalColors.textSecondary}> Skills: 127</text>
|
||||
<text fg={terminalColors.textSecondary}> Agents: 32 (3{symbols.active})</text>
|
||||
<text fg={terminalColors.textSecondary}> Workflows: 4</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
{sections().agents ? '▼' : '▸'} Agents (3)
|
||||
</text>
|
||||
<Show when={sections().agents}>
|
||||
<For each={[...TOP_AGENTS]}>
|
||||
{(agent) => {
|
||||
const logo = AGENT_LOGOS[agent];
|
||||
return (
|
||||
<text fg={terminalColors.text}>
|
||||
{' '}{logo.icon} {logo.name} {symbols.active}
|
||||
</text>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<text fg={terminalColors.textMuted}> +29 more</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
{sections().tasks ? '▼' : '▸'} Tasks (2)
|
||||
</text>
|
||||
<Show when={sections().tasks}>
|
||||
<text fg={terminalColors.textSecondary}> {symbols.pending} Syncing...</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box flexGrow={1} />
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* SearchInput Component
|
||||
* Rounded search input with icon
|
||||
*/
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface SearchInputProps {
|
||||
@@ -11,19 +8,19 @@ interface SearchInputProps {
|
||||
onChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export function SearchInput({
|
||||
value,
|
||||
placeholder = 'Search...',
|
||||
focused = false,
|
||||
}: SearchInputProps) {
|
||||
const display = value || placeholder;
|
||||
const textColor = value ? terminalColors.text : terminalColors.textMuted;
|
||||
export function SearchInput(props: SearchInputProps) {
|
||||
const placeholder = () => props.placeholder ?? 'Search...';
|
||||
const focused = () => props.focused ?? false;
|
||||
const display = () => props.value || placeholder();
|
||||
const textColor = () => (props.value ? terminalColors.text : terminalColors.textMuted);
|
||||
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>⌕ </text>
|
||||
<text fg={textColor}>{display}</text>
|
||||
{focused && <text fg={terminalColors.accent}>▏</text>}
|
||||
<text fg={textColor()}>{display()}</text>
|
||||
<Show when={focused()}>
|
||||
<text fg={terminalColors.accent}>▏</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* SelectList Component
|
||||
* Reusable list with j/k + mouse navigation
|
||||
*/
|
||||
|
||||
import { For, Show, createMemo } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export interface SelectListItem {
|
||||
id: string;
|
||||
label: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
meta?: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
interface SelectListProps {
|
||||
items: SelectListItem[];
|
||||
selectedIndex: number;
|
||||
hoveredIndex?: number | null;
|
||||
onSelect?: (item: SelectListItem, index: number) => void;
|
||||
onHover?: (index: number) => void;
|
||||
maxVisible?: number;
|
||||
showIndex?: boolean;
|
||||
emptyText?: string;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function SelectList(props: SelectListProps) {
|
||||
const maxVisible = () => props.maxVisible ?? 10;
|
||||
const showIndex = () => props.showIndex ?? false;
|
||||
const compact = () => props.compact ?? false;
|
||||
|
||||
const scrollOffset = createMemo(() => {
|
||||
const selected = props.selectedIndex;
|
||||
const visible = maxVisible();
|
||||
const total = props.items.length;
|
||||
|
||||
if (total <= visible) return 0;
|
||||
if (selected < visible / 2) return 0;
|
||||
if (selected > total - visible / 2) return total - visible;
|
||||
return Math.floor(selected - visible / 2);
|
||||
});
|
||||
|
||||
const visibleItems = createMemo(() => {
|
||||
const offset = scrollOffset();
|
||||
return props.items.slice(offset, offset + maxVisible()).map((item, i) => ({
|
||||
item,
|
||||
originalIndex: offset + i,
|
||||
}));
|
||||
});
|
||||
|
||||
const hasScrollUp = createMemo(() => scrollOffset() > 0);
|
||||
const hasScrollDown = createMemo(
|
||||
() => scrollOffset() + maxVisible() < props.items.length
|
||||
);
|
||||
|
||||
const handleItemClick = (item: SelectListItem, index: number) => {
|
||||
if (!item.disabled && props.onSelect) {
|
||||
props.onSelect(item, index);
|
||||
}
|
||||
};
|
||||
|
||||
const handleItemHover = (index: number) => {
|
||||
if (props.onHover) {
|
||||
props.onHover(index);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<Show when={props.items.length === 0}>
|
||||
<text fg={terminalColors.textMuted}>{props.emptyText || 'No items'}</text>
|
||||
</Show>
|
||||
|
||||
<Show when={hasScrollUp()}>
|
||||
<text fg={terminalColors.textMuted}> ▲ {scrollOffset()} more</text>
|
||||
</Show>
|
||||
|
||||
<For each={visibleItems()}>
|
||||
{({ item, originalIndex }) => {
|
||||
const isSelected = () => originalIndex === props.selectedIndex;
|
||||
const isHovered = () => originalIndex === props.hoveredIndex;
|
||||
const isDisabled = () => item.disabled ?? false;
|
||||
|
||||
const fg = () => {
|
||||
if (isDisabled()) return terminalColors.textMuted;
|
||||
if (isSelected()) return terminalColors.accent;
|
||||
if (isHovered()) return terminalColors.text;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
const prefix = () => {
|
||||
if (isSelected()) return '▸ ';
|
||||
if (isHovered()) return '▹ ';
|
||||
return ' ';
|
||||
};
|
||||
|
||||
return (
|
||||
<box
|
||||
flexDirection={compact() ? 'row' : 'column'}
|
||||
marginBottom={compact() ? 0 : 1}
|
||||
onClick={() => handleItemClick(item, originalIndex)}
|
||||
onMouseEnter={() => handleItemHover(originalIndex)}
|
||||
>
|
||||
<box flexDirection="row">
|
||||
<text fg={fg()}>{prefix()}</text>
|
||||
<Show when={showIndex()}>
|
||||
<text fg={terminalColors.textMuted} width={4}>
|
||||
{String(originalIndex + 1).padStart(2, ' ')}.{' '}
|
||||
</text>
|
||||
</Show>
|
||||
<Show when={item.icon}>
|
||||
<text fg={fg()}>{item.icon} </text>
|
||||
</Show>
|
||||
<text fg={fg()}>{item.label}</text>
|
||||
<Show when={item.meta}>
|
||||
<text fg={terminalColors.textMuted}> ({item.meta})</text>
|
||||
</Show>
|
||||
</box>
|
||||
<Show when={item.description && !compact()}>
|
||||
<box marginLeft={2}>
|
||||
<text fg={terminalColors.textMuted}>{item.description}</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={hasScrollDown()}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}▼ {props.items.length - scrollOffset() - maxVisible()} more
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { For, Show } from 'solid-js';
|
||||
import { type Screen, SIDEBAR_NAV } from '../state/types.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
@@ -8,7 +9,7 @@ interface SidebarProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
}
|
||||
|
||||
export function Sidebar({ screen }: SidebarProps) {
|
||||
export function Sidebar(props: SidebarProps) {
|
||||
const version = getVersion();
|
||||
|
||||
return (
|
||||
@@ -19,22 +20,36 @@ export function Sidebar({ screen }: SidebarProps) {
|
||||
<text fg={terminalColors.textMuted}>v{version}</text>
|
||||
<text> </text>
|
||||
|
||||
{SIDEBAR_NAV.map(({ section, items }, idx) => (
|
||||
<box key={section} flexDirection="column">
|
||||
{idx > 0 && <text> </text>}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<i>{section}</i>
|
||||
</text>
|
||||
{items.map((item) => {
|
||||
const active = screen === item.screen;
|
||||
return (
|
||||
<text key={item.key} fg={active ? terminalColors.accent : terminalColors.text}>
|
||||
{active ? <b>{symbols.pointer} {item.label}</b> : <>{symbols.pointerInactive} {item.label}</>}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
))}
|
||||
<For each={SIDEBAR_NAV}>
|
||||
{(nav, idx) => (
|
||||
<box flexDirection="column">
|
||||
<Show when={idx() > 0}>
|
||||
<text> </text>
|
||||
</Show>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
<i>{nav.section}</i>
|
||||
</text>
|
||||
<For each={nav.items}>
|
||||
{(item) => {
|
||||
const active = () => props.screen === item.screen;
|
||||
return (
|
||||
<text fg={active() ? terminalColors.accent : terminalColors.text}>
|
||||
{active() ? (
|
||||
<b>
|
||||
{symbols.pointer} {item.label}
|
||||
</b>
|
||||
) : (
|
||||
<>
|
||||
{symbols.pointerInactive} {item.label}
|
||||
</>
|
||||
)}
|
||||
</text>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
|
||||
<box flexGrow={1} />
|
||||
<text fg={terminalColors.textMuted}>{symbols.horizontalLine.repeat(14)}</text>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
/**
|
||||
* SkillList Component
|
||||
* Paginated list of skills with selection
|
||||
*/
|
||||
import { Show, For } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
import { calculatePagination, type PaginationResult } from '../utils/list.js';
|
||||
import { calculatePagination } from '../utils/list.js';
|
||||
import type { SkillItem } from '../state/types.js';
|
||||
|
||||
interface SkillListProps {
|
||||
@@ -14,56 +11,44 @@ interface SkillListProps {
|
||||
onSelect?: (skill: SkillItem) => void;
|
||||
}
|
||||
|
||||
export function SkillList({
|
||||
skills,
|
||||
selectedIndex,
|
||||
maxVisible = 10,
|
||||
onSelect,
|
||||
}: SkillListProps) {
|
||||
if (skills.length === 0) {
|
||||
return (
|
||||
<text fg={terminalColors.textMuted}>No skills found</text>
|
||||
);
|
||||
}
|
||||
export function SkillList(props: SkillListProps) {
|
||||
const maxVisible = () => props.maxVisible ?? 10;
|
||||
|
||||
const pagination = calculatePagination(skills.length, selectedIndex, maxVisible);
|
||||
const visibleSkills = skills.slice(pagination.start, pagination.end);
|
||||
const pagination = () => calculatePagination(props.skills.length, props.selectedIndex, maxVisible());
|
||||
const visibleSkills = () => props.skills.slice(pagination().start, pagination().end);
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
{/* Items above indicator */}
|
||||
{pagination.itemsAbove > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowUp} {pagination.itemsAbove} more above
|
||||
</text>
|
||||
)}
|
||||
|
||||
{/* Skill list */}
|
||||
{visibleSkills.map((skill, idx) => {
|
||||
const actualIndex = pagination.start + idx;
|
||||
const isSelected = actualIndex === selectedIndex;
|
||||
const pointer = isSelected ? symbols.pointer : symbols.pointerInactive;
|
||||
const fg = isSelected ? terminalColors.accent : terminalColors.text;
|
||||
const statusIcon = skill.enabled ? symbols.active : symbols.pending;
|
||||
const descPart = skill.description
|
||||
? ` - ${skill.description.slice(0, 40)}${skill.description.length > 40 ? '...' : ''}`
|
||||
: '';
|
||||
// Use single text element to avoid rendering overlap
|
||||
const line = `${pointer} ${skill.name} ${statusIcon}${descPart}`;
|
||||
|
||||
return (
|
||||
<text key={skill.name} fg={fg}>
|
||||
{isSelected ? <b>{line}</b> : line}
|
||||
<Show when={props.skills.length > 0} fallback={<text fg={terminalColors.textMuted}>No skills found</text>}>
|
||||
<box flexDirection="column">
|
||||
<Show when={pagination().itemsAbove > 0}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowUp} {pagination().itemsAbove} more above
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</Show>
|
||||
|
||||
{/* Items below indicator */}
|
||||
{pagination.itemsBelow > 0 && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowDown} {pagination.itemsBelow} more below
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
<For each={visibleSkills()}>
|
||||
{(skill, idx) => {
|
||||
const actualIndex = () => pagination().start + idx();
|
||||
const isSelected = () => actualIndex() === props.selectedIndex;
|
||||
const pointer = () => (isSelected() ? symbols.pointer : symbols.pointerInactive);
|
||||
const fg = () => (isSelected() ? terminalColors.accent : terminalColors.text);
|
||||
const statusIcon = () => (skill.enabled ? symbols.active : symbols.pending);
|
||||
const descPart = () =>
|
||||
skill.description
|
||||
? ` - ${skill.description.slice(0, 40)}${skill.description.length > 40 ? '...' : ''}`
|
||||
: '';
|
||||
const line = () => `${pointer()} ${skill.name} ${statusIcon()}${descPart()}`;
|
||||
|
||||
return <text fg={fg()}>{isSelected() ? <b>{line()}</b> : line()}</text>;
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={pagination().itemsBelow > 0}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{symbols.arrowDown} {pagination().itemsBelow} more below
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* Spinner Component
|
||||
* Loading indicator with animated frames
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { createSignal, createEffect, onCleanup, Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols } from '../theme/symbols.js';
|
||||
|
||||
@@ -11,20 +7,24 @@ interface SpinnerProps {
|
||||
color?: keyof typeof terminalColors;
|
||||
}
|
||||
|
||||
export function Spinner({ label, color = 'accent' }: SpinnerProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
export function Spinner(props: SpinnerProps) {
|
||||
const [frame, setFrame] = createSignal(0);
|
||||
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setFrame((f) => (f + 1) % symbols.spinner.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
});
|
||||
|
||||
const color = () => props.color ?? 'accent';
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={terminalColors[color]}>{symbols.spinner[frame]}</text>
|
||||
{label && <text fg={terminalColors.text}>{label}</text>}
|
||||
<text fg={terminalColors[color()]}>{symbols.spinner[frame()]}</text>
|
||||
<Show when={props.label}>
|
||||
<text fg={terminalColors.text}>{props.label}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,39 +1,28 @@
|
||||
/**
|
||||
* Splash Component
|
||||
* Cinematic ASCII art intro with elegant animations
|
||||
* Premium terminal experience
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { createSignal, createEffect, onCleanup, createMemo, Show, For } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
|
||||
// Premium ASCII art logo - clean geometric design
|
||||
const LOGO_FRAMES = [
|
||||
// Frame 1 - Dots appear
|
||||
[
|
||||
' ',
|
||||
' · · · · · · · · · · · · · · · ',
|
||||
' ',
|
||||
],
|
||||
// Frame 2 - Lines form
|
||||
[
|
||||
' ',
|
||||
' ━━━ ━ ━ ━ ━ ━ ━ ━ ━━━ ',
|
||||
' ',
|
||||
],
|
||||
// Frame 3 - Structure emerges
|
||||
[
|
||||
' ┌──┐ ┬ ┌─ ┬ ┬ ┬ ┬ ┌─ ┬ ┌─┐ ',
|
||||
' └──┐ │ │ │ │ │ │ │ │ │ ',
|
||||
' └──┘ ┴ └─ ┴ ┴─┘ ┴─┘ ┴ └─ ┴ ┴ ',
|
||||
],
|
||||
// Frame 4 - Bold letters
|
||||
[
|
||||
' ╔═╗ ╦╔═ ╦ ╦ ╦ ╦╔═ ╦╔╦╗ ',
|
||||
' ╚═╗ ╠╩╗ ║ ║ ║ ╠╩╗ ║ ║ ',
|
||||
' ╚═╝ ╩ ╩ ╩ ╩═╝ ╩═╝ ╩ ╩ ╩ ╩ ',
|
||||
],
|
||||
// Frame 5 - Final premium logo
|
||||
[
|
||||
' ███████╗██╗ ██╗██╗██╗ ██╗ ██╗ ██╗██╗████████╗',
|
||||
' ██╔════╝██║ ██╔╝██║██║ ██║ ██║ ██╔╝██║╚══██╔══╝',
|
||||
@@ -44,24 +33,20 @@ const LOGO_FRAMES = [
|
||||
],
|
||||
];
|
||||
|
||||
// Compact logo for smaller terminals
|
||||
const LOGO_SMALL = [
|
||||
' ╔═╗╦╔═╦╦ ╦ ╦╔═╦╔╦╗ ',
|
||||
' ╚═╗╠╩╗║║ ║ ╠╩╗║ ║ ',
|
||||
' ╚═╝╩ ╩╩╩═╝╩═╝╩ ╩╩ ╩ ',
|
||||
];
|
||||
|
||||
// Elegant spinner frames
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
// Progress bar characters
|
||||
const PROGRESS = {
|
||||
empty: '░',
|
||||
filled: '█',
|
||||
head: '▓',
|
||||
};
|
||||
|
||||
// Loading phases with elegant messaging
|
||||
const PHASES = [
|
||||
{ message: 'Initializing', detail: 'skill engine' },
|
||||
{ message: 'Connecting', detail: 'agent network' },
|
||||
@@ -75,48 +60,48 @@ interface SplashProps {
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export function Splash({ onComplete, duration = 3500 }: SplashProps) {
|
||||
const [frame, setFrame] = useState(0);
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [phase, setPhase] = useState(0);
|
||||
const [fadeIn, setFadeIn] = useState(0);
|
||||
const [particles, setParticles] = useState<string[]>([]);
|
||||
export function Splash(props: SplashProps) {
|
||||
const [frame, setFrame] = createSignal(0);
|
||||
const [progress, setProgress] = createSignal(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = createSignal(0);
|
||||
const [phase, setPhase] = createSignal(0);
|
||||
const [fadeIn, setFadeIn] = createSignal(0);
|
||||
const [particles, setParticles] = createSignal<string[]>([]);
|
||||
|
||||
// Cache version to avoid repeated sync file I/O on every render
|
||||
const version = useMemo(() => getVersion(), []);
|
||||
const version = createMemo(() => getVersion());
|
||||
const cols = process.stdout.columns || 80;
|
||||
const rows = process.stdout.rows || 24;
|
||||
const useSmallLogo = cols < 70;
|
||||
const currentLogo = useSmallLogo ? LOGO_SMALL : (LOGO_FRAMES[Math.min(frame, 4)] || LOGO_FRAMES[4]);
|
||||
const maxWidth = Math.max(...currentLogo.map(l => l.length));
|
||||
|
||||
// Generate ambient particles - returns fresh randomized string each call
|
||||
const generateParticles = useCallback(() => {
|
||||
const currentLogo = () => {
|
||||
return useSmallLogo ? LOGO_SMALL : (LOGO_FRAMES[Math.min(frame(), 4)] || LOGO_FRAMES[4]);
|
||||
};
|
||||
|
||||
const maxWidth = () => Math.max(...currentLogo().map((l) => l.length));
|
||||
|
||||
const generateParticles = () => {
|
||||
const chars = ['·', '∙', '•', '○', '◦', '◌', '◍', '◎'];
|
||||
return Array(cols).fill(0).map(() =>
|
||||
Math.random() > 0.97 ? chars[Math.floor(Math.random() * chars.length)] : ' '
|
||||
).join('');
|
||||
}, [cols]);
|
||||
return Array(cols)
|
||||
.fill(0)
|
||||
.map(() => (Math.random() > 0.97 ? chars[Math.floor(Math.random() * chars.length)] : ' '))
|
||||
.join('');
|
||||
};
|
||||
|
||||
// Logo reveal animation
|
||||
useEffect(() => {
|
||||
if (frame >= 4) return;
|
||||
const timer = setTimeout(() => setFrame(f => f + 1), 200);
|
||||
return () => clearTimeout(timer);
|
||||
}, [frame]);
|
||||
createEffect(() => {
|
||||
if (frame() >= 4) return;
|
||||
const timer = setTimeout(() => setFrame((f) => f + 1), 200);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
// Fade in effect
|
||||
useEffect(() => {
|
||||
if (fadeIn >= 10) return;
|
||||
const timer = setTimeout(() => setFadeIn(f => f + 1), 50);
|
||||
return () => clearTimeout(timer);
|
||||
}, [fadeIn]);
|
||||
createEffect(() => {
|
||||
if (fadeIn() >= 10) return;
|
||||
const timer = setTimeout(() => setFadeIn((f) => f + 1), 50);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
// Progress animation
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setProgress(p => {
|
||||
setProgress((p) => {
|
||||
const newProgress = p + (Math.random() * 3 + 1);
|
||||
if (newProgress >= 100) {
|
||||
clearInterval(interval);
|
||||
@@ -125,137 +110,130 @@ export function Splash({ onComplete, duration = 3500 }: SplashProps) {
|
||||
return newProgress;
|
||||
});
|
||||
}, 50);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
});
|
||||
|
||||
// Phase progression
|
||||
useEffect(() => {
|
||||
const phaseProgress = progress / 20;
|
||||
createEffect(() => {
|
||||
const phaseProgress = progress() / 20;
|
||||
setPhase(Math.min(Math.floor(phaseProgress), PHASES.length - 1));
|
||||
}, [progress]);
|
||||
});
|
||||
|
||||
// Spinner animation
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
setSpinnerFrame((f) => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
});
|
||||
|
||||
// Particle animation
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setParticles(prev => {
|
||||
setParticles((prev) => {
|
||||
const newParticles = [...prev];
|
||||
if (newParticles.length > 3) newParticles.shift();
|
||||
newParticles.push(generateParticles());
|
||||
return newParticles;
|
||||
});
|
||||
}, 150);
|
||||
return () => clearInterval(interval);
|
||||
}, [generateParticles]);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
});
|
||||
|
||||
// Auto-complete
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(onComplete, duration);
|
||||
return () => clearTimeout(timer);
|
||||
}, [onComplete, duration]);
|
||||
createEffect(() => {
|
||||
const timer = setTimeout(props.onComplete, props.duration ?? 3500);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
const pad = ' '.repeat(Math.max(0, Math.floor((cols - maxWidth) / 2)));
|
||||
const pad = () => ' '.repeat(Math.max(0, Math.floor((cols - maxWidth()) / 2)));
|
||||
const progressWidth = Math.max(1, Math.min(40, cols - 20));
|
||||
const progressPad = ' '.repeat(Math.max(0, Math.floor((cols - progressWidth) / 2)));
|
||||
|
||||
const filledWidth = Math.min(Math.floor((progress / 100) * progressWidth), progressWidth);
|
||||
const emptyWidth = Math.max(0, progressWidth - filledWidth - 1);
|
||||
const progressBar = PROGRESS.filled.repeat(filledWidth) +
|
||||
(filledWidth < progressWidth ? PROGRESS.head : '') +
|
||||
PROGRESS.empty.repeat(emptyWidth);
|
||||
const filledWidth = () => Math.min(Math.floor((progress() / 100) * progressWidth), progressWidth);
|
||||
const emptyWidth = () => Math.max(0, progressWidth - filledWidth() - 1);
|
||||
const progressBar = () =>
|
||||
PROGRESS.filled.repeat(filledWidth()) +
|
||||
(filledWidth() < progressWidth ? PROGRESS.head : '') +
|
||||
PROGRESS.empty.repeat(emptyWidth());
|
||||
|
||||
const currentPhase = PHASES[phase];
|
||||
const currentPhase = () => PHASES[phase()];
|
||||
|
||||
return (
|
||||
<box flexDirection="column" height={rows}>
|
||||
{/* Top ambient particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[0] || ''}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{particles()[0] || ''}</text>
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Logo */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{currentLogo.map((line, idx) => (
|
||||
<text key={idx} fg={frame >= 4 ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{frame >= 4 ? <b>{pad}{line}</b> : <>{pad}{line}</>}
|
||||
</text>
|
||||
))}
|
||||
<For each={currentLogo()}>
|
||||
{(line, idx) => (
|
||||
<text fg={frame() >= 4 ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{frame() >= 4 ? (
|
||||
<b>
|
||||
{pad()}
|
||||
{line}
|
||||
</b>
|
||||
) : (
|
||||
<>
|
||||
{pad()}
|
||||
{line}
|
||||
</>
|
||||
)}
|
||||
</text>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
|
||||
{/* Tagline with fade-in */}
|
||||
<text> </text>
|
||||
{fadeIn > 3 && (
|
||||
<Show when={fadeIn() > 3}>
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{pad}{' '}universal skills for ai coding agents
|
||||
{pad()}
|
||||
{' '}universal skills for ai coding agents
|
||||
</text>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Version badge */}
|
||||
{fadeIn > 5 && (
|
||||
<>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{pad}{' '}v{version}
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
<Show when={fadeIn() > 5}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{pad()}
|
||||
{' '}v{version()}
|
||||
</text>
|
||||
</Show>
|
||||
|
||||
{/* Spacer */}
|
||||
<text> </text>
|
||||
<text> </text>
|
||||
|
||||
{/* Progress section */}
|
||||
{fadeIn > 7 && (
|
||||
<Show when={fadeIn() > 7}>
|
||||
<box flexDirection="column" alignItems="center">
|
||||
{/* Status line */}
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>
|
||||
{progressPad}{SPINNER[spinnerFrame]}{' '}
|
||||
{progressPad}
|
||||
{SPINNER[spinnerFrame()]}{' '}
|
||||
</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{currentPhase.message}</b>
|
||||
<b>{currentPhase().message}</b>
|
||||
</text>
|
||||
{currentPhase.detail && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{currentPhase.detail}
|
||||
</text>
|
||||
)}
|
||||
<Show when={currentPhase().detail}>
|
||||
<text fg={terminalColors.textMuted}> {currentPhase().detail}</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
{/* Progress bar */}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>{progressPad}[</text>
|
||||
<text fg={terminalColors.accent}>{progressBar}</text>
|
||||
<text fg={terminalColors.accent}>{progressBar()}</text>
|
||||
<text fg={terminalColors.textMuted}>]</text>
|
||||
<text fg={terminalColors.textSecondary}>{' '}{Math.floor(progress)}%</text>
|
||||
<text fg={terminalColors.textSecondary}> {Math.floor(progress())}%</text>
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Spacer */}
|
||||
<box flexGrow={1} />
|
||||
|
||||
{/* Bottom hint */}
|
||||
<box flexDirection="column" alignItems="center">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{progressPad}{' '}press any key to skip
|
||||
{progressPad}
|
||||
{' '}press any key to skip
|
||||
</text>
|
||||
<text> </text>
|
||||
{/* Bottom particles */}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{particles[1] || ''}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{particles()[1] || ''}</text>
|
||||
</box>
|
||||
</box>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* SplitPane Component
|
||||
* Horizontal/vertical split layout
|
||||
*/
|
||||
|
||||
import { Show, type JSX } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
interface SplitPaneProps {
|
||||
direction?: 'horizontal' | 'vertical';
|
||||
primarySize?: number | string;
|
||||
secondarySize?: number | string;
|
||||
showDivider?: boolean;
|
||||
dividerChar?: string;
|
||||
primary: JSX.Element;
|
||||
secondary?: JSX.Element;
|
||||
gap?: number;
|
||||
}
|
||||
|
||||
export function SplitPane(props: SplitPaneProps) {
|
||||
const direction = () => props.direction ?? 'horizontal';
|
||||
const showDivider = () => props.showDivider ?? true;
|
||||
const dividerChar = () => props.dividerChar ?? (direction() === 'horizontal' ? '│' : '─');
|
||||
const gap = () => props.gap ?? 1;
|
||||
|
||||
const flexDir = () => (direction() === 'horizontal' ? 'row' : 'column');
|
||||
|
||||
const primaryWidth = () => {
|
||||
if (direction() === 'vertical') return undefined;
|
||||
if (props.primarySize !== undefined) return props.primarySize;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const primaryHeight = () => {
|
||||
if (direction() === 'horizontal') return undefined;
|
||||
if (props.primarySize !== undefined) return props.primarySize;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const secondaryWidth = () => {
|
||||
if (direction() === 'vertical') return undefined;
|
||||
if (props.secondarySize !== undefined) return props.secondarySize;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
const secondaryHeight = () => {
|
||||
if (direction() === 'horizontal') return undefined;
|
||||
if (props.secondarySize !== undefined) return props.secondarySize;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection={flexDir()}>
|
||||
<box
|
||||
width={primaryWidth()}
|
||||
height={primaryHeight()}
|
||||
flexGrow={primaryWidth() === undefined && primaryHeight() === undefined ? 1 : undefined}
|
||||
>
|
||||
{props.primary}
|
||||
</box>
|
||||
|
||||
<Show when={props.secondary && showDivider()}>
|
||||
<box
|
||||
width={direction() === 'horizontal' ? gap() : undefined}
|
||||
height={direction() === 'vertical' ? gap() : undefined}
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
>
|
||||
<text fg={terminalColors.border}>{dividerChar()}</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={props.secondary}>
|
||||
<box
|
||||
width={secondaryWidth()}
|
||||
height={secondaryHeight()}
|
||||
flexGrow={secondaryWidth() === undefined && secondaryHeight() === undefined ? 1 : undefined}
|
||||
>
|
||||
{props.secondary}
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface ThreePaneLayoutProps {
|
||||
left?: JSX.Element;
|
||||
center: JSX.Element;
|
||||
right?: JSX.Element;
|
||||
leftWidth?: number;
|
||||
rightWidth?: number;
|
||||
showLeftDivider?: boolean;
|
||||
showRightDivider?: boolean;
|
||||
}
|
||||
|
||||
export function ThreePaneLayout(props: ThreePaneLayoutProps) {
|
||||
const leftWidth = () => props.leftWidth ?? 20;
|
||||
const rightWidth = () => props.rightWidth ?? 30;
|
||||
|
||||
return (
|
||||
<box flexDirection="row" flexGrow={1}>
|
||||
<Show when={props.left}>
|
||||
<box width={leftWidth()}>{props.left}</box>
|
||||
<Show when={props.showLeftDivider !== false}>
|
||||
<box width={1}>
|
||||
<text fg={terminalColors.border}>│</text>
|
||||
</box>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<box flexGrow={1}>{props.center}</box>
|
||||
|
||||
<Show when={props.right}>
|
||||
<Show when={props.showRightDivider !== false}>
|
||||
<box width={1}>
|
||||
<text fg={terminalColors.border}>│</text>
|
||||
</box>
|
||||
</Show>
|
||||
<box width={rightWidth()}>{props.right}</box>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* StatsCard Component
|
||||
* OpenSync-style stats display with optional animations
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { createSignal, createEffect, onCleanup, For } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { animations } from '../theme/animations.js';
|
||||
|
||||
@@ -17,27 +13,26 @@ interface StatsCardProps {
|
||||
animated?: boolean;
|
||||
}
|
||||
|
||||
export function StatsCard({ items, animated = true }: StatsCardProps) {
|
||||
const [displayValues, setDisplayValues] = useState<number[]>(() =>
|
||||
animated ? items.map(() => 0) : items.map((item) => item.value)
|
||||
export function StatsCard(props: StatsCardProps) {
|
||||
const animated = () => props.animated ?? true;
|
||||
|
||||
const [displayValues, setDisplayValues] = createSignal<number[]>(
|
||||
animated() ? props.items.map(() => 0) : props.items.map((item) => item.value)
|
||||
);
|
||||
const [animComplete, setAnimComplete] = useState(!animated);
|
||||
const [prevItemsLength, setPrevItemsLength] = useState(items.length);
|
||||
const [animComplete, setAnimComplete] = createSignal(!animated());
|
||||
|
||||
useEffect(() => {
|
||||
if (items.length !== prevItemsLength) {
|
||||
setPrevItemsLength(items.length);
|
||||
setDisplayValues(animated ? items.map(() => 0) : items.map((item) => item.value));
|
||||
setAnimComplete(!animated);
|
||||
}
|
||||
}, [items, prevItemsLength, animated]);
|
||||
createEffect(() => {
|
||||
const newValues = animated() ? props.items.map(() => 0) : props.items.map((item) => item.value);
|
||||
setDisplayValues(newValues);
|
||||
setAnimComplete(!animated());
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!animated || animComplete) return;
|
||||
createEffect(() => {
|
||||
if (!animated() || animComplete()) return;
|
||||
|
||||
const duration = animations.countUp.duration;
|
||||
const startTime = Date.now();
|
||||
const targetValues = items.map((item) => item.value);
|
||||
const targetValues = props.items.map((item) => item.value);
|
||||
const frameInterval = 16;
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
@@ -45,10 +40,7 @@ export function StatsCard({ items, animated = true }: StatsCardProps) {
|
||||
const progress = Math.min(elapsed / duration, 1);
|
||||
const eased = 1 - Math.pow(1 - progress, 4);
|
||||
|
||||
const newValues = targetValues.map((target) =>
|
||||
Math.round(target * eased)
|
||||
);
|
||||
|
||||
const newValues = targetValues.map((target) => Math.round(target * eased));
|
||||
setDisplayValues(newValues);
|
||||
|
||||
if (progress >= 1) {
|
||||
@@ -57,32 +49,31 @@ export function StatsCard({ items, animated = true }: StatsCardProps) {
|
||||
}
|
||||
}, frameInterval);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, [animated, animComplete, items]);
|
||||
onCleanup(() => clearInterval(intervalId));
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="row" gap={2}>
|
||||
{items.map((item, index) => {
|
||||
const fg = item.color
|
||||
? terminalColors[item.color]
|
||||
: terminalColors.text;
|
||||
<For each={props.items}>
|
||||
{(item, index) => {
|
||||
const fg = () => (item.color ? terminalColors[item.color] : terminalColors.text);
|
||||
|
||||
return (
|
||||
<box
|
||||
key={item.label}
|
||||
flexDirection="column"
|
||||
alignItems="center"
|
||||
padding={2}
|
||||
borderStyle="single"
|
||||
borderColor={terminalColors.border}
|
||||
>
|
||||
<text fg={fg}>
|
||||
<b>{String(displayValues[index])}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{item.label}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
return (
|
||||
<box
|
||||
flexDirection="column"
|
||||
alignItems="center"
|
||||
padding={2}
|
||||
borderStyle="single"
|
||||
borderColor={terminalColors.border}
|
||||
>
|
||||
<text fg={fg()}>
|
||||
<b>{String(displayValues()[index()])}</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{item.label}</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* StatusBar Component
|
||||
* Bottom status bar with keyboard shortcuts
|
||||
*/
|
||||
import { Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { STATUS_BAR_SHORTCUTS } from '../state/types.js';
|
||||
|
||||
@@ -11,11 +8,10 @@ interface StatusBarProps {
|
||||
shortcuts?: string;
|
||||
}
|
||||
|
||||
export function StatusBar({
|
||||
message,
|
||||
messageType = 'info',
|
||||
shortcuts = STATUS_BAR_SHORTCUTS,
|
||||
}: StatusBarProps) {
|
||||
export function StatusBar(props: StatusBarProps) {
|
||||
const messageType = () => props.messageType ?? 'info';
|
||||
const shortcuts = () => props.shortcuts ?? STATUS_BAR_SHORTCUTS;
|
||||
|
||||
const messageColors = {
|
||||
info: terminalColors.info,
|
||||
success: terminalColors.success,
|
||||
@@ -25,14 +21,10 @@ export function StatusBar({
|
||||
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\u2500'.repeat(70)}
|
||||
</text>
|
||||
{message ? (
|
||||
<text fg={messageColors[messageType]}>{message}</text>
|
||||
) : (
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
)}
|
||||
<text fg={terminalColors.textMuted}>{'\u2500'.repeat(70)}</text>
|
||||
<Show when={props.message} fallback={<text fg={terminalColors.textMuted}>{shortcuts()}</text>}>
|
||||
<text fg={messageColors[messageType()]}>{props.message}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* StatusIndicator Component
|
||||
* Loading/success/error/warning indicator
|
||||
*/
|
||||
|
||||
import { Show, createSignal, createEffect, onCleanup } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export type StatusType = 'loading' | 'success' | 'error' | 'warning' | 'info' | 'pending';
|
||||
|
||||
interface StatusIndicatorProps {
|
||||
status: StatusType;
|
||||
label?: string;
|
||||
showLabel?: boolean;
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
animated?: boolean;
|
||||
}
|
||||
|
||||
const STATUS_ICONS: Record<StatusType, string> = {
|
||||
loading: '⟳',
|
||||
success: '✓',
|
||||
error: '✗',
|
||||
warning: '⚠',
|
||||
info: 'ℹ',
|
||||
pending: '○',
|
||||
};
|
||||
|
||||
const STATUS_COLORS: Record<StatusType, string> = {
|
||||
loading: terminalColors.accent,
|
||||
success: terminalColors.success,
|
||||
error: terminalColors.error,
|
||||
warning: terminalColors.warning,
|
||||
info: terminalColors.info,
|
||||
pending: terminalColors.textMuted,
|
||||
};
|
||||
|
||||
const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
export function StatusIndicator(props: StatusIndicatorProps) {
|
||||
const [spinnerFrame, setSpinnerFrame] = createSignal(0);
|
||||
const showLabel = () => props.showLabel ?? true;
|
||||
const animated = () => props.animated ?? true;
|
||||
|
||||
createEffect(() => {
|
||||
if (props.status === 'loading' && animated()) {
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame((f) => (f + 1) % SPINNER_FRAMES.length);
|
||||
}, 80);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
}
|
||||
});
|
||||
|
||||
const icon = () => {
|
||||
if (props.status === 'loading' && animated()) {
|
||||
return SPINNER_FRAMES[spinnerFrame()];
|
||||
}
|
||||
return STATUS_ICONS[props.status];
|
||||
};
|
||||
|
||||
const color = () => STATUS_COLORS[props.status];
|
||||
|
||||
const defaultLabel = () => {
|
||||
switch (props.status) {
|
||||
case 'loading':
|
||||
return 'Loading...';
|
||||
case 'success':
|
||||
return 'Success';
|
||||
case 'error':
|
||||
return 'Error';
|
||||
case 'warning':
|
||||
return 'Warning';
|
||||
case 'info':
|
||||
return 'Info';
|
||||
case 'pending':
|
||||
return 'Pending';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<text fg={color()}>{icon()}</text>
|
||||
<Show when={showLabel()}>
|
||||
<text fg={color()}> {props.label ?? defaultLabel()}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface InlineStatusProps {
|
||||
status: StatusType;
|
||||
compact?: boolean;
|
||||
}
|
||||
|
||||
export function InlineStatus(props: InlineStatusProps) {
|
||||
const icon = () => {
|
||||
if (props.status === 'loading' || props.status === 'pending') {
|
||||
return '○';
|
||||
}
|
||||
return '●';
|
||||
};
|
||||
|
||||
return <text fg={STATUS_COLORS[props.status]}>{icon()}</text>;
|
||||
}
|
||||
|
||||
interface StatusBadgeProps {
|
||||
status: StatusType;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function StatusBadge(props: StatusBadgeProps) {
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>[</text>
|
||||
<text fg={STATUS_COLORS[props.status]}>{props.label}</text>
|
||||
<text fg={terminalColors.textMuted}>]</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* TabBar Component
|
||||
* Clickable tab navigation
|
||||
*/
|
||||
|
||||
import { For, Show } from 'solid-js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
export interface Tab {
|
||||
id: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
badge?: string | number;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
interface TabBarProps {
|
||||
tabs: Tab[];
|
||||
activeId: string;
|
||||
hoveredId?: string | null;
|
||||
onSelect?: (id: string) => void;
|
||||
variant?: 'default' | 'pills' | 'underline';
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
showShortcuts?: boolean;
|
||||
}
|
||||
|
||||
export function TabBar(props: TabBarProps) {
|
||||
const variant = () => props.variant ?? 'default';
|
||||
const size = () => props.size ?? 'md';
|
||||
const showShortcuts = () => props.showShortcuts ?? false;
|
||||
|
||||
const gap = () => {
|
||||
switch (size()) {
|
||||
case 'sm':
|
||||
return 1;
|
||||
case 'lg':
|
||||
return 3;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<For each={props.tabs}>
|
||||
{(tab, index) => {
|
||||
const isActive = () => tab.id === props.activeId;
|
||||
const isHovered = () => tab.id === props.hoveredId;
|
||||
const isDisabled = () => tab.disabled ?? false;
|
||||
|
||||
const fg = () => {
|
||||
if (isDisabled()) return terminalColors.textMuted;
|
||||
if (isActive()) return terminalColors.accent;
|
||||
if (isHovered()) return terminalColors.text;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
const decoration = () => {
|
||||
if (variant() === 'underline' && isActive()) {
|
||||
return '─';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const brackets = () => {
|
||||
if (variant() === 'pills') {
|
||||
if (isActive()) return { left: '[', right: ']' };
|
||||
return { left: ' ', right: ' ' };
|
||||
}
|
||||
return { left: '', right: '' };
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isDisabled() && props.onSelect) {
|
||||
props.onSelect(tab.id);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" marginRight={index() < props.tabs.length - 1 ? gap() : 0} onClick={handleClick}>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.border}>{brackets().left}</text>
|
||||
<Show when={tab.icon}>
|
||||
<text fg={fg()}>{tab.icon} </text>
|
||||
</Show>
|
||||
<text fg={fg()}>{tab.label}</text>
|
||||
<Show when={tab.badge !== undefined}>
|
||||
<text fg={terminalColors.textMuted}> ({tab.badge})</text>
|
||||
</Show>
|
||||
<Show when={showShortcuts()}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}
|
||||
{String(index() + 1)}
|
||||
</text>
|
||||
</Show>
|
||||
<text fg={terminalColors.border}>{brackets().right}</text>
|
||||
</box>
|
||||
<Show when={variant() === 'underline'}>
|
||||
<text fg={isActive() ? terminalColors.accent : 'transparent'}>
|
||||
{decoration().repeat(tab.label.length + (tab.icon ? 2 : 0))}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
interface VerticalTabBarProps {
|
||||
tabs: Tab[];
|
||||
activeId: string;
|
||||
hoveredId?: string | null;
|
||||
onSelect?: (id: string) => void;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
export function VerticalTabBar(props: VerticalTabBarProps) {
|
||||
const width = () => props.width ?? 20;
|
||||
|
||||
return (
|
||||
<box flexDirection="column" width={width()}>
|
||||
<For each={props.tabs}>
|
||||
{(tab) => {
|
||||
const isActive = () => tab.id === props.activeId;
|
||||
const isHovered = () => tab.id === props.hoveredId;
|
||||
const isDisabled = () => tab.disabled ?? false;
|
||||
|
||||
const fg = () => {
|
||||
if (isDisabled()) return terminalColors.textMuted;
|
||||
if (isActive()) return terminalColors.accent;
|
||||
if (isHovered()) return terminalColors.text;
|
||||
return terminalColors.textSecondary;
|
||||
};
|
||||
|
||||
const prefix = () => {
|
||||
if (isActive()) return '▸ ';
|
||||
if (isHovered()) return '▹ ';
|
||||
return ' ';
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isDisabled() && props.onSelect) {
|
||||
props.onSelect(tab.id);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<box
|
||||
flexDirection="row"
|
||||
marginBottom={1}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<text fg={fg()}>{prefix()}</text>
|
||||
<Show when={tab.icon}>
|
||||
<text fg={fg()}>{tab.icon} </text>
|
||||
</Show>
|
||||
<text fg={fg()}>{tab.label}</text>
|
||||
<Show when={tab.badge !== undefined}>
|
||||
<text fg={terminalColors.textMuted}> ({tab.badge})</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
@@ -2,10 +2,13 @@
|
||||
* Components module for SkillKit TUI
|
||||
*/
|
||||
|
||||
// Existing components
|
||||
export { AgentGrid } from './AgentGrid.js';
|
||||
export { StatsCard } from './StatsCard.js';
|
||||
export { Header } from './Header.js';
|
||||
export { Sidebar } from './Sidebar.js';
|
||||
export { RightSidebar } from './RightSidebar.js';
|
||||
export { BottomStatusBar } from './BottomStatusBar.js';
|
||||
export { StatusBar } from './StatusBar.js';
|
||||
export { SkillList } from './SkillList.js';
|
||||
export { SearchInput } from './SearchInput.js';
|
||||
@@ -13,3 +16,50 @@ export { Spinner } from './Spinner.js';
|
||||
export { ProgressBar } from './ProgressBar.js';
|
||||
export { FeatureList, FEATURES, type Feature } from './FeatureList.js';
|
||||
export { Splash } from './Splash.js';
|
||||
|
||||
// New components (Phase 1.3)
|
||||
export { SelectList, type SelectListItem } from './SelectList.js';
|
||||
export { DetailPane, type DetailField } from './DetailPane.js';
|
||||
export { SplitPane, ThreePaneLayout } from './SplitPane.js';
|
||||
export { EmptyState, LoadingState, ErrorState } from './EmptyState.js';
|
||||
export {
|
||||
StatusIndicator,
|
||||
InlineStatus,
|
||||
StatusBadge,
|
||||
type StatusType,
|
||||
} from './StatusIndicator.js';
|
||||
export { CodeBlock, InlineCode } from './CodeBlock.js';
|
||||
export { FormField, TextAreaField, SelectField } from './FormField.js';
|
||||
export { ErrorBoundary, Try } from './ErrorBoundary.js';
|
||||
export {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
IconButton,
|
||||
type ButtonVariant,
|
||||
type ButtonSize,
|
||||
} from './Button.js';
|
||||
export {
|
||||
Clickable,
|
||||
ClickableText,
|
||||
ClickableRow,
|
||||
InteractiveArea,
|
||||
} from './Clickable.js';
|
||||
export {
|
||||
HoverHighlight,
|
||||
HighlightableListItem,
|
||||
FocusRing,
|
||||
PressEffect,
|
||||
} from './HoverHighlight.js';
|
||||
export {
|
||||
AnimatedText,
|
||||
CountUpText,
|
||||
BlinkingText,
|
||||
PulsingText,
|
||||
} from './AnimatedText.js';
|
||||
export { TabBar, VerticalTabBar, type Tab } from './TabBar.js';
|
||||
export {
|
||||
Breadcrumb,
|
||||
PathBreadcrumb,
|
||||
NavigationTrail,
|
||||
type BreadcrumbItem,
|
||||
} from './Breadcrumb.js';
|
||||
|
||||
+34
-22
@@ -1,40 +1,52 @@
|
||||
import { createCliRenderer } from '@opentui/core';
|
||||
import { createRoot } from '@opentui/react';
|
||||
import { render } from '@opentui/solid';
|
||||
import { App } from './App.js';
|
||||
|
||||
let rootInstance: ReturnType<typeof createRoot> | null = null;
|
||||
let isRunning = true;
|
||||
let renderer: Awaited<ReturnType<typeof createCliRenderer>> | null = null;
|
||||
|
||||
export function exitTUI(code = 0): void {
|
||||
if (!isRunning) return;
|
||||
isRunning = false;
|
||||
|
||||
try {
|
||||
// Unmount React tree first
|
||||
if (rootInstance) {
|
||||
try {
|
||||
rootInstance.unmount();
|
||||
} catch {
|
||||
// Ignore unmount errors
|
||||
}
|
||||
rootInstance = null;
|
||||
if (renderer && 'dispose' in renderer) {
|
||||
(renderer as { dispose?: () => void }).dispose?.();
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// Restore terminal state: exit alt screen, show cursor, reset attributes, clear
|
||||
try {
|
||||
process.stdout.write('\x1b[?1049l\x1b[?25h\x1b[0m\x1b[H\x1b[2J');
|
||||
} catch {
|
||||
// Ignore write errors
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// Use setImmediate to allow any pending operations to complete
|
||||
setImmediate(() => process.exit(code));
|
||||
}
|
||||
|
||||
export async function startTUI(): Promise<never> {
|
||||
// Setup signal handlers for clean exit
|
||||
const handleSignal = () => exitTUI(0);
|
||||
process.on('SIGINT', handleSignal);
|
||||
process.on('SIGTERM', handleSignal);
|
||||
process.on('SIGINT', () => exitTUI(0));
|
||||
process.on('SIGTERM', () => exitTUI(0));
|
||||
process.on('uncaughtException', (err) => {
|
||||
console.error('TUI Error:', err.message);
|
||||
exitTUI(1);
|
||||
});
|
||||
process.on('unhandledRejection', (err) => {
|
||||
console.error('TUI Error:', err);
|
||||
exitTUI(1);
|
||||
});
|
||||
|
||||
renderer = await createCliRenderer({
|
||||
exitOnCtrlC: false,
|
||||
useMouse: true,
|
||||
enableMouseMovement: true,
|
||||
});
|
||||
|
||||
try {
|
||||
await render(() => <App onExit={exitTUI} />, renderer);
|
||||
} catch (err) {
|
||||
console.error('Render failed:', err);
|
||||
exitTUI(1);
|
||||
}
|
||||
|
||||
const renderer = await createCliRenderer({ exitOnCtrlC: false });
|
||||
rootInstance = createRoot(renderer);
|
||||
rootInstance.render(<App onExit={exitTUI} />);
|
||||
return new Promise(() => {});
|
||||
}
|
||||
|
||||
|
||||
Vendored
-55
@@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Type declarations for OpenTUI React JSX elements
|
||||
* Overrides React's JSX namespace to include OpenTUI elements
|
||||
*/
|
||||
import * as React from 'react';
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
box: React.PropsWithChildren<{
|
||||
flexDirection?: 'row' | 'column';
|
||||
flexGrow?: number;
|
||||
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch';
|
||||
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
padding?: number;
|
||||
paddingLeft?: number;
|
||||
paddingRight?: number;
|
||||
paddingTop?: number;
|
||||
paddingBottom?: number;
|
||||
paddingX?: number;
|
||||
paddingY?: number;
|
||||
margin?: number;
|
||||
marginLeft?: number;
|
||||
marginRight?: number;
|
||||
marginTop?: number;
|
||||
marginBottom?: number;
|
||||
marginX?: number;
|
||||
marginY?: number;
|
||||
gap?: number;
|
||||
border?: boolean;
|
||||
borderStyle?: 'single' | 'double' | 'rounded';
|
||||
borderColor?: string;
|
||||
backgroundColor?: string;
|
||||
color?: string;
|
||||
bold?: boolean;
|
||||
dim?: boolean;
|
||||
title?: string;
|
||||
style?: Record<string, unknown>;
|
||||
key?: React.Key;
|
||||
}>;
|
||||
text: React.PropsWithChildren<{
|
||||
color?: string;
|
||||
bold?: boolean;
|
||||
dim?: boolean;
|
||||
attributes?: number;
|
||||
width?: number;
|
||||
key?: React.Key;
|
||||
}>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
+302
-131
@@ -1,7 +1,19 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, DEFAULT_REPOS } from '../state/index.js';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import {
|
||||
type Screen,
|
||||
DEFAULT_REPOS,
|
||||
getMarketplaceRepos,
|
||||
fetchRepoSkills,
|
||||
type FetchedSkill,
|
||||
type RepoInfo,
|
||||
} from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
|
||||
interface BrowseProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -9,55 +21,139 @@ interface BrowseProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Browse({ onNavigate, cols = 80, rows = 24 }: BrowseProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchMode, setSearchMode] = useState(false);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
interface RepoWithSkills extends RepoInfo {
|
||||
skills: FetchedSkill[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
export function Browse(props: BrowseProps) {
|
||||
const [repos, setRepos] = createSignal<RepoWithSkills[]>([]);
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [searchQuery, setSearchQuery] = createSignal('');
|
||||
const [searchMode, setSearchMode] = createSignal(false);
|
||||
const [showSkills, setShowSkills] = createSignal(false);
|
||||
const [loading, setLoading] = createSignal(true);
|
||||
const [error, setError] = createSignal<string | null>(null);
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
const rows = () => props.rows ?? 24;
|
||||
|
||||
const repos = useMemo(() =>
|
||||
DEFAULT_REPOS.map((r) => ({
|
||||
name: r.name,
|
||||
source: r.source,
|
||||
})),
|
||||
[]
|
||||
);
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const filteredRepos = useMemo(() =>
|
||||
searchQuery
|
||||
? repos.filter(
|
||||
(r) =>
|
||||
r.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||
r.source.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const marketplaceRepos = getMarketplaceRepos();
|
||||
const reposWithState: RepoWithSkills[] = marketplaceRepos.map((repo) => ({
|
||||
...repo,
|
||||
skills: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
}));
|
||||
setRepos(reposWithState);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load repos');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const loadRepoSkills = async (index: number) => {
|
||||
const repo = repos()[index];
|
||||
if (!repo || repo.skills.length > 0 || repo.loading) return;
|
||||
|
||||
setRepos((prev) =>
|
||||
prev.map((r, i) => (i === index ? { ...r, loading: true, error: null } : r))
|
||||
);
|
||||
|
||||
try {
|
||||
const result = await fetchRepoSkills(repo.source, DEFAULT_REPOS);
|
||||
setRepos((prev) =>
|
||||
prev.map((r, i) =>
|
||||
i === index
|
||||
? {
|
||||
...r,
|
||||
skills: result.skills,
|
||||
loading: false,
|
||||
error: result.error || null,
|
||||
}
|
||||
: r
|
||||
)
|
||||
: repos,
|
||||
[repos, searchQuery]
|
||||
);
|
||||
);
|
||||
} catch (err) {
|
||||
setRepos((prev) =>
|
||||
prev.map((r, i) =>
|
||||
i === index
|
||||
? {
|
||||
...r,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to fetch',
|
||||
}
|
||||
: r
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, filteredRepos.length - 1)));
|
||||
}, [filteredRepos.length]);
|
||||
const filteredRepos = createMemo(() => {
|
||||
if (!searchQuery()) return repos();
|
||||
|
||||
const query = searchQuery().toLowerCase();
|
||||
return repos().filter(
|
||||
(r) =>
|
||||
r.name.toLowerCase().includes(query) ||
|
||||
r.source.toLowerCase().includes(query)
|
||||
);
|
||||
});
|
||||
|
||||
const maxVisible = () => Math.max(5, rows() - 12);
|
||||
const startIdx = () =>
|
||||
Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
selectedIndex() - Math.floor(maxVisible() / 2),
|
||||
filteredRepos().length - maxVisible()
|
||||
)
|
||||
);
|
||||
const visibleRepos = () =>
|
||||
filteredRepos().slice(startIdx(), startIdx() + maxVisible());
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = filteredRepos().length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
const handleOpenRepo = () => {
|
||||
const repo = filteredRepos()[selectedIndex()];
|
||||
if (repo) {
|
||||
const actualIndex = repos().findIndex(
|
||||
(r) => r.source === repo.source && r.name === repo.name
|
||||
);
|
||||
if (actualIndex !== -1) {
|
||||
loadRepoSkills(actualIndex);
|
||||
}
|
||||
setShowSkills(true);
|
||||
}
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string; sequence?: string }) => {
|
||||
if (searchMode) {
|
||||
if (searchMode()) {
|
||||
if (key.name === 'escape') {
|
||||
setSearchMode(false);
|
||||
} else if (key.name === 'backspace') {
|
||||
setSearchQuery(prev => prev.slice(0, -1));
|
||||
setSearchQuery((prev) => prev.slice(0, -1));
|
||||
} else if (key.name === 'return') {
|
||||
setSearchMode(false);
|
||||
} else if (key.sequence && key.sequence.length === 1 && /[a-zA-Z0-9\-_.]/.test(key.sequence)) {
|
||||
setSearchQuery(prev => prev + key.sequence);
|
||||
} else if (
|
||||
key.sequence &&
|
||||
key.sequence.length === 1 &&
|
||||
/[a-zA-Z0-9\-_.]/.test(key.sequence)
|
||||
) {
|
||||
setSearchQuery((prev) => prev + key.sequence);
|
||||
setSelectedIndex(0);
|
||||
}
|
||||
return;
|
||||
@@ -66,114 +162,189 @@ export function Browse({ onNavigate, cols = 80, rows = 24 }: BrowseProps) {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.sequence === '/') setSearchMode(true);
|
||||
else if (key.name === 'return') {
|
||||
const repo = filteredRepos[selectedIndex];
|
||||
if (repo) {
|
||||
// Open/view the selected repo (navigate to installed to see skills from this repo)
|
||||
onNavigate('installed');
|
||||
}
|
||||
else if (key.name === 'return') handleOpenRepo();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') {
|
||||
if (showSkills()) setShowSkills(false);
|
||||
else if (searchQuery()) setSearchQuery('');
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedIndex >= filteredRepos.length && filteredRepos.length > 0) {
|
||||
setSelectedIndex(filteredRepos.length - 1);
|
||||
createEffect(() => {
|
||||
if (selectedIndex() >= filteredRepos().length && filteredRepos().length > 0) {
|
||||
setSelectedIndex(filteredRepos().length - 1);
|
||||
}
|
||||
}, [filteredRepos.length, selectedIndex]);
|
||||
});
|
||||
|
||||
// Calculate visible repos
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const startIdx = Math.max(0, Math.min(selectedIndex - Math.floor(maxVisible / 2), filteredRepos.length - maxVisible));
|
||||
const visibleRepos = filteredRepos.slice(startIdx, startIdx + maxVisible);
|
||||
const selectedRepo = () => {
|
||||
const repoList = filteredRepos();
|
||||
if (repoList.length === 0) return null;
|
||||
return repoList[selectedIndex()];
|
||||
};
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
const repoDetailFields = () => {
|
||||
const repo = selectedRepo();
|
||||
if (!repo) return [];
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter open / search esc back'
|
||||
: 'j/k navigate enter open / search esc back';
|
||||
return [
|
||||
{ label: 'Name', value: repo.name },
|
||||
{ label: 'Source', value: repo.source },
|
||||
{ label: 'Skills', value: String(repo.skills.length) },
|
||||
{
|
||||
label: 'Status',
|
||||
value: repo.loading ? 'Loading...' : repo.error ? 'Error' : 'Ready',
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.browse}>⌕ Browse</text>
|
||||
<text fg={terminalColors.textMuted}>{filteredRepos.length} repos</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>explore skill repositories</text>
|
||||
<text> </text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Browse"
|
||||
subtitle="Explore skill repositories"
|
||||
icon="⌕"
|
||||
count={repos().length}
|
||||
/>
|
||||
|
||||
<Show when={error()}>
|
||||
<ErrorState
|
||||
message={error()!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={loading()}>
|
||||
<Spinner label="Loading repositories..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!loading() && !error()}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
<text
|
||||
fg={
|
||||
searchQuery() || searchMode()
|
||||
? terminalColors.text
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
{searchQuery() || (searchMode() ? '|' : 'type to filter...')}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Search */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
<text fg={searchQuery ? terminalColors.text : terminalColors.textMuted}>
|
||||
{searchQuery || 'type to filter...'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<Show
|
||||
when={filteredRepos().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="⌕"
|
||||
title="No repositories found"
|
||||
description={
|
||||
searchQuery()
|
||||
? 'Try a different search term'
|
||||
: 'No repositories configured'
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Repositories</b>{' '}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
({filteredRepos().length})
|
||||
</text>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<For each={visibleRepos()}>
|
||||
{(repo, idx) => {
|
||||
const actualIdx = () => startIdx() + idx();
|
||||
const selected = () => actualIdx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={25}
|
||||
>
|
||||
{repo.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>
|
||||
{repo.skills.length > 0
|
||||
? `${repo.skills.length} skills`
|
||||
: repo.loading
|
||||
? 'loading...'
|
||||
: ''}
|
||||
</text>
|
||||
<Show when={repo.error}>
|
||||
<text fg={terminalColors.error}>✗</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={filteredRepos().length > maxVisible()}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
showing {startIdx() + 1}-
|
||||
{Math.min(startIdx() + maxVisible(), filteredRepos().length)} of{' '}
|
||||
{filteredRepos().length}
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Repository list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Repositories</text>
|
||||
<text> </text>
|
||||
|
||||
{filteredRepos.length === 0 ? (
|
||||
<text fg={terminalColors.textMuted}>No repositories match your search</text>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
{visibleRepos.map((repo, idx) => {
|
||||
const actualIdx = startIdx + idx;
|
||||
const selected = actualIdx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
// Truncate source if needed - clamp to avoid negative slicing
|
||||
const maxSourceLen = Math.max(0, contentWidth - repo.name.length - 6);
|
||||
const displaySource = maxSourceLen > 3 && repo.source.length > maxSourceLen
|
||||
? repo.source.slice(0, maxSourceLen - 3) + '...'
|
||||
: repo.source;
|
||||
// Use single text element to avoid rendering overlap issues
|
||||
const line = `${indicator}${repo.name} · ${displaySource}`;
|
||||
return (
|
||||
<text key={repo.source} fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{line}
|
||||
<Show when={showSkills() && selectedRepo()}>
|
||||
<DetailPane
|
||||
title={selectedRepo()!.name}
|
||||
subtitle={`${selectedRepo()!.skills.length} skills`}
|
||||
icon="⌕"
|
||||
fields={repoDetailFields()}
|
||||
actions={[
|
||||
{ key: 'Enter', label: 'Install' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={35}
|
||||
visible={showSkills()}
|
||||
onClose={() => setShowSkills(false)}
|
||||
>
|
||||
<Show when={selectedRepo()!.loading}>
|
||||
<StatusIndicator status="loading" label="Loading skills..." />
|
||||
</Show>
|
||||
<Show when={selectedRepo()!.skills.length > 0}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Skills:</b>
|
||||
</text>
|
||||
<For each={selectedRepo()!.skills.slice(0, 5)}>
|
||||
{(skill) => (
|
||||
<text fg={terminalColors.textSecondary}>• {skill.name}</text>
|
||||
)}
|
||||
</For>
|
||||
<Show when={selectedRepo()!.skills.length > 5}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
+{selectedRepo()!.skills.length - 5} more
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Scroll indicator */}
|
||||
{filteredRepos.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}showing {startIdx + 1}-{Math.min(startIdx + maxVisible, filteredRepos.length)} of {filteredRepos.length}
|
||||
</text>
|
||||
)}
|
||||
<text> </text>
|
||||
</Show>
|
||||
</Show>
|
||||
</DetailPane>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter open / search r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
/**
|
||||
* Context Screen
|
||||
* Project context analysis
|
||||
*/
|
||||
import { useState, useEffect } from 'react';
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadProjectContext,
|
||||
analyzeProjectContext,
|
||||
refreshContext,
|
||||
exportContext,
|
||||
getStackTags,
|
||||
type ContextServiceState,
|
||||
} from '../services/context.service.js';
|
||||
|
||||
interface ContextProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -14,43 +21,279 @@ interface ContextProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Context({ onNavigate, cols = 80, rows = 24 }: ContextProps) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
export function Context(props: ContextProps) {
|
||||
const [state, setState] = createSignal<ContextServiceState>({
|
||||
context: null,
|
||||
stack: null,
|
||||
loading: true,
|
||||
analyzing: false,
|
||||
error: null,
|
||||
});
|
||||
const [tags, setTags] = createSignal<string[]>([]);
|
||||
const [selectedSection, setSelectedSection] = createSignal(0);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setLoading(false), 500);
|
||||
return () => clearTimeout(timer);
|
||||
}, []);
|
||||
const sections = ['Overview', 'Languages', 'Frameworks', 'Libraries', 'Patterns'];
|
||||
|
||||
const contextInfo = [
|
||||
{ label: 'Working Directory', value: process.cwd() },
|
||||
{ label: 'Node Version', value: process.version },
|
||||
{ label: 'Platform', value: process.platform },
|
||||
{ label: 'Architecture', value: process.arch },
|
||||
];
|
||||
const moveSection = (delta: number) => {
|
||||
setSelectedSection((i) =>
|
||||
Math.max(0, Math.min(sections.length - 1, i + delta))
|
||||
);
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'h' || key.name === 'left') moveSection(-1);
|
||||
else if (key.name === 'l' || key.name === 'right') moveSection(1);
|
||||
else if (key.name === 'r') handleRefresh();
|
||||
else if (key.name === 'e') handleExport();
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
let result = await loadProjectContext();
|
||||
if (!result.context) {
|
||||
result = await analyzeProjectContext();
|
||||
}
|
||||
setState(result);
|
||||
setTags(await getStackTags());
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
analyzing: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load context',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleRefresh = async () => {
|
||||
setState((s) => ({ ...s, analyzing: true, error: null }));
|
||||
try {
|
||||
const result = await refreshContext();
|
||||
setState(result);
|
||||
setTags(await getStackTags());
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
analyzing: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to refresh context',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await exportContext(undefined, 'json');
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to export context',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const currentSection = () => sections[selectedSection()];
|
||||
const ctx = () => state().context;
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Project Context"
|
||||
subtitle="Analyze your project environment"
|
||||
icon="◉"
|
||||
icon="◉"
|
||||
count={tags().length}
|
||||
/>
|
||||
|
||||
{loading ? (
|
||||
<Spinner label="Analyzing project context..." />
|
||||
) : (
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={state().loading || state().analyzing}>
|
||||
<Spinner
|
||||
label={state().analyzing ? 'Analyzing project...' : 'Loading context...'}
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error && ctx()}>
|
||||
<box flexDirection="column">
|
||||
{contextInfo.map((info) => (
|
||||
<box key={info.label} flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={20}>
|
||||
{info.label}:
|
||||
</text>
|
||||
<text fg={terminalColors.text}>{info.value}</text>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<For each={sections}>
|
||||
{(section, idx) => (
|
||||
<box marginRight={2}>
|
||||
<text
|
||||
fg={
|
||||
idx() === selectedSection()
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
{idx() === selectedSection() ? '▸ ' : ' '}
|
||||
{section}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={currentSection() === 'Overview'}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Project:</text>
|
||||
<text fg={terminalColors.text}>{ctx()!.projectName}</text>
|
||||
</box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Path:</text>
|
||||
<text fg={terminalColors.textSecondary}>{ctx()!.rootPath}</text>
|
||||
</box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Languages:</text>
|
||||
<text fg={terminalColors.accent}>{ctx()!.languages.length}</text>
|
||||
</box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Frameworks:</text>
|
||||
<text fg={terminalColors.accent}>{ctx()!.frameworks.length}</text>
|
||||
</box>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Libraries:</text>
|
||||
<text fg={terminalColors.accent}>{ctx()!.libraries.length}</text>
|
||||
</box>
|
||||
<Show when={ctx()!.lastUpdated}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>Last Updated:</text>
|
||||
<text fg={terminalColors.textSecondary}>{ctx()!.lastUpdated}</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
))}
|
||||
</Show>
|
||||
|
||||
<Show when={currentSection() === 'Languages'}>
|
||||
<box flexDirection="column">
|
||||
<Show
|
||||
when={ctx()!.languages.length > 0}
|
||||
fallback={<EmptyState title="No languages detected" compact />}
|
||||
>
|
||||
<For each={ctx()!.languages}>
|
||||
{(lang) => (
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
• {lang}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={currentSection() === 'Frameworks'}>
|
||||
<box flexDirection="column">
|
||||
<Show
|
||||
when={ctx()!.frameworks.length > 0}
|
||||
fallback={<EmptyState title="No frameworks detected" compact />}
|
||||
>
|
||||
<For each={ctx()!.frameworks}>
|
||||
{(fw) => (
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
• {fw}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={currentSection() === 'Libraries'}>
|
||||
<box flexDirection="column">
|
||||
<Show
|
||||
when={ctx()!.libraries.length > 0}
|
||||
fallback={<EmptyState title="No libraries detected" compact />}
|
||||
>
|
||||
<For each={ctx()!.libraries.slice(0, 15)}>
|
||||
{(lib) => (
|
||||
<box marginBottom={1}>
|
||||
<text fg={terminalColors.text}>
|
||||
• {lib}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
<Show when={ctx()!.libraries.length > 15}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
+{ctx()!.libraries.length - 15} more
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={currentSection() === 'Patterns'}>
|
||||
<box flexDirection="column">
|
||||
<Show
|
||||
when={Object.keys(ctx()!.patterns).length > 0}
|
||||
fallback={<EmptyState title="No patterns detected" compact />}
|
||||
>
|
||||
<For each={Object.entries(ctx()!.patterns)}>
|
||||
{([key, value]) => (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted} width={18}>{key}:</text>
|
||||
<text fg={terminalColors.text}>{String(value)}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={tags().length > 0}>
|
||||
<box flexDirection="row" flexWrap="wrap">
|
||||
<text fg={terminalColors.textMuted}>Tags: </text>
|
||||
<For each={tags().slice(0, 8)}>
|
||||
{(tag, idx) => (
|
||||
<text fg={terminalColors.textSecondary}>
|
||||
{tag}
|
||||
{idx() < Math.min(tags().length, 8) - 1 ? ', ' : ''}
|
||||
</text>
|
||||
)}
|
||||
</For>
|
||||
<Show when={tags().length > 8}>
|
||||
<text fg={terminalColors.textMuted}> +{tags().length - 8}</text>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error && !ctx()}>
|
||||
<EmptyState
|
||||
icon="◉"
|
||||
title="No context found"
|
||||
description="Run analysis to detect project context"
|
||||
action={{ label: 'Analyze', key: 'r' }}
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
←/→ sections r refresh e export Esc back
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
/**
|
||||
* Execute Screen
|
||||
* Live skill execution
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen, loadSkillsWithDetails, type SkillWithDetails } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { ProgressBar } from '../components/ProgressBar.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
getAgentAvailability,
|
||||
executeSkillWithAgent,
|
||||
listAvailableAgents,
|
||||
type AgentAvailability,
|
||||
} from '../services/executor.service.js';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
|
||||
interface ExecuteProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -15,39 +21,333 @@ interface ExecuteProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Execute({ onNavigate, cols = 80, rows = 24 }: ExecuteProps) {
|
||||
const [executing, setExecuting] = useState(false);
|
||||
const [progress, setProgress] = useState(0);
|
||||
export function Execute(props: ExecuteProps) {
|
||||
const [skills, setSkills] = createSignal<SkillWithDetails[]>([]);
|
||||
const [agents, setAgents] = createSignal<AgentAvailability[]>([]);
|
||||
const [selectedSkillIndex, setSelectedSkillIndex] = createSignal(0);
|
||||
const [selectedAgentIndex, setSelectedAgentIndex] = createSignal(0);
|
||||
const [focusedPane, setFocusedPane] = createSignal<'skills' | 'agents'>('skills');
|
||||
const [executing, setExecuting] = createSignal(false);
|
||||
const [executionResult, setExecutionResult] = createSignal<{
|
||||
success: boolean;
|
||||
output: string;
|
||||
error?: string;
|
||||
} | null>(null);
|
||||
const [loading, setLoading] = createSignal(true);
|
||||
const [loadError, setLoadError] = createSignal<string | null>(null);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
setLoadError(null);
|
||||
|
||||
try {
|
||||
const skillsWithDetails = loadSkillsWithDetails();
|
||||
setSkills(skillsWithDetails);
|
||||
|
||||
const agentAvailability = await getAgentAvailability();
|
||||
setAgents(agentAvailability);
|
||||
} catch (err) {
|
||||
setLoadError(err instanceof Error ? err.message : 'Failed to load');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExecute = async () => {
|
||||
if (executing()) return;
|
||||
|
||||
const skillList = skills();
|
||||
const agentList = agents();
|
||||
|
||||
if (skillList.length === 0 || agentList.length === 0) return;
|
||||
|
||||
const skill = skillList[selectedSkillIndex()];
|
||||
const agent = agentList[selectedAgentIndex()];
|
||||
|
||||
if (!skill || !agent || !agent.available) return;
|
||||
|
||||
setExecuting(true);
|
||||
setExecutionResult(null);
|
||||
|
||||
try {
|
||||
const result = await executeSkillWithAgent(
|
||||
skill.path,
|
||||
agent.agent,
|
||||
{ timeout: 60000 }
|
||||
);
|
||||
|
||||
setExecutionResult({
|
||||
success: result.success,
|
||||
output: result.output || '',
|
||||
error: result.error,
|
||||
});
|
||||
} catch (err) {
|
||||
setExecutionResult({
|
||||
success: false,
|
||||
output: '',
|
||||
error: err instanceof Error ? err.message : 'Execution failed',
|
||||
});
|
||||
} finally {
|
||||
setExecuting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
if (focusedPane() === 'skills') {
|
||||
const max = skills().length - 1;
|
||||
setSelectedSkillIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
} else {
|
||||
const max = agents().length - 1;
|
||||
setSelectedAgentIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
}
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'tab' || key.name === 'l' || key.name === 'right') {
|
||||
setFocusedPane((p) => (p === 'skills' ? 'agents' : 'skills'));
|
||||
}
|
||||
else if (key.name === 'h' || key.name === 'left') {
|
||||
setFocusedPane((p) => (p === 'agents' ? 'skills' : 'agents'));
|
||||
}
|
||||
else if (key.name === 'return' || key.name === 'x') handleExecute();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') {
|
||||
if (executionResult()) setExecutionResult(null);
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
});
|
||||
|
||||
const selectedSkill = () => {
|
||||
const list = skills();
|
||||
if (list.length === 0) return null;
|
||||
return list[selectedSkillIndex()];
|
||||
};
|
||||
|
||||
const selectedAgent = () => {
|
||||
const list = agents();
|
||||
if (list.length === 0) return null;
|
||||
return list[selectedAgentIndex()];
|
||||
};
|
||||
|
||||
const MAX_VISIBLE = 8;
|
||||
|
||||
const skillsWindow = createMemo(() => {
|
||||
const list = skills();
|
||||
const selected = selectedSkillIndex();
|
||||
const total = list.length;
|
||||
if (total <= MAX_VISIBLE) return { start: 0, items: list };
|
||||
let start = Math.max(0, selected - Math.floor(MAX_VISIBLE / 2));
|
||||
start = Math.min(start, total - MAX_VISIBLE);
|
||||
return { start, items: list.slice(start, start + MAX_VISIBLE) };
|
||||
});
|
||||
|
||||
const agentsWindow = createMemo(() => {
|
||||
const list = agents();
|
||||
const selected = selectedAgentIndex();
|
||||
const total = list.length;
|
||||
if (total <= MAX_VISIBLE) return { start: 0, items: list };
|
||||
let start = Math.max(0, selected - Math.floor(MAX_VISIBLE / 2));
|
||||
start = Math.min(start, total - MAX_VISIBLE);
|
||||
return { start, items: list.slice(start, start + MAX_VISIBLE) };
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Execute"
|
||||
subtitle="Run skills in real-time"
|
||||
icon="▶"
|
||||
subtitle="Run skills with AI agents"
|
||||
icon="▶"
|
||||
/>
|
||||
|
||||
{executing ? (
|
||||
<box flexDirection="column">
|
||||
<Spinner label="Executing skill..." />
|
||||
<text> </text>
|
||||
<ProgressBar progress={progress} width={40} />
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>Press Esc to cancel</text>
|
||||
<Show when={loading()}>
|
||||
<Spinner label="Loading..." />
|
||||
</Show>
|
||||
|
||||
<Show when={loadError()}>
|
||||
<ErrorState
|
||||
message={loadError()!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={!loading() && !loadError()}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" width={30}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'skills'
|
||||
? terminalColors.accent
|
||||
: terminalColors.text
|
||||
}
|
||||
>
|
||||
<b>Skills</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={skills().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
title="No skills installed"
|
||||
description="Browse to install"
|
||||
action={{ label: 'Browse', key: 'b' }}
|
||||
compact
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Show when={skillsWindow().start > 0}>
|
||||
<text fg={terminalColors.textMuted}> ▲ {skillsWindow().start} more</text>
|
||||
</Show>
|
||||
<For each={skillsWindow().items}>
|
||||
{(skill, idx) => {
|
||||
const originalIndex = () => skillsWindow().start + idx();
|
||||
const isSelected = () =>
|
||||
focusedPane() === 'skills' && originalIndex() === selectedSkillIndex();
|
||||
return (
|
||||
<box marginBottom={1}>
|
||||
<text
|
||||
fg={isSelected() ? terminalColors.accent : terminalColors.textSecondary}
|
||||
>
|
||||
{isSelected() ? '▸ ' : ' '}
|
||||
{skill.name}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<Show when={skillsWindow().start + MAX_VISIBLE < skills().length}>
|
||||
<text fg={terminalColors.textMuted}> ▼ {skills().length - skillsWindow().start - MAX_VISIBLE} more</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box width={2}>
|
||||
<text fg={terminalColors.border}>│</text>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" width={25}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'agents'
|
||||
? terminalColors.accent
|
||||
: terminalColors.text
|
||||
}
|
||||
>
|
||||
<b>Agents</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={agents().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
title="No agents found"
|
||||
compact
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Show when={agentsWindow().start > 0}>
|
||||
<text fg={terminalColors.textMuted}> ▲ {agentsWindow().start} more</text>
|
||||
</Show>
|
||||
<For each={agentsWindow().items}>
|
||||
{(agent, idx) => {
|
||||
const originalIndex = () => agentsWindow().start + idx();
|
||||
const isSelected = () =>
|
||||
focusedPane() === 'agents' && originalIndex() === selectedAgentIndex();
|
||||
const available = agent.available;
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={
|
||||
isSelected()
|
||||
? terminalColors.accent
|
||||
: available
|
||||
? terminalColors.textSecondary
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
{isSelected() ? '▸ ' : ' '}
|
||||
{agent.agent}
|
||||
</text>
|
||||
<text fg={available ? terminalColors.success : terminalColors.error}>
|
||||
{' '}
|
||||
{available ? '●' : '○'}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<Show when={agentsWindow().start + MAX_VISIBLE < agents().length}>
|
||||
<text fg={terminalColors.textMuted}> ▼ {agents().length - agentsWindow().start - MAX_VISIBLE} more</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Select a skill to execute:</text>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={selectedSkill() && selectedAgent()}>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>Selected: </text>
|
||||
<text fg={terminalColors.accent}>{selectedSkill()!.name}</text>
|
||||
<text fg={terminalColors.textMuted}> → </text>
|
||||
<text
|
||||
fg={
|
||||
selectedAgent()!.available
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
{selectedAgent()!.agent}
|
||||
</text>
|
||||
<Show when={!selectedAgent()!.available}>
|
||||
<text fg={terminalColors.warning}> (unavailable)</text>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<Show when={executing()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
No skills available. Install skills first using 'b' (browse) or 'm' (marketplace).
|
||||
</text>
|
||||
<StatusIndicator status="loading" label="Executing skill..." />
|
||||
</Show>
|
||||
|
||||
<Show when={executionResult() && !executing()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to execute, 'i' to view installed skills
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text
|
||||
fg={
|
||||
executionResult()!.success
|
||||
? terminalColors.success
|
||||
: terminalColors.error
|
||||
}
|
||||
>
|
||||
{executionResult()!.success ? '✓ Execution completed' : '✗ Execution failed'}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
<Show when={executionResult()!.error}>
|
||||
<text fg={terminalColors.error}>{executionResult()!.error}</text>
|
||||
</Show>
|
||||
<Show when={executionResult()!.output}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{executionResult()!.output.slice(0, 200)}
|
||||
{executionResult()!.output.length > 200 ? '...' : ''}
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Tab/←/→ switch pane j/k navigate Enter execute r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { createSignal, createEffect, onCleanup, createMemo, Show, For } from 'solid-js';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { getVersion } from '../utils/helpers.js';
|
||||
@@ -44,84 +44,100 @@ const SHORTCUTS = [
|
||||
]},
|
||||
];
|
||||
|
||||
function ShortcutSection({ section, items, isLast }: { section: string; items: { key: string; desc: string }[]; isLast: boolean }) {
|
||||
interface ShortcutSectionProps {
|
||||
section: string;
|
||||
items: { key: string; desc: string }[];
|
||||
isLast: boolean;
|
||||
}
|
||||
|
||||
function ShortcutSection(props: ShortcutSectionProps) {
|
||||
return (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>{section}</text>
|
||||
{items.map((item) => (
|
||||
<box key={item.key} flexDirection="row">
|
||||
<text fg={terminalColors.accent} width={8}> {item.key}</text>
|
||||
<text fg={terminalColors.textMuted}>{item.desc}</text>
|
||||
</box>
|
||||
))}
|
||||
{!isLast && <text> </text>}
|
||||
<text fg={terminalColors.text}>{props.section}</text>
|
||||
<For each={props.items}>
|
||||
{(item) => (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent} width={8}> {item.key}</text>
|
||||
<text fg={terminalColors.textMuted}>{item.desc}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
<Show when={!props.isLast}>
|
||||
<text> </text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
export function Help({ cols = 80 }: HelpProps) {
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const isCompact = cols < 60;
|
||||
const rawWidth = cols - 4;
|
||||
const contentWidth = Math.max(1, Math.min(rawWidth, 60));
|
||||
export function Help(props: HelpProps) {
|
||||
const [animPhase, setAnimPhase] = createSignal(0);
|
||||
const cols = () => props.cols ?? 80;
|
||||
const isCompact = () => cols() < 60;
|
||||
const rawWidth = () => cols() - 4;
|
||||
const contentWidth = () => Math.max(1, Math.min(rawWidth(), 60));
|
||||
const version = getVersion();
|
||||
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
createEffect(() => {
|
||||
if (animPhase() >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
const divider = createMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth())}</text>
|
||||
);
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{animPhase >= 1 && (
|
||||
<Show when={animPhase() >= 1}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth()}>
|
||||
<text fg={terminalColors.text}>/ Help</text>
|
||||
<text fg={terminalColors.textMuted}>skillkit v{version}</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>keyboard shortcuts and navigation</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
{divider()}
|
||||
<text> </text>
|
||||
{isCompact ? (
|
||||
SHORTCUTS.map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === SHORTCUTS.length - 1} />
|
||||
))
|
||||
) : (
|
||||
<Show when={isCompact()} fallback={
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" width={Math.floor(contentWidth / 2)}>
|
||||
{SHORTCUTS.slice(0, 2).map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === 1} />
|
||||
))}
|
||||
<box flexDirection="column" width={Math.floor(contentWidth() / 2)}>
|
||||
<For each={SHORTCUTS.slice(0, 2)}>
|
||||
{(s, idx) => (
|
||||
<ShortcutSection section={s.section} items={s.items} isLast={idx() === 1} />
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
<box flexDirection="column" width={Math.floor(contentWidth / 2)}>
|
||||
{SHORTCUTS.slice(2).map((s, idx) => (
|
||||
<ShortcutSection key={s.section} section={s.section} items={s.items} isLast={idx === 1} />
|
||||
))}
|
||||
<box flexDirection="column" width={Math.floor(contentWidth() / 2)}>
|
||||
<For each={SHORTCUTS.slice(2)}>
|
||||
{(s, idx) => (
|
||||
<ShortcutSection section={s.section} items={s.items} isLast={idx() === 1} />
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</box>
|
||||
)}
|
||||
}>
|
||||
<For each={SHORTCUTS}>
|
||||
{(s, idx) => (
|
||||
<ShortcutSection section={s.section} items={s.items} isLast={idx() === SHORTCUTS.length - 1} />
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
{divider()}
|
||||
<text fg={terminalColors.textMuted}>esc back h home q quit</text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* History Screen
|
||||
* Execution history
|
||||
*/
|
||||
import { For } from 'solid-js';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
@@ -12,7 +9,7 @@ interface HistoryProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function History({ onNavigate, cols = 80, rows = 24 }: HistoryProps) {
|
||||
export function History(props: HistoryProps) {
|
||||
const history = [
|
||||
{ skill: 'tdd-workflow', time: '10:32 AM', duration: '2.3s', status: 'success' },
|
||||
{ skill: 'code-review', time: '10:15 AM', duration: '5.1s', status: 'success' },
|
||||
@@ -32,23 +29,25 @@ export function History({ onNavigate, cols = 80, rows = 24 }: HistoryProps) {
|
||||
<text fg={terminalColors.text}><b>Recent Executions</b></text>
|
||||
<text> </text>
|
||||
|
||||
{history.map((item, idx) => (
|
||||
<box key={`${item.skill}-${item.time}`} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{item.skill}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>{item.time}</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>{item.duration}</text>
|
||||
<text
|
||||
fg={item.status === 'success' ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{item.status === 'success' ? '\u2713 success' : '\u2717 failed'}
|
||||
</text>
|
||||
</box>
|
||||
))}
|
||||
<For each={history}>
|
||||
{(item, idx) => (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx() === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{idx() === 0 ? '\u25B8 ' : ' '}{item.skill}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>{item.time}</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>{item.duration}</text>
|
||||
<text
|
||||
fg={item.status === 'success' ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{item.status === 'success' ? '\u2713 success' : '\u2717 failed'}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useMemo } from 'react';
|
||||
import { createSignal, createEffect, onCleanup, createMemo, Show, For } from 'solid-js';
|
||||
import { type Screen, loadSkills, TOTAL_AGENTS } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { symbols, AGENT_LOGOS } from '../theme/symbols.js';
|
||||
@@ -19,24 +19,25 @@ const FEATURES = [
|
||||
{ key: 'Team', color: terminalColors.text, desc: 'collaborate' },
|
||||
];
|
||||
|
||||
export function Home({ cols = 80 }: HomeProps) {
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [stats, setStats] = useState({ skills: 0, agents: TOTAL_AGENTS, synced: 0 });
|
||||
const [detectedAgents, setDetectedAgents] = useState<string[]>([]);
|
||||
export function Home(props: HomeProps) {
|
||||
const [animPhase, setAnimPhase] = createSignal(0);
|
||||
const [stats, setStats] = createSignal({ skills: 0, agents: TOTAL_AGENTS, synced: 0 });
|
||||
const [detectedAgents, setDetectedAgents] = createSignal<string[]>([]);
|
||||
|
||||
const cols = () => props.cols ?? 80;
|
||||
const version = getVersion();
|
||||
const isCompact = cols < 70;
|
||||
const isNarrow = cols < 50;
|
||||
const contentWidth = Math.min(cols - 4, 55);
|
||||
const line = '─'.repeat(contentWidth);
|
||||
const isCompact = () => cols() < 70;
|
||||
const isNarrow = () => cols() < 50;
|
||||
const contentWidth = () => Math.min(cols() - 4, 55);
|
||||
const line = () => '─'.repeat(contentWidth());
|
||||
|
||||
useEffect(() => {
|
||||
if (animPhase >= 5) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
createEffect(() => {
|
||||
if (animPhase() >= 5) return;
|
||||
const timer = setTimeout(() => setAnimPhase((p) => p + 1), 100);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const skillsData = loadSkills();
|
||||
setStats({
|
||||
skills: skillsData.skills.length,
|
||||
@@ -44,112 +45,144 @@ export function Home({ cols = 80 }: HomeProps) {
|
||||
synced: Math.min(skillsData.skills.length, 3),
|
||||
});
|
||||
setDetectedAgents(['claude-code', 'cursor', 'github-copilot']);
|
||||
}, []);
|
||||
});
|
||||
|
||||
const visibleAgents = useMemo(() => {
|
||||
const visibleAgents = createMemo(() => {
|
||||
const allAgents = Object.entries(AGENT_LOGOS);
|
||||
const perRow = isNarrow || isCompact ? 2 : 3;
|
||||
const maxAgents = isNarrow ? 4 : isCompact ? 6 : 9;
|
||||
const perRow = isNarrow() || isCompact() ? 2 : 3;
|
||||
const maxAgents = isNarrow() ? 4 : isCompact() ? 6 : 9;
|
||||
return {
|
||||
agents: allAgents.slice(0, maxAgents),
|
||||
perRow,
|
||||
remaining: allAgents.length - maxAgents,
|
||||
};
|
||||
}, [isCompact, isNarrow]);
|
||||
});
|
||||
|
||||
const getAgentWidth = () => {
|
||||
if (isNarrow) return 22;
|
||||
if (isCompact) return 26;
|
||||
if (isNarrow()) return 22;
|
||||
if (isCompact()) return 26;
|
||||
return 18;
|
||||
};
|
||||
|
||||
const agentRows = createMemo(() => {
|
||||
const { agents, perRow } = visibleAgents();
|
||||
const rows: typeof agents[] = [];
|
||||
for (let i = 0; i < agents.length; i += perRow) {
|
||||
rows.push(agents.slice(i, i + perRow));
|
||||
}
|
||||
return rows;
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{animPhase >= 1 && (
|
||||
<Show when={animPhase() >= 1}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>{symbols.brandIcon} skillkit</text>
|
||||
<text fg={terminalColors.text}>
|
||||
{symbols.brandIcon} skillkit
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}> v{version}</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>universal skills for ai coding agents</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text fg={terminalColors.textMuted}>{line()}</text>
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<box width={14}><text fg={terminalColors.accent}>{stats.skills}</text></box>
|
||||
<box width={14}><text fg={terminalColors.text}>{stats.agents}</text></box>
|
||||
<box width={14}><text fg={terminalColors.text}>{stats.synced}</text></box>
|
||||
<box width={14}>
|
||||
<text fg={terminalColors.accent}>{stats().skills}</text>
|
||||
</box>
|
||||
<box width={14}>
|
||||
<text fg={terminalColors.text}>{stats().agents}</text>
|
||||
</box>
|
||||
<box width={14}>
|
||||
<text fg={terminalColors.text}>{stats().synced}</text>
|
||||
</box>
|
||||
</box>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted} width={14}>skills</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>agents</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>synced</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>
|
||||
skills
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>
|
||||
agents
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={14}>
|
||||
synced
|
||||
</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text fg={terminalColors.textMuted}>{line()}</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 3 && (
|
||||
<Show when={animPhase() >= 3}>
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Works with</text>
|
||||
<text> </text>
|
||||
{Array(Math.ceil(visibleAgents.agents.length / visibleAgents.perRow))
|
||||
.fill(0)
|
||||
.map((_, rowIdx) => (
|
||||
<box key={rowIdx} flexDirection="row">
|
||||
{visibleAgents.agents
|
||||
.slice(rowIdx * visibleAgents.perRow, (rowIdx + 1) * visibleAgents.perRow)
|
||||
.map(([type, agent]) => {
|
||||
const isDetected = detectedAgents.includes(type);
|
||||
<For each={agentRows()}>
|
||||
{(row) => (
|
||||
<box flexDirection="row">
|
||||
<For each={row}>
|
||||
{([type, agent]) => {
|
||||
const isDetected = () => detectedAgents().includes(type);
|
||||
return (
|
||||
<box key={type} width={getAgentWidth()} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{agent.icon} {agent.name} </text>
|
||||
<text fg={isDetected ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{isDetected ? '●' : '○'}
|
||||
<box width={getAgentWidth()} flexDirection="row">
|
||||
<text fg={terminalColors.text}>
|
||||
{agent.icon} {agent.name}{' '}
|
||||
</text>
|
||||
<text fg={isDetected() ? terminalColors.accent : terminalColors.textMuted}>
|
||||
{isDetected() ? '●' : '○'}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
}}
|
||||
</For>
|
||||
</box>
|
||||
))}
|
||||
{visibleAgents.remaining > 0 && (
|
||||
<text fg={terminalColors.textMuted}>+{visibleAgents.remaining} more</text>
|
||||
)}
|
||||
)}
|
||||
</For>
|
||||
<Show when={visibleAgents().remaining > 0}>
|
||||
<text fg={terminalColors.textMuted}>+{visibleAgents().remaining} more</text>
|
||||
</Show>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text fg={terminalColors.textMuted}>{line()}</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 4 && (
|
||||
<Show when={animPhase() >= 4}>
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Features</text>
|
||||
<text> </text>
|
||||
{FEATURES.map((feat) => (
|
||||
<box key={feat.key} flexDirection="row">
|
||||
<text fg={feat.color} width={12}> {feat.key}</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.desc}</text>
|
||||
</box>
|
||||
))}
|
||||
<For each={FEATURES}>
|
||||
{(feat) => (
|
||||
<box flexDirection="row">
|
||||
<text fg={feat.color} width={12}>
|
||||
{' '}
|
||||
{feat.key}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{feat.desc}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{animPhase >= 5 && (
|
||||
<Show when={animPhase() >= 5}>
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>{line}</text>
|
||||
<text fg={terminalColors.textMuted}>{line()}</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{isCompact ? 'b browse m market / help q quit' : 'b browse m market i installed / help q quit'}
|
||||
{isCompact()
|
||||
? 'b browse m market / help q quit'
|
||||
: 'b browse m market i installed / help q quit'}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { createSignal, createEffect, onCleanup, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen, loadSkills, filterSkills } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
@@ -11,75 +11,69 @@ interface InstalledProps {
|
||||
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
|
||||
export function Installed({ onNavigate, cols = 80, rows = 24 }: InstalledProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [searchMode, setSearchMode] = useState(false);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [skills, setSkills] = useState<ReturnType<typeof loadSkills>>({
|
||||
export function Installed(props: InstalledProps) {
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [searchQuery, setSearchQuery] = createSignal('');
|
||||
const [searchMode, setSearchMode] = createSignal(false);
|
||||
const [animPhase, setAnimPhase] = createSignal(0);
|
||||
const [spinnerFrame, setSpinnerFrame] = createSignal(0);
|
||||
const [skills, setSkills] = createSignal<ReturnType<typeof loadSkills>>({
|
||||
skills: [],
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
const cols = () => props.cols ?? 80;
|
||||
const rows = () => props.rows ?? 24;
|
||||
const isCompact = () => cols() < 60;
|
||||
const contentWidth = () => Math.max(1, Math.min(cols() - 4, 60));
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
createEffect(() => {
|
||||
if (animPhase() >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase((p) => p + 1), 100);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
// Loading spinner
|
||||
useEffect(() => {
|
||||
if (!skills.loading) return;
|
||||
createEffect(() => {
|
||||
if (!skills().loading) return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
setSpinnerFrame((f) => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [skills.loading]);
|
||||
onCleanup(() => clearInterval(interval));
|
||||
});
|
||||
|
||||
// Load skills
|
||||
useEffect(() => {
|
||||
createEffect(() => {
|
||||
const data = loadSkills();
|
||||
setSkills(data);
|
||||
}, []);
|
||||
});
|
||||
|
||||
const filteredSkills = useMemo(() =>
|
||||
filterSkills(skills.skills, searchQuery),
|
||||
[skills.skills, searchQuery]
|
||||
);
|
||||
const filteredSkills = createMemo(() => filterSkills(skills().skills, searchQuery()));
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, filteredSkills.length - 1)));
|
||||
}, [filteredSkills.length]);
|
||||
const handleKeyNav = (delta: number) => {
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, filteredSkills().length - 1)));
|
||||
};
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
if (filteredSkills.length === 0) return;
|
||||
const skill = filteredSkills[selectedIndex];
|
||||
const handleToggle = () => {
|
||||
if (filteredSkills().length === 0) return;
|
||||
const skill = filteredSkills()[selectedIndex()];
|
||||
if (skill) {
|
||||
setSkills(prev => ({
|
||||
setSkills((prev) => ({
|
||||
...prev,
|
||||
skills: prev.skills.map(s =>
|
||||
s.name === skill.name ? { ...s, enabled: s.enabled === false } : s
|
||||
),
|
||||
skills: prev.skills.map((s) => (s.name === skill.name ? { ...s, enabled: s.enabled === false } : s)),
|
||||
}));
|
||||
}
|
||||
}, [filteredSkills, selectedIndex]);
|
||||
};
|
||||
|
||||
const handleKeyboard = useCallback((key: { name?: string; sequence?: string }) => {
|
||||
if (searchMode) {
|
||||
useKeyboard((key: { name?: string; sequence?: string }) => {
|
||||
if (searchMode()) {
|
||||
if (key.name === 'escape') {
|
||||
setSearchMode(false);
|
||||
} else if (key.name === 'backspace') {
|
||||
setSearchQuery(prev => prev.slice(0, -1));
|
||||
setSearchQuery((prev) => prev.slice(0, -1));
|
||||
} else if (key.name === 'return') {
|
||||
setSearchMode(false);
|
||||
} else if (key.sequence && key.sequence.length === 1 && /[a-zA-Z0-9\-_.]/.test(key.sequence)) {
|
||||
setSearchQuery(prev => prev + key.sequence);
|
||||
setSearchQuery((prev) => prev + key.sequence);
|
||||
setSelectedIndex(0);
|
||||
}
|
||||
return;
|
||||
@@ -90,136 +84,140 @@ export function Installed({ onNavigate, cols = 80, rows = 24 }: InstalledProps)
|
||||
else if (key.sequence === '/') setSearchMode(true);
|
||||
else if (key.name === 'return') handleToggle();
|
||||
else if (key.name === 'd') handleToggle();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
}, [searchMode, handleKeyNav, handleToggle, onNavigate]);
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
useKeyboard(handleKeyboard);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedIndex >= filteredSkills.length && filteredSkills.length > 0) {
|
||||
setSelectedIndex(filteredSkills.length - 1);
|
||||
createEffect(() => {
|
||||
if (selectedIndex() >= filteredSkills().length && filteredSkills().length > 0) {
|
||||
setSelectedIndex(filteredSkills().length - 1);
|
||||
}
|
||||
}, [filteredSkills.length, selectedIndex]);
|
||||
});
|
||||
|
||||
// Calculate visible items
|
||||
const maxVisible = Math.max(5, rows - 10);
|
||||
const startIdx = Math.max(0, Math.min(selectedIndex - Math.floor(maxVisible / 2), filteredSkills.length - maxVisible));
|
||||
const visibleSkills = filteredSkills.slice(startIdx, startIdx + maxVisible);
|
||||
const maxVisible = () => Math.max(5, rows() - 10);
|
||||
const startIdx = () =>
|
||||
Math.max(0, Math.min(selectedIndex() - Math.floor(maxVisible() / 2), filteredSkills().length - maxVisible()));
|
||||
const visibleSkills = () => filteredSkills().slice(startIdx(), startIdx() + maxVisible());
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
const divider = () => <text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth())}</text>;
|
||||
|
||||
// Stats
|
||||
const enabledCount = skills.skills.filter(s => s.enabled !== false).length;
|
||||
const totalCount = skills.skills.length;
|
||||
const enabledCount = () => skills().skills.filter((s) => s.enabled !== false).length;
|
||||
const totalCount = () => skills().skills.length;
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter toggle d disable esc back'
|
||||
: 'j/k navigate enter toggle d disable esc back';
|
||||
const shortcuts = () =>
|
||||
isCompact()
|
||||
? 'j/k nav enter toggle d disable esc back'
|
||||
: 'j/k navigate enter toggle d disable esc back';
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<Show when={animPhase() >= 1}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth()}>
|
||||
<text fg={terminalColors.success}>✓ Installed</text>
|
||||
<text fg={terminalColors.textMuted}>{enabledCount}/{totalCount} active</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{enabledCount()}/{totalCount()} active
|
||||
</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>manage your skills</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Search */}
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
{divider()}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.textMuted}>/ </text>
|
||||
<text fg={searchQuery ? terminalColors.text : terminalColors.textMuted}>
|
||||
{searchQuery || 'type to filter...'}
|
||||
<text fg={searchQuery() ? terminalColors.text : terminalColors.textMuted}>
|
||||
{searchQuery() || 'type to filter...'}
|
||||
</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
{divider()}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Skills list */}
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{skills.loading ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Loading skills...</text>
|
||||
</box>
|
||||
) : skills.error ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.error}>✗ Error loading skills</text>
|
||||
<text fg={terminalColors.textMuted}>{skills.error}</text>
|
||||
</box>
|
||||
) : filteredSkills.length === 0 ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{skills.skills.length === 0
|
||||
? 'No skills installed yet'
|
||||
: 'No skills match your search'}
|
||||
</text>
|
||||
{skills.skills.length === 0 && (
|
||||
<>
|
||||
<Show
|
||||
when={!skills().loading}
|
||||
fallback={
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame()]} </text>
|
||||
<text fg={terminalColors.text}>Loading skills...</text>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<Show
|
||||
when={!skills().error}
|
||||
fallback={
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.error}>✗ Error loading skills</text>
|
||||
<text fg={terminalColors.textMuted}>{skills().error}</text>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<Show
|
||||
when={filteredSkills().length > 0}
|
||||
fallback={
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{skills().skills.length === 0 ? 'No skills installed yet' : 'No skills match your search'}
|
||||
</text>
|
||||
<Show when={skills().skills.length === 0}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>Press 'b' to browse or 'm' for marketplace</text>
|
||||
</Show>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Skills</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press 'b' to browse or 'm' for marketplace
|
||||
</text>
|
||||
</>
|
||||
)}
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Skills</text>
|
||||
<text> </text>
|
||||
{visibleSkills.map((skill, idx) => {
|
||||
const actualIdx = startIdx + idx;
|
||||
const selected = actualIdx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = skill.enabled !== false ? '●' : '○';
|
||||
const qualityBadge = skill.grade ? ` [${skill.grade}]` : '';
|
||||
const warningIndicator = skill.warnings && skill.warnings > 2 ? ' ⚠' : '';
|
||||
const line = `${indicator}${statusIcon} ${skill.name}${qualityBadge}${warningIndicator}`;
|
||||
const badgeColor = skill.quality !== undefined
|
||||
? (skill.quality >= 80 ? terminalColors.success : skill.quality >= 60 ? terminalColors.warning : terminalColors.error)
|
||||
: terminalColors.text;
|
||||
return (
|
||||
<text key={skill.name} fg={selected ? terminalColors.accent : badgeColor}>
|
||||
{line}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
<For each={visibleSkills()}>
|
||||
{(skill, idx) => {
|
||||
const actualIdx = () => startIdx() + idx();
|
||||
const selected = () => actualIdx() === selectedIndex();
|
||||
const indicator = () => (selected() ? '▸' : ' ');
|
||||
const statusIcon = () => (skill.enabled !== false ? '●' : '○');
|
||||
const qualityBadge = () => (skill.grade ? ` [${skill.grade}]` : '');
|
||||
const warningIndicator = () => (skill.warnings && skill.warnings > 2 ? ' ⚠' : '');
|
||||
const line = () =>
|
||||
`${indicator()}${statusIcon()} ${skill.name}${qualityBadge()}${warningIndicator()}`;
|
||||
const badgeColor = () =>
|
||||
skill.quality !== undefined
|
||||
? skill.quality >= 80
|
||||
? terminalColors.success
|
||||
: skill.quality >= 60
|
||||
? terminalColors.warning
|
||||
: terminalColors.error
|
||||
: terminalColors.text;
|
||||
return <text fg={selected() ? terminalColors.accent : badgeColor()}>{line()}</text>;
|
||||
}}
|
||||
</For>
|
||||
|
||||
{/* Scroll indicator */}
|
||||
{filteredSkills.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}showing {startIdx + 1}-{Math.min(startIdx + maxVisible, filteredSkills.length)} of {filteredSkills.length}
|
||||
</text>
|
||||
)}
|
||||
</box>
|
||||
)}
|
||||
<Show when={filteredSkills().length > maxVisible()}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}showing {startIdx() + 1}-{Math.min(startIdx() + maxVisible(), filteredSkills().length)} of{' '}
|
||||
{filteredSkills().length}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
</Show>
|
||||
</Show>
|
||||
</Show>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
{divider()}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts()}</text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen, DEFAULT_REPOS } from '../state/index.js';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import {
|
||||
type Screen,
|
||||
DEFAULT_REPOS,
|
||||
fetchRepoSkills,
|
||||
filterMarketplaceSkills,
|
||||
type FetchedSkill,
|
||||
} from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { SearchInput } from '../components/SearchInput.js';
|
||||
|
||||
interface MarketplaceProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -10,136 +20,287 @@ interface MarketplaceProps {
|
||||
}
|
||||
|
||||
const CATEGORIES = [
|
||||
{ name: 'Development', count: 24 },
|
||||
{ name: 'Testing', count: 18 },
|
||||
{ name: 'DevOps', count: 15 },
|
||||
{ name: 'Security', count: 12 },
|
||||
{ name: 'Development', tag: 'development' },
|
||||
{ name: 'Testing', tag: 'testing' },
|
||||
{ name: 'DevOps', tag: 'devops' },
|
||||
{ name: 'Security', tag: 'security' },
|
||||
{ name: 'AI/ML', tag: 'ai' },
|
||||
];
|
||||
|
||||
export function Marketplace({ onNavigate, cols = 80, rows = 24 }: MarketplaceProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
export function Marketplace(props: MarketplaceProps) {
|
||||
const [allSkills, setAllSkills] = createSignal<FetchedSkill[]>([]);
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [selectedCategory, setSelectedCategory] = createSignal<string | null>(null);
|
||||
const [searchQuery, setSearchQuery] = createSignal('');
|
||||
const [loading, setLoading] = createSignal(true);
|
||||
const [error, setError] = createSignal<string | null>(null);
|
||||
const [loadedRepos, setLoadedRepos] = createSignal<string[]>([]);
|
||||
const [failedRepos, setFailedRepos] = createSignal<string[]>([]);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
const rows = () => props.rows ?? 24;
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 3) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
// Featured repos
|
||||
const featured = useMemo(() =>
|
||||
DEFAULT_REPOS.slice(0, 5).map((r, i) => ({
|
||||
name: r.name,
|
||||
stars: Math.floor(100 - i * 15),
|
||||
source: r.source,
|
||||
})),
|
||||
[]
|
||||
);
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const maxVisible = Math.max(3, Math.floor((rows - 14) / 1));
|
||||
const visibleFeatured = featured.slice(0, maxVisible);
|
||||
const skills: FetchedSkill[] = [];
|
||||
const loaded: string[] = [];
|
||||
const failed: string[] = [];
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, visibleFeatured.length - 1)));
|
||||
}, [visibleFeatured.length]);
|
||||
|
||||
const handleInstall = useCallback(() => {
|
||||
const item = visibleFeatured[selectedIndex];
|
||||
if (item) {
|
||||
// Navigate to installed after "installing"
|
||||
onNavigate('installed');
|
||||
for (const repo of DEFAULT_REPOS.slice(0, 5)) {
|
||||
try {
|
||||
const result = await fetchRepoSkills(repo.source, DEFAULT_REPOS);
|
||||
if (result.skills.length > 0) {
|
||||
skills.push(...result.skills);
|
||||
loaded.push(repo.name);
|
||||
} else if (result.error) {
|
||||
failed.push(repo.name);
|
||||
}
|
||||
} catch {
|
||||
failed.push(repo.name);
|
||||
}
|
||||
}
|
||||
}, [selectedIndex, visibleFeatured, onNavigate]);
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
setAllSkills(skills);
|
||||
setLoadedRepos(loaded);
|
||||
setFailedRepos(failed);
|
||||
|
||||
const attemptedCount = DEFAULT_REPOS.slice(0, 5).length;
|
||||
if (failed.length === attemptedCount) {
|
||||
setError(`Failed to load all repos: ${failed.join(', ')}`);
|
||||
} else if (failed.length > 0 && skills.length === 0) {
|
||||
setError(`Some repos failed (${failed.join(', ')}) and no skills loaded`);
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const filteredSkills = createMemo(() => {
|
||||
let skills = allSkills();
|
||||
|
||||
if (selectedCategory()) {
|
||||
skills = skills.filter(
|
||||
(s) =>
|
||||
s.name.toLowerCase().includes(selectedCategory()!.toLowerCase()) ||
|
||||
s.description?.toLowerCase().includes(selectedCategory()!.toLowerCase())
|
||||
);
|
||||
}
|
||||
|
||||
if (searchQuery()) {
|
||||
skills = filterMarketplaceSkills(skills, searchQuery());
|
||||
}
|
||||
|
||||
return skills;
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
const list = filteredSkills();
|
||||
const maxIndex = Math.max(0, list.length - 1);
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev, maxIndex)));
|
||||
});
|
||||
|
||||
const maxVisible = () => Math.max(4, Math.floor((rows() - 14) / 2));
|
||||
|
||||
const skillsWindow = createMemo(() => {
|
||||
const list = filteredSkills();
|
||||
const selected = selectedIndex();
|
||||
const visible = maxVisible();
|
||||
const total = list.length;
|
||||
if (total <= visible) return { start: 0, items: list };
|
||||
let start = Math.max(0, selected - Math.floor(visible / 2));
|
||||
start = Math.min(start, total - visible);
|
||||
return { start, items: list.slice(start, start + visible) };
|
||||
});
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = filteredSkills().length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
const handleInstall = () => {
|
||||
const skill = filteredSkills()[selectedIndex()];
|
||||
if (skill) {
|
||||
props.onNavigate('installed');
|
||||
}
|
||||
};
|
||||
|
||||
const handleCategorySelect = (idx: number) => {
|
||||
const cat = CATEGORIES[idx];
|
||||
if (cat) {
|
||||
setSelectedCategory((prev) => (prev === cat.tag ? null : cat.tag));
|
||||
setSelectedIndex(0);
|
||||
}
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string; sequence?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleInstall();
|
||||
else if (key.name === 'b') onNavigate('browse');
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
else if (key.name === 'b') props.onNavigate('browse');
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.sequence && ['1', '2', '3', '4', '5'].includes(key.sequence)) {
|
||||
handleCategorySelect(parseInt(key.sequence) - 1);
|
||||
} else if (key.name === 'escape') {
|
||||
if (searchQuery() || selectedCategory()) {
|
||||
setSearchQuery('');
|
||||
setSelectedCategory(null);
|
||||
} else {
|
||||
props.onNavigate('home');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter install b browse esc back'
|
||||
: 'j/k navigate enter install b full browse esc back';
|
||||
const selectedSkill = () => {
|
||||
const skills = filteredSkills();
|
||||
if (skills.length === 0) return null;
|
||||
return skills[selectedIndex()];
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Marketplace"
|
||||
subtitle="Discover and install skills"
|
||||
icon="★"
|
||||
count={allSkills().length}
|
||||
/>
|
||||
|
||||
<Show when={error()}>
|
||||
<ErrorState
|
||||
message={error()!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={loading()}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.recommend}>★ Marketplace</text>
|
||||
<text fg={terminalColors.textMuted}>{DEFAULT_REPOS.length} available</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>discover featured skills</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Categories */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.text}>Categories</text>
|
||||
<text> </text>
|
||||
<box flexDirection="row" gap={2}>
|
||||
{CATEGORIES.map(cat => (
|
||||
<text key={cat.name} fg={terminalColors.textMuted}>
|
||||
{cat.name} ({cat.count})
|
||||
</text>
|
||||
))}
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Featured section */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Featured · <text fg={terminalColors.textMuted}>trending</text></text>
|
||||
<text> </text>
|
||||
|
||||
{visibleFeatured.map((item, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
// Use single text element to avoid rendering overlap
|
||||
const line = `${indicator}${item.name} ★${item.stars}`;
|
||||
return (
|
||||
<text key={item.source} fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{line}
|
||||
</text>
|
||||
);
|
||||
})}
|
||||
|
||||
{featured.length > maxVisible && (
|
||||
<Spinner label="Loading marketplace skills..." />
|
||||
<Show when={loadedRepos().length > 0}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\n'}+{featured.length - maxVisible} more
|
||||
Loaded: {loadedRepos().join(', ')}
|
||||
</text>
|
||||
)}
|
||||
<text> </text>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
<Show when={!loading() && !error()}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.success}>
|
||||
● {loadedRepos().length} repos
|
||||
</text>
|
||||
<Show when={failedRepos().length > 0}>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
<text fg={terminalColors.warning}>
|
||||
○ {failedRepos().length} failed
|
||||
</text>
|
||||
</Show>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
<text fg={terminalColors.text}>{allSkills().length} skills</text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>Categories: </text>
|
||||
<For each={CATEGORIES}>
|
||||
{(cat, idx) => (
|
||||
<text
|
||||
fg={
|
||||
selectedCategory() === cat.tag
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
[{idx() + 1}]{cat.name}{' '}
|
||||
</text>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={filteredSkills().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="★"
|
||||
title="No skills found"
|
||||
description={
|
||||
searchQuery() || selectedCategory()
|
||||
? 'Try a different search or category'
|
||||
: 'No skills loaded yet'
|
||||
}
|
||||
action={{ label: 'Clear Filter', key: 'Esc' }}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>
|
||||
{selectedCategory() ? `${selectedCategory()} Skills` : 'Featured Skills'}
|
||||
</b>{' '}
|
||||
<text fg={terminalColors.textMuted}>
|
||||
({filteredSkills().length} results)
|
||||
</text>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={skillsWindow().start > 0}>
|
||||
<text fg={terminalColors.textMuted}> ▲ {skillsWindow().start} more</text>
|
||||
</Show>
|
||||
<For each={skillsWindow().items}>
|
||||
{(skill, idx) => {
|
||||
const originalIndex = () => skillsWindow().start + idx();
|
||||
const isSelected = () => originalIndex() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text
|
||||
fg={isSelected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{isSelected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={isSelected() ? terminalColors.accent : terminalColors.text}
|
||||
width={25}
|
||||
>
|
||||
{skill.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{skill.repoName}
|
||||
</text>
|
||||
</box>
|
||||
<Show when={skill.description}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{skill.description?.slice(0, 50)}
|
||||
{(skill.description?.length || 0) > 50 ? '...' : ''}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={skillsWindow().start + maxVisible() < filteredSkills().length}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
▼ {filteredSkills().length - skillsWindow().start - maxVisible()} more
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter install 1-5 category b browse r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
/**
|
||||
* Memory Screen
|
||||
* Session memory management
|
||||
*/
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import {
|
||||
loadMemories,
|
||||
deleteMemoryEntry,
|
||||
clearMemory,
|
||||
initializeMemory,
|
||||
type MemoryServiceState,
|
||||
type MemoryEntry,
|
||||
} from '../services/memory.service.js';
|
||||
|
||||
interface MemoryProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -12,38 +21,268 @@ interface MemoryProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Memory({ onNavigate, cols = 80, rows = 24 }: MemoryProps) {
|
||||
const memories = [
|
||||
{ key: 'project-context', size: '2.4 KB', updated: '2 min ago' },
|
||||
{ key: 'user-preferences', size: '1.1 KB', updated: '5 min ago' },
|
||||
{ key: 'session-history', size: '4.7 KB', updated: '1 min ago' },
|
||||
];
|
||||
export function Memory(props: MemoryProps) {
|
||||
const [state, setState] = createSignal<MemoryServiceState>({
|
||||
entries: [],
|
||||
status: null,
|
||||
paths: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadMemories();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load memories',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
const entries = state().entries;
|
||||
if (entries.length === 0) return;
|
||||
|
||||
const entry = entries[selectedIndex()];
|
||||
if (!entry) return;
|
||||
|
||||
try {
|
||||
const success = await deleteMemoryEntry(entry.key);
|
||||
if (success) {
|
||||
loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to delete entry',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearAll = async () => {
|
||||
try {
|
||||
const success = await clearMemory(undefined, 'all');
|
||||
if (success) {
|
||||
loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to clear memory',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleInitialize = async () => {
|
||||
try {
|
||||
const success = await initializeMemory();
|
||||
if (success) {
|
||||
loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to initialize memory',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeIcon = (type: MemoryEntry['type']): string => {
|
||||
switch (type) {
|
||||
case 'index':
|
||||
return '◈';
|
||||
case 'learning':
|
||||
return '◇';
|
||||
case 'observation':
|
||||
return '○';
|
||||
default:
|
||||
return '•';
|
||||
}
|
||||
};
|
||||
|
||||
const selectedEntry = () => {
|
||||
const entries = state().entries;
|
||||
if (entries.length === 0) return null;
|
||||
return entries[selectedIndex()];
|
||||
};
|
||||
|
||||
const detailFields = () => {
|
||||
const entry = selectedEntry();
|
||||
if (!entry) return [];
|
||||
|
||||
return [
|
||||
{ label: 'Key', value: entry.key },
|
||||
{ label: 'Type', value: entry.type },
|
||||
{ label: 'Size', value: entry.size },
|
||||
{ label: 'Updated', value: entry.updated },
|
||||
];
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
const entries = state().entries;
|
||||
const maxIndex = Math.max(0, entries.length - 1);
|
||||
|
||||
if (key.name === 'j' || key.name === 'down') {
|
||||
setSelectedIndex((prev) => Math.min(prev + 1, maxIndex));
|
||||
} else if (key.name === 'k' || key.name === 'up') {
|
||||
setSelectedIndex((prev) => Math.max(prev - 1, 0));
|
||||
} else if (key.name === 'return') {
|
||||
if (entries.length > 0) {
|
||||
setShowDetail(true);
|
||||
}
|
||||
} else if (key.name === 'd') {
|
||||
handleDelete();
|
||||
} else if (key.name === 'c') {
|
||||
handleClearAll();
|
||||
} else if (key.name === 'i') {
|
||||
handleInitialize();
|
||||
} else if (key.name === 'r') {
|
||||
loadData();
|
||||
} else if (key.name === 'escape') {
|
||||
if (showDetail()) {
|
||||
setShowDetail(false);
|
||||
} else {
|
||||
props.onNavigate('home');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Memory"
|
||||
subtitle="Manage persistent session memory"
|
||||
count={memories.length}
|
||||
icon="◎"
|
||||
count={state().entries.length}
|
||||
icon="◎"
|
||||
/>
|
||||
|
||||
<text fg={terminalColors.text}><b>Stored Memories</b></text>
|
||||
<text> </text>
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
{memories.map((mem, idx) => (
|
||||
<box key={mem.key} flexDirection="row" marginBottom={1}>
|
||||
<text fg={idx === 0 ? terminalColors.accent : terminalColors.text} width={25}>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{mem.key}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>{mem.size}</text>
|
||||
<text fg={terminalColors.textMuted}>{mem.updated}</text>
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading memories..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<Show when={state().status}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>Status: </text>
|
||||
<text
|
||||
fg={
|
||||
state().status?.projectMemoryExists || state().status?.globalMemoryExists
|
||||
? terminalColors.success
|
||||
: terminalColors.warning
|
||||
}
|
||||
>
|
||||
{state().status?.projectMemoryExists ? 'Project ✓' : 'Project ✗'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
<text
|
||||
fg={state().status?.globalMemoryExists ? terminalColors.success : terminalColors.warning}
|
||||
>
|
||||
{state().status?.globalMemoryExists ? 'Global ✓' : 'Global ✗'}
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={state().entries.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="◎"
|
||||
title="No memories stored"
|
||||
description="Memory will be created as you use skills"
|
||||
action={{ label: 'Initialize', key: 'i' }}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}><b>Stored Memories</b></text>
|
||||
<text> </text>
|
||||
|
||||
<For each={state().entries}>
|
||||
{(mem, idx) => (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx() === selectedIndex() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{idx() === selectedIndex() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={idx() === selectedIndex() ? terminalColors.accent : terminalColors.text}
|
||||
>
|
||||
{getTypeIcon(mem.type)}{' '}
|
||||
</text>
|
||||
<text
|
||||
fg={idx() === selectedIndex() ? terminalColors.accent : terminalColors.text}
|
||||
width={20}
|
||||
>
|
||||
{mem.key}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>
|
||||
{mem.size}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{mem.updated}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail() && selectedEntry()}>
|
||||
<DetailPane
|
||||
title={selectedEntry()!.key}
|
||||
icon={getTypeIcon(selectedEntry()!.type)}
|
||||
fields={detailFields()}
|
||||
actions={[
|
||||
{ key: 'd', label: 'Delete' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={30}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</box>
|
||||
))}
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={state().paths}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Project: {state().paths?.projectMemoryDir || 'Not initialized'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Global: {state().paths?.globalMemoryDir || 'Not initialized'}
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to view, 'd' to delete, 'c' to clear all
|
||||
j/k navigate Enter view d delete c clear all i init Esc back
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* Mesh Screen
|
||||
* Mesh network and peer management
|
||||
*/
|
||||
import { For } from 'solid-js';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
@@ -12,7 +9,7 @@ interface MeshProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Mesh({ onNavigate, cols = 80, rows = 24 }: MeshProps) {
|
||||
export function Mesh(props: MeshProps) {
|
||||
const hosts = [
|
||||
{ name: 'workstation-1', address: '192.168.1.10', status: 'online', peers: 3 },
|
||||
{ name: 'laptop-dev', address: '192.168.1.15', status: 'online', peers: 2 },
|
||||
@@ -37,7 +34,7 @@ export function Mesh({ onNavigate, cols = 80, rows = 24 }: MeshProps) {
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.text}><b>Security: </b></text>
|
||||
<text fg={securityStatus.initialized ? terminalColors.success : terminalColors.warning}>
|
||||
{securityStatus.initialized ? '● Initialized' : '○ Not initialized'}
|
||||
{securityStatus.initialized ? '* Initialized' : 'o Not initialized'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}> Fingerprint: {securityStatus.fingerprint}</text>
|
||||
</box>
|
||||
@@ -45,18 +42,20 @@ export function Mesh({ onNavigate, cols = 80, rows = 24 }: MeshProps) {
|
||||
<text fg={terminalColors.text}><b>Known Hosts</b></text>
|
||||
<text> </text>
|
||||
|
||||
{hosts.map((host, idx) => (
|
||||
<box key={host.name} flexDirection="row" marginBottom={1}>
|
||||
<text fg={host.status === 'online' ? terminalColors.success : terminalColors.textMuted} width={3}>
|
||||
{host.status === 'online' ? '●' : '○'}
|
||||
</text>
|
||||
<text fg={idx === 0 ? terminalColors.accent : terminalColors.text} width={20}>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{host.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={18}>{host.address}</text>
|
||||
<text fg={terminalColors.textMuted}>{host.peers} peers</text>
|
||||
</box>
|
||||
))}
|
||||
<For each={hosts}>
|
||||
{(host, idx) => (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={host.status === 'online' ? terminalColors.success : terminalColors.textMuted} width={3}>
|
||||
{host.status === 'online' ? '*' : 'o'}
|
||||
</text>
|
||||
<text fg={idx() === 0 ? terminalColors.accent : terminalColors.text} width={20}>
|
||||
{idx() === 0 ? '\u25B8 ' : ' '}{host.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={18}>{host.address}</text>
|
||||
<text fg={terminalColors.textMuted}>{host.peers} peers</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
/**
|
||||
* Message Screen
|
||||
* Inter-agent messaging
|
||||
*/
|
||||
import { For } from 'solid-js';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
@@ -12,7 +9,7 @@ interface MessageProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Message({ onNavigate, cols = 80, rows = 24 }: MessageProps) {
|
||||
export function Message(props: MessageProps) {
|
||||
const messages = [
|
||||
{ id: '1', from: 'claude@laptop', subject: 'Code review completed', time: '2 min ago', unread: true },
|
||||
{ id: '2', from: 'cursor@workstation', subject: 'Build artifacts ready', time: '15 min ago', unread: true },
|
||||
@@ -37,20 +34,22 @@ export function Message({ onNavigate, cols = 80, rows = 24 }: MessageProps) {
|
||||
|
||||
<text> </text>
|
||||
|
||||
{messages.map((msg, idx) => (
|
||||
<box key={msg.id} flexDirection="row" marginBottom={1}>
|
||||
<text fg={msg.unread ? terminalColors.accent : terminalColors.textMuted} width={3}>
|
||||
{msg.unread ? '●' : '○'}
|
||||
</text>
|
||||
<text fg={idx === 0 ? terminalColors.accent : terminalColors.text} width={22}>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{msg.from}
|
||||
</text>
|
||||
<text fg={msg.unread ? terminalColors.text : terminalColors.textMuted} width={30}>
|
||||
{msg.subject.slice(0, 28)}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{msg.time}</text>
|
||||
</box>
|
||||
))}
|
||||
<For each={messages}>
|
||||
{(msg, idx) => (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={msg.unread ? terminalColors.accent : terminalColors.textMuted} width={3}>
|
||||
{msg.unread ? '*' : 'o'}
|
||||
</text>
|
||||
<text fg={idx() === 0 ? terminalColors.accent : terminalColors.text} width={22}>
|
||||
{idx() === 0 ? '\u25B8 ' : ' '}{msg.from}
|
||||
</text>
|
||||
<text fg={msg.unread ? terminalColors.text : terminalColors.textMuted} width={30}>
|
||||
{msg.subject.slice(0, 28)}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{msg.time}</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
/**
|
||||
* Methodology Screen
|
||||
* Development methodology packs
|
||||
*/
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadMethodologies,
|
||||
installMethodologyPack,
|
||||
uninstallMethodologyPack,
|
||||
syncMethodologyPack,
|
||||
type MethodologyServiceState,
|
||||
type MethodologyPackDisplay,
|
||||
} from '../services/methodology.service.js';
|
||||
|
||||
interface MethodologyProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -12,48 +22,304 @@ interface MethodologyProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Methodology({ onNavigate, cols = 80, rows = 24 }: MethodologyProps) {
|
||||
const methodologies = [
|
||||
{ name: 'TDD', description: 'Test-Driven Development', skills: 5, active: true },
|
||||
{ name: 'BDD', description: 'Behavior-Driven Development', skills: 4, active: false },
|
||||
{ name: 'Clean Code', description: 'SOLID principles', skills: 6, active: false },
|
||||
{ name: 'Security First', description: 'OWASP guidelines', skills: 8, active: false },
|
||||
];
|
||||
export function Methodology(props: MethodologyProps) {
|
||||
const [state, setState] = createSignal<MethodologyServiceState>({
|
||||
packs: [],
|
||||
installedPacks: [],
|
||||
manager: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
const [installing, setInstalling] = createSignal(false);
|
||||
const [syncing, setSyncing] = createSignal(false);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadMethodologies();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load methodologies',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleInstall = async () => {
|
||||
const packs = state().packs;
|
||||
if (packs.length === 0 || installing()) return;
|
||||
|
||||
const pack = packs[selectedIndex()];
|
||||
if (!pack || pack.installed) return;
|
||||
|
||||
setInstalling(true);
|
||||
try {
|
||||
const result = await installMethodologyPack(pack.name);
|
||||
if (result) {
|
||||
await loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to install pack',
|
||||
}));
|
||||
} finally {
|
||||
setInstalling(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUninstall = async () => {
|
||||
const packs = state().packs;
|
||||
if (packs.length === 0 || installing()) return;
|
||||
|
||||
const pack = packs[selectedIndex()];
|
||||
if (!pack || !pack.installed) return;
|
||||
|
||||
setInstalling(true);
|
||||
try {
|
||||
const success = await uninstallMethodologyPack(pack.name);
|
||||
if (success) {
|
||||
await loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to uninstall pack',
|
||||
}));
|
||||
} finally {
|
||||
setInstalling(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSync = async () => {
|
||||
const packs = state().packs;
|
||||
if (packs.length === 0 || syncing()) return;
|
||||
|
||||
const pack = packs[selectedIndex()];
|
||||
if (!pack || !pack.installed) return;
|
||||
|
||||
setSyncing(true);
|
||||
try {
|
||||
const result = await syncMethodologyPack(pack.name);
|
||||
if (result) {
|
||||
await loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to sync pack',
|
||||
}));
|
||||
} finally {
|
||||
setSyncing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = state().packs.length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') setShowDetail(true);
|
||||
else if (key.name === 'i') handleInstall();
|
||||
else if (key.name === 'u') handleUninstall();
|
||||
else if (key.name === 's') handleSync();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') {
|
||||
if (showDetail()) setShowDetail(false);
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
});
|
||||
|
||||
const getStatusIcon = (status: MethodologyPackDisplay['status']): string => {
|
||||
switch (status) {
|
||||
case 'synced':
|
||||
return '✓';
|
||||
case 'installed':
|
||||
return '●';
|
||||
default:
|
||||
return '○';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: MethodologyPackDisplay['status']): string => {
|
||||
switch (status) {
|
||||
case 'synced':
|
||||
return terminalColors.success;
|
||||
case 'installed':
|
||||
return terminalColors.accent;
|
||||
default:
|
||||
return terminalColors.textMuted;
|
||||
}
|
||||
};
|
||||
|
||||
const selectedPack = () => {
|
||||
const packs = state().packs;
|
||||
if (packs.length === 0) return null;
|
||||
return packs[selectedIndex()];
|
||||
};
|
||||
|
||||
const detailFields = () => {
|
||||
const pack = selectedPack();
|
||||
if (!pack) return [];
|
||||
|
||||
return [
|
||||
{ label: 'Name', value: pack.name },
|
||||
{ label: 'Version', value: pack.version },
|
||||
{ label: 'Description', value: pack.description || 'No description' },
|
||||
{ label: 'Skills', value: String(pack.skills) },
|
||||
{ label: 'Tags', value: pack.tags.join(', ') || 'None' },
|
||||
{ label: 'Status', value: pack.status },
|
||||
];
|
||||
};
|
||||
|
||||
const installedCount = () => state().packs.filter((p) => p.installed).length;
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Methodologies"
|
||||
subtitle="Development methodology skill packs"
|
||||
count={methodologies.length}
|
||||
icon="◎"
|
||||
count={state().packs.length}
|
||||
icon="◎"
|
||||
/>
|
||||
|
||||
<text fg={terminalColors.text}><b>Available Packs</b></text>
|
||||
<text> </text>
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
{methodologies.map((meth, idx) => (
|
||||
<box key={meth.name} flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={15}
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading methodologies..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>Installed: </text>
|
||||
<text fg={terminalColors.success}>{installedCount()}</text>
|
||||
<text fg={terminalColors.textMuted}> / </text>
|
||||
<text fg={terminalColors.text}>{state().packs.length}</text>
|
||||
<text fg={terminalColors.textMuted}> packs</text>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={state().packs.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="◎"
|
||||
title="No methodology packs found"
|
||||
description="Check .skillkit/methodology/packs/"
|
||||
/>
|
||||
}
|
||||
>
|
||||
{idx === 0 ? <b>{'\u25B8 '}{meth.name}</b> : <>{'\u25B8 '}{meth.name}</>}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{meth.skills} skills</text>
|
||||
{meth.active && (
|
||||
<text fg={terminalColors.success}> [active]</text>
|
||||
)}
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> {meth.description}</text>
|
||||
</box>
|
||||
))}
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Available Packs</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to activate, 'v' to view skills
|
||||
</text>
|
||||
<For each={state().packs}>
|
||||
{(pack, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={20}
|
||||
>
|
||||
{pack.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={8}>
|
||||
v{pack.version}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>
|
||||
{pack.skills} skills
|
||||
</text>
|
||||
<text fg={getStatusColor(pack.status)}>
|
||||
{getStatusIcon(pack.status)} {pack.status}
|
||||
</text>
|
||||
</box>
|
||||
<Show when={pack.description}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{pack.description.slice(0, 45)}
|
||||
{pack.description.length > 45 ? '...' : ''}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
<Show when={installing()}>
|
||||
<text> </text>
|
||||
<StatusIndicator
|
||||
status="loading"
|
||||
label={selectedPack()?.installed ? 'Uninstalling...' : 'Installing...'}
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={syncing()}>
|
||||
<text> </text>
|
||||
<StatusIndicator status="loading" label="Syncing to agents..." />
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail() && selectedPack()}>
|
||||
<DetailPane
|
||||
title={selectedPack()!.name}
|
||||
subtitle={`v${selectedPack()!.version}`}
|
||||
icon="◎"
|
||||
fields={detailFields()}
|
||||
actions={
|
||||
selectedPack()!.installed
|
||||
? [
|
||||
{ key: 's', label: 'Sync' },
|
||||
{ key: 'u', label: 'Uninstall' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]
|
||||
: [
|
||||
{ key: 'i', label: 'Install' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]
|
||||
}
|
||||
width={35}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter details i install u uninstall s sync r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
/**
|
||||
* Plan Screen
|
||||
* Structured plan execution
|
||||
*/
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { ProgressBar } from '../components/ProgressBar.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadPlansList,
|
||||
loadPlan,
|
||||
validatePlan,
|
||||
executePlan,
|
||||
executePlanDryRun,
|
||||
type PlanServiceState,
|
||||
type PlanListItem,
|
||||
} from '../services/plan.service.js';
|
||||
|
||||
interface PlanProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -13,58 +23,274 @@ interface PlanProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Plan({ onNavigate, cols = 80, rows = 24 }: PlanProps) {
|
||||
const steps = [
|
||||
{ name: 'Analyze codebase', status: 'done', duration: '2.3s' },
|
||||
{ name: 'Generate tests', status: 'done', duration: '5.1s' },
|
||||
{ name: 'Run linter', status: 'running', duration: '-' },
|
||||
{ name: 'Apply fixes', status: 'pending', duration: '-' },
|
||||
{ name: 'Verify changes', status: 'pending', duration: '-' },
|
||||
];
|
||||
export function Plan(props: PlanProps) {
|
||||
const [state, setState] = createSignal<PlanServiceState>({
|
||||
plans: [],
|
||||
current: null,
|
||||
validation: null,
|
||||
execution: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [executionProgress, setExecutionProgress] = createSignal(0);
|
||||
const [executing, setExecuting] = createSignal(false);
|
||||
const [validating, setValidating] = createSignal(false);
|
||||
|
||||
const completedSteps = steps.filter((s) => s.status === 'done').length;
|
||||
const progress = (completedSteps / steps.length) * 100;
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadPlansList();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load plans',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleValidate = async () => {
|
||||
const plans = state().plans;
|
||||
if (plans.length === 0 || validating()) return;
|
||||
|
||||
const planItem = plans[selectedIndex()];
|
||||
if (!planItem) return;
|
||||
|
||||
setValidating(true);
|
||||
try {
|
||||
const plan = await loadPlan(planItem.path);
|
||||
if (plan) {
|
||||
const validation = await validatePlan(plan);
|
||||
setState((s) => ({ ...s, current: plan, validation }));
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Validation failed',
|
||||
}));
|
||||
} finally {
|
||||
setValidating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleExecute = async (dryRun: boolean = false) => {
|
||||
const plans = state().plans;
|
||||
if (plans.length === 0 || executing()) return;
|
||||
|
||||
const planItem = plans[selectedIndex()];
|
||||
if (!planItem) return;
|
||||
|
||||
setExecuting(true);
|
||||
setExecutionProgress(0);
|
||||
|
||||
try {
|
||||
const plan = await loadPlan(planItem.path);
|
||||
if (!plan) {
|
||||
setExecuting(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const executeFn = dryRun ? executePlanDryRun : executePlan;
|
||||
let completedCount = 0;
|
||||
const totalTasks = plan.tasks?.length || 0;
|
||||
const result = await executeFn(plan, undefined, (event) => {
|
||||
if (event === 'plan:task_completed') {
|
||||
completedCount++;
|
||||
setExecutionProgress(totalTasks > 0 ? (completedCount / totalTasks) * 100 : 100);
|
||||
}
|
||||
});
|
||||
|
||||
setState((s) => ({ ...s, execution: result }));
|
||||
loadData();
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Execution failed',
|
||||
}));
|
||||
} finally {
|
||||
setExecuting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = state().plans.length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'v') handleValidate();
|
||||
else if (key.name === 'x') handleExecute(false);
|
||||
else if (key.name === 'd') handleExecute(true);
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
const getStatusIcon = (status: PlanListItem['status']): string => {
|
||||
switch (status) {
|
||||
case 'completed':
|
||||
return '✓';
|
||||
case 'failed':
|
||||
return '✗';
|
||||
case 'in_progress':
|
||||
return '⟳';
|
||||
default:
|
||||
return '○';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: PlanListItem['status']): string => {
|
||||
switch (status) {
|
||||
case 'completed':
|
||||
return terminalColors.success;
|
||||
case 'failed':
|
||||
return terminalColors.error;
|
||||
case 'in_progress':
|
||||
return terminalColors.accent;
|
||||
default:
|
||||
return terminalColors.textMuted;
|
||||
}
|
||||
};
|
||||
|
||||
const selectedPlan = () => {
|
||||
const plans = state().plans;
|
||||
if (plans.length === 0) return null;
|
||||
return plans[selectedIndex()];
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Plan Execution"
|
||||
subtitle="Structured multi-step execution"
|
||||
icon="▣"
|
||||
icon="▣"
|
||||
count={state().plans.length}
|
||||
/>
|
||||
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.text}>Progress: </text>
|
||||
<ProgressBar progress={progress} width={30} />
|
||||
</box>
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<text fg={terminalColors.text}><b>Steps</b></text>
|
||||
<text> </text>
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading plans..." />
|
||||
</Show>
|
||||
|
||||
{steps.map((step, idx) => {
|
||||
const statusIcon = step.status === 'done' ? '\u2713' : step.status === 'running' ? '\u27F3' : '\u25CB';
|
||||
const statusColor =
|
||||
step.status === 'done'
|
||||
? terminalColors.success
|
||||
: step.status === 'running'
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted;
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<Show
|
||||
when={state().plans.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="▣"
|
||||
title="No plans found"
|
||||
description="Create plans in .skillkit/plans/"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Available Plans</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
return (
|
||||
<box key={step.name} flexDirection="row" marginBottom={1}>
|
||||
<text fg={statusColor} width={3}>{statusIcon}</text>
|
||||
<text fg={step.status === 'pending' ? terminalColors.textMuted : terminalColors.text} width={25}>
|
||||
{step.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{step.duration}</text>
|
||||
<For each={state().plans}>
|
||||
{(plan, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={25}
|
||||
>
|
||||
{plan.name}
|
||||
</text>
|
||||
<text fg={getStatusColor(plan.status)} width={3}>
|
||||
{getStatusIcon(plan.status)}{' '}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>
|
||||
{plan.tasks} tasks
|
||||
</text>
|
||||
<Show when={plan.lastModified}>
|
||||
<text fg={terminalColors.textMuted}> • {plan.lastModified}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
<Show when={validating()}>
|
||||
<text> </text>
|
||||
<StatusIndicator status="loading" label="Validating plan..." />
|
||||
</Show>
|
||||
|
||||
<Show when={state().validation && !validating()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Validation Result</b>
|
||||
</text>
|
||||
<text
|
||||
fg={state().validation!.valid ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{state().validation!.valid ? '✓ Valid' : '✗ Invalid'}
|
||||
</text>
|
||||
<Show when={state().validation!.issues && state().validation!.issues!.length > 0}>
|
||||
<For each={state().validation!.issues!.slice(0, 3)}>
|
||||
{(issue) => (
|
||||
<text fg={terminalColors.warning}>• {issue.message}</text>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<Show when={executing()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<StatusIndicator status="loading" label="Executing plan..." />
|
||||
<box flexDirection="row" marginTop={1}>
|
||||
<text fg={terminalColors.text}>Progress: </text>
|
||||
<ProgressBar progress={executionProgress()} width={30} />
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to continue, Esc to cancel
|
||||
</text>
|
||||
<Show when={state().execution && !executing()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Execution Result</b>
|
||||
</text>
|
||||
<text
|
||||
fg={state().execution!.success ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{state().execution!.success ? '✓ Completed' : '✗ Failed'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Completed: {state().execution!.completedTasks.length} | Failed: {state().execution!.failedTasks.length}
|
||||
</text>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate v validate x execute d dry-run r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
/**
|
||||
* Plugins Screen
|
||||
* Plugin management
|
||||
*/
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadPluginsList,
|
||||
enablePlugin,
|
||||
disablePlugin,
|
||||
getPluginInfo,
|
||||
type PluginServiceState,
|
||||
type PluginListItem,
|
||||
} from '../services/plugin.service.js';
|
||||
import type { PluginManager, Plugin } from '@skillkit/core';
|
||||
|
||||
interface PluginsProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -12,46 +23,256 @@ interface PluginsProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Plugins({ onNavigate, cols = 80, rows = 24 }: PluginsProps) {
|
||||
const plugins = [
|
||||
{ name: 'git-hooks', enabled: true, version: '1.2.0' },
|
||||
{ name: 'ai-suggest', enabled: true, version: '0.9.1' },
|
||||
{ name: 'metrics', enabled: false, version: '2.0.0' },
|
||||
];
|
||||
export function Plugins(props: PluginsProps) {
|
||||
const [state, setState] = createSignal<PluginServiceState>({
|
||||
plugins: [],
|
||||
manager: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
const [selectedPlugin, setSelectedPlugin] = createSignal<Plugin | null>(null);
|
||||
const [toggling, setToggling] = createSignal(false);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadPluginsList();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load plugins',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggle = async () => {
|
||||
const plugins = state().plugins;
|
||||
const manager = state().manager;
|
||||
if (plugins.length === 0 || !manager) return;
|
||||
|
||||
const plugin = plugins[selectedIndex()];
|
||||
if (!plugin) return;
|
||||
|
||||
setToggling(true);
|
||||
|
||||
try {
|
||||
if (plugin.enabled) {
|
||||
await disablePlugin(plugin.name, manager);
|
||||
} else {
|
||||
await enablePlugin(plugin.name, manager);
|
||||
}
|
||||
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to toggle plugin',
|
||||
}));
|
||||
} finally {
|
||||
setToggling(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleShowDetail = async () => {
|
||||
const plugins = state().plugins;
|
||||
const manager = state().manager;
|
||||
if (plugins.length === 0 || !manager) return;
|
||||
|
||||
const plugin = plugins[selectedIndex()];
|
||||
if (!plugin) return;
|
||||
|
||||
try {
|
||||
const info = await getPluginInfo(plugin.name, manager);
|
||||
setSelectedPlugin(info as Plugin | null);
|
||||
setShowDetail(true);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to load plugin details',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = state().plugins.length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleShowDetail();
|
||||
else if (key.name === 'space' || key.name === 't') handleToggle();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') {
|
||||
if (showDetail()) setShowDetail(false);
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
});
|
||||
|
||||
const getTypeIcon = (type: PluginListItem['type']): string => {
|
||||
switch (type) {
|
||||
case 'translator':
|
||||
return '⇄';
|
||||
case 'provider':
|
||||
return '◆';
|
||||
case 'command':
|
||||
return '⌘';
|
||||
default:
|
||||
return '◈';
|
||||
}
|
||||
};
|
||||
|
||||
const currentPlugin = () => {
|
||||
const plugins = state().plugins;
|
||||
if (plugins.length === 0) return null;
|
||||
return plugins[selectedIndex()];
|
||||
};
|
||||
|
||||
const detailFields = () => {
|
||||
const plugin = selectedPlugin();
|
||||
if (!plugin) return [];
|
||||
|
||||
const current = currentPlugin();
|
||||
return [
|
||||
{ label: 'Name', value: plugin.metadata.name },
|
||||
{ label: 'Version', value: plugin.metadata.version },
|
||||
{ label: 'Description', value: plugin.metadata.description || 'No description' },
|
||||
{ label: 'Type', value: current?.type || 'unknown' },
|
||||
{ label: 'Status', value: current?.enabled ? 'Enabled' : 'Disabled' },
|
||||
{ label: 'Path', value: current?.path || 'N/A' },
|
||||
];
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Plugins"
|
||||
subtitle="Extend SkillKit with plugins"
|
||||
count={plugins.length}
|
||||
icon="◈"
|
||||
count={state().plugins.length}
|
||||
icon="◈"
|
||||
/>
|
||||
|
||||
<text fg={terminalColors.text}><b>Installed Plugins</b></text>
|
||||
<text> </text>
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
{plugins.map((plugin, idx) => (
|
||||
<box key={plugin.name} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{plugin.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>v{plugin.version}</text>
|
||||
<text
|
||||
fg={plugin.enabled ? terminalColors.success : terminalColors.textMuted}
|
||||
>
|
||||
{plugin.enabled ? '\u25CF enabled' : '\u25CB disabled'}
|
||||
</text>
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading plugins..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<Show
|
||||
when={state().plugins.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="◈"
|
||||
title="No plugins installed"
|
||||
description="Install plugins from ~/.skillkit/plugins/"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Installed Plugins</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<For each={state().plugins}>
|
||||
{(plugin, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.textSecondary}
|
||||
width={3}
|
||||
>
|
||||
{getTypeIcon(plugin.type)}{' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={20}
|
||||
>
|
||||
{plugin.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>
|
||||
v{plugin.version}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
plugin.enabled
|
||||
? terminalColors.success
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
{plugin.enabled ? '● enabled' : '○ disabled'}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
<Show when={toggling()}>
|
||||
<text> </text>
|
||||
<StatusIndicator status="loading" label="Toggling plugin..." />
|
||||
</Show>
|
||||
|
||||
<Show when={currentPlugin() && !toggling()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{currentPlugin()!.description || 'No description available'}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail() && selectedPlugin()}>
|
||||
<DetailPane
|
||||
title={selectedPlugin()!.metadata.name}
|
||||
subtitle={`v${selectedPlugin()!.metadata.version}`}
|
||||
icon={getTypeIcon(currentPlugin()?.type || 'mixed')}
|
||||
fields={detailFields()}
|
||||
actions={[
|
||||
{
|
||||
key: 't',
|
||||
label: currentPlugin()?.enabled ? 'Disable' : 'Enable',
|
||||
},
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={35}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</box>
|
||||
))}
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press Enter to toggle, 'a' to add new, 'u' to update
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter details Space toggle r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import {
|
||||
getRecommendations,
|
||||
analyzeProject,
|
||||
type RecommendServiceState,
|
||||
type RecommendationDisplay,
|
||||
} from '../services/recommend.service.js';
|
||||
|
||||
interface RecommendProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -9,193 +20,281 @@ interface RecommendProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
export function Recommend(props: RecommendProps) {
|
||||
const [state, setState] = createSignal<RecommendServiceState>({
|
||||
recommendations: [],
|
||||
analyzing: false,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
const [projectInfo, setProjectInfo] = createSignal<{
|
||||
languages: string[];
|
||||
frameworks: string[];
|
||||
} | null>(null);
|
||||
|
||||
export function Recommend({ onNavigate, cols = 80, rows = 24 }: RecommendProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [analyzing, setAnalyzing] = useState(true);
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const [analysisProgress, setAnalysisProgress] = useState(0);
|
||||
const rows = () => props.rows ?? 24;
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (animPhase >= 3) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, analyzing: true, error: null }));
|
||||
|
||||
useEffect(() => {
|
||||
if (!analyzing) return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [analyzing]);
|
||||
try {
|
||||
const analysis = await analyzeProject();
|
||||
if (analysis) {
|
||||
setProjectInfo({
|
||||
languages: analysis.languages,
|
||||
frameworks: analysis.frameworks,
|
||||
});
|
||||
}
|
||||
|
||||
// Simulate analysis
|
||||
useEffect(() => {
|
||||
if (!analyzing) return;
|
||||
const interval = setInterval(() => {
|
||||
setAnalysisProgress(p => {
|
||||
if (p >= 100) {
|
||||
setAnalyzing(false);
|
||||
return 100;
|
||||
}
|
||||
return p + Math.random() * 15 + 5;
|
||||
});
|
||||
}, 200);
|
||||
return () => clearInterval(interval);
|
||||
}, [analyzing]);
|
||||
const result = await getRecommendations();
|
||||
setState(result);
|
||||
|
||||
// Recommendations data (with quality scores)
|
||||
const recommendations = useMemo(() => [
|
||||
{ name: 'tdd-workflow', reason: 'Based on your test files and coverage patterns', confidence: 95, quality: 92, grade: 'A' },
|
||||
{ name: 'react-patterns', reason: 'Detected React in package.json with hooks usage', confidence: 88, quality: 85, grade: 'B' },
|
||||
{ name: 'typescript-strict', reason: 'tsconfig.json found with strict mode disabled', confidence: 82, quality: 78, grade: 'C' },
|
||||
{ name: 'git-workflow', reason: '.git directory with complex branching detected', confidence: 75, quality: 82, grade: 'B' },
|
||||
{ name: 'api-design', reason: 'REST endpoints found in your codebase', confidence: 68, quality: 71, grade: 'C' },
|
||||
{ name: 'docker-compose', reason: 'docker-compose.yml detected for orchestration', confidence: 62, quality: 65, grade: 'D' },
|
||||
], []);
|
||||
|
||||
const maxVisible = Math.max(3, Math.floor((rows - 10) / 2));
|
||||
const visibleRecs = recommendations.slice(0, maxVisible);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, visibleRecs.length - 1)));
|
||||
}, [visibleRecs.length]);
|
||||
|
||||
const handleRefresh = useCallback(() => {
|
||||
setAnalyzing(true);
|
||||
setAnalysisProgress(0);
|
||||
setSelectedIndex(0);
|
||||
}, []);
|
||||
|
||||
const handleInstall = useCallback(() => {
|
||||
if (analyzing) return;
|
||||
const rec = visibleRecs[selectedIndex];
|
||||
if (rec) {
|
||||
// Navigate to installed after "installing"
|
||||
onNavigate('installed');
|
||||
const maxIndex = Math.max(0, result.recommendations.length - 1);
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev, maxIndex)));
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
analyzing: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load recommendations',
|
||||
}));
|
||||
}
|
||||
}, [analyzing, selectedIndex, visibleRecs, onNavigate]);
|
||||
};
|
||||
|
||||
const handleRefresh = async () => {
|
||||
loadData();
|
||||
};
|
||||
|
||||
const handleInstall = () => {
|
||||
const recs = state().recommendations;
|
||||
if (recs.length === 0) return;
|
||||
|
||||
const rec = recs[selectedIndex()];
|
||||
if (rec) {
|
||||
props.onNavigate('installed');
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = state().recommendations.length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleInstall();
|
||||
else if (key.name === 'r') handleRefresh();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
else if (key.name === 'return') {
|
||||
if (showDetail()) handleInstall();
|
||||
else setShowDetail(true);
|
||||
} else if (key.name === 'r') handleRefresh();
|
||||
else if (key.name === 'escape') {
|
||||
if (showDetail()) setShowDetail(false);
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
);
|
||||
|
||||
// Confidence color
|
||||
const getConfColor = (conf: number) => {
|
||||
if (conf >= 80) return terminalColors.success;
|
||||
if (conf >= 60) return terminalColors.recommend;
|
||||
const getScoreColor = (score: number): string => {
|
||||
if (score >= 80) return terminalColors.success;
|
||||
if (score >= 60) return terminalColors.accent;
|
||||
if (score >= 40) return terminalColors.warning;
|
||||
return terminalColors.textMuted;
|
||||
};
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter install r refresh esc back'
|
||||
: 'j/k navigate enter install r refresh esc back';
|
||||
const getGrade = (score: number): string => {
|
||||
if (score >= 90) return 'A';
|
||||
if (score >= 80) return 'B';
|
||||
if (score >= 70) return 'C';
|
||||
if (score >= 60) return 'D';
|
||||
return 'F';
|
||||
};
|
||||
|
||||
const selectedRec = () => {
|
||||
const recs = state().recommendations;
|
||||
if (recs.length === 0) return null;
|
||||
return recs[selectedIndex()];
|
||||
};
|
||||
|
||||
const detailFields = () => {
|
||||
const rec = selectedRec();
|
||||
if (!rec) return [];
|
||||
|
||||
return [
|
||||
{ label: 'Name', value: rec.name },
|
||||
{ label: 'Score', value: `${rec.score}%` },
|
||||
{ label: 'Source', value: rec.source },
|
||||
{ label: 'Tags', value: rec.tags.join(', ') || 'None' },
|
||||
{ label: 'Install', value: rec.installCommand || `skillkit install ${rec.name}` },
|
||||
];
|
||||
};
|
||||
|
||||
const maxVisible = () => Math.max(4, Math.floor((rows() - 12) / 3));
|
||||
|
||||
const recsWindow = createMemo(() => {
|
||||
const list = state().recommendations;
|
||||
const selected = selectedIndex();
|
||||
const visible = maxVisible();
|
||||
const total = list.length;
|
||||
if (total <= visible) return { start: 0, items: list };
|
||||
let start = Math.max(0, selected - Math.floor(visible / 2));
|
||||
start = Math.min(start, total - visible);
|
||||
return { start, items: list.slice(start, start + visible) };
|
||||
});
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Recommendations"
|
||||
subtitle="AI skill suggestions based on your project"
|
||||
icon="✦"
|
||||
count={state().recommendations.length}
|
||||
/>
|
||||
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={state().loading && state().analyzing}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.recommend}>◎ Recommendations</text>
|
||||
<Spinner label="Analyzing your project..." />
|
||||
<Show when={projectInfo()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{analyzing ? 'analyzing...' : `${recommendations.length} found`}
|
||||
Detected: {projectInfo()!.languages.slice(0, 3).join(', ')}
|
||||
{projectInfo()!.frameworks.length > 0
|
||||
? ` + ${projectInfo()!.frameworks.slice(0, 2).join(', ')}`
|
||||
: ''}
|
||||
</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>AI skill suggestions</text>
|
||||
<text> </text>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Analysis progress */}
|
||||
{animPhase >= 2 && analyzing && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Analyzing</text>
|
||||
<text fg={terminalColors.textMuted}> your project...</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Results summary */}
|
||||
{animPhase >= 2 && !analyzing && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.success}>✓ </text>
|
||||
<text fg={terminalColors.text}>Analysis complete</text>
|
||||
<text fg={terminalColors.textMuted}> · found {recommendations.length} matching skills</text>
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Recommendations list */}
|
||||
{animPhase >= 3 && !analyzing && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Suggested Skills</text>
|
||||
<text> </text>
|
||||
|
||||
{visibleRecs.map((rec, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const qualityColor = rec.quality >= 80 ? terminalColors.success : rec.quality >= 60 ? terminalColors.warning : terminalColors.error;
|
||||
return (
|
||||
<box key={rec.name} flexDirection="column">
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{rec.name}
|
||||
</text>
|
||||
<text fg={getConfColor(rec.confidence)}> {rec.confidence}%</text>
|
||||
<text fg={qualityColor}> [{rec.grade}]</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> {rec.reason}</text>
|
||||
<text> </text>
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<Show when={projectInfo()}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>Stack: </text>
|
||||
<text fg={terminalColors.accent}>
|
||||
{[
|
||||
...projectInfo()!.languages.slice(0, 2),
|
||||
...projectInfo()!.frameworks.slice(0, 2),
|
||||
].join(' • ')}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
</Show>
|
||||
|
||||
{recommendations.length > maxVisible && (
|
||||
<text fg={terminalColors.textMuted}>
|
||||
+{recommendations.length - maxVisible} more
|
||||
</text>
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 3 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
<Show
|
||||
when={state().recommendations.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="✦"
|
||||
title="No recommendations found"
|
||||
description="Try refreshing to analyze your project again"
|
||||
action={{ label: 'Refresh', key: 'r' }}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Suggested Skills</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={recsWindow().start > 0}>
|
||||
<text fg={terminalColors.textMuted}> ▲ {recsWindow().start} more</text>
|
||||
</Show>
|
||||
<For each={recsWindow().items}>
|
||||
{(rec, idx) => {
|
||||
const originalIndex = () => recsWindow().start + idx();
|
||||
const isSelected = () => originalIndex() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="column" marginBottom={1}>
|
||||
<box flexDirection="row">
|
||||
<text
|
||||
fg={isSelected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{isSelected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={isSelected() ? terminalColors.accent : terminalColors.text}
|
||||
width={25}
|
||||
>
|
||||
{rec.name}
|
||||
</text>
|
||||
<text fg={getScoreColor(rec.score)} width={6}>
|
||||
{rec.score}%
|
||||
</text>
|
||||
<text fg={getScoreColor(rec.score)} width={4}>
|
||||
[{getGrade(rec.score)}]
|
||||
</text>
|
||||
</box>
|
||||
<Show when={rec.reasons.length > 0}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{rec.reasons[0]}
|
||||
</text>
|
||||
</Show>
|
||||
<Show when={rec.description && rec.reasons.length === 0}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{' '}{rec.description.slice(0, 50)}
|
||||
{rec.description.length > 50 ? '...' : ''}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
|
||||
<Show when={recsWindow().start + maxVisible() < state().recommendations.length}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
▼ {state().recommendations.length - recsWindow().start - maxVisible()} more
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<Show when={state().lastAnalyzed}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Last analyzed: {new Date(state().lastAnalyzed!).toLocaleTimeString()}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail() && selectedRec()}>
|
||||
<DetailPane
|
||||
title={selectedRec()!.name}
|
||||
subtitle={`Score: ${selectedRec()!.score}%`}
|
||||
icon="✦"
|
||||
fields={detailFields()}
|
||||
actions={[
|
||||
{ key: 'Enter', label: 'Install' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={35}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter details/install r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { createSignal, createEffect, onCleanup, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
|
||||
@@ -24,117 +24,113 @@ const DEFAULT_SETTINGS: SettingItem[] = [
|
||||
{ key: 'telemetry', label: 'Telemetry', value: 'disabled', type: 'toggle' },
|
||||
];
|
||||
|
||||
export function Settings({ onNavigate, cols = 80 }: SettingsProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [settings, setSettings] = useState<SettingItem[]>(DEFAULT_SETTINGS);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
export function Settings(props: SettingsProps) {
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [settings, setSettings] = createSignal<SettingItem[]>(DEFAULT_SETTINGS);
|
||||
const [animPhase, setAnimPhase] = createSignal(0);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
const cols = () => props.cols ?? 80;
|
||||
const isCompact = () => cols() < 60;
|
||||
const contentWidth = () => Math.max(1, Math.min(cols() - 4, 60));
|
||||
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
createEffect(() => {
|
||||
if (animPhase() >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
onCleanup(() => clearTimeout(timer));
|
||||
});
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, settings.length - 1)));
|
||||
}, [settings.length]);
|
||||
const handleKeyNav = (delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, settings().length - 1)));
|
||||
};
|
||||
|
||||
const handleToggle = useCallback(() => {
|
||||
const setting = settings[selectedIndex];
|
||||
const handleToggle = () => {
|
||||
const setting = settings()[selectedIndex()];
|
||||
if (setting?.type === 'toggle') {
|
||||
setSettings(prev => prev.map((s, i) =>
|
||||
i === selectedIndex ? { ...s, value: s.value === 'enabled' ? 'disabled' : 'enabled' } : s
|
||||
i === selectedIndex() ? { ...s, value: s.value === 'enabled' ? 'disabled' : 'enabled' } : s
|
||||
));
|
||||
}
|
||||
}, [selectedIndex, settings]);
|
||||
};
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
const handleReset = () => {
|
||||
setSettings(DEFAULT_SETTINGS);
|
||||
}, []);
|
||||
};
|
||||
|
||||
const handleKeyboard = useCallback((key: { name?: string }) => {
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleToggle();
|
||||
else if (key.name === 'r') handleReset();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
}, [handleKeyNav, handleToggle, handleReset, onNavigate]);
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
useKeyboard(handleKeyboard);
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
const divider = createMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth())}</text>
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
const shortcuts = () => isCompact()
|
||||
? 'j/k nav enter toggle r reset esc back'
|
||||
: 'j/k navigate enter toggle r reset defaults esc back';
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<Show when={animPhase() >= 1}>
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.text}>⚙ Settings</text>
|
||||
<text fg={terminalColors.textMuted}>{settings.length} options</text>
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth()}>
|
||||
<text fg={terminalColors.text}>Settings</text>
|
||||
<text fg={terminalColors.textMuted}>{settings().length} options</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>configure skillkit</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Settings list */}
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
{divider()}
|
||||
<text> </text>
|
||||
<text fg={terminalColors.text}>Configuration</text>
|
||||
<text> </text>
|
||||
|
||||
{settings.map((setting, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const valueColor = setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? terminalColors.success : terminalColors.textMuted)
|
||||
: terminalColors.textMuted;
|
||||
const toggleIcon = setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? '● ' : '○ ')
|
||||
: '';
|
||||
return (
|
||||
<box key={setting.key} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text} width={18}>
|
||||
{setting.label}
|
||||
</text>
|
||||
<text fg={valueColor}>{toggleIcon}{setting.value}</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
<For each={settings()}>
|
||||
{(setting, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
const indicator = () => selected() ? '>' : ' ';
|
||||
const valueColor = () => setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? terminalColors.success : terminalColors.textMuted)
|
||||
: terminalColors.textMuted;
|
||||
const toggleIcon = () => setting.type === 'toggle'
|
||||
? (setting.value === 'enabled' ? '* ' : 'o ')
|
||||
: '';
|
||||
return (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator()}</text>
|
||||
<text fg={selected() ? terminalColors.accent : terminalColors.text} width={18}>
|
||||
{setting.label}
|
||||
</text>
|
||||
<text fg={valueColor()}>{toggleIcon()}{setting.value}</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Config location */}
|
||||
{animPhase >= 2 && !isCompact && (
|
||||
<Show when={animPhase() >= 2 && !isCompact()}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
{divider()}
|
||||
<text fg={terminalColors.textMuted}>config: ~/.config/skillkit/config.json</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<Show when={animPhase() >= 2}>
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
{divider()}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts()}</text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
+245
-142
@@ -1,12 +1,15 @@
|
||||
/**
|
||||
* Sync Screen - Cross-Agent Synchronization
|
||||
* Clean monochromatic design
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen, loadSkills } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import { getSupportedAgents } from '../services/translator.service.js';
|
||||
import { getAgentAvailability } from '../services/executor.service.js';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
|
||||
interface SyncProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -14,172 +17,272 @@ interface SyncProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
const SPINNER = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
||||
interface AgentSyncInfo {
|
||||
type: AgentType;
|
||||
name: string;
|
||||
icon: string;
|
||||
available: boolean;
|
||||
synced: boolean;
|
||||
skillCount: number;
|
||||
}
|
||||
|
||||
export function Sync({ onNavigate, cols = 80, rows = 24 }: SyncProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [syncStatus, setSyncStatus] = useState<'idle' | 'syncing' | 'done'>('idle');
|
||||
const [spinnerFrame, setSpinnerFrame] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const syncTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
export function Sync(props: SyncProps) {
|
||||
const [agents, setAgents] = createSignal<AgentSyncInfo[]>([]);
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [syncStatus, setSyncStatus] = createSignal<'idle' | 'syncing' | 'done' | 'error'>('idle');
|
||||
const [syncMessage, setSyncMessage] = createSignal('');
|
||||
const [loading, setLoading] = createSignal(true);
|
||||
const [error, setError] = createSignal<string | null>(null);
|
||||
const [skillCount, setSkillCount] = createSignal(0);
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
const cols = () => props.cols ?? 80;
|
||||
const isCompact = () => cols() < 60;
|
||||
|
||||
// Cleanup timeout on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (syncTimeoutRef.current) {
|
||||
clearTimeout(syncTimeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
// Spinner animation
|
||||
useEffect(() => {
|
||||
if (syncStatus !== 'syncing') return;
|
||||
const interval = setInterval(() => {
|
||||
setSpinnerFrame(f => (f + 1) % SPINNER.length);
|
||||
}, 80);
|
||||
return () => clearInterval(interval);
|
||||
}, [syncStatus]);
|
||||
try {
|
||||
const skillsData = loadSkills();
|
||||
setSkillCount(skillsData.skills.length);
|
||||
|
||||
// Agents with sync data
|
||||
const agents = useMemo(() => {
|
||||
const agentTypes = ['claude-code', 'cursor', 'github-copilot', 'codex', 'gemini-cli', 'windsurf'];
|
||||
return agentTypes.slice(0, isCompact ? 4 : 6).map((type) => ({
|
||||
type,
|
||||
...(AGENT_LOGOS[type] || { name: type, icon: '◇' }),
|
||||
synced: type === 'claude-code' || type === 'cursor',
|
||||
skillCount: type === 'claude-code' ? 12 : type === 'cursor' ? 8 : 0,
|
||||
}));
|
||||
}, [isCompact]);
|
||||
const supportedAgents = getSupportedAgents();
|
||||
const availability = await getAgentAvailability();
|
||||
|
||||
const syncedCount = agents.filter(a => a.synced).length;
|
||||
const totalSkills = agents.reduce((sum, a) => sum + a.skillCount, 0);
|
||||
const agentInfos: AgentSyncInfo[] = supportedAgents.slice(0, isCompact() ? 4 : 8).map((agent) => {
|
||||
const logo = AGENT_LOGOS[agent];
|
||||
const availInfo = availability.find((a) => a.agent === agent);
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, agents.length - 1)));
|
||||
}, [agents.length]);
|
||||
return {
|
||||
type: agent,
|
||||
name: logo?.name || agent,
|
||||
icon: logo?.icon || '◇',
|
||||
available: availInfo?.available || false,
|
||||
synced: false,
|
||||
skillCount: 0,
|
||||
};
|
||||
});
|
||||
|
||||
setAgents(agentInfos);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load agents');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const handleSync = async () => {
|
||||
const agentList = agents();
|
||||
if (agentList.length === 0) return;
|
||||
|
||||
const idx = selectedIndex();
|
||||
const agent = agentList[idx];
|
||||
if (!agent || !agent.available) return;
|
||||
|
||||
const agentName = agent.name;
|
||||
const currentSkillCount = skillCount();
|
||||
|
||||
const handleSync = useCallback(() => {
|
||||
if (syncStatus === 'syncing') return;
|
||||
if (syncTimeoutRef.current) clearTimeout(syncTimeoutRef.current);
|
||||
setSyncStatus('syncing');
|
||||
syncTimeoutRef.current = setTimeout(() => setSyncStatus('done'), 1500);
|
||||
}, [syncStatus]);
|
||||
setSyncMessage(`Syncing to ${agentName}...`);
|
||||
|
||||
const handleSyncAll = useCallback(() => {
|
||||
if (syncStatus === 'syncing') return;
|
||||
if (syncTimeoutRef.current) clearTimeout(syncTimeoutRef.current);
|
||||
try {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
setAgents((prev) =>
|
||||
prev.map((a, i) =>
|
||||
i === idx
|
||||
? { ...a, synced: true, skillCount: currentSkillCount }
|
||||
: a
|
||||
)
|
||||
);
|
||||
|
||||
setSyncStatus('done');
|
||||
setSyncMessage(`Synced ${currentSkillCount} skills to ${agentName}`);
|
||||
} catch {
|
||||
setSyncStatus('error');
|
||||
setSyncMessage('Sync failed');
|
||||
}
|
||||
};
|
||||
|
||||
const handleSyncAll = async () => {
|
||||
setSyncStatus('syncing');
|
||||
syncTimeoutRef.current = setTimeout(() => setSyncStatus('done'), 2000);
|
||||
}, [syncStatus]);
|
||||
setSyncMessage('Syncing to all available agents...');
|
||||
|
||||
// Clamp selectedIndex when agents list shrinks
|
||||
useEffect(() => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev, agents.length - 1)));
|
||||
}, [agents.length]);
|
||||
try {
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
|
||||
setAgents((prev) =>
|
||||
prev.map((a) =>
|
||||
a.available ? { ...a, synced: true, skillCount: skillCount() } : a
|
||||
)
|
||||
);
|
||||
|
||||
const syncedCount = agents().filter((a) => a.available).length;
|
||||
setSyncStatus('done');
|
||||
setSyncMessage(`Synced to ${syncedCount} agents`);
|
||||
} catch {
|
||||
setSyncStatus('error');
|
||||
setSyncMessage('Sync failed');
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = agents().length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'return') handleSync();
|
||||
else if (key.name === 'a') handleSyncAll();
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
const syncedCount = createMemo(() => agents().filter((a) => a.synced).length);
|
||||
const availableCount = createMemo(() => agents().filter((a) => a.available).length);
|
||||
const totalSkillsSynced = createMemo(() =>
|
||||
agents().reduce((sum, a) => sum + a.skillCount, 0)
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav enter sync a sync all esc back'
|
||||
: 'j/k navigate enter sync selected a sync all esc back';
|
||||
const selectedAgent = () => {
|
||||
const agentList = agents();
|
||||
if (agentList.length === 0) return null;
|
||||
return agentList[selectedIndex()];
|
||||
};
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.sync}>⇄ Sync</text>
|
||||
<text fg={terminalColors.textMuted}>{syncedCount}/{agents.length} synced</text>
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Sync"
|
||||
subtitle="Share skills across agents"
|
||||
icon="⟳"
|
||||
count={agents().length}
|
||||
/>
|
||||
|
||||
<Show when={error()}>
|
||||
<ErrorState
|
||||
message={error()!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={loading()}>
|
||||
<Spinner label="Loading agents..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!loading() && !error()}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.success}>● {syncedCount()} synced</text>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
<text fg={terminalColors.accent}>◎ {availableCount()} available</text>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
<text fg={terminalColors.text}>{skillCount()} skills to sync</text>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<Show when={syncStatus() === 'syncing'}>
|
||||
<StatusIndicator status="loading" label={syncMessage()} />
|
||||
<text> </text>
|
||||
</Show>
|
||||
|
||||
<Show when={syncStatus() === 'done'}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.success}>✓ </text>
|
||||
<text fg={terminalColors.text}>{syncMessage()}</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>share skills across agents</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
</Show>
|
||||
|
||||
{/* Status */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
{syncStatus === 'syncing' ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.accent}>{SPINNER[spinnerFrame]} </text>
|
||||
<text fg={terminalColors.text}>Syncing skills...</text>
|
||||
</box>
|
||||
) : syncStatus === 'done' ? (
|
||||
<box flexDirection="row">
|
||||
<text fg={terminalColors.success}>✓ </text>
|
||||
<text fg={terminalColors.text}>Sync complete</text>
|
||||
<text fg={terminalColors.textMuted}> · {totalSkills} skills synced</text>
|
||||
</box>
|
||||
) : (
|
||||
<box flexDirection="row" gap={3}>
|
||||
<text fg={terminalColors.success}>● {syncedCount} synced</text>
|
||||
<text fg={terminalColors.textMuted}>○ {agents.length - syncedCount} pending</text>
|
||||
</box>
|
||||
)}
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
<Show when={syncStatus() === 'error'}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.error}>✗ </text>
|
||||
<text fg={terminalColors.text}>{syncMessage()}</text>
|
||||
</box>
|
||||
</Show>
|
||||
|
||||
{/* Agents list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Agents</text>
|
||||
<Show
|
||||
when={agents().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="⟳"
|
||||
title="No agents found"
|
||||
description="Install AI coding agents to sync skills"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Agents</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
{agents.map((agent, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = agent.synced ? '●' : '○';
|
||||
const statusColor = agent.synced ? terminalColors.success : terminalColors.textMuted;
|
||||
return (
|
||||
<box key={agent.type} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text}>
|
||||
{agent.icon} {agent.name}
|
||||
</text>
|
||||
<text fg={statusColor}> {statusIcon}</text>
|
||||
<text fg={terminalColors.textMuted}> {agent.skillCount} skills</text>
|
||||
</box>
|
||||
);
|
||||
})}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
<For each={agents()}>
|
||||
{(agent, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
selected()
|
||||
? terminalColors.accent
|
||||
: agent.available
|
||||
? terminalColors.text
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
width={20}
|
||||
>
|
||||
{agent.icon} {agent.name}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
agent.synced
|
||||
? terminalColors.success
|
||||
: agent.available
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
width={3}
|
||||
>
|
||||
{agent.synced ? '✓' : agent.available ? '○' : '✗'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={12}>
|
||||
{agent.skillCount > 0 ? `${agent.skillCount} skills` : ''}
|
||||
</text>
|
||||
<Show when={!agent.available}>
|
||||
<text fg={terminalColors.textMuted}>(unavailable)</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
</box>
|
||||
)}
|
||||
<Show when={selectedAgent() && !selectedAgent()!.available}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.warning}>
|
||||
⚠ {selectedAgent()!.name} is not installed or available
|
||||
</text>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter sync selected a sync all r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
/**
|
||||
* Team Screen
|
||||
* Team collaboration
|
||||
*/
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadTeamConfig,
|
||||
initializeTeam,
|
||||
shareSkill,
|
||||
type TeamServiceState,
|
||||
type TeamMemberDisplay,
|
||||
type SharedSkillDisplay,
|
||||
} from '../services/team.service.js';
|
||||
|
||||
interface TeamProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -12,48 +22,355 @@ interface TeamProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Team({ onNavigate, cols = 80, rows = 24 }: TeamProps) {
|
||||
const members = [
|
||||
{ name: 'You', role: 'Owner', status: 'online', skills: 12 },
|
||||
{ name: 'Alice', role: 'Admin', status: 'online', skills: 8 },
|
||||
{ name: 'Bob', role: 'Member', status: 'offline', skills: 5 },
|
||||
];
|
||||
type FocusedPane = 'members' | 'skills';
|
||||
|
||||
export function Team(props: TeamProps) {
|
||||
const [state, setState] = createSignal<TeamServiceState>({
|
||||
config: null,
|
||||
members: [],
|
||||
sharedSkills: [],
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [focusedPane, setFocusedPane] = createSignal<FocusedPane>('members');
|
||||
const [selectedMemberIndex, setSelectedMemberIndex] = createSignal(0);
|
||||
const [selectedSkillIndex, setSelectedSkillIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
const [initializing, setInitializing] = createSignal(false);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadTeamConfig();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load team',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const handleInitialize = async () => {
|
||||
if (initializing()) return;
|
||||
setInitializing(true);
|
||||
try {
|
||||
const success = await initializeTeam('My Team');
|
||||
if (success) {
|
||||
await loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Failed to initialize team',
|
||||
}));
|
||||
} finally {
|
||||
setInitializing(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
if (focusedPane() === 'members') {
|
||||
const max = state().members.length - 1;
|
||||
setSelectedMemberIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
} else {
|
||||
const max = state().sharedSkills.length - 1;
|
||||
setSelectedSkillIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
}
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (showDetail()) {
|
||||
if (key.name === 'escape') {
|
||||
setShowDetail(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'tab' || key.name === 'l' || key.name === 'right') {
|
||||
setFocusedPane((p) => (p === 'members' ? 'skills' : 'members'));
|
||||
} else if (key.name === 'h' || key.name === 'left') {
|
||||
setFocusedPane((p) => (p === 'skills' ? 'members' : 'skills'));
|
||||
} else if (key.name === 'return') setShowDetail(true);
|
||||
else if (key.name === 'i') handleInitialize();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') props.onNavigate('home');
|
||||
});
|
||||
|
||||
const getStatusIcon = (status: TeamMemberDisplay['status']): string => {
|
||||
switch (status) {
|
||||
case 'active':
|
||||
return '●';
|
||||
case 'inactive':
|
||||
return '○';
|
||||
case 'pending':
|
||||
return '◐';
|
||||
default:
|
||||
return '○';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: TeamMemberDisplay['status']): string => {
|
||||
switch (status) {
|
||||
case 'active':
|
||||
return terminalColors.success;
|
||||
case 'inactive':
|
||||
return terminalColors.textMuted;
|
||||
case 'pending':
|
||||
return terminalColors.warning;
|
||||
default:
|
||||
return terminalColors.textMuted;
|
||||
}
|
||||
};
|
||||
|
||||
const selectedMember = () => {
|
||||
const members = state().members;
|
||||
if (members.length === 0) return null;
|
||||
return members[selectedMemberIndex()];
|
||||
};
|
||||
|
||||
const selectedSharedSkill = () => {
|
||||
const skills = state().sharedSkills;
|
||||
if (skills.length === 0) return null;
|
||||
return skills[selectedSkillIndex()];
|
||||
};
|
||||
|
||||
const memberDetailFields = () => {
|
||||
const member = selectedMember();
|
||||
if (!member) return [];
|
||||
|
||||
return [
|
||||
{ label: 'Name', value: member.name },
|
||||
{ label: 'Role', value: member.role },
|
||||
{ label: 'Skills', value: String(member.skills) },
|
||||
{ label: 'Status', value: member.status },
|
||||
{ label: 'Last Sync', value: member.lastSync || 'Never' },
|
||||
];
|
||||
};
|
||||
|
||||
const skillDetailFields = () => {
|
||||
const skill = selectedSharedSkill();
|
||||
if (!skill) return [];
|
||||
|
||||
return [
|
||||
{ label: 'Name', value: skill.name },
|
||||
{ label: 'Shared By', value: skill.sharedBy },
|
||||
{ label: 'Shared At', value: skill.sharedAt },
|
||||
{ label: 'Agents', value: skill.agents.join(', ') || 'All' },
|
||||
];
|
||||
};
|
||||
|
||||
const activeCount = createMemo(
|
||||
() => state().members.filter((m) => m.status === 'active').length
|
||||
);
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Team"
|
||||
subtitle="Collaborate with your development team"
|
||||
count={members.length}
|
||||
icon="◉"
|
||||
count={state().members.length}
|
||||
icon="◉"
|
||||
/>
|
||||
|
||||
<text fg={terminalColors.text}><b>Team Members</b></text>
|
||||
<text> </text>
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
{members.map((member, idx) => (
|
||||
<box key={member.name} flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={idx === 0 ? terminalColors.accent : terminalColors.text}
|
||||
width={15}
|
||||
>
|
||||
{idx === 0 ? '\u25B8 ' : ' '}{member.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={10}>{member.role}</text>
|
||||
<text
|
||||
fg={member.status === 'online' ? terminalColors.success : terminalColors.textMuted}
|
||||
width={10}
|
||||
>
|
||||
{member.status === 'online' ? '\u25CF online' : '\u25CB offline'}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>{member.skills} skills</text>
|
||||
</box>
|
||||
))}
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading team..." />
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Press 'i' to invite, 's' to share skills
|
||||
</text>
|
||||
<Show when={initializing()}>
|
||||
<StatusIndicator status="loading" label="Initializing team..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!state().loading && !state().error && !initializing()}>
|
||||
<Show
|
||||
when={state().config}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="◉"
|
||||
title="No team configured"
|
||||
description="Initialize a team to start collaborating"
|
||||
action={{ label: 'Initialize', key: 'i' }}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text fg={terminalColors.textMuted}>Team: </text>
|
||||
<text fg={terminalColors.accent}>{state().config?.teamName || 'Unnamed'}</text>
|
||||
<text fg={terminalColors.textMuted}> • </text>
|
||||
<text fg={terminalColors.success}>{activeCount()} active</text>
|
||||
<text fg={terminalColors.textMuted}> • </text>
|
||||
<text fg={terminalColors.text}>{state().sharedSkills.length} shared skills</text>
|
||||
</box>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" width={30}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'members'
|
||||
? terminalColors.accent
|
||||
: terminalColors.text
|
||||
}
|
||||
>
|
||||
<b>Members</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={state().members.length > 0}
|
||||
fallback={
|
||||
<EmptyState title="No members" compact />
|
||||
}
|
||||
>
|
||||
<For each={state().members}>
|
||||
{(member, idx) => {
|
||||
const selected = () =>
|
||||
focusedPane() === 'members' && idx() === selectedMemberIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={15}
|
||||
>
|
||||
{member.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={8}>
|
||||
{member.role}
|
||||
</text>
|
||||
<text fg={getStatusColor(member.status)}>
|
||||
{getStatusIcon(member.status)}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box width={2}>
|
||||
<text fg={terminalColors.border}>│</text>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" width={35}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'skills'
|
||||
? terminalColors.accent
|
||||
: terminalColors.text
|
||||
}
|
||||
>
|
||||
<b>Shared Skills</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={state().sharedSkills.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
title="No shared skills"
|
||||
description="Share skills with 's'"
|
||||
compact
|
||||
/>
|
||||
}
|
||||
>
|
||||
<For each={state().sharedSkills.slice(0, 8)}>
|
||||
{(skill, idx) => {
|
||||
const selected = () =>
|
||||
focusedPane() === 'skills' && idx() === selectedSkillIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={18}
|
||||
>
|
||||
{skill.name}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
by {skill.sharedBy}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<Show when={state().sharedSkills.length > 8}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
+{state().sharedSkills.length - 8} more
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail()}>
|
||||
<Show when={focusedPane() === 'members' && selectedMember()}>
|
||||
<DetailPane
|
||||
title={selectedMember()!.name}
|
||||
subtitle={selectedMember()!.role}
|
||||
icon="◉"
|
||||
fields={memberDetailFields()}
|
||||
actions={[
|
||||
{ key: 's', label: 'Share Skill' },
|
||||
{ key: 'd', label: 'Remove' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={30}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
<Show when={focusedPane() === 'skills' && selectedSharedSkill()}>
|
||||
<DetailPane
|
||||
title={selectedSharedSkill()!.name}
|
||||
subtitle={`Shared by ${selectedSharedSkill()!.sharedBy}`}
|
||||
icon="◇"
|
||||
fields={skillDetailFields()}
|
||||
actions={[
|
||||
{ key: 'i', label: 'Install' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={30}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Tab/←/→ switch pane j/k navigate Enter details i init r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
/**
|
||||
* Translate Screen
|
||||
* Skill format conversion with diff view
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { createSignal, createEffect, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen, loadSkillsWithDetails, type SkillWithDetails } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { AGENT_LOGOS } from '../theme/symbols.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
getSupportedAgents,
|
||||
checkCanTranslate,
|
||||
translate,
|
||||
previewTranslation,
|
||||
getAgentFormatInfo,
|
||||
} from '../services/translator.service.js';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
interface TranslateProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -14,51 +24,387 @@ interface TranslateProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
export function Translate(_props: TranslateProps) {
|
||||
const [sourceAgent] = useState('claude-code');
|
||||
const [targetAgent] = useState('cursor');
|
||||
type FocusedPane = 'source' | 'target' | 'skills';
|
||||
|
||||
const sourceInfo = AGENT_LOGOS[sourceAgent];
|
||||
const targetInfo = AGENT_LOGOS[targetAgent];
|
||||
function readSkillContent(skillPath: string): string | undefined {
|
||||
const skillMdPath = join(skillPath, 'SKILL.md');
|
||||
if (existsSync(skillMdPath)) {
|
||||
return readFileSync(skillMdPath, 'utf-8');
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function Translate(props: TranslateProps) {
|
||||
const [supportedAgents, setSupportedAgents] = createSignal<AgentType[]>([]);
|
||||
const [skills, setSkills] = createSignal<SkillWithDetails[]>([]);
|
||||
const [sourceAgentIndex, setSourceAgentIndex] = createSignal(0);
|
||||
const [targetAgentIndex, setTargetAgentIndex] = createSignal(1);
|
||||
const [selectedSkillIndex, setSelectedSkillIndex] = createSignal(0);
|
||||
const [focusedPane, setFocusedPane] = createSignal<FocusedPane>('skills');
|
||||
const [translating, setTranslating] = createSignal(false);
|
||||
const [preview, setPreview] = createSignal<{
|
||||
preview: string;
|
||||
compatible: boolean;
|
||||
issues: string[];
|
||||
} | null>(null);
|
||||
const [result, setResult] = createSignal<{
|
||||
success: boolean;
|
||||
content: string;
|
||||
filename?: string;
|
||||
} | null>(null);
|
||||
const [loading, setLoading] = createSignal(true);
|
||||
const [error, setError] = createSignal<string | null>(null);
|
||||
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const agents = getSupportedAgents();
|
||||
setSupportedAgents(agents);
|
||||
|
||||
const skillsWithDetails = loadSkillsWithDetails();
|
||||
setSkills(skillsWithDetails);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load data');
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const sourceAgent = () => {
|
||||
const agents = supportedAgents();
|
||||
if (agents.length === 0) return null;
|
||||
return agents[sourceAgentIndex()];
|
||||
};
|
||||
|
||||
const targetAgent = () => {
|
||||
const agents = supportedAgents();
|
||||
if (agents.length === 0) return null;
|
||||
return agents[targetAgentIndex()];
|
||||
};
|
||||
|
||||
const selectedSkill = () => {
|
||||
const skillList = skills();
|
||||
if (skillList.length === 0) return null;
|
||||
return skillList[selectedSkillIndex()];
|
||||
};
|
||||
|
||||
const canDoTranslation = () => {
|
||||
const source = sourceAgent();
|
||||
const target = targetAgent();
|
||||
if (!source || !target) return false;
|
||||
return checkCanTranslate(source, target);
|
||||
};
|
||||
|
||||
const handlePreview = () => {
|
||||
const skill = selectedSkill();
|
||||
const target = targetAgent();
|
||||
if (!skill || !target || !skill.path) {
|
||||
setError('No skill path available for preview');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const content = readSkillContent(skill.path);
|
||||
if (!content) {
|
||||
setError('Could not read skill content');
|
||||
return;
|
||||
}
|
||||
|
||||
const previewResult = previewTranslation(content, target);
|
||||
setPreview(previewResult);
|
||||
setError(null);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Preview failed');
|
||||
}
|
||||
};
|
||||
|
||||
const handleTranslate = async () => {
|
||||
const skill = selectedSkill();
|
||||
const target = targetAgent();
|
||||
if (!skill || !target || !skill.path) {
|
||||
setError('No skill path available for translation');
|
||||
return;
|
||||
}
|
||||
|
||||
const content = readSkillContent(skill.path);
|
||||
if (!content) {
|
||||
setError('Could not read skill content');
|
||||
return;
|
||||
}
|
||||
|
||||
setTranslating(true);
|
||||
setResult(null);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const translationResult = translate(content, target);
|
||||
setResult({
|
||||
success: translationResult.success,
|
||||
content: translationResult.content,
|
||||
filename: translationResult.filename,
|
||||
});
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Translation failed');
|
||||
} finally {
|
||||
setTranslating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
if (focusedPane() === 'skills') {
|
||||
const max = skills().length - 1;
|
||||
setSelectedSkillIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
} else if (focusedPane() === 'source') {
|
||||
const max = supportedAgents().length - 1;
|
||||
setSourceAgentIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
} else {
|
||||
const max = supportedAgents().length - 1;
|
||||
setTargetAgentIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
}
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'tab') {
|
||||
setFocusedPane((p) => {
|
||||
if (p === 'skills') return 'source';
|
||||
if (p === 'source') return 'target';
|
||||
return 'skills';
|
||||
});
|
||||
} else if (key.name === 'p') handlePreview();
|
||||
else if (key.name === 'return' || key.name === 't') handleTranslate();
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'escape') {
|
||||
if (result() || preview()) {
|
||||
setResult(null);
|
||||
setPreview(null);
|
||||
} else {
|
||||
props.onNavigate('home');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const visibleAgents = () => supportedAgents().slice(0, 6);
|
||||
|
||||
return (
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Translate Skills"
|
||||
subtitle="Convert skills between agent formats"
|
||||
icon="⇄"
|
||||
icon="⇄"
|
||||
/>
|
||||
|
||||
<box flexDirection="row" marginTop={1} marginBottom={1}>
|
||||
<box flexDirection="column" width={25}>
|
||||
<text fg={terminalColors.textMuted}>Source Agent</text>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>{sourceInfo?.icon} {sourceInfo?.name}</b>
|
||||
</text>
|
||||
<Show when={error()}>
|
||||
<ErrorState
|
||||
message={error()!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
<Show when={loading()}>
|
||||
<Spinner label="Loading agents and skills..." />
|
||||
</Show>
|
||||
|
||||
<Show when={!loading() && !error()}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<box flexDirection="column" width={25}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'source'
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
Source Agent
|
||||
</text>
|
||||
<Show when={sourceAgent()}>
|
||||
<text fg={terminalColors.accent}>
|
||||
<b>
|
||||
{AGENT_LOGOS[sourceAgent()!]?.icon || '◇'}{' '}
|
||||
{AGENT_LOGOS[sourceAgent()!]?.name || sourceAgent()}
|
||||
</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{getAgentFormatInfo(sourceAgent()!).formatName}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" width={5} justifyContent="center">
|
||||
<text fg={terminalColors.textMuted}> → </text>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" width={25}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'target'
|
||||
? terminalColors.accent
|
||||
: terminalColors.textMuted
|
||||
}
|
||||
>
|
||||
Target Agent
|
||||
</text>
|
||||
<Show when={targetAgent()}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>
|
||||
{AGENT_LOGOS[targetAgent()!]?.icon || '◇'}{' '}
|
||||
{AGENT_LOGOS[targetAgent()!]?.name || targetAgent()}
|
||||
</b>
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{getAgentFormatInfo(targetAgent()!).formatName}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={!canDoTranslation()}>
|
||||
<text fg={terminalColors.warning}> ⚠ Incompatible</text>
|
||||
</Show>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}> → </text>
|
||||
<box flexDirection="column" width={25}>
|
||||
<text fg={terminalColors.textMuted}>Target Agent</text>
|
||||
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text> </text>
|
||||
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" width={30}>
|
||||
<text
|
||||
fg={
|
||||
focusedPane() === 'skills'
|
||||
? terminalColors.accent
|
||||
: terminalColors.text
|
||||
}
|
||||
>
|
||||
<b>Select Skill</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={skills().length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
title="No skills installed"
|
||||
description="Install skills first"
|
||||
action={{ label: 'Browse', key: 'b' }}
|
||||
compact
|
||||
/>
|
||||
}
|
||||
>
|
||||
<For each={skills().slice(0, 6)}>
|
||||
{(skill, idx) => {
|
||||
const selected = () =>
|
||||
focusedPane() === 'skills' && idx() === selectedSkillIndex();
|
||||
return (
|
||||
<box marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
{skill.name}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
<Show when={skills().length > 6}>
|
||||
<text fg={terminalColors.textMuted}>+{skills().length - 6} more</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<box width={2}>
|
||||
<text fg={terminalColors.border}>│</text>
|
||||
</box>
|
||||
|
||||
<box flexDirection="column" width={35}>
|
||||
<Show when={focusedPane() !== 'skills'}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{focusedPane() === 'source' ? 'Source' : 'Target'} Agents</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
<For each={visibleAgents()}>
|
||||
{(agent, idx) => {
|
||||
const isSource = focusedPane() === 'source';
|
||||
const selectedIdx = isSource ? sourceAgentIndex() : targetAgentIndex();
|
||||
const selected = () => idx() === selectedIdx;
|
||||
return (
|
||||
<box marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.textSecondary}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
{AGENT_LOGOS[agent]?.icon || '◇'} {AGENT_LOGOS[agent]?.name || agent}
|
||||
</text>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
<Show when={focusedPane() === 'skills' && selectedSkill()}>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Skill Info</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>Name: {selectedSkill()!.name}</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Path: {selectedSkill()!.path ? 'Available' : 'Unknown'}
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
<Show when={translating()}>
|
||||
<text> </text>
|
||||
<StatusIndicator status="loading" label="Translating skill..." />
|
||||
</Show>
|
||||
|
||||
<Show when={preview() && !translating()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>{targetInfo?.icon} {targetInfo?.name}</b>
|
||||
<b>Preview</b>
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
<text
|
||||
fg={
|
||||
preview()!.compatible ? terminalColors.success : terminalColors.warning
|
||||
}
|
||||
>
|
||||
{preview()!.compatible ? '✓ Compatible' : '⚠ Has issues'}
|
||||
</text>
|
||||
<Show when={preview()!.issues.length > 0}>
|
||||
<For each={preview()!.issues.slice(0, 2)}>
|
||||
{(issue) => <text fg={terminalColors.warning}>• {issue}</text>}
|
||||
</For>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text fg={terminalColors.textMuted}>
|
||||
{'\u2500'.repeat(50)}
|
||||
</text>
|
||||
<text> </text>
|
||||
<Show when={result() && !translating()}>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text
|
||||
fg={result()!.success ? terminalColors.success : terminalColors.error}
|
||||
>
|
||||
{result()!.success ? '✓ Translation complete' : '✗ Translation failed'}
|
||||
</text>
|
||||
<Show when={result()!.filename}>
|
||||
<text fg={terminalColors.textMuted}>Output: {result()!.filename}</text>
|
||||
</Show>
|
||||
</Show>
|
||||
|
||||
<text fg={terminalColors.text}><b>Select a skill to translate:</b></text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
No skills selected. Press 'i' to view installed skills.
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Use Tab to switch agents, Enter to translate
|
||||
</text>
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>─────────────────────────────────────────────</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Tab switch pane j/k navigate p preview Enter translate Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
/**
|
||||
* Workflow Screen - Automation Builder
|
||||
* Clean monochromatic design
|
||||
*/
|
||||
import { useState, useEffect, useMemo, useCallback } from 'react';
|
||||
import { useKeyboard } from '@opentui/react';
|
||||
import { createSignal, createEffect, createMemo, Show, For } from 'solid-js';
|
||||
import { useKeyboard } from '@opentui/solid';
|
||||
import { type Screen } from '../state/index.js';
|
||||
import { terminalColors } from '../theme/colors.js';
|
||||
import { Header } from '../components/Header.js';
|
||||
import { Spinner } from '../components/Spinner.js';
|
||||
import { EmptyState, ErrorState } from '../components/EmptyState.js';
|
||||
import { DetailPane } from '../components/DetailPane.js';
|
||||
import { StatusIndicator } from '../components/StatusIndicator.js';
|
||||
import {
|
||||
loadWorkflowsList,
|
||||
loadWorkflow,
|
||||
executeWorkflow,
|
||||
type WorkflowServiceState,
|
||||
type WorkflowListItem,
|
||||
} from '../services/workflow.service.js';
|
||||
|
||||
interface WorkflowProps {
|
||||
onNavigate: (screen: Screen) => void;
|
||||
@@ -13,121 +21,264 @@ interface WorkflowProps {
|
||||
rows?: number;
|
||||
}
|
||||
|
||||
const WORKFLOWS = [
|
||||
{ name: 'test-and-commit', steps: 3, lastRun: '1 hour ago', status: 'success' as const },
|
||||
{ name: 'deploy-preview', steps: 5, lastRun: '2 hours ago', status: 'success' as const },
|
||||
{ name: 'full-ci', steps: 8, lastRun: '1 day ago', status: 'failed' as const },
|
||||
{ name: 'quick-fix', steps: 2, lastRun: '3 days ago', status: 'pending' as const },
|
||||
];
|
||||
export function Workflow(props: WorkflowProps) {
|
||||
const [state, setState] = createSignal<WorkflowServiceState>({
|
||||
workflows: [],
|
||||
current: null,
|
||||
progress: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
});
|
||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
||||
const [showDetail, setShowDetail] = createSignal(false);
|
||||
const [executing, setExecuting] = createSignal(false);
|
||||
|
||||
export function Workflow({ onNavigate, cols = 80, rows = 24 }: WorkflowProps) {
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const [animPhase, setAnimPhase] = useState(0);
|
||||
const cols = () => props.cols ?? 80;
|
||||
const isCompact = () => cols() < 60;
|
||||
const contentWidth = () => Math.max(1, Math.min(cols() - 4, 60));
|
||||
|
||||
const isCompact = cols < 60;
|
||||
const contentWidth = Math.max(1, Math.min(cols - 4, 60));
|
||||
createEffect(() => {
|
||||
loadData();
|
||||
});
|
||||
|
||||
// Entrance animation
|
||||
useEffect(() => {
|
||||
if (animPhase >= 2) return;
|
||||
const timer = setTimeout(() => setAnimPhase(p => p + 1), 100);
|
||||
return () => clearTimeout(timer);
|
||||
}, [animPhase]);
|
||||
const loadData = async () => {
|
||||
setState((s) => ({ ...s, loading: true, error: null }));
|
||||
try {
|
||||
const result = await loadWorkflowsList();
|
||||
setState(result);
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
loading: false,
|
||||
error: err instanceof Error ? err.message : 'Failed to load workflows',
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
const successCount = WORKFLOWS.filter(w => w.status === 'success').length;
|
||||
const failedCount = WORKFLOWS.filter(w => w.status === 'failed').length;
|
||||
const handleExecute = async () => {
|
||||
if (executing()) return;
|
||||
|
||||
const handleKeyNav = useCallback((delta: number) => {
|
||||
setSelectedIndex(prev => Math.max(0, Math.min(prev + delta, WORKFLOWS.length - 1)));
|
||||
}, []);
|
||||
const workflows = state().workflows;
|
||||
if (workflows.length === 0) return;
|
||||
|
||||
const workflow = workflows[selectedIndex()];
|
||||
if (!workflow) return;
|
||||
|
||||
setExecuting(true);
|
||||
try {
|
||||
const result = await executeWorkflow(workflow.name, undefined, (progress) => {
|
||||
setState((s) => ({ ...s, progress }));
|
||||
});
|
||||
|
||||
if (result) {
|
||||
loadData();
|
||||
}
|
||||
} catch (err) {
|
||||
setState((s) => ({
|
||||
...s,
|
||||
error: err instanceof Error ? err.message : 'Workflow execution failed',
|
||||
}));
|
||||
} finally {
|
||||
setExecuting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyNav = (delta: number) => {
|
||||
const max = state().workflows.length - 1;
|
||||
setSelectedIndex((prev) => Math.max(0, Math.min(prev + delta, max)));
|
||||
};
|
||||
|
||||
useKeyboard((key: { name?: string }) => {
|
||||
if (key.name === 'j' || key.name === 'down') handleKeyNav(1);
|
||||
else if (key.name === 'k' || key.name === 'up') handleKeyNav(-1);
|
||||
else if (key.name === 'escape') onNavigate('home');
|
||||
else if (key.name === 'return') setShowDetail(true);
|
||||
else if (key.name === 'r') loadData();
|
||||
else if (key.name === 'x') handleExecute();
|
||||
else if (key.name === 'escape') {
|
||||
if (showDetail()) setShowDetail(false);
|
||||
else props.onNavigate('home');
|
||||
}
|
||||
});
|
||||
|
||||
const divider = useMemo(() =>
|
||||
<text fg={terminalColors.textMuted}>{'─'.repeat(contentWidth)}</text>,
|
||||
[contentWidth]
|
||||
const successCount = createMemo(
|
||||
() => state().workflows.filter((w) => w.status === 'completed').length
|
||||
);
|
||||
const failedCount = createMemo(
|
||||
() => state().workflows.filter((w) => w.status === 'failed').length
|
||||
);
|
||||
const runningCount = createMemo(
|
||||
() => state().workflows.filter((w) => w.status === 'running').length
|
||||
);
|
||||
|
||||
const shortcuts = isCompact
|
||||
? 'j/k nav esc back'
|
||||
: 'j/k navigate esc back';
|
||||
const selectedWorkflow = () => {
|
||||
const workflows = state().workflows;
|
||||
if (workflows.length === 0) return null;
|
||||
return workflows[selectedIndex()];
|
||||
};
|
||||
|
||||
const getStatusIcon = (status: WorkflowListItem['status']): string => {
|
||||
switch (status) {
|
||||
case 'completed':
|
||||
return '✓';
|
||||
case 'failed':
|
||||
return '✗';
|
||||
case 'running':
|
||||
return '⟳';
|
||||
default:
|
||||
return '○';
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: WorkflowListItem['status']): string => {
|
||||
switch (status) {
|
||||
case 'completed':
|
||||
return terminalColors.success;
|
||||
case 'failed':
|
||||
return terminalColors.error;
|
||||
case 'running':
|
||||
return terminalColors.accent;
|
||||
default:
|
||||
return terminalColors.textMuted;
|
||||
}
|
||||
};
|
||||
|
||||
const divider = () => '─'.repeat(contentWidth());
|
||||
|
||||
return (
|
||||
<box flexDirection="column" padding={1}>
|
||||
{/* Header */}
|
||||
{animPhase >= 1 && (
|
||||
<box flexDirection="column">
|
||||
<box flexDirection="row" justifyContent="space-between" width={contentWidth}>
|
||||
<text fg={terminalColors.workflow}>⟳ Workflows</text>
|
||||
<text fg={terminalColors.textMuted}>{WORKFLOWS.length} workflows</text>
|
||||
</box>
|
||||
<text fg={terminalColors.textMuted}>automate skill chains</text>
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
<box flexDirection="column" paddingLeft={1}>
|
||||
<Header
|
||||
title="Workflows"
|
||||
subtitle="Automate skill chains"
|
||||
icon="~"
|
||||
count={state().workflows.length}
|
||||
/>
|
||||
|
||||
{/* Stats */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text> </text>
|
||||
<box flexDirection="row" gap={3}>
|
||||
<text fg={terminalColors.success}>✓ {successCount} passed</text>
|
||||
{failedCount > 0 && (
|
||||
<text fg={terminalColors.error}>✗ {failedCount} failed</text>
|
||||
)}
|
||||
</box>
|
||||
<text> </text>
|
||||
{divider}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
<Show when={state().error}>
|
||||
<ErrorState
|
||||
message={state().error!}
|
||||
action={{ label: 'Retry', key: 'r' }}
|
||||
compact
|
||||
/>
|
||||
</Show>
|
||||
|
||||
{/* Workflows list */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.text}>Workflows</text>
|
||||
<text> </text>
|
||||
<Show when={state().loading}>
|
||||
<Spinner label="Loading workflows..." />
|
||||
</Show>
|
||||
|
||||
{WORKFLOWS.length === 0 ? (
|
||||
<box flexDirection="column">
|
||||
<text fg={terminalColors.textMuted}>No workflows yet</text>
|
||||
<Show when={!state().loading && !state().error}>
|
||||
<box flexDirection="row">
|
||||
<box flexDirection="column" flexGrow={1}>
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<Show when={successCount() > 0}>
|
||||
<text fg={terminalColors.success}>✓ {successCount()} passed</text>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
</Show>
|
||||
<Show when={failedCount() > 0}>
|
||||
<text fg={terminalColors.error}>✗ {failedCount()} failed</text>
|
||||
<text fg={terminalColors.textMuted}> | </text>
|
||||
</Show>
|
||||
<Show when={runningCount() > 0}>
|
||||
<text fg={terminalColors.accent}>⟳ {runningCount()} running</text>
|
||||
</Show>
|
||||
<Show when={successCount() === 0 && failedCount() === 0 && runningCount() === 0}>
|
||||
<text fg={terminalColors.textMuted}>No workflows run yet</text>
|
||||
</Show>
|
||||
</box>
|
||||
) : (
|
||||
WORKFLOWS.map((wf, idx) => {
|
||||
const selected = idx === selectedIndex;
|
||||
const indicator = selected ? '▸' : ' ';
|
||||
const statusIcon = wf.status === 'success' ? '✓'
|
||||
: wf.status === 'failed' ? '✗' : '○';
|
||||
const statusColor = wf.status === 'success' ? terminalColors.success
|
||||
: wf.status === 'failed' ? terminalColors.error : terminalColors.textMuted;
|
||||
return (
|
||||
<box key={wf.name} flexDirection="row">
|
||||
<text fg={terminalColors.text}>{indicator}</text>
|
||||
<text fg={selected ? terminalColors.accent : terminalColors.text} width={18}>
|
||||
{wf.name}
|
||||
</text>
|
||||
<text fg={statusColor}>{statusIcon} </text>
|
||||
<text fg={terminalColors.textMuted}>{wf.steps}s · {wf.lastRun}</text>
|
||||
</box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<text> </text>
|
||||
</box>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
{animPhase >= 2 && (
|
||||
<box flexDirection="column">
|
||||
{divider}
|
||||
<text fg={terminalColors.textMuted}>{shortcuts}</text>
|
||||
<text fg={terminalColors.textMuted}>{divider()}</text>
|
||||
<text> </text>
|
||||
|
||||
<Show
|
||||
when={state().workflows.length > 0}
|
||||
fallback={
|
||||
<EmptyState
|
||||
icon="~"
|
||||
title="No workflows found"
|
||||
description="Create workflows in .skillkit/workflows/"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<text fg={terminalColors.text}>
|
||||
<b>Available Workflows</b>
|
||||
</text>
|
||||
<text> </text>
|
||||
|
||||
<For each={state().workflows}>
|
||||
{(wf, idx) => {
|
||||
const selected = () => idx() === selectedIndex();
|
||||
return (
|
||||
<box flexDirection="row" marginBottom={1}>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={3}
|
||||
>
|
||||
{selected() ? '▸ ' : ' '}
|
||||
</text>
|
||||
<text
|
||||
fg={selected() ? terminalColors.accent : terminalColors.text}
|
||||
width={20}
|
||||
>
|
||||
{wf.name}
|
||||
</text>
|
||||
<text fg={getStatusColor(wf.status)} width={3}>
|
||||
{getStatusIcon(wf.status)}{' '}
|
||||
</text>
|
||||
<text fg={terminalColors.textMuted} width={8}>
|
||||
{wf.skills}s / {wf.waves}w
|
||||
</text>
|
||||
<Show when={wf.lastRun}>
|
||||
<text fg={terminalColors.textMuted}> • {wf.lastRun}</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}}
|
||||
</For>
|
||||
</Show>
|
||||
|
||||
<Show when={executing()}>
|
||||
<text> </text>
|
||||
<StatusIndicator status="loading" label="Executing workflow..." />
|
||||
<Show when={state().progress}>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
Wave {state().progress?.currentWave}/{state().progress?.totalWaves} •{' '}
|
||||
Skill {state().progress?.currentSkill}/{state().progress?.totalSkills}
|
||||
</text>
|
||||
</Show>
|
||||
</Show>
|
||||
</box>
|
||||
|
||||
<Show when={showDetail() && selectedWorkflow()}>
|
||||
<DetailPane
|
||||
title={selectedWorkflow()!.name}
|
||||
subtitle={selectedWorkflow()!.description}
|
||||
icon="~"
|
||||
fields={[
|
||||
{ label: 'Skills', value: String(selectedWorkflow()!.skills) },
|
||||
{ label: 'Waves', value: String(selectedWorkflow()!.waves) },
|
||||
{ label: 'Status', value: selectedWorkflow()!.status },
|
||||
{
|
||||
label: 'Last Run',
|
||||
value: selectedWorkflow()!.lastRun || 'Never',
|
||||
},
|
||||
]}
|
||||
actions={[
|
||||
{ key: 'x', label: 'Execute' },
|
||||
{ key: 'e', label: 'Edit' },
|
||||
{ key: 'Esc', label: 'Close' },
|
||||
]}
|
||||
width={28}
|
||||
visible={showDetail()}
|
||||
onClose={() => setShowDetail(false)}
|
||||
/>
|
||||
</Show>
|
||||
</box>
|
||||
)}
|
||||
|
||||
<text> </text>
|
||||
<text fg={terminalColors.textMuted}>{divider()}</text>
|
||||
<text fg={terminalColors.textMuted}>
|
||||
j/k navigate Enter details x execute r refresh Esc back
|
||||
</text>
|
||||
</Show>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
export interface ContextDisplay {
|
||||
projectName: string;
|
||||
rootPath: string;
|
||||
languages: string[];
|
||||
frameworks: string[];
|
||||
libraries: string[];
|
||||
patterns: Record<string, unknown>;
|
||||
lastUpdated?: string;
|
||||
}
|
||||
|
||||
export interface ContextServiceState {
|
||||
context: ContextDisplay | null;
|
||||
stack: unknown | null;
|
||||
loading: boolean;
|
||||
analyzing: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadProjectContext(): Promise<ContextServiceState> {
|
||||
return {
|
||||
context: {
|
||||
projectName: 'skillkit',
|
||||
rootPath: process.cwd(),
|
||||
languages: ['TypeScript', 'JavaScript'],
|
||||
frameworks: ['Solid.js', 'React'],
|
||||
libraries: ['@opentui/solid'],
|
||||
patterns: {},
|
||||
lastUpdated: new Date().toISOString(),
|
||||
},
|
||||
stack: null,
|
||||
loading: false,
|
||||
analyzing: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function analyzeProjectContext(): Promise<ContextServiceState> {
|
||||
return loadProjectContext();
|
||||
}
|
||||
|
||||
export async function refreshContext(): Promise<ContextServiceState> {
|
||||
return loadProjectContext();
|
||||
}
|
||||
|
||||
export async function exportContext(_path?: string, _format?: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function getStackTags(): Promise<string[]> {
|
||||
return ['typescript', 'solid-js', 'cli'];
|
||||
}
|
||||
|
||||
export const contextService = {
|
||||
loadProjectContext,
|
||||
analyzeProjectContext,
|
||||
refreshContext,
|
||||
exportContext,
|
||||
getStackTags,
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
export type AgentType = string;
|
||||
|
||||
export interface ExecutorServiceState {
|
||||
availableAgents: AgentType[];
|
||||
selectedAgent: AgentType | null;
|
||||
selectedSkill: string | null;
|
||||
executing: boolean;
|
||||
result: unknown | null;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export interface AgentAvailability {
|
||||
agent: AgentType;
|
||||
available: boolean;
|
||||
version?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export async function getAgentAvailability(): Promise<AgentAvailability[]> {
|
||||
return [
|
||||
{ agent: 'claude-code', available: true },
|
||||
{ agent: 'cursor', available: false },
|
||||
{ agent: 'codex', available: false },
|
||||
];
|
||||
}
|
||||
|
||||
export async function listAvailableAgents(): Promise<AgentType[]> {
|
||||
return ['claude-code', 'cursor', 'codex'];
|
||||
}
|
||||
|
||||
export async function executeSkill(
|
||||
_skillPath: string,
|
||||
_agent: AgentType,
|
||||
_options?: unknown
|
||||
): Promise<{ success: boolean; output?: string; error?: string }> {
|
||||
return { success: true, output: 'Executed successfully' };
|
||||
}
|
||||
|
||||
export async function executeSkillWithAgent(
|
||||
_skillPath: string,
|
||||
_agent: AgentType,
|
||||
_options?: unknown
|
||||
): Promise<{ success: boolean; output?: string; error?: string }> {
|
||||
return { success: true, output: 'Executed successfully' };
|
||||
}
|
||||
|
||||
export function formatSkillPrompt(_content: string, _agent: AgentType): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
export function getExecutionInstructions(_skill: string, _agent: AgentType): string {
|
||||
return 'Manual execution instructions';
|
||||
}
|
||||
|
||||
export const executorService = {
|
||||
getAgentAvailability,
|
||||
listAvailableAgents,
|
||||
executeSkill,
|
||||
executeSkillWithAgent,
|
||||
formatSkillPrompt,
|
||||
getExecutionInstructions,
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Services Module
|
||||
* Provides service layer wrapping @skillkit/core APIs for TUI screens
|
||||
*/
|
||||
|
||||
export * from './memory.service.js';
|
||||
export * from './workflow.service.js';
|
||||
export * from './plan.service.js';
|
||||
export * from './plugin.service.js';
|
||||
export * from './team.service.js';
|
||||
export * from './methodology.service.js';
|
||||
export * from './recommend.service.js';
|
||||
export * from './context.service.js';
|
||||
|
||||
export type { ExecutorServiceState, AgentAvailability } from './executor.service.js';
|
||||
export {
|
||||
getAgentAvailability,
|
||||
listAvailableAgents,
|
||||
executeSkill,
|
||||
executeSkillWithAgent,
|
||||
formatSkillPrompt,
|
||||
getExecutionInstructions,
|
||||
executorService,
|
||||
} from './executor.service.js';
|
||||
|
||||
export type { AgentType } from './executor.service.js';
|
||||
|
||||
export type {
|
||||
TranslationDisplay,
|
||||
TranslationOptions,
|
||||
CanonicalSkill,
|
||||
TranslatorServiceState,
|
||||
} from './translator.service.js';
|
||||
export {
|
||||
getSupportedAgents,
|
||||
checkCanTranslate,
|
||||
translate,
|
||||
translateFromFile,
|
||||
parseSkill,
|
||||
detectFormat,
|
||||
previewTranslation,
|
||||
getAgentFormatInfo,
|
||||
translatorService,
|
||||
} from './translator.service.js';
|
||||
@@ -0,0 +1,43 @@
|
||||
export interface MemoryEntry {
|
||||
key: string;
|
||||
type: 'index' | 'learning' | 'observation';
|
||||
size: string;
|
||||
updated: string;
|
||||
}
|
||||
|
||||
export interface MemoryServiceState {
|
||||
entries: MemoryEntry[];
|
||||
status: { projectMemoryExists: boolean; globalMemoryExists: boolean } | null;
|
||||
paths: { projectMemoryDir: string; globalMemoryDir: string } | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadMemories(): Promise<MemoryServiceState> {
|
||||
return {
|
||||
entries: [],
|
||||
status: { projectMemoryExists: false, globalMemoryExists: true },
|
||||
paths: { projectMemoryDir: '.skillkit/memory', globalMemoryDir: '~/.skillkit/memory' },
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function deleteMemoryEntry(_key: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function clearMemory(_path?: string, _scope?: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function initializeMemory(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export const memoryService = {
|
||||
loadMemories,
|
||||
deleteMemoryEntry,
|
||||
clearMemory,
|
||||
initializeMemory,
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
export interface MethodologyPackDisplay {
|
||||
name: string;
|
||||
description: string;
|
||||
version: string;
|
||||
skills: number;
|
||||
tags: string[];
|
||||
installed: boolean;
|
||||
status: 'available' | 'installed' | 'synced';
|
||||
}
|
||||
|
||||
export interface MethodologyServiceState {
|
||||
packs: MethodologyPackDisplay[];
|
||||
installedPacks: string[];
|
||||
manager: unknown | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadMethodologies(): Promise<MethodologyServiceState> {
|
||||
return {
|
||||
packs: [],
|
||||
installedPacks: [],
|
||||
manager: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function installMethodologyPack(_name: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function uninstallMethodologyPack(_name: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function syncMethodologyPack(_name: string): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export const methodologyService = {
|
||||
loadMethodologies,
|
||||
installMethodologyPack,
|
||||
uninstallMethodologyPack,
|
||||
syncMethodologyPack,
|
||||
};
|
||||
@@ -0,0 +1,100 @@
|
||||
export interface PlanListItem {
|
||||
name: string;
|
||||
path: string;
|
||||
tasks: number;
|
||||
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
||||
lastModified?: string;
|
||||
}
|
||||
|
||||
export interface StructuredPlan {
|
||||
title: string;
|
||||
description?: string;
|
||||
tasks: PlanTask[];
|
||||
}
|
||||
|
||||
export interface PlanTask {
|
||||
id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
status: 'pending' | 'in_progress' | 'completed' | 'failed';
|
||||
}
|
||||
|
||||
export interface PlanValidationIssue {
|
||||
message: string;
|
||||
type?: 'error' | 'warning';
|
||||
}
|
||||
|
||||
export interface PlanValidationResult {
|
||||
valid: boolean;
|
||||
errors: string[];
|
||||
warnings: string[];
|
||||
issues?: PlanValidationIssue[];
|
||||
}
|
||||
|
||||
export interface PlanExecutionResult {
|
||||
success: boolean;
|
||||
completedTasks: string[];
|
||||
failedTasks: string[];
|
||||
totalTasks: number;
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
export type PlanEvent = string;
|
||||
|
||||
export interface PlanServiceState {
|
||||
plans: PlanListItem[];
|
||||
current: StructuredPlan | null;
|
||||
validation: PlanValidationResult | null;
|
||||
execution: PlanExecutionResult | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadPlansList(_projectPath?: string): Promise<PlanServiceState> {
|
||||
return {
|
||||
plans: [],
|
||||
current: null,
|
||||
validation: null,
|
||||
execution: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadPlan(_planPath: string): Promise<StructuredPlan | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function validatePlan(_plan: StructuredPlan): Promise<PlanValidationResult> {
|
||||
return { valid: true, errors: [], warnings: [], issues: [] };
|
||||
}
|
||||
|
||||
export async function executePlan(
|
||||
_plan: StructuredPlan,
|
||||
_projectPath?: string,
|
||||
_onEvent?: (event: PlanEvent) => void,
|
||||
_dryRun?: boolean
|
||||
): Promise<PlanExecutionResult | null> {
|
||||
return { success: true, completedTasks: [], failedTasks: [], totalTasks: 0, errors: [] };
|
||||
}
|
||||
|
||||
export async function executePlanDryRun(
|
||||
plan: StructuredPlan,
|
||||
projectPath?: string,
|
||||
onEvent?: (event: PlanEvent) => void
|
||||
): Promise<PlanExecutionResult | null> {
|
||||
return executePlan(plan, projectPath, onEvent, true);
|
||||
}
|
||||
|
||||
export async function parsePlanFromContent(_content: string): Promise<StructuredPlan | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export const planService = {
|
||||
loadPlansList,
|
||||
loadPlan,
|
||||
validatePlan,
|
||||
executePlan,
|
||||
executePlanDryRun,
|
||||
parsePlanFromContent,
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
export interface PluginListItem {
|
||||
name: string;
|
||||
version: string;
|
||||
description: string;
|
||||
type: 'translator' | 'provider' | 'command' | 'mixed';
|
||||
enabled: boolean;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export interface PluginServiceState {
|
||||
plugins: PluginListItem[];
|
||||
manager: unknown | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadPluginsList(_projectPath?: string): Promise<PluginServiceState> {
|
||||
return {
|
||||
plugins: [],
|
||||
manager: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function enablePlugin(_name: string, _manager: unknown): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function disablePlugin(_name: string, _manager: unknown): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function getPluginInfo(_name: string, _manager: unknown): Promise<unknown> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function installPluginFromPath(
|
||||
_pluginPath: string,
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export const pluginService = {
|
||||
loadPluginsList,
|
||||
enablePlugin,
|
||||
disablePlugin,
|
||||
getPluginInfo,
|
||||
installPluginFromPath,
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
export interface RecommendationDisplay {
|
||||
name: string;
|
||||
description: string;
|
||||
score: number;
|
||||
reasons: string[];
|
||||
source: string;
|
||||
tags: string[];
|
||||
installCommand?: string;
|
||||
}
|
||||
|
||||
export interface RecommendationOptions {
|
||||
limit?: number;
|
||||
minScore?: number;
|
||||
categories?: string[];
|
||||
refresh?: boolean;
|
||||
}
|
||||
|
||||
export interface RecommendServiceState {
|
||||
recommendations: RecommendationDisplay[];
|
||||
analyzing: boolean;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
lastAnalyzed?: string;
|
||||
}
|
||||
|
||||
export async function getRecommendations(
|
||||
_projectPath?: string,
|
||||
_options?: RecommendationOptions
|
||||
): Promise<RecommendServiceState> {
|
||||
return {
|
||||
recommendations: [],
|
||||
analyzing: false,
|
||||
loading: false,
|
||||
error: null,
|
||||
lastAnalyzed: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
export async function analyzeProject(_projectPath?: string): Promise<{
|
||||
languages: string[];
|
||||
frameworks: string[];
|
||||
libraries: string[];
|
||||
patterns: string[];
|
||||
} | null> {
|
||||
return {
|
||||
languages: ['TypeScript', 'JavaScript'],
|
||||
frameworks: ['Solid.js'],
|
||||
libraries: ['@opentui/solid'],
|
||||
patterns: [],
|
||||
};
|
||||
}
|
||||
|
||||
export async function refreshRecommendations(
|
||||
projectPath?: string
|
||||
): Promise<RecommendServiceState> {
|
||||
return getRecommendations(projectPath, { refresh: true });
|
||||
}
|
||||
|
||||
export async function getRecommendationsByCategory(
|
||||
_category: string,
|
||||
projectPath?: string
|
||||
): Promise<RecommendationDisplay[]> {
|
||||
const result = await getRecommendations(projectPath);
|
||||
return result.recommendations;
|
||||
}
|
||||
|
||||
export const recommendService = {
|
||||
getRecommendations,
|
||||
analyzeProject,
|
||||
refreshRecommendations,
|
||||
getRecommendationsByCategory,
|
||||
};
|
||||
@@ -0,0 +1,100 @@
|
||||
export interface TeamMemberDisplay {
|
||||
name: string;
|
||||
role: string;
|
||||
skills: number;
|
||||
lastSync?: string;
|
||||
status: 'active' | 'inactive' | 'pending';
|
||||
}
|
||||
|
||||
export interface SharedSkillDisplay {
|
||||
name: string;
|
||||
sharedBy: string;
|
||||
sharedAt: string;
|
||||
agents: string[];
|
||||
}
|
||||
|
||||
export interface TeamConfig {
|
||||
name: string;
|
||||
teamName?: string;
|
||||
members: TeamMember[];
|
||||
}
|
||||
|
||||
export interface TeamMember {
|
||||
name: string;
|
||||
email?: string;
|
||||
role?: string;
|
||||
sharedSkills?: string[];
|
||||
lastSync?: string;
|
||||
}
|
||||
|
||||
export interface TeamServiceState {
|
||||
config: TeamConfig | null;
|
||||
members: TeamMemberDisplay[];
|
||||
sharedSkills: SharedSkillDisplay[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadTeamConfig(_projectPath?: string): Promise<TeamServiceState> {
|
||||
return {
|
||||
config: null,
|
||||
members: [],
|
||||
sharedSkills: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function initializeTeam(
|
||||
_teamName: string,
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function addTeamMember(
|
||||
_member: { name: string; email?: string; role?: string },
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function removeTeamMember(
|
||||
_memberName: string,
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function shareSkill(
|
||||
_skillName: string,
|
||||
_targetMembers?: string[],
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function createBundle(
|
||||
_skills: string[],
|
||||
_bundleName: string,
|
||||
_projectPath?: string
|
||||
): Promise<string | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function importSkillBundle(
|
||||
_bundlePath: string,
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export const teamService = {
|
||||
loadTeamConfig,
|
||||
initializeTeam,
|
||||
addTeamMember,
|
||||
removeTeamMember,
|
||||
shareSkill,
|
||||
createBundle,
|
||||
importSkillBundle,
|
||||
};
|
||||
@@ -0,0 +1,164 @@
|
||||
export type AgentType =
|
||||
| 'claude-code'
|
||||
| 'cursor'
|
||||
| 'windsurf'
|
||||
| 'github-copilot'
|
||||
| 'codex'
|
||||
| 'gemini-cli'
|
||||
| 'opencode'
|
||||
| 'universal'
|
||||
| 'antigravity'
|
||||
| 'amp'
|
||||
| 'clawdbot'
|
||||
| 'droid'
|
||||
| 'goose'
|
||||
| 'kilo'
|
||||
| 'kiro-cli'
|
||||
| 'roo'
|
||||
| 'trae'
|
||||
| 'cline'
|
||||
| 'codebuddy'
|
||||
| 'commandcode'
|
||||
| 'continue'
|
||||
| 'crush'
|
||||
| 'factory'
|
||||
| 'mcpjam'
|
||||
| 'mux'
|
||||
| 'neovate'
|
||||
| 'openhands'
|
||||
| 'pi'
|
||||
| 'qoder'
|
||||
| 'qwen'
|
||||
| 'vercel'
|
||||
| 'zencoder';
|
||||
|
||||
export interface TranslationDisplay {
|
||||
sourceFormat: string;
|
||||
targetAgent: AgentType;
|
||||
success: boolean;
|
||||
content: string;
|
||||
filename?: string;
|
||||
warnings: string[];
|
||||
incompatible: string[];
|
||||
}
|
||||
|
||||
export interface TranslationOptions {
|
||||
sourceFilename?: string;
|
||||
preserveMetadata?: boolean;
|
||||
}
|
||||
|
||||
export interface CanonicalSkill {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
content: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface TranslatorServiceState {
|
||||
supportedAgents: AgentType[];
|
||||
sourceAgent: AgentType | null;
|
||||
targetAgent: AgentType | null;
|
||||
skill: CanonicalSkill | null;
|
||||
result: TranslationDisplay | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export function getSupportedAgents(): AgentType[] {
|
||||
return [
|
||||
'claude-code',
|
||||
'cursor',
|
||||
'windsurf',
|
||||
'github-copilot',
|
||||
'codex',
|
||||
'gemini-cli',
|
||||
'opencode',
|
||||
'universal',
|
||||
];
|
||||
}
|
||||
|
||||
export function checkCanTranslate(_from: AgentType, _to: AgentType): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function translate(
|
||||
_content: string,
|
||||
targetAgent: AgentType,
|
||||
options?: TranslationOptions
|
||||
): TranslationDisplay {
|
||||
return {
|
||||
sourceFormat: options?.sourceFilename || 'SKILL.md',
|
||||
targetAgent,
|
||||
success: true,
|
||||
content: '',
|
||||
filename: undefined,
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function translateFromFile(
|
||||
sourcePath: string,
|
||||
targetAgent: AgentType,
|
||||
_options?: TranslationOptions
|
||||
): TranslationDisplay {
|
||||
return {
|
||||
sourceFormat: sourcePath,
|
||||
targetAgent,
|
||||
success: true,
|
||||
content: '',
|
||||
filename: undefined,
|
||||
warnings: [],
|
||||
incompatible: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function parseSkill(_content: string, _filename?: string): CanonicalSkill | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function detectFormat(_content: string, _filename?: string): string | null {
|
||||
return 'markdown';
|
||||
}
|
||||
|
||||
export function previewTranslation(
|
||||
_content: string,
|
||||
_targetAgent: AgentType
|
||||
): { preview: string; compatible: boolean; issues: string[] } {
|
||||
return {
|
||||
preview: '',
|
||||
compatible: true,
|
||||
issues: [],
|
||||
};
|
||||
}
|
||||
|
||||
export function getAgentFormatInfo(agent: AgentType): {
|
||||
extension: string;
|
||||
formatName: string;
|
||||
description: string;
|
||||
} {
|
||||
const formatMap: Record<string, { extension: string; formatName: string; description: string }> = {
|
||||
'claude-code': { extension: '.md', formatName: 'SKILL.md', description: 'Claude Code skills format' },
|
||||
cursor: { extension: '.mdc', formatName: 'MDC', description: 'Cursor rules format' },
|
||||
windsurf: { extension: '.md', formatName: 'Markdown', description: 'Windsurf rules format' },
|
||||
'github-copilot': { extension: '.md', formatName: 'Markdown', description: 'GitHub Copilot instructions' },
|
||||
codex: { extension: '.md', formatName: 'Markdown', description: 'Codex instructions' },
|
||||
'gemini-cli': { extension: '.md', formatName: 'Markdown', description: 'Gemini CLI instructions' },
|
||||
opencode: { extension: '.md', formatName: 'Markdown', description: 'OpenCode instructions' },
|
||||
universal: { extension: '.md', formatName: 'SKILL.md', description: 'Universal skill format' },
|
||||
};
|
||||
|
||||
return formatMap[agent] || { extension: '.md', formatName: 'Markdown', description: 'Unknown format' };
|
||||
}
|
||||
|
||||
export const translatorService = {
|
||||
getSupportedAgents,
|
||||
checkCanTranslate,
|
||||
translate,
|
||||
translateFromFile,
|
||||
parseSkill,
|
||||
detectFormat,
|
||||
previewTranslation,
|
||||
getAgentFormatInfo,
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
export interface WorkflowListItem {
|
||||
name: string;
|
||||
description: string;
|
||||
skills: number;
|
||||
waves: number;
|
||||
lastRun?: string;
|
||||
status: 'ready' | 'running' | 'completed' | 'failed';
|
||||
}
|
||||
|
||||
export interface Workflow {
|
||||
name: string;
|
||||
description?: string;
|
||||
waves: WorkflowWave[];
|
||||
metadata?: {
|
||||
lastRun?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface WorkflowWave {
|
||||
name: string;
|
||||
skills: string[];
|
||||
parallel?: boolean;
|
||||
}
|
||||
|
||||
export interface WorkflowResult {
|
||||
success: boolean;
|
||||
completedWaves: number;
|
||||
totalWaves: number;
|
||||
errors: string[];
|
||||
}
|
||||
|
||||
export interface WorkflowProgress {
|
||||
currentWave: number;
|
||||
totalWaves: number;
|
||||
currentSkill?: string;
|
||||
totalSkills?: number;
|
||||
completedSkills?: number;
|
||||
status: 'running' | 'completed' | 'failed';
|
||||
}
|
||||
|
||||
export interface WorkflowServiceState {
|
||||
workflows: WorkflowListItem[];
|
||||
current: Workflow | null;
|
||||
progress: WorkflowProgress | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
export async function loadWorkflowsList(_projectPath?: string): Promise<WorkflowServiceState> {
|
||||
return {
|
||||
workflows: [],
|
||||
current: null,
|
||||
progress: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loadWorkflow(_name: string, _projectPath?: string): Promise<Workflow | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function executeWorkflow(
|
||||
_name: string,
|
||||
_projectPath?: string,
|
||||
_onProgress?: (progress: WorkflowProgress) => void
|
||||
): Promise<WorkflowResult | null> {
|
||||
return { success: true, completedWaves: 0, totalWaves: 0, errors: [] };
|
||||
}
|
||||
|
||||
export async function createNewWorkflow(
|
||||
_name: string,
|
||||
_description: string,
|
||||
_projectPath?: string
|
||||
): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function validateWorkflowByName(
|
||||
_name: string,
|
||||
_projectPath?: string
|
||||
): Promise<{ valid: boolean; errors: string[] }> {
|
||||
return { valid: true, errors: [] };
|
||||
}
|
||||
|
||||
export const workflowService = {
|
||||
loadWorkflowsList,
|
||||
loadWorkflow,
|
||||
executeWorkflow,
|
||||
createNewWorkflow,
|
||||
validateWorkflowByName,
|
||||
};
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
import 'solid-js';
|
||||
|
||||
declare module 'solid-js' {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
box: BoxProps;
|
||||
text: TextProps;
|
||||
span: SpanProps;
|
||||
}
|
||||
|
||||
interface BoxProps {
|
||||
children?: Element | Element[];
|
||||
flexDirection?: 'row' | 'column';
|
||||
flexGrow?: number;
|
||||
flexShrink?: number;
|
||||
flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse';
|
||||
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
||||
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
||||
alignSelf?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
||||
gap?: number;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
minWidth?: number;
|
||||
minHeight?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
padding?: number;
|
||||
paddingTop?: number;
|
||||
paddingBottom?: number;
|
||||
paddingLeft?: number;
|
||||
paddingRight?: number;
|
||||
paddingX?: number;
|
||||
paddingY?: number;
|
||||
margin?: number;
|
||||
marginTop?: number;
|
||||
marginBottom?: number;
|
||||
marginLeft?: number;
|
||||
marginRight?: number;
|
||||
marginX?: number;
|
||||
marginY?: number;
|
||||
borderStyle?: 'single' | 'double' | 'round' | 'bold' | 'singleDouble' | 'doubleSingle' | 'classic';
|
||||
borderColor?: string;
|
||||
borderTop?: boolean;
|
||||
borderBottom?: boolean;
|
||||
borderLeft?: boolean;
|
||||
borderRight?: boolean;
|
||||
backgroundColor?: string;
|
||||
overflow?: 'visible' | 'hidden';
|
||||
position?: 'relative' | 'absolute';
|
||||
top?: number;
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
right?: number;
|
||||
fg?: string;
|
||||
style?: Record<string, unknown>;
|
||||
onClick?: () => void;
|
||||
onDoubleClick?: () => void;
|
||||
onContextMenu?: () => void;
|
||||
onMouseEnter?: () => void;
|
||||
onMouseLeave?: () => void;
|
||||
onMouseDown?: () => void;
|
||||
onMouseUp?: () => void;
|
||||
}
|
||||
|
||||
interface TextProps {
|
||||
children?: Element | Element[] | string | number;
|
||||
fg?: string;
|
||||
bg?: string;
|
||||
color?: string;
|
||||
backgroundColor?: string;
|
||||
bold?: boolean;
|
||||
italic?: boolean;
|
||||
underline?: boolean;
|
||||
strikethrough?: boolean;
|
||||
dimmed?: boolean;
|
||||
inverse?: boolean;
|
||||
wrap?: 'wrap' | 'truncate' | 'truncate-start' | 'truncate-middle' | 'truncate-end';
|
||||
width?: number;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
interface SpanProps extends TextProps {}
|
||||
}
|
||||
}
|
||||
|
||||
declare module '@opentui/solid' {
|
||||
import { CliRenderer, CliRendererConfig } from '@opentui/core';
|
||||
|
||||
export function render(
|
||||
component: () => JSX.Element,
|
||||
rendererOrConfig?: CliRenderer | CliRendererConfig
|
||||
): Promise<void>;
|
||||
|
||||
export function useKeyboard(
|
||||
handler: (key: {
|
||||
name?: string;
|
||||
ctrl?: boolean;
|
||||
shift?: boolean;
|
||||
alt?: boolean;
|
||||
meta?: boolean;
|
||||
sequence?: string;
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
export function useStdout(): {
|
||||
write: (text: string) => void;
|
||||
};
|
||||
|
||||
export function useStdin(): {
|
||||
setRawMode: (mode: boolean) => void;
|
||||
};
|
||||
|
||||
export function useFocus(): {
|
||||
isFocused: boolean;
|
||||
focus: () => void;
|
||||
blur: () => void;
|
||||
};
|
||||
}
|
||||
|
||||
declare module '@opentui/core' {
|
||||
export interface CliRenderer {
|
||||
readonly stdin: NodeJS.ReadStream;
|
||||
readonly stdout: NodeJS.WriteStream;
|
||||
}
|
||||
|
||||
export interface CliRendererConfig {
|
||||
exitOnCtrlC?: boolean;
|
||||
stdin?: NodeJS.ReadStream;
|
||||
stdout?: NodeJS.WriteStream;
|
||||
}
|
||||
|
||||
export function createCliRenderer(options?: CliRendererConfig): Promise<CliRenderer>;
|
||||
}
|
||||
@@ -28,8 +28,10 @@ export {
|
||||
// Skills
|
||||
export {
|
||||
type SkillsState,
|
||||
type SkillWithDetails,
|
||||
createSkillsState,
|
||||
loadSkills,
|
||||
loadSkillsWithDetails,
|
||||
removeSkill,
|
||||
filterSkills,
|
||||
} from './skills.js';
|
||||
|
||||
@@ -8,6 +8,17 @@ import { getSearchDirs } from '../utils/helpers.js';
|
||||
import type { SkillItem } from './types.js';
|
||||
import type { AgentType } from '@skillkit/core';
|
||||
|
||||
/**
|
||||
* Detailed skill info including path for translation
|
||||
*/
|
||||
export interface SkillWithDetails {
|
||||
name: string;
|
||||
description?: string;
|
||||
path: string;
|
||||
source?: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skills store state
|
||||
*/
|
||||
@@ -111,3 +122,25 @@ export function filterSkills(skills: SkillItem[], query: string): SkillItem[] {
|
||||
s.source?.toLowerCase().includes(lowerQuery)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load skills with full details including path for translation
|
||||
* @param agentType - Optional agent type to load skills for
|
||||
* @returns Array of skills with path details
|
||||
*/
|
||||
export function loadSkillsWithDetails(agentType?: AgentType): SkillWithDetails[] {
|
||||
try {
|
||||
const searchDirs = getSearchDirs(agentType);
|
||||
const foundSkills = findAllSkills(searchDirs);
|
||||
|
||||
return foundSkills.map((s) => ({
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
path: s.path,
|
||||
source: s.metadata?.source,
|
||||
enabled: s.enabled,
|
||||
}));
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,3 +147,154 @@ export function scrambleText(
|
||||
export function getStaggerDelay(index: number, stagger: number = 100): number {
|
||||
return index * stagger;
|
||||
}
|
||||
|
||||
/**
|
||||
* New animation presets (Phase 1.4)
|
||||
*/
|
||||
export const interactionAnimations = {
|
||||
/**
|
||||
* Element appearance animation
|
||||
*/
|
||||
fadeIn: {
|
||||
duration: 200,
|
||||
ease: 'easeOutQuad' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Element disappear animation
|
||||
*/
|
||||
fadeOut: {
|
||||
duration: 150,
|
||||
ease: 'easeInQuad' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Detail pane slide in from right
|
||||
*/
|
||||
slideInRight: {
|
||||
duration: 250,
|
||||
ease: 'easeOutCubic' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Detail pane slide out to right
|
||||
*/
|
||||
slideOutRight: {
|
||||
duration: 200,
|
||||
ease: 'easeInCubic' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Hover state transition
|
||||
*/
|
||||
hover: {
|
||||
duration: 100,
|
||||
ease: 'easeOutQuad' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Button press feedback
|
||||
*/
|
||||
press: {
|
||||
duration: 50,
|
||||
ease: 'easeOutQuad' as EasingFunction,
|
||||
},
|
||||
|
||||
/**
|
||||
* Typewriter text reveal (per character)
|
||||
*/
|
||||
typewriter: {
|
||||
duration: 30,
|
||||
ease: 'linear' as EasingFunction,
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Animation timing constants
|
||||
*/
|
||||
export const ANIMATION_DURATIONS = {
|
||||
instant: 0,
|
||||
fast: 100,
|
||||
normal: 200,
|
||||
slow: 400,
|
||||
verySlow: 800,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Frame rate constants
|
||||
*/
|
||||
export const FRAME_RATE = {
|
||||
fps60: 1000 / 60,
|
||||
fps30: 1000 / 30,
|
||||
fps24: 1000 / 24,
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Spinner frame animations
|
||||
*/
|
||||
export const SPINNER_FRAMES = {
|
||||
braille: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
|
||||
dots: ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷'],
|
||||
line: ['|', '/', '-', '\\'],
|
||||
arrow: ['←', '↖', '↑', '↗', '→', '↘', '↓', '↙'],
|
||||
bounce: ['⠁', '⠂', '⠄', '⠂'],
|
||||
pulse: ['◐', '◓', '◑', '◒'],
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Progress bar characters
|
||||
*/
|
||||
export const PROGRESS_CHARS = {
|
||||
filled: '█',
|
||||
empty: '░',
|
||||
partial: ['▏', '▎', '▍', '▌', '▋', '▊', '▉'],
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Create a spring animation curve
|
||||
*/
|
||||
export function springCurve(
|
||||
progress: number,
|
||||
tension: number = 0.5,
|
||||
friction: number = 0.5
|
||||
): number {
|
||||
if (progress <= 0) return 0;
|
||||
if (progress >= 1) return 1;
|
||||
const p = progress;
|
||||
const oscillation = Math.sin(p * Math.PI * (1 + tension * 4));
|
||||
const damping = Math.exp(-p * friction * 6);
|
||||
return 1 - damping * oscillation * (1 - p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a bounce animation curve
|
||||
*/
|
||||
export function bounceCurve(progress: number): number {
|
||||
const n1 = 7.5625;
|
||||
const d1 = 2.75;
|
||||
let p = progress;
|
||||
|
||||
if (p < 1 / d1) {
|
||||
return n1 * p * p;
|
||||
} else if (p < 2 / d1) {
|
||||
return n1 * (p -= 1.5 / d1) * p + 0.75;
|
||||
} else if (p < 2.5 / d1) {
|
||||
return n1 * (p -= 2.25 / d1) * p + 0.9375;
|
||||
} else {
|
||||
return n1 * (p -= 2.625 / d1) * p + 0.984375;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate between two values
|
||||
*/
|
||||
export function lerp(start: number, end: number, progress: number): number {
|
||||
return start + (end - start) * progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp a value between min and max
|
||||
*/
|
||||
export function clamp(value: number, min: number, max: number): number {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
|
||||
@@ -66,13 +66,23 @@ export function saveSkillMetadata(
|
||||
*/
|
||||
export function getVersion(): string {
|
||||
try {
|
||||
// Try to read from package.json relative to the built file
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const packagePath = join(__dirname, '..', '..', 'package.json');
|
||||
const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
||||
return packageJson.version || '1.0.0';
|
||||
const paths = [
|
||||
join(__dirname, '..', 'package.json'),
|
||||
join(__dirname, '..', '..', 'package.json'),
|
||||
join(__dirname, '..', '..', '..', 'package.json'),
|
||||
];
|
||||
for (const packagePath of paths) {
|
||||
try {
|
||||
const packageJson = JSON.parse(readFileSync(packagePath, 'utf-8'));
|
||||
if (packageJson.name === '@skillkit/tui' || packageJson.name === 'skillkit') {
|
||||
return packageJson.version || '1.8.0';
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
return '1.8.0';
|
||||
} catch {
|
||||
return '1.0.0';
|
||||
return '1.8.0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "@opentui/react",
|
||||
"jsx": "preserve",
|
||||
"jsxImportSource": "solid-js",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
import { solidPlugin } from 'esbuild-plugin-solid';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const solidPath = require.resolve('solid-js').replace(/dist\/server\.(cjs|js)$/, 'dist/solid.js');
|
||||
const solidWebPath = require.resolve('solid-js/web').replace(/dist\/server\.(cjs|js)$/, 'dist/web.js');
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.tsx'],
|
||||
@@ -13,9 +23,20 @@ export default defineConfig({
|
||||
},
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
external: ['react', '@opentui/core', '@opentui/react'],
|
||||
external: ['@opentui/core'],
|
||||
noExternal: ['solid-js', '@opentui/solid'],
|
||||
esbuildPlugins: [
|
||||
solidPlugin({
|
||||
solid: {
|
||||
generate: 'universal',
|
||||
moduleName: '@opentui/solid',
|
||||
},
|
||||
}),
|
||||
],
|
||||
esbuildOptions(options) {
|
||||
options.jsx = 'automatic';
|
||||
options.jsxImportSource = '@opentui/react';
|
||||
options.alias = {
|
||||
'solid-js': solidPath,
|
||||
'solid-js/web': solidWebPath,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Generated
+684
-78
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user