maestro-flow 0.5.46 → 0.5.47

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 (237) hide show
  1. package/.agents/skills/domain-add/SKILL.md +9 -0
  2. package/.agents/skills/learn-decompose/SKILL.md +12 -0
  3. package/.agents/skills/learn-follow/SKILL.md +41 -0
  4. package/.agents/skills/learn-investigate/SKILL.md +14 -0
  5. package/.agents/skills/learn-second-opinion/SKILL.md +14 -0
  6. package/.agents/skills/maestro-amend/SKILL.md +11 -0
  7. package/.agents/skills/maestro-companion/SKILL.md +11 -0
  8. package/.agents/skills/maestro-composer/SKILL.md +11 -0
  9. package/.agents/skills/maestro-guard/SKILL.md +25 -0
  10. package/.agents/skills/maestro-init/SKILL.md +28 -0
  11. package/.agents/skills/maestro-overlay/SKILL.md +11 -0
  12. package/.agents/skills/maestro-player/SKILL.md +11 -0
  13. package/.agents/skills/maestro-quick/SKILL.md +29 -0
  14. package/.agents/skills/maestro-swarm-workflow/SKILL.md +25 -0
  15. package/.agents/skills/maestro-tools-execute/SKILL.md +29 -0
  16. package/.agents/skills/maestro-tools-register/SKILL.md +29 -0
  17. package/.agents/skills/maestro-ui-codify/SKILL.md +11 -0
  18. package/.agents/skills/maestro-universal-workflow/SKILL.md +59 -0
  19. package/.agents/skills/maestro-update/SKILL.md +38 -0
  20. package/.agents/skills/manage-codebase-rebuild/SKILL.md +29 -0
  21. package/.agents/skills/manage-drift-realign/SKILL.md +12 -0
  22. package/.agents/skills/manage-harvest/SKILL.md +30 -6
  23. package/.agents/skills/manage-issue/SKILL.md +23 -0
  24. package/.agents/skills/manage-issue-discover/SKILL.md +28 -0
  25. package/.agents/skills/manage-kg-extractors/SKILL.md +27 -1
  26. package/.agents/skills/manage-knowhow/SKILL.md +26 -0
  27. package/.agents/skills/manage-knowhow-capture/SKILL.md +24 -0
  28. package/.agents/skills/manage-knowledge-audit/SKILL.md +13 -0
  29. package/.agents/skills/manage-status/SKILL.md +22 -0
  30. package/.agents/skills/manage-wiki/SKILL.md +28 -0
  31. package/.agents/skills/odyssey-improve/SKILL.md +50 -0
  32. package/.agents/skills/odyssey-planex/SKILL.md +46 -0
  33. package/.agents/skills/odyssey-review-test-fix/SKILL.md +50 -0
  34. package/.agents/skills/odyssey-ui/SKILL.md +50 -0
  35. package/.agents/skills/quality-auto-test/SKILL.md +12 -0
  36. package/.agents/skills/quality-debug/SKILL.md +11 -0
  37. package/.agents/skills/quality-refactor/SKILL.md +11 -0
  38. package/.agents/skills/quality-retrospective/SKILL.md +11 -0
  39. package/.agents/skills/quality-review/SKILL.md +11 -0
  40. package/.agents/skills/quality-sync/SKILL.md +10 -0
  41. package/.agents/skills/quality-test/SKILL.md +12 -0
  42. package/.agents/skills/security-audit/SKILL.md +11 -0
  43. package/.agents/skills/spec-add/SKILL.md +27 -0
  44. package/.agents/skills/spec-load/SKILL.md +25 -0
  45. package/.agents/skills/spec-remove/SKILL.md +26 -0
  46. package/.agents/skills/spec-setup/SKILL.md +30 -0
  47. package/.agy/skills/domain-add/SKILL.md +9 -0
  48. package/.agy/skills/learn-decompose/SKILL.md +12 -0
  49. package/.agy/skills/learn-follow/SKILL.md +41 -0
  50. package/.agy/skills/learn-investigate/SKILL.md +14 -0
  51. package/.agy/skills/learn-second-opinion/SKILL.md +14 -0
  52. package/.agy/skills/maestro-amend/SKILL.md +11 -0
  53. package/.agy/skills/maestro-companion/SKILL.md +11 -0
  54. package/.agy/skills/maestro-composer/SKILL.md +11 -0
  55. package/.agy/skills/maestro-guard/SKILL.md +25 -0
  56. package/.agy/skills/maestro-init/SKILL.md +28 -0
  57. package/.agy/skills/maestro-overlay/SKILL.md +11 -0
  58. package/.agy/skills/maestro-player/SKILL.md +11 -0
  59. package/.agy/skills/maestro-quick/SKILL.md +29 -0
  60. package/.agy/skills/maestro-swarm-workflow/SKILL.md +25 -0
  61. package/.agy/skills/maestro-tools-execute/SKILL.md +29 -0
  62. package/.agy/skills/maestro-tools-register/SKILL.md +29 -0
  63. package/.agy/skills/maestro-ui-codify/SKILL.md +11 -0
  64. package/.agy/skills/maestro-universal-workflow/SKILL.md +59 -0
  65. package/.agy/skills/maestro-update/SKILL.md +38 -0
  66. package/.agy/skills/manage-codebase-rebuild/SKILL.md +29 -0
  67. package/.agy/skills/manage-drift-realign/SKILL.md +12 -0
  68. package/.agy/skills/manage-harvest/SKILL.md +30 -6
  69. package/.agy/skills/manage-issue/SKILL.md +23 -0
  70. package/.agy/skills/manage-issue-discover/SKILL.md +28 -0
  71. package/.agy/skills/manage-kg-extractors/SKILL.md +27 -1
  72. package/.agy/skills/manage-knowhow/SKILL.md +26 -0
  73. package/.agy/skills/manage-knowhow-capture/SKILL.md +24 -0
  74. package/.agy/skills/manage-knowledge-audit/SKILL.md +13 -0
  75. package/.agy/skills/manage-status/SKILL.md +22 -0
  76. package/.agy/skills/manage-wiki/SKILL.md +28 -0
  77. package/.agy/skills/odyssey-improve/SKILL.md +50 -0
  78. package/.agy/skills/odyssey-planex/SKILL.md +46 -0
  79. package/.agy/skills/odyssey-review-test-fix/SKILL.md +50 -0
  80. package/.agy/skills/odyssey-ui/SKILL.md +50 -0
  81. package/.agy/skills/quality-auto-test/SKILL.md +12 -0
  82. package/.agy/skills/quality-debug/SKILL.md +11 -0
  83. package/.agy/skills/quality-refactor/SKILL.md +11 -0
  84. package/.agy/skills/quality-retrospective/SKILL.md +11 -0
  85. package/.agy/skills/quality-review/SKILL.md +11 -0
  86. package/.agy/skills/quality-sync/SKILL.md +10 -0
  87. package/.agy/skills/quality-test/SKILL.md +12 -0
  88. package/.agy/skills/security-audit/SKILL.md +11 -0
  89. package/.agy/skills/spec-add/SKILL.md +27 -0
  90. package/.agy/skills/spec-load/SKILL.md +25 -0
  91. package/.agy/skills/spec-remove/SKILL.md +26 -0
  92. package/.agy/skills/spec-setup/SKILL.md +30 -0
  93. package/.claude/commands/domain-add.md +9 -0
  94. package/.claude/commands/learn-decompose.md +12 -0
  95. package/.claude/commands/learn-follow.md +41 -0
  96. package/.claude/commands/learn-investigate.md +14 -0
  97. package/.claude/commands/learn-second-opinion.md +14 -0
  98. package/.claude/commands/maestro-amend.md +11 -0
  99. package/.claude/commands/maestro-companion.md +11 -0
  100. package/.claude/commands/maestro-composer.md +11 -0
  101. package/.claude/commands/maestro-guard.md +25 -0
  102. package/.claude/commands/maestro-init.md +28 -0
  103. package/.claude/commands/maestro-overlay.md +11 -0
  104. package/.claude/commands/maestro-player.md +11 -0
  105. package/.claude/commands/maestro-quick.md +29 -0
  106. package/.claude/commands/maestro-swarm-workflow.md +25 -0
  107. package/.claude/commands/maestro-tools-execute.md +29 -0
  108. package/.claude/commands/maestro-tools-register.md +29 -0
  109. package/.claude/commands/maestro-ui-codify.md +11 -0
  110. package/.claude/commands/maestro-universal-workflow.md +59 -0
  111. package/.claude/commands/maestro-update.md +38 -0
  112. package/.claude/commands/manage-codebase-rebuild.md +29 -0
  113. package/.claude/commands/manage-drift-realign.md +12 -0
  114. package/.claude/commands/manage-harvest.md +30 -6
  115. package/.claude/commands/manage-issue-discover.md +28 -0
  116. package/.claude/commands/manage-issue.md +23 -0
  117. package/.claude/commands/manage-kg-extractors.md +27 -1
  118. package/.claude/commands/manage-knowhow-capture.md +24 -0
  119. package/.claude/commands/manage-knowhow.md +26 -0
  120. package/.claude/commands/manage-knowledge-audit.md +13 -0
  121. package/.claude/commands/manage-status.md +22 -0
  122. package/.claude/commands/manage-wiki.md +28 -0
  123. package/.claude/commands/odyssey-improve.md +50 -0
  124. package/.claude/commands/odyssey-planex.md +46 -0
  125. package/.claude/commands/odyssey-review-test-fix.md +50 -0
  126. package/.claude/commands/odyssey-ui.md +50 -0
  127. package/.claude/commands/quality-auto-test.md +12 -0
  128. package/.claude/commands/quality-debug.md +11 -0
  129. package/.claude/commands/quality-refactor.md +11 -0
  130. package/.claude/commands/quality-retrospective.md +11 -0
  131. package/.claude/commands/quality-review.md +11 -0
  132. package/.claude/commands/quality-sync.md +10 -0
  133. package/.claude/commands/quality-test.md +12 -0
  134. package/.claude/commands/security-audit.md +11 -0
  135. package/.claude/commands/spec-add.md +27 -0
  136. package/.claude/commands/spec-load.md +25 -0
  137. package/.claude/commands/spec-remove.md +26 -0
  138. package/.claude/commands/spec-setup.md +30 -0
  139. package/.codex/skills/codify-to-knowhow/SKILL.md +2 -0
  140. package/.codex/skills/domain-add/SKILL.md +26 -0
  141. package/.codex/skills/domain-discover/SKILL.md +46 -0
  142. package/.codex/skills/domain-list/SKILL.md +29 -0
  143. package/.codex/skills/learn-decompose/SKILL.md +2 -0
  144. package/.codex/skills/learn-follow/SKILL.md +34 -0
  145. package/.codex/skills/learn-investigate/SKILL.md +33 -0
  146. package/.codex/skills/learn-retro/SKILL.md +33 -0
  147. package/.codex/skills/learn-second-opinion/SKILL.md +30 -0
  148. package/.codex/skills/maestro-amend/SKILL.md +11 -0
  149. package/.codex/skills/maestro-companion/SKILL.md +11 -0
  150. package/.codex/skills/maestro-composer/SKILL.md +11 -0
  151. package/.codex/skills/maestro-guard/SKILL.md +25 -0
  152. package/.codex/skills/maestro-help/SKILL.md +2 -0
  153. package/.codex/skills/maestro-init/SKILL.md +16 -0
  154. package/.codex/skills/maestro-learn/SKILL.md +2 -0
  155. package/.codex/skills/maestro-overlay/SKILL.md +1 -0
  156. package/.codex/skills/maestro-player/SKILL.md +2 -0
  157. package/.codex/skills/maestro-quick/SKILL.md +17 -0
  158. package/.codex/skills/maestro-tools-execute/SKILL.md +31 -0
  159. package/.codex/skills/maestro-tools-register/SKILL.md +29 -0
  160. package/.codex/skills/maestro-ui-codify/SKILL.md +2 -0
  161. package/.codex/skills/maestro-update/SKILL.md +38 -0
  162. package/.codex/skills/manage-codebase-rebuild/SKILL.md +2 -0
  163. package/.codex/skills/manage-codebase-refresh/SKILL.md +11 -0
  164. package/.codex/skills/manage-drift-realign/SKILL.md +2 -0
  165. package/.codex/skills/manage-harvest/SKILL.md +30 -8
  166. package/.codex/skills/manage-issue/SKILL.md +24 -0
  167. package/.codex/skills/manage-issue-discover/SKILL.md +2 -0
  168. package/.codex/skills/manage-knowhow/SKILL.md +26 -0
  169. package/.codex/skills/manage-knowhow-capture/SKILL.md +23 -0
  170. package/.codex/skills/manage-learn/SKILL.md +2 -0
  171. package/.codex/skills/manage-status/SKILL.md +22 -0
  172. package/.codex/skills/manage-wiki/SKILL.md +28 -0
  173. package/.codex/skills/odyssey-debug/SKILL.md +44 -0
  174. package/.codex/skills/odyssey-improve/SKILL.md +49 -0
  175. package/.codex/skills/odyssey-planex/SKILL.md +44 -0
  176. package/.codex/skills/odyssey-review-test-fix/SKILL.md +48 -0
  177. package/.codex/skills/odyssey-ui/SKILL.md +49 -0
  178. package/.codex/skills/quality-auto-test/SKILL.md +2 -0
  179. package/.codex/skills/quality-debug/SKILL.md +2 -0
  180. package/.codex/skills/quality-refactor/SKILL.md +2 -0
  181. package/.codex/skills/quality-retrospective/SKILL.md +2 -0
  182. package/.codex/skills/quality-review/SKILL.md +2 -0
  183. package/.codex/skills/quality-sync/SKILL.md +24 -0
  184. package/.codex/skills/quality-test/SKILL.md +2 -0
  185. package/.codex/skills/security-audit/SKILL.md +30 -0
  186. package/.codex/skills/spec-add/SKILL.md +28 -0
  187. package/.codex/skills/spec-load/SKILL.md +26 -0
  188. package/.codex/skills/spec-map/SKILL.md +1 -0
  189. package/.codex/skills/spec-remove/SKILL.md +28 -0
  190. package/.codex/skills/spec-setup/SKILL.md +28 -0
  191. package/.codex/skills/wiki-connect/SKILL.md +11 -0
  192. package/.codex/skills/wiki-digest/SKILL.md +11 -0
  193. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js +3 -1
  194. package/dashboard/dist-server/dashboard/src/server/agents/api-explore-adapter.js.map +1 -1
  195. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.d.ts +5 -0
  196. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +25 -1
  197. package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
  198. package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +4 -0
  199. package/dashboard/dist-server/src/graph/kg/db/queries.js +35 -19
  200. package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
  201. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +19 -11
  202. package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
  203. package/dist/src/agents/api-explore/config.d.ts +11 -1
  204. package/dist/src/agents/api-explore/config.d.ts.map +1 -1
  205. package/dist/src/agents/api-explore/config.js +17 -16
  206. package/dist/src/agents/api-explore/config.js.map +1 -1
  207. package/dist/src/agents/api-explore/index.js +4 -4
  208. package/dist/src/agents/api-explore/index.js.map +1 -1
  209. package/dist/src/agents/api-explore/llm.d.ts +2 -0
  210. package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
  211. package/dist/src/agents/api-explore/llm.js +16 -4
  212. package/dist/src/agents/api-explore/llm.js.map +1 -1
  213. package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
  214. package/dist/src/agents/api-explore/runner.js +16 -12
  215. package/dist/src/agents/api-explore/runner.js.map +1 -1
  216. package/dist/src/commands/explore.d.ts.map +1 -1
  217. package/dist/src/commands/explore.js +19 -2
  218. package/dist/src/commands/explore.js.map +1 -1
  219. package/dist/src/commands/install.js +7 -28
  220. package/dist/src/commands/install.js.map +1 -1
  221. package/dist/src/commands/moa.d.ts.map +1 -1
  222. package/dist/src/commands/moa.js +17 -2
  223. package/dist/src/commands/moa.js.map +1 -1
  224. package/dist/src/commands/search.d.ts.map +1 -1
  225. package/dist/src/commands/search.js +2 -0
  226. package/dist/src/commands/search.js.map +1 -1
  227. package/dist/src/graph/kg/db/queries.d.ts +4 -0
  228. package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
  229. package/dist/src/graph/kg/db/queries.js +35 -19
  230. package/dist/src/graph/kg/db/queries.js.map +1 -1
  231. package/dist/src/graph/kg/extraction/orchestrator.d.ts.map +1 -1
  232. package/dist/src/graph/kg/extraction/orchestrator.js +19 -11
  233. package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
  234. package/dist/src/hooks/plugins/explore-plugin.d.ts.map +1 -1
  235. package/dist/src/hooks/plugins/explore-plugin.js +3 -2
  236. package/dist/src/hooks/plugins/explore-plugin.js.map +1 -1
  237. package/package.json +1 -1
