IdiomarkD API Reference
Complete API reference for IdiomarkD (Idiomark for Developers) implementation and usage.
HTTP API
IdiomarkD v1 runs as a standalone HTTP server on port 4000.
Base URL
http://localhost:4000
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/analyze | Analyze code samples |
| GET | /health | Health check |
| GET | / | API info |
POST /api/v1/analyze
Analyzes code samples for behavioral patterns.
Request:
curl -X POST http://localhost:4000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{
"code_samples": [
{
"filePath": "src/utils.ts",
"content": "export function add(a: number, b: number) {\n return a + b\n}",
"language": "typescript"
}
]
}'
Request Body:
interface AnalyzeRequest {
code_samples: CodeSample[] // Required, max 100 samples
}
interface CodeSample {
filePath: string // Required - file path
content: string // Required - max 100KB per sample
language?: string // Optional - typescript, javascript, python, rust, etc.
}
Response:
interface AnalyzeResponse {
behavioral: DeveloperBehavior
confidence: {
overall: number
cognitive_style: number
code_structure: number
naming: number
error_handling: number
testing: number
code_review: number
}
sampleCount: number
meta: {
processedAt: string
processingTimeMs: number
apiVersion: string
}
}
GET /health
Health check endpoint.
curl http://localhost:4000/health
Response:
{
"status": "ok",
"service": "idiomarkd-api",
"version": "1.0.0",
"timestamp": "2026-02-15T12:00:00.000Z"
}
Rate Limits
- 100 requests per minute per IP
- 429 response when exceeded
Error Responses
{
"error": "code_samples array required",
"statusCode": 400
}
Core Package
Installation
npm install @idiomark/core
Exports
// Types
import type {
IdiomarkDFile,
DeveloperBehavior,
DeveloperAIPersonality,
DeveloperEnvironment,
CodeSample
} from '@idiomark/core'
// Analysis
import {
DeveloperBehaviorAnalyzer,
analyzeDeveloperBehavior
} from '@idiomark/core'
// Validation
import {
IdiomarkDValidator,
validateIdiomarkD
} from '@idiomark/core'
// Integration
import {
EditorIntegration,
DevBehavior,
CodeTransformation,
CommentGenerationOptions,
createIntegration,
applyCodeStyle,
generateComment
} from '@idiomark/core'
Core APIs
DeveloperBehaviorAnalyzer
Analyzes code samples to extract developer behavioral patterns.
import { DeveloperBehaviorAnalyzer, type CodeSample } from '@idiomark/core'
const analyzer = new DeveloperBehaviorAnalyzer()
// Add code samples
analyzer.addSamples([
{
filePath: 'src/utils.ts',
content: '...',
language: 'typescript'
}
])
// Run analysis
const result = await analyzer.analyze()
console.log('Cognitive Style:', result.behavioral.cognitive_style)
console.log('Confidence:', result.confidence.cognitive_style)
Methods:
addSamples(samples: CodeSample[])- Add code samples for analysisanalyze(): Promise<BehavioralAnalysisResult>- Run complete behavioral analysis
Returns:
interface BehavioralAnalysisResult {
behavioral: DeveloperBehavior
confidence: {
overall: number
cognitive_style: number
code_structure: number
naming: number
error_handling: number
testing: number
code_review: number
}
sampleCount: number
analyzedAt: string
}
IdiomarkDValidator
Validates IdiomarkD files against schema requirements.
import { IdiomarkDValidator } from '@idiomark/core'
const validator = new IdiomarkDValidator({ strict: false })
// Validate IdiomarkD file
const result = await validator.validate(idiomarkdData)
if (result.valid) {
console.log('Valid IdiomarkD file')
} else {
console.error('Validation failed:', result.errors)
}
Options:
strict: boolean- Enable strict validation mode
Methods:
validate(data: any): Promise<ValidationResult>- Validate IdiomarkD data
Returns:
interface ValidationResult {
valid: boolean
version: string
id: string
created: string
sources: string[]
profile_type?: string
errors: ValidationError[]
}
EditorIntegration
Platform-agnostic interface for AI tools to consume IdiomarkD profiles.
import { createIntegration, type DevBehavior, type CodeTransformation } from '@idiomark/core'
const integration = createIntegration({
name: 'my-tool'
})
// Load profile
const behavior = await integration.loadBehavior('/path/to/profile.idiomarkd.json')
// Apply code transformation
const result = integration.applyBehavior('const x = 1', behavior)
console.log('Transformed:', result.transformed)
Methods:
loadBehavior(profilePath: string): Promise<DevBehavior>- Load IdiomarkD profileapplyBehavior(code: string, behavior: DevBehavior): CodeTransformation- Apply profile to codegenerateComment(options: CommentGenerationOptions): string- Generate commentisAvailable(): Promise<boolean>- Check if available
validateIdiomarkD
Convenience function for validating IdiomarkD files.
import { validateIdiomarkD } from '@idiomark/core'
// Validate IdiomarkD file
const result = await validateIdiomarkD(idiomarkdData)
if (result.valid) {
console.log('Valid IdiomarkD file')
} else {
console.error('Validation failed:', result.errors)
}
CLI Package
Installation
npm install @idiomark/cli
Commands
# Extract developer profile from GitHub
idiomark extract:developer --github -u <username> -t <token> --output profile.idiomarkd.json
# Validate IdiomarkD file
idiomark validate profile.idiomarkd.json
GitHub Adapter
Installation
npm install @idiomark/adapter-github
DeveloperExtractor
Fetches code samples from GitHub repositories for behavioral analysis.
import { DeveloperExtractor, type DeveloperExtractionOptions } from '@idiomark/adapter-github'
const extractor = new DeveloperExtractor({ token: '...' })
// Fetch code samples
const result = await extractor.fetchCodeSamples({
sampleSize: 100,
extensions: ['.ts', '.tsx', '.js'],
includeTests: true
})
console.log('Samples:', result.samples.length)
console.log('Repositories:', result.metadata.repositories)
Methods:
fetchCodeSamples(options): Promise<DeveloperExtractionResult>- Fetch code files from reposfetchCommitsWithDiff(): Promise<CodeSample[]>- Fetch commits with diffsfetchPullRequestReviews(): Promise<CodeSample[]>- Fetch PR reviewsfetchIssuesAndDiscussions(): Promise<CodeSample[]>- Fetch issues and discussionsextractDeveloperBehavior(): Promise<CodeSample[]>- Orchestrate all extraction methods
Options:
interface DeveloperExtractionOptions {
sampleSize?: number // Default: 100
extensions?: string[] // Default: ['.ts', '.tsx', '.js', '.jsx']
maxFileSize?: number // Default: 100KB
includeTests?: boolean // Default: true
startDate?: Date
endDate?: Date
repos?: string[] // Specific repositories
}
Types
IdiomarkDFile
Complete IdiomarkD file structure.
interface IdiomarkDFile {
idiomark: string // Version: "1.1.0"
profile_type: "developer" // Must be "developer"
id?: string // Unique identifier
metadata: IdiomarkDMetadata
behavioral: DeveloperBehavior // Required
ai_personality?: DeveloperAIPersonality // Optional
environmental?: DeveloperEnvironment // Optional
}
DeveloperBehavior
All 6 behavioral dimensions.
interface DeveloperBehavior {
cognitive_style: {
problem_solving: 'iterative_refinement' | 'divide_conquer' | 'mvp_first' | 'spike_first'
learning_style: 'experimental' | 'research_driven' | 'copy_existing_similar'
documentation_preference: 'code_first_comments_selective' | 'comments_first_code_second' | 'docstring_driven'
}
code_structure: {
functional_preference: number // 0.0-1.0
max_function_length: number
complexity_tolerance: 'minimal' | 'moderate' | 'high'
file_organization: 'co-located' | 'domain_driven' | 'layered'
}
naming: {
philosophy: 'descriptive_over_brief' | 'efficient'
conventions: {
variables: 'camelCase' | 'PascalCase' | 'UPPER_SNAKE' | 'kebab-case'
types: 'PascalCase' | 'camelCase' | 'UPPER_SNAKE' | 'kebab-case'
constants: 'UPPER_SNAKE' | 'kebab-case'
files: 'kebab-case' | 'camelCase' | 'PascalCase'
}
abbreviations: string[]
anti_patterns: string[]
}
error_handling: {
philosophy: 'graceful_degradation' | 'fail_fast' | 'defensive'
fail_fast: boolean
error_context: 'always_include_trace' | 'on_error_only'
logging_level: 'silent' | 'fatal' | 'error' | 'warn' | 'info' | 'debug'
}
testing: {
temperament: 'pragmatic_not_zealous' | 'tdd_zealot' | 'exploratory'
coverage_threshold: number // 0.0-1.0
test_external_dependencies: boolean
mock_strategy: 'external_only' | 'mixed' | 'minimal'
}
code_review: {
style: 'collaborative_not_adversarial' | 'direct' | 'mentoring'
focus_areas: string[]
nit_picks: string[]
}
}
CodeSample
Code sample for analysis.
interface CodeSample {
filePath: string
content: string
language: string
metadata?: {
commitHash?: string
timestamp?: string
author?: string
}
}
DevBehavior
Developer profile for integration.
interface DevBehavior {
behavioral: DeveloperBehavior
ai_personality?: {
voice?: { ... }
code_generation?: { ... }
interaction?: { ... }
}
sourceFile?: string
}
Examples
Validate IdiomarkD File
import { validateIdiomarkD } from '@idiomark/core'
const idiomarkdData = {
idiomark: '1.1.0',
profile_type: 'developer',
metadata: { ... },
behavioral: { ... }
}
const result = await validateIdiomarkD(idiomarkdData)
console.log('Valid:', result.valid)
console.log('Errors:', result.errors)
Extract Developer Behavior
import { analyzeDeveloperBehavior, type CodeSample } from '@idiomark/core'
const samples: CodeSample[] = [
{
filePath: 'src/utils.ts',
content: '...',
language: 'typescript'
}
]
const result = await analyzeDeveloperBehavior(samples)
console.log('Problem Solving:', result.behavioral.cognitive_style.problem_solving)
console.log('Confidence:', result.confidence.overall)
Apply Code Style
import { applyCodeStyle, type DevBehavior } from '@idiomark/core'
const behavior: DevBehavior = { ... }
const code = 'const x = 1'
const result = applyCodeStyle(code, behavior)
console.log('Original:', result.original)
console.log('Transformed:', result.transformed)
console.log('Confidence:', result.confidence)
Error Handling
ValidationError
Validation error with field information.
interface ValidationError {
field: string // Dot path to field (e.g., "behavioral.naming")
message: string // Human-readable error message
code: string // Machine-readable error code
}
Error Codes:
INVALID_PROFILE_TYPE- Wrong profile_type valueMISSING_BEHAVIORAL- Required behavioral layer missingMISSING_AI_PERSONALITY- Required AI personality layer missingINVALID_RANGE- Number out of valid range (0-1)INVALID_ENUM_VALUE- Invalid enum valueFULL_SCHEMA_ERROR- Full schema validation failed
TypeScript Support
All types exported from @idiomark/core include full TypeScript definitions.
Version Support
IdiomarkD extends Idiomark version 1.0.0.
| Idiomark Version | IdiomarkD Features | Status |
|---|---|---|
| 1.0.0 | Base protocol | ✅ Supported |
| 1.1.0 | IdiomarkD for Developers | ✅ Supported |
See Also
- Getting Started Guide - User documentation
- Field Definitions - Detailed field explanations
- Integration Guide - Tool integration
- Testing Guide - Testing procedures