bun-workspaces 1.5.1 → 1.6.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 (260) hide show
  1. package/README.md +96 -2
  2. package/bin/cli.js +0 -0
  3. package/package.json +1 -5
  4. package/src/1108.mjs +30 -0
  5. package/src/{cli/commands/commandsConfig.mjs → 2392.mjs} +52 -11
  6. package/src/4427.mjs +9 -0
  7. package/src/5166.mjs +8 -0
  8. package/src/8126.mjs +4 -0
  9. package/src/8257.mjs +4 -0
  10. package/src/{config/util/configLocation.mjs → 8529.mjs} +11 -2
  11. package/src/ai/mcp/bwMcpServer.mjs +299 -9
  12. package/src/ai/mcp/core/index.mjs +3 -1
  13. package/src/ai/mcp/core/server.mjs +1 -3
  14. package/src/ai/mcp/core/transport.mjs +1 -2
  15. package/src/ai/mcp/core/types.mjs +0 -1
  16. package/src/ai/mcp/index.mjs +3 -1
  17. package/src/ai/mcp/resources.mjs +1 -2
  18. package/src/ai/mcp/tools.mjs +1 -5
  19. package/src/cli/commands/commandHandlerUtils.mjs +2 -6
  20. package/src/cli/commands/commands.mjs +1 -4
  21. package/src/cli/commands/handleSimpleCommands.mjs +4 -10
  22. package/src/cli/commands/index.mjs +11 -2
  23. package/src/cli/commands/mcp.mjs +1 -4
  24. package/src/cli/commands/runScript/handleRunScript.mjs +1 -9
  25. package/src/cli/commands/runScript/index.mjs +3 -1
  26. package/src/cli/commands/runScript/output/index.mjs +3 -1
  27. package/src/cli/commands/runScript/output/outputStyle.mjs +1 -3
  28. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +1 -6
  29. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +1 -2
  30. package/src/cli/commands/runScript/output/sanitizeChunk.mjs +0 -1
  31. package/src/cli/createCli.mjs +2 -12
  32. package/src/cli/fatalErrorLogger.mjs +1 -2
  33. package/src/cli/globalOptions/globalOptions.mjs +2 -9
  34. package/src/cli/globalOptions/index.mjs +3 -2
  35. package/src/cli/index.d.ts +1085 -3
  36. package/src/cli/index.mjs +3 -1
  37. package/src/cli/middleware.mjs +1 -3
  38. package/src/config/index.mjs +3 -1
  39. package/src/config/public.d.ts +151 -10
  40. package/src/config/public.mjs +4 -6
  41. package/src/config/rootConfig/defineRootConfig.mjs +1 -2
  42. package/src/config/rootConfig/errors.mjs +1 -2
  43. package/src/config/rootConfig/index.mjs +3 -1
  44. package/src/config/rootConfig/loadRootConfig.mjs +1 -4
  45. package/src/config/rootConfig/mergeRootConfig.mjs +24 -0
  46. package/src/config/rootConfig/rootConfig.mjs +8 -6
  47. package/src/config/rootConfig/rootConfigSchema.mjs +19 -1
  48. package/src/config/userEnvVars/index.mjs +3 -1
  49. package/src/config/userEnvVars/userEnvVars.mjs +3 -8
  50. package/src/config/util/ajvTypes.mjs +2 -1
  51. package/src/config/util/index.mjs +2 -1
  52. package/src/config/util/loadConfig.mjs +1 -6
  53. package/src/config/util/validateConfig.mjs +0 -1
  54. package/src/config/workspaceConfig/defineWorkspaceConfig.mjs +1 -2
  55. package/src/config/workspaceConfig/errors.mjs +1 -2
  56. package/src/config/workspaceConfig/index.mjs +3 -1
  57. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +2 -8
  58. package/src/config/workspaceConfig/mergeWorkspaceConfig.mjs +75 -0
  59. package/src/config/workspaceConfig/workspaceConfig.mjs +1 -13
  60. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +0 -1
  61. package/src/doctor/doctor.mjs +1 -5
  62. package/src/doctor/index.mjs +3 -1
  63. package/src/index.d.ts +516 -38
  64. package/src/index.mjs +4 -13
  65. package/src/internal/bun/bunLock.mjs +2 -4
  66. package/src/internal/bun/bunVersion.mjs +1 -3
  67. package/src/internal/bun/index.mjs +3 -1
  68. package/src/internal/bundledDeps/commander.mjs +3843 -0
  69. package/src/internal/bundledDeps/shellQuote.mjs +291 -0
  70. package/src/internal/core/error/error.mjs +0 -1
  71. package/src/internal/core/error/index.mjs +3 -1
  72. package/src/internal/core/index.mjs +3 -1
  73. package/src/internal/core/json/index.mjs +3 -1
  74. package/src/internal/core/json/json.mjs +3 -5
  75. package/src/internal/core/json/jsonc.mjs +0 -1
  76. package/src/internal/core/language/array/index.mjs +3 -1
  77. package/src/internal/core/language/array/optionalArray.mjs +0 -1
  78. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +0 -1
  79. package/src/internal/core/language/asyncIterable/index.mjs +3 -1
  80. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +0 -1
  81. package/src/internal/core/language/events/typedEventTarget.mjs +0 -1
  82. package/src/internal/core/language/index.mjs +3 -1
  83. package/src/internal/core/language/regex/index.mjs +3 -1
  84. package/src/internal/core/language/regex/regex.mjs +0 -1
  85. package/src/internal/core/language/string/id.mjs +0 -1
  86. package/src/internal/core/language/string/index.mjs +3 -1
  87. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +0 -1
  88. package/src/internal/core/language/string/utf/visibleLength.mjs +1 -2
  89. package/src/internal/core/language/types/index.mjs +3 -1
  90. package/src/internal/core/language/types/typeof.mjs +1 -3
  91. package/src/internal/core/language/types/types.mjs +3 -2
  92. package/src/internal/core/runtime/env.mjs +0 -1
  93. package/src/internal/core/runtime/index.mjs +3 -1
  94. package/src/internal/core/runtime/onExit.mjs +1 -2
  95. package/src/internal/core/runtime/os.mjs +1 -3
  96. package/src/internal/core/runtime/tempFile.mjs +1 -9
  97. package/src/internal/core/runtime/terminal.mjs +0 -1
  98. package/src/internal/generated/aiDocs/.gitkeep.mjs +1 -0
  99. package/src/internal/generated/aiDocs/docs.mjs +92 -15
  100. package/src/internal/generated/ajv/validateRootConfig.mjs +1 -1
  101. package/src/internal/logger/index.mjs +3 -1
  102. package/src/internal/logger/logger.mjs +4 -14
  103. package/src/internal/version.mjs +1 -2
  104. package/src/project/errors.mjs +1 -2
  105. package/src/project/implementations/fileSystemProject.mjs +4 -18
  106. package/src/project/implementations/memoryProject.mjs +1 -5
  107. package/src/project/implementations/projectBase.mjs +10 -19
  108. package/src/project/index.mjs +3 -1
  109. package/src/project/project.mjs +2 -1
  110. package/src/rslib-runtime.mjs +62 -0
  111. package/src/runScript/index.mjs +3 -1
  112. package/src/runScript/output/index.mjs +3 -1
  113. package/src/runScript/output/multiProcessOutput.mjs +1 -2
  114. package/src/runScript/output/outputStream.mjs +1 -1
  115. package/src/runScript/output/processOutput.mjs +1 -2
  116. package/src/runScript/parallel.mjs +4 -10
  117. package/src/runScript/recursion.mjs +1 -2
  118. package/src/runScript/runScript.mjs +1 -4
  119. package/src/runScript/runScripts.mjs +1 -6
  120. package/src/runScript/scriptCommand.mjs +1 -2
  121. package/src/runScript/scriptExecution.mjs +1 -3
  122. package/src/runScript/scriptRuntimeMetadata.mjs +38 -56
  123. package/src/runScript/scriptShellOption.mjs +5 -14
  124. package/src/runScript/subprocesses.mjs +1 -3
  125. package/src/workspaces/applyWorkspacePatternConfigs.mjs +58 -0
  126. package/src/workspaces/dependencyGraph/cycles.mjs +0 -1
  127. package/src/workspaces/dependencyGraph/index.mjs +3 -1
  128. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +1 -2
  129. package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +12 -13
  130. package/src/workspaces/errors.mjs +1 -2
  131. package/src/workspaces/findWorkspaces.mjs +11 -11
  132. package/src/workspaces/index.mjs +3 -1
  133. package/src/workspaces/packageJson.mjs +2 -7
  134. package/src/workspaces/workspace.mjs +2 -1
  135. package/src/workspaces/workspacePattern.mjs +4 -4
  136. package/src/ai/mcp/bwMcpServer.d.ts +0 -4
  137. package/src/ai/mcp/core/index.d.ts +0 -3
  138. package/src/ai/mcp/core/server.d.ts +0 -14
  139. package/src/ai/mcp/core/transport.d.ts +0 -12
  140. package/src/ai/mcp/core/types.d.ts +0 -104
  141. package/src/ai/mcp/index.d.ts +0 -2
  142. package/src/ai/mcp/resources.d.ts +0 -6
  143. package/src/ai/mcp/tools.d.ts +0 -6
  144. package/src/cli/commands/commandHandlerUtils.d.ts +0 -51
  145. package/src/cli/commands/commands.d.ts +0 -10
  146. package/src/cli/commands/commandsConfig.d.ts +0 -436
  147. package/src/cli/commands/handleSimpleCommands.d.ts +0 -21
  148. package/src/cli/commands/index.d.ts +0 -4
  149. package/src/cli/commands/mcp.d.ts +0 -3
  150. package/src/cli/commands/runScript/handleRunScript.d.ts +0 -3
  151. package/src/cli/commands/runScript/index.d.ts +0 -2
  152. package/src/cli/commands/runScript/output/index.d.ts +0 -1
  153. package/src/cli/commands/runScript/output/outputStyle.d.ts +0 -9
  154. package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +0 -75
  155. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +0 -24
  156. package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +0 -4
  157. package/src/cli/createCli.d.ts +0 -26
  158. package/src/cli/fatalErrorLogger.d.ts +0 -1
  159. package/src/cli/globalOptions/globalOptions.d.ts +0 -43
  160. package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -52
  161. package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -43
  162. package/src/cli/globalOptions/index.d.ts +0 -2
  163. package/src/cli/middleware.d.ts +0 -83
  164. package/src/config/index.d.ts +0 -3
  165. package/src/config/rootConfig/defineRootConfig.d.ts +0 -4
  166. package/src/config/rootConfig/errors.d.ts +0 -1
  167. package/src/config/rootConfig/index.d.ts +0 -5
  168. package/src/config/rootConfig/loadRootConfig.d.ts +0 -3
  169. package/src/config/rootConfig/rootConfig.d.ts +0 -25
  170. package/src/config/rootConfig/rootConfigLocation.d.ts +0 -2
  171. package/src/config/rootConfig/rootConfigLocation.mjs +0 -5
  172. package/src/config/rootConfig/rootConfigSchema.d.ts +0 -21
  173. package/src/config/userEnvVars/index.d.ts +0 -1
  174. package/src/config/userEnvVars/userEnvVars.d.ts +0 -13
  175. package/src/config/util/ajvTypes.d.ts +0 -10
  176. package/src/config/util/configLocation.d.ts +0 -18
  177. package/src/config/util/index.d.ts +0 -4
  178. package/src/config/util/loadConfig.d.ts +0 -18
  179. package/src/config/util/validateConfig.d.ts +0 -8
  180. package/src/config/workspaceConfig/defineWorkspaceConfig.d.ts +0 -7
  181. package/src/config/workspaceConfig/errors.d.ts +0 -1
  182. package/src/config/workspaceConfig/index.d.ts +0 -5
  183. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +0 -3
  184. package/src/config/workspaceConfig/workspaceConfig.d.ts +0 -56
  185. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +0 -2
  186. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +0 -5
  187. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +0 -56
  188. package/src/doctor/doctor.d.ts +0 -35
  189. package/src/doctor/index.d.ts +0 -1
  190. package/src/internal/bun/bunLock.d.ts +0 -20
  191. package/src/internal/bun/bunVersion.d.ts +0 -21
  192. package/src/internal/bun/index.d.ts +0 -2
  193. package/src/internal/core/error/error.d.ts +0 -13
  194. package/src/internal/core/error/index.d.ts +0 -1
  195. package/src/internal/core/index.d.ts +0 -4
  196. package/src/internal/core/json/index.d.ts +0 -2
  197. package/src/internal/core/json/json.d.ts +0 -49
  198. package/src/internal/core/json/jsonc.d.ts +0 -9
  199. package/src/internal/core/language/array/index.d.ts +0 -1
  200. package/src/internal/core/language/array/optionalArray.d.ts +0 -15
  201. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +0 -16
  202. package/src/internal/core/language/asyncIterable/index.d.ts +0 -2
  203. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +0 -5
  204. package/src/internal/core/language/events/typedEventTarget.d.ts +0 -50
  205. package/src/internal/core/language/index.d.ts +0 -5
  206. package/src/internal/core/language/regex/index.d.ts +0 -1
  207. package/src/internal/core/language/regex/regex.d.ts +0 -3
  208. package/src/internal/core/language/string/id.d.ts +0 -1
  209. package/src/internal/core/language/string/index.d.ts +0 -1
  210. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +0 -16
  211. package/src/internal/core/language/string/utf/visibleLength.d.ts +0 -5
  212. package/src/internal/core/language/types/index.d.ts +0 -2
  213. package/src/internal/core/language/types/typeof.d.ts +0 -102
  214. package/src/internal/core/language/types/types.d.ts +0 -19
  215. package/src/internal/core/runtime/env.d.ts +0 -6
  216. package/src/internal/core/runtime/index.d.ts +0 -5
  217. package/src/internal/core/runtime/onExit.d.ts +0 -4
  218. package/src/internal/core/runtime/os.d.ts +0 -6
  219. package/src/internal/core/runtime/tempFile.d.ts +0 -20
  220. package/src/internal/core/runtime/terminal.d.ts +0 -1
  221. package/src/internal/docs/apiQuickstart.d.ts +0 -3
  222. package/src/internal/docs/apiQuickstart.mjs +0 -132
  223. package/src/internal/docs/cliQuickstart.d.ts +0 -2
  224. package/src/internal/docs/cliQuickstart.mjs +0 -86
  225. package/src/internal/docs/index.d.ts +0 -2
  226. package/src/internal/docs/index.mjs +0 -2
  227. package/src/internal/generated/aiDocs/docs.d.ts +0 -10
  228. package/src/internal/logger/index.d.ts +0 -1
  229. package/src/internal/logger/logger.d.ts +0 -45
  230. package/src/internal/version.d.ts +0 -1
  231. package/src/project/errors.d.ts +0 -5
  232. package/src/project/implementations/fileSystemProject.d.ts +0 -148
  233. package/src/project/implementations/memoryProject.d.ts +0 -41
  234. package/src/project/implementations/projectBase.d.ts +0 -37
  235. package/src/project/index.d.ts +0 -5
  236. package/src/project/project.d.ts +0 -79
  237. package/src/runScript/index.d.ts +0 -7
  238. package/src/runScript/output/index.d.ts +0 -3
  239. package/src/runScript/output/multiProcessOutput.d.ts +0 -14
  240. package/src/runScript/output/outputStream.d.ts +0 -1
  241. package/src/runScript/output/processOutput.d.ts +0 -33
  242. package/src/runScript/parallel.d.ts +0 -24
  243. package/src/runScript/recursion.d.ts +0 -4
  244. package/src/runScript/runScript.d.ts +0 -45
  245. package/src/runScript/runScripts.d.ts +0 -65
  246. package/src/runScript/scriptCommand.d.ts +0 -33
  247. package/src/runScript/scriptExecution.d.ts +0 -9
  248. package/src/runScript/scriptRuntimeMetadata.d.ts +0 -73
  249. package/src/runScript/scriptShellOption.d.ts +0 -8
  250. package/src/runScript/subprocesses.d.ts +0 -11
  251. package/src/workspaces/dependencyGraph/cycles.d.ts +0 -9
  252. package/src/workspaces/dependencyGraph/index.d.ts +0 -3
  253. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +0 -18
  254. package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +0 -7
  255. package/src/workspaces/errors.d.ts +0 -14
  256. package/src/workspaces/findWorkspaces.d.ts +0 -24
  257. package/src/workspaces/index.d.ts +0 -4
  258. package/src/workspaces/packageJson.d.ts +0 -31
  259. package/src/workspaces/workspace.d.ts +0 -21
  260. package/src/workspaces/workspacePattern.d.ts +0 -22
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <a href="https://bunworkspaces.com">
2
- <img src="./packages/doc-website/src/pages/public/images/png/bwunster-bg-banner-wide_3000x900.png" alt="bun-workspaces" width="100%" />
2
+ <img src="./workspaces/web/documentation-website/src/pages/public/images/png/bwunster-bg-banner-wide_3000x900.png" alt="bun-workspaces" width="100%" />
3
3
  </a>
