aiwf 0.3.15 → 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 (35) hide show
  1. package/README.ko.md +3 -4
  2. package/README.md +38 -3
  3. package/docs/API_REFERENCE_FULL.ko.md +979 -0
  4. package/docs/API_REFERENCE_FULL.md +979 -0
  5. package/docs/ARCHITECTURE.ko.md +314 -0
  6. package/docs/ARCHITECTURE.md +314 -0
  7. package/docs/GETTING_STARTED.ko.md +219 -0
  8. package/docs/GETTING_STARTED.md +0 -1
  9. package/docs/PERFORMANCE_GUIDELINES.ko.md +388 -0
  10. package/docs/TROUBLESHOOTING.ko.md +366 -0
  11. package/package.json +50 -2
  12. package/src/DEPENDENCY_MAP.md +90 -0
  13. package/src/lib/installer.js +1 -0
  14. package/src/lib/resources/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
  15. package/src/lib/resources/templates/api-server/template/src/routes/aiwf.ts +0 -11
  16. package/src/lib/resources/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
  17. package/src/lib/resources/utils/token-reporter.js +2 -3
  18. package/src/utils/checkpoint-manager.js +11 -1
  19. package/src/utils/engineering-guard.js +11 -1
  20. package/templates/api-server/template/src/controllers/aiwfController.ts +0 -14
  21. package/templates/api-server/template/src/routes/aiwf.ts +0 -11
  22. package/templates/web-app/template/src/pages/AiwfDashboard.tsx +2 -5
  23. package/docs/guides/feature-git-integration-guide-ko.md +0 -481
  24. package/docs/guides/feature-git-integration-guide.md +0 -481
  25. package/src/commands/cache-templates.js +0 -209
  26. package/src/commands/create-offline.js +0 -86
  27. package/src/commands/state-refactored.js +0 -419
  28. package/src/lib/resources/commands/feature-ledger.js +0 -565
  29. package/src/lib/resources/commands/feature_commit_report.js +0 -370
  30. package/src/lib/resources/commands/scan_git_history.js +0 -234
  31. package/src/lib/resources/commands/sync_feature_commits.js +0 -154
  32. package/src/lib/resources/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
  33. package/src/lib/resources/utils/feature-updater.js +0 -271
  34. package/src/utils/git-integration.js +0 -173
  35. package/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +0 -93
