aiwf 0.3.7 → 0.3.8
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.
- package/.aiwf/00_PROJECT_MANIFEST.md +226 -2
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/S03_M02_sprint_meta.md +112 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T01_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T02_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T03_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T04_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T05_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T06_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T07_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T08_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T09_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T100_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T101_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T102_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T103_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T104_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T105_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T106_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T107_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T108_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T109_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T10_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T110_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T111_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T112_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T11_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T12_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T13_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T14_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T15_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T16_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T17_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T18_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T19_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T20_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T21_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T22_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T23_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T24_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T25_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T26_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T27_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T28_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T29_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T30_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T31_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T32_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T33_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T34_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T35_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T36_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T37_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T38_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T39_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T40_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T41_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T42_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T43_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T44_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T45_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T46_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T47_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T48_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T49_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T50_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T51_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T52_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T53_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T54_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T55_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T56_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T57_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T58_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T59_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T60_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T61_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T62_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T63_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T64_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T65_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T66_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T67_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T68_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T69_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T70_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T71_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T72_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T73_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T74_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T75_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T76_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T77_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T78_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T79_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T80_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T81_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T82_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T83_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T84_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T85_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T86_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T87_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T88_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T89_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T90_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T91_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T92_S03_task_with_special_characters.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T93_S03_test.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T94_S03_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T95_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T96_S03_next_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T97_S03_new_test_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T98_S03_first_task.md +39 -0
- package/.aiwf/03_SPRINTS/S03_M02_ecosystem_integration/T99_S03_test_task.md +39 -0
- package/.aiwf/test-results-s02.json +5 -5
- package/.claude/commands/aiwf/aiwf_compress_aggressive_persona.md +3 -15
- package/.claude/commands/aiwf/aiwf_compress_minimal_persona.md +2 -15
- package/.claude/commands/aiwf/aiwf_compress_stats.md +2 -51
- package/.claude/commands/aiwf/aiwf_compress_with_persona.md +5 -18
- package/.claude/commands/aiwf/aiwf_create_feature_ledger.md +1 -1
- package/.claude/commands/aiwf/aiwf_default_mode.md +1 -1
- package/.claude/commands/aiwf/aiwf_evaluate.md +3 -16
- package/.claude/commands/aiwf/aiwf_get_feature_details.md +1 -1
- package/.claude/commands/aiwf/aiwf_link_feature_to_milestone.md +1 -1
- package/.claude/commands/aiwf/aiwf_list_features.md +1 -1
- package/.claude/commands/aiwf/aiwf_switch_language.md +48 -120
- package/.claude/commands/aiwf/aiwf_update_feature_status.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_aggressive_persona.md +2 -2
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_minimal_persona.md +2 -2
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_stats.md +10 -47
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_compress_with_persona.md +2 -2
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_create_feature_ledger.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_default_mode.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_evaluate.md +2 -2
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_get_feature_details.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_link_feature_to_milestone.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_list_features.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_architect.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_backend.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_data_analyst.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_frontend.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_security.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_persona_status.md +1 -1
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_update_feature_status.md +1 -1
- package/package.json +1 -1
- package/src/cli/index.js +174 -0
- package/src/commands/compress.js +60 -0
- package/src/commands/create-project.js +23 -17
- package/src/commands/evaluate.js +459 -0
- package/src/commands/feature.js +365 -0
- package/src/commands/persona.js +37 -16
- package/src/commands/token.js +312 -0
- package/src/lib/resource-loader.js +250 -0
- package/src/lib/resources/commands/ai-persona.js +602 -0
- package/src/lib/resources/commands/compress-context.js +389 -0
- package/src/lib/resources/commands/evaluate.js +246 -0
- package/src/lib/resources/commands/feature-ledger.js +565 -0
- package/src/lib/resources/commands/feature_commit_report.js +370 -0
- package/src/lib/resources/commands/persona-context-apply.js +562 -0
- package/src/lib/resources/commands/scan_git_history.js +234 -0
- package/src/lib/resources/commands/sync_feature_commits.js +154 -0
- package/src/lib/resources/commands/token-tracking.js +443 -0
- package/src/lib/resources/config/commit-patterns.js +103 -0
- package/src/lib/resources/config/language.json +6 -0
- package/src/lib/resources/personas/PERSONA_INDEX.md +57 -0
- package/src/lib/resources/personas/analyst.json +44 -0
- package/src/lib/resources/personas/architect/best_practices.md +136 -0
- package/src/lib/resources/personas/architect/knowledge_base.md +377 -0
- package/src/lib/resources/personas/architect.json +44 -0
- package/src/lib/resources/personas/backend/best_practices.md +766 -0
- package/src/lib/resources/personas/backend/knowledge_base.md +1070 -0
- package/src/lib/resources/personas/data_analyst/best_practices.md +594 -0
- package/src/lib/resources/personas/data_analyst/knowledge_base.md +1057 -0
- package/src/lib/resources/personas/developer.json +44 -0
- package/src/lib/resources/personas/developer.md +37 -0
- package/src/lib/resources/personas/evaluation_criteria.json +137 -0
- package/src/lib/resources/personas/frontend/best_practices.md +445 -0
- package/src/lib/resources/personas/frontend/knowledge_base.md +729 -0
- package/src/lib/resources/personas/persona-index.json +31 -0
- package/src/lib/resources/personas/reviewer.json +44 -0
- package/src/lib/resources/personas/security/best_practices.md +307 -0
- package/src/lib/resources/personas/security/knowledge_base.md +498 -0
- package/src/lib/resources/personas/tester.json +44 -0
- package/src/lib/resources/templates/README.md +78 -0
- package/src/lib/resources/templates/api-server/config.json +64 -0
- package/src/lib/resources/templates/api-server/template/.aiwf/config.json +56 -0
- package/src/lib/resources/templates/api-server/template/.aiwf/feature-ledger.json +42 -0
- package/src/lib/resources/templates/api-server/template/.aiwf/personas/backend-engineer.json +40 -0
- package/src/lib/resources/templates/api-server/template/.aiwf/scripts/cli.js +111 -0
- package/src/lib/resources/templates/api-server/template/.env.example +29 -0
- package/src/lib/resources/templates/api-server/template/.eslintrc.json +23 -0
- package/src/lib/resources/templates/api-server/template/README.md +171 -0
- package/src/lib/resources/templates/api-server/template/jest.config.js +26 -0
- package/src/lib/resources/templates/api-server/template/nodemon.json +9 -0
- package/src/lib/resources/templates/api-server/template/package.json +61 -0
- package/src/lib/resources/templates/api-server/template/src/app.ts +60 -0
- package/src/lib/resources/templates/api-server/template/src/config/swagger.ts +38 -0
- package/src/lib/resources/templates/api-server/template/src/controllers/aiwfController.ts +68 -0
- package/src/lib/resources/templates/api-server/template/src/controllers/authController.ts +128 -0
- package/src/lib/resources/templates/api-server/template/src/controllers/statusController.ts +28 -0
- package/src/lib/resources/templates/api-server/template/src/index.ts +28 -0
- package/src/lib/resources/templates/api-server/template/src/middleware/aiwfMiddleware.ts +50 -0
- package/src/lib/resources/templates/api-server/template/src/middleware/authMiddleware.ts +41 -0
- package/src/lib/resources/templates/api-server/template/src/middleware/errorHandler.ts +42 -0
- package/src/lib/resources/templates/api-server/template/src/middleware/notFoundHandler.ts +14 -0
- package/src/lib/resources/templates/api-server/template/src/middleware/requestLogger.ts +20 -0
- package/src/lib/resources/templates/api-server/template/src/routes/aiwf.ts +42 -0
- package/src/lib/resources/templates/api-server/template/src/routes/index.ts +13 -0
- package/src/lib/resources/templates/api-server/template/src/routes/v1/index.ts +67 -0
- package/src/lib/resources/templates/api-server/template/src/utils/logger.ts +37 -0
- package/src/lib/resources/templates/api-server/template/tests/app.test.ts +40 -0
- package/src/lib/resources/templates/api-server/template/tsconfig.json +43 -0
- package/src/lib/resources/templates/npm-library/config.json +61 -0
- package/src/lib/resources/templates/npm-library/template/LICENSE +21 -0
- package/src/lib/resources/templates/npm-library/template/README.md +201 -0
- package/src/lib/resources/templates/npm-library/template/package.json +78 -0
- package/src/lib/resources/templates/web-app/config.json +53 -0
- package/src/lib/resources/templates/web-app/template/.aiwf/config.json +54 -0
- package/src/lib/resources/templates/web-app/template/.aiwf/feature-ledger.json +37 -0
- package/src/lib/resources/templates/web-app/template/.aiwf/personas/fullstack-developer.json +40 -0
- package/src/lib/resources/templates/web-app/template/.aiwf/scripts/cli.js +110 -0
- package/src/lib/resources/templates/web-app/template/.eslintrc.cjs +20 -0
- package/src/lib/resources/templates/web-app/template/README.md +151 -0
- package/src/lib/resources/templates/web-app/template/index.html +14 -0
- package/src/lib/resources/templates/web-app/template/package.json +44 -0
- package/src/lib/resources/templates/web-app/template/postcss.config.js +6 -0
- package/src/lib/resources/templates/web-app/template/public/vite.svg +1 -0
- package/src/lib/resources/templates/web-app/template/src/App.tsx +21 -0
- package/src/lib/resources/templates/web-app/template/src/components/Layout.tsx +57 -0
- package/src/lib/resources/templates/web-app/template/src/components/aiwf/ContextStatus.tsx +107 -0
- package/src/lib/resources/templates/web-app/template/src/components/aiwf/FeatureLedger.tsx +93 -0
- package/src/lib/resources/templates/web-app/template/src/components/aiwf/TokenUsage.tsx +71 -0
- package/src/lib/resources/templates/web-app/template/src/index.css +60 -0
- package/src/lib/resources/templates/web-app/template/src/main.tsx +10 -0
- package/src/lib/resources/templates/web-app/template/src/pages/AiwfDashboard.tsx +60 -0
- package/src/lib/resources/templates/web-app/template/src/pages/HomePage.tsx +89 -0
- package/src/lib/resources/templates/web-app/template/src/pages/NotFound.tsx +25 -0
- package/src/lib/resources/templates/web-app/template/src/stores/aiwfStore.ts +126 -0
- package/src/lib/resources/templates/web-app/template/src/types/global.d.ts +9 -0
- package/src/lib/resources/templates/web-app/template/src/vite-env.d.ts +1 -0
- package/src/lib/resources/templates/web-app/template/tailwind.config.js +30 -0
- package/src/lib/resources/templates/web-app/template/tsconfig.json +37 -0
- package/src/lib/resources/templates/web-app/template/tsconfig.node.json +10 -0
- package/src/lib/resources/templates/web-app/template/vite.config.ts +23 -0
- package/src/lib/resources/utils/background-monitor.js +223 -0
- package/src/lib/resources/utils/compression-metrics.js +1031 -0
- package/src/lib/resources/utils/compression-strategies.js +557 -0
- package/src/lib/resources/utils/content-normalizer.js +455 -0
- package/src/lib/resources/utils/context-compressor.js +583 -0
- package/src/lib/resources/utils/context-rule-parser.js +180 -0
- package/src/lib/resources/utils/context-token-monitor.js +463 -0
- package/src/lib/resources/utils/context-update-manager.js +502 -0
- package/src/lib/resources/utils/feature-updater.js +271 -0
- package/src/lib/resources/utils/git-utils.js +220 -0
- package/src/lib/resources/utils/importance-classifier.js +645 -0
- package/src/lib/resources/utils/information-filter.js +710 -0
- package/src/lib/resources/utils/persona-aware-compressor.js +598 -0
- package/src/lib/resources/utils/prompt-injector.js +242 -0
- package/src/lib/resources/utils/simplified-evaluator.js +119 -0
- package/src/lib/resources/utils/text-summarizer.js +492 -0
- package/src/lib/resources/utils/token-counter.js +177 -0
- package/src/lib/resources/utils/token-monitor.js +484 -0
- package/src/lib/resources/utils/token-reporter.js +453 -0
- package/src/lib/resources/utils/token-storage.js +433 -0
- package/src/lib/resources/utils/token-tracker.js +283 -0
- package/claude-code/aiwf/ko/.claude/commands/aiwf/aiwf_switch_language.md +0 -160
- /package/claude-code/aiwf/ko/.claude/commands/aiwf/{aiwf_update_docs_kr.md → aiwf_update_docs.md} +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AIWF 토큰 추적 명령어
|
|
5
|
+
* AI 토큰 사용량 모니터링 및 분석
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { ResourceLoader } from '../lib/resource-loader.js';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
|
|
13
|
+
class TokenCommand {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.resourceLoader = new ResourceLoader();
|
|
16
|
+
this.tokenDataPath = path.join(process.cwd(), '.aiwf', 'token-usage');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Token 명령어 실행
|
|
21
|
+
*/
|
|
22
|
+
async execute(args) {
|
|
23
|
+
const [subcommand, ...restArgs] = args;
|
|
24
|
+
|
|
25
|
+
switch (subcommand) {
|
|
26
|
+
case 'status':
|
|
27
|
+
await this.showStatus();
|
|
28
|
+
break;
|
|
29
|
+
case 'report':
|
|
30
|
+
await this.generateReport(restArgs);
|
|
31
|
+
break;
|
|
32
|
+
case 'track':
|
|
33
|
+
await this.trackUsage(restArgs);
|
|
34
|
+
break;
|
|
35
|
+
case 'reset':
|
|
36
|
+
await this.resetTracking();
|
|
37
|
+
break;
|
|
38
|
+
case 'limit':
|
|
39
|
+
await this.setLimit(restArgs);
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
this.showHelp();
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 토큰 사용 상태 표시
|
|
49
|
+
*/
|
|
50
|
+
async showStatus() {
|
|
51
|
+
try {
|
|
52
|
+
// 토큰 추적 모듈 로드
|
|
53
|
+
const tokenTrackerModule = await this.resourceLoader.loadUtil('token-tracker.js');
|
|
54
|
+
const TokenTracker = tokenTrackerModule.TokenTracker || tokenTrackerModule.default;
|
|
55
|
+
|
|
56
|
+
if (!TokenTracker) {
|
|
57
|
+
throw new Error('TokenTracker 모듈을 로드할 수 없습니다.');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const tracker = new TokenTracker({
|
|
61
|
+
storageDir: this.tokenDataPath
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await tracker.init();
|
|
65
|
+
const stats = await tracker.getStatistics();
|
|
66
|
+
const limits = await this.getLimits();
|
|
67
|
+
|
|
68
|
+
console.log(chalk.cyan('💰 토큰 사용 현황'));
|
|
69
|
+
console.log(chalk.gray('-'.repeat(50)));
|
|
70
|
+
|
|
71
|
+
// 오늘 사용량
|
|
72
|
+
console.log(chalk.bold('오늘 사용량:'));
|
|
73
|
+
console.log(` 입력 토큰: ${chalk.yellow(stats.today.input.toLocaleString())}`);
|
|
74
|
+
console.log(` 출력 토큰: ${chalk.yellow(stats.today.output.toLocaleString())}`);
|
|
75
|
+
console.log(` 총 토큰: ${chalk.yellow(stats.today.total.toLocaleString())}`);
|
|
76
|
+
|
|
77
|
+
if (limits.daily > 0) {
|
|
78
|
+
const dailyUsagePercent = (stats.today.total / limits.daily * 100).toFixed(1);
|
|
79
|
+
const dailyColor = dailyUsagePercent > 90 ? 'red' : dailyUsagePercent > 70 ? 'yellow' : 'green';
|
|
80
|
+
console.log(` 일일 한도: ${chalk[dailyColor](`${dailyUsagePercent}% 사용`)}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 이번 주 사용량
|
|
84
|
+
console.log(chalk.bold('\n이번 주 사용량:'));
|
|
85
|
+
console.log(` 입력 토큰: ${chalk.yellow(stats.week.input.toLocaleString())}`);
|
|
86
|
+
console.log(` 출력 토큰: ${chalk.yellow(stats.week.output.toLocaleString())}`);
|
|
87
|
+
console.log(` 총 토큰: ${chalk.yellow(stats.week.total.toLocaleString())}`);
|
|
88
|
+
|
|
89
|
+
// 이번 달 사용량
|
|
90
|
+
console.log(chalk.bold('\n이번 달 사용량:'));
|
|
91
|
+
console.log(` 입력 토큰: ${chalk.yellow(stats.month.input.toLocaleString())}`);
|
|
92
|
+
console.log(` 출력 토큰: ${chalk.yellow(stats.month.output.toLocaleString())}`);
|
|
93
|
+
console.log(` 총 토큰: ${chalk.yellow(stats.month.total.toLocaleString())}`);
|
|
94
|
+
|
|
95
|
+
if (limits.monthly > 0) {
|
|
96
|
+
const monthlyUsagePercent = (stats.month.total / limits.monthly * 100).toFixed(1);
|
|
97
|
+
const monthlyColor = monthlyUsagePercent > 90 ? 'red' : monthlyUsagePercent > 70 ? 'yellow' : 'green';
|
|
98
|
+
console.log(` 월간 한도: ${chalk[monthlyColor](`${monthlyUsagePercent}% 사용`)}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 전체 통계
|
|
102
|
+
console.log(chalk.bold('\n전체 통계:'));
|
|
103
|
+
console.log(` 총 세션: ${stats.overall.sessions}`);
|
|
104
|
+
console.log(` 평균 세션당 토큰: ${Math.round(stats.overall.total / stats.overall.sessions).toLocaleString()}`);
|
|
105
|
+
console.log(` 최대 단일 세션: ${stats.overall.maxSession.toLocaleString()} 토큰`);
|
|
106
|
+
|
|
107
|
+
console.log(chalk.gray('\n' + '-'.repeat(50)));
|
|
108
|
+
console.log(chalk.gray('상세 리포트: aiwf token report'));
|
|
109
|
+
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(chalk.red('❌ 토큰 상태 조회 중 오류가 발생했습니다:'), error.message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 토큰 사용 리포트 생성
|
|
117
|
+
*/
|
|
118
|
+
async generateReport(args) {
|
|
119
|
+
const [period = 'week'] = args;
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
// 토큰 리포터 모듈 로드
|
|
123
|
+
const reporterModule = await this.resourceLoader.loadUtil('token-reporter.js');
|
|
124
|
+
const TokenReporter = reporterModule.TokenReporter || reporterModule.default;
|
|
125
|
+
|
|
126
|
+
if (!TokenReporter) {
|
|
127
|
+
throw new Error('TokenReporter 모듈을 로드할 수 없습니다.');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const reporter = new TokenReporter({
|
|
131
|
+
storageDir: this.tokenDataPath
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
console.log(chalk.cyan(`📊 토큰 사용 리포트 (${period})`));
|
|
135
|
+
console.log(chalk.gray('생성 중...'));
|
|
136
|
+
|
|
137
|
+
const report = await reporter.generateReport(period);
|
|
138
|
+
const reportPath = path.join(this.tokenDataPath, 'reports', `token-report-${period}-${Date.now()}.md`);
|
|
139
|
+
|
|
140
|
+
await fs.ensureDir(path.dirname(reportPath));
|
|
141
|
+
await fs.writeFile(reportPath, report);
|
|
142
|
+
|
|
143
|
+
console.log(chalk.green(`✅ 리포트가 생성되었습니다: ${reportPath}`));
|
|
144
|
+
|
|
145
|
+
// 리포트 요약 표시
|
|
146
|
+
console.log(chalk.cyan('\n📄 리포트 요약:'));
|
|
147
|
+
const lines = report.split('\n').slice(0, 20);
|
|
148
|
+
console.log(lines.join('\n'));
|
|
149
|
+
console.log(chalk.gray('\n... (전체 리포트는 파일을 확인하세요)'));
|
|
150
|
+
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error(chalk.red('❌ 리포트 생성 중 오류가 발생했습니다:'), error.message);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* 토큰 사용량 추적
|
|
158
|
+
*/
|
|
159
|
+
async trackUsage(args) {
|
|
160
|
+
const [inputTokens, outputTokens] = args.map(Number);
|
|
161
|
+
|
|
162
|
+
if (!inputTokens || !outputTokens) {
|
|
163
|
+
console.error(chalk.red('❌ 입력 토큰과 출력 토큰 수를 지정해주세요.'));
|
|
164
|
+
console.log(chalk.gray('사용법: aiwf token track <입력토큰> <출력토큰>'));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
const trackerModule = await this.resourceLoader.loadUtil('token-tracker.js');
|
|
170
|
+
const TokenTracker = trackerModule.TokenTracker || trackerModule.default;
|
|
171
|
+
|
|
172
|
+
const tracker = new TokenTracker({
|
|
173
|
+
storageDir: this.tokenDataPath
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
await tracker.init();
|
|
177
|
+
await tracker.trackUsage({
|
|
178
|
+
input: inputTokens,
|
|
179
|
+
output: outputTokens,
|
|
180
|
+
timestamp: new Date().toISOString(),
|
|
181
|
+
source: 'manual'
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
console.log(chalk.green('✅ 토큰 사용량이 기록되었습니다.'));
|
|
185
|
+
console.log(`입력: ${chalk.yellow(inputTokens.toLocaleString())} 토큰`);
|
|
186
|
+
console.log(`출력: ${chalk.yellow(outputTokens.toLocaleString())} 토큰`);
|
|
187
|
+
console.log(`총합: ${chalk.yellow((inputTokens + outputTokens).toLocaleString())} 토큰`);
|
|
188
|
+
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error(chalk.red('❌ 토큰 추적 중 오류가 발생했습니다:'), error.message);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 토큰 추적 초기화
|
|
196
|
+
*/
|
|
197
|
+
async resetTracking() {
|
|
198
|
+
try {
|
|
199
|
+
const confirm = await this.confirmReset();
|
|
200
|
+
if (!confirm) {
|
|
201
|
+
console.log(chalk.yellow('초기화가 취소되었습니다.'));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
await fs.remove(this.tokenDataPath);
|
|
206
|
+
console.log(chalk.green('✅ 토큰 추적 데이터가 초기화되었습니다.'));
|
|
207
|
+
|
|
208
|
+
} catch (error) {
|
|
209
|
+
console.error(chalk.red('❌ 초기화 중 오류가 발생했습니다:'), error.message);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 토큰 사용 한도 설정
|
|
215
|
+
*/
|
|
216
|
+
async setLimit(args) {
|
|
217
|
+
const [limitType, limitValue] = args;
|
|
218
|
+
|
|
219
|
+
if (!limitType || !limitValue) {
|
|
220
|
+
console.error(chalk.red('❌ 한도 유형과 값을 지정해주세요.'));
|
|
221
|
+
console.log(chalk.gray('사용법: aiwf token limit <daily|monthly> <값>'));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const validTypes = ['daily', 'monthly'];
|
|
226
|
+
if (!validTypes.includes(limitType)) {
|
|
227
|
+
console.error(chalk.red(`❌ 유효하지 않은 한도 유형: ${limitType}`));
|
|
228
|
+
console.log(chalk.gray('유효한 유형: daily, monthly'));
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const limit = parseInt(limitValue);
|
|
233
|
+
if (isNaN(limit) || limit < 0) {
|
|
234
|
+
console.error(chalk.red('❌ 한도 값은 0 이상의 숫자여야 합니다.'));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
try {
|
|
239
|
+
const configPath = path.join(this.tokenDataPath, 'limits.json');
|
|
240
|
+
await fs.ensureDir(this.tokenDataPath);
|
|
241
|
+
|
|
242
|
+
let limits = {};
|
|
243
|
+
if (fs.existsSync(configPath)) {
|
|
244
|
+
limits = await fs.readJson(configPath);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
limits[limitType] = limit;
|
|
248
|
+
await fs.writeJson(configPath, limits, { spaces: 2 });
|
|
249
|
+
|
|
250
|
+
console.log(chalk.green(`✅ ${limitType === 'daily' ? '일일' : '월간'} 한도가 ${limit.toLocaleString()} 토큰으로 설정되었습니다.`));
|
|
251
|
+
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.error(chalk.red('❌ 한도 설정 중 오류가 발생했습니다:'), error.message);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 한도 설정 가져오기
|
|
259
|
+
*/
|
|
260
|
+
async getLimits() {
|
|
261
|
+
try {
|
|
262
|
+
const configPath = path.join(this.tokenDataPath, 'limits.json');
|
|
263
|
+
if (fs.existsSync(configPath)) {
|
|
264
|
+
return await fs.readJson(configPath);
|
|
265
|
+
}
|
|
266
|
+
} catch (error) {
|
|
267
|
+
// 에러 무시
|
|
268
|
+
}
|
|
269
|
+
return { daily: 0, monthly: 0 };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 초기화 확인
|
|
274
|
+
*/
|
|
275
|
+
async confirmReset() {
|
|
276
|
+
// 간단한 확인 (실제로는 prompts 패키지 사용 권장)
|
|
277
|
+
console.log(chalk.yellow('⚠️ 모든 토큰 추적 데이터가 삭제됩니다.'));
|
|
278
|
+
console.log(chalk.gray('계속하려면 5초 내에 Ctrl+C로 취소하세요...'));
|
|
279
|
+
|
|
280
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 도움말 표시
|
|
286
|
+
*/
|
|
287
|
+
showHelp() {
|
|
288
|
+
console.log(chalk.cyan('💰 AIWF 토큰 추적'));
|
|
289
|
+
console.log(chalk.gray('-'.repeat(50)));
|
|
290
|
+
console.log('사용법: aiwf token <명령어> [옵션]');
|
|
291
|
+
console.log('');
|
|
292
|
+
console.log('명령어:');
|
|
293
|
+
console.log(' status 토큰 사용 현황 표시');
|
|
294
|
+
console.log(' report [기간] 사용 리포트 생성');
|
|
295
|
+
console.log(' track <입력> <출력> 토큰 사용량 수동 기록');
|
|
296
|
+
console.log(' limit <유형> <값> 사용 한도 설정');
|
|
297
|
+
console.log(' reset 추적 데이터 초기화');
|
|
298
|
+
console.log('');
|
|
299
|
+
console.log('리포트 기간:');
|
|
300
|
+
console.log(' day 일간 리포트');
|
|
301
|
+
console.log(' week 주간 리포트 (기본값)');
|
|
302
|
+
console.log(' month 월간 리포트');
|
|
303
|
+
console.log('');
|
|
304
|
+
console.log('예시:');
|
|
305
|
+
console.log(' aiwf token status');
|
|
306
|
+
console.log(' aiwf token report week');
|
|
307
|
+
console.log(' aiwf token track 1500 500');
|
|
308
|
+
console.log(' aiwf token limit daily 100000');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export default TokenCommand;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AIWF Resource Loader
|
|
3
|
+
* 번들된 리소스와 사용자 디렉토리 리소스를 통합 관리
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname } from 'path';
|
|
10
|
+
import { existsSync } from 'fs';
|
|
11
|
+
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = dirname(__filename);
|
|
14
|
+
|
|
15
|
+
// 리소스 기본 경로
|
|
16
|
+
const BUNDLED_RESOURCES_PATH = path.join(__dirname, 'resources');
|
|
17
|
+
const USER_RESOURCES_PATH = path.join(process.env.HOME || process.env.USERPROFILE, '.aiwf');
|
|
18
|
+
|
|
19
|
+
export class ResourceLoader {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this.bundledPath = options.bundledPath || BUNDLED_RESOURCES_PATH;
|
|
22
|
+
this.userPath = options.userPath || USER_RESOURCES_PATH;
|
|
23
|
+
this.preferUserResources = options.preferUserResources ?? true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 리소스 파일 경로 해결
|
|
28
|
+
* 사용자 디렉토리 우선, 없으면 번들된 리소스 사용
|
|
29
|
+
*/
|
|
30
|
+
async resolvePath(resourceType, resourceName) {
|
|
31
|
+
const paths = this.preferUserResources
|
|
32
|
+
? [
|
|
33
|
+
path.join(this.userPath, resourceType, resourceName),
|
|
34
|
+
path.join(this.bundledPath, resourceType, resourceName)
|
|
35
|
+
]
|
|
36
|
+
: [
|
|
37
|
+
path.join(this.bundledPath, resourceType, resourceName),
|
|
38
|
+
path.join(this.userPath, resourceType, resourceName)
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
for (const resourcePath of paths) {
|
|
42
|
+
if (existsSync(resourcePath)) {
|
|
43
|
+
return resourcePath;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
throw new Error(`Resource not found: ${resourceType}/${resourceName}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* JSON 리소스 로드
|
|
52
|
+
*/
|
|
53
|
+
async loadJSON(resourceType, resourceName) {
|
|
54
|
+
const resourcePath = await this.resolvePath(resourceType, resourceName);
|
|
55
|
+
const content = await fs.readFile(resourcePath, 'utf8');
|
|
56
|
+
return JSON.parse(content);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 텍스트 리소스 로드
|
|
61
|
+
*/
|
|
62
|
+
async loadText(resourceType, resourceName) {
|
|
63
|
+
const resourcePath = await this.resolvePath(resourceType, resourceName);
|
|
64
|
+
return await fs.readFile(resourcePath, 'utf8');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 리소스 목록 가져오기
|
|
69
|
+
*/
|
|
70
|
+
async listResources(resourceType, options = {}) {
|
|
71
|
+
const resources = new Set();
|
|
72
|
+
|
|
73
|
+
// 번들된 리소스 목록
|
|
74
|
+
const bundledDir = path.join(this.bundledPath, resourceType);
|
|
75
|
+
if (existsSync(bundledDir)) {
|
|
76
|
+
const bundledFiles = await fs.readdir(bundledDir);
|
|
77
|
+
bundledFiles.forEach(file => resources.add(file));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 사용자 리소스 목록
|
|
81
|
+
const userDir = path.join(this.userPath, resourceType);
|
|
82
|
+
if (existsSync(userDir)) {
|
|
83
|
+
const userFiles = await fs.readdir(userDir);
|
|
84
|
+
userFiles.forEach(file => resources.add(file));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 필터링
|
|
88
|
+
let fileList = Array.from(resources);
|
|
89
|
+
if (options.extension) {
|
|
90
|
+
fileList = fileList.filter(file => file.endsWith(options.extension));
|
|
91
|
+
}
|
|
92
|
+
if (options.filter) {
|
|
93
|
+
fileList = fileList.filter(options.filter);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return fileList.sort();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 페르소나 로드
|
|
101
|
+
*/
|
|
102
|
+
async loadPersona(personaName) {
|
|
103
|
+
if (!personaName.endsWith('.json')) {
|
|
104
|
+
personaName += '.json';
|
|
105
|
+
}
|
|
106
|
+
return await this.loadJSON('personas', personaName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 모든 페르소나 목록
|
|
111
|
+
*/
|
|
112
|
+
async listPersonas() {
|
|
113
|
+
const personas = await this.listResources('personas', {
|
|
114
|
+
extension: '.json',
|
|
115
|
+
filter: (file) => file !== 'persona-index.json' && file !== 'evaluation_criteria.json'
|
|
116
|
+
});
|
|
117
|
+
return personas.map(file => path.basename(file, '.json'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 템플릿 설정 로드
|
|
122
|
+
*/
|
|
123
|
+
async loadTemplateConfig(templateName) {
|
|
124
|
+
return await this.loadJSON('templates', path.join(templateName, 'config.json'));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 템플릿 목록
|
|
129
|
+
*/
|
|
130
|
+
async listTemplates() {
|
|
131
|
+
const templates = [];
|
|
132
|
+
const templateDir = path.join(this.bundledPath, 'templates');
|
|
133
|
+
|
|
134
|
+
if (existsSync(templateDir)) {
|
|
135
|
+
const entries = await fs.readdir(templateDir, { withFileTypes: true });
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
if (entry.isDirectory()) {
|
|
138
|
+
const configPath = path.join(templateDir, entry.name, 'config.json');
|
|
139
|
+
if (existsSync(configPath)) {
|
|
140
|
+
templates.push(entry.name);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return templates;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 템플릿 경로 가져오기
|
|
151
|
+
*/
|
|
152
|
+
async getTemplatePath(templateName) {
|
|
153
|
+
const templatePath = await this.resolvePath('templates', templateName);
|
|
154
|
+
const configPath = path.join(templatePath, 'config.json');
|
|
155
|
+
|
|
156
|
+
if (!existsSync(configPath)) {
|
|
157
|
+
throw new Error(`Invalid template: ${templateName}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return path.join(templatePath, 'template');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 명령어 모듈 로드
|
|
165
|
+
*/
|
|
166
|
+
async loadCommand(commandName) {
|
|
167
|
+
if (!commandName.endsWith('.js')) {
|
|
168
|
+
commandName += '.js';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const commandPath = await this.resolvePath('commands', commandName);
|
|
172
|
+
return await import(commandPath);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 유틸리티 모듈 로드
|
|
177
|
+
*/
|
|
178
|
+
async loadUtil(utilName) {
|
|
179
|
+
if (!utilName.endsWith('.js')) {
|
|
180
|
+
utilName += '.js';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const utilPath = await this.resolvePath('utils', utilName);
|
|
184
|
+
return await import(utilPath);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 사용자 리소스 디렉토리 초기화
|
|
189
|
+
*/
|
|
190
|
+
async initUserDirectory() {
|
|
191
|
+
const dirs = ['personas', 'templates', 'commands', 'utils', 'config'];
|
|
192
|
+
|
|
193
|
+
for (const dir of dirs) {
|
|
194
|
+
const dirPath = path.join(this.userPath, dir);
|
|
195
|
+
if (!existsSync(dirPath)) {
|
|
196
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 기본 설정 파일 복사
|
|
201
|
+
const configFiles = ['language.json', 'personas/current.json'];
|
|
202
|
+
for (const configFile of configFiles) {
|
|
203
|
+
const userFile = path.join(this.userPath, configFile);
|
|
204
|
+
if (!existsSync(userFile)) {
|
|
205
|
+
try {
|
|
206
|
+
const bundledFile = path.join(this.bundledPath, configFile);
|
|
207
|
+
if (existsSync(bundledFile)) {
|
|
208
|
+
await fs.copyFile(bundledFile, userFile);
|
|
209
|
+
}
|
|
210
|
+
} catch (error) {
|
|
211
|
+
// 기본 설정 파일이 없어도 계속 진행
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 리소스 존재 여부 확인
|
|
219
|
+
*/
|
|
220
|
+
async exists(resourceType, resourceName) {
|
|
221
|
+
try {
|
|
222
|
+
await this.resolvePath(resourceType, resourceName);
|
|
223
|
+
return true;
|
|
224
|
+
} catch {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 리소스 복사 (번들 -> 사용자 디렉토리)
|
|
231
|
+
*/
|
|
232
|
+
async copyToUserDirectory(resourceType, resourceName) {
|
|
233
|
+
const bundledPath = path.join(this.bundledPath, resourceType, resourceName);
|
|
234
|
+
const userPath = path.join(this.userPath, resourceType, resourceName);
|
|
235
|
+
|
|
236
|
+
if (!existsSync(bundledPath)) {
|
|
237
|
+
throw new Error(`Bundled resource not found: ${resourceType}/${resourceName}`);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
await fs.mkdir(path.dirname(userPath), { recursive: true });
|
|
241
|
+
await fs.copyFile(bundledPath, userPath);
|
|
242
|
+
|
|
243
|
+
return userPath;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// 기본 인스턴스 export
|
|
248
|
+
export const defaultLoader = new ResourceLoader();
|
|
249
|
+
|
|
250
|
+
export default ResourceLoader;
|