aiwf 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.ko.md +19 -10
  2. package/README.md +54 -9
  3. package/docs/AI-WORKFLOW.ko.md +1 -1
  4. package/docs/AI-WORKFLOW.md +1 -1
  5. package/docs/API_REFERENCE_FULL.ko.md +979 -0
  6. package/docs/API_REFERENCE_FULL.md +979 -0
  7. package/docs/ARCHITECTURE.ko.md +314 -0
  8. package/docs/ARCHITECTURE.md +314 -0
  9. package/docs/GETTING_STARTED.ko.md +219 -0
  10. package/docs/GETTING_STARTED.md +1 -2
  11. package/docs/PERFORMANCE_GUIDELINES.ko.md +388 -0
  12. package/docs/ROADMAP_v0.4.0.md +286 -0
  13. package/docs/TROUBLESHOOTING.ko.md +366 -0
  14. package/package.json +50 -2
  15. package/src/DEPENDENCY_MAP.md +90 -0
  16. package/src/cli/index.js +1 -1
  17. package/src/lib/installer.js +204 -15
  18. package/src/lib/resources/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
  19. package/src/lib/resources/templates/api-server/template/src/routes/aiwf.ts +0 -11
  20. package/src/lib/resources/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
  21. package/src/lib/resources/utils/token-reporter.js +2 -3
  22. package/src/utils/checkpoint-manager.js +11 -1
  23. package/src/utils/engineering-guard.js +11 -1
  24. package/src/utils/messages.js +16 -0
  25. package/src/utils/paths.js +2 -2
  26. package/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
  27. package/templates/api-server/template/src/routes/aiwf.ts +0 -11
  28. package/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
  29. package/docs/CLEANUP_RECOMMENDATIONS.md +0 -86
  30. package/docs/git-feature-integration-guide.md +0 -253
  31. package/docs/guides/feature-git-integration-guide-ko.md +0 -481
  32. package/docs/guides/feature-git-integration-guide.md +0 -481
  33. package/docs/lightweight-evaluation.md +0 -198
  34. package/docs/performance-benchmark-report.md +0 -159
  35. package/docs/reports/S02-sprint-report.md +0 -190
  36. package/docs/usability-test-report.md +0 -170
  37. package/src/commands/cache-templates.js +0 -209
  38. package/src/commands/create-offline.js +0 -86
  39. package/src/commands/state-refactored.js +0 -419
  40. package/src/lib/resources/commands/feature-ledger.js +0 -565
  41. package/src/lib/resources/commands/feature_commit_report.js +0 -370
  42. package/src/lib/resources/commands/scan_git_history.js +0 -234
  43. package/src/lib/resources/commands/sync_feature_commits.js +0 -154
  44. package/src/lib/resources/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
  45. package/src/lib/resources/utils/feature-updater.js +0 -271
  46. package/src/utils/git-integration.js +0 -173
  47. package/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
  48. /package/docs/{AI_PERSONA_SYSTEM_DESIGN.md → designs/AI_PERSONA_SYSTEM_DESIGN.md} +0 -0
  49. /package/docs/{API_DOCUMENTATION.md → designs/API_DOCUMENTATION.md} +0 -0
  50. /package/docs/{API_REFERENCE.md → designs/API_REFERENCE.md} +0 -0
  51. /package/docs/{Enhanced_Installation_Flow_Design.md → designs/Enhanced_Installation_Flow_Design.md} +0 -0
  52. /package/docs/{moonklabs-metadata-system-prd.md → designs/aiwf-metadata-system-prd.md} +0 -0
  53. /package/docs/{offline-template-cache.md → designs/offline-template-cache.md} +0 -0
  54. /package/docs/{persona-aware-compression.md → designs/persona-aware-compression.md} +0 -0