@@ -0,0 +1,314 @@
1
+ # AIWF 아키텍처
2
+
3
+ > AI 워크플로우 프레임워크의 시스템 아키텍처에 대한 종합적인 개요
4
+
5
+ [한국어](ARCHITECTURE.ko.md) | [English](ARCHITECTURE.md)
6
+
7
+ ## 목차
8
+
9
+ 1. [시스템 개요](#시스템-개요)
10
+ 2. [아키텍처 레이어](#아키텍처-레이어)
11
+ 3. [핵심 컴포넌트](#핵심-컴포넌트)
12
+ 4. [데이터 흐름](#데이터-흐름)
13
+ 5. [플러그인 아키텍처](#플러그인-아키텍처)
14
+ 6. [보안 고려사항](#보안-고려사항)
15
+ 7. [성능 아키텍처](#성능-아키텍처)
16
+ 8. [확장성과 향후 확장](#확장성과-향후-확장)
17
+
18
+ ## 시스템 개요
19
+
20
+ AIWF(AI 워크플로우 프레임워크)는 AI 지원 소프트웨어 개발 워크플로우를 위한 유연하고 확장 가능한 플랫폼을 제공하도록 설계된 모듈식 계층 아키텍처를 기반으로 구축되었습니다.
21
+
22
+ ### 아키텍처 다이어그램
23
+
24
+ ```
25
+ ┌─────────────────────────────────────────────────────────────────┐
26
+ │ CLI 인터페이스 레이어 │
27
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
28
+ │ │ aiwf CLI │ │ aiwf-lang │ │ 훅 │ │
29
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
30
+ └─────────┼─────────────────┼─────────────────┼──────────────────┘
31
+ │ │ │
32
+ ┌─────────┼─────────────────┼─────────────────┼──────────────────┐
33
+ │ │ 코어 엔진 레이어 │ │
34
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
35
+ │ │ 명령어 │ │ 리소스 │ │ 상태 │ │
36
+ │ │ 프로세서 │ │ 로더 │ │ 관리자 │ │
37
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
38
+ │ │ │ │ │
39
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
40
+ │ │ 템플릿 │ │ 플러그인 │ │ 토큰 │ │
41
+ │ │ 엔진 │ │ 시스템 │ │ 관리자 │ │
42
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
43
+ └─────────┼─────────────────┼─────────────────┼──────────────────┘
44
+ │ │ │
45
+ ┌─────────┼─────────────────┼─────────────────┼──────────────────┐
46
+ │ │ 저장소 및 영속성 레이어 │ │
47
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
48
+ │ │ 파일 │ │ JSON │ │ Git │ │
49
+ │ │ 시스템 │ │ 저장소 │ │ 통합 │ │
50
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
51
+ └─────────────────────────────────────────────────────────────────┘
52
+ │ │ │
53
+ ┌─────────▼─────────────────▼─────────────────▼──────────────────┐
54
+ │ AI 통합 레이어 │
55
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
56
+ │ │ 페르소나 │ │ 압축 │ │ 평가 │ │
57
+ │ │ 관리자 │ │ 엔진 │ │ 시스템 │ │
58
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
59
+ └─────────────────────────────────────────────────────────────────┘
60
+ ```
61
+
62
+ ## 아키텍처 레이어
63
+
64
+ ### 1. CLI 인터페이스 레이어
65
+ AIWF와의 모든 사용자 상호작용을 위한 진입점입니다.
66
+
67
+ - **aiwf CLI**: Commander.js로 구축된 주요 명령줄 인터페이스
68
+ - **aiwf-lang**: 국제화를 위한 언어 관리 CLI
69
+ - **훅**: Git 훅 및 시스템 통합 지점
70
+
71
+ ### 2. 코어 엔진 레이어
72
+ AIWF 기능의 핵심입니다.
73
+
74
+ - **명령어 프로세서**: 명령어 라우팅 및 실행
75
+ - **리소스 로더**: 번들 및 사용자 리소스 관리
76
+ - **상태 관리자**: 워크플로우 상태 및 전환 처리
77
+ - **템플릿 엔진**: 프로젝트 템플릿 처리
78
+ - **플러그인 시스템**: 확장성 지원
79
+ - **토큰 관리자**: AI 토큰 사용량 추적 및 최적화
80
+
81
+ ### 3. 저장소 및 영속성 레이어
82
+ 모든 데이터 저장 및 검색을 관리합니다.
83
+
84
+ - **파일 시스템**: 직접 파일 작업 및 캐싱
85
+ - **JSON 저장소**: 구조화된 데이터 영속성
86
+ - **Git 통합**: 버전 관리 시스템 통합
87
+
88
+ ### 4. AI 통합 레이어
89
+ 지능형 기능과 AI 지원을 제공합니다.
90
+
91
+ - **페르소나 관리자**: AI 동작 사용자 정의
92
+ - **압축 엔진**: AI 모델을 위한 컨텍스트 최적화
93
+ - **평가 시스템**: 코드 및 응답 품질 평가
94
+
95
+ ## 핵심 컴포넌트
96
+
97
+ ### 리소스 로더
98
+
99
+ 리소스 로더는 개발 및 프로덕션 환경 모두에서 리소스를 관리하는 중요한 컴포넌트입니다.
100
+
101
+ ```javascript
102
+ // 리소스 로딩 우선순위
103
+ 1. 사용자 리소스 (~/.aiwf/)
104
+ 2. 프로젝트 리소스 (./.aiwf/)
105
+ 3. 번들 리소스 (npm 패키지)
106
+ ```
107
+
108
+ 주요 기능:
109
+ - 동적 리소스 검색
110
+ - 폴백 메커니즘
111
+ - 템플릿 및 페르소나 관리
112
+ - 개발 중 핫 리로딩
113
+
114
+ ### 상태 관리자
115
+
116
+ 정교한 워크플로우 기반 상태 관리 시스템을 구현합니다.
117
+
118
+ ```javascript
119
+ // 상태 구조
120
+ {
121
+ "version": "1.0.0",
122
+ "lastUpdated": "ISO-8601 타임스탬프",
123
+ "workflow": {
124
+ "currentPhase": "development",
125
+ "currentTask": "task-id",
126
+ "transitions": []
127
+ },
128
+ "tasks": {
129
+ "task-id": {
130
+ "status": "in-progress",
131
+ "dependencies": [],
132
+ "priority": 0.8
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ 기능:
139
+ - 의존성 추적
140
+ - 우선순위 계산
141
+ - 순환 의존성 감지
142
+ - 상태 검증
143
+ - 전환 관리
144
+
145
+ ### 명령어 프로세서
146
+
147
+ 모듈식 설계로 명령어 라우팅 및 실행을 처리합니다.
148
+
149
+ ```javascript
150
+ // 명령어 구조
151
+ export default async function commandName(options) {
152
+ // 검증
153
+ // 실행
154
+ // 상태 업데이트
155
+ // 결과 포맷팅
156
+ }
157
+ ```
158
+
159
+ ### 템플릿 엔진
160
+
161
+ AIWF 통합이 내장된 프로젝트 스캐폴딩을 제공합니다.
162
+
163
+ 지원되는 템플릿:
164
+ - `api-server`: TypeScript를 사용한 Express.js API
165
+ - `npm-library`: Rollup을 사용한 NPM 패키지
166
+ - `web-app`: Vite를 사용한 React 애플리케이션
167
+
168
+ ### 플러그인 시스템
169
+
170
+ 훅 기반 아키텍처를 통해 확장성을 지원합니다.
171
+
172
+ ```javascript
173
+ // 플러그인 인터페이스
174
+ export interface AIWFPlugin {
175
+ name: string;
176
+ version: string;
177
+ hooks: {
178
+ beforeCommand?: (command: string, args: any) => void;
179
+ afterCommand?: (command: string, result: any) => void;
180
+ beforeStateChange?: (oldState: State, newState: State) => State;
181
+ afterStateChange?: (state: State) => void;
182
+ };
183
+ }
184
+ ```
185
+
186
+ ## 데이터 흐름
187
+
188
+ ### 명령어 실행 흐름
189
+
190
+ ```
191
+ 사용자 입력 → CLI 파서 → 명령어 프로세서 → 명령어 구현
192
+ ↓ ↓
193
+ 토큰 추적 ← 상태 업데이트 ← 결과 처리 ← 실행
194
+ ↓
195
+ 사용자 출력
196
+ ```
197
+
198
+ ### 리소스 로딩 흐름
199
+
200
+ ```
201
+ 리소스 요청 → 사용자 리소스 확인 → 발견? → 반환
202
+ ↓ 미발견
203
+ 프로젝트 리소스 확인 → 발견? → 반환
204
+ ↓ 미발견
205
+ 번들 리소스 로드 → 반환
206
+ ```
207
+
208
+ ### 상태 관리 흐름
209
+
210
+ ```
211
+ 명령어 실행 → 사전 검증 → 상태 잠금 → 상태 업데이트
212
+ ↓
213
+ 사후 검증
214
+ ↓
215
+ 구독자 알림
216
+ ↓
217
+ 잠금 해제
218
+ ```
219
+
220
+ ## 플러그인 아키텍처
221
+
222
+ AIWF의 플러그인 시스템은 코어 코드를 수정하지 않고도 기능을 확장할 수 있게 합니다.
223
+
224
+ ### 플러그인 로딩
225
+
226
+ 1. 다음 위치에서 플러그인 스캔:
227
+ - `~/.aiwf/plugins/`
228
+ - `./node_modules/aiwf-plugin-*/`
229
+ - 명시적 플러그인 경로
230
+
231
+ 2. 플러그인 구조 검증
232
+ 3. 훅 등록
233
+ 4. 플러그인 초기화
234
+
235
+ ### 훅 포인트
236
+
237
+ - **라이프사이클 훅**: `init`, `destroy`
238
+ - **명령어 훅**: `beforeCommand`, `afterCommand`
239
+ - **상태 훅**: `beforeStateChange`, `afterStateChange`
240
+ - **리소스 훅**: `beforeResourceLoad`, `afterResourceLoad`
241
+
242
+ ## 보안 고려사항
243
+
244
+ ### 입력 검증
245
+
246
+ 모든 사용자 입력은 처리 전에 검증됩니다:
247
+ - 명령어 인수 살균
248
+ - 경로 순회 방지
249
+ - 인젝션 공격 방지
250
+
251
+ ### 리소스 격리
252
+
253
+ - 사용자 리소스는 시스템 리소스와 격리됨
254
+ - 샌드박스 템플릿 실행
255
+ - 제한된 파일 시스템 접근
256
+
257
+ ### 토큰 보안
258
+
259
+ - 토큰 수는 로컬에만 저장
260
+ - 토큰 추적에 민감한 데이터 없음
261
+ - 구성 가능한 개인정보 설정
262
+
263
+ ## 성능 아키텍처
264
+
265
+ ### 최적화 전략
266
+
267
+ 1. **지연 로딩**: 명령어와 리소스를 필요시 로드
268
+ 2. **캐싱**: 자주 접근하는 리소스를 메모리에 캐시
269
+ 3. **병렬 처리**: 독립적인 작업을 동시에 실행
270
+ 4. **증분 업데이트**: 변경된 상태 부분만 업데이트
271
+
272
+ ### 메모리 관리
273
+
274
+ - 템플릿을 위한 리소스 풀링
275
+ - 자동 캐시 제거
276
+ - 메모리 사용량 모니터링
277
+ - 가비지 컬렉션 최적화
278
+
279
+ ### 성능 모니터링
280
+
281
+ 내장 성능 추적:
282
+ - 명령어 실행 시간
283
+ - 리소스 로딩 시간
284
+ - 상태 작업 메트릭
285
+ - 토큰 사용 효율성
286
+
287
+ ## 확장성과 향후 확장
288
+
289
+ ### 계획된 확장
290
+
291
+ 1. **클라우드 동기화**: 기기 간 상태 동기화
292
+ 2. **팀 협업**: 공유 워크플로우 및 상태
293
+ 3. **커스텀 AI 모델**: 자체 호스팅 모델 지원
294
+ 4. **고급 분석**: 상세한 생산성 메트릭
295
+
296
+ ### 확장 포인트
297
+
298
+ - 사용자 정의 명령어 개발
299
+ - 새로운 템플릿 유형
300
+ - 추가 AI 페르소나
301
+ - 대체 저장소 백엔드
302
+ - 사용자 정의 압축 전략
303
+
304
+ ### API 안정성
305
+
306
+ AIWF는 시맨틱 버전 관리를 따릅니다:
307
+ - v1.0.0부터 코어 API 안정화
308
+ - 플러그인 API는 별도로 버전 관리
309
+ - 주요 변경사항에 대한 사용 중단 알림
310
+ - 주요 버전에 대한 마이그레이션 가이드
311
+
312
+ ## 결론
313
+
314
+ AIWF의 아키텍처는 모듈식, 확장 가능, 고성능으로 설계되었습니다. 계층화된 접근 방식은 관심사의 분리를 보장하며, 플러그인 시스템은 코어 안정성을 손상시키지 않으면서 사용자 정의를 가능하게 합니다. 이 아키텍처는 역호환성을 유지하면서 현재 기능과 향후 확장을 모두 지원합니다.
@@ -0,0 +1,314 @@
1
+ # AIWF Architecture
2
+
3
+ > A comprehensive overview of the AI Workflow Framework's system architecture
4
+
5
+ [한국어](ARCHITECTURE.ko.md) | [English](ARCHITECTURE.md)
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [System Overview](#system-overview)
10
+ 2. [Architecture Layers](#architecture-layers)
11
+ 3. [Core Components](#core-components)
12
+ 4. [Data Flow](#data-flow)
13
+ 5. [Plugin Architecture](#plugin-architecture)
14
+ 6. [Security Considerations](#security-considerations)
15
+ 7. [Performance Architecture](#performance-architecture)
16
+ 8. [Scalability and Future Extensions](#scalability-and-future-extensions)
17
+
18
+ ## System Overview
19
+
20
+ AIWF (AI Workflow Framework) is built on a modular, layered architecture designed to provide a flexible and extensible platform for AI-assisted software development workflows.
21
+
22
+ ### Architecture Diagram
23
+
24
+ ```
25
+ ┌─────────────────────────────────────────────────────────────────┐
26
+ │ CLI Interface Layer │
27
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
28
+ │ │ aiwf CLI │ │ aiwf-lang │ │ Hooks │ │
29
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
30
+ └─────────┼─────────────────┼─────────────────┼──────────────────┘
31
+ │ │ │
32
+ ┌─────────┼─────────────────┼─────────────────┼──────────────────┐
33
+ │ │ Core Engine Layer │ │
34
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
35
+ │ │ Command │ │ Resource │ │ State │ │
36
+ │ │ Processor │ │ Loader │ │ Manager │ │
37
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
38
+ │ │ │ │ │
39
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
40
+ │ │ Template │ │ Plugin │ │ Token │ │
41
+ │ │ Engine │ │ System │ │ Manager │ │
42
+ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
43
+ └─────────┼─────────────────┼─────────────────┼──────────────────┘
44
+ │ │ │
45
+ ┌─────────┼─────────────────┼─────────────────┼──────────────────┐
46
+ │ │ Storage & Persistence Layer │ │
47
+ │ ┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐ │
48
+ │ │ File │ │ JSON │ │ Git │ │
49
+ │ │ System │ │ Storage │ │ Integration │ │
50
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
51
+ └─────────────────────────────────────────────────────────────────┘
52
+ │ │ │
53
+ ┌─────────▼─────────────────▼─────────────────▼──────────────────┐
54
+ │ AI Integration Layer │
55
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
56
+ │ │ Persona │ │ Compression │ │ Evaluation │ │
57
+ │ │ Manager │ │ Engine │ │ System │ │
58
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
59
+ └─────────────────────────────────────────────────────────────────┘
60
+ ```
61
+
62
+ ## Architecture Layers
63
+
64
+ ### 1. CLI Interface Layer
65
+ The entry point for all user interactions with AIWF.
66
+
67
+ - **aiwf CLI**: Main command-line interface built with Commander.js
68
+ - **aiwf-lang**: Language management CLI for internationalization
69
+ - **Hooks**: Git hooks and system integration points
70
+
71
+ ### 2. Core Engine Layer
72
+ The heart of AIWF's functionality.
73
+
74
+ - **Command Processor**: Routes and executes commands
75
+ - **Resource Loader**: Manages bundled and user resources
76
+ - **State Manager**: Handles workflow state and transitions
77
+ - **Template Engine**: Processes project templates
78
+ - **Plugin System**: Enables extensibility
79
+ - **Token Manager**: Tracks and optimizes AI token usage
80
+
81
+ ### 3. Storage & Persistence Layer
82
+ Manages all data storage and retrieval.
83
+
84
+ - **File System**: Direct file operations and caching
85
+ - **JSON Storage**: Structured data persistence
86
+ - **Git Integration**: Version control system integration
87
+
88
+ ### 4. AI Integration Layer
89
+ Provides intelligent features and AI assistance.
90
+
91
+ - **Persona Manager**: AI behavior customization
92
+ - **Compression Engine**: Context optimization for AI models
93
+ - **Evaluation System**: Code and response quality assessment
94
+
95
+ ## Core Components
96
+
97
+ ### Resource Loader
98
+
99
+ The Resource Loader is a critical component that manages resources in both development and production environments.
100
+
101
+ ```javascript
102
+ // Resource loading priority
103
+ 1. User resources (~/.aiwf/)
104
+ 2. Project resources (./.aiwf/)
105
+ 3. Bundled resources (npm package)
106
+ ```
107
+
108
+ Key features:
109
+ - Dynamic resource discovery
110
+ - Fallback mechanism
111
+ - Template and persona management
112
+ - Hot-reloading in development
113
+
114
+ ### State Manager
115
+
116
+ Implements a sophisticated workflow-based state management system.
117
+
118
+ ```javascript
119
+ // State structure
120
+ {
121
+ "version": "1.0.0",
122
+ "lastUpdated": "ISO-8601 timestamp",
123
+ "workflow": {
124
+ "currentPhase": "development",
125
+ "currentTask": "task-id",
126
+ "transitions": []
127
+ },
128
+ "tasks": {
129
+ "task-id": {
130
+ "status": "in-progress",
131
+ "dependencies": [],
132
+ "priority": 0.8
133
+ }
134
+ }
135
+ }
136
+ ```
137
+
138
+ Features:
139
+ - Dependency tracking
140
+ - Priority calculation
141
+ - Circular dependency detection
142
+ - State validation
143
+ - Transition management
144
+
145
+ ### Command Processor
146
+
147
+ Handles command routing and execution with a modular design.
148
+
149
+ ```javascript
150
+ // Command structure
151
+ export default async function commandName(options) {
152
+ // Validation
153
+ // Execution
154
+ // State update
155
+ // Result formatting
156
+ }
157
+ ```
158
+
159
+ ### Template Engine
160
+
161
+ Provides project scaffolding with AIWF integration built-in.
162
+
163
+ Supported templates:
164
+ - `api-server`: Express.js API with TypeScript
165
+ - `npm-library`: NPM package with Rollup
166
+ - `web-app`: React application with Vite
167
+
168
+ ### Plugin System
169
+
170
+ Enables extensibility through a hook-based architecture.
171
+
172
+ ```javascript
173
+ // Plugin interface
174
+ export interface AIWFPlugin {
175
+ name: string;
176
+ version: string;
177
+ hooks: {
178
+ beforeCommand?: (command: string, args: any) => void;
179
+ afterCommand?: (command: string, result: any) => void;
180
+ beforeStateChange?: (oldState: State, newState: State) => State;
181
+ afterStateChange?: (state: State) => void;
182
+ };
183
+ }
184
+ ```
185
+
186
+ ## Data Flow
187
+
188
+ ### Command Execution Flow
189
+
190
+ ```
191
+ User Input → CLI Parser → Command Processor → Command Implementation
192
+ ↓ ↓
193
+ Token Tracking ← State Update ← Result Processing ← Execution
194
+ ↓
195
+ User Output
196
+ ```
197
+
198
+ ### Resource Loading Flow
199
+
200
+ ```
201
+ Resource Request → Check User Resources → Found? → Return
202
+ ↓ Not Found
203
+ Check Project Resources → Found? → Return
204
+ ↓ Not Found
205
+ Load Bundled Resources → Return
206
+ ```
207
+
208
+ ### State Management Flow
209
+
210
+ ```
211
+ Command Execution → Pre-validation → State Lock → Update State
212
+ ↓
213
+ Post-validation
214
+ ↓
215
+ Notify Subscribers
216
+ ↓
217
+ Release Lock
218
+ ```
219
+
220
+ ## Plugin Architecture
221
+
222
+ AIWF's plugin system allows for extending functionality without modifying core code.
223
+
224
+ ### Plugin Loading
225
+
226
+ 1. Scan for plugins in:
227
+ - `~/.aiwf/plugins/`
228
+ - `./node_modules/aiwf-plugin-*/`
229
+ - Explicit plugin paths
230
+
231
+ 2. Validate plugin structure
232
+ 3. Register hooks
233
+ 4. Initialize plugin
234
+
235
+ ### Hook Points
236
+
237
+ - **Lifecycle Hooks**: `init`, `destroy`
238
+ - **Command Hooks**: `beforeCommand`, `afterCommand`
239
+ - **State Hooks**: `beforeStateChange`, `afterStateChange`
240
+ - **Resource Hooks**: `beforeResourceLoad`, `afterResourceLoad`
241
+
242
+ ## Security Considerations
243
+
244
+ ### Input Validation
245
+
246
+ All user inputs are validated before processing:
247
+ - Command arguments sanitization
248
+ - Path traversal prevention
249
+ - Injection attack prevention
250
+
251
+ ### Resource Isolation
252
+
253
+ - User resources are isolated from system resources
254
+ - Sandboxed template execution
255
+ - Limited file system access
256
+
257
+ ### Token Security
258
+
259
+ - Token counts stored locally only
260
+ - No sensitive data in token tracking
261
+ - Configurable privacy settings
262
+
263
+ ## Performance Architecture
264
+
265
+ ### Optimization Strategies
266
+
267
+ 1. **Lazy Loading**: Commands and resources loaded on-demand
268
+ 2. **Caching**: Frequently accessed resources cached in memory
269
+ 3. **Parallel Processing**: Independent operations run concurrently
270
+ 4. **Incremental Updates**: Only changed state portions updated
271
+
272
+ ### Memory Management
273
+
274
+ - Resource pooling for templates
275
+ - Automatic cache eviction
276
+ - Memory usage monitoring
277
+ - Garbage collection optimization
278
+
279
+ ### Performance Monitoring
280
+
281
+ Built-in performance tracking:
282
+ - Command execution time
283
+ - Resource loading time
284
+ - State operation metrics
285
+ - Token usage efficiency
286
+
287
+ ## Scalability and Future Extensions
288
+
289
+ ### Planned Extensions
290
+
291
+ 1. **Cloud Sync**: Synchronize state across devices
292
+ 2. **Team Collaboration**: Shared workflows and states
293
+ 3. **Custom AI Models**: Support for self-hosted models
294
+ 4. **Advanced Analytics**: Detailed productivity metrics
295
+
296
+ ### Extension Points
297
+
298
+ - Custom command development
299
+ - New template types
300
+ - Additional AI personas
301
+ - Alternative storage backends
302
+ - Custom compression strategies
303
+
304
+ ### API Stability
305
+
306
+ AIWF follows semantic versioning:
307
+ - Core APIs stable from v1.0.0
308
+ - Plugin APIs versioned separately
309
+ - Deprecation notices for breaking changes
310
+ - Migration guides for major versions
311
+
312
+ ## Conclusion
313
+
314
+ AIWF's architecture is designed to be modular, extensible, and performant. The layered approach ensures separation of concerns while the plugin system enables customization without compromising core stability. This architecture supports both current features and future expansions while maintaining backward compatibility.