toolflow 3.1.4

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 (49) hide show
  1. package/.github/workflows/ci.yml +31 -0
  2. package/README.md +106 -0
  3. package/README_zh.md +109 -0
  4. package/docs/reports/ADVANCED_EVOLUTION_REPORT.md +44 -0
  5. package/docs/reports/AUDIT_AND_OPTIMIZATION_REPORT.md +645 -0
  6. package/docs/reports/COLD_START_REVIEW_EVOLUTION.md +51 -0
  7. package/docs/reports/DEEP_ECOSYSTEM_EVOLUTION.md +43 -0
  8. package/docs/reports/MEMORY.md +18 -0
  9. package/docs/reports/MICHAEL_DISPATCH_RESULT.md +36 -0
  10. package/docs/reports/OPENSOURCE_INTEGRATION_REPORT.md +43 -0
  11. package/docs/reports/PHASE_1_OPTIMIZATION_REPORT.md +87 -0
  12. package/docs/reports/PHASE_2_OPTIMIZATION_REPORT.md +50 -0
  13. package/docs/reports/PHASE_3_OPTIMIZATION_REPORT.md +24 -0
  14. package/docs/reports/PHASE_4_OPTIMIZATION_REPORT.md +28 -0
  15. package/docs/reports/REPORT_TO_MICHAEL.md +101 -0
  16. package/docs/reports/SIGNOFF_AND_RELEASE_REPORT.md +85 -0
  17. package/docs/reports/STAFF_ASSIGNMENTS.md +26 -0
  18. package/docs/reports/TASK_ASSIGNMENTS.md +59 -0
  19. package/docs/reports/V1_6_0_EVOLUTION_REPORT.md +48 -0
  20. package/docs/reports/V1_9_0_HOTFIX_REPORT.md +30 -0
  21. package/docs/reports/V2_0_0_RELEASE_REPORT.md +18 -0
  22. package/docs/reports/V2_2_0_ZERO_SPECIALIZATION_REPORT.md +24 -0
  23. package/docs/reports/V2_3_0_EVOLUTION_REPORT.md +12 -0
  24. package/ecosystem_taxonomy.json +798 -0
  25. package/package.json +46 -0
  26. package/src/blast_radius.ts +302 -0
  27. package/src/deep_ecosystem.ts +523 -0
  28. package/src/degradation_matrix.ts +180 -0
  29. package/src/dehydrator.ts +532 -0
  30. package/src/ecosystem_taxonomy.json +803 -0
  31. package/src/engine.ts +1510 -0
  32. package/src/i18n.ts +89 -0
  33. package/src/index.ts +983 -0
  34. package/src/json_extractor.ts +57 -0
  35. package/src/memory.ts +151 -0
  36. package/src/prompts_manager.ts +262 -0
  37. package/src/review_isolation.ts +188 -0
  38. package/src/state.ts +810 -0
  39. package/src/taxonomy.ts +580 -0
  40. package/src/types.ts +341 -0
  41. package/src/ui.ts +1036 -0
  42. package/src/worker_orchestrator.ts +60 -0
  43. package/tests/challenger_stress_harness.ts +265 -0
  44. package/tests/monorepo_multilang_stress.ts +404 -0
  45. package/tests/sandbox_e2e.ts +167 -0
  46. package/tests/test_json_extractor.ts +44 -0
  47. package/tests/test_modules_1_to_4.ts +106 -0
  48. package/tests/test_suite.ts +1689 -0
  49. package/tsconfig.json +17 -0
