mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +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
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { existsSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { homedir } from 'node:os';
|
|
import type { AgentAdapter } from './base.js';
|
|
import { createSkillXml } from './base.js';
|
|
import type { Skill, AgentType } from '@skillkit/core';
|
|
|
|
export class OpenCodeAdapter implements AgentAdapter {
|
|
readonly type: AgentType = 'opencode';
|
|
readonly name = 'OpenCode';
|
|
readonly skillsDir = '.opencode/skills';
|
|
readonly configFile = 'AGENTS.md';
|
|
|
|
generateConfig(skills: Skill[]): string {
|
|
const enabledSkills = skills.filter(s => s.enabled);
|
|
|
|
if (enabledSkills.length === 0) {
|
|
return '';
|
|
}
|
|
|
|
const skillsXml = enabledSkills.map(createSkillXml).join('\n\n');
|
|
|
|
return `<!-- SKILLKIT_START -->
|
|
# Skills
|
|
|
|
The following skills are available to help complete tasks:
|
|
|
|
<skills>
|
|
${skillsXml}
|
|
</skills>
|
|
|
|
## How to Use
|
|
|
|
When a task matches a skill's description:
|
|
|
|
\`\`\`bash
|
|
skillkit read <skill-name>
|
|
\`\`\`
|
|
|
|
This loads the skill's instructions into context.
|
|
|
|
<!-- SKILLKIT_END -->`;
|
|
}
|
|
|
|
parseConfig(content: string): string[] {
|
|
const skillNames: string[] = [];
|
|
const skillRegex = /<name>([^<]+)<\/name>/g;
|
|
let match;
|
|
|
|
while ((match = skillRegex.exec(content)) !== null) {
|
|
skillNames.push(match[1].trim());
|
|
}
|
|
|
|
return skillNames;
|
|
}
|
|
|
|
getInvokeCommand(skillName: string): string {
|
|
return `skillkit read ${skillName}`;
|
|
}
|
|
|
|
async isDetected(): Promise<boolean> {
|
|
const opencodeDir = join(process.cwd(), '.opencode');
|
|
const globalOpencode = join(homedir(), '.opencode');
|
|
|
|
return existsSync(opencodeDir) || existsSync(globalOpencode);
|
|
}
|
|
}
|