@@ -0,0 +1,979 @@
1
+ # AIWF Complete API Reference
2
+
3
+ [한국어로 보기](API_REFERENCE_FULL.ko.md)
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Core APIs](#core-apis)
8
+ - [Resource Loader](#resource-loader)
9
+ - [State Management](#state-management)
10
+ - [Template System](#template-system)
11
+ 2. [Command APIs](#command-apis)
12
+ - [AI Tool Command](#ai-tool-command)
13
+ - [Compress Command](#compress-command)
14
+ - [Create Project](#create-project)
15
+ - [Evaluate Command](#evaluate-command)
16
+ - [Feature Command](#feature-command)
17
+ - [Persona Command](#persona-command)
18
+ - [State Command](#state-command)
19
+ - [Token Command](#token-command)
20
+ - [YOLO Config](#yolo-config)
21
+ 3. [Utility APIs](#utility-apis)
22
+ - [Checkpoint Manager](#checkpoint-manager)
23
+ - [Git Utilities](#git-utilities)
24
+ - [Token Counter](#token-counter)
25
+ - [Text Processors](#text-processors)
26
+ 4. [Plugin APIs](#plugin-apis)
27
+ - [Plugin Interface](#plugin-interface)
28
+ - [Hook System](#hook-system)
29
+ 5. [AI Integration APIs](#ai-integration-apis)
30
+ - [Persona Manager](#persona-manager)
31
+ - [Compression Engine](#compression-engine)
32
+ - [Evaluation System](#evaluation-system)
33
+
34
+ ---
35
+
36
+ ## Core APIs
37
+
38
+ ### Resource Loader
39
+
40
+ The Resource Loader manages all framework resources, providing a unified interface for accessing bundled and user resources.
41
+
42
+ #### Class: `ResourceLoader`
43
+
44
+ ```javascript
45
+ import { ResourceLoader } from 'aiwf/lib/resource-loader';
46
+ ```
47
+
48
+ ##### Constructor
49
+
50
+ ```javascript
51
+ new ResourceLoader(options?: ResourceLoaderOptions)
52
+ ```
53
+
54
+ **Options:**
55
+ ```typescript
56
+ interface ResourceLoaderOptions {
57
+ bundledPath?: string; // Path to bundled resources
58
+ userPath?: string; // Path to user resources
59
+ preferUserResources?: boolean; // Prefer user over bundled (default: true)
60
+ }
61
+ ```
62
+
63
+ ##### Methods
64
+
65
+ ###### `resolvePath(resourceType, resourceName)`
66
+
67
+ Resolves the path to a resource, checking user directory first, then bundled resources.
68
+
69
+ ```javascript
70
+ async resolvePath(resourceType: string, resourceName: string): Promise<string>
71
+ ```
72
+
73
+ **Example:**
74
+ ```javascript
75
+ const loader = new ResourceLoader();
76
+ const personaPath = await loader.resolvePath('personas', 'analyst.json');
77
+ ```
78
+
79
+ ###### `loadResource(resourceType, resourceName)`
80
+
81
+ Loads and parses a resource file.
82
+
83
+ ```javascript
84
+ async loadResource(resourceType: string, resourceName: string): Promise<any>
85
+ ```
86
+
87
+ **Supported formats:**
88
+ - JSON (`.json`)
89
+ - YAML (`.yaml`, `.yml`)
90
+ - JavaScript modules (`.js`)
91
+ - Markdown (`.md`)
92
+
93
+ ###### `listResources(resourceType)`
94
+
95
+ Lists all available resources of a given type.
96
+
97
+ ```javascript
98
+ async listResources(resourceType: string): Promise<string[]>
99
+ ```
100
+
101
+ ###### `copyResource(resourceType, resourceName, destination)`
102
+
103
+ Copies a resource to a specified location.
104
+
105
+ ```javascript
106
+ async copyResource(
107
+ resourceType: string,
108
+ resourceName: string,
109
+ destination: string
110
+ ): Promise<void>
111
+ ```
112
+
113
+ ### State Management
114
+
115
+ Manages application and project state with support for checkpoints and atomic updates.
116
+
117
+ #### Class: `StateIndexManager`
118
+
119
+ ```javascript
120
+ import { StateIndexManager } from 'aiwf/lib/state/state-index';
121
+ ```
122
+
123
+ ##### Constructor
124
+
125
+ ```javascript
126
+ new StateIndexManager(aiwfPath: string)
127
+ ```
128
+
129
+ ##### Methods
130
+
131
+ ###### `loadState()`
132
+
133
+ Loads the current state from disk.
134
+
135
+ ```javascript
136
+ async loadState(): Promise<StateIndex>
137
+ ```
138
+
139
+ **Returns:**
140
+ ```typescript
141
+ interface StateIndex {
142
+ version: string;
143
+ last_updated: string;
144
+ last_updated_by: string;
145
+ project_info: ProjectInfo;
146
+ milestones: Milestone[];
147
+ sprints: Sprint[];
148
+ tasks: Task[];
149
+ workflow_mode: WorkflowMode;
150
+ }
151
+ ```
152
+
153
+ ###### `saveState(state)`
154
+
155
+ Saves state to disk with automatic backup.
156
+
157
+ ```javascript
158
+ async saveState(state: StateIndex): Promise<void>
159
+ ```
160
+
161
+ ###### `updateProjectInfo(updates)`
162
+
163
+ Updates project information.
164
+
165
+ ```javascript
166
+ async updateProjectInfo(updates: Partial<ProjectInfo>): Promise<void>
167
+ ```
168
+
169
+ ###### `addMilestone(milestone)`
170
+
171
+ Adds a new milestone to the project.
172
+
173
+ ```javascript
174
+ async addMilestone(milestone: Milestone): Promise<void>
175
+ ```
176
+
177
+ ### Template System
178
+
179
+ Manages project templates and code generation.
180
+
181
+ #### Class: `TemplateEngine`
182
+
183
+ ```javascript
184
+ import { TemplateEngine } from 'aiwf/lib/template-engine';
185
+ ```
186
+
187
+ ##### Methods
188
+
189
+ ###### `listTemplates()`
190
+
191
+ Lists all available project templates.
192
+
193
+ ```javascript
194
+ async listTemplates(): Promise<TemplateInfo[]>
195
+ ```
196
+
197
+ ###### `createFromTemplate(templateName, targetPath, variables)`
198
+
199
+ Creates a new project from a template.
200
+
201
+ ```javascript
202
+ async createFromTemplate(
203
+ templateName: string,
204
+ targetPath: string,
205
+ variables: Record<string, string>
206
+ ): Promise<void>
207
+ ```
208
+
209
+ **Example:**
210
+ ```javascript
211
+ const engine = new TemplateEngine();
212
+ await engine.createFromTemplate('api-server', './my-api', {
213
+ projectName: 'My API',
214
+ author: 'John Doe',
215
+ description: 'My awesome API server'
216
+ });
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Command APIs
222
+
223
+ ### AI Tool Command
224
+
225
+ Manages AI tool integrations and configurations.
226
+
227
+ #### Class: `AIToolCommand`
228
+
229
+ ```javascript
230
+ import AIToolCommand from 'aiwf/commands/ai-tool';
231
+ ```
232
+
233
+ ##### Methods
234
+
235
+ ###### `execute(args)`
236
+
237
+ Executes AI tool commands.
238
+
239
+ ```javascript
240
+ async execute(args: string[]): Promise<void>
241
+ ```
242
+
243
+ **Subcommands:**
244
+ - `list` - List all available AI tools
245
+ - `activate <tool>` - Activate an AI tool
246
+ - `configure <tool>` - Configure an AI tool
247
+ - `status` - Show current AI tool status
248
+
249
+ ### Compress Command
250
+
251
+ Provides various compression strategies for optimizing context.
252
+
253
+ #### Functions
254
+
255
+ ###### `compress(mode, content, options)`
256
+
257
+ Compresses content using specified strategy.
258
+
259
+ ```javascript
260
+ async compress(
261
+ mode: CompressionMode,
262
+ content: string,
263
+ options?: CompressionOptions
264
+ ): Promise<string>
265
+ ```
266
+
267
+ **Compression Modes:**
268
+ - `simple` - Basic whitespace and comment removal
269
+ - `moderate` - Balanced compression
270
+ - `aggressive` - Maximum compression
271
+ - `custom` - User-defined rules
272
+
273
+ **Options:**
274
+ ```typescript
275
+ interface CompressionOptions {
276
+ preserveComments?: boolean;
277
+ preserveWhitespace?: boolean;
278
+ maxLineLength?: number;
279
+ customRules?: CompressionRule[];
280
+ }
281
+ ```
282
+
283
+ ### Create Project
284
+
285
+ Creates new AIWF projects from templates.
286
+
287
+ #### Function: `createProject`
288
+
289
+ ```javascript
290
+ async createProject(options: CreateProjectOptions): Promise<void>
291
+ ```
292
+
293
+ **Options:**
294
+ ```typescript
295
+ interface CreateProjectOptions {
296
+ template: string;
297
+ name: string;
298
+ path?: string;
299
+ variables?: Record<string, string>;
300
+ skipInstall?: boolean;
301
+ gitInit?: boolean;
302
+ }
303
+ ```
304
+
305
+ ### Evaluate Command
306
+
307
+ Evaluates AI responses and code quality.
308
+
309
+ #### Class: `EvaluateCommand`
310
+
311
+ ##### Methods
312
+
313
+ ###### `evaluateResponse(file, options)`
314
+
315
+ Evaluates the quality of an AI response.
316
+
317
+ ```javascript
318
+ async evaluateResponse(
319
+ file: string,
320
+ options?: EvaluationOptions
321
+ ): Promise<EvaluationResult>
322
+ ```
323
+
324
+ ###### `evaluateCode(file, options)`
325
+
326
+ Evaluates code quality and best practices.
327
+
328
+ ```javascript
329
+ async evaluateCode(
330
+ file: string,
331
+ options?: CodeEvaluationOptions
332
+ ): Promise<CodeEvaluationResult>
333
+ ```
334
+
335
+ ### Feature Command
336
+
337
+ Manages feature tracking and development workflow.
338
+
339
+ #### Functions
340
+
341
+ ###### `createFeature(name, description)`
342
+
343
+ Creates a new feature entry.
344
+
345
+ ```javascript
346
+ async createFeature(
347
+ name: string,
348
+ description?: string
349
+ ): Promise<FeatureEntry>
350
+ ```
351
+
352
+ ###### `updateFeatureStatus(id, status)`
353
+
354
+ Updates the status of a feature.
355
+
356
+ ```javascript
357
+ async updateFeatureStatus(
358
+ id: string,
359
+ status: FeatureStatus
360
+ ): Promise<void>
361
+ ```
362
+
363
+ **Feature Statuses:**
364
+ - `planned`
365
+ - `in-progress`
366
+ - `testing`
367
+ - `completed`
368
+ - `deployed`
369
+
370
+ ### Persona Command
371
+
372
+ Manages AI personas and their configurations.
373
+
374
+ #### Class: `PersonaCommand`
375
+
376
+ ##### Methods
377
+
378
+ ###### `listPersonas()`
379
+
380
+ Lists all available personas.
381
+
382
+ ```javascript
383
+ async listPersonas(): Promise<PersonaInfo[]>
384
+ ```
385
+
386
+ ###### `activatePersona(name)`
387
+
388
+ Activates a specific persona.
389
+
390
+ ```javascript
391
+ async activatePersona(name: string): Promise<void>
392
+ ```
393
+
394
+ ###### `createPersona(name, config)`
395
+
396
+ Creates a custom persona.
397
+
398
+ ```javascript
399
+ async createPersona(
400
+ name: string,
401
+ config: PersonaConfig
402
+ ): Promise<void>
403
+ ```
404
+
405
+ ### State Command
406
+
407
+ Manages project state and workflow transitions.
408
+
409
+ #### Class: `StateCommand`
410
+
411
+ ##### Methods
412
+
413
+ ###### `showStatus()`
414
+
415
+ Displays current project state.
416
+
417
+ ```javascript
418
+ async showStatus(): Promise<StateStatus>
419
+ ```
420
+
421
+ ###### `checkpoint(name, description)`
422
+
423
+ Creates a state checkpoint.
424
+
425
+ ```javascript
426
+ async checkpoint(
427
+ name: string,
428
+ description?: string
429
+ ): Promise<CheckpointInfo>
430
+ ```
431
+
432
+ ###### `restore(checkpointId)`
433
+
434
+ Restores from a checkpoint.
435
+
436
+ ```javascript
437
+ async restore(checkpointId: string): Promise<void>
438
+ ```
439
+
440
+ ### Token Command
441
+
442
+ Monitors and manages AI token usage.
443
+
444
+ #### Functions
445
+
446
+ ###### `trackUsage(input, output, model)`
447
+
448
+ Records token usage.
449
+
450
+ ```javascript
451
+ async trackUsage(
452
+ input: string,
453
+ output: string,
454
+ model?: string
455
+ ): Promise<UsageRecord>
456
+ ```
457
+
458
+ ###### `getUsageReport(period)`
459
+
460
+ Generates usage report.
461
+
462
+ ```javascript
463
+ async getUsageReport(
464
+ period?: 'day' | 'week' | 'month'
465
+ ): Promise<UsageReport>
466
+ ```
467
+
468
+ ### YOLO Config
469
+
470
+ Manages YOLO mode configuration.
471
+
472
+ #### Functions
473
+
474
+ ###### `createYoloConfig(options)`
475
+
476
+ Creates YOLO configuration file.
477
+
478
+ ```javascript
479
+ async createYoloConfig(options?: YoloOptions): Promise<void>
480
+ ```
481
+
482
+ ###### `createInteractiveYoloConfig()`
483
+
484
+ Creates configuration through interactive prompts.
485
+
486
+ ```javascript
487
+ async createInteractiveYoloConfig(): Promise<void>
488
+ ```
489
+
490
+ ---
491
+
492
+ ## Utility APIs
493
+
494
+ ### Checkpoint Manager
495
+
496
+ Manages state checkpoints and recovery.
497
+
498
+ #### Class: `CheckpointManager`
499
+
500
+ ```javascript
501
+ import { CheckpointManager } from 'aiwf/utils/checkpoint-manager';
502
+ ```
503
+
504
+ ##### Methods
505
+
506
+ ###### `createCheckpoint(state, metadata)`
507
+
508
+ Creates a new checkpoint.
509
+
510
+ ```javascript
511
+ async createCheckpoint(
512
+ state: any,
513
+ metadata?: CheckpointMetadata
514
+ ): Promise<string>
515
+ ```
516
+
517
+ ###### `listCheckpoints()`
518
+
519
+ Lists all available checkpoints.
520
+
521
+ ```javascript
522
+ async listCheckpoints(): Promise<CheckpointInfo[]>
523
+ ```
524
+
525
+ ###### `restoreCheckpoint(checkpointId)`
526
+
527
+ Restores from a specific checkpoint.
528
+
529
+ ```javascript
530
+ async restoreCheckpoint(checkpointId: string): Promise<any>
531
+ ```
532
+
533
+ ### Git Utilities
534
+
535
+ Provides Git integration utilities.
536
+
537
+ #### Functions
538
+
539
+ ###### `parseCommitMessage(message)`
540
+
541
+ Parses structured commit messages.
542
+
543
+ ```javascript
544
+ parseCommitMessage(message: string): ParsedCommit
545
+ ```
546
+
547
+ **Returns:**
548
+ ```typescript
549
+ interface ParsedCommit {
550
+ type: string;
551
+ scope?: string;
552
+ subject: string;
553
+ body?: string;
554
+ features?: string[];
555
+ tasks?: string[];
556
+ }
557
+ ```
558
+
559
+ ###### `getRecentCommits(limit)`
560
+
561
+ Gets recent commit history.
562
+
563
+ ```javascript
564
+ async getRecentCommits(limit?: number): Promise<Commit[]>
565
+ ```
566
+
567
+ ### Token Counter
568
+
569
+ Counts tokens for various AI models.
570
+
571
+ #### Functions
572
+
573
+ ###### `countTokens(text, model)`
574
+
575
+ Counts tokens in text.
576
+
577
+ ```javascript
578
+ countTokens(text: string, model?: string): number
579
+ ```
580
+
581
+ **Supported models:**
582
+ - `gpt-3.5-turbo`
583
+ - `gpt-4`
584
+ - `claude`
585
+ - `claude-instant`
586
+
587
+ ###### `estimateCost(tokens, model)`
588
+
589
+ Estimates cost based on token count.
590
+
591
+ ```javascript
592
+ estimateCost(tokens: number, model: string): number
593
+ ```
594
+
595
+ ### Text Processors
596
+
597
+ Various text processing utilities.
598
+
599
+ #### Functions
600
+
601
+ ###### `summarizeText(text, maxLength)`
602
+
603
+ Creates a summary of text.
604
+
605
+ ```javascript
606
+ async summarizeText(
607
+ text: string,
608
+ maxLength?: number
609
+ ): Promise<string>
610
+ ```
611
+
612
+ ###### `extractKeywords(text)`
613
+
614
+ Extracts keywords from text.
615
+
616
+ ```javascript
617
+ extractKeywords(text: string): string[]
618
+ ```
619
+
620
+ ###### `normalizeWhitespace(text)`
621
+
622
+ Normalizes whitespace in text.
623
+
624
+ ```javascript
625
+ normalizeWhitespace(text: string): string
626
+ ```
627
+
628
+ ---
629
+
630
+ ## Plugin APIs
631
+
632
+ ### Plugin Interface
633
+
634
+ Standard interface for AIWF plugins.
635
+
636
+ #### Interface: `AIWFPlugin`
637
+
638
+ ```typescript
639
+ interface AIWFPlugin {
640
+ name: string;
641
+ version: string;
642
+ description?: string;
643
+
644
+ // Lifecycle hooks
645
+ init?(context: PluginContext): Promise<void>;
646
+ destroy?(): Promise<void>;
647
+
648
+ // Command hooks
649
+ commands?: Record<string, CommandHandler>;
650
+
651
+ // Event hooks
652
+ hooks?: Record<string, HookHandler>;
653
+ }
654
+ ```
655
+
656
+ #### Plugin Context
657
+
658
+ ```typescript
659
+ interface PluginContext {
660
+ aiwfPath: string;
661
+ projectRoot: string;
662
+ config: AIWFConfig;
663
+ logger: Logger;
664
+
665
+ // Core services
666
+ resourceLoader: ResourceLoader;
667
+ stateManager: StateIndexManager;
668
+ templateEngine: TemplateEngine;
669
+ }
670
+ ```
671
+
672
+ ### Hook System
673
+
674
+ Event-driven extension system.
675
+
676
+ #### Available Hooks
677
+
678
+ ##### Command Lifecycle
679
+
680
+ ```javascript
681
+ hooks: {
682
+ 'before-command': async (command, args) => { /* ... */ },
683
+ 'after-command': async (command, result) => { /* ... */ },
684
+ 'command-error': async (command, error) => { /* ... */ }
685
+ }
686
+ ```
687
+
688
+ ##### State Management
689
+
690
+ ```javascript
691
+ hooks: {
692
+ 'before-state-change': async (oldState, newState) => { /* ... */ },
693
+ 'after-state-change': async (oldState, newState) => { /* ... */ },
694
+ 'state-checkpoint': async (checkpoint) => { /* ... */ }
695
+ }
696
+ ```
697
+
698
+ ##### Resource Loading
699
+
700
+ ```javascript
701
+ hooks: {
702
+ 'before-resource-load': async (type, name) => { /* ... */ },
703
+ 'after-resource-load': async (type, name, content) => { /* ... */ },
704
+ 'resource-not-found': async (type, name) => { /* ... */ }
705
+ }
706
+ ```
707
+
708
+ ---
709
+
710
+ ## AI Integration APIs
711
+
712
+ ### Persona Manager
713
+
714
+ Manages AI persona configurations and contexts.
715
+
716
+ #### Class: `AIPersonaManager`
717
+
718
+ ```javascript
719
+ import { AIPersonaManager } from 'aiwf/lib/ai-persona-manager';
720
+ ```
721
+
722
+ ##### Methods
723
+
724
+ ###### `loadPersona(name)`
725
+
726
+ Loads a persona configuration.
727
+
728
+ ```javascript
729
+ async loadPersona(name: string): Promise<Persona>
730
+ ```
731
+
732
+ ###### `applyPersona(content, persona)`
733
+
734
+ Applies persona context to content.
735
+
736
+ ```javascript
737
+ applyPersona(content: string, persona: Persona): string
738
+ ```
739
+
740
+ ###### `validatePersona(persona)`
741
+
742
+ Validates persona configuration.
743
+
744
+ ```javascript
745
+ validatePersona(persona: Persona): ValidationResult
746
+ ```
747
+
748
+ ### Compression Engine
749
+
750
+ Provides intelligent content compression.
751
+
752
+ #### Class: `CompressionEngine`
753
+
754
+ ##### Methods
755
+
756
+ ###### `compress(content, strategy)`
757
+
758
+ Compresses content using specified strategy.
759
+
760
+ ```javascript
761
+ async compress(
762
+ content: string,
763
+ strategy: CompressionStrategy
764
+ ): Promise<CompressedContent>
765
+ ```
766
+
767
+ ###### `decompress(compressed)`
768
+
769
+ Decompresses content.
770
+
771
+ ```javascript
772
+ async decompress(compressed: CompressedContent): Promise<string>
773
+ ```
774
+
775
+ ###### `analyzeCompression(content)`
776
+
777
+ Analyzes potential compression savings.
778
+
779
+ ```javascript
780
+ analyzeCompression(content: string): CompressionAnalysis
781
+ ```
782
+
783
+ ### Evaluation System
784
+
785
+ Evaluates AI responses and code quality.
786
+
787
+ #### Class: `EvaluationSystem`
788
+
789
+ ##### Methods
790
+
791
+ ###### `evaluateQuality(content, criteria)`
792
+
793
+ Evaluates content quality.
794
+
795
+ ```javascript
796
+ async evaluateQuality(
797
+ content: string,
798
+ criteria?: EvaluationCriteria
799
+ ): Promise<QualityScore>
800
+ ```
801
+
802
+ ###### `compareResponses(responses)`
803
+
804
+ Compares multiple AI responses.
805
+
806
+ ```javascript
807
+ compareResponses(responses: string[]): ComparisonResult
808
+ ```
809
+
810
+ ###### `generateReport(evaluations)`
811
+
812
+ Generates evaluation report.
813
+
814
+ ```javascript
815
+ generateReport(evaluations: Evaluation[]): EvaluationReport
816
+ ```
817
+
818
+ ---
819
+
820
+ ## Error Handling
821
+
822
+ All AIWF APIs follow consistent error handling patterns:
823
+
824
+ ```javascript
825
+ try {
826
+ const result = await aiwfApi.someMethod();
827
+ } catch (error) {
828
+ if (error.code === 'RESOURCE_NOT_FOUND') {
829
+ // Handle missing resource
830
+ } else if (error.code === 'VALIDATION_ERROR') {
831
+ // Handle validation error
832
+ console.error(error.details);
833
+ } else {
834
+ // Handle unexpected error
835
+ throw error;
836
+ }
837
+ }
838
+ ```
839
+
840
+ ### Error Codes
841
+
842
+ - `RESOURCE_NOT_FOUND` - Requested resource not found
843
+ - `VALIDATION_ERROR` - Input validation failed
844
+ - `STATE_CONFLICT` - State operation conflict
845
+ - `PERMISSION_DENIED` - Insufficient permissions
846
+ - `NETWORK_ERROR` - Network operation failed
847
+ - `TIMEOUT` - Operation timed out
848
+
849
+ ---
850
+
851
+ ## Best Practices
852
+
853
+ ### Resource Management
854
+
855
+ 1. Always use ResourceLoader for accessing framework resources
856
+ 2. Prefer async methods for I/O operations
857
+ 3. Handle resource not found errors gracefully
858
+ 4. Cache expensive operations when possible
859
+
860
+ ### State Management
861
+
862
+ 1. Use atomic state updates to prevent conflicts
863
+ 2. Create checkpoints before major operations
864
+ 3. Validate state transitions
865
+ 4. Handle concurrent modifications
866
+
867
+ ### Error Handling
868
+
869
+ 1. Use specific error codes for different scenarios
870
+ 2. Provide meaningful error messages
871
+ 3. Include context in error details
872
+ 4. Log errors appropriately
873
+
874
+ ### Performance
875
+
876
+ 1. Use streaming for large files
877
+ 2. Implement pagination for lists
878
+ 3. Cache frequently accessed data
879
+ 4. Monitor memory usage
880
+
881
+ ---
882
+
883
+ ## Examples
884
+
885
+ ### Creating a Custom Command
886
+
887
+ ```javascript
888
+ import { ResourceLoader } from 'aiwf/lib/resource-loader';
889
+ import { StateIndexManager } from 'aiwf/lib/state/state-index';
890
+
891
+ export default class CustomCommand {
892
+ constructor() {
893
+ this.loader = new ResourceLoader();
894
+ this.stateManager = new StateIndexManager('.aiwf');
895
+ }
896
+
897
+ async execute(args) {
898
+ // Load current state
899
+ const state = await this.stateManager.loadState();
900
+
901
+ // Perform operations
902
+ // ...
903
+
904
+ // Save updated state
905
+ await this.stateManager.saveState(state);
906
+ }
907
+ }
908
+ ```
909
+
910
+ ### Creating a Plugin
911
+
912
+ ```javascript
913
+ export default {
914
+ name: 'my-plugin',
915
+ version: '1.0.0',
916
+
917
+ async init(context) {
918
+ this.logger = context.logger;
919
+ this.logger.info('My plugin initialized');
920
+ },
921
+
922
+ commands: {
923
+ 'my-command': {
924
+ description: 'My custom command',
925
+ handler: async (args, options) => {
926
+ // Command implementation
927
+ }
928
+ }
929
+ },
930
+
931
+ hooks: {
932
+ 'after-state-change': async (oldState, newState) => {
933
+ this.logger.info('State changed', {
934
+ from: oldState.workflow_mode,
935
+ to: newState.workflow_mode
936
+ });
937
+ }
938
+ }
939
+ };
940
+ ```
941
+
942
+ ### Using the Compression Engine
943
+
944
+ ```javascript
945
+ import { CompressionEngine } from 'aiwf/utils/compression-engine';
946
+
947
+ const engine = new CompressionEngine();
948
+
949
+ // Analyze before compression
950
+ const analysis = engine.analyzeCompression(largeContent);
951
+ console.log(`Potential savings: ${analysis.savingsPercent}%`);
952
+
953
+ // Compress with specific strategy
954
+ const compressed = await engine.compress(largeContent, {
955
+ strategy: 'aggressive',
956
+ preserveStructure: true
957
+ });
958
+
959
+ // Later, decompress
960
+ const original = await engine.decompress(compressed);
961
+ ```
962
+
963
+ ---
964
+
965
+ ## Version History
966
+
967
+ - **v0.3.x** - Current stable release
968
+ - Complete API redesign
969
+ - Plugin system introduction
970
+ - Enhanced state management
971
+
972
+ - **v0.2.x** - Legacy version
973
+ - Basic command structure
974
+ - Initial resource loader
975
+
976
+ - **v0.1.x** - Initial release
977
+ - Core framework setup
978
+
979
+ For detailed changelog, see [CHANGELOG.md](../CHANGELOG.md).