vinext 0.1.8 → 0.2.0

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/README.md +51 -30
  2. package/dist/build/inject-pregenerated-paths.d.ts +4 -0
  3. package/dist/build/inject-pregenerated-paths.js +18 -0
  4. package/dist/build/layout-classification.js +1 -1
  5. package/dist/build/nitro-route-rules.js +1 -1
  6. package/dist/build/pages-client-assets-module.d.ts +11 -0
  7. package/dist/build/pages-client-assets-module.js +27 -0
  8. package/dist/build/prerender.d.ts +2 -1
  9. package/dist/build/prerender.js +13 -6
  10. package/dist/build/report.d.ts +13 -2
  11. package/dist/build/report.js +99 -2
  12. package/dist/build/run-prerender.d.ts +7 -0
  13. package/dist/build/run-prerender.js +10 -1
  14. package/dist/build/standalone.js +2 -0
  15. package/dist/cache/cache-adapters-virtual.js +3 -3
  16. package/dist/check.js +40 -2
  17. package/dist/cli-args.d.ts +1 -2
  18. package/dist/cli-args.js +1 -1
  19. package/dist/cli-dev-config.d.ts +12 -0
  20. package/dist/cli-dev-config.js +23 -0
  21. package/dist/cli.js +111 -95
  22. package/dist/{server → client}/dev-error-overlay-store.d.ts +1 -1
  23. package/dist/{server → client}/dev-error-overlay-store.js +1 -1
  24. package/dist/{server → client}/dev-error-overlay.d.ts +1 -1
  25. package/dist/{server → client}/dev-error-overlay.js +2 -2
  26. package/dist/client/navigation-runtime.d.ts +2 -0
  27. package/dist/client/navigation-runtime.js +3 -1
  28. package/dist/client/window-next.d.ts +2 -1
  29. package/dist/cloudflare/index.d.ts +2 -2
  30. package/dist/cloudflare/index.js +2 -2
  31. package/dist/config/config-matchers.js +14 -10
  32. package/dist/config/next-config.d.ts +5 -3
  33. package/dist/config/next-config.js +44 -1
  34. package/dist/config/prerender.d.ts +34 -0
  35. package/dist/config/prerender.js +55 -0
  36. package/dist/entries/app-rsc-entry.d.ts +2 -1
  37. package/dist/entries/app-rsc-entry.js +40 -10
  38. package/dist/entries/app-rsc-manifest.js +2 -0
  39. package/dist/entries/pages-client-entry.d.ts +3 -0
  40. package/dist/entries/pages-client-entry.js +15 -1
  41. package/dist/entries/pages-server-entry.js +5 -2
  42. package/dist/image/image-adapters-virtual.d.ts +59 -0
  43. package/dist/image/image-adapters-virtual.js +59 -0
  44. package/dist/index.d.ts +33 -0
  45. package/dist/index.js +167 -100
  46. package/dist/init-cloudflare.d.ts +43 -0
  47. package/dist/init-cloudflare.js +839 -0
  48. package/dist/init-platform.d.ts +40 -0
  49. package/dist/init-platform.js +195 -0
  50. package/dist/init.d.ts +16 -38
  51. package/dist/init.js +209 -99
  52. package/dist/node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.js +294 -0
  53. package/dist/node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js +94 -0
  54. package/dist/{cloudflare → packages/cloudflare}/src/cache/cdn-adapter.runtime.js +1 -1
  55. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.d.ts +2 -2
  56. package/dist/{cloudflare → packages/cloudflare}/src/cache/kv-data-adapter.runtime.js +1 -1
  57. package/dist/packages/cloudflare/src/deploy-config.js +150 -0
  58. package/dist/packages/cloudflare/src/deploy-help.js +55 -0
  59. package/dist/packages/cloudflare/src/deploy.js +276 -0
  60. package/dist/{cloudflare → packages/cloudflare/src}/tpr.d.ts +4 -41
  61. package/dist/{cloudflare → packages/cloudflare/src}/tpr.js +18 -15
  62. package/dist/plugins/ast-scope.d.ts +16 -0
  63. package/dist/plugins/ast-scope.js +62 -0
  64. package/dist/plugins/ast-utils.d.ts +27 -1
  65. package/dist/plugins/ast-utils.js +32 -1
  66. package/dist/plugins/css-module-imports.d.ts +14 -0
  67. package/dist/plugins/css-module-imports.js +59 -0
  68. package/dist/plugins/extensionless-dynamic-import.js +2 -2
  69. package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
  70. package/dist/plugins/ignore-dynamic-requests.js +530 -0
  71. package/dist/plugins/typeof-window.d.ts +1 -1
  72. package/dist/plugins/typeof-window.js +28 -56
  73. package/dist/routing/app-route-graph.d.ts +23 -2
  74. package/dist/routing/app-route-graph.js +126 -32
  75. package/dist/routing/file-matcher.d.ts +3 -0
  76. package/dist/routing/file-matcher.js +3 -0
  77. package/dist/routing/pages-router.js +2 -2
  78. package/dist/server/api-handler.js +9 -14
  79. package/dist/server/app-browser-action-result.d.ts +4 -1
  80. package/dist/server/app-browser-action-result.js +8 -1
  81. package/dist/server/app-browser-entry.js +161 -52
  82. package/dist/server/app-browser-interception-context.d.ts +1 -0
  83. package/dist/server/app-browser-interception-context.js +4 -2
  84. package/dist/server/app-browser-navigation-controller.d.ts +2 -0
  85. package/dist/server/app-browser-navigation-controller.js +60 -31
  86. package/dist/server/app-browser-server-action-client.d.ts +1 -1
  87. package/dist/server/app-browser-server-action-client.js +3 -4
  88. package/dist/server/app-browser-state.d.ts +11 -1
  89. package/dist/server/app-browser-state.js +25 -8
  90. package/dist/server/app-browser-visible-commit.d.ts +6 -1
  91. package/dist/server/app-browser-visible-commit.js +43 -25
  92. package/dist/server/app-elements-wire.d.ts +9 -2
  93. package/dist/server/app-elements-wire.js +8 -1
  94. package/dist/server/app-elements.d.ts +2 -2
  95. package/dist/server/app-elements.js +4 -3
  96. package/dist/server/app-fallback-renderer.d.ts +2 -1
  97. package/dist/server/app-fallback-renderer.js +10 -6
  98. package/dist/server/app-hydration-cache-publication.d.ts +11 -0
  99. package/dist/server/app-hydration-cache-publication.js +43 -0
  100. package/dist/server/app-middleware.d.ts +4 -3
  101. package/dist/server/app-middleware.js +8 -3
  102. package/dist/server/app-optimistic-routing.js +11 -4
  103. package/dist/server/app-page-cache-finalizer.js +2 -1
  104. package/dist/server/app-page-cache-render.d.ts +1 -0
  105. package/dist/server/app-page-cache-render.js +8 -4
  106. package/dist/server/app-page-cache.d.ts +1 -0
  107. package/dist/server/app-page-cache.js +5 -2
  108. package/dist/server/app-page-dispatch.js +1 -0
  109. package/dist/server/app-page-element-builder.d.ts +2 -1
  110. package/dist/server/app-page-element-builder.js +58 -4
  111. package/dist/server/app-page-probe.js +5 -0
  112. package/dist/server/app-page-render-identity.d.ts +1 -0
  113. package/dist/server/app-page-render-identity.js +1 -1
  114. package/dist/server/app-page-render.js +18 -0
  115. package/dist/server/app-page-request.d.ts +14 -0
  116. package/dist/server/app-page-request.js +69 -4
  117. package/dist/server/app-page-route-wiring.d.ts +8 -1
  118. package/dist/server/app-page-route-wiring.js +32 -18
  119. package/dist/server/app-page-segment-state.d.ts +2 -1
  120. package/dist/server/app-page-segment-state.js +3 -1
  121. package/dist/server/app-page-stream.d.ts +5 -0
  122. package/dist/server/app-page-stream.js +3 -1
  123. package/dist/server/app-route-handler-execution.js +5 -1
  124. package/dist/server/app-route-handler-response.js +1 -0
  125. package/dist/server/app-route-handler-runtime.js +1 -1
  126. package/dist/server/app-router-entry.js +9 -2
  127. package/dist/server/app-rsc-handler.d.ts +1 -0
  128. package/dist/server/app-rsc-handler.js +62 -31
  129. package/dist/server/app-rsc-request-normalization.d.ts +3 -2
  130. package/dist/server/app-rsc-request-normalization.js +6 -3
  131. package/dist/server/app-segment-config.d.ts +11 -0
  132. package/dist/server/app-segment-config.js +62 -6
  133. package/dist/server/app-server-action-execution.d.ts +1 -0
  134. package/dist/server/app-server-action-execution.js +58 -28
  135. package/dist/server/app-ssr-entry.d.ts +3 -0
  136. package/dist/server/app-ssr-entry.js +15 -7
  137. package/dist/server/app-ssr-stream.d.ts +7 -3
  138. package/dist/server/app-ssr-stream.js +10 -6
  139. package/dist/server/app-visited-response-cache.d.ts +6 -0
  140. package/dist/server/app-visited-response-cache.js +3 -1
  141. package/dist/server/client-trace-metadata.js +26 -0
  142. package/dist/server/default-global-not-found-module.d.ts +14 -0
  143. package/dist/server/default-global-not-found-module.js +14 -0
  144. package/dist/server/dev-route-files.js +4 -0
  145. package/dist/server/dev-server.js +19 -18
  146. package/dist/server/dev-stack-sourcemap.d.ts +1 -1
  147. package/dist/server/dev-stack-sourcemap.js +1 -1
  148. package/dist/server/fetch-handler.d.ts +2 -0
  149. package/dist/server/fetch-handler.js +18 -0
  150. package/dist/server/headers.d.ts +3 -15
  151. package/dist/server/headers.js +2 -15
  152. package/dist/server/image-optimization.d.ts +51 -1
  153. package/dist/server/image-optimization.js +52 -2
  154. package/dist/server/implicit-tags.js +1 -1
  155. package/dist/server/isr-cache.d.ts +1 -1
  156. package/dist/server/isr-cache.js +2 -2
  157. package/dist/server/metadata-routes.d.ts +3 -1
  158. package/dist/server/metadata-routes.js +12 -2
  159. package/dist/server/middleware-runtime.js +6 -1
  160. package/dist/server/navigation-planner.d.ts +1 -0
  161. package/dist/server/navigation-planner.js +14 -3
  162. package/dist/server/pages-api-route.js +2 -2
  163. package/dist/server/pages-asset-tags.d.ts +4 -6
  164. package/dist/server/pages-asset-tags.js +12 -12
  165. package/dist/server/pages-client-assets.d.ts +12 -0
  166. package/dist/server/pages-client-assets.js +10 -0
  167. package/dist/server/pages-node-compat.d.ts +8 -1
  168. package/dist/server/pages-node-compat.js +32 -4
  169. package/dist/server/pages-page-data.d.ts +24 -1
  170. package/dist/server/pages-page-data.js +45 -24
  171. package/dist/server/pages-page-handler.d.ts +2 -1
  172. package/dist/server/pages-page-handler.js +19 -12
  173. package/dist/server/pages-page-response.d.ts +7 -0
  174. package/dist/server/pages-page-response.js +4 -1
  175. package/dist/server/pages-request-pipeline.d.ts +2 -0
  176. package/dist/server/pages-request-pipeline.js +25 -1
  177. package/dist/server/pages-router-entry.d.ts +30 -0
  178. package/dist/server/pages-router-entry.js +108 -0
  179. package/dist/server/prerender-manifest.d.ts +3 -1
  180. package/dist/server/prerender-route-params.js +1 -1
  181. package/dist/server/prod-server.d.ts +1 -1
  182. package/dist/server/prod-server.js +33 -20
  183. package/dist/server/request-pipeline.js +1 -0
  184. package/dist/server/seed-cache.js +4 -4
  185. package/dist/shims/app-router-scroll-state.d.ts +1 -0
  186. package/dist/shims/app-router-scroll-state.js +1 -0
  187. package/dist/shims/app-router-scroll.js +2 -1
  188. package/dist/shims/cache.js +19 -15
  189. package/dist/shims/cdn-cache.js +1 -1
  190. package/dist/shims/dynamic-preload-chunks.js +2 -1
  191. package/dist/shims/form.d.ts +3 -1
  192. package/dist/shims/form.js +37 -43
  193. package/dist/shims/headers.d.ts +7 -1
  194. package/dist/shims/headers.js +17 -3
  195. package/dist/shims/image.js +75 -14
  196. package/dist/shims/internal/app-route-detection.d.ts +2 -17
  197. package/dist/shims/internal/app-route-detection.js +4 -17
  198. package/dist/shims/internal/hybrid-client-route-owner-direct.d.ts +23 -0
  199. package/dist/shims/internal/hybrid-client-route-owner-direct.js +51 -0
  200. package/dist/shims/internal/hybrid-client-route-owner.d.ts +2 -15
  201. package/dist/shims/internal/hybrid-client-route-owner.js +9 -60
  202. package/dist/shims/internal/pages-data-fetch-dedup.d.ts +9 -5
  203. package/dist/shims/internal/pages-data-fetch-dedup.js +73 -14
  204. package/dist/shims/internal/pages-data-target.d.ts +10 -9
  205. package/dist/shims/internal/pages-data-target.js +91 -12
  206. package/dist/shims/internal/pages-router-components.d.ts +7 -0
  207. package/dist/shims/internal/pages-router-components.js +13 -0
  208. package/dist/shims/layout-segment-context.d.ts +4 -1
  209. package/dist/shims/layout-segment-context.js +18 -4
  210. package/dist/shims/link.js +55 -26
  211. package/dist/shims/navigation.d.ts +5 -1
  212. package/dist/shims/navigation.js +45 -10
  213. package/dist/shims/navigation.react-server.js +1 -1
  214. package/dist/shims/root-params.d.ts +15 -1
  215. package/dist/shims/root-params.js +21 -1
  216. package/dist/shims/router.d.ts +5 -7
  217. package/dist/shims/router.js +362 -93
  218. package/dist/shims/server.js +3 -2
  219. package/dist/shims/slot.js +3 -6
  220. package/dist/utils/client-runtime-metadata.d.ts +2 -18
  221. package/dist/utils/client-runtime-metadata.js +31 -22
  222. package/dist/utils/dev-stack-sourcemap-endpoint.d.ts +4 -0
  223. package/dist/{server → utils}/dev-stack-sourcemap-endpoint.js +1 -1
  224. package/dist/utils/domain-locale.d.ts +6 -3
  225. package/dist/{server → utils}/middleware-request-headers.d.ts +1 -1
  226. package/dist/{server → utils}/middleware-request-headers.js +2 -2
  227. package/dist/utils/project.d.ts +48 -2
  228. package/dist/utils/project.js +225 -4
  229. package/dist/utils/protocol-headers.d.ts +17 -0
  230. package/dist/utils/protocol-headers.js +17 -0
  231. package/dist/utils/react-version.d.ts +4 -0
  232. package/dist/utils/react-version.js +44 -0
  233. package/package.json +47 -2
  234. package/dist/deploy.d.ts +0 -197
  235. package/dist/deploy.js +0 -1040
  236. package/dist/server/dev-stack-sourcemap-endpoint.d.ts +0 -4
  237. /package/dist/{cloudflare → packages/cloudflare}/src/utils/cache-control-metadata.js +0 -0