@@ -40,6 +40,8 @@ $ARGUMENTS
40
40
  **Session**: `.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`
41
41
  **Output**: `session.json` | `evidence.ndjson` | `understanding.md`
42
42
 
43
+ **Output boundary**: ALL session artifacts MUST target the session directory (`.workflow/scratch/{YYYYMMDD}-ui-odyssey-{slug}/`) or `.workflow/state.json` only. Source code modifications during S_FIX are in-scope but MUST be committed per action. NEVER write session artifacts outside these paths.
44
+
43
45
  **session.json -- ui-specific fields:**
44
46
  ```json
45
47
  { "target": "", "dimensions": [], "audit_result": null, "diverge_result": null,
@@ -117,6 +119,53 @@ id,title,description,task_type,dimension,deps,wave,status,findings,evidence,erro
117
119
  Applies to: **S_SURVEY, S_AUDIT, S_DIVERGE, S_GENERALIZE**. Logic in base.
118
120
  </self_iteration>
119
121
 
122
+ <execution>
123
+ Follow base execution discipline completely. Actions defined in state_machine below.
124
+
125
+ ### Phase Gates (MANDATORY, BLOCKING)
126
+
127
+ **GATE 1: INTAKE → SURVEY**
128
+ - REQUIRED: Target resolved, SESSION_DIR created, session.json initialized.
129
+ - REQUIRED: phase_goals[] derived from flags, understanding.md §1 written.
130
+ - BLOCKED if: no target specified (E001) or target path not found (E002).
131
+
132
+ **GATE 2: SURVEY → AUDIT**
133
+ - REQUIRED: Design system inventory + current state analysis completed.
134
+ - REQUIRED: Evidence phase=survey logged, understanding.md §2 updated, G1 marked done.
135
+ - BLOCKED if: survey incomplete — token scan and styling analysis must both be attempted.
136
+
137
+ **GATE 3: AUDIT → DIVERGE**
138
+ - REQUIRED: All 6 dimension agents completed (or --dimensions subset), findings merged with severity classification.
139
+ - REQUIRED: audit_result written to session.json, understanding.md §3 with severity matrix, G2 marked done.
140
+ - BLOCKED if: zero dimensions reviewed (W002 partial is allowed, zero is not).
141
+
142
+ **GATE 4: DIVERGE → FIX**
143
+ - REQUIRED: Both parallel agents (Polish + Delight) completed, ideas consolidated with audit findings.
144
+ - REQUIRED: diverge_result written, understanding.md §4 updated, G3 marked done.
145
+ - BLOCKED if: divergent exploration not attempted.
146
+
147
+ **GATE 5: FIX → VERIFY**
148
+ - REQUIRED: ALL findings/ideas within fix_threshold fixed by priority tier.
149
+ - REQUIRED: Per-fix evidence phase=fix logged.
150
+ - BLOCKED if: tier incomplete — each tier must be fully addressed before advancing.
151
+
152
+ **GATE 6: VERIFY → GENERALIZE**
153
+ - REQUIRED: Tests pass (lint, unit, visual regression), delegate verification completed.
154
+ - REQUIRED: confirmation written, understanding.md §5 updated, G4 marked done.
155
+ - BLOCKED if: needs_rework → route back to S_FIX.
156
+
157
+ **GATE 7: GENERALIZE → DISCOVER**
158
+ - REQUIRED: ALL 3 layers (syntax/semantic/structural) attempted with evidence logged.
159
+ - REQUIRED: generalization_stats written with by_layer entries for all 3 layers, G5 marked done.
160
+ - BLOCKED if: any layer not attempted (thoroughness floor violation).
161
+
162
+ **GATE 8: DISCOVER → RECORD**
163
+ - REQUIRED: All hits triaged with per-item classification and reason.
164
+ - REQUIRED: remaining_actionable == 0 OR loops >= max_loops with per-item reasons logged, G6 marked done.
165
+ - BLOCKED if: unclassified hits remain.
166
+
167
+ </execution>
168
+
120
169
  <state_machine>
121
170
 
122
171
  <states>
@@ -36,6 +36,8 @@ $ARGUMENTS -- phase number and optional flags.
36
36
 
37
37
  **Session**: `.tests/auto-test/.csv-session/`
38
38
  **Output**: scenarios.csv, results.csv, discoveries.ndjson, report.json, state.json, reflection-log.md
39
+
40
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-auto-test-P{N}-{slug}/` or `.workflow/state.json` only. Source code modifications are limited to test files generated by this command. NEVER modify existing production source code.
39
41
  </context>
