mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-20 20:34:46 +00:00
* feat: add TUI enhancements and monorepo structure - Add Translate screen for cross-agent skill translation - Add Context screen for project context management - Add Recommend screen with smart skill recommendations - Fix TUI screen duplication by using fixed height container - Clean up unnecessary comments following code-simplifier principles - Refactor to monorepo structure with @skillkit/core, @skillkit/cli, @skillkit/tui, and @skillkit/agents packages - Add comprehensive tests for translator, context, and recommend features - Update license to Apache-2.0 - Add CONTRIBUTING.md with contribution guidelines * ci: switch from npm to pnpm for monorepo support * ci: use pnpm version from package.json * fix: remove unused import in TUI helpers
89 lines
2.3 KiB
TypeScript
89 lines
2.3 KiB
TypeScript
import { existsSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { homedir } from 'node:os';
|
|
import type { AgentAdapter } from './base.js';
|
|
import type { Skill, AgentType } from '@skillkit/core';
|
|
|
|
export class GeminiCliAdapter implements AgentAdapter {
|
|
readonly type: AgentType = 'gemini-cli';
|
|
readonly name = 'Gemini CLI';
|
|
readonly skillsDir = '.gemini/skills';
|
|
readonly configFile = 'GEMINI.md';
|
|
|
|
generateConfig(skills: Skill[]): string {
|
|
const enabledSkills = skills.filter(s => s.enabled);
|
|
|
|
if (enabledSkills.length === 0) {
|
|
return '';
|
|
}
|
|
|
|
const skillsJson = enabledSkills.map(s => ({
|
|
name: s.name,
|
|
description: s.description,
|
|
invoke: `skillkit read ${s.name}`,
|
|
location: s.location,
|
|
}));
|
|
|
|
return `# Skills Configuration
|
|
|
|
You have access to specialized skills that extend your capabilities.
|
|
|
|
## Available Skills
|
|
|
|
${enabledSkills.map(s => `### ${s.name}\n${s.description}\n\nInvoke: \`skillkit read ${s.name}\``).join('\n\n')}
|
|
|
|
## Skills Data
|
|
|
|
\`\`\`json
|
|
${JSON.stringify(skillsJson, null, 2)}
|
|
\`\`\`
|
|
|
|
## Usage Instructions
|
|
|
|
1. When a task matches a skill's description, load it using the invoke command
|
|
2. Skills provide step-by-step instructions for complex tasks
|
|
3. Each skill is self-contained with its own resources
|
|
`;
|
|
}
|
|
|
|
parseConfig(content: string): string[] {
|
|
const skillNames: string[] = [];
|
|
|
|
const jsonMatch = content.match(/```json\s*([\s\S]*?)```/);
|
|
if (jsonMatch) {
|
|
try {
|
|
const skills = JSON.parse(jsonMatch[1]);
|
|
if (Array.isArray(skills)) {
|
|
skills.forEach(s => {
|
|
if (s.name) skillNames.push(s.name);
|
|
});
|
|
}
|
|
} catch {
|
|
// Ignore parse errors
|
|
}
|
|
}
|
|
|
|
if (skillNames.length === 0) {
|
|
const headerRegex = /^### ([a-z0-9-]+)$/gm;
|
|
let match;
|
|
while ((match = headerRegex.exec(content)) !== null) {
|
|
skillNames.push(match[1].trim());
|
|
}
|
|
}
|
|
|
|
return skillNames;
|
|
}
|
|
|
|
getInvokeCommand(skillName: string): string {
|
|
return `skillkit read ${skillName}`;
|
|
}
|
|
|
|
async isDetected(): Promise<boolean> {
|
|
const geminiMd = join(process.cwd(), 'GEMINI.md');
|
|
const geminiDir = join(process.cwd(), '.gemini');
|
|
const globalGemini = join(homedir(), '.gemini');
|
|
|
|
return existsSync(geminiMd) || existsSync(geminiDir) || existsSync(globalGemini);
|
|
}
|
|
}
|