@@ -0,0 +1,294 @@
1
+ import { getProcessAncestry } from "../../../../process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js";
2
+ //#region ../../node_modules/.pnpm/am-i-vibing@0.5.0/node_modules/am-i-vibing/dist/detector-1yx2Hoe0.mjs
3
+ /**
4
+ * Provider configurations for major AI coding tools
5
+ */
6
+ const providers = [
7
+ {
8
+ id: "opencode",
9
+ name: "OpenCode",
10
+ type: "agent",
11
+ envVars: [{ any: [
12
+ "OPENCODE",
13
+ "OPENCODE_BIN_PATH",
14
+ "OPENCODE_SERVER",
15
+ "OPENCODE_APP_INFO",
16
+ "OPENCODE_MODES"
17
+ ] }]
18
+ },
19
+ {
20
+ id: "jules",
21
+ name: "Jules",
22
+ type: "agent",
23
+ envVars: [{ all: [["HOME", "/home/jules"], ["USER", "swebot"]] }]
24
+ },
25
+ {
26
+ id: "claude-code",
27
+ name: "Claude Code",
28
+ type: "agent",
29
+ envVars: ["CLAUDECODE"]
30
+ },
31
+ {
32
+ id: "cursor-agent",
33
+ name: "Cursor Agent",
34
+ type: "agent",
35
+ envVars: [{ all: ["CURSOR_TRACE_ID", ["PAGER", "head -n 10000 | cat"]] }]
36
+ },
37
+ {
38
+ id: "cursor",
39
+ name: "Cursor",
40
+ type: "interactive",
41
+ envVars: ["CURSOR_TRACE_ID"]
42
+ },
43
+ {
44
+ id: "antigravity",
45
+ name: "Antigravity",
46
+ type: "agent",
47
+ envVars: [{ any: ["ANTIGRAVITY_AGENT", "ANTIGRAVITY_PROJECT_ID"] }]
48
+ },
49
+ {
50
+ id: "gemini-agent",
51
+ name: "Gemini CLI",
52
+ type: "agent",
53
+ envVars: [["GEMINI_CLI", "1"]],
54
+ processChecks: ["gemini"]
55
+ },
56
+ {
57
+ id: "codex",
58
+ name: "OpenAI Codex",
59
+ type: "agent",
60
+ envVars: ["CODEX_THREAD_ID"],
61
+ processChecks: ["codex"]
62
+ },
63
+ {
64
+ id: "replit",
65
+ name: "Replit",
66
+ type: "agent",
67
+ envVars: ["REPL_ID"]
68
+ },
69
+ {
70
+ id: "aider",
71
+ name: "Aider",
72
+ type: "agent",
73
+ envVars: ["AIDER_API_KEY"],
74
+ processChecks: ["aider"]
75
+ },
76
+ {
77
+ id: "bolt-agent",
78
+ name: "Bolt.new Agent",
79
+ type: "agent",
80
+ envVars: [{ all: [["SHELL", "/bin/jsh"], "npm_config_yes"] }]
81
+ },
82
+ {
83
+ id: "bolt",
84
+ name: "Bolt.new",
85
+ type: "interactive",
86
+ envVars: [{
87
+ all: [["SHELL", "/bin/jsh"]],
88
+ none: ["npm_config_yes"]
89
+ }]
90
+ },
91
+ {
92
+ id: "zed-agent",
93
+ name: "Zed Agent",
94
+ type: "agent",
95
+ envVars: [{ all: [["TERM_PROGRAM", "zed"], ["PAGER", "cat"]] }]
96
+ },
97
+ {
98
+ id: "zed",
99
+ name: "Zed",
100
+ type: "interactive",
101
+ envVars: [{
102
+ all: [["TERM_PROGRAM", "zed"]],
103
+ none: [["PAGER", "cat"]]
104
+ }]
105
+ },
106
+ {
107
+ id: "replit-assistant",
108
+ name: "Replit Assistant",
109
+ type: "agent",
110
+ envVars: [{ all: ["REPL_ID", ["REPLIT_MODE", "assistant"]] }]
111
+ },
112
+ {
113
+ id: "replit",
114
+ name: "Replit",
115
+ type: "interactive",
116
+ envVars: [{
117
+ all: ["REPL_ID"],
118
+ none: [["REPLIT_MODE", "assistant"]]
119
+ }]
120
+ },
121
+ {
122
+ id: "windsurf",
123
+ name: "Windsurf",
124
+ type: "agent",
125
+ envVars: ["CODEIUM_EDITOR_APP_ROOT"]
126
+ },
127
+ {
128
+ id: "crush",
129
+ name: "Crush",
130
+ type: "agent",
131
+ envVars: [{ any: [
132
+ ["CRUSH", "1"],
133
+ ["AGENT", "crush"],
134
+ ["AI_AGENT", "crush"]
135
+ ] }],
136
+ processChecks: ["crush"]
137
+ },
138
+ {
139
+ id: "amp",
140
+ name: "Amp",
141
+ type: "agent",
142
+ envVars: [{ any: ["AMP_CURRENT_THREAD_ID", ["AGENT", "amp"]] }]
143
+ },
144
+ {
145
+ id: "auggie",
146
+ name: "Auggie",
147
+ type: "agent",
148
+ envVars: [["AUGMENT_AGENT", "1"]]
149
+ },
150
+ {
151
+ id: "qwen-code",
152
+ name: "Qwen Code",
153
+ type: "agent",
154
+ envVars: [["QWEN_CODE", "1"]]
155
+ },
156
+ {
157
+ id: "vscode-copilot-agent",
158
+ name: "GitHub Copilot in VS Code",
159
+ type: "agent",
160
+ envVars: [{ all: [["TERM_PROGRAM", "vscode"], ["GIT_PAGER", "cat"]] }]
161
+ },
162
+ {
163
+ id: "warp",
164
+ name: "Warp Terminal",
165
+ type: "hybrid",
166
+ envVars: [{ all: [["TERM_PROGRAM", "WarpTerminal"]] }]
167
+ },
168
+ {
169
+ id: "octofriend",
170
+ name: "Octofriend",
171
+ type: "agent",
172
+ processChecks: ["octofriend"]
173
+ },
174
+ {
175
+ id: "devin",
176
+ name: "Devin",
177
+ type: "agent",
178
+ processChecks: ["devin"]
179
+ },
180
+ {
181
+ id: "droid",
182
+ name: "Factory Droid",
183
+ type: "agent",
184
+ processChecks: ["droid"]
185
+ },
186
+ {
187
+ id: "pi",
188
+ name: "Pi",
189
+ type: "agent",
190
+ envVars: [["PI_CODING_AGENT", "true"]]
191
+ }
192
+ ];
193
+ /**
194
+ * Check if a specific environment variable exists (handles both strings and tuples)
195
+ */
196
+ function checkEnvVar(envVarDef, env = process.env) {
197
+ const [envVar, expectedValue] = typeof envVarDef === "string" ? [envVarDef, void 0] : envVarDef;
198
+ const actualValue = env[envVar];
199
+ return Boolean(actualValue && (!expectedValue || actualValue === expectedValue));
200
+ }
201
+ /**
202
+ * Check if a process is running in the process tree
203
+ */
204
+ function checkProcess(processName, processAncestry) {
205
+ for (const ancestorProcess of processAncestry) if (ancestorProcess.command?.includes(processName)) return true;
206
+ return false;
207
+ }
208
+ /**
209
+ * Check if an environment variable group matches based on its properties
210
+ */
211
+ function checkEnvVars(definition, env = process.env) {
212
+ if (typeof definition === "string" || Array.isArray(definition)) return checkEnvVar(definition, env);
213
+ const { any, all, none } = definition;
214
+ const anyResult = !any?.length || any.some((envVar) => checkEnvVar(envVar, env));
215
+ const allResult = !all?.length || all.every((envVar) => checkEnvVar(envVar, env));
216
+ const noneResult = !none?.length || !none.some((envVar) => checkEnvVar(envVar, env));
217
+ return anyResult && allResult && noneResult;
218
+ }
219
+ /**
220
+ * Run custom detectors for a provider
221
+ */
222
+ function runCustomDetectors(provider) {
223
+ return provider.customDetectors?.some((detector) => {
224
+ try {
225
+ return detector();
226
+ } catch {
227
+ return false;
228
+ }
229
+ }) ?? false;
230
+ }
231
+ /**
232
+ * Create a positive detection result
233
+ */
234
+ function createDetectedResult(provider) {
235
+ return {
236
+ isAgentic: true,
237
+ id: provider.id,
238
+ name: provider.name,
239
+ type: provider.type
240
+ };
241
+ }
242
+ /**
243
+ * Normalize the various supported argument shapes into a DetectOptions object.
244
+ *
245
+ * Supported shapes:
246
+ * - detectAgenticEnvironment()
247
+ * - detectAgenticEnvironment(options)
248
+ * - detectAgenticEnvironment(env) // legacy
249
+ * - detectAgenticEnvironment(env, processAncestry) // legacy
250
+ */
251
+ function normalizeOptions(envOrOptions, legacyAncestry) {
252
+ if (envOrOptions != null && typeof envOrOptions === "object" && ("env" in envOrOptions || "processAncestry" in envOrOptions || "checkProcesses" in envOrOptions)) {
253
+ const opts = envOrOptions;
254
+ return {
255
+ env: opts.env ?? process.env,
256
+ processAncestry: opts.processAncestry,
257
+ checkProcesses: opts.checkProcesses ?? opts.processAncestry !== void 0
258
+ };
259
+ }
260
+ return {
261
+ env: envOrOptions ?? process.env,
262
+ processAncestry: legacyAncestry,
263
+ checkProcesses: legacyAncestry !== void 0
264
+ };
265
+ }
266
+ function detectAgenticEnvironment(envOrOptions, legacyAncestry) {
267
+ const { env, processAncestry, checkProcesses } = normalizeOptions(envOrOptions, legacyAncestry);
268
+ for (const provider of providers) if (provider.envVars?.some((group) => checkEnvVars(group, env))) return createDetectedResult(provider);
269
+ for (const provider of providers) if (runCustomDetectors(provider)) return createDetectedResult(provider);
270
+ if (checkProcesses) {
271
+ let cachedAncestry = processAncestry;
272
+ const getAncestry = () => {
273
+ if (cachedAncestry === void 0) try {
274
+ cachedAncestry = getProcessAncestry();
275
+ } catch {
276
+ cachedAncestry = [];
277
+ }
278
+ return cachedAncestry;
279
+ };
280
+ for (const provider of providers) if (provider.processChecks?.some((processName) => checkProcess(processName, getAncestry()))) return createDetectedResult(provider);
281
+ }
282
+ return {
283
+ isAgentic: false,
284
+ id: null,
285
+ name: null,
286
+ type: null
287
+ };
288
+ }
289
+ function isAgent(envOrOptions, legacyAncestry) {
290
+ const result = detectAgenticEnvironment(envOrOptions, legacyAncestry);
291
+ return result.type === "agent" || result.type === "hybrid";
292
+ }
293
+ //#endregion
294
+ export { isAgent };
@@ -0,0 +1,94 @@
1
+ import os from "os";
2
+ import { execSync } from "child_process";
3
+ //#region ../../node_modules/.pnpm/process-ancestry@0.1.0/node_modules/process-ancestry/dist/index.js
4
+ function getProcessInfo(pid) {
5
+ try {
6
+ const output = execSync(`ps -p ${pid} -o pid=,ppid=,command=`, {
7
+ encoding: "utf8",
8
+ timeout: 5e3
9
+ }).trim();
10
+ if (!output) return null;
11
+ const [pidStr, ppidStr, ...commandParts] = output.split(/\s+/);
12
+ const parsedPid = pidStr ? parseInt(pidStr, 10) : NaN;
13
+ const parsedPpid = ppidStr ? parseInt(ppidStr, 10) : NaN;
14
+ if (isNaN(parsedPid) || isNaN(parsedPpid)) return null;
15
+ return {
16
+ pid: parsedPid,
17
+ ppid: parsedPpid,
18
+ command: commandParts.join(" ") || void 0
19
+ };
20
+ } catch (error) {
21
+ if (error instanceof Error && error.message.includes("timeout")) console.warn(`Process lookup timed out for PID ${pid}`);
22
+ return null;
23
+ }
24
+ }
25
+ function getAncestryUnix(startPid) {
26
+ const result = [];
27
+ const visited = /* @__PURE__ */ new Set();
28
+ let currentPid = startPid;
29
+ let maxDepth = 1e3;
30
+ while (currentPid && maxDepth > 0) {
31
+ if (visited.has(currentPid)) {
32
+ console.warn(`Detected cycle in process tree at PID ${currentPid}`);
33
+ break;
34
+ }
35
+ visited.add(currentPid);
36
+ const info = getProcessInfo(currentPid);
37
+ if (!info || info.ppid === 0 || info.ppid === 1) break;
38
+ result.push(info);
39
+ currentPid = info.ppid;
40
+ maxDepth--;
41
+ }
42
+ if (maxDepth === 0) console.warn(`Reached maximum depth limit while traversing process tree from PID ${startPid}`);
43
+ return result;
44
+ }
45
+ function getProcessInfo2(pid) {
46
+ try {
47
+ const output = execSync(`wmic process where (ProcessId=${pid}) get ProcessId,ParentProcessId,CommandLine /format:csv`, {
48
+ encoding: "utf8",
49
+ timeout: 1e4
50
+ });
51
+ if (!output) return null;
52
+ const fields = output.split("\n").filter((line) => line.trim() && !line.startsWith("Node")).pop()?.split(",");
53
+ if (!fields || fields.length < 4) return null;
54
+ const [_node, commandLine, parentPid, thisPid] = fields;
55
+ const parsedPid = thisPid ? parseInt(thisPid.trim(), 10) : NaN;
56
+ const parsedPpid = parentPid ? parseInt(parentPid.trim(), 10) : NaN;
57
+ if (isNaN(parsedPid) || isNaN(parsedPpid)) return null;
58
+ return {
59
+ pid: parsedPid,
60
+ ppid: parsedPpid,
61
+ command: commandLine?.trim() || void 0
62
+ };
63
+ } catch (error) {
64
+ if (error instanceof Error && error.message.includes("timeout")) console.warn(`Process lookup timed out for PID ${pid}`);
65
+ return null;
66
+ }
67
+ }
68
+ function getAncestryWindows(startPid) {
69
+ const result = [];
70
+ const visited = /* @__PURE__ */ new Set();
71
+ let currentPid = startPid;
72
+ let maxDepth = 1e3;
73
+ while (currentPid && maxDepth > 0) {
74
+ if (visited.has(currentPid)) {
75
+ console.warn(`Detected cycle in process tree at PID ${currentPid}`);
76
+ break;
77
+ }
78
+ visited.add(currentPid);
79
+ const info = getProcessInfo2(currentPid);
80
+ if (!info || info.ppid === 0 || info.ppid === 4) break;
81
+ result.push(info);
82
+ currentPid = info.ppid;
83
+ maxDepth--;
84
+ }
85
+ if (maxDepth === 0) console.warn(`Reached maximum depth limit while traversing process tree from PID ${startPid}`);
86
+ return result;
87
+ }
88
+ function getProcessAncestry(pid = process.pid) {
89
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) throw new Error("PID must be a positive integer");
90
+ if (os.platform() === "win32") return getAncestryWindows(pid);
91
+ else return getAncestryUnix(pid);
92
+ }
93
+ //#endregion
94
+ export { getProcessAncestry };
@@ -1,4 +1,4 @@
1
- import { getRequestExecutionContext } from "../../../shims/request-context.js";
1
+ import { getRequestExecutionContext } from "../../../../shims/request-context.js";
2
2
  //#region ../cloudflare/src/cache/cdn-adapter.runtime.ts