40
42
 
41
43
  <csv_schema>
@@ -84,6 +84,8 @@ When `--yes` or `-y`: Auto-confirm hypothesis selection, skip interactive sympto
84
84
 
85
85
  **Output Directory**: `.workflow/.csv-wave/{session-id}/`
86
86
  **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `understanding.md` (human-readable report)
87
+
88
+ **Output boundary**: ALL file writes MUST target `DEBUG_DIR` or `.workflow/state.json` only. NEVER modify source code, test files, or other artifacts outside these paths during investigation.
87
89
  </context>
88
90
 
89
91
  <csv_schema>
@@ -32,6 +32,8 @@ $quality-refactor "--dir .workflow/scratch/refactor-auth-2026-03-18" # resume e
32
32
  **Output**: `.workflow/scratch/refactor-{slug}-{date}/` with index.json, plan.json, reflection-log.md, .task/, .summaries/
33
33
 
34
34
  **Session**: `.workflow/.csv-wave/{YYYYMMDD}-refactor-{slug}/`
35
+
36
+ **Output boundary**: Refactoring modifies source files within the declared scope only. Ancillary outputs (reflection-log.md) MUST target `.workflow/scratch/{YYYYMMDD}-refactor-{slug}/`. NEVER modify files outside the confirmed scope without re-confirmation.
35
37
  </context>
