Compare commits

..
Author SHA1 Message Date
Rohit Ghumare b456f7b691 feat: add skillkit primer command for AI instruction generation
New feature that analyzes codebases and generates AI instruction files
for all 32 supported agents (inspired by pierceboggan/primer).

## New Module: packages/core/src/primer/
- types.ts: Zod schemas and TypeScript interfaces
- analyzer.ts: Codebase analysis (languages, frameworks, conventions)
- generator.ts: Agent-specific instruction file generation
- index.ts: Barrel exports
- __tests__/primer.test.ts: 15 comprehensive tests

## CLI Command: skillkit primer
- --agent/-a: Generate for specific agents
- --all-agents/-A: Generate for all 32 agents
- --output/-o: Custom output directory
- --dry-run/-n: Preview without writing
- --analyze-only: Show analysis only
- --verbose/-v: Detailed output
- --json/-j: JSON output

## Features
- Detects: languages, frameworks, package managers, libraries
- Analyzes: project structure, code conventions, CI/CD, Docker
- Generates: CLAUDE.md, .cursorrules, copilot-instructions.md, etc.
2026-01-29 13:32:12 +00:00
Rohit Ghumare a5d692093a fix: add all 32 agents to documentation and tests
- apps/skillkit/README.md: Split agents into Primary (17) and Extended (15)
- e2e/onboarding-ui.e2e.test.ts: Add 15 extended agents to test array
- e2e/translation.e2e.test.ts: Add 15 extended agents to SUPPORTED_AGENTS
- README.md: Add extended agents to inline list and table
2026-01-29 13:20:06 +00:00
Rohit Ghumare 6c8d5b0a72 fix: update agent count from 17 to 32 across codebase
- Update all documentation files (README.md, package READMEs)
- Update hardcoded AGENT_COUNT constant in onboarding
- Update JSDoc comments in core modules
- Update test files and e2e tests
- SkillKit now supports 32 AI coding agents:
  Primary: claude-code, codex, cursor, antigravity, opencode,
  gemini-cli, amp, clawdbot, droid, github-copilot, goose,
  kilo, kiro-cli, roo, trae, windsurf, universal
  Extended: cline, codebuddy, commandcode, continue, crush,
  factory, mcpjam, mux, neovate, openhands, pi, qoder, qwen,
  vercel, zencoder