3
3
  function getWorkersCache() {
4
4
  const cache = getRequestExecutionContext()?.cache;
@@ -1,5 +1,5 @@
1
- import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../shims/cache-handler.js";
2
- import { ExecutionContextLike } from "../../../shims/request-context.js";
1
+ import { CacheHandler, CacheHandlerValue, IncrementalCacheValue } from "../../../../shims/cache-handler.js";
2
+ import { ExecutionContextLike } from "../../../../shims/request-context.js";
3
3
 
4
4
  //#region ../cloudflare/src/cache/kv-data-adapter.runtime.d.ts
5
5
  type KVNamespace = {
@@ -1,4 +1,4 @@
1
- import { getRequestExecutionContext } from "../../../shims/request-context.js";
1
+ import { getRequestExecutionContext } from "../../../../shims/request-context.js";
2
2
  import { isUnknownRecord, readCacheControlNumberField } from "../utils/cache-control-metadata.js";
3
3
  import { Buffer } from "node:buffer";
4
4
  //#region ../cloudflare/src/cache/kv-data-adapter.runtime.ts
@@ -0,0 +1,150 @@
1
+ import { findViteConfigPath } from "../../../utils/project.js";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ //#region ../cloudflare/src/deploy-config.ts
5
+ function escapeRegExp(value) {
6
+ return value.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
7
+ }
8
+ /**
9
+ * Check whether an existing vite.config file already imports and uses the
10
+ * Cloudflare Vite plugin. This is a heuristic text scan — it doesn't execute
11
+ * the config — so it may produce false negatives for unusual configurations.
12
+ *
13
+ * Returns true when the config both imports the package and invokes
14
+ * `cloudflare(...)` in the plugin list.
15
+ */
16
+ function viteConfigHasCloudflarePlugin(root) {
17
+ const configPath = findViteConfigPath(root);
18
+ if (!configPath) return false;
19
+ try {
20
+ const content = fs.readFileSync(configPath, "utf-8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
21
+ const requireBinding = content.match(/(?:const|let|var)\s*{([^}]*)}\s*=\s*require\s*\(\s*["']@cloudflare\/vite-plugin["']\s*\)/)?.[1];
22
+ if (requireBinding) {
23
+ const requireMatch = requireBinding.match(/(?:^|,)\s*cloudflare\s*(?::\s*([A-Za-z_$][\w$]*))?\s*(?:,|$)/);
24
+ if (requireMatch) {
25
+ const binding = requireMatch[1] ?? "cloudflare";
26
+ return new RegExp(`\\b${escapeRegExp(binding)}\\s*\\(`).test(content);
27
+ }
28
+ }
29
+ const namedImports = content.match(/import\s*{([^}]*)}\s*from\s*["']@cloudflare\/vite-plugin["']/)?.[1];
30
+ if (!namedImports) return false;
31
+ const importMatch = namedImports.match(/(?:^|,)\s*cloudflare\s*(?:as\s+([A-Za-z_$][\w$]*))?\s*(?:,|$)/);
32
+ if (!importMatch) return false;
33
+ const binding = importMatch[1] ?? "cloudflare";
34
+ return new RegExp(`\\b${escapeRegExp(binding)}\\s*\\(`).test(content);
35
+ } catch {
36
+ return false;
37
+ }
38
+ }
39
+ /**
40
+ * Extract the object-literal text of the `cache:` key (the `{ ... }` passed as
41
+ * `vinext({ cache })`) from a Vite config source, via brace matching. Returns
42
+ * null if there is no `cache:` object literal.
43
+ */
44
+ function extractCacheBlock(content) {
45
+ const m = /\bcache\s*:\s*\{/.exec(content);
46
+ if (!m) return null;
47
+ const open = m.index + m[0].length - 1;
48
+ let depth = 0;
49
+ for (let i = open; i < content.length; i++) {
50
+ const ch = content[i];
51
+ if (ch === "{") depth++;
52
+ else if (ch === "}" && --depth === 0) return content.slice(open, i + 1);
53
+ }
54
+ return null;
55
+ }
56
+ /**
57
+ * Whether a `cdn` / `data` field inside the cache object is assigned a real
58
+ * value (not absent, `undefined`, or `null`). Reads the value up to the next
59
+ * comma / closing brace / newline, which is enough to tell an assignment like
60
+ * `data: kvDataAdapter()` from `data: undefined`.
61
+ */
62
+ function cacheFieldAssigned(cacheBlock, field) {
63
+ const m = new RegExp(`\\b${field}\\s*:\\s*([^,}\\n]+)`).exec(cacheBlock);
64
+ if (!m) return false;
65
+ const value = m[1].trim();
66
+ return value.length > 0 && value !== "undefined" && value !== "null";
67
+ }
68
+ /**
69
+ * Detect whether the Vite config assigns a CDN or data cache adapter — i.e. the
70
+ * `cdn` or `data` field of the `vinext({ cache })` option is given a value.
71
+ * This is a source-level check on those exact object fields, not a fuzzy scan
72
+ * for adapter names. Mirrors {@link viteConfigHasCloudflarePlugin}'s leniency:
73
+ * an unreadable or absent config is treated as configured so a deploy is never
74
+ * blocked on a false negative.
75
+ */
76
+ function viteConfigHasCacheAdapter(root) {
77
+ const configPath = findViteConfigPath(root);
78
+ if (!configPath) return true;
79
+ let content;
80
+ try {
81
+ content = fs.readFileSync(configPath, "utf-8");
82
+ } catch {
83
+ return true;
84
+ }
85
+ const block = extractCacheBlock(content);
86
+ if (!block) return false;
87
+ return cacheFieldAssigned(block, "cdn") || cacheFieldAssigned(block, "data");
88
+ }
89
+ function viteConfigHasImageAdapter(root) {
90
+ const configPath = findViteConfigPath(root);
91
+ if (!configPath) return true;
92
+ try {
93
+ const content = fs.readFileSync(configPath, "utf-8");
94
+ const match = /\bimages\s*:\s*\{/.exec(content);
95
+ if (!match) return false;
96
+ const open = match.index + match[0].length - 1;
97
+ let depth = 0;
98
+ for (let index = open; index < content.length; index++) if (content[index] === "{") depth++;
99
+ else if (content[index] === "}" && --depth === 0) {
100
+ const optimizer = /\boptimizer\s*:\s*([^,}\n]+)/.exec(content.slice(open, index + 1))?.[1];
101
+ return Boolean(optimizer && !/^(?:undefined|null)$/.test(optimizer.trim()));
102
+ }
103
+ return false;
104
+ } catch {
105
+ return true;
106
+ }
107
+ }
108
+ /**
109
+ * Detect whether an existing user-authored Worker entry wires up a cache
110
+ * backend imperatively via one of the `setCacheHandler` / `setDataCacheHandler`
111
+ * / `setCdnCacheAdapter` setters. These setters are deprecated in favour of the
112
+ * declarative `vinext({ cache })` option, but older apps that scaffolded a KV
113
+ * cache handler into their Worker entry must keep working — so a deploy should
114
+ * not be blocked when the Worker entry already configures a backend.
115
+ *
116
+ * This is a heuristic text scan (it doesn't execute the entry), mirroring
117
+ * {@link viteConfigHasCacheAdapter}'s leniency: an unreadable Worker entry is
118
+ * treated as configured so a deploy is never blocked on a false negative. A
119
+ * missing Worker entry returns false (nothing to inspect — defer to other
120
+ * checks).
121
+ */
122
+ function workerEntryHasCacheHandler(root) {
123
+ const candidates = [path.join(root, "worker", "index.ts"), path.join(root, "worker", "index.js")];
124
+ for (const candidate of candidates) {
125
+ if (!fs.existsSync(candidate)) continue;
126
+ let content;
127
+ try {
128
+ content = fs.readFileSync(candidate, "utf-8");
129
+ } catch {
130
+ return true;
131
+ }
132
+ return /\b(?:setCacheHandler|setDataCacheHandler|setCdnCacheAdapter)\s*\(/.test(content);
133
+ }
134
+ return false;
135
+ }
136
+ /**
137
+ * Build the error thrown when an ISR/cached app is deployed without a cache
138
+ * adapter configured in the Vite config. Production deployments need a
139
+ * persistent cache backend; vinext no longer scaffolds one into the Worker
140
+ * entry, so it must be declared via `vinext({ cache })`.
141
+ */
142
+ function formatMissingCacheAdapterError(options) {
143
+ const configRef = options.configFile ? options.configFile : "your Vite config";
144
+ return `[vinext] This app uses ISR / caching but no cache adapter is configured in ${configRef}.\n\n Production deployments need a persistent cache backend. Declare one on the\n vinext() plugin in ${configRef}:\n\n import { kvDataAdapter } from "@vinext/cloudflare/cache/kv-data-adapter";\n\n export default defineConfig({\n plugins: [\n vinext({\n cache: {\n data: kvDataAdapter(), // KV-backed data cache (binding: VINEXT_KV_CACHE)\n },\n }),\n cloudflare(),\n ],\n });\n\n The VINEXT_KV_CACHE namespace binding is added to wrangler.jsonc for you.\n Create the namespace with:\n\n npx wrangler kv namespace create VINEXT_KV_CACHE`;
145
+ }
146
+ function formatImageOptimizationHint() {
147
+ return " [vinext] next/image is served unoptimized. To enable edge image\n optimization via Cloudflare Images, run:\n\n vinext init --platform=cloudflare --image-optimization=cloudflare-images\n\n This adds the imagesOptimizer() option to your Vite config and the matching\n IMAGES binding to your Wrangler config without replacing existing settings.";
148
+ }
149
+ //#endregion
150
+ export { formatImageOptimizationHint, formatMissingCacheAdapterError, viteConfigHasCacheAdapter, viteConfigHasCloudflarePlugin, viteConfigHasImageAdapter, workerEntryHasCacheHandler };
@@ -0,0 +1,55 @@
1
+ //#region ../cloudflare/src/deploy-help.ts
2
+ function formatDeployHelp() {
3
+ return `
4
+ vinext-cloudflare deploy - Deploy to Cloudflare Workers
5
+
6
+ Usage: vinext-cloudflare deploy [options]
7
+
8
+ One-command deployment to Cloudflare Workers. Automatically:
9
+ - Detects App Router or Pages Router
10
+ - Validates setup from vinext init --platform=cloudflare
11
+ - Builds the project with Vite
12
+ - Deploys via wrangler
13
+
14
+ Options:
15
+ --preview Deploy to preview environment (same as --env preview)
16
+ --env <name> Deploy using wrangler env.<name>
17
+ --name <name> Custom Worker name (default: from package.json)
18
+ --skip-build Skip the build step (use existing dist/)
19
+ --dry-run Validate setup without building or deploying
20
+ --prerender-all Pre-render discovered routes after building (future
21
+ releases will auto-populate the remote cache)
22
+ --prerender-concurrency <count>
23
+ Maximum number of routes to pre-render in parallel
24
+ -h, --help Show this help
25
+
26
+ Experimental:
27
+ --experimental-tpr Enable Traffic-aware Pre-Rendering
28
+ --tpr-coverage <pct> Traffic coverage target, 0-100 (default: 90)
29
+ --tpr-limit <count> Hard cap on pages to pre-render (default: 1000)
30
+ --tpr-window <hours> Analytics lookback window in hours (default: 24)
31
+
32
+ TPR (Traffic-aware Pre-Rendering) uses Cloudflare zone analytics to determine
33
+ which pages get the most traffic and pre-renders them into KV cache during
34
+ deploy. This feature is experimental and must be explicitly enabled. Requires
35
+ a custom domain (zone analytics are unavailable on *.workers.dev) and the
36
+ CLOUDFLARE_API_TOKEN environment variable with Zone.Analytics read permission.
37
+
38
+ Examples:
39
+ npx @vinext/cloudflare deploy Build and deploy to production
40
+ vpx @vinext/cloudflare deploy Build and deploy with Vite+
41
+ vp exec vinext-cloudflare deploy Run the locally installed Vite+ bin
42
+ vinext-cloudflare deploy --preview Deploy to a preview URL
43
+ vinext-cloudflare deploy --env staging Deploy using wrangler env.staging
44
+ vinext-cloudflare deploy --dry-run Validate setup without building or deploying
45
+ vinext-cloudflare deploy --name my-app Deploy with a custom Worker name
46
+ vinext-cloudflare deploy --experimental-tpr Enable TPR during deploy
47
+ vinext-cloudflare deploy --experimental-tpr --tpr-coverage 95 Cover 95% of traffic
48
+ vinext-cloudflare deploy --experimental-tpr --tpr-limit 500 Cap at 500 pages
49
+ `;
50
+ }
51
+ function printDeployHelp() {
52
+ console.log(formatDeployHelp());
53
+ }
54
+ //#endregion
55
+ export { printDeployHelp };