36
38
 
37
39
  <csv_schema>
@@ -95,6 +95,8 @@ Each artifact's type determines its outputs at `.workflow/{a.path}/`:
95
95
  - **test** → uat.md, .tests/ (UAT results, gaps, coverage)
96
96
  - Also reads: `.workflow/issues/issues.jsonl`, `.workflow/state.json`
97
97
 
98
+ **Output boundary**: ALL file writes MUST target the phase's retrospective directory (`.workflow/scratch/{YYYYMMDD}-retrospective-P{N}/`), `.workflow/state.json`, `.workflow/issues.jsonl`, or `.workflow/specs/` (append-only). NEVER modify source code, verification.json, review.json, plan.json, or other existing artifacts.
99
+
98
100
  ### Agent Registry
99
101
 
100
102
  | Agent | task_name | fork_turns | Responsibility |
@@ -74,6 +74,8 @@ When `--yes` or `-y`: Auto-confirm dimension selection, skip interactive validat
74
74
 
75
75
  **Output Directory**: `.workflow/.csv-wave/{session-id}/`
76
76
  **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `review.json` (structured review output)
77
+
78
+ **Output boundary**: ALL file writes MUST target `.workflow/.csv-wave/{session-id}/`, `.workflow/state.json`, or `.workflow/issues/issues.jsonl` only. NEVER modify source code or files outside these paths. Review produces reports only — no source modifications.
77
79
  </context>
