headlesscode 1.0.2

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 (232) hide show
  1. package/ATTRIBUTION.md +53 -0
  2. package/CODE_OF_CONDUCT.md +130 -0
  3. package/CONTRIBUTING.md +107 -0
  4. package/LICENSE +202 -0
  5. package/README.md +486 -0
  6. package/SECURITY.md +211 -0
  7. package/bin/headlesscode.mjs +83 -0
  8. package/package.json +63 -0
  9. package/shared/prompts/review-mode-prompt-short.md +93 -0
  10. package/shared/prompts/review-mode-prompt.md +281 -0
  11. package/shared/rules-code/rules.md +22 -0
  12. package/shared/stacks/cpp/rules.md +30 -0
  13. package/shared/stacks/fastapi/rules.md +30 -0
  14. package/shared/stacks/javascript/rules.md +37 -0
  15. package/shared/stacks/postgresql/rules.md +31 -0
  16. package/shared/stacks/python/rules.md +35 -0
  17. package/shared/stacks/react/rules.md +11 -0
  18. package/shared/stacks/typescript/rules.md +10 -0
  19. package/src/budget/budget.ts +221 -0
  20. package/src/budget/concurrency.ts +126 -0
  21. package/src/budget/cost.ts +309 -0
  22. package/src/budget/index.ts +8 -0
  23. package/src/checkpoints/cli.ts +256 -0
  24. package/src/checkpoints/service.ts +227 -0
  25. package/src/cli.ts +1535 -0
  26. package/src/cloud/docker-provider.ts +334 -0
  27. package/src/cloud/provider.ts +300 -0
  28. package/src/codeintel/call-graph.ts +78 -0
  29. package/src/codeintel/find-references.ts +123 -0
  30. package/src/codeintel/go-to-definition.ts +193 -0
  31. package/src/codeintel/handlers.ts +190 -0
  32. package/src/codeintel/import-graph.ts +173 -0
  33. package/src/codeintel/outline.ts +180 -0
  34. package/src/codeintel/position.ts +77 -0
  35. package/src/codeintel/program.ts +350 -0
  36. package/src/codeintel/rename-symbol.ts +213 -0
  37. package/src/codeintel/tools.ts +280 -0
  38. package/src/codemap/build.ts +135 -0
  39. package/src/codemap/cli.ts +190 -0
  40. package/src/codemap/extract.ts +339 -0
  41. package/src/codemap/files.ts +236 -0
  42. package/src/codemap/fingerprint.ts +65 -0
  43. package/src/codemap/flows.ts +62 -0
  44. package/src/codemap/html.ts +451 -0
  45. package/src/codemap/lock.ts +80 -0
  46. package/src/codemap/types.ts +101 -0
  47. package/src/codesearch/airunner-embedder.ts +185 -0
  48. package/src/codesearch/chunk.ts +339 -0
  49. package/src/codesearch/cli.ts +223 -0
  50. package/src/codesearch/embedder.ts +332 -0
  51. package/src/codesearch/files.ts +280 -0
  52. package/src/codesearch/index.ts +469 -0
  53. package/src/codesearch/ollama-embedder.ts +205 -0
  54. package/src/codesearch/search.ts +141 -0
  55. package/src/codesearch/types.ts +100 -0
  56. package/src/config/mode-models.ts +218 -0
  57. package/src/dashboard/aggregate.ts +364 -0
  58. package/src/dashboard/chat-thread.ts +141 -0
  59. package/src/dashboard/checkpoints.ts +124 -0
  60. package/src/dashboard/cli.ts +193 -0
  61. package/src/dashboard/codemap.ts +44 -0
  62. package/src/dashboard/files.ts +121 -0
  63. package/src/dashboard/page.ts +2803 -0
  64. package/src/dashboard/self-improvement-metrics.ts +282 -0
  65. package/src/dashboard/server.ts +1103 -0
  66. package/src/dashboard/session-launch.ts +310 -0
  67. package/src/dashboard/timeline.ts +273 -0
  68. package/src/dashboard/tool-exec.ts +107 -0
  69. package/src/dashboard/trend-cli.ts +141 -0
  70. package/src/dashboard/trend.ts +413 -0
  71. package/src/decision-proxy/cli.ts +261 -0
  72. package/src/decision-proxy/proxy.ts +569 -0
  73. package/src/deploy/gate-cli.ts +147 -0
  74. package/src/deploy/gate.ts +254 -0
  75. package/src/engine/condense.ts +512 -0
  76. package/src/engine/events.ts +428 -0
  77. package/src/engine/handoff.ts +71 -0
  78. package/src/engine/lazy-tools.ts +160 -0
  79. package/src/engine/local-explore.ts +653 -0
  80. package/src/engine/logger.ts +96 -0
  81. package/src/engine/loop.ts +5517 -0
  82. package/src/engine/parser.ts +347 -0
  83. package/src/engine/prompt.ts +860 -0
  84. package/src/engine/reports.ts +47 -0
  85. package/src/engine/stacks.ts +448 -0
  86. package/src/engine/types.ts +291 -0
  87. package/src/engine/usage.ts +186 -0
  88. package/src/github/app-auth.ts +161 -0
  89. package/src/github/cli.ts +448 -0
  90. package/src/github/installations.ts +133 -0
  91. package/src/github/pr.ts +321 -0
  92. package/src/github/provision.ts +118 -0
  93. package/src/github/push.ts +122 -0
  94. package/src/index-util.ts +50 -0
  95. package/src/index.ts +81 -0
  96. package/src/init/cli.ts +248 -0
  97. package/src/init/gitignore.ts +74 -0
  98. package/src/llm/ollama.ts +308 -0
  99. package/src/llm/openrouter.ts +868 -0
  100. package/src/llm/preflight.ts +367 -0
  101. package/src/llm/transcript-capture.ts +84 -0
  102. package/src/memory/embed.ts +110 -0
  103. package/src/memory/index.ts +22 -0
  104. package/src/memory/local.ts +259 -0
  105. package/src/memory/summarizer.ts +283 -0
  106. package/src/memory/types.ts +153 -0
  107. package/src/memory/uwuchat.ts +157 -0
  108. package/src/migrate/cli.ts +115 -0
  109. package/src/orchestrator/analyze-cli.ts +104 -0
  110. package/src/orchestrator/auto-split.ts +206 -0
  111. package/src/orchestrator/cleanup.ts +1003 -0
  112. package/src/orchestrator/cli.ts +3571 -0
  113. package/src/orchestrator/cost-estimate.ts +564 -0
  114. package/src/orchestrator/cost-history-cli.ts +242 -0
  115. package/src/orchestrator/cost-history.ts +397 -0
  116. package/src/orchestrator/git-sync.ts +250 -0
  117. package/src/orchestrator/index.ts +153 -0
  118. package/src/orchestrator/log-analysis.ts +0 -0
  119. package/src/orchestrator/merge-check.ts +108 -0
  120. package/src/orchestrator/pipeline.ts +411 -0
  121. package/src/orchestrator/resume.ts +1940 -0
  122. package/src/orchestrator/reviewer.ts +503 -0
  123. package/src/orchestrator/split.ts +296 -0
  124. package/src/orchestrator/state.ts +542 -0
  125. package/src/orchestrator/status.ts +697 -0
  126. package/src/orchestrator/verification-gate.ts +134 -0
  127. package/src/orchestrator/watch.ts +898 -0
  128. package/src/permissions/commands.ts +1083 -0
  129. package/src/permissions/config.ts +241 -0
  130. package/src/permissions/index.ts +12 -0
  131. package/src/permissions/protected-files.ts +96 -0
  132. package/src/permissions/store-protection.ts +272 -0
  133. package/src/project-store.ts +648 -0
  134. package/src/projects/cli.ts +382 -0
  135. package/src/qa/qa.ts +487 -0
  136. package/src/tools/browser/handler.ts +346 -0
  137. package/src/tools/browser/service.ts +406 -0
  138. package/src/tools/browser/smoke.ts +78 -0
  139. package/src/tools/browser/tool.ts +99 -0
  140. package/src/tools/executor.ts +2575 -0
  141. package/src/tools/language-detect.ts +183 -0
  142. package/src/tools/output-summarizer.ts +369 -0
  143. package/src/tools/run-tests.ts +302 -0
  144. package/src/tools/set-indentation-tool.ts +49 -0
  145. package/src/tools/test-selection.ts +160 -0
  146. package/src/vendor/tests/smoke.ts +103 -0
  147. package/src/vendor/zoo-code/VENDOR-NOTES.md +213 -0
  148. package/src/vendor/zoo-code/shim/anthropic.ts +71 -0
  149. package/src/vendor/zoo-code/shim/openai.d.ts +60 -0
  150. package/src/vendor/zoo-code/shim/os-name.ts +18 -0
  151. package/src/vendor/zoo-code/shim/strip-bom.ts +14 -0
  152. package/src/vendor/zoo-code/shim/vscode.ts +76 -0
  153. package/src/vendor/zoo-code/src/core/config/CustomModesManager.ts +1015 -0
  154. package/src/vendor/zoo-code/src/core/diff/strategies/multi-search-replace.ts +670 -0
  155. package/src/vendor/zoo-code/src/core/prompts/sections/capabilities.ts +46 -0
  156. package/src/vendor/zoo-code/src/core/prompts/sections/custom-instructions.ts +559 -0
  157. package/src/vendor/zoo-code/src/core/prompts/sections/index.ts +10 -0
  158. package/src/vendor/zoo-code/src/core/prompts/sections/markdown-formatting.ts +7 -0
  159. package/src/vendor/zoo-code/src/core/prompts/sections/modes.ts +35 -0
  160. package/src/vendor/zoo-code/src/core/prompts/sections/objective.ts +13 -0
  161. package/src/vendor/zoo-code/src/core/prompts/sections/rules.ts +95 -0
  162. package/src/vendor/zoo-code/src/core/prompts/sections/skills.ts +105 -0
  163. package/src/vendor/zoo-code/src/core/prompts/sections/system-info.ts +30 -0
  164. package/src/vendor/zoo-code/src/core/prompts/sections/tool-use-guidelines.ts +9 -0
  165. package/src/vendor/zoo-code/src/core/prompts/sections/tool-use.ts +7 -0
  166. package/src/vendor/zoo-code/src/core/prompts/system.ts +176 -0
  167. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/access_mcp_resource.ts +41 -0
  168. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/apply_diff.ts +40 -0
  169. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/apply_patch.ts +61 -0
  170. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/ask_followup_question.ts +62 -0
  171. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/attempt_completion.ts +33 -0
  172. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/codebase_search.ts +43 -0
  173. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/converters.ts +109 -0
  174. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/edit.ts +48 -0
  175. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/edit_file.ts +72 -0
  176. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/execute_command.ts +54 -0
  177. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/generate_image.ts +51 -0
  178. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/index.ts +75 -0
  179. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/list_files.ts +41 -0
  180. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/mcp_server.ts +75 -0
  181. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/new_task.ts +39 -0
  182. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/read_command_output.ts +81 -0
  183. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/read_file.ts +169 -0
  184. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/run_slash_command.ts +31 -0
  185. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/search_files.ts +50 -0
  186. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/search_replace.ts +51 -0
  187. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/skill.ts +33 -0
  188. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/switch_mode.ts +31 -0
  189. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/update_todo_list.ts +54 -0
  190. package/src/vendor/zoo-code/src/core/prompts/tools/native-tools/write_to_file.ts +40 -0
  191. package/src/vendor/zoo-code/src/core/prompts/types.ts +12 -0
  192. package/src/vendor/zoo-code/src/i18n/index.ts +19 -0
  193. package/src/vendor/zoo-code/src/integrations/misc/extract-text.ts +81 -0
  194. package/src/vendor/zoo-code/src/services/checkpoints/RepoPerTaskCheckpointService.ts +15 -0
  195. package/src/vendor/zoo-code/src/services/checkpoints/ShadowCheckpointService.ts +553 -0
  196. package/src/vendor/zoo-code/src/services/checkpoints/excludes.ts +212 -0
  197. package/src/vendor/zoo-code/src/services/checkpoints/index.ts +3 -0
  198. package/src/vendor/zoo-code/src/services/checkpoints/types.ts +35 -0
  199. package/src/vendor/zoo-code/src/services/code-index/manager.ts +19 -0
  200. package/src/vendor/zoo-code/src/services/mcp/McpHub.ts +36 -0
  201. package/src/vendor/zoo-code/src/services/roo-config/index.ts +441 -0
  202. package/src/vendor/zoo-code/src/services/search/file-search.ts +143 -0
  203. package/src/vendor/zoo-code/src/services/skills/SkillsManager.ts +20 -0
  204. package/src/vendor/zoo-code/src/shared/globalFileNames.ts +9 -0
  205. package/src/vendor/zoo-code/src/shared/language.ts +43 -0
  206. package/src/vendor/zoo-code/src/shared/modes.ts +257 -0
  207. package/src/vendor/zoo-code/src/shared/tools.ts +385 -0
  208. package/src/vendor/zoo-code/src/utils/fs.ts +39 -0
  209. package/src/vendor/zoo-code/src/utils/globalContext.ts +22 -0
  210. package/src/vendor/zoo-code/src/utils/json-schema.ts +16 -0
  211. package/src/vendor/zoo-code/src/utils/logging.ts +21 -0
  212. package/src/vendor/zoo-code/src/utils/mcp-name.ts +190 -0
  213. package/src/vendor/zoo-code/src/utils/object.ts +18 -0
  214. package/src/vendor/zoo-code/src/utils/path.ts +94 -0
  215. package/src/vendor/zoo-code/src/utils/shell.ts +376 -0
  216. package/src/vendor/zoo-code/src/utils/text-normalization.ts +99 -0
  217. package/src/vendor/zoo-code/types/global-settings.ts +19 -0
  218. package/src/vendor/zoo-code/types/index.ts +22 -0
  219. package/src/vendor/zoo-code/types/message.ts +375 -0
  220. package/src/vendor/zoo-code/types/mode.ts +241 -0
  221. package/src/vendor/zoo-code/types/todo.ts +19 -0
  222. package/src/vendor/zoo-code/types/tool-params.ts +116 -0
  223. package/src/vendor/zoo-code/types/tool.ts +67 -0
  224. package/src/vendor/zoo-code/types/vscode.ts +84 -0
  225. package/src/vision/describe.ts +242 -0
  226. package/src/vision/tool.ts +91 -0
  227. package/src/watcher/cli.ts +369 -0
  228. package/src/watcher/github.ts +304 -0
  229. package/src/watcher/index.ts +59 -0
  230. package/src/watcher/state.ts +254 -0
  231. package/src/watcher/watch.ts +562 -0
  232. package/tsconfig.json +18 -0
