claude-mem 3.3.7 → 3.3.9

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 (96) hide show
  1. package/README.md +183 -46
  2. package/dist/bin/cli.d.ts +2 -0
  3. package/dist/bin/cli.js +179 -0
  4. package/dist/commands/compress.d.ts +2 -0
  5. package/dist/commands/compress.js +27 -0
  6. package/dist/commands/hooks.d.ts +19 -0
  7. package/dist/commands/hooks.js +131 -0
  8. package/dist/commands/install.d.ts +2 -0
  9. package/dist/commands/install.js +836 -0
  10. package/dist/commands/load-context.d.ts +2 -0
  11. package/dist/commands/load-context.js +151 -0
  12. package/dist/commands/logs.d.ts +2 -0
  13. package/dist/commands/logs.js +76 -0
  14. package/dist/commands/migrate-to-jsonl.d.ts +5 -0
  15. package/dist/commands/migrate-to-jsonl.js +99 -0
  16. package/dist/commands/restore.d.ts +1 -0
  17. package/dist/commands/restore.js +20 -0
  18. package/dist/commands/status.d.ts +1 -0
  19. package/dist/commands/status.js +136 -0
  20. package/dist/commands/trash-empty.d.ts +3 -0
  21. package/dist/commands/trash-empty.js +56 -0
  22. package/dist/commands/trash-view.d.ts +1 -0
  23. package/dist/commands/trash-view.js +101 -0
  24. package/dist/commands/trash.d.ts +6 -0
  25. package/dist/commands/trash.js +49 -0
  26. package/dist/commands/uninstall.d.ts +2 -0
  27. package/dist/commands/uninstall.js +107 -0
  28. package/dist/constants.d.ts +271 -0
  29. package/dist/constants.js +199 -0
  30. package/dist/core/compression/TranscriptCompressor.d.ts +79 -0
  31. package/dist/core/compression/TranscriptCompressor.js +585 -0
  32. package/dist/core/orchestration/PromptOrchestrator.d.ts +165 -0
  33. package/dist/core/orchestration/PromptOrchestrator.js +182 -0
  34. package/dist/lib/time-utils.d.ts +5 -0
  35. package/dist/lib/time-utils.js +70 -0
  36. package/dist/prompts/constants.d.ts +126 -0
  37. package/dist/prompts/constants.js +161 -0
  38. package/dist/prompts/index.d.ts +10 -0
  39. package/dist/prompts/index.js +11 -0
  40. package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +13 -0
  41. package/dist/prompts/templates/analysis/AnalysisTemplates.js +94 -0
  42. package/dist/prompts/templates/context/ContextTemplates.d.ts +119 -0
  43. package/dist/prompts/templates/context/ContextTemplates.js +399 -0
  44. package/dist/prompts/templates/hooks/HookTemplates.d.ts +175 -0
  45. package/dist/prompts/templates/hooks/HookTemplates.js +394 -0
  46. package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +7 -0
  47. package/dist/prompts/templates/hooks/HookTemplates.test.js +127 -0
  48. package/dist/shared/config.d.ts +4 -0
  49. package/dist/shared/config.js +41 -0
  50. package/dist/shared/error-handler.d.ts +22 -0
  51. package/dist/shared/error-handler.js +142 -0
  52. package/dist/shared/logger.d.ts +19 -0
  53. package/dist/shared/logger.js +51 -0
  54. package/dist/shared/paths.d.ts +28 -0
  55. package/dist/shared/paths.js +100 -0
  56. package/dist/shared/settings.d.ts +41 -0
  57. package/dist/shared/settings.js +81 -0
  58. package/dist/shared/types.d.ts +145 -0
  59. package/dist/shared/types.js +78 -0
  60. package/docs/STATUS.md +155 -0
  61. package/docs/chroma-backend-migration.md +161 -0
  62. package/docs/landing-page-outline.md +287 -0
  63. package/docs/multi-platform-builds.md +96 -0
  64. package/docs/plans/cloud-service-plan.md +274 -0
  65. package/docs/plans/fix-response-format-issue.md +61 -0
  66. package/docs/plans/restructure-session-hook-output.md +102 -0
  67. package/docs/plans/session-start-hook-investigation.md +45 -0
  68. package/docs/plans/src-reorganization-plan.md +181 -0
  69. package/docs/plans/terminal-effects-decision.md +22 -0
  70. package/docs/plans/terminal-effects-integration.md +82 -0
  71. package/docs/plans/trash-bin-feature-plan.md +240 -0
  72. package/docs/plans/trash-bin-minimal-plan.md +102 -0
  73. package/docs/reference/bun-single-executable.md +584 -0
  74. package/docs/reference/cc-output-styles.md +99 -0
  75. package/docs/reference/chroma-mcp-project-memory-example.md +80 -0
  76. package/docs/reference/chroma-mcp-team-example.md +92 -0
  77. package/docs/reference/claude-code/cc-hooks.md +787 -0
  78. package/docs/reference/claude-code/cc-status-line.md +202 -0
  79. package/docs/reference/claude-code/hook-configuration.md +173 -0
  80. package/docs/reference/claude-code/hook-responses.md +127 -0
  81. package/docs/reference/claude-code/hooks.md +175 -0
  82. package/docs/reference/claude-code/mcp-configuration.md +133 -0
  83. package/docs/reference/claude-code/session-start-hook.md +82 -0
  84. package/docs/reference/load-context-format-example.md +33 -0
  85. package/docs/reference/mcp-sdk/mcp-typescript-sdk-readme.md +1323 -0
  86. package/docs/reference/mcp-sdk/server-implementation.md +286 -0
  87. package/docs/reference/mcp-sdk/stdio-transport.md +345 -0
  88. package/docs/todos/fix-response-format-tasks.md +43 -0
  89. package/docs/todos/implementation-todos.md +280 -0
  90. package/docs/todos/restructure-hook-output-tasks.md +103 -0
  91. package/docs/todos/session-start-hook-fix.md +26 -0
  92. package/docs/todos/terminal-effects-tasks.md +42 -0
  93. package/docs/todos/trash-bin-implementation-todos.md +348 -0
  94. package/docs/todos/trash-bin-minimal-todos.md +27 -0
  95. package/package.json +56 -6
  96. package/claude-mem +0 -0
