Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 303 additions & 0 deletions docs/fumadocs/content/docs/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,150 @@ import { RecommendationEngine, analyzeProject } from '@skillkit/core/recommend'
const engine = new RecommendationEngine()
const profile = await analyzeProject('./my-project')
const recommendations = engine.recommend(profile)

// Recommendations with scores and reasons
recommendations.forEach(rec => {
console.log(`${rec.score}% - ${rec.skill.name}`)
console.log(`Reasons: ${rec.reasons.join(', ')}`)
})
```

## Primer (Auto-Generate Instructions)

```typescript
import { analyzeProject, generateInstructions } from '@skillkit/core'

// Analyze project
const analysis = await analyzeProject('./my-project')
console.log(analysis.techStack)
// { framework: 'Next.js', language: 'TypeScript', styling: 'Tailwind' }

// Generate instructions for specific agents
const instructions = await generateInstructions(analysis, {
agents: ['claude', 'cursor', 'windsurf'],
includeExamples: true,
tone: 'detailed',
})

// Write to files
for (const [agent, content] of Object.entries(instructions)) {
await fs.writeFile(`.${agent}/instructions.md`, content)
}
```

## Mesh Network

```typescript
import { MeshHost, PeerIdentity } from '@skillkit/mesh'

// Generate identity
const identity = await PeerIdentity.generate()

// Create mesh host
const host = new MeshHost({
hostId: 'my-workstation',
identity,
security: { mode: 'secure' },
})

await host.start()

// Send message to peer
await host.send('peer-fingerprint', {
type: 'skill-sync',
payload: { skills: ['react-patterns'] },
})

// Listen for messages
host.on('message', (msg) => {
console.log('Received:', msg.type, 'from', msg.from)
})
```

## Inter-Agent Messaging

```typescript
import { MessagingClient } from '@skillkit/messaging'

// Create messaging client
const messaging = new MessagingClient({
meshHost: host,
storagePath: '~/.skillkit/messages',
})
Comment on lines +154 to +160
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Node.js does ~ tilde expand home directory in file paths fs module

💡 Result:

Node’s fs APIs do not perform ~ (tilde) expansion. ~ expansion is typically done by your shell (bash/zsh/etc.), not by filesystem syscalls or Node’s fs module—so fs.readFile('~/x') will look for a literal directory named ~. [2][3]

Use os.homedir() (recommended) and rewrite only a leading ~ yourself: [1][2]

import os from "node:os";
import path from "node:path";

function expandHome(p) {
  if (p === "~") return os.homedir();
  if (p.startsWith("~/") || p.startsWith("~\\")) {
    return path.join(os.homedir(), p.slice(2));
  }
  return p;
}

// example:
const filename = expandHome("~/Documents/file.txt");

If you prefer a library, common options are untildify or expand-tilde. [4][5]

Sources: Node os.homedir() docs [1]; explanation that Node fs doesn’t expand ~ [2][3]; untildify [4]; expand-tilde [5].


Avoid ~ in storagePath—Node.js won't expand it.

~/.skillkit/messages will be treated as a literal folder name, not the user's home directory. Use os.homedir() with path.join() so the example works as intended.

🔧 Suggested fix
-import { MessagingClient } from '@skillkit/messaging'
+import { MessagingClient } from '@skillkit/messaging'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
@@
-  storagePath: '~/.skillkit/messages',
+  storagePath: join(homedir(), '.skillkit/messages'),
🤖 Prompt for AI Agents
In `@docs/fumadocs/content/docs/api-reference.mdx` around lines 154 - 160, The
example uses a literal tilde in the MessagingClient storagePath which Node.js
won't expand; update the MessagingClient instantiation to compute the path using
the user's home directory (e.g., use os.homedir() and path.join()) instead of
'~/.skillkit/messages' so storagePath points to the actual home-based folder;
change the example around the MessagingClient constructor to import/require os
and path and build the storagePath via path.join(os.homedir(), '.skillkit',
'messages').


await messaging.init()

// Send a message
await messaging.send({
to: 'claude@laptop',
subject: 'Code review completed',
body: 'I reviewed the auth module...',
priority: 'normal',
})

// Listen for new messages
messaging.on('message', (msg) => {
console.log('New message from:', msg.from)
console.log('Subject:', msg.subject)
})