@@ -0,0 +1,213 @@
1
+ # VENDOR-NOTES — vendored Zoo Code portable core
2
+
3
+ This directory contains a verbatim vendored copy of the portable (VS Code-free)
4
+ core of **Zoo Code** (`Zoo-Code-Org/Zoo-Code`, a Roo Code fork), Apache-2.0,
5
+ Copyright 2026 Zoo Code.
6
+
7
+ - Upstream clone: `~/Projects/zoo-code` (also at `./zoo-code` inside
8
+ this workspace while vendoring is in progress).
9
+ - Inspected commit: `ca9b60fbc7b72a27352b0e2084271c28f2419f94`.
10
+ - License: `LICENSE` at repo root is the verbatim Apache 2.0 text from
11
+ upstream. `ATTRIBUTION.md` at repo root covers attribution. The upstream
12
+ files do not carry per-file license headers (verified while copying), so the
13
+ repo-root LICENSE + ATTRIBUTION is the only header bookkeeping required.
14
+
15
+ **Vendoring rule applied:** files under `src/` and `types/` are copied verbatim
16
+ (`cp`), byte-for-byte, with their original relative structure so their internal
17
+ relative imports resolve unchanged. Where the original imports something that
18
+ does not exist in a headless Node process (`vscode`, `openai` SDK types,
19
+ `@anthropic-ai/sdk`, `os-name`, `strip-bom`) or a GUI-only service, we do one
20
+ of:
21
+
22
+ 1. **Path-map the bare specifier to a local shim** via `tsconfig.json` →
23
+ `compilerOptions.paths` (keeps copied files 100% unmodified), or
24
+ 2. **Place a local replacement file at the same relative path** the original
25
+ import expected (also keeps copied files unmodified).
26
+
27
+ Every shim is listed below. Nothing under `src/` or `types/` was hand-edited.
28
+
29
+ ---
30
+
31
+ ## 1. Files vendored verbatim (with original source paths)
32
+
33
+ ### System prompt builder + sections — `zoo-code/src/core/prompts/`
34
+ | Vendored file | Original path |
35
+ |---|---|
36
+ | `src/core/prompts/system.ts` | `zoo-code/src/core/prompts/system.ts` |
37
+ | `src/core/prompts/types.ts` | `zoo-code/src/core/prompts/types.ts` (SystemPromptSettings) |
38
+ | `src/core/prompts/sections/index.ts` | `zoo-code/src/core/prompts/sections/index.ts` |
39
+ | `src/core/prompts/sections/tool-use.ts` | `zoo-code/src/core/prompts/sections/tool-use.ts` |
40
+ | `src/core/prompts/sections/tool-use-guidelines.ts` | `zoo-code/src/core/prompts/sections/tool-use-guidelines.ts` |
41
+ | `src/core/prompts/sections/capabilities.ts` | `zoo-code/src/core/prompts/sections/capabilities.ts` |
42
+ | `src/core/prompts/sections/rules.ts` | `zoo-code/src/core/prompts/sections/rules.ts` |
43
+ | `src/core/prompts/sections/system-info.ts` | `zoo-code/src/core/prompts/sections/system-info.ts` |
44
+ | `src/core/prompts/sections/objective.ts` | `zoo-code/src/core/prompts/sections/objective.ts` |
45
+ | `src/core/prompts/sections/modes.ts` | `zoo-code/src/core/prompts/sections/modes.ts` (1 `vscode.*` ref, satisfied by shim) |
46
+ | `src/core/prompts/sections/markdown-formatting.ts` | `zoo-code/src/core/prompts/sections/markdown-formatting.ts` |
47
+ | `src/core/prompts/sections/custom-instructions.ts` | `zoo-code/src/core/prompts/sections/custom-instructions.ts` (rules splicing: `.roo/rules-<slug>/`, `.roo/rules/`, `AGENTS.md`, legacy `.roorules`/`.clinerules`, cache-file filtering) |
48
+ | `src/core/prompts/sections/skills.ts` | `zoo-code/src/core/prompts/sections/skills.ts` |
49
+
50
+ ### Native tool schemas + converters — `zoo-code/src/core/prompts/tools/native-tools/`
51
+ All 21 tool schema files + the index + converters + MCP-server schema builder
52
+ (top-level `*.ts`; the `__tests__/` subdirectories were **not** vendored):
53
+
54
+ `access_mcp_resource.ts`, `apply_diff.ts`, `apply_patch.ts`,
55
+ `ask_followup_question.ts`, `attempt_completion.ts`, `codebase_search.ts`,
56
+ `converters.ts`, `edit.ts`, `edit_file.ts`, `execute_command.ts`,
57
+ `generate_image.ts`, `index.ts` (`getNativeTools()`), `list_files.ts`,
58
+ `mcp_server.ts`, `new_task.ts`, `read_command_output.ts`, `read_file.ts`,
59
+ `run_slash_command.ts`, `search_files.ts`, `search_replace.ts`, `skill.ts`,
60
+ `switch_mode.ts`, `update_todo_list.ts`, `write_to_file.ts`
61
+
62
+ → all copied from `zoo-code/src/core/prompts/tools/native-tools/*.ts`.
63
+
64
+ ### Mode config / rules loading / shared logic
65
+ | Vendored file | Original path |
66
+ |---|---|
67
+ | `src/core/config/CustomModesManager.ts` | `zoo-code/src/core/config/CustomModesManager.ts` (`.roomodes` YAML/JSON parsing, invisible-char cleaning, zod validation, project/global merge) |
68
+ | `src/services/roo-config/index.ts` | `zoo-code/src/services/roo-config/index.ts` (`.roo` directory discovery order) |
69
+ | `src/shared/modes.ts` | `zoo-code/src/shared/modes.ts` (mode lookup/selection, `FileRestrictionError`) |
70
+ | `src/shared/tools.ts` | `zoo-code/src/shared/tools.ts` (`TOOL_GROUPS`, `ALWAYS_AVAILABLE_TOOLS`, `TOOL_ALIASES`, `NativeToolArgs`, `DiffStrategy`) |
71
+ | `src/shared/language.ts` | `zoo-code/src/shared/language.ts` (`LANGUAGES`, `formatLanguage`) |
72
+ | `src/shared/globalFileNames.ts` | `zoo-code/src/shared/globalFileNames.ts` |
73
+ | `src/utils/object.ts` | `zoo-code/src/utils/object.ts` (`isEmpty`) |
74
+ | `src/utils/shell.ts` | `zoo-code/src/utils/shell.ts` (`getShell`, allowlist; `vscode.*` refs satisfied by shim) |
75
+ | `src/utils/mcp-name.ts` | `zoo-code/src/utils/mcp-name.ts` (pure; `buildMcpToolName`, sanitizers) |
76
+
77
+ ### Vendored `@roo-code/types` subset — `zoo-code/packages/types/src/`
78
+ | Vendored file | Original path |
79
+ |---|---|
80
+ | `types/tool.ts` | `zoo-code/packages/types/src/tool.ts` (tool groups, tool names) |
81
+ | `types/mode.ts` | `zoo-code/packages/types/src/mode.ts` (`ModeConfig` zod schema + `DEFAULT_MODES` for architect/code/ask/debug/orchestrator) |
82
+ | `types/todo.ts` | `zoo-code/packages/types/src/todo.ts` (`TodoItem`) |
83
+ | `types/vscode.ts` | `zoo-code/packages/types/src/vscode.ts` (`Language`, `isLanguage`) |
84
+ | `types/message.ts` | `zoo-code/packages/types/src/message.ts` (`ClineAsk`, `ToolProgressStatus`) |
85
+ | `types/tool-params.ts` | `zoo-code/packages/types/src/tool-params.ts` (`GenerateImageParams`, `ReadFileToolParams`) |
86
+
87
+ ### Checkpoints — `zoo-code/src/services/checkpoints/`
88
+ | Vendored file | Original path |
89
+ |---|---|
90
+ | `src/services/checkpoints/ShadowCheckpointService.ts` | `zoo-code/src/services/checkpoints/ShadowCheckpointService.ts` (shadow-git mechanism via `simple-git`; 1 `vscode.*` ref — an error toast — satisfied by the shim) |
91
+ | `src/services/checkpoints/RepoPerTaskCheckpointService.ts` | `zoo-code/src/services/checkpoints/RepoPerTaskCheckpointService.ts` (thin subclass: `shadowDir/tasks/<taskId>/checkpoints` layout) |
92
+ | `src/services/checkpoints/types.ts` | `zoo-code/src/services/checkpoints/types.ts` |
93
+ | `src/services/checkpoints/excludes.ts` | `zoo-code/src/services/checkpoints/excludes.ts` (shadow-repo `.git/info/exclude` patterns) |
94
+ | `src/services/checkpoints/index.ts` | `zoo-code/src/services/checkpoints/index.ts` (barrel) |
95
+
96
+ ### Diff-based editing — `zoo-code/src/core/diff/`
97
+ | Vendored file | Original path |
98
+ |---|---|
99
+ | `src/core/diff/strategies/multi-search-replace.ts` | `zoo-code/src/core/diff/strategies/multi-search-replace.ts` (fuzzy Levenshtein diff engine with `:start_line:` disambiguation + truncated-diff repair; backs the harness's `apply_diff` tool) |
100
+ | `src/utils/text-normalization.ts` | `zoo-code/src/utils/text-normalization.ts` (pure: `normalizeString`, `unescapeHtmlEntities`) |
101
+ | `src/integrations/misc/extract-text.ts` | `zoo-code/src/integrations/misc/extract-text.ts` (subset: only the `addLineNumbers` / `everyLineHasLineNumbers` / `stripLineNumbers` helpers the diff strategy imports; PDF/DOCX/XLSX extractors and binary detection excluded — they drag `pdf-parse`, `mammoth`, `isbinaryfile`) |
102
+ | `types/global-settings.ts` | `zoo-code/packages/types/src/global-settings.ts` (subset: only `DEFAULT_DIFF_FUZZY_THRESHOLD = 1.0`, re-exported from the `@roo-code/types` barrel) |
103
+
104
+ New real npm dep added for this: `fastest-levenshtein` (the diff strategy's Levenshtein distance function).
105
+
106
+ Real npm deps added for this (not shimmed — genuine portable packages):
107
+ `simple-git`, `p-wait-for` (see root `package.json`). Harness wiring is
108
+ `src/checkpoints/service.ts` + `src/checkpoints/cli.ts`; see
109
+ `docs/checkpoints.md`.
110
+
111
+ One adaptation note specific to checkpoints: `ShadowCheckpointService`'s
112
+ private `stageAll()` (`git add . --ignore-errors`) only stages correctly
113
+ when the shadow dir's `cwd` is unrelated to the workspace it tracks (true for
114
+ Zoo Code's real `globalStorageUri`-based shadow dir, which is always outside
115
+ any workspace). `src/checkpoints/service.ts` runtime-patches that one method
116
+ on its own subclass's prototype to `git add -A` as defense in depth, and
117
+ separately refuses (throws) to create a checkpoint service whose
118
+ `checkpointDir` resolves inside `workspaceRoot` at all — nesting also breaks
119
+ `restoreCheckpoint()`'s `git clean -f -d -f`, which would delete a nested
120
+ shadow repo's own `.git`. See the file header of `src/checkpoints/service.ts`
121
+ for the full writeup (verified empirically, not just from reading the code).
122
+ No vendored file was edited for this — the fix is a subclass-prototype patch
123
+ in the harness's own wrapper module.
124
+
125
+ ---
126
+
127
+ ## 2. Shims created (all under `src/vendor/zoo-code/`)
128
+
129
+ Wired by rewriting the vendored imports to real relative paths (e.g.
130
+ `import * as vscode from "../../shim/vscode"`, `import ... from "../../types"`)
131
+ — since issue #99, the package must boot from a clean `npm install`, where
132
+ tsx does NOT apply tsconfig `paths` to files under `node_modules`. The shims
133
+ sit at the same depth-relative locations regardless of install prefix, so the
134
+ relative imports resolve with no tsconfig magic:
135
+
136
+ | Shim file | Replaces (upstream) | Why / notes |
137
+ |---|---|---|
138
+ | `shim/vscode.ts` | the `vscode` module | Headless no-op stand-in: `ExtensionContext.globalState`, `workspace.workspaceFolders` (= `undefined`), no-op `createFileSystemWatcher`, `getConfiguration`, `window.showErrorMessage/WarningMessage` → console, `env.language` = `"en"`. Imported by relative path (`../../shim/vscode`). |
139
+ | `shim/openai.d.ts` | the `openai` package (types only) | Vendored schemas only use `import type OpenAI` — no runtime needed. Declares just `Chat.ChatCompletionTool` (+ `FunctionParameters`, `ChatCompletionCreateParams["tool_choice"]`). |
140
+ | `shim/anthropic.ts` | `@anthropic-ai/sdk` | Class + namespace merge (mirrors the real SDK's export shape) providing `Anthropic.Tool`/`Tool.InputSchema`/`Messages.MessageCreateParams["tool_choice"]`/`TextBlockParam`/`ImageBlockParam` plus an empty runtime class so the named import in `shared/tools.ts` resolves. Mapped via `paths`. |
141
+ | `shim/os-name.ts` | the `os-name` npm package | Returns the same `<platform> <release>` fallback the original code uses when `os-name` fails. Mapped via `paths`. |
142
+ | `shim/strip-bom.ts` | the `strip-bom` npm package | Strips a leading UTF-8 BOM. Mapped via `paths`. |
143
+ | `src/utils/path.ts` | `zoo-code/src/utils/path.ts` | Same exported surface (`toPosix` side effect on `String.prototype`, `arePathsEqual`, `getReadablePath`, `toRelativePath`, `getWorkspacePath`), but workspace root comes from `HEADLESSCODE_WORKSPACE_ROOT` env var, falling back to `process.cwd()`. Placed at the same relative path so `CustomModesManager`'s `../../utils/path` import resolves unmodified. |
144
+ | `src/utils/fs.ts` | `zoo-code/src/utils/fs.ts` | Only the subset used by the vendored core: `fileExistsAtPath`. |
145
+ | `src/utils/logging.ts` | `zoo-code/src/utils/logging.ts` | Console-backed `logger` (original wraps VS Code output channels). |
146
+ | `src/utils/globalContext.ts` | `zoo-code/src/utils/globalContext.ts` | `ensureSettingsDirectoryExists` → `~/.roo` (created if needed). |
147
+ | `src/utils/json-schema.ts` | `zoo-code/src/utils/json-schema.ts` | Identity `normalizeToolSchema` + structural `JsonSchema`. Original drags `zod/v4`; full normalization only matters for real MCP support. **Needs adaptation when MCP lands.** |
148
+ | `src/services/mcp/McpHub.ts` | `zoo-code/src/services/mcp/McpHub.ts` | Stub `McpHub` with an injectable server list; `getServers()`. No transports (Phase 1 has no MCP). |
149
+ | `src/services/code-index/manager.ts` | `zoo-code/src/services/code-index/manager.ts` | Stub `CodeIndexManager.getInstance()` (prompt builder only calls the factory; result unused). |
150
+ | `src/services/skills/SkillsManager.ts` | `zoo-code/src/services/skills/SkillsManager.ts` | Stub returning no skills from `getSkillsForMode()`. |
151
+ | `src/services/search/file-search.ts` | `zoo-code/src/services/search/file-search.ts` | `executeRipgrep` implemented with pure Node fs + a small glob matcher (`**`, `*`, `!`-excludes). Originally only served `.roo` subdirectory discovery (`roo-config`); extended for the checkpoints vendoring to also serve `ShadowCheckpointService#getNestedGitRepository()`'s `**/.git/HEAD` nested-repo scan (returns `{ path, type }`, not just `path`, to match what that caller destructures). |
152
+ | `src/i18n/index.ts` | `zoo-code/src/i18n/index.ts` | `t()` returns the key with `{param}` interpolation; original is the webview UI catalog. |
153
+ | `types/index.ts` | the `@roo-code/types` package | Re-export barrel over the vendored `types/*` modules. Imported by relative path (`../../types`). |
154
+
155
+ ---
156
+
157
+ ## 3. Files excluded and why
158
+
159
+ | Excluded (upstream path) | Why |
160
+ |---|---|
161
+ | `zoo-code/src/core/prompts/tools/filter-tools-for-mode.ts` | Drags `McpHub`, `CodeIndexManager`, `ModelInfo`, and `validateToolUse`; per-mode tool filtering is orchestration-layer work for a later subtask. Only the schemas themselves were required now. |
162
+ | `zoo-code/src/core/prompts/responses.ts` | Result formatting back to the model; depends on diff/terminal result shapes. Deferred to the tool-execution subtask. (Not required by this subtask's scope.) |
163
+ | `zoo-code/src/core/prompts/sections/__tests__/` and all `__tests__/` dirs | Test scaffolding (vitest) with snapshots; not needed headless. |
164
+ | `zoo-code/src/core/assistant-message/`, `core/task/`, `core/context-management/`, `core/condense/` | Orchestration loop, tool-call parsing, context management — explicitly out of scope for this subtask (next subtask). |
165
+ | `zoo-code/src/core/tools/` (tool *executions*) | Diff-view-provider/terminal-coupled; replaced by plain `fs`/`subprocess` executors in the next subtask. |
166
+ | `zoo-code/src/services/rules/rules.ts` | CRUD + path-traversal guards for rules files; the splice path only needs `custom-instructions.ts`'s own scanning (which was vendored). |
167
+ | `zoo-code/apps/cli/`, `packages/vscode-shim/`, `webview-ui/`, `src/extension.ts`, `activate/`, `api/`, `integrations/` | GUI/extension machinery — excluded per instructions. |
168
+ | `zoo-code/src/utils/path.ts` (original), `utils/fs.ts`, `utils/logging.ts`, `utils/globalContext.ts`, `utils/json-schema.ts` | Replaced by the local shims listed above (placed at the same relative paths). |
169
+ | `zoo-code/src/shared/string-extensions.d.ts` | Its `String.toPosix` declaration is provided by the vendored `src/utils/path.ts` shim instead. |
170
+
171
+ ---
172
+
173
+ ## 4. Remaining `vscode.*` references and adaptation notes for the next subtask
174
+
175
+ All remaining `vscode.*` references in vendored code are satisfied **at type
176
+ and runtime level** by the `shim/vscode.ts` stand-in; none require a real
177
+ VS Code. They are listed here so the next subtask knows exactly what a headless
178
+ implementation must provide or replace:
179
+
180
+ | File | `vscode.*` use | Headless plan |
181
+ |---|---|---|
182
+ | `src/core/prompts/system.ts` | `vscode.ExtensionContext` type; `vscode.env.language` | Context is a thin in-memory `globalState` object; language comes from config/env. |
183
+ | `src/core/prompts/sections/modes.ts` | `vscode.ExtensionContext` type (via `getAllModesWithPrompts`) | Same as above. |
184
+ | `src/shared/modes.ts` | `vscode.ExtensionContext` type in `getAllModesWithPrompts` | Same as above. |
185
+ | `src/utils/shell.ts` | `vscode.workspace.getConfiguration` (terminal profile lookup, inside try/catch) | Falls through to `os.userInfo()`/`$SHELL`/platform defaults. |
186
+ | `src/core/config/CustomModesManager.ts` | `vscode.Disposable`/`ExtensionContext` types; `workspace.workspaceFolders`; `workspace.createFileSystemWatcher`; `window.showErrorMessage/WarningMessage` | Harness should expose a headless `getCustomModes(cwd)` path (or set `HEADLESSCODE_WORKSPACE_ROOT`); watchers are dropped; errors go to logs. |
187
+
188
+ Other adaptation notes for the next subtask:
189
+ - `fs.readdir(..., { withFileTypes: true, recursive: true })` in
190
+ `custom-instructions.ts` requires **Node ≥ 20.4** at runtime (fine under the
191
+ declared `engines.node >= 18` only for shallow rules trees; bump engines or
192
+ tolerate the TypeError if Node 18 is used with deeply nested rules dirs).
193
+ - The vendored `McpHub`, `CodeIndexManager`, `SkillsManager`, and
194
+ `json-schema` shims are stubs; replace them with real implementations when
195
+ MCP servers, codebase search, skills, and MCP schema normalization are
196
+ actually needed.
197
+ - `native-tools/mcp_server.ts` is vendored and compiles against the stubs but
198
+ returns `[]` until a real `McpHub` is wired.
199
+
200
+ ---
201
+
202
+ ## 5. Verification
203
+
204
+ - `npm install` — succeeded (deps: `zod`, `yaml`; devDeps: `typescript`, `tsx`,
205
+ `@types/node`; no SDK/runtime deps added beyond the project minimum).
206
+ - `npx tsc --noEmit` — **passes with 0 errors** (no "needs adaptation"
207
+ exclusions were necessary).
208
+ - `npm run smoke` — builds a system prompt for the `code` mode (≈15.7k chars,
209
+ includes TOOL USE / OBJECTIVE / RULES / MODES / CAPABILITIES / SYSTEM
210
+ INFORMATION / USER'S CUSTOM INSTRUCTIONS with passed-in custom-instructions
211
+ text), assembles 21 native (OpenAI-format) tool schemas, converts them to
212
+ Anthropic format, and validates a `.roomodes`-style doc against
213
+ `customModesSettingsSchema`. See `src/vendor/tests/smoke.ts`.
@@ -0,0 +1,71 @@
1
+ /**
2
+ * SHIM — minimal stand-in for the `@anthropic-ai/sdk` package.
3
+ *
4
+ * The vendored `shared/tools.ts`'s `import { Anthropic } from
5
+ * "@anthropic-ai/sdk"` is rewritten to import this file by relative path
6
+ * (issue #99 rework). It imports the `Anthropic` value only
7
+ * for its types (TextBlockParam/ImageBlockParam), and
8
+ * `native-tools/converters.ts` imports it with `import type`. The class +
9
+ * namespace merging below mirrors how the real SDK exports `Anthropic`: the
10
+ * (empty) class provides the runtime value so the named import resolves
11
+ * headlessly, and the merged namespace provides the type surface the vendored
12
+ * converters rely on (`Anthropic.Tool`, `Anthropic.Tool.InputSchema`,
13
+ * `Anthropic.Messages.MessageCreateParams`, text/image block params).
14
+ *
15
+ * See VENDOR-NOTES.md.
16
+ */
17
+
18
+ export class Anthropic {}
19
+
20
+ export namespace Anthropic {
21
+ export namespace Messages {
22
+ export interface MessageCreateParams {
23
+ tool_choice?:
24
+ | "auto"
25
+ | "any"
26
+ | "tool"
27
+ | { type: "auto" | "any" | "tool"; name?: string; disable_parallel_tool_use?: boolean }
28
+ | null
29
+ }
30
+ }
31
+
32
+ export interface Tool {
33
+ name: string
34
+ description?: string
35
+ input_schema: {
36
+ type: "object"
37
+ properties?: Record<string, unknown>
38
+ required?: string[]
39
+ additionalProperties?: boolean
40
+ [key: string]: unknown
41
+ }
42
+ [key: string]: unknown
43
+ }
44
+
45
+ export namespace Tool {
46
+ export interface InputSchema {
47
+ type: "object"
48
+ properties?: Record<string, unknown>
49
+ required?: string[]
50
+ additionalProperties?: boolean
51
+ [key: string]: unknown
52
+ }
53
+ }
54
+
55
+ export interface TextBlockParam {
56
+ type: "text"
57
+ text: string
58
+ }
59
+
60
+ export interface ImageBlockParam {
61
+ type: "image"
62
+ source: {
63
+ type: "base64" | "url"
64
+ media_type?: string
65
+ data?: string
66
+ url?: string
67
+ }
68
+ }
69
+ }
70
+
71
+ export default Anthropic
@@ -0,0 +1,60 @@
1
+ /**
2
+ * SHIM — ambient type-only declaration for the `openai` package.
3
+ *
4
+ * All vendored tool-schema files import OpenAI types with `import type ... from
5
+ * "openai"`, so nothing from this package is ever needed at runtime. This
6
+ * declaration provides just enough of the `OpenAI.Chat` surface the vendored
7
+ * schemas annotate with `satisfies OpenAI.Chat.ChatCompletionTool`.
8
+ *
9
+ * The canonical, much larger types come from the real `openai` npm package in
10
+ * the upstream repo; a headless harness does not need to install it just for
11
+ * JSON schema annotations. See VENDOR-NOTES.md.
12
+ */
13
+
14
+ declare module "openai" {
15
+ namespace OpenAI {
16
+ namespace Chat {
17
+ export type FunctionParameters = {
18
+ type: "object"
19
+ [key: string]: unknown
20
+ }
21
+
22
+ export interface ChatCompletionFunctionTool {
23
+ type: "function"
24
+ function: {
25
+ name: string
26
+ description?: string
27
+ strict?: boolean | null
28
+ parameters?: FunctionParameters
29
+ [key: string]: unknown
30
+ }
31
+ }
32
+
33
+ export interface ChatCompletionCustomTool {
34
+ type: "custom"
35
+ function: {
36
+ name: string
37
+ description?: string
38
+ parameters?: unknown
39
+ [key: string]: unknown
40
+ }
41
+ }
42
+
43
+ export type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool
44
+
45
+ export interface ChatCompletionCreateParams {
46
+ tool_choice?:
47
+ | "none"
48
+ | "auto"
49
+ | "required"
50
+ | { type: "function"; function: { name: string } }
51
+ | null
52
+ }
53
+ }
54
+
55
+ export type FunctionParameters = Chat.FunctionParameters
56
+ export type ChatCompletionTool = Chat.ChatCompletionTool
57
+ }
58
+
59
+ export = OpenAI
60
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * SHIM — local replacement for the tiny `os-name` npm package.
3
+ *
4
+ * The vendored `src/core/prompts/sections/system-info.ts` imports a default
5
+ * `osName()` function. The real package returns a human-readable OS name
6
+ * (e.g. "macOS Sequoia"). This shim returns the same `<platform> <release>`
7
+ * string the original code falls back to when `os-name` itself fails, keeping
8
+ * the dependency count at the project minimum.
9
+ *
10
+ * The vendored `system-info.ts`'s default import of `os-name` is rewritten to
11
+ * import this file by relative path (issue #99 rework).
12
+ */
13
+
14
+ import * as os from "os"
15
+
16
+ export default function osName(): string {
17
+ return `${os.platform()} ${os.release()}`
18
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SHIM — local replacement for the tiny `strip-bom` npm package.
3
+ *
4
+ * The vendored `src/core/config/CustomModesManager.ts` imports a default
5
+ * `stripBom()` function that removes a leading UTF-8 byte order mark. This shim
6
+ * implements exactly that so the dependency count stays at the project minimum.
7
+ *
8
+ * The vendored `CustomModesManager.ts`'s default import of `strip-bom` is
9
+ * rewritten to import this file by relative path (issue #99 rework).
10
+ */
11
+
12
+ export default function stripBom(string: string): string {
13
+ return string.replace(/^\uFEFF/, "")
14
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * SHIM — headless stand-in for the `vscode` module.
3
+ *
4
+ * The vendored core's `import * as vscode from "vscode"` is rewritten to
5
+ * import this file by relative path (issue #99 rework — the package must boot
6
+ * from a clean npm install, where tsx does not apply tsconfig `paths`). The
7
+ * real Zoo Code imports `vscode.*` all over its GUI-coupled layer; the vendored
8
+ * core only touches the small surface below. Every method is a harmless no-op —
9
+ * a headless harness must never depend on VS Code UI or file watchers.
10
+ *
11
+ * See VENDOR-NOTES.md for the full shim inventory.
12
+ */
13
+
14
+ export interface Disposable {
15
+ dispose(): void
16
+ }
17
+
18
+ export interface ExtensionContext {
19
+ globalState: {
20
+ get<T>(key: string, defaultValue?: T): Promise<T | undefined>
21
+ update(key: string, value: unknown): Promise<void>
22
+ }
23
+ globalStorageUri: { fsPath: string }
24
+ subscriptions: Disposable[]
25
+ }
26
+
27
+ export interface WorkspaceFolder {
28
+ uri: { fsPath: string }
29
+ name: string
30
+ index: number
31
+ }
32
+
33
+ export interface FileSystemWatcher extends Disposable {
34
+ onDidChange(listener: (e: unknown) => unknown): Disposable
35
+ onDidCreate(listener: (e: unknown) => unknown): Disposable
36
+ onDidDelete(listener: (e: unknown) => unknown): Disposable
37
+ }
38
+
39
+ export namespace window {
40
+ export function showErrorMessage(message: string, ..._items: string[]): Promise<string | undefined> {
41
+ console.error(`[headlesscode vscode-shim] ${message}`)
42
+ return Promise.resolve(undefined)
43
+ }
44
+
45
+ export function showWarningMessage(message: string, ..._items: string[]): Promise<string | undefined> {
46
+ console.warn(`[headlesscode vscode-shim] ${message}`)
47
+ return Promise.resolve(undefined)
48
+ }
49
+ }
50
+
51
+ export namespace workspace {
52
+ // The headless harness has no VS Code workspace folders. CustomModesManager
53
+ // treats this as "no .roomodes file in the UI sense" and falls back to the
54
+ // headless workspace root from utils/path.ts.
55
+ export const workspaceFolders: readonly WorkspaceFolder[] | undefined = undefined
56
+
57
+ export function createFileSystemWatcher(_globPattern: string | unknown): FileSystemWatcher {
58
+ // No-op: file watching is a GUI feature, out of scope for the harness.
59
+ return {
60
+ onDidChange: () => ({ dispose: () => {} }),
61
+ onDidCreate: () => ({ dispose: () => {} }),
62
+ onDidDelete: () => ({ dispose: () => {} }),
63
+ dispose: () => {},
64
+ }
65
+ }
66
+
67
+ export function getConfiguration(_section?: string): {
68
+ get<T>(key: string, defaultValue?: T): T | undefined
69
+ } {
70
+ return { get: () => undefined }
71
+ }
72
+ }
73
+
74
+ export namespace env {
75
+ export const language = "en"
76
+ }