2026-01-29 13:07:52 +00:00
14 changed files with 176 additions and 358 deletions
-3
View File
@@ -323,9 +323,6 @@ skillkit primer --all-agents # Generate for all 32 agents
skillkit primer --agent claude-code,cursor # Specific agents only
skillkit primer --dry-run # Preview without writing files
skillkit primer --analyze-only # Only show codebase analysis
skillkit primer --output ./instructions # Write to custom directory
skillkit primer --json # Output analysis as JSON (for scripting)
skillkit primer --json --analyze-only # Machine-readable analysis
```
Inspired by [primer](https://github.com/pierceboggan/primer) but extended for all SkillKit agents.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "skillkit",
"version": "1.7.10",
"version": "1.7.9",
"description": "Supercharge AI coding agents with portable skills. Install, translate, and share skills across Claude Code, Cursor, Codex, Copilot & 13 more",
"type": "module",
"bin": {
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "skillkit-monorepo",
"version": "1.7.10",
"version": "1.7.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "skillkit-monorepo",
"version": "1.7.10",
"version": "1.7.2",
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^22.10.5",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "skillkit-monorepo",
"version": "1.7.10",
"version": "1.7.9",
"private": true,
"description": "Universal skills loader for AI coding agents - Monorepo",
"type": "module",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@skillkit/agents",
"version": "1.7.10",
"version": "1.7.9",
"description": "Agent adapters for SkillKit - supports 32 AI coding agents",
"type": "module",
"main": "./dist/index.js",
+2 -10
View File
@@ -81,16 +81,8 @@ export function getAdapter(type: AgentType): AgentAdapter {
return adapters[type];
}
export interface AgentAdapterWithType extends AgentAdapter {
readonly agentType: AgentType;
}
export function getAllAdapters(): AgentAdapterWithType[] {
return Object.entries(adapters).map(([type, adapter]) => ({
...adapter,
type: type as AgentType,
agentType: type as AgentType,
}));
export function getAllAdapters(): AgentAdapter[] {
return Object.values(adapters);
}
export async function detectAgent(): Promise<AgentType> {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@skillkit/cli",
"version": "1.7.10",
"version": "1.7.9",
"description": "CLI commands for SkillKit",
"type": "module",
"main": "./dist/index.js",
+1
View File
@@ -107,6 +107,7 @@ export class PrimerCommand extends Command {
try {
const result = generatePrimer(projectPath, {
projectPath,
agents,
allAgents: this.allAgents,
outputDir: this.output ? resolve(this.output) : undefined,
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@skillkit/core",
"version": "1.7.10",
"version": "1.7.9",
"description": "Core functionality for SkillKit - skill discovery, parsing, and translation",
"type": "module",
"main": "./dist/index.js",
@@ -173,7 +173,6 @@ describe('Primer', () => {
});
expect(result.success).toBe(true);
expect(result.generated.length).toBeGreaterThan(0);
const instruction = result.generated[0];
expect(instruction.content).toContain('# test-project');
+13 -21
View File
@@ -1,5 +1,5 @@
import { existsSync, readFileSync, readdirSync } from 'node:fs';
import { join, basename, relative, sep } from 'node:path';
import { join, basename } from 'node:path';
import type {
PrimerAnalysis,
PackageManager,
@@ -125,8 +125,7 @@ export class PrimerAnalyzer {
try {
const entries = readdirSync(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = join(dir, entry.name);
const relativePath = relative(this.projectPath, fullPath);
const relativePath = join(dir, entry.name).replace(this.projectPath + '/', '');
if (entry.name.startsWith('.') && entry.name !== '.github' && entry.name !== '.env.example') {
if (!entry.isDirectory()) {
this.files.add(relativePath);
@@ -138,7 +137,7 @@ export class PrimerAnalyzer {
}
this.files.add(relativePath);
if (entry.isDirectory()) {
scan(fullPath, depth + 1);
scan(join(dir, entry.name), depth + 1);
}
}
} catch {
@@ -232,15 +231,10 @@ export class PrimerAnalyzer {
}
if (this.hasFile('pyproject.toml') || this.hasFile('requirements.txt') || this.hasFile('setup.py')) {
const source = this.hasFile('pyproject.toml')
? 'pyproject.toml'
: this.hasFile('requirements.txt')
? 'requirements.txt'
: 'setup.py';
languages.push({
name: 'python',
confidence: 100,
source,
source: 'pyproject.toml',
});
}
@@ -295,8 +289,8 @@ export class PrimerAnalyzer {
return languages;
}
private detectPackageManagers(): PackageManager[] {
const managers: Set<PackageManager> = new Set();
private detectPackageManagers(): string[] {
const managers: Set<string> = new Set();
for (const [file, manager] of Object.entries(PACKAGE_MANAGER_FILES)) {
if (this.hasFile(file)) {
@@ -308,8 +302,8 @@ export class PrimerAnalyzer {
const packageManager = this.packageJson.packageManager;
if (typeof packageManager === 'string') {
const match = packageManager.match(/^(npm|pnpm|yarn|bun)@/);
if (match && ['npm', 'pnpm', 'yarn', 'bun'].includes(match[1])) {
managers.add(match[1] as PackageManager);
if (match) {
managers.add(match[1]);
}
}
}
@@ -322,11 +316,11 @@ export class PrimerAnalyzer {
hasWorkspaces: false,
};
if (this.hasFile('packages') || this.hasFile('apps')) {
structure.type = 'monorepo';
} else if (this.hasFile('src')) {
if (this.hasFile('src')) {
structure.type = 'src-based';
structure.srcDir = 'src';
} else if (this.hasFile('packages') || this.hasFile('apps')) {
structure.type = 'monorepo';
} else if (this.hasFile('lib')) {
structure.type = 'src-based';
structure.srcDir = 'lib';
@@ -588,7 +582,7 @@ export class PrimerAnalyzer {
let directories = 0;
for (const file of this.files) {
if (file.includes(sep)) {
if (file.includes('/')) {
directories++;
}
files++;
@@ -602,9 +596,7 @@ export class PrimerAnalyzer {
private hasFile(name: string): boolean {
if (name.includes('*')) {
const regex = new RegExp(
name.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')
);
const regex = new RegExp(name.replace(/\*/g, '.*'));
for (const file of this.files) {
if (regex.test(file)) return true;
}
+151 -314
View File
@@ -12,121 +12,40 @@ import type {
import { AGENT_INSTRUCTION_TEMPLATES } from './types.js';
import { analyzePrimer } from './analyzer.js';
const ALL_AGENTS: AgentType[] = Object.keys(AGENT_CONFIG) as AgentType[];
type OutputFormat = 'markdown' | 'mdc' | 'json' | 'xml';
interface FormatRenderer {
h1(text: string): string;
h2(text: string): string;
h3(text: string): string;
bold(text: string): string;
code(text: string): string;
codeBlock(code: string, lang?: string): string;
list(items: string[]): string;
keyValue(key: string, value: string): string;
paragraph(text: string): string;
separator(): string;
wrap(content: string, metadata?: Record<string, unknown>): string;
}
const markdownRenderer: FormatRenderer = {
h1: (text) => `# ${text}`,
h2: (text) => `## ${text}`,
h3: (text) => `### ${text}`,
bold: (text) => `**${text}**`,
code: (text) => `\`${text}\``,
codeBlock: (code, lang = '') => `\`\`\`${lang}\n${code}\n\`\`\``,
list: (items) => items.map(item => `- ${item}`).join('\n'),
keyValue: (key, value) => `**${key}:** ${value}`,
paragraph: (text) => text,
separator: () => '',
wrap: (content) => content,
};
const mdcRenderer: FormatRenderer = {
h1: (text) => `# ${text}`,
h2: (text) => `## ${text}`,
h3: (text) => `### ${text}`,
bold: (text) => `**${text}**`,
code: (text) => `\`${text}\``,
codeBlock: (code, lang = '') => `\`\`\`${lang}\n${code}\n\`\`\``,
list: (items) => items.map(item => `- ${item}`).join('\n'),
keyValue: (key, value) => `**${key}:** ${value}`,
paragraph: (text) => text,
separator: () => '',
wrap: (content, metadata) => {
if (metadata && Object.keys(metadata).length > 0) {
const yaml = Object.entries(metadata)
.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
.join('\n');
return `---\n${yaml}\n---\n\n${content}`;
}
return content;
},
};
const jsonRenderer: FormatRenderer = {
h1: (text) => text,
h2: (text) => text,
h3: (text) => text,
bold: (text) => text,
code: (text) => text,
codeBlock: (code) => code,
list: (items) => items.join(', '),
keyValue: (key, value) => `${key}: ${value}`,
paragraph: (text) => text,
separator: () => '',
wrap: (content, metadata) => {
try {
const data = { ...metadata, content };
return JSON.stringify(data, null, 2);
} catch {
return content;
}
},
};
const xmlRenderer: FormatRenderer = {
h1: (text) => `<h1>${escapeXml(text)}</h1>`,
h2: (text) => `<h2>${escapeXml(text)}</h2>`,
h3: (text) => `<h3>${escapeXml(text)}</h3>`,
bold: (text) => `<strong>${escapeXml(text)}</strong>`,
code: (text) => `<code>${escapeXml(text)}</code>`,
codeBlock: (code, lang = '') => `<pre${lang ? ` lang="${lang}"` : ''}><code>${escapeXml(code)}</code></pre>`,
list: (items) => `<ul>\n${items.map(item => ` <li>${escapeXml(item)}</li>`).join('\n')}\n</ul>`,
keyValue: (key, value) => `<dt>${escapeXml(key)}</dt><dd>${escapeXml(value)}</dd>`,
paragraph: (text) => `<p>${escapeXml(text)}</p>`,
separator: () => '',
wrap: (content, metadata) => {
const attrs = metadata
? Object.entries(metadata).map(([k, v]) => `${k}="${escapeXml(String(v))}"`).join(' ')
: '';
return `<?xml version="1.0" encoding="UTF-8"?>\n<instructions${attrs ? ' ' + attrs : ''}>\n${content}\n</instructions>`;
},
};
function escapeXml(text: string): string {
return text
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
}
function getRenderer(format: OutputFormat): FormatRenderer {
switch (format) {
case 'mdc':
return mdcRenderer;
case 'json':
return jsonRenderer;
case 'xml':
return xmlRenderer;
default:
return markdownRenderer;
}
}
const ALL_AGENTS: AgentType[] = [
'claude-code',
'cursor',
'codex',
'gemini-cli',
'opencode',
'antigravity',
'amp',
'clawdbot',
'droid',
'github-copilot',
'goose',
'kilo',
'kiro-cli',
'roo',
'trae',
'windsurf',
'universal',
'cline',
'codebuddy',
'commandcode',
'continue',
'crush',
'factory',
'mcpjam',
'mux',
'neovate',
'openhands',
'pi',
'qoder',
'qwen',
'vercel',
'zencoder',
];
export class PrimerGenerator {
private projectPath: string;
@@ -142,7 +61,6 @@ export class PrimerGenerator {
const warnings: string[] = [];
const errors: string[] = [];
const generated: GeneratedInstruction[] = [];
const seenPaths = new Map<string, string>();
this.analysis = analyzePrimer(this.projectPath);
@@ -162,15 +80,6 @@ export class PrimerGenerator {
try {
const instruction = this.generateForAgent(agent);
if (instruction) {
const existingAgent = seenPaths.get(instruction.filepath);
if (existingAgent) {
warnings.push(
`Skipping ${agent}: output path "${instruction.filename}" already used by ${existingAgent}`
);
continue;
}
seenPaths.set(instruction.filepath, agent);
if (!this.options.dryRun) {
this.writeInstruction(instruction);
}
@@ -253,21 +162,10 @@ export class PrimerGenerator {
}
private getDefaultTemplate(agent: AgentType, config: AgentDirectoryConfig): AgentInstructionTemplate {
const formatMap: Record<string, OutputFormat> = {
'.md': 'markdown',
'.json': 'json',
'.mdc': 'mdc',
'.xml': 'xml',
};
const ext = config.configFile.includes('.')
? '.' + config.configFile.split('.').pop()
: '.md';
const format = formatMap[ext] || 'markdown';
return {
agent,
filename: config.configFile,
format,
format: 'markdown',
sectionOrder: ['overview', 'stack', 'commands', 'conventions', 'structure', 'guidelines'],
};
}
@@ -275,17 +173,10 @@ export class PrimerGenerator {
private generateContent(template: AgentInstructionTemplate): string {
if (!this.analysis) return '';
const format = template.format as OutputFormat;
const renderer = getRenderer(format);
if (format === 'json') {
return this.generateJsonContent(template);
}
const sections: string[] = [];
for (const section of template.sectionOrder) {
const content = this.generateSection(section, template, renderer);
const content = this.generateSection(section, template);
if (content) {
sections.push(content);
}
@@ -302,310 +193,271 @@ export class PrimerGenerator {
}
if (this.options.customInstructions) {
result += '\n\n' + renderer.h2('Custom Instructions') + '\n\n' + this.options.customInstructions;
result += '\n\n## Custom Instructions\n\n' + this.options.customInstructions;
}
const metadata = format === 'mdc' ? {
title: this.analysis.project.name,
type: this.analysis.project.type,
generated: new Date().toISOString(),
} : undefined;
return renderer.wrap(result, metadata);
return result;
}
private generateJsonContent(template: AgentInstructionTemplate): string {
if (!this.analysis) return '{}';
const data: Record<string, unknown> = {
project: this.analysis.project,
languages: this.analysis.languages.map(l => l.name),
packageManagers: this.analysis.packageManagers,
stack: {
frameworks: this.analysis.stack.frameworks.map(f => ({ name: f.name, version: f.version })),
libraries: this.analysis.stack.libraries.map(l => ({ name: l.name, version: l.version })),
styling: this.analysis.stack.styling.map(s => s.name),
testing: this.analysis.stack.testing.map(t => t.name),
databases: this.analysis.stack.databases.map(d => d.name),
},
commands: this.analysis.buildCommands,
conventions: this.analysis.conventions,
structure: this.analysis.structure,
importantFiles: this.analysis.importantFiles,
generated: {
agent: template.agent,
timestamp: new Date().toISOString(),
},
};
if (this.options.customInstructions) {
data.customInstructions = this.options.customInstructions;
}
return JSON.stringify(data, null, 2);
}
private generateSection(section: string, template: AgentInstructionTemplate, renderer: FormatRenderer): string {
private generateSection(section: string, template: AgentInstructionTemplate): string {
if (!this.analysis) return '';
switch (section) {
case 'overview':
return this.generateOverviewSection(renderer);
return this.generateOverviewSection();
case 'stack':
return this.generateStackSection(renderer);
return this.generateStackSection();
case 'commands':
return this.generateCommandsSection(renderer);
return this.generateCommandsSection();
case 'conventions':
return this.generateConventionsSection(renderer);
return this.generateConventionsSection();
case 'structure':
return this.generateStructureSection(renderer);
return this.generateStructureSection();
case 'guidelines':
return this.generateGuidelinesSection(template.agent, renderer);
return this.generateGuidelinesSection(template.agent);
default:
return '';
}
}
private generateOverviewSection(renderer: FormatRenderer): string {
private generateOverviewSection(): string {
if (!this.analysis) return '';
const { project, languages } = this.analysis;
const lines: string[] = [];
lines.push(renderer.h1(project.name));
lines.push(`# ${project.name}`);
lines.push('');
if (project.description) {
lines.push(renderer.paragraph(project.description));
lines.push(project.description);
lines.push('');
}
if (project.type) {
lines.push(renderer.keyValue('Project Type', this.formatProjectType(project.type)));
lines.push(`**Project Type:** ${this.formatProjectType(project.type)}`);
}
if (languages.length > 0) {
const langNames = languages.map(l => this.capitalize(l.name)).join(', ');
lines.push(renderer.keyValue('Languages', langNames));
lines.push(`**Languages:** ${langNames}`);
}
if (project.version) {
lines.push(renderer.keyValue('Version', project.version));
lines.push(`**Version:** ${project.version}`);
}
return lines.join('\n');
}
private generateStackSection(renderer: FormatRenderer): string {
private generateStackSection(): string {
if (!this.analysis) return '';
const { stack, packageManagers } = this.analysis;
const lines: string[] = [];
lines.push(renderer.h2('Technology Stack'));
lines.push('## Technology Stack');
lines.push('');
if (stack.frameworks.length > 0) {
lines.push(renderer.h3('Frameworks'));
const items = stack.frameworks.map(fw => {
lines.push('### Frameworks');
for (const fw of stack.frameworks) {
const version = fw.version ? ` (${fw.version})` : '';
return `${this.capitalize(fw.name)}${version}`;
});
lines.push(renderer.list(items));
lines.push(`- ${this.capitalize(fw.name)}${version}`);
}
lines.push('');
}
if (stack.libraries.length > 0) {
lines.push(renderer.h3('Libraries'));
const items = stack.libraries.map(lib => {
lines.push('### Libraries');
for (const lib of stack.libraries) {
const version = lib.version ? ` (${lib.version})` : '';
return `${this.capitalize(lib.name)}${version}`;
});
lines.push(renderer.list(items));
lines.push(`- ${this.capitalize(lib.name)}${version}`);
}
lines.push('');
}
if (stack.styling.length > 0) {
lines.push(renderer.h3('Styling'));
lines.push(renderer.list(stack.styling.map(s => this.capitalize(s.name))));
lines.push('### Styling');
for (const style of stack.styling) {
lines.push(`- ${this.capitalize(style.name)}`);
}
lines.push('');
}
if (stack.testing.length > 0) {
lines.push(renderer.h3('Testing'));
lines.push(renderer.list(stack.testing.map(t => this.capitalize(t.name))));
lines.push('### Testing');
for (const test of stack.testing) {
lines.push(`- ${this.capitalize(test.name)}`);
}
lines.push('');
}
if (stack.databases.length > 0) {
lines.push(renderer.h3('Databases'));
lines.push(renderer.list(stack.databases.map(d => this.capitalize(d.name))));
lines.push('### Databases');
for (const db of stack.databases) {
lines.push(`- ${this.capitalize(db.name)}`);
}
lines.push('');
}
if (packageManagers.length > 0) {
lines.push(renderer.h3('Package Manager'));
lines.push(renderer.list([packageManagers.map(pm => this.capitalize(pm)).join(', ')]));
lines.push('### Package Manager');
lines.push(`- ${packageManagers.map(pm => this.capitalize(pm)).join(', ')}`);
lines.push('');
}
return lines.join('\n');
}
private generateCommandsSection(renderer: FormatRenderer): string {
private generateCommandsSection(): string {
if (!this.analysis || !this.analysis.buildCommands) return '';
const { buildCommands } = this.analysis;
const lines: string[] = [];
const commands: string[] = [];
lines.push(renderer.h2('Development Commands'));
lines.push('## Development Commands');
lines.push('');
lines.push('```bash');
if (buildCommands.install) {
commands.push(`# Install dependencies`);
commands.push(buildCommands.install);
commands.push('');
lines.push(`# Install dependencies`);
lines.push(buildCommands.install);
lines.push('');
}
if (buildCommands.dev) {
commands.push(`# Start development server`);
commands.push(buildCommands.dev);
commands.push('');
lines.push(`# Start development server`);
lines.push(buildCommands.dev);
lines.push('');
}
if (buildCommands.build) {
commands.push(`# Build for production`);
commands.push(buildCommands.build);
commands.push('');
lines.push(`# Build for production`);
lines.push(buildCommands.build);
lines.push('');
}
if (buildCommands.test) {
commands.push(`# Run tests`);
commands.push(buildCommands.test);
commands.push('');
lines.push(`# Run tests`);
lines.push(buildCommands.test);
lines.push('');
}
if (buildCommands.lint) {
commands.push(`# Run linter`);
commands.push(buildCommands.lint);
commands.push('');
lines.push(`# Run linter`);
lines.push(buildCommands.lint);
lines.push('');
}
if (buildCommands.format) {
commands.push(`# Format code`);
commands.push(buildCommands.format);
lines.push(`# Format code`);
lines.push(buildCommands.format);
}
lines.push(renderer.codeBlock(commands.join('\n'), 'bash'));
lines.push('```');
return lines.join('\n');
}
private generateConventionsSection(renderer: FormatRenderer): string {
private generateConventionsSection(): string {
if (!this.analysis) return '';
const { conventions, patterns } = this.analysis;
const lines: string[] = [];
lines.push(renderer.h2('Code Conventions'));
lines.push('## Code Conventions');
lines.push('');
if (conventions) {
const items: string[] = [];
if (conventions.indentation) {
items.push(`${renderer.bold('Indentation:')} ${conventions.indentation}`);
lines.push(`- **Indentation:** ${conventions.indentation}`);
}
if (conventions.quotes) {
items.push(`${renderer.bold('Quotes:')} ${conventions.quotes}`);
lines.push(`- **Quotes:** ${conventions.quotes}`);
}
if (conventions.semicolons !== undefined) {
items.push(`${renderer.bold('Semicolons:')} ${conventions.semicolons ? 'required' : 'omitted'}`);
lines.push(`- **Semicolons:** ${conventions.semicolons ? 'required' : 'omitted'}`);
}
if (conventions.trailingCommas) {
items.push(`${renderer.bold('Trailing Commas:')} ${conventions.trailingCommas}`);
lines.push(`- **Trailing Commas:** ${conventions.trailingCommas}`);
}
if (conventions.maxLineLength) {
items.push(`${renderer.bold('Max Line Length:')} ${conventions.maxLineLength}`);
}
if (items.length > 0) {
lines.push(renderer.list(items));
lines.push(`- **Max Line Length:** ${conventions.maxLineLength}`);
}
}
if (patterns) {
lines.push('');
lines.push(renderer.h3('Patterns'));
const items: string[] = [];
lines.push('### Patterns');
if (patterns.components) {
items.push(`${renderer.bold('Components:')} ${patterns.components}`);
lines.push(`- **Components:** ${patterns.components}`);
}
if (patterns.stateManagement) {
items.push(`${renderer.bold('State Management:')} ${patterns.stateManagement}`);
lines.push(`- **State Management:** ${patterns.stateManagement}`);
}
if (patterns.apiStyle) {
items.push(`${renderer.bold('API Style:')} ${patterns.apiStyle}`);
lines.push(`- **API Style:** ${patterns.apiStyle}`);
}
if (patterns.styling) {
items.push(`${renderer.bold('Styling:')} ${patterns.styling}`);
lines.push(`- **Styling:** ${patterns.styling}`);
}
if (patterns.testing) {
items.push(`${renderer.bold('Testing:')} ${patterns.testing}`);
lines.push(`- **Testing:** ${patterns.testing}`);
}
if (patterns.linting) {
items.push(`${renderer.bold('Linting:')} ${patterns.linting}`);
lines.push(`- **Linting:** ${patterns.linting}`);
}
if (patterns.formatting) {
items.push(`${renderer.bold('Formatting:')} ${patterns.formatting}`);
}
if (items.length > 0) {
lines.push(renderer.list(items));
lines.push(`- **Formatting:** ${patterns.formatting}`);
}
}
return lines.join('\n');
}
private generateStructureSection(renderer: FormatRenderer): string {
private generateStructureSection(): string {
if (!this.analysis) return '';
const { structure, importantFiles } = this.analysis;
const lines: string[] = [];
lines.push(renderer.h2('Project Structure'));
lines.push('## Project Structure');
lines.push('');
if (structure) {
if (structure.type) {
lines.push(renderer.keyValue('Structure Type', structure.type));
lines.push(`**Structure Type:** ${structure.type}`);
}
if (structure.srcDir) {
lines.push(renderer.keyValue('Source Directory', renderer.code(`${structure.srcDir}/`)));
lines.push(`**Source Directory:** \`${structure.srcDir}/\``);
}
if (structure.testDir) {
lines.push(renderer.keyValue('Test Directory', renderer.code(`${structure.testDir}/`)));
lines.push(`**Test Directory:** \`${structure.testDir}/\``);
}
if (structure.hasWorkspaces && structure.workspaces) {
lines.push(renderer.keyValue('Workspaces', structure.workspaces.join(', ')));
lines.push(`**Workspaces:** ${structure.workspaces.join(', ')}`);
}
lines.push('');
}
if (importantFiles.length > 0) {
lines.push(renderer.h3('Important Files'));
lines.push(renderer.list(importantFiles.slice(0, 15).map(f => renderer.code(f))));
lines.push('### Important Files');
for (const file of importantFiles.slice(0, 15)) {
lines.push(`- \`${file}\``);
}
}
return lines.join('\n');
}
private generateGuidelinesSection(_agent: AgentType, renderer: FormatRenderer): string {
private generateGuidelinesSection(_agent: AgentType): string {
if (!this.analysis) return '';
const { stack, patterns } = this.analysis;
const lines: string[] = [];
lines.push(renderer.h2('Development Guidelines'));
lines.push('## Development Guidelines');
lines.push('');
const hasReact = stack.frameworks.some(f => f.name === 'react' || f.name === 'nextjs');
@@ -616,74 +468,59 @@ export class PrimerGenerator {
const hasZod = stack.libraries.some(l => l.name === 'zod');
if (hasTypeScript) {
lines.push(renderer.h3('TypeScript'));
lines.push(renderer.list([
'Use strict TypeScript with proper type annotations',
'Prefer `interface` for object types, `type` for unions/intersections',
'Avoid `any` - use `unknown` when type is uncertain',
]));
lines.push('### TypeScript');
lines.push('- Use strict TypeScript with proper type annotations');
lines.push('- Prefer `interface` for object types, `type` for unions/intersections');
lines.push('- Avoid `any` - use `unknown` when type is uncertain');
lines.push('');
}
if (hasReact) {
lines.push(renderer.h3('React'));
const reactItems = [
'Use functional components with hooks',
'Prefer composition over inheritance',
'Keep components small and focused',
];
lines.push('### React');
lines.push('- Use functional components with hooks');
lines.push('- Prefer composition over inheritance');
lines.push('- Keep components small and focused');
if (patterns?.stateManagement) {
reactItems.push(`Use ${patterns.stateManagement} for state management`);
lines.push(`- Use ${patterns.stateManagement} for state management`);
}
lines.push(renderer.list(reactItems));
lines.push('');
}
if (hasVue) {
lines.push(renderer.h3('Vue'));
lines.push(renderer.list([
'Use Composition API with `<script setup>`',
'Keep components small and focused',
]));
lines.push('### Vue');
lines.push('- Use Composition API with `<script setup>`');
lines.push('- Keep components small and focused');
lines.push('');
}
if (hasTailwind) {
lines.push(renderer.h3('Styling'));
lines.push(renderer.list([
'Use Tailwind CSS utility classes',
'Follow mobile-first responsive design',
'Extract repeated patterns to components',
]));
lines.push('### Styling');
lines.push('- Use Tailwind CSS utility classes');
lines.push('- Follow mobile-first responsive design');
lines.push('- Extract repeated patterns to components');
lines.push('');
}
if (hasPrisma) {
lines.push(renderer.h3('Database'));
lines.push(renderer.list([
'Use Prisma for database operations',
'Keep database queries in dedicated service files',
'Use transactions for related operations',
]));
lines.push('### Database');
lines.push('- Use Prisma for database operations');
lines.push('- Keep database queries in dedicated service files');
lines.push('- Use transactions for related operations');
lines.push('');
}
if (hasZod) {
lines.push(renderer.h3('Validation'));
lines.push(renderer.list([
'Use Zod for runtime validation',
'Define schemas alongside types',
]));
lines.push('### Validation');
lines.push('- Use Zod for runtime validation');
lines.push('- Define schemas alongside types');
lines.push('');
}
lines.push(renderer.h3('General'));
lines.push(renderer.list([
'Follow existing code patterns and conventions',
'Write clear, self-documenting code',
'Keep functions small and focused',
'Add tests for new functionality',
]));
lines.push('### General');
lines.push('- Follow existing code patterns and conventions');
lines.push('- Write clear, self-documenting code');
lines.push('- Keep functions small and focused');
lines.push('- Add tests for new functionality');
return lines.join('\n');
}
+1 -1
View File
@@ -91,7 +91,7 @@ export const PrimerAnalysis = z.object({
repository: z.string().optional(),
}),
languages: z.array(Detection).default([]),
packageManagers: z.array(PackageManager).default([]),
packageManagers: z.array(z.string()).default([]),
stack: ProjectStack,
patterns: ProjectPatterns.optional(),
structure: ProjectStructure.optional(),
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@skillkit/tui",
"version": "2.0.1",
"version": "2.0.0",
"description": "Unified Terminal UI for SkillKit - Built on OpenTUI",
"type": "module",
"main": "./dist/index.js",