// Get inbox
const inbox = await messaging.getInbox({ unread: true })
```

## Workflow Orchestration

```typescript
import { WorkflowEngine, WorkflowStep } from '@skillkit/core'

// Define workflow
const workflow = {
name: 'feature-development',
steps: [
{ skill: 'tdd-workflow', action: 'write-tests' },
{ skill: 'code-implementation', action: 'implement' },
{ skill: 'code-review', action: 'review' },
{ skill: 'documentation', action: 'update-docs' },
],
}

// Execute workflow
const engine = new WorkflowEngine()
const result = await engine.run(workflow)

console.log('Workflow completed:', result.status)
console.log('Steps executed:', result.steps.length)
```

## Skill Testing

```typescript
import { SkillTestRunner, SkillTest } from '@skillkit/core'

// Define test
const test: SkillTest = {
name: 'pdf-processing',
setup: async () => {
// Setup test environment
},
assertions: [
{
type: 'file_exists',
path: './output.pdf',
},
{
type: 'content_includes',
text: 'Expected content',
},
],
}

// Run test
const runner = new SkillTestRunner()
const result = await runner.run(test)

console.log('Test passed:', result.passed)
console.log('Assertions:', result.assertions)
```

## Types
Expand All @@ -99,6 +243,15 @@ interface Skill {
content: string
metadata: SkillMetadata
enabled: boolean
agent: string
}

interface SkillMetadata {
version?: string
author?: string
tags?: string[]
dependencies?: string[]
quality?: QualityScore
}

interface QualityScore {
Expand All @@ -114,4 +267,154 @@ interface Recommendation {
score: number
reasons: string[]
}

interface ProjectAnalysis {
techStack: {
framework?: string
language: string
styling?: string
testing?: string
packageManager: string
}
patterns: {
architecture: string
codeStyle: Record<string, any>
directory: string
}
dependencies: Record<string, string>
}

interface MeshMessage {
from: string
to: string
type: string
payload: any
timestamp: number
signature?: string
}

interface WorkflowResult {
status: 'success' | 'failure'
steps: WorkflowStepResult[]
duration: number
}
```

## Package Exports

### @skillkit/core

```typescript
export {
// Discovery
findAllSkills,
findSkill,

// Quality
evaluateSkillContent,
getQualityGrade,

// Translation
translateSkill,

// Memory
MemoryCompressor,
LearningStore,

// Recommendations
RecommendationEngine,
analyzeProject,

// Primer
generateInstructions,

// Workflows
WorkflowEngine,

// Testing
SkillTestRunner,
}
```

### @skillkit/mesh

```typescript
export {
MeshHost,
PeerIdentity,
PeerRegistry,
SecureTransport,
}
```

### @skillkit/messaging

```typescript
export {
MessagingClient,
MessageBuilder,
MessageRouter,
}
```

### @skillkit/memory

```typescript
export {
MemoryStore,
TierManager,
EmbeddingEncoder,
}
```

## Full Example: Custom Build Pipeline

```typescript
import {
analyzeProject,
generateInstructions,
RecommendationEngine,
translateSkill,
} from '@skillkit/core'

async function setupProject() {
// 1. Analyze project
const analysis = await analyzeProject('./my-project')

// 2. Generate base instructions
const instructions = await generateInstructions(analysis, {
agents: ['claude', 'cursor', 'windsurf'],
})

// 3. Get recommendations
const engine = new RecommendationEngine()
const recommendations = engine.recommend(analysis)

// 4. Install top recommendations
const topSkills = recommendations.slice(0, 5)
for (const rec of topSkills) {
console.log(`Installing ${rec.skill.name} (${rec.score}% match)`)
}

// 5. Translate skills to all agents
for (const agent of ['claude', 'cursor', 'windsurf']) {
const translated = await translateSkill(
topSkills[0].skill.content,
agent
)
await fs.writeFile(`.${agent}/skills/${translated.filename}`, translated.content)
}

console.log('✅ Project setup complete!')
}

setupProject()
```

## Next Steps

- [Commands Reference](/docs/commands) - CLI commands
- [Memory System](/docs/memory) - Persistent learning
- [Mesh Network](/docs/mesh) - Multi-machine setup
- [Workflows](/docs/workflows) - Automation
- [Testing](/docs/testing) - Skill validation
Loading