@@ -0,0 +1,584 @@
1
+ Bun's bundler implements a `--compile` flag for generating a standalone binary from a TypeScript or JavaScript file.
2
+
3
+ {% codetabs %}
4
+
5
+ ```bash
6
+ $ bun build ./cli.ts --compile --outfile mycli
7
+ ```
8
+
9
+ ```ts#cli.ts
10
+ console.log("Hello world!");
11
+ ```
12
+
13
+ {% /codetabs %}
14
+
15
+ This bundles `cli.ts` into an executable that can be executed directly:
16
+
17
+ ```
18
+ $ ./mycli
19
+ Hello world!
20
+ ```
21
+
22
+ All imported files and packages are bundled into the executable, along with a copy of the Bun runtime. All built-in Bun and Node.js APIs are supported.
23
+
24
+ ## Cross-compile to other platforms
25
+
26
+ The `--target` flag lets you compile your standalone executable for a different operating system, architecture, or version of Bun than the machine you're running `bun build` on.
27
+
28
+ To build for Linux x64 (most servers):
29
+
30
+ ```sh
31
+ bun build --compile --target=bun-linux-x64 ./index.ts --outfile myapp
32
+
33
+ # To support CPUs from before 2013, use the baseline version (nehalem)
34
+ bun build --compile --target=bun-linux-x64-baseline ./index.ts --outfile myapp
35
+
36
+ # To explicitly only support CPUs from 2013 and later, use the modern version (haswell)
37
+ # modern is faster, but baseline is more compatible.
38
+ bun build --compile --target=bun-linux-x64-modern ./index.ts --outfile myapp
39
+ ```
40
+
41
+ To build for Linux ARM64 (e.g. Graviton or Raspberry Pi):
42
+
43
+ ```sh
44
+ # Note: the default architecture is x64 if no architecture is specified.
45
+ bun build --compile --target=bun-linux-arm64 ./index.ts --outfile myapp
46
+ ```
47
+
48
+ To build for Windows x64:
49
+
50
+ ```sh
51
+ bun build --compile --target=bun-windows-x64 ./path/to/my/app.ts --outfile myapp
52
+
53
+ # To support CPUs from before 2013, use the baseline version (nehalem)
54
+ bun build --compile --target=bun-windows-x64-baseline ./path/to/my/app.ts --outfile myapp
55
+
56
+ # To explicitly only support CPUs from 2013 and later, use the modern version (haswell)
57
+ bun build --compile --target=bun-windows-x64-modern ./path/to/my/app.ts --outfile myapp
58
+
59
+ # note: if no .exe extension is provided, Bun will automatically add it for Windows executables
60
+ ```
61
+
62
+ To build for macOS arm64:
63
+
64
+ ```sh
65
+ bun build --compile --target=bun-darwin-arm64 ./path/to/my/app.ts --outfile myapp
66
+ ```
67
+
68
+ To build for macOS x64:
69
+
70
+ ```sh
71
+ bun build --compile --target=bun-darwin-x64 ./path/to/my/app.ts --outfile myapp
72
+ ```
73
+
74
+ #### Supported targets
75
+
76
+ The order of the `--target` flag does not matter, as long as they're delimited by a `-`.
77
+
78
+ | --target | Operating System | Architecture | Modern | Baseline | Libc |
79
+ | --------------------- | ---------------- | ------------ | ------ | -------- | ----- |
80
+ | bun-linux-x64 | Linux | x64 | ✅ | ✅ | glibc |
81
+ | bun-linux-arm64 | Linux | arm64 | ✅ | N/A | glibc |
82
+ | bun-windows-x64 | Windows | x64 | ✅ | ✅ | - |
83
+ | ~~bun-windows-arm64~~ | Windows | arm64 | ❌ | ❌ | - |
84
+ | bun-darwin-x64 | macOS | x64 | ✅ | ✅ | - |
85
+ | bun-darwin-arm64 | macOS | arm64 | ✅ | N/A | - |
86
+ | bun-linux-x64-musl | Linux | x64 | ✅ | ✅ | musl |
87
+ | bun-linux-arm64-musl | Linux | arm64 | ✅ | N/A | musl |
88
+
89
+ On x64 platforms, Bun uses SIMD optimizations which require a modern CPU supporting AVX2 instructions. The `-baseline` build of Bun is for older CPUs that don't support these optimizations. Normally, when you install Bun we automatically detect which version to use but this can be harder to do when cross-compiling since you might not know the target CPU. You usually don't need to worry about it on Darwin x64, but it is relevant for Windows x64 and Linux x64. If you or your users see `"Illegal instruction"` errors, you might need to use the baseline version.
90
+
91
+ ## Build-time constants
92
+
93
+ Use the `--define` flag to inject build-time constants into your executable, such as version numbers, build timestamps, or configuration values:
94
+
95
+ ```bash
96
+ $ bun build --compile --define BUILD_VERSION='"1.2.3"' --define BUILD_TIME='"2024-01-15T10:30:00Z"' src/cli.ts --outfile mycli
97
+ ```
98
+
99
+ These constants are embedded directly into your compiled binary at build time, providing zero runtime overhead and enabling dead code elimination optimizations.
100
+
101
+ {% callout type="info" %}
102
+ For comprehensive examples and advanced patterns, see the [Build-time constants guide](/guides/runtime/build-time-constants).
103
+ {% /callout %}
104
+
105
+ ## Deploying to production
106
+
107
+ Compiled executables reduce memory usage and improve Bun's start time.
108
+
109
+ Normally, Bun reads and transpiles JavaScript and TypeScript files on `import` and `require`. This is part of what makes so much of Bun "just work", but it's not free. It costs time and memory to read files from disk, resolve file paths, parse, transpile, and print source code.
110
+
111
+ With compiled executables, you can move that cost from runtime to build-time.
112
+
113
+ When deploying to production, we recommend the following:
114
+
115
+ ```sh
116
+ bun build --compile --minify --sourcemap ./path/to/my/app.ts --outfile myapp
117
+ ```
118
+
119
+ ### Bytecode compilation
120
+
121
+ To improve startup time, enable bytecode compilation:
122
+
123
+ ```sh
124
+ bun build --compile --minify --sourcemap --bytecode ./path/to/my/app.ts --outfile myapp
125
+ ```
126
+
127
+ Using bytecode compilation, `tsc` starts 2x faster:
128
+
129
+ {% image src="https://github.com/user-attachments/assets/dc8913db-01d2-48f8-a8ef-ac4e984f9763" width="689" /%}
130
+
131
+ Bytecode compilation moves parsing overhead for large input files from runtime to bundle time. Your app starts faster, in exchange for making the `bun build` command a little slower. It doesn't obscure source code.
132
+
133
+ **Experimental:** Bytecode compilation is an experimental feature introduced in Bun v1.1.30. Only `cjs` format is supported (which means no top-level-await). Let us know if you run into any issues!
134
+
135
+ ### What do these flags do?
136
+
137
+ The `--minify` argument optimizes the size of the transpiled output code. If you have a large application, this can save megabytes of space. For smaller applications, it might still improve start time a little.
138
+
139
+ The `--sourcemap` argument embeds a sourcemap compressed with zstd, so that errors & stacktraces point to their original locations instead of the transpiled location. Bun will automatically decompress & resolve the sourcemap when an error occurs.
140
+
141
+ The `--bytecode` argument enables bytecode compilation. Every time you run JavaScript code in Bun, JavaScriptCore (the engine) will compile your source code into bytecode. We can move this parsing work from runtime to bundle time, saving you startup time.
142
+
143
+ ## Act as the Bun CLI
144
+
145
+ {% note %}
146
+
147
+ New in Bun v1.2.16
148
+
149
+ {% /note %}
150
+
151
+ You can run a standalone executable as if it were the `bun` CLI itself by setting the `BUN_BE_BUN=1` environment variable. When this variable is set, the executable will ignore its bundled entrypoint and instead expose all the features of Bun's CLI.
152
+
153
+ For example, consider an executable compiled from a simple script:
154
+
155
+ ```sh
156
+ $ cat such-bun.js
157
+ console.log("you shouldn't see this");
158
+
159
+ $ bun build --compile ./such-bun.js
160
+ [3ms] bundle 1 modules
161
+ [89ms] compile such-bun
162
+ ```
163
+
164
+ Normally, running `./such-bun` with arguments would execute the script. However, with the `BUN_BE_BUN=1` environment variable, it acts just like the `bun` binary:
165
+
166
+ ```sh
167
+ # Executable runs its own entrypoint by default
168
+ $ ./such-bun install
169
+ you shouldn't see this
170
+
171
+ # With the env var, the executable acts like the `bun` CLI
172
+ $ BUN_BE_BUN=1 ./such-bun install
173
+ bun install v1.2.16-canary.1 (1d1db811)
174
+ Checked 63 installs across 64 packages (no changes) [5.00ms]
175
+ ```
176
+
177
+ This is useful for building CLI tools on top of Bun that may need to install packages, bundle dependencies, run different or local files and more without needing to download a separate binary or install bun.
178
+
179
+ ## Full-stack executables
180
+
181
+ {% note %}
182
+
183
+ New in Bun v1.2.17
184
+
185
+ {% /note %}
186
+
187
+ Bun's `--compile` flag can create standalone executables that contain both server and client code, making it ideal for full-stack applications. When you import an HTML file in your server code, Bun automatically bundles all frontend assets (JavaScript, CSS, etc.) and embeds them into the executable. When Bun sees the HTML import on the server, it kicks off a frontend build process to bundle JavaScript, CSS, and other assets.
188
+
189
+ {% codetabs %}
190
+
191
+ ```ts#server.ts
192
+ import { serve } from "bun";
193
+ import index from "./index.html";
194
+
195
+ const server = serve({
196
+ routes: {
197
+ "/": index,
198
+ "/api/hello": { GET: () => Response.json({ message: "Hello from API" }) },
199
+ },
200
+ });
201
+
202
+ console.log(`Server running at http://localhost:${server.port}`);
203
+ ```
204
+
205
+ ```html#index.html
206
+ <!DOCTYPE html>
207
+ <html>
208
+ <head>
209
+ <title>My App</title>
210
+ <link rel="stylesheet" href="./styles.css">
211
+ </head>
212
+ <body>
213
+ <h1>Hello World</h1>
214
+ <script src="./app.js"></script>
215
+ </body>
216
+ </html>
217
+ ```
218
+
219
+ ```js#app.js
220
+ console.log("Hello from the client!");
221
+ ```
222
+
223
+ ```css#styles.css
224
+ body {
225
+ background-color: #f0f0f0;
226
+ }
227
+ ```
228
+
229
+ {% /codetabs %}
230
+
231
+ To build this into a single executable:
232
+
233
+ ```sh
234
+ bun build --compile ./server.ts --outfile myapp
235
+ ```
236
+
237
+ This creates a self-contained binary that includes:
238
+
239
+ - Your server code
240
+ - The Bun runtime
241
+ - All frontend assets (HTML, CSS, JavaScript)
242
+ - Any npm packages used by your server
243
+
244
+ The result is a single file that can be deployed anywhere without needing Node.js, Bun, or any dependencies installed. Just run:
245
+
246
+ ```sh
247
+ ./myapp
248
+ ```
249
+
250
+ Bun automatically handles serving the frontend assets with proper MIME types and cache headers. The HTML import is replaced with a manifest object that `Bun.serve` uses to efficiently serve pre-bundled assets.
251
+
252
+ For more details on building full-stack applications with Bun, see the [full-stack guide](/docs/bundler/fullstack).
253
+
254
+ ## Worker
255
+
256
+ To use workers in a standalone executable, add the worker's entrypoint to the CLI arguments:
257
+
258
+ ```sh
259
+ $ bun build --compile ./index.ts ./my-worker.ts --outfile myapp
260
+ ```
261
+
262
+ Then, reference the worker in your code:
263
+
264
+ ```ts
265
+ console.log("Hello from Bun!");
266
+
267
+ // Any of these will work:
268
+ new Worker("./my-worker.ts");
269
+ new Worker(new URL("./my-worker.ts", import.meta.url));
270
+ new Worker(new URL("./my-worker.ts", import.meta.url).href);
271
+ ```
272
+
273
+ As of Bun v1.1.25, when you add multiple entrypoints to a standalone executable, they will be bundled separately into the executable.
274
+
275
+ In the future, we may automatically detect usages of statically-known paths in `new Worker(path)` and then bundle those into the executable, but for now, you'll need to add it to the shell command manually like the above example.
276
+
277
+ If you use a relative path to a file not included in the standalone executable, it will attempt to load that path from disk relative to the current working directory of the process (and then error if it doesn't exist).
278
+
279
+ ## SQLite
280
+
281
+ You can use `bun:sqlite` imports with `bun build --compile`.
282
+
283
+ By default, the database is resolved relative to the current working directory of the process.
284
+
285
+ ```js
286
+ import db from "./my.db" with { type: "sqlite" };
287
+
288
+ console.log(db.query("select * from users LIMIT 1").get());
289
+ ```
290
+
291
+ That means if the executable is located at `/usr/bin/hello`, the user's terminal is located at `/home/me/Desktop`, it will look for `/home/me/Desktop/my.db`.
292
+
293
+ ```
294
+ $ cd /home/me/Desktop
295
+ $ ./hello
296
+ ```
297
+
298
+ ## Embed assets & files
299
+
300
+ Standalone executables support embedding files.
301
+
302
+ To embed files into an executable with `bun build --compile`, import the file in your code.
303
+
304
+ ```ts
305
+ // this becomes an internal file path
306
+ import icon from "./icon.png" with { type: "file" };
307
+ import { file } from "bun";
308
+
309
+ export default {
310
+ fetch(req) {
311
+ // Embedded files can be streamed from Response objects
312
+ return new Response(file(icon));
313
+ },
314
+ };
315
+ ```
316
+
317
+ Embedded files can be read using `Bun.file`'s functions or the Node.js `fs.readFile` function (in `"node:fs"`).
318
+
319
+ For example, to read the contents of the embedded file:
320
+
321
+ ```js
322
+ import icon from "./icon.png" with { type: "file" };
323
+ import { file } from "bun";
324
+
325
+ const bytes = await file(icon).arrayBuffer();
326
+ // await fs.promises.readFile(icon)
327
+ // fs.readFileSync(icon)
328
+ ```
329
+
330
+ ### Embed SQLite databases
331
+
332
+ If your application wants to embed a SQLite database, set `type: "sqlite"` in the import attribute and the `embed` attribute to `"true"`.
333
+
334
+ ```js
335
+ import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
336
+
337
+ console.log(myEmbeddedDb.query("select * from users LIMIT 1").get());
338
+ ```
339
+
340
+ This database is read-write, but all changes are lost when the executable exits (since it's stored in memory).
341
+
342
+ ### Embed N-API Addons
343
+
344
+ As of Bun v1.0.23, you can embed `.node` files into executables.
345
+
346
+ ```js
347
+ const addon = require("./addon.node");
348
+
349
+ console.log(addon.hello());
350
+ ```
351
+
352
+ Unfortunately, if you're using `@mapbox/node-pre-gyp` or other similar tools, you'll need to make sure the `.node` file is directly required or it won't bundle correctly.
353
+
354
+ ### Embed directories
355
+
356
+ To embed a directory with `bun build --compile`, use a shell glob in your `bun build` command:
357
+
358
+ ```sh
359
+ $ bun build --compile ./index.ts ./public/**/*.png
360
+ ```
361
+
362
+ Then, you can reference the files in your code:
363
+
364
+ ```ts
365
+ import icon from "./public/assets/icon.png" with { type: "file" };
366
+ import { file } from "bun";
367
+
368
+ export default {
369
+ fetch(req) {
370
+ // Embedded files can be streamed from Response objects
371
+ return new Response(file(icon));
372
+ },
373
+ };
374
+ ```
375
+
376
+ This is honestly a workaround, and we expect to improve this in the future with a more direct API.
377
+
378
+ ### Listing embedded files
379
+
380
+ To get a list of all embedded files, use `Bun.embeddedFiles`:
381
+
382
+ ```js
383
+ import "./icon.png" with { type: "file" };
384
+ import { embeddedFiles } from "bun";
385
+
386
+ console.log(embeddedFiles[0].name); // `icon-${hash}.png`
387
+ ```
388
+
389
+ `Bun.embeddedFiles` returns an array of `Blob` objects which you can use to get the size, contents, and other properties of the files.
390
+
391
+ ```ts
392
+ embeddedFiles: Blob[]
393
+ ```
394
+
395
+ The list of embedded files excludes bundled source code like `.ts` and `.js` files.
396
+
397
+ #### Content hash
398
+
399
+ By default, embedded files have a content hash appended to their name. This is useful for situations where you want to serve the file from a URL or CDN and have fewer cache invalidation issues. But sometimes, this is unexpected and you might want the original name instead:
400
+
401
+ To disable the content hash, pass `--asset-naming` to `bun build --compile` like this:
402
+
403
+ ```sh
404
+ $ bun build --compile --asset-naming="[name].[ext]" ./index.ts
405
+ ```
406
+
407
+ ## Minification
408
+
409
+ To trim down the size of the executable a little, pass `--minify` to `bun build --compile`. This uses Bun's minifier to reduce the code size. Overall though, Bun's binary is still way too big and we need to make it smaller.
410
+
411
+ ## Using Bun.build() API
412
+
413
+ You can also generate standalone executables using the `Bun.build()` JavaScript API. This is useful when you need programmatic control over the build process.
414
+
415
+ ### Basic usage
416
+
417
+ ```js
418
+ await Bun.build({
419
+ entrypoints: ["./app.ts"],
420
+ outdir: "./dist",
421
+ compile: {
422
+ target: "bun-windows-x64",
423
+ outfile: "myapp.exe",
424
+ },
425
+ });
426
+ ```
427
+
428
+ ### Windows metadata with Bun.build()
429
+
430
+ When targeting Windows, you can specify metadata through the `windows` object:
431
+
432
+ ```js
433
+ await Bun.build({
434
+ entrypoints: ["./app.ts"],
435
+ outdir: "./dist",
436
+ compile: {
437
+ target: "bun-windows-x64",
438
+ outfile: "myapp.exe",
439
+ windows: {
440
+ title: "My Application",
441
+ publisher: "My Company Inc",
442
+ version: "1.2.3.4",
443
+ description: "A powerful application built with Bun",
444
+ copyright: "© 2024 My Company Inc",
445
+ hideConsole: false, // Set to true for GUI applications
446
+ icon: "./icon.ico", // Path to icon file
447
+ },
448
+ },
449
+ });
450
+ ```
451
+
452
+ ### Cross-compilation with Bun.build()
453
+
454
+ You can cross-compile for different platforms:
455
+
456
+ ```js
457
+ // Build for multiple platforms
458
+ const platforms = [
459
+ { target: "bun-windows-x64", outfile: "app-windows.exe" },
460
+ { target: "bun-linux-x64", outfile: "app-linux" },
461
+ { target: "bun-darwin-arm64", outfile: "app-macos" },
462
+ ];
463
+
464
+ for (const platform of platforms) {
465
+ await Bun.build({
466
+ entrypoints: ["./app.ts"],
467
+ outdir: "./dist",
468
+ compile: platform,
469
+ });
470
+ }
471
+ ```
472
+
473
+ ## Windows-specific flags
474
+
475
+ When compiling a standalone executable for Windows, there are several platform-specific options that can be used to customize the generated `.exe` file:
476
+
477
+ ### Visual customization
478
+
479
+ - `--windows-icon=path/to/icon.ico` - Set the executable file icon
480
+ - `--windows-hide-console` - Disable the background terminal window (useful for GUI applications)
481
+
482
+ ### Metadata customization
483
+
484
+ You can embed version information and other metadata into your Windows executable:
485
+
486
+ - `--windows-title <STR>` - Set the product name (appears in file properties)
487
+ - `--windows-publisher <STR>` - Set the company name
488
+ - `--windows-version <STR>` - Set the version number (e.g. "1.2.3.4")
489
+ - `--windows-description <STR>` - Set the file description
490
+ - `--windows-copyright <STR>` - Set the copyright information
491
+
492
+ #### Example with all metadata flags:
493
+
494
+ ```sh
495
+ bun build --compile ./app.ts \
496
+ --outfile myapp.exe \
497
+ --windows-title "My Application" \
498
+ --windows-publisher "My Company Inc" \
499
+ --windows-version "1.2.3.4" \
500
+ --windows-description "A powerful application built with Bun" \
501
+ --windows-copyright "© 2024 My Company Inc"
502
+ ```
503
+
504
+ This metadata will be visible in Windows Explorer when viewing the file properties:
505
+
506
+ 1. Right-click the executable in Windows Explorer
507
+ 2. Select "Properties"
508
+ 3. Go to the "Details" tab
509
+
510
+ #### Version string format
511
+
512
+ The `--windows-version` flag accepts version strings in the following formats:
513
+
514
+ - `"1"` - Will be normalized to "1.0.0.0"
515
+ - `"1.2"` - Will be normalized to "1.2.0.0"
516
+ - `"1.2.3"` - Will be normalized to "1.2.3.0"
517
+ - `"1.2.3.4"` - Full version format
518
+
519
+ Each version component must be a number between 0 and 65535.
520
+
521
+ {% callout %}
522
+
523
+ These flags currently cannot be used when cross-compiling because they depend on Windows APIs. They are only available when building on Windows itself.
524
+
525
+ {% /callout %}
526
+
527
+ ## Code signing on macOS
528
+
529
+ To codesign a standalone executable on macOS (which fixes Gatekeeper warnings), use the `codesign` command.
530
+
531
+ ```sh
532
+ $ codesign --deep --force -vvvv --sign "XXXXXXXXXX" ./myapp
533
+ ```
534
+
535
+ We recommend including an `entitlements.plist` file with JIT permissions.
536
+
537
+ ```xml#entitlements.plist
538
+ <?xml version="1.0" encoding="UTF-8"?>
539
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
540
+ <plist version="1.0">
541
+ <dict>
542
+ <key>com.apple.security.cs.allow-jit</key>
543
+ <true/>
544
+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
545
+ <true/>
546
+ <key>com.apple.security.cs.disable-executable-page-protection</key>
547
+ <true/>
548
+ <key>com.apple.security.cs.allow-dyld-environment-variables</key>
549
+ <true/>
550
+ <key>com.apple.security.cs.disable-library-validation</key>
551
+ <true/>
552
+ </dict>
553
+ </plist>
554
+ ```
555
+
556
+ To codesign with JIT support, pass the `--entitlements` flag to `codesign`.
557
+
558
+ ```sh
559
+ $ codesign --deep --force -vvvv --sign "XXXXXXXXXX" --entitlements entitlements.plist ./myapp
560
+ ```
561
+
562
+ After codesigning, verify the executable:
563
+
564
+ ```sh
565
+ $ codesign -vvv --verify ./myapp
566
+ ./myapp: valid on disk
567
+ ./myapp: satisfies its Designated Requirement
568
+ ```
569
+
570
+ {% callout %}
571
+
572
+ Codesign support requires Bun v1.2.4 or newer.
573
+
574
+ {% /callout %}
575
+
576
+ ## Unsupported CLI arguments
577
+
578
+ Currently, the `--compile` flag can only accept a single entrypoint at a time and does not support the following flags:
579
+
580
+ - `--outdir` — use `outfile` instead.
581
+ - `--splitting`
582
+ - `--public-path`
583
+ - `--target=node` or `--target=browser`
584
+ - `--no-bundle` - we always bundle everything into the executable.
@@ -0,0 +1,99 @@
1
+ # Output styles
2
+
3
+ > Adapt Claude Code for uses beyond software engineering
4
+
5
+ Output styles allow you to use Claude Code as any type of agent while keeping
6
+ its core capabilities, such as running local scripts, reading/writing files, and
7
+ tracking TODOs.
8
+
9
+ ## Built-in output styles
10
+
11
+ Claude Code's **Default** output style is the existing system prompt, designed
12
+ to help you complete software engineering tasks efficiently.
13
+
14
+ There are two additional built-in output styles focused on teaching you the
15
+ codebase and how Claude operates:
16
+
17
+ * **Explanatory**: Provides educational "Insights" in between helping you
18
+ complete software engineering tasks. Helps you understand implementation
19
+ choices and codebase patterns.
20
+
21
+ * **Learning**: Collaborative, learn-by-doing mode where Claude will not only
22
+ share "Insights" while coding, but also ask you to contribute small, strategic
23
+ pieces of code yourself. Claude Code will add `TODO(human)` markers in your
24
+ code for you to implement.
25
+
26
+ ## How output styles work
27
+
28
+ Output styles directly modify Claude Code's system prompt.
29
+
30
+ * Non-default output styles exclude instructions specific to code generation and
31
+ efficient output normally built into Claude Code (such as responding concisely
32
+ and verifying code with tests).
33
+ * Instead, these output styles have their own custom instructions added to the
34
+ system prompt.
35
+
36
+ ## Change your output style
37
+
38
+ You can either:
39
+
40
+ * Run `/output-style` to access the menu and select your output style (this can
41
+ also be accessed from the `/config` menu)
42
+
43
+ * Run `/output-style [style]`, such as `/output-style explanatory`, to directly
44
+ switch to a style
45
+
46
+ These changes apply to the [local project level](/en/docs/claude-code/settings)
47
+ and are saved in `.claude/settings.local.json`.
48
+
49
+ ## Create a custom output style
50
+
51
+ To set up a new output style with Claude's help, run
52
+ `/output-style:new I want an output style that ...`
53
+
54
+ By default, output styles created through `/output-style:new` are saved as
55
+ markdown files at the user level in `~/.claude/output-styles` and can be used
56
+ across projects. They have the following structure:
57
+
58
+ ```markdown
59
+ ---
60
+ name: My Custom Style
61
+ description:
62
+ A brief description of what this style does, to be displayed to the user
63
+ ---
64
+
65
+ # Custom Style Instructions
66
+
67
+ You are an interactive CLI tool that helps users with software engineering
68
+ tasks. [Your custom instructions here...]
69
+
70
+ ## Specific Behaviors
71
+
72
+ [Define how the assistant should behave in this style...]
73
+ ```
74
+
75
+ You can also create your own output style Markdown files and save them either at
76
+ the user level (`~/.claude/output-styles`) or the project level
77
+ (`.claude/output-styles`).
78
+
79
+ ## Comparisons to related features
80
+
81
+ ### Output Styles vs. CLAUDE.md vs. --append-system-prompt
82
+
83
+ Output styles completely “turn off” the parts of Claude Code’s default system
84
+ prompt specific to software engineering. Neither CLAUDE.md nor
85
+ `--append-system-prompt` edit Claude Code’s default system prompt. CLAUDE.md
86
+ adds the contents as a user message *following* Claude Code’s default system
87
+ prompt. `--append-system-prompt` appends the content to the system prompt.
88
+
89
+ ### Output Styles vs. [Agents](/en/docs/claude-code/sub-agents)
90
+
91
+ Output styles directly affect the main agent loop and only affect the system
92
+ prompt. Agents are invoked to handle specific tasks and can include additional
93
+ settings like the model to use, the tools they have available, and some context
94
+ about when to use the agent.
95
+
96
+ ### Output Styles vs. [Custom Slash Commands](/en/docs/claude-code/slash-commands)
97
+
98
+ You can think of output styles as “stored system prompts” and custom slash
99
+ commands as “stored prompts”.