78
80
 
79
81
  <csv_schema>
@@ -24,10 +24,34 @@ $quality-sync "--since abc123 --dry-run"
24
24
  - `--since <commit|HEAD~N>` -- Diff since specific commit (default: last sync timestamp)
25
25
  - `--dry-run` -- Show what would be updated without writing
26
26
 
27
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/`, `.workflow/state.json`, or `doc-index.json` only. NEVER modify source code or files outside `.workflow/`. `--dry-run` MUST suppress all writes.
27
28
  </context>
28
29
 
30
+ <invariants>
31
+ 1. **Source code is read-only** — sync reads source files to generate documentation. NEVER modify source code, test files, or any non-documentation files.
32
+ 2. **Dry-run is side-effect-free** — when `--dry-run` is set, NO file writes occur. Report only what would change.
33
+ 3. **Impact trace before refresh** — NEVER regenerate a doc file without first tracing which source changes affect it via doc-index.json. Untargeted full-refresh requires explicit `--full` flag.
34
+ 4. **Idempotent sync** — running sync twice with the same diff MUST produce identical results. State.json timestamp prevents redundant re-runs.
35
+ 5. **Incremental by default** — without `--full`, only changed components are refreshed. NEVER silently expand to a full rebuild.
36
+ </invariants>
37
+
29
38
  <execution>
30
39
 
40
+ ### Phase Gates (MANDATORY, BLOCKING)
41
+
42
+ **GATE 1: Diff → Impact Trace**
43
+ - REQUIRED: Git diff computed (or --full flag set for all files).
44
+ - BLOCKED if no diff and no --full: nothing to sync (W001).
45
+
46
+ **GATE 2: Impact Trace → Refresh**
47
+ - REQUIRED: Affected components traced via doc-index.json.
48
+ - BLOCKED if trace fails: cannot refresh docs without impact mapping.
49
+
50
+ **GATE 3: Refresh → Completion**
51
+ - REQUIRED: `.workflow/codebase/` docs refreshed for affected components.
52
+ - REQUIRED: If `--dry-run` is set, skip state.json write and report what would change. Otherwise, update state.json with sync timestamp.
53
+ - BLOCKED if missing: do not report completion without updated docs.
54
+
31
55
  ### Step 1: Validate
32
56
 
33
57
  Verify `.workflow/` directory exists — if missing, raise E001.
@@ -27,6 +27,8 @@ $ARGUMENTS -- phase number and optional flags.
27
27
  - `{target_dir}/.tests/test-results.json` -- pass/fail results
28
28
  - `{target_dir}/.tests/coverage-report.json` -- requirement coverage
29
29
  - `.tests/.csv-session/diagnosis.csv` + `diagnosis-results.csv`
30
+
31
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-test-P{N}-{slug}/`, `.workflow/state.json`, or `.workflow/issues.jsonl` only. NEVER modify source code or execution artifacts outside these paths.
30
32
  </context>
31
33
 
32
34
  <csv_schema>
@@ -25,10 +25,40 @@ $ARGUMENTS -- Parse tier and scope:
25
25
  | quick | Y | Y | -- | -- | -- | -- |
26
26
  | standard | Y | Y | Y | Y | -- | -- |
27
27
  | deep | Y | Y | Y | Y | Y | Y |