4
4
 
5
5
  # bun-workspaces
@@ -248,10 +248,104 @@ const runManyScripts = async () => {
248
248
  };
249
249
  ```
250
250
 
251
+ ### Configuration
252
+
253
+ `bun-workspaces` has no required configuration, but there are optional config files.
254
+
255
+ #### Workspace Config
256
+
257
+ Workspace configs can be placed in a workspace's directory at `bw.workspace.ts`.
258
+
259
+ [Workspace configuration documentation here](https://bunworkspaces.com/config/workspace)
260
+
261
+ ```typescript
262
+ // bw.workspace.ts — place in a workspace directory
263
+
264
+ // Also supported: bw.workspace.js, bw.workspace.json, bw.workspace.jsonc, or a "bw" key in package.json
265
+
266
+ import { defineWorkspaceConfig } from "bun-workspaces/config";
267
+
268
+ export default defineWorkspaceConfig({
269
+ alias: "my-web-app", // shorthand name; use array for multiple
270
+ tags: ["app", "frontend"],
271
+ scripts: {
272
+ // lower order runs first in sequenced script execution
273
+ build: { order: 1 },
274
+ test: { order: 2 },
275
+ },
276
+ rules: {
277
+ workspaceDependencies: {
278
+ // Only "my-workspace" or workspaces tagged "lib" are allowed as dependencies
279
+ allowPatterns: ["tag:lib", "my-workspace"],
280
+ // Workspaces tagged "backend" are forbidden as dependencies
281
+ denyPatterns: ["tag:backend"],
282
+ },
283
+ },
284
+ });
285
+ ```
286
+
287
+ #### Root Config
288
+
289
+ A root config can be placed in the project root directory at `bw.root.ts`,
290
+ which can also apply workspace configs in bulk by using workspace patterns.
291
+
292
+ [Root configuration documentation here](https://bunworkspaces.com/config/root)
293
+
294
+ [More on workspace pattern configs here](https://bunworkspaces.com/config/workspace-pattern-configs)
295
+
296
+ ```typescript
297
+ // bw.root.ts — place in your project root directory
298
+ // Also supported: bw.root.js, bw.root.json, bw.root.jsonc, or a "bw" key in package.json
299
+ import { defineRootConfig } from "bun-workspaces/config";
300
+
301
+ export default defineRootConfig({
302
+ defaults: {
303
+ // default value for --parallel option
304
+ parallelMax: 4,
305
+ // default value for --shell option
306
+ shell: "system",
307
+ // default value for global --include-root-workspace option
308
+ includeRootWorkspace: false,
309
+ },
310
+
311
+ // Apply workspace configs in bulk by workspace pattern, in order.
312
+ // Each entry merges into matching workspaces' accumulated config.
313
+ // Pattern matching reflects aliases and tags added by earlier entries.
314
+ workspacePatternConfigs: [
315
+ {
316
+ patterns: ["path:packages/apps/**/*"],
317
+ config: { tags: ["app"] },
318
+ },
319
+ {
320
+ patterns: ["path:packages/libs/**/*"],
321
+ config: { tags: ["lib"] },
322
+ },
323
+ {
324
+ // "tag:app" matches because the first entry added it
325
+ patterns: ["tag:app"],
326
+ config: {
327
+ rules: {
328
+ workspaceDependencies: {
329
+ allowPatterns: ["tag:lib"], // apps may only depend on libs
330
+ },
331
+ },
332
+ },
333
+ },
334
+ {
335
+ patterns: ["tag:app"],
336
+ // Factory form: receives static workspace data and accumulated config
337
+ config: (workspace, prevConfig) => ({
338
+ alias: workspace.name.replace(/^@my-scope\//, ""),
339
+ }),
340
+ },
341
+ ],
342
+ });
343
+ ```
344
+
251
345
  _`bun-workspaces` is independent from the [Bun](https://bun.sh) project and is not affiliated with or endorsed by Anthropic. This project aims to enhance the experience of Bun for its users._
252
346
 
253
347
  Developed By:
254
348
 
255
349
  <a href="https://smorsic.io" target="_blank" rel="noopener noreferrer">
256
- <img src="./packages/doc-website/src/pages/public/images/png/smorsic-banner_light_803x300.png" alt="Smorsic Labs logo" width="280" />
350
+ <img src="./workspaces/web/documentation-website/src/pages/public/images/png/smorsic-banner_light_803x300.png" alt="Smorsic Labs logo" width="280" />
257
351
  </a>
package/bin/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-workspaces",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "A monorepo management tool for Bun, with a CLI and API to enhance Bun's native workspaces.",
5
5
  "license": "MIT",
6
6
  "exports": {
@@ -43,9 +43,5 @@
43
43
  "build": "1.3.5",
44
44
  "libraryConsumer": "^1.2.0"
45
45
  }
46
- },
47
- "dependencies": {
48
- "commander": "^12.1.0",
49
- "shell-quote": "^1.8.3"
50
46
  }
51
47
  }
package/src/1108.mjs ADDED
@@ -0,0 +1,30 @@
1
+ const SCRIPT_RUNTIME_METADATA_CONFIG = {
2
+ projectPath: {
3
+ inlineName: "<projectPath>",
4
+ envVarName: "BW_PROJECT_PATH",
5
+ },
6
+ projectName: {
7
+ inlineName: "<projectName>",
8
+ envVarName: "BW_PROJECT_NAME",
9
+ },
10
+ workspacePath: {
11
+ inlineName: "<workspacePath>",
12
+ envVarName: "BW_WORKSPACE_PATH",
13
+ },
14
+ workspaceRelativePath: {
15
+ inlineName: "<workspaceRelativePath>",
16
+ envVarName: "BW_WORKSPACE_RELATIVE_PATH",
17
+ },
18
+ scriptName: {
19
+ inlineName: "<scriptName>",
20
+ envVarName: "BW_SCRIPT_NAME",
21
+ },
22
+ workspaceName: {
23
+ inlineName: "<workspaceName>",
24
+ envVarName: "BW_WORKSPACE_NAME",
25
+ },
26
+ };
27
+ const getScriptRuntimeMetadataConfig = (key) =>
28
+ SCRIPT_RUNTIME_METADATA_CONFIG[key];
29
+
30
+ export { getScriptRuntimeMetadataConfig };
@@ -1,9 +1,8 @@
1
- import { SCRIPT_SHELL_OPTIONS } from "../../runScript/scriptShellOption.mjs";
2
- import { OUTPUT_STYLE_VALUES } from "./runScript/output/outputStyle.mjs"; // CONCATENATED MODULE: external "../../runScript/scriptShellOption.mjs"
3
- // CONCATENATED MODULE: external "./runScript/output/outputStyle.mjs"
4
- // CONCATENATED MODULE: ./src/cli/commands/commandsConfig.ts
1
+ import { OUTPUT_STYLE_VALUES, SCRIPT_SHELL_OPTIONS } from "./4427.mjs";
2
+ import { LOG_LEVELS } from "./8126.mjs";
5
3
 
6
4
  const JSON_FLAGS = ["-j", "--json"];
5
+ const PRETTY_FLAGS = ["-p", "--pretty"];
7
6
  const CLI_COMMANDS_CONFIG = {
8
7
  doctor: {
9
8
  command: "doctor",
@@ -16,7 +15,7 @@ const CLI_COMMANDS_CONFIG = {
16
15
  description: "Output as JSON",
17
16
  },
18
17
  pretty: {
19
- flags: ["-p", "--pretty"],
18
+ flags: PRETTY_FLAGS,
20
19
  description: "Pretty print JSON",
21
20
  },
22
21
  },
@@ -40,7 +39,7 @@ const CLI_COMMANDS_CONFIG = {
40
39
  description: "Output as JSON",
41
40
  },
42
41
  pretty: {
43
- flags: ["-p", "--pretty"],
42
+ flags: PRETTY_FLAGS,
44
43
  description: "Pretty print JSON",
45
44
  },
46
45
  },
@@ -60,7 +59,7 @@ const CLI_COMMANDS_CONFIG = {
60
59
  description: "Output as JSON",
61
60
  },
62
61
  pretty: {
63
- flags: ["-p", "--pretty"],
62
+ flags: PRETTY_FLAGS,
64
63
  description: "Pretty print JSON",
65
64
  },
66
65
  },
@@ -76,7 +75,7 @@ const CLI_COMMANDS_CONFIG = {
76
75
  description: "Output as JSON",
77
76
  },
78
77
  pretty: {
79
- flags: ["-p", "--pretty"],
78
+ flags: PRETTY_FLAGS,
80
79
  description: "Pretty print JSON",
81
80
  },
82
81
  },
@@ -96,7 +95,7 @@ const CLI_COMMANDS_CONFIG = {
96
95
  description: "Output as JSON",
97
96
  },
98
97
  pretty: {
99
- flags: ["-p", "--pretty"],
98
+ flags: PRETTY_FLAGS,
100
99
  description: "Pretty print JSON",
101
100
  },
102
101
  },
@@ -116,7 +115,7 @@ const CLI_COMMANDS_CONFIG = {
116
115
  description: "Output as JSON",
117
116
  },
118
117
  pretty: {
119
- flags: ["-p", "--pretty"],
118
+ flags: PRETTY_FLAGS,
120
119
  description: "Pretty print JSON",
121
120
  },
122
121
  },
@@ -132,7 +131,7 @@ const CLI_COMMANDS_CONFIG = {
132
131
  description: "Output as JSON",
133
132
  },
134
133
  pretty: {
135
- flags: ["-p", "--pretty"],
134
+ flags: PRETTY_FLAGS,
136
135
  description: "Pretty print JSON",
137
136
  },
138
137
  },
@@ -217,9 +216,51 @@ const CLI_COMMANDS_CONFIG = {
217
216
  const getCliCommandConfig = (commandName) => CLI_COMMANDS_CONFIG[commandName];
218
217
  const getCliCommandNames = () => Object.keys(CLI_COMMANDS_CONFIG);
219
218
 
219
+ const CLI_GLOBAL_OPTIONS_CONFIG = {
220
+ logLevel: {
221
+ mainOption: "--log-level",
222
+ shortOption: "-l",
223
+ description: "Log levels",
224
+ defaultValue: "info",
225
+ values: [...LOG_LEVELS, "silent"],
226
+ param: "level",
227
+ },
228
+ cwd: {
229
+ mainOption: "--cwd",
230
+ shortOption: "-d",
231
+ description: "Working directory",
232
+ defaultValue: "",
233
+ values: null,
234
+ param: "path",
235
+ },
236
+ includeRoot: {
237
+ mainOption: "--include-root",
238
+ shortOption: "-r",
239
+ description: "Include the root workspace as a normal workspace",
240
+ defaultValue: "",
241
+ values: null,
242
+ param: "",
243
+ },
244
+ workspaceRoot: {
245
+ mainOption: "--workspace-root",
246
+ shortOption: "-w",
247
+ description:
248
+ "Run from the project root above the current working directory",
249
+ defaultValue: "",
250
+ values: null,
251
+ param: "",
252
+ },
253
+ };
254
+ const getCliGlobalOptionConfig = (optionName) =>
255
+ CLI_GLOBAL_OPTIONS_CONFIG[optionName];
256
+ const getCliGlobalOptionNames = () => Object.keys(CLI_GLOBAL_OPTIONS_CONFIG);
257
+
220
258
  export {
221
259
  CLI_COMMANDS_CONFIG,
222
260
  JSON_FLAGS,
261
+ PRETTY_FLAGS,
223
262
  getCliCommandConfig,
224
263
  getCliCommandNames,
264
+ getCliGlobalOptionConfig,
265
+ getCliGlobalOptionNames,
225
266
  };
package/src/4427.mjs ADDED
@@ -0,0 +1,9 @@
1
+ const SCRIPT_SHELL_OPTIONS = ["bun", "system"];
2
+ const OUTPUT_STYLE_VALUES = ["grouped", "prefixed", "plain", "none"];
3
+ const PARALLEL_MAX_VALUES = /* unused pure expression or super */ null && [
4
+ "auto",
5
+ "unbounded",
6
+ "default",
7
+ ];
8
+
9
+ export { OUTPUT_STYLE_VALUES, SCRIPT_SHELL_OPTIONS };
package/src/5166.mjs ADDED
@@ -0,0 +1,8 @@
1
+ const USER_ENV_VARS = {
2
+ parallelMaxDefault: "BW_PARALLEL_MAX_DEFAULT",
3
+ scriptShellDefault: "BW_SHELL_DEFAULT",
4
+ includeRootWorkspaceDefault: "BW_INCLUDE_ROOT_WORKSPACE_DEFAULT",
5
+ };
6
+ const getUserEnvVarName = (key) => USER_ENV_VARS[key];
7
+
8
+ export { USER_ENV_VARS, getUserEnvVarName };
package/src/8126.mjs ADDED
@@ -0,0 +1,4 @@
1
+ const LOG_LEVELS = ["debug", "info", "warn", "error"];
2
+ const getLogLevelNumber = (level) => LOG_LEVELS.indexOf(level);
3
+
4
+ export { LOG_LEVELS, getLogLevelNumber };
package/src/8257.mjs ADDED
@@ -0,0 +1,4 @@
1
+ const isJSONObject = (value) =>
2
+ typeof value === "object" && value !== null && value?.constructor === Object;
3
+
4
+ export { isJSONObject };
@@ -1,4 +1,7 @@
1
- // CONCATENATED MODULE: ./src/config/util/configLocation.ts
1
+ const ROOT_CONFIG_FILE_NAME = "bw.root";
2
+ const ROOT_CONFIG_PACKAGE_JSON_KEY = "bw-root";
3
+ const WORKSPACE_CONFIG_FILE_NAME = "bw.workspace";
4
+ const WORKSPACE_CONFIG_PACKAGE_JSON_KEY = "bw";
2
5
  const CONFIG_LOCATION_TYPES = [
3
6
  "tsFile",
4
7
  "jsFile",
@@ -16,4 +19,10 @@ const CONFIG_LOCATION_PATHS = {
16
19
  const createConfigLocationPath = (locationType, name, packageJsonKey) =>
17
20
  CONFIG_LOCATION_PATHS[locationType](name, packageJsonKey);
18
21
 
19
- export { CONFIG_LOCATION_TYPES, createConfigLocationPath };
22
+ export {
23
+ CONFIG_LOCATION_TYPES,
24
+ ROOT_CONFIG_FILE_NAME,
25
+ ROOT_CONFIG_PACKAGE_JSON_KEY,
26
+ WORKSPACE_CONFIG_FILE_NAME,
27
+ createConfigLocationPath,
28
+ };
@@ -1,15 +1,293 @@
1
1
  import package_0 from "../../../package.json";
2
- import { API_QUICKSTART } from "../../internal/docs/apiQuickstart.mjs";
3
- import { CLI_QUICKSTART } from "../../internal/docs/cliQuickstart.mjs";
4
2
  import { createMcpServer } from "./core/index.mjs";
5
3
  import { registerBwResources } from "./resources.mjs";
6
- import { registerBwTools } from "./tools.mjs"; // CONCATENATED MODULE: external "../../../package.json"
7
- // CONCATENATED MODULE: external "../../internal/docs/apiQuickstart.mjs"
8
- // CONCATENATED MODULE: external "../../internal/docs/cliQuickstart.mjs"
9
- // CONCATENATED MODULE: external "./core/index.mjs"
10
- // CONCATENATED MODULE: external "./resources.mjs"
11
- // CONCATENATED MODULE: external "./tools.mjs"
12
- // CONCATENATED MODULE: ./src/ai/mcp/bwMcpServer.ts
4
+ import { registerBwTools } from "./tools.mjs";
5
+
6
+ const CLI_QUICKSTART = `
7
+ # You can add this to .bashrc, .zshrc, or similar.
8
+ # You can also invoke "bw" in your root package.json scripts.
9
+ alias bw="bunx bun-workspaces"
10
+
11
+ # List all workspaces in your project
12
+ bw list-workspaces
13
+
14
+ # ls is an alias for list-workspaces
15
+ bw ls --json --pretty # Output as formatted JSON
16
+
17
+ # Get info about a workspace
18
+ bw workspace-info my-workspace
19
+ bw info my-workspace --json --pretty # info is alias for workspace-info
20
+
21
+ # Get info about a script, such as the workspaces that have it
22
+ bw script-info my-script
23
+
24
+ # Run the lint script for all workspaces
25
+ # that have it in their package.json "scripts" field
26
+ bw run-script lint
27
+
28
+ # run is an alias for run-script
29
+ bw run lint my-workspace # Run for a single workspace
30
+ bw run lint my-workspace-a my-workspace-b # Run for multiple workspaces
31
+ bw run lint my-alias-a my-alias-b # Run by alias (set by optional config)
32
+
33
+ # A workspace's script will wait until any workspaces it depends on have completed
34
+ # Similar to Bun's --filter behavior
35
+ bw run lint --dep-order
36
+
37
+ # Continue running scripts even if a dependency fails
38
+ bw run lint --dep-order --ignore-dep-failure
39
+
40
+ bw run lint "my-workspace-*" # Run for matching workspace names
41
+ bw run lint "alias:my-alias-*" "path:my-glob/**/*" "tag:my-tag" # Use matching specifiers
42
+ bw run lint "*" "not:path:my-path/*" # Run for all workspaces not in my-path/
43
+
44
+ bw run lint --args="--my-appended-args" # Add args to each script call
45
+ bw run lint --args="--my-arg=<workspaceName>" # Use the workspace name in args
46
+
47
+ bw run "bun build" --inline # Run an inline command via the Bun shell
48
+
49
+ # Scripts run in parallel by default
50
+ bw run lint --parallel=false # Run in series
51
+ bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
52
+ bw run lint --parallel=auto # Default, based on number of available logical CPUs
53
+ bw run lint --parallel=50% # Run in parallel with a max of 50% of the "auto" limit
54
+
55
+ # Use the grouped output style (default when on a TTY)
56
+ bw run my-script --output-style=grouped
57
+
58
+ # Set the max preview lines for script output in grouped output style
59
+ bw run my-script --output-style=grouped --grouped-lines=auto
60
+ bw run my-script --output-style=grouped --grouped-lines=10
61
+
62
+ # Use simple script output with workspace prefixes (default when not on a TTY)
63
+ bw run my-script --output-style=prefixed
64
+
65
+ # Use the plain output style (no workspace prefixes)
66
+ bw run my-script --output-style=plain
67
+
68
+ # Silence all output of the run command
69
+ bw --log-level=silent run my-script --output-style=none
70
+
71
+ # Show usage (you can pass --help to any command)
72
+ bw help
73
+ bw --help
74
+
75
+ # Show version
76
+ bw --version
77
+
78
+ # Pass --cwd to any command
79
+ bw --cwd=/path/to/your/project ls
80
+ bw --cwd=/path/to/your/project run my-script
81
+
82
+ # Pass --log-level to any command (debug, info, warn, error, or silent)
83
+ bw --log-level=debug ls
84
+ `.trim();
85
+ const INLINE_SCRIPT_EXAMPLE =
86
+ /* unused pure expression or super */ null &&
87
+ `
88
+ # Run an inline command from the workspace directory
89
+ bw run "bun run build" --inline
90
+ `.trim();
91
+
92
+ const RUN_WORKSPACE_SCRIPT_EXAMPLE = `
93
+ const { output, exit } = project.runWorkspaceScript({
94
+ workspaceNameOrAlias: "my-workspace",
95
+ script: "my-script",
96
+
97
+ // Optional. Arguments to add to the command
98
+ // Can be a string or an array of strings
99
+ // If string, the argv will be parsed POSIX-style
100
+ args: ["--my", "--appended", "--args"],
101
+
102
+ // Optional. Whether to ignore all output from the script.
103
+ // This saves memory when you don't need script output.
104
+ ignoreOutput: false,
105
+ });
106
+
107
+ // Get a stream of the script subprocess's output
108
+ for await (const { chunk, metadata } of output.text()) {
109
+ // console.log(chunk); // The output chunk's content (string)
110
+ // console.log(metadata.streamName); // The output stream, "stdout" or "stderr"
111
+ // console.log(metadata.workspace); // The target Workspace
112
+ }
113
+
114
+ // Get data about the script execution after it exits
115
+ const exitResult = await exit;
116
+
117
+ // exitResult.exitCode // The exit code (number)
118
+ // exitResult.signal // The exit signal (string), or null
119
+ // exitResult.success // true if exit code was 0
120
+ // exitResult.startTimeISO // Start time (string)
121
+ // exitResult.endTimeISO // End time (string)
122
+ // exitResult.durationMs // Duration in milliseconds (number)
123
+ // exitResult.metadata.workspace // The target workspace (Workspace)
124
+
125
+ `.trim();
126
+ const RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE = `
127
+
128
+ const { output, summary } = project.runScriptAcrossWorkspaces({
129
+ // Optional. This will run in all matching workspaces that have my-script
130
+ // Accepts same values as the CLI run-script command's workspace patterns
131
+ // When not provided, all workspaces that have the script will be used.
132
+ workspacePatterns: ["my-workspace", "my-name-pattern-*"],
133
+
134
+ // Required. The package.json "scripts" field name to run
135
+ script: "my-script",
136
+
137
+ // Optional. Arguments to add to the command (same as for runWorkspaceScript)
138
+ args: ["--my", "--appended", "--args"],
139
+
140
+ // Optional. Whether to run the scripts in parallel (default: true)
141
+ parallel: true,
142
+
143
+ // Optional. When true, a workspace's script will wait
144
+ // until any workspaces it depends on have completed
145
+ dependencyOrder: false,
146
+
147
+ // Optional. When true and dependencyOrder is true,
148
+ // continue running scripts even if a dependency fails
149
+ ignoreDependencyFailure: false,
150
+
151
+ // Optional. Whether to ignore all output from the scripts.
152
+ // This saves memory when you don't need script output.
153
+ ignoreOutput: false,
154
+
155
+ // Optional, callback when script starts, skips, or exits
156
+ onScriptEvent: (event, { workspace, exitResult }) => {
157
+ // event: "start", "skip", "exit"
158
+ }
159
+ });
160
+
161
+ // Get a stream of script output
162
+ for await (const { chunk, metadata } of output.text()) {
163
+ // console.log(chunk); // the output chunk's content (string)
164
+ // console.log(metadata.streamName); // "stdout" or "stderr"
165
+ // console.log(metadata.workspace); // the Workspace that the output came from
166
+ }
167
+
168
+ // Get final summary data and script exit details after all scripts have completed
169
+ const summaryResult = await summary;
170
+
171
+ // summaryResult.totalCount // Total number of scripts
172
+ // summaryResult.allSuccess // true if all scripts succeeded
173
+ // summaryResult.successCount // Number of scripts that succeeded
174
+ // summaryResult.failureCount // Number of scripts that failed
175
+ // summaryResult.startTimeISO // Start time (string)
176
+ // summaryResult.endTimeISO // End time (string)
177
+ // summaryResult.durationMs // Total duration in milliseconds (number)
178
+
179
+ // The exit details of each workspace script
180
+ for (const exitResult of summaryResult.scriptResults) {
181
+ // exitResult.exitCode // The exit code (number)
182
+ // exitResult.signal // The exit signal (string), or null
183
+ // exitResult.success // true if exit code was 0
184
+ // exitResult.startTimeISO // Start time (ISO string)
185
+ // exitResult.endTimeISO // End time (ISO string)
186
+ // exitResult.durationMs // Duration in milliseconds (number)
187
+ // exitResult.metadata.workspace // The target workspace (Workspace)
188
+ }
189
+ `.trim();
190
+ const API_QUICKSTART = `
191
+ import { createFileSystemProject } from "bun-workspaces";
192
+
193
+ // A Project contains the core functionality of bun-workspaces.
194
+ // Below defaults to process.cwd() for the project root directory
195
+ // Pass { rootDirectory: "path/to/your/project" } to use a different root directory
196
+ const project = createFileSystemProject();
197
+
198
+ // A Workspace that matches the name or alias "my-workspace"
199
+ const myWorkspace = project.findWorkspaceByNameOrAlias("my-workspace");
200
+
201
+ // Array of workspaces whose names match the wildcard pattern
202
+ const wildcardWorkspaces = project.findWorkspacesByPattern("my-workspace-*");
203
+
204
+ // Array of workspaces that have "my-script" in their package.json "scripts"
205
+ const workspacesWithScript = project.listWorkspacesWithScript("my-script");
206
+
207
+ // Run a script in a workspace
208
+ const runSingleScript = async () => {
209
+ ${RUN_WORKSPACE_SCRIPT_EXAMPLE.split("\n").join("\n ")}
210
+ }
211
+
212
+ // Run a script in all workspaces that have it in their package.json "scripts" field
213
+ const runManyScripts = async () => {
214
+ ${RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE.split("\n").join("\n ")}
215
+ }
216
+ `.trim();
217
+
218
+ const ROOT_CONFIG_QUICKSTART = `
219
+ // bw.root.ts — place in your project root directory
220
+ // Also supported: bw.root.js, bw.root.json, bw.root.jsonc, or a "bw" key in package.json
221
+ import { defineRootConfig } from "bun-workspaces/config";
222
+
223
+ export default defineRootConfig({
224
+ defaults: {
225
+ // default value for --parallel option
226
+ parallelMax: 4,
227
+ // default value for --shell option
228
+ shell: "system",
229
+ // default value for global --include-root-workspace option
230
+ includeRootWorkspace: false,
231
+ },
232
+
233
+ // Apply workspace configs in bulk by workspace pattern, in order.
234
+ // Each entry merges into matching workspaces' accumulated config.
235
+ // Pattern matching reflects aliases and tags added by earlier entries.
236
+ workspacePatternConfigs: [
237
+ {
238
+ patterns: ["path:packages/apps/**/*"],
239
+ config: { tags: ["app"] },
240
+ },
241
+ {
242
+ patterns: ["path:packages/libs/**/*"],
243
+ config: { tags: ["lib"] },
244
+ },
245
+ {
246
+ // "tag:app" matches because the first entry added it
247
+ patterns: ["tag:app"],
248
+ config: {
249
+ rules: {
250
+ workspaceDependencies: {
251
+ allowPatterns: ["tag:lib"], // apps may only depend on libs
252
+ },
253
+ },
254
+ },
255
+ },
256
+ {
257
+ patterns: ["tag:app"],
258
+ // Factory form: receives static workspace data and accumulated config
259
+ config: (workspace, prevConfig) => ({
260
+ alias: workspace.name.replace(/^@my-scope\\//, ""),
261
+ }),
262
+ },
263
+ ],
264
+ });
265
+ `.trim();
266
+ const WORKSPACE_CONFIG_QUICKSTART = `
267
+ // bw.workspace.ts — place in a workspace directory
268
+
269
+ // Also supported: bw.workspace.js, bw.workspace.json, bw.workspace.jsonc, or a "bw" key in package.json
270
+
271
+ import { defineWorkspaceConfig } from "bun-workspaces/config";
272
+
273
+ export default defineWorkspaceConfig({
274
+ alias: "my-web-app", // shorthand name; use array for multiple
275
+ tags: ["app", "frontend"],
276
+ scripts: {
277
+ // lower order runs first in sequenced script execution
278
+ build: { order: 1 },
279
+ test: { order: 2 },
280
+ },
281
+ rules: {
282
+ workspaceDependencies: {
283
+ // Only "my-workspace" or workspaces tagged "lib" are allowed as dependencies
284
+ allowPatterns: ["tag:lib", "my-workspace"],
285
+ // Workspaces tagged "backend" are forbidden as dependencies
286
+ denyPatterns: ["tag:backend"],
287
+ },
288
+ },
289
+ });
290
+ `.trim();
13
291
 
14
292
  const SERVER_INSTRUCTIONS = `
15
293
  bun-workspaces MCP server: tools to query Bun monorepo workspace metadata and documentation resources for the bun-workspaces CLI and TypeScript API.
@@ -31,6 +309,18 @@ ${CLI_QUICKSTART}
31
309
  \`\`\`typescript
32
310
  ${API_QUICKSTART}
33
311
  \`\`\`
312
+
313
+ ## Root config quickstart
314
+
315
+ \`\`\`typescript
316
+ ${ROOT_CONFIG_QUICKSTART}
317
+ \`\`\`
318
+
319
+ ## Workspace config quickstart
320
+
321
+ \`\`\`typescript
322
+ ${WORKSPACE_CONFIG_QUICKSTART}
323
+ \`\`\`
34
324
  `.trim();
35
325
  const startBwMcpServer = async (project) => {
36
326
  const server = createMcpServer({
@@ -1,3 +1,5 @@
1
1
  export * from "./types.mjs";
2
2
  export * from "./transport.mjs";
3
- export * from "./server.mjs"; // CONCATENATED MODULE: ./src/ai/mcp/core/index.ts
3
+ export * from "./server.mjs";
4
+
5
+ export {};
@@ -1,7 +1,5 @@
1
1
  import { createStdioTransport } from "./transport.mjs";
2
- import { JSON_RPC_ERROR_CODES, MCP_PROTOCOL_VERSION } from "./types.mjs"; // CONCATENATED MODULE: external "./transport.mjs"
3
- // CONCATENATED MODULE: external "./types.mjs"
4
- // CONCATENATED MODULE: ./src/ai/mcp/core/server.ts
2
+ import { JSON_RPC_ERROR_CODES, MCP_PROTOCOL_VERSION } from "./types.mjs";
5
3
 
6
4
  const createMcpServer = (info) => {
7
5
  const tools = new Map();