package/src/i18n.ts ADDED
@@ -0,0 +1,89 @@
1
+ // i18n helper: System locale detection and dictionary for ToolFlow
2
+ // Follows minimal, zero-overhead runtime pattern:
3
+ // Default language is English. Automatically switches to Chinese only if system locale is Chinese.
4
+
5
+ export const isZh = Intl.DateTimeFormat().resolvedOptions().locale.toLowerCase().startsWith("zh");
6
+
7
+ export const t = {
8
+ // Common notifications
9
+ analyzingTask: (task: string) =>
10
+ isZh ? `正在分析「${task}」工程结构与阶段计划...` : `Analyzing "${task}" and generating stage plan...`,
11
+ cancelled: isZh ? "已取消任务执行。" : "Task execution cancelled.",
12
+ noDecision: isZh ? "未选择方案,已退出。" : "No option selected. Exited.",
13
+ resetSuccess: isZh
14
+ ? "[OK] 已清除当前项目的工作状态与缓存记录。"
15
+ : "[OK] Cleared active task state and caches.",
16
+ exportNoBlueprint: isZh
17
+ ? "当前没有正在执行的计划可供导出。可运行 /toolflow <任务>。"
18
+ : "No active plan to export. Run `/toolflow <task>` first.",
19
+ exportSuccess: (path: string) =>
20
+ isZh ? `[OK] 计划已保存至: ${path}` : `[OK] Plan exported to: ${path}`,
21
+ exportFailed: (msg: string) =>
22
+ isZh ? `导出失败: ${msg}` : `Export failed: ${msg}`,
23
+ statusNoBlueprint: isZh
24
+ ? "当前无进行中的任务,可运行 /toolflow <任务> 启动。"
25
+ : "No active task. Run `/toolflow <task>` to start.",
26
+ prefillNotice: (cmd: string) =>
27
+ isZh ? `已将模板 ${cmd} 填入输入框` : `Template "${cmd}" loaded into input.`,
28
+ stageVerified: (stageIdx: number, file: string, sha: string) =>
29
+ isZh
30
+ ? `[阶段 ${stageIdx} 完成] 已生成 ${file} (SHA: ${sha}...)`
31
+ : `[Stage ${stageIdx} Done] Created ${file} (SHA: ${sha}...)`,
32
+ allCompleted: (task: string) =>
33
+ isZh
34
+ ? `⌬ 任务「${task}」全部阶段执行完毕,产物校验通过。`
35
+ : `⌬ Task "${task}" completed! All files verified.`,
36
+ circuitBroken: (stageIdx: number, file: string) =>
37
+ isZh
38
+ ? `[暂停] 阶段 ${stageIdx} 连续 3 次未检测到产物,请检查 ${file} 或运行 /toolflow rollback。`
39
+ : `[Paused] Stage ${stageIdx} stopped after 3 attempts without target file. Check ${file} or run /toolflow rollback.`,
40
+
41
+ // Command descriptions
42
+ cmdMainDesc: isZh
43
+ ? "任务阶段规划与 Prompt 模板工作台 (/toolflow <任务>, 支持 rollback/reset/export)"
44
+ : "Task staging runner & prompt template workbench (/toolflow <task>)",
45
+ cmdRollbackArgDesc: isZh ? "撤销当前阶段修改并回退快照" : "Rollback code changes to stage snapshot",
46
+ cmdResetArgDesc: isZh ? "清除当前任务状态与临时缓存" : "Reset and clear active workflow state",
47
+ cmdStatusArgDesc: isZh ? "查看当前阶段流水线看板" : "View current stage pipeline status",
48
+ cmdExportArgDesc: isZh ? "导出阶段计划为 Markdown" : "Export active stage plan to Markdown",
49
+ cmdRollbackShortcutDesc: isZh ? "撤销当前阶段修改并回退快照 (快捷方式)" : "Rollback changes and restore stage snapshot (shortcut)",
50
+ cmdSopDesc: isZh ? "查看当前阶段执行状态 (/toolflow status 别名)" : "View current stage execution status (/toolflow status alias)",
51
+
52
+ // TUI Labels & Help
53
+ workbenchTitle: isZh ? "PROMPT 模板库" : "PROMPT WORKBENCH",
54
+ workbenchSub: isZh
55
+ ? "[Enter] 输入任务拆解阶段 [p] 填入选中模板 [c] 新建模板"
56
+ : "[Enter] Input task [p] Load template [c] New template",
57
+ decisionTitle: isZh ? "任务方案选择" : "OPTIONS",
58
+ navHelp: isZh
59
+ ? "[←/→] 切换 [1-4] 选择 [e] 补充要求 [a] 直接开始 [Esc] 取消"
60
+ : "[←/→] Toggle [1-4] Select [e] Notes [a] Quick run [Esc] Cancel",
61
+ resumedStage: (stage: number | string, title: string) =>
62
+ isZh ? `恢复进度: 阶段 ${stage} (${title})` : `Resumed: Stage ${stage} (${title})`,
63
+ cleaningOldTask: isZh
64
+ ? "清理旧任务,准备初始化新任务..."
65
+ : "Resetting state for new task...",
66
+ prefilledPrompt: (cmd: string) =>
67
+ isZh ? `已填入模板: ${cmd}` : `Template loaded: ${cmd}`,
68
+ contextDehydrated: isZh
69
+ ? "⚡ 会话上下文已精简压缩"
70
+ : "⚡ Session context compacted.",
71
+ toolOutputDehydrated: (tool: string, lines: number, tokens: number) =>
72
+ isZh
73
+ ? `⚡ [ToolFlow] 已归档 ${tool} 冗长输出 (${lines} 行),节约 ~${tokens} Tokens`
74
+ : `⚡ [ToolFlow] Archived ${tool} verbose output (${lines} lines), saved ~${tokens} tokens`,
75
+ readCacheHitNotice: (file: string, tokens: number) =>
76
+ isZh
77
+ ? `⚡ [ToolFlow 读缓存] 文件 ${file} 内容未变动,命中缓存节约 ~${tokens} Tokens`
78
+ : `⚡ [ToolFlow Read Cache] ${file} unchanged, hit cache saved ~${tokens} tokens`,
79
+ compactNotice: (tokensSaved?: number) => {
80
+ if (tokensSaved) {
81
+ return isZh
82
+ ? `⚡ [ToolFlow] 阶段历史已脱水封存,已释放 ~${tokensSaved} Tokens`
83
+ : `⚡ [ToolFlow] Stage history compacted, ~${tokensSaved} tokens released`;
84
+ }
85
+ return isZh
86
+ ? "⚡ [ToolFlow] 阶段历史已脱水封存"
87
+ : "⚡ [ToolFlow] Stage history compacted";
88
+ },
89
+ };