28
+
29
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-security-audit-{tier}-{slug}/` or `.workflow/state.json` only. NEVER modify source code, configuration files, or dependencies. Audit is read-only analysis.
28
30
  </context>
29
31
 
32
+ <invariants>
33
+ 1. **Audit is read-only** — NEVER modify source code, configuration, dependencies, or CI/CD files during audit. Security audit produces reports only.
34
+ 2. **Findings require file:line evidence** — every finding MUST reference a specific file:line location and include the vulnerable code pattern. No vague or category-only findings.
35
+ 3. **Severity NEVER downgraded without justification** — if a finding matches a known OWASP category, its severity follows OWASP guidance. Downgrading requires documented rationale (e.g., compensating control exists).
36
+ 4. **Tier coverage is mandatory** — all scan phases required by the selected tier MUST complete. NEVER skip a tier-required phase silently; failures are logged as W00x warnings.
37
+ 5. **False positive marking requires evidence** — marking a finding as false positive MUST include the compensating control or code path that prevents exploitation. NEVER dismiss findings without counter-evidence.
38
+ 6. **Secrets are never logged** — if secrets are discovered, report their location (file:line) and type but NEVER include the actual secret value in the report output.
39
+ </invariants>
40
+
30
41
  <execution>
31
42
 
43
+ ### Phase Gates (MANDATORY, BLOCKING)
44
+
45
+ **GATE 1: Recon → Scan**
46
+ - REQUIRED: Tech stack detected and entry points identified.
47
+ - REQUIRED: Auth/authz modules listed and data flow mapped.
48
+ - BLOCKED if missing: cannot scan without entry points and data flow baseline.
49
+
50
+ **GATE 2: Scan → Report** (tier-gated)
51
+ - REQUIRED: OWASP Top 10 scan completed (all tiers).
52
+ - REQUIRED: Dependency audit completed (all tiers).
53
+ - REQUIRED: Secrets + CI/CD scan completed (standard/deep only).
54
+ - REQUIRED: STRIDE + git history completed (deep only).
55
+ - BLOCKED if tier-required scans incomplete: finish all tier-applicable phases before reporting.
56
+
57
+ **GATE 3: Report → Completion**
58
+ - REQUIRED: Severity matrix produced with file:line references and remediation.
59
+ - REQUIRED: Artifact registered in state.json.
60
+ - BLOCKED if missing: do not emit completion status without severity matrix.
61
+
32
62
  **Phase 1: Reconnaissance**
33
63
 
34
64
  1. Detect tech stack from package.json / go.mod / requirements.txt / Cargo.toml
@@ -45,10 +45,38 @@ $ARGUMENTS — `<category> <title> <content>` where category selects the target
45
45
  Extended types (`bug`, `pattern`, `decision`, `rule`, `validation`) are stored in the file of their closest core category but retain their specific category in the `<spec-entry>` tag.
46
46
 
47
47
  Category is determined by the first positional argument.
48
+
49
+ **Output boundary**: ALL file writes MUST target `.workflow/specs/` only. NEVER modify source code or files outside this path.
48
50
  </context>
49
51
 
52
+ <invariants>
53
+ 1. **Idempotent append** — duplicate entry ID MUST be rejected (E003-level check on title + category match before write)
54
+ 2. **Category validation** — category MUST be one of: coding, arch, quality, debug, test, review, learning, tools, bug, pattern, decision, rule, validation. Invalid category → E003
55
+ 3. **Confirmation gate** — MUST request_user_input before appending entry; NEVER write without user confirmation in interactive mode
56
+ 4. **Entry format invariance** — all entries MUST use `<spec-entry>` closed-tag format with id, keywords, and category attributes
57
+ 5. **Append-only** — MUST append to target file; NEVER overwrite or truncate existing spec content
58
+ 6. **Output boundary** — ALL file writes MUST target `.workflow/specs/` only. NEVER modify source code or files outside this path
59
+ </invariants>
60
+
50
61
  <execution>
51
62
 
63
+ ### Phase Gates (MANDATORY, BLOCKING)
64
+
65
+ **GATE 1: Parse → Validate**
66
+ - REQUIRED: Category and content both parsed from arguments.
67
+ - REQUIRED: Category is a valid value.
68
+ - BLOCKED if: E001 (missing args), E003 (invalid category).
69
+
70
+ **GATE 2: Validate → Format**
71
+ - REQUIRED: `.workflow/specs/` directory exists.
72
+ - REQUIRED: No duplicate entry with identical title + category already present in target file.
73
+ - BLOCKED if: E002 (specs not initialized).
74
+
75
+ **GATE 3: Format → Write**
76
+ - REQUIRED: `<spec-entry>` block formatted with id, keywords, category attributes.
77
+ - REQUIRED: User confirmation via request_user_input.
78
+ - BLOCKED if: user declines confirmation — abort without writing.
79
+
52
80
  ### Step 1: Parse Input
53
81
 
54
82
  Extract category (first token), title (second token or quoted string), and content (remainder) from arguments.
@@ -36,10 +36,36 @@ $spec-load "--category review"
36
36
  **--category loading**: Loads category's primary doc in full + matching entries from other files.
37
37
 
38
38
  **Keyword filtering**: When `--keyword` is provided, only entries with matching keyword in their `<spec-entry keywords="...">` attribute are returned.
39
+
40
+ **Output boundary**: This command produces NO file writes. All output is conversation-context injection only.
39
41
  </context>
40
42
 
43
+ <invariants>
44
+ 1. **Read-only** — NEVER modify, create, or delete any spec files during load. This command is purely a read operation
45
+ 2. **Output to context only** — loaded specs are injected into the conversation context; NEVER write loaded content to new files or modify existing files
46
+ 3. **Category primary doc** — when --category is specified, the primary category doc MUST be loaded in full before cross-file matching
47
+ 4. **Entry-level filtering** — --keyword filtering operates at `<spec-entry>` level via keywords attribute, NOT at file level; unmatched entries in a matching file are excluded
48
+ 5. **Graceful degradation** — if `.workflow/specs/` is missing but CLI search is available, fallback to CLI; only fail when both paths are exhausted
49
+ 6. **Output boundary** — this command produces NO file writes. All output is conversation-context injection only
50
+ </invariants>
51
+
41
52
  <execution>
42
53
 
54
+ ### Phase Gates (MANDATORY, BLOCKING)
55
+
56
+ **GATE 1: Parse → Discover**
57
+ - REQUIRED: Arguments parsed — at least one of --category or --keyword provided, or empty args triggers full load.
58
+ - BLOCKED if: invalid category value.
59
+
60
+ **GATE 2: Discover → Load**
61
+ - REQUIRED: At least one spec directory exists.
62
+ - BLOCKED if: E001 — `.workflow/specs/` not initialized and no CLI fallback available.
63
+
64
+ **GATE 3: Load → Display**
65
+ - REQUIRED: Spec files read and entries parsed.
66
+ - REQUIRED: Keyword filtering applied if --keyword was provided.
67
+ - BLOCKED if: no readable spec files found.
68
+
43
69
  ### Step 1: Validate Specs Directory
44
70
 
45
71
  Verify `.workflow/specs/` exists (E001).
@@ -53,6 +53,7 @@ $spec-map --continue "20260318-map-auth"
53
53
 
54
54
  **Output**: `.workflow/codebase/` (tech-stack.md, architecture.md, features.md, concerns.md)
55
55
 
56
+ **Output boundary**: ALL file writes MUST target `.workflow/codebase/` (output docs) and `.workflow/.csv-wave/{sessionId}/` (session state). NEVER modify source code or files outside these paths.
56
57
  </context>
57
58
 
58
59
  <csv_schema>
@@ -27,10 +27,38 @@ $ARGUMENTS — entry ID to remove (e.g., `spec-learnings-003`)
27
27
  **Flags:**
28
28
  - `--cascade` — When the target spec has a `ref` attribute linking to a knowhow document, also delete the referenced knowhow file. Without this flag, removal leaves an orphan knowhow file. Cascade checks the entry's `ref` attribute in the `<spec-entry>` tag.
29
29
  - `-y` — Skip confirmation prompt and proceed with removal immediately.
30
+
31
+ **Output boundary**: File modifications MUST target ONLY the spec container file (.workflow/specs/*.md) and optionally the referenced knowhow file (.workflow/knowhow/*) when --cascade is used. NEVER modify source code or files outside these paths.
30
32
  </context>
31
33
 
34
+ <invariants>
35
+ 1. **Confirmation required** — MUST request_user_input before deletion (unless -y flag); NEVER remove entries silently
36
+ 2. **Referential integrity** — before removing, check if other spec entries reference the target entry; warn user if references exist
37
+ 3. **Cascade explicit** — ref-type entries MUST NOT cascade-delete the linked knowhow file unless --cascade is explicitly passed; default leaves orphan knowhow intact
38
+ 4. **Atomic removal** — use `maestro wiki remove-entry` for atomic operation; NEVER manually edit spec files to remove entries
39
+ 5. **Index consistency** — wiki index MUST be auto-updated after removal; stale index entries are a hard failure
40
+ 6. **Output boundary** — file modifications MUST target ONLY the spec container file (.workflow/specs/*.md) and optionally the referenced knowhow file (.workflow/knowhow/*) when --cascade is used. NEVER modify source code or files outside these paths
41
+ </invariants>
42
+
32
43
  <execution>
33
44
 
45
+ ### Phase Gates (MANDATORY, BLOCKING)
46
+
47
+ **GATE 1: Parse → Lookup**
48
+ - REQUIRED: Entry ID parsed from arguments.
49
+ - BLOCKED if: E001 — no entry ID provided.
50
+
51
+ **GATE 2: Lookup → Confirm**
52
+ - REQUIRED: `.workflow/specs/` directory exists.
53
+ - REQUIRED: Entry found in wiki index as a spec sub-node.
54
+ - REQUIRED: Entry content loaded for user preview.
55
+ - BLOCKED if: E002 (specs not initialized), E003 (entry not found), E004 (wrong type).
56
+
57
+ **GATE 3: Confirm → Remove**
58
+ - REQUIRED: User confirmed removal via request_user_input (unless -y flag).
59
+ - REQUIRED: If --cascade and entry has ref attribute, user additionally confirmed knowhow file deletion.
60
+ - BLOCKED if: user declines — abort without modification.
61
+
34
62
  ### Step 1: Parse Input
35
63
 
36
64
  Extract entry ID from arguments.
@@ -16,10 +16,38 @@ $spec-setup
16
16
 
17
17
  <context>
18
18
  No arguments. Scans the codebase and generates spec files in `.workflow/specs/`.
19
+
20
+ **Output boundary**: ALL file writes MUST target `.workflow/specs/` (spec files) and `.workflow/knowhow/` (recipe knowhow) only. NEVER modify source code, `.workflow/state.json`, or files outside these paths.
19
21
  </context>
20
22
 
23
+ <invariants>
24
+ 1. **Non-destructive** — NEVER overwrite existing spec files; if a file already exists, skip it and report as already-initialized
25
+ 2. **Idempotent** — safe to re-run on an initialized project; re-running MUST NOT duplicate entries or corrupt existing content
26
+ 3. **Core files mandatory** — coding-conventions.md, architecture-constraints.md, and learnings.md MUST always be created (unless they already exist)
27
+ 4. **Signal-driven optionals** — optional spec files (quality-rules.md, test-conventions.md) MUST only be created when corresponding framework/tool signals are detected in the codebase; NEVER create optional files without evidence
28
+ 5. **Output boundary** — ALL file writes MUST target `.workflow/specs/` and `.workflow/knowhow/` only. NEVER modify source code or files outside these paths
29
+ 6. **Confirmation gate** — MUST present all files to be created before writing; NEVER write without user awareness
30
+ </invariants>
31
+
21
32
  <execution>
22
33
 
34
+ ### Phase Gates (MANDATORY, BLOCKING)
35
+
36
+ **GATE 1: Precondition → Scan**
37
+ - REQUIRED: `.workflow/` directory exists.
38
+ - REQUIRED: Project contains source files to scan.
39
+ - BLOCKED if: E001 (`.workflow/` not initialized), E002 (no source files).
40
+
41
+ **GATE 2: Scan → Generate**
42
+ - REQUIRED: Codebase scan completed — framework, language, and tooling signals collected.
43
+ - REQUIRED: Core spec file list determined (always 3: coding-conventions, architecture-constraints, learnings).
44
+ - REQUIRED: Optional spec files determined by detected signals only.
45
+
46
+ **GATE 3: Generate → Report**
47
+ - REQUIRED: All planned files written to `.workflow/specs/`.
48
+ - REQUIRED: Existing files skipped (not overwritten).
49
+ - BLOCKED if: filesystem write errors.
50
+
23
51
  ### Step 1: Validate Preconditions
24
52
 
25
53
  Verify `.workflow/` exists (E001) and project contains source files (E002).
@@ -21,8 +21,19 @@ $ARGUMENTS — optional flags.
21
21
  - `--max N` — Max suggestions (default: 20)
22
22
 
23
23
  **Output**: `.workflow/knowhow/KNW-wiki-connections-{date}.md`
24
+
25
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` (connection report) and `.workflow/specs/learnings.md` (graph insights). Wiki entry `related` field updates via `maestro wiki update` only. NEVER modify source code or files outside these paths.
24
26
  </context>
25
27
 
28
+ <invariants>
29
+ 1. **Read-only analysis** — wiki entries are analyzed but NEVER modified during Stages 1-4; only Stage 5 (--fix) updates entries via CLI
30
+ 2. **Fix requires confirmation** — MUST request_user_input before applying link changes; NEVER auto-apply without user consent (unless both --fix and -y)
31
+ 3. **Bidirectional links** — when adding A→B, MUST also add B→A; unidirectional links are the problem this command solves
32
+ 4. **Scoring threshold** — candidates below --min-similarity MUST be filtered out; NEVER present sub-threshold suggestions
33
+ 5. **Append-only insights** — graph insights appended to specs/learnings.md; NEVER overwrite existing entries
34
+ 6. **Output boundary** — file writes limited to `.workflow/knowhow/` and `.workflow/specs/learnings.md`. Wiki updates via `maestro wiki update` CLI only
35
+ </invariants>
36
+
26
37
  <execution>
27
38
 
28
39
  ### Stage 1: Load Wiki State
@@ -27,8 +27,19 @@ $ARGUMENTS — scope and optional flags.
27
27
  - `--create-issues` — Auto-create knowledge-gap issues in issues.jsonl
28
28
 
29
29
  **Output**: `.workflow/knowhow/digest-{slug}-{date}.md`
30
+
31
+ **Output boundary**: ALL file writes MUST target `.workflow/knowhow/` (digest document) and `.workflow/specs/learnings.md` (meta-insights). Issue creation targets `.workflow/issues/issues.jsonl` only when --create-issues is set. NEVER modify source code or wiki entries.
30
32
  </context>
31
33
 
34
+ <invariants>
35
+ 1. **Read-only analysis** — wiki entries and source code are read but NEVER modified; this is a synthesis command
36
+ 2. **Issue dedup** — when --create-issues is set, MUST dedup against existing issues.jsonl before creating; NEVER create duplicate knowledge-gap issues
37
+ 3. **Confirmation for issues** — MUST request_user_input before creating issues; NEVER auto-create issues without user consent (unless both --create-issues and -y)
38
+ 4. **Theme minimum** — MUST cluster into 3-5 themes; fewer than 3 entries triggers W001 warning, not an error
39
+ 5. **Append-only insights** — meta-insights appended to specs/learnings.md; NEVER overwrite existing entries
40
+ 6. **Output boundary** — file writes limited to `.workflow/knowhow/` (digest), `.workflow/specs/learnings.md` (insights), and `.workflow/issues/issues.jsonl` (gap issues). NEVER modify source code or wiki entries
41
+ </invariants>
42
+
32
43
  <execution>
33
44
 
34
45
  ### Stage 1: Scope & Load
@@ -6,8 +6,10 @@
6
6
  // is inherited from StreamJsonAdapter. We only override argument building
7
7
  // and environment mapping.
8
8
  // ---------------------------------------------------------------------------
9
- import { join } from 'node:path';
9
+ import { join, dirname } from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
10
11
  import { StreamJsonAdapter } from './stream-json-adapter.js';
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
13
  function resolveAgentScript() {
12
14
  const distRoot = join(__dirname, '..', '..', '..', '..', 'dist', 'src', 'agents', 'api-explore', 'index.js');
13
15
  return `node "${distRoot}"`;
@@ -1 +1 @@
1
- {"version":3,"file":"api-explore-adapter.js","sourceRoot":"","sources":["../../../../../src/server/agents/api-explore-adapter.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8DAA8D;AAC9D,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,2BAA2B;AAC3B,8EAA8E;AAE9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC7G,OAAO,SAAS,QAAQ,GAAG,CAAC;AAC9B,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACtD;QACE,KAAK,CAAC,kBAAkB,EAAE,EAAE,aAA0B,CAAC,CAAC;IAC1D,CAAC;IAEkB,SAAS,CAAC,MAAmB;QAC9C,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"file":"api-explore-adapter.js","sourceRoot":"","sources":["../../../../../src/server/agents/api-explore-adapter.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8DAA8D;AAC9D,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,2BAA2B;AAC3B,8EAA8E;AAE9E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;IAC7G,OAAO,SAAS,QAAQ,GAAG,CAAC;AAC9B,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IACtD;QACE,KAAK,CAAC,kBAAkB,EAAE,EAAE,aAA0B,CAAC,CAAC;IAC1D,CAAC;IAEkB,SAAS,CAAC,MAAmB;QAC9C,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -77,6 +77,11 @@ export interface HardwareInfo {
77
77
  export declare function getHardwareInfo(): Promise<HardwareInfo>;
78
78
  export declare function getModelId(): string;
79
79
  export declare const DEFAULT_MODEL_ID = "Xenova/multilingual-e5-small";
80
+ /**
81
+ * Check if the local ONNX model is already downloaded in the HuggingFace cache.
82
+ * Returns true for API mode (no local model needed).
83
+ */
84
+ export declare function isModelCached(): boolean;
80
85
  export type ModelProgressCallback = (info: {
81
86
  status: string;
82
87
  file?: string;
@@ -10,7 +10,7 @@
10
10
  import { join } from 'node:path';
11
11
  import { homedir } from 'node:os';
12
12
  import { createHash } from 'node:crypto';
13
- import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync, renameSync } from 'node:fs';
13
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync, renameSync, readdirSync } from 'node:fs';
14
14
  let _zvecModule;
15
15
  async function getZvec() {
16
16
  if (_zvecModule !== undefined)
@@ -330,6 +330,30 @@ export function getModelId() {
330
330
  return apiConf ? apiConf.model : DEFAULT_LOCAL_MODEL;
331
331
  }
332
332
  export const DEFAULT_MODEL_ID = DEFAULT_LOCAL_MODEL;
333
+ /**
334
+ * Check if the local ONNX model is already downloaded in the HuggingFace cache.
335
+ * Returns true for API mode (no local model needed).
336
+ */
337
+ export function isModelCached() {
338
+ if (isApiMode())
339
+ return true;
340
+ const cacheKey = DEFAULT_LOCAL_MODEL.replace('/', '--');
341
+ const hfHome = process.env.HF_HOME || join(homedir(), '.cache', 'huggingface');
342
+ for (const base of [hfHome, join(hfHome, 'hub')]) {
343
+ const snapshotsDir = join(base, `models--${cacheKey}`, 'snapshots');
344
+ if (!existsSync(snapshotsDir))
345
+ continue;
346
+ try {
347
+ const snapshots = readdirSync(snapshotsDir);
348
+ for (const snap of snapshots) {
349
+ if (existsSync(join(snapshotsDir, snap, 'onnx', 'model.onnx')))
350
+ return true;
351
+ }
352
+ }
353
+ catch { /* ignore */ }
354
+ }
355
+ return false;
356
+ }
333
357
  const CACHE_FILE = 'embedding-index.json';
334
358
  let _pipeline = null;
335
359
  let _available = null;