Skip to content

refactor: comprehensive source code reorganization for guessability - #25781

Closed
robobun wants to merge 116 commits into
mainfrom
claude/source-reorganization
Closed

robobun wants to merge 116 commits into
mainfrom
claude/source-reorganization

Conversation

@robobun

@robobun robobun commented Dec 31, 2025

Copy link
Copy Markdown
Collaborator

Summary

This PR reorganizes the Bun source code to make file locations guessable. The goal: Claude (or any developer) should be able to guess where code lives without searching.

Key Changes

  • Renamed src/bun.js/ → src/buntime/ - More intuitive name for the JavaScript runtime
  • Created src/transpiler/ - Moved JS/TS transpiler (parser, lexer, printer) from root
  • Created src/test_runner/ - Moved test runner from buntime/test/
  • Dissolved bindings/ - Split ~150 files into domain-specific directories
  • Dissolved webcore/ - Moved to appropriate web/ subdirectories
  • Organized node/ - Created subdirectories for buffer, process, vm, crypto, etc.
  • Created jsc/ - Organized JSC integration into types/, global/, gc/, interop/, generated/
  • Created compat/ - Grouped napi/, v8/, libuv/, windows/
  • Moved event_loop/ - Now at buntime/ root level

New Directory Structure

src/
├── transpiler/           # JS/TS transpiler
├── test_runner/          # bun:test
├── bundler/              # bun build
├── install/              # Package manager
├── css/                  # CSS parser
├── shell/                # Bun.$
└── buntime/              # JavaScript runtime
    ├── api/              # Bun.* APIs (server, console, ffi, sqlite, etc.)
    ├── web/              # Web Standards (fetch, url, blob, streams, etc.)
    ├── node/             # Node.js compat (buffer, process, crypto, etc.)
    ├── compat/           # Native addons (napi, v8, libuv)
    ├── jsc/              # JSC integration (types, global, gc, interop)
    ├── module/           # Module system
    └── event_loop/       # Event loop

Guessability Table

Task Location
Fix the transpiler src/transpiler/
Fix Bun.serve() src/buntime/api/server/
Fix fetch() src/buntime/web/fetch/
Fix node:crypto src/buntime/node/crypto/
Fix N-API src/buntime/compat/napi/
Fix V8 compat src/buntime/compat/v8/

Stats

  • 114 commits
  • 1717 files changed
  • All imports and build configuration updated
  • Documentation paths fixed in .md files
  • CMake duplicate/invalid path issues fixed

Test plan

  • bun bd builds successfully
  • All directory structure matches PLAN.md
  • No stray files in old locations (bindings/, webcore/)
  • CLAUDE.md updated with new structure

🤖 Generated with Claude Code

@robobun
robobun requested a review from alii as a code owner December 31, 2025 08:36
@robobun

robobun commented Dec 31, 2025 •

Copy link
Copy Markdown
Collaborator Author
Updated 2:00 AM PT - Dec 31st, 2025

❌ Your commit c2403a8d has 7 failures in Build #33915 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 25781

That installs a local version of the PR into your bun-25781 executable, so you can run:

bun-25781 --bun

@coderabbitai

coderabbitai Bot commented Dec 31, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Large-scale repository reorganization: files and imports moved from src/bun.js/... into a new src/buntime/... tree; src/transpiler/ and src/test_runner/ subtrees added. Numerous Zig, C/C++, CMake, and JS paths updated to the new layout; no substantive logic changes reported.

Changes

Cohort / File(s) Summary
Planning & Documentation
PLAN.md, CLAUDE.md, .claude/commands/upgrade-nodejs.md, .claude/skills/implementing-jsc-classes-cpp/SKILL.md, .claude/skills/implementing-jsc-classes-zig/SKILL.md, src/AGENTS.md, src/buntime/STREAMS.md
Adds reorg plan and docs; updates many docs/comments to reference buntime and new top-level layout.
Build config & source lists
cmake/Sources.json, cmake/analysis/RunClangFormat.cmake, cmake/targets/BuildBun.cmake, cmake/targets/BuildSQLite.cmake, cmake/tools/SetupBun.cmake, build.zig
Redirects build globs, include groups and CMake targets from src/bun.js/... to src/buntime/...; adjusts source lists and clang-format globs.
Package scripts
package.json
Updates uv-posix-stubs script to point at src/buntime/compat/libuv/generate_uv_posix_stubs.ts.
Core Zig entrypoints & exports
src/bun.zig, src/bun.js.zig, src/ast.zig
Public imports/exports repointed to buntime and transpiler subpaths (jsc, webcore, api, bindgen, transpiler, parser/printer/lexer).
Transpiler & bundler imports
src/ast/Expr.zig, src/bundler/LinkerContext.zig, src/bundler/bundle_v2.zig
Moves js_printer/js_parser/js_lexer imports into transpiler/ subdirectory; updates exported constants to new import paths.
BoringSSL / crypto imports
src/boringssl.zig
X509 import path updated to ./buntime/api/bun/x509.zig.
Buntime API & JS bindings
src/buntime/api.zig, src/buntime/api/BunObject.zig, src/buntime/api/FFI.h, src/buntime/api/ffi.zig, src/buntime/api/ffi/FFI.zig, src/buntime/api/BunProcess.cpp, src/buntime/api/s3/*.classes.ts
Adjusts many API import paths and local includes/comments to reflect new nested layout (BuildMessage, ResolveMessage, Sizes, Jest.call, FFI comments, etc.).
Timer / Inspector / IPC / Spawn modules
src/buntime/api/Timer/*.zig, src/buntime/api/inspector/Debugger.zig, src/buntime/api/bun/js_bun_spawn_bindings.zig, src/buntime/api/bun/subprocess.zig, src/buntime/api/ipc/ipc.zig
Updates Debugger, agent, and IPC/spawn module import paths into inspector/, server/, and ipc/ subtrees.
Console / test-runner references
src/buntime/api/console/ConsoleObject.zig, src/buntime/api/BunObject.zig
Repoints Visited.ObjectPool, CLI, JestPrettyFormat, and BunObject.jest to relocated test_runner and pool/cli modules.
Libuv headers rework
src/bun.js/bindings/libuv/* (many removed), src/buntime/compat/libuv/uv.h, src/buntime/compat/libuv/*
Removes old bun.js libuv headers and platform-specific trees; adds comprehensive new src/buntime/compat/libuv/uv.h and platform headers (aix, etc.).
Stdatomic replacement
src/bun.js/api/ffi-stdatomic.h (removed), src/buntime/api/ffi-stdatomic.h (added)
Deletes old stdatomic header under bun.js and adds a self-contained stdatomic-like header under buntime/api.
Clang-format ignore / cleanup
src/bun.js/bindings/.clang-format-ignore, src/bun.js/bindings/v8/AGENTS.md
Removes two ignore patterns and deletes an obsolete doc file in the old bun.js tree.
Misc path fixes & formatting
cmake/Sources.json (JS/C/Cxx lists), src/buntime/api/ffi-stddef.h, src/buntime/compat/libuv/aix.h, various Zig files
Formatting tweaks and numerous relative-import path adjustments across Zig/C headers (no behavioral changes).

Possibly related PRs

Suggested reviewers

  • alii
  • pfgithub
  • taylordotfish
  • zackradisic
  • Jarred-Sumner

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: comprehensive source code reorganization for guessability' is specific, clear, and directly reflects the main objective of the PR—a major reorganization of source code structure for improved navigability.
Description check ✅ Passed The description comprehensively covers all required sections: it explains what the PR does (source reorganization for guessability), includes a detailed guessability table mapping tasks to locations, documents the new directory structure with a visual tree, and provides test/verification evidence (build success, directory structure validation).

Comment @coderabbitai help to get the list of available commands and usage tips.

Claude Bot and others added 27 commits December 31, 2025 08:53
Step 1 of source reorganization - rename the JavaScript runtime
directory from bun.js to buntime for better discoverability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 2 of source reorganization - move js_parser, js_lexer, js_printer,
and transpiler files to src/transpiler/ directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 3 of source reorganization - move test runner files from
src/buntime/test/ to src/test_runner/ for better discoverability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 4.1 of source reorganization - move console-related files:
- ConsoleObject.cpp/h
- UtilInspect.cpp/h
- ConsoleObject.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 4.2 of source reorganization - move inspector-related files:
- BunInspector.cpp
- InspectorBunFrontendDevServerAgent.cpp/h
- InspectorHTTPServerAgent.cpp/h
- InspectorLifecycleAgent.cpp/h
- InspectorTestReporterAgent.cpp/h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 4.3 of source reorganization - move error-related files:
- DeferredError.zig
- ErrorCode.cpp/h/ts/zig
- ErrorStackFrame.cpp/h
- ErrorStackTrace.cpp/h
- Errorable.zig
- JSErrorCode.zig
- SystemError.zig
- ZigErrorType.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Step 4.4 of source reorganization - move cookie-related files:
- JSCookie.cpp/h
- JSCookieMap.cpp/h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move domain-specific files from bindings/ to api/ subdirectories:
- api/s3/: S3 client and error handling
- api/secrets/: Platform secrets management
- api/ffi/: Foreign Function Interface
- api/sqlite/: SQLite bindings (moved from bindings/sqlite/)
- api/sql/: SQL client
- api/shell/: Shell bindings
- api/ipc/: IPC bindings
- api/test/: Testing utilities
- api/server/: HTTP server bindings
- api/plugin/: Bundler plugin system

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move v8 directory from bindings/ to compat/v8/ for better organization
of compatibility layers.

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move webcrypto directory from bindings/ to webcore/webcrypto/ for
better organization of web-related APIs.

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Consolidate node compatibility files:
- Move node C++ files from bindings/node/ to buntime/node/
- Rename bindings/node/crypto to node/crypto_bindings for clarity
- Move webcrypto from bindings/ to webcore/webcrypto/
- Update cmake include paths and source patterns

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Move bindings/libuv/ to compat/libuv/ for libuv compatibility layer
- Move bindings/webcore/ to webcore/ (438 files)
- Update all include paths for webcore/ prefix removal
- Fix relative includes in webcrypto files

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Move napi files from bindings/ to compat/napi/
- Move module loader files from bindings/ to module/
  - InternalModuleRegistry, JSModuleLoader, JSCommonJSModule, etc.
- Update all import paths and cmake configurations

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move process-related files from bindings/ to api/process/:
- BunProcess, ProcessBindingBuffer, ProcessBindingConstants
- ProcessBindingFs, ProcessBindingHTTPParser, ProcessBindingNatives
- ProcessBindingTTYWrap, ProcessBindingUV, ProcessIdentifier
- bun-spawn

Part of source code reorganization to make code location "guessable".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move BunClientData, BunCommonStrings, BunGCOutputConstraint,
BunGlobalScope, BunIDL*, BunJSCEventLoop, BunObject, BunString,
and BunWorkerGlobalScope from bindings/ to core/.

This makes the purpose of these files clearer - they are core Bun
runtime infrastructure rather than JavaScript bindings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move FetchHeaders, FetchTasklet, HTTPHeader*, JSFetchHeaders,
NodeFetch, Undici, and fetch.zig from bindings/ and webcore/
to web/fetch/.

This groups all fetch-related functionality in one directory
for easier navigation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move DOMURL, URLSearchParams, URLPattern*, EncodeURIComponent,
decodeURIComponentSIMD, ObjectURLRegistry, NodeURL and related
files from bindings/ and webcore/ to web/url/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move blob.cpp, DOMFormData, JSDOMFile, and JSDOMFormData
from bindings/ and webcore/ to web/blob/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move Base64Helpers, TextCodec*, TextEncoder*, TextDecoder*,
EncodingLabel, encoding.zig and related files from bindings/
and webcore/ to web/encoding/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move JSCompressionStream and JSDecompressionStream from bindings/
to web/compression/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move Event*, MessagePort*, BroadcastChannel*, AbortSignal,
EventTarget, EventEmitter, JS* event files from bindings/
and webcore/ to web/events/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move ReadableStream, WritableStream, TransformStream, Sink,
FileSink, ByteStream, ResumableSink, JS* stream files from
webcore/ to web/streams/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move Response.zig, Request.zig, Body.zig, BakeResponse.zig,
and response.classes.ts from webcore/ to web/http/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move Blob.zig, ByteBlobLoader.zig and blob/ subdirectory files from
webcore/ to web/blob/. Update relative imports for env.zig, S3File.zig,
and Store/read_file/write_file/copy_file references.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move 60 performance-related files from webcore/ to web/performance/.
Includes Performance API, PerformanceObserver, Timing, Marks, Measures,
ResourceTiming, ServerTiming, and NetworkLoadMetrics.

Added JSDOMWrapperCache.h include to JSPerformanceEntryCustom.cpp.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move 8 WebSocket-related files from webcore/ to web/websocket/.
Includes WebSocket core, JSWebSocket bindings, and helpers.
Updated cmake/Sources.json and cmake/targets/BuildBun.cmake.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move S3Client.zig, S3File.zig, S3Stat.zig from webcore/ to api/s3/.
Update imports in webcore.zig and Blob.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude Bot and others added 24 commits December 31, 2025 08:53
Script caching belongs with module loading infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
bmalloc and mimalloc integration belongs in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
String adaptors and utilities belong in core infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move StringAdaptors.h, MiString.h, and ConcatCStrings.h to the existing
src/string/ directory where other string utilities live.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Debugger helpers belong with inspector/profiling code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Generic tuple algorithms belong in core utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…e to module/

Move module loading related files to the module/ subdirectory:
- ModuleLoader.zig
- AsyncModule.zig
- RuntimeTranspilerStore.zig
- RuntimeTranspilerCache.zig

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
These are JSC reference management utilities that belong with other bindings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Event loop is core runtime infrastructure that belongs in the core/ directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move RefString.zig, array_buffer.zig, dom_call.zig, host_fn.zig to bindings/
since they are JSC binding utilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
These are core runtime infrastructure files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move bindgen.zig, bindgen_test.zig, javascript_core_c_api.zig to bindings/
since they are all binding-related files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
These are core runtime infrastructure files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
According to PLAN.md, webcrypto should be under web/ as a Web Standard API,
not under webcore/ which is for core JSDOM infrastructure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move string-related C++ files per PLAN.md section 4.80:
- bun-simdutf.cpp, bun-simdutf.zig
- BunString.cpp, BunString.h
- BunCommonStrings.cpp, BunCommonStrings.h
- DoubleFormatter.cpp
- highway_strings.cpp
- StringBuilderBinding.cpp
- stripANSI.cpp, stripANSI.h

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Per PLAN.md section 4.90, this bundler-related file belongs in bake/.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move bindings/ directory to jsc/ with the following organization:
- jsc/types/ - JSValue types (JSArray, JSObject, JSPromise, etc.)
- jsc/global/ - Global objects (ZigGlobalObject, ScriptExecutionContext, etc.)
- jsc/gc/ - GC-related files (StrongRef, Weak, MarkingConstraint, etc.)
- jsc/interop/ - C++/Zig interop (bindings.cpp, helpers.cpp, etc.)
- jsc/generated/ - Generated code (GeneratedBindings, JS2Native, etc.)

Also:
- Move uv polyfills to compat/libuv/
- Move v8 fixture to compat/v8/
- Move Windows files to compat/windows/
- Move bindgen_test.bind.ts to jsc/interop/
- Update cmake Sources.json and BuildBun.cmake for new paths
- Update codegen scripts to generate correct relative import paths
- Fix Zig imports throughout the codebase

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move all JSDOM infrastructure from webcore/ to jsc/interop/:
- ActiveDOMObject, ContextDestructionObserver
- JSDOMConvert*, JSDOMPromise, JSDOMIterator
- JSDOMWrapper*, JSDOMConstructor*, JSDOMBuiltin*
- DOMJITHelpers, DOMIsoSubspaces, DOMClientIsoSubspaces
- WebCoreTypedArrayController, BufferSource
- All other JSDOM binding utilities

Also:
- Move AutoFlusher.zig to jsc/interop/
- Move ScriptExecutionContext.zig to jsc/global/
- Update cmake Sources.json to remove webcore/ glob
- Fix missing JSDOMGlobalObject.h include in JSPerformanceObserverCallback.h
- Fix JSC::JSValue qualification in JSAbortAlgorithm.h

The webcore/ directory is now fully dissolved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move C++ files from node/ root into organized subdirectories:
- node/buffer/ - Buffer and StringDecoder
- node/process/ - NextTickQueue
- node/vm/ - VM, VMScript
- node/crypto/ - All crypto bindings (renamed from crypto_bindings/)
- node/http/ - HTTP server socket, NodeHTTP
- node/fs/ - Dirent, stat bindings
- node/os/ - OsBinding
- node/path/ - Path utilities
- node/util/ - NodeValidator
- node/timers/ - Timer objects
- node/async_hooks/ - AsyncContextFrame, AsyncHooks
- node/perf_hooks/ - Performance histogram
- node/constants/ - NodeConstants

Also moves global scope files to jsc/global/:
- BunGlobalScope, BunObject, BunWorkerGlobalScope
- ZigSourceProvider

Updates cmake Sources.json and BuildBun.cmake with new paths.
Fixes include paths in NodeBufferModule.h and NodeStringDecoderModule.h.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Per PLAN.md's Final Structure, event_loop should be at the buntime/
root level. This move:
- Moves the event_loop directory from core/event_loop/ to buntime/event_loop/
- Moves event_loop.zig and related C++ files (EventLoopTask.h,
  EventLoopTaskNoContext.cpp/h, BunJSCEventLoop.cpp)
- Updates imports in jsc.zig, GeneratedJS2Native.zig, rare_data.zig
- Fixes relative paths in event_loop.zig and Task.zig
- Updates cmake Sources.json and BuildBun.cmake with new paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move remaining core/ files to organized jsc/ subdirectories:
- BunClientData, BunIDL*, CPUFeatures, JSCTaskScheduler, coroutine → jsc/interop/
- BunGCOutputConstraint, MimallocWTFMalloc.h, bmalloc_heap_ref.h → jsc/gc/
- RegularExpression → jsc/types/

Fix outdated file paths in documentation:
- STREAMS.md: webcore/ → web/streams/
- event_loop/README.md: bindings/JSNextTickQueue → node/process/
- compat/v8/CLAUDE.md and AGENTS.md: bindings/v8/ → compat/v8/
- node/http/llhttp/README.md: bindings/ProcessBindingHTTPParser → api/process/

Fix cmake BuildBun.cmake issues:
- Remove duplicate directory entries in BUN_ERROR_CODE_SOURCES
- Remove directory (not file) arguments from WEBKIT_ADD_SOURCE_DEPENDENCIES

Update Zig imports for moved files in jsc.zig and crash_handler.zig.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Rename files in src/transpiler/ to have consistent js_ prefix:
- parser.zig → js_parser.zig
- printer.zig → js_printer.zig
- lexer.zig → js_lexer.zig
- lexer_tables.zig → js_lexer_tables.zig

Update all imports across the codebase:
- bun.zig
- renamer.zig
- ast.zig
- ast/Expr.zig
- logger.zig
- string/MutableString.zig
- bundler/bundle_v2.zig
- bundler/LinkerContext.zig
- transpiler/js_lexer.zig (internal import)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Completely rewrite the Code Architecture section to reflect the
reorganized source structure. Now includes:

- Quick-reference table mapping tasks to directories
- Full directory tree showing the organized buntime/ structure
- Updated paths (src/buntime/ instead of src/bun.js/)
- Removed references to dissolved directories (bindings/, webcore/)

The goal: Claude should be able to GUESS where code lives.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@robobun
robobun force-pushed the claude/source-reorganization branch from 2c97696 to e48a998 Compare December 31, 2025 09:01
autofix-ci Bot and others added 2 commits December 31, 2025 09:02
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Comment thread CLAUDE.md
Comment on lines +140 to +218
```
src/
├── transpiler/ # JS/TS transpiler (js_parser, js_lexer, js_printer)
├── test_runner/ # bun:test implementation
├── bundler/ # bun build
├── resolver/ # Module resolution
├── install/ # Package manager (bun install)
├── css/ # CSS parser
├── shell/ # Bun.$ shell
├── bake/ # Bake framework
├── sql/ # SQL clients (postgres/, mysql/)
├── s3/ # S3 core
├── valkey/ # Valkey/Redis
├── http/ # HTTP client
├── string/ # String utilities
├── ast/ # AST types
├── js/ # TypeScript built-in modules
│
└── buntime/ # JavaScript runtime
├── api/ # Bun.* APIs
│ ├── server/ # Bun.serve()
│ ├── console/ # console.*
│ ├── inspector/ # Debugger, profiler
│ ├── error/ # Error handling, stack traces
│ ├── cookie/ # Cookie parsing
│ ├── s3/ # S3 JS bindings
│ ├── ffi/ # Bun.FFI
│ ├── sqlite/ # bun:sqlite
│ ├── sql/ # SQL bindings
│ ├── shell/ # Shell bindings
│ ├── ipc/ # IPC
│ ├── plugin/ # Bundler plugins
│ ├── secrets/ # Secrets API
│ └── test/ # Test helpers
│
├── web/ # Web Standards
│ ├── fetch/ # Fetch API
│ ├── url/ # URL, URLSearchParams
│ ├── blob/ # Blob, File, FormData
│ ├── encoding/ # TextEncoder/Decoder
│ ├── compression/ # CompressionStream
│ ├── events/ # EventTarget, CustomEvent
│ ├── streams/ # ReadableStream, WritableStream
│ ├── performance/ # Performance API
│ ├── websocket/ # WebSocket
│ └── webcrypto/ # crypto.subtle
│
├── node/ # Node.js Compatibility
│ ├── buffer/ # Buffer
│ ├── process/ # process.*
│ ├── vm/ # node:vm
│ ├── crypto/ # node:crypto
│ ├── http/ # node:http
│ ├── fs/ # node:fs helpers
│ ├── os/ # node:os
│ ├── path/ # node:path
│ ├── util/ # node:util
│ ├── timers/ # Timers
│ ├── async_hooks/ # AsyncLocalStorage
│ ├── perf_hooks/ # Performance hooks
│ └── constants/ # Constants
│
├── compat/ # Native Addon Compatibility
│ ├── napi/ # N-API
│ ├── v8/ # V8 C++ API
│ ├── libuv/ # libuv polyfills
│ └── windows/ # Windows-specific
│
├── jsc/ # JavaScriptCore Integration
│ ├── types/ # JSValue, JSString, JSArray, etc.
│ ├── global/ # ZigGlobalObject, BunGlobalScope
│ ├── gc/ # GC helpers, weak refs
│ ├── interop/ # C++/Zig bindings, IDL
│ └── generated/ # Generated bindings
│
├── module/ # Module system (CommonJS, ESM)
├── event_loop/ # Event loop, tasks, timers
└── core/ # VirtualMachine, config
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add languages to new fenced code blocks to satisfy markdownlint

markdownlint is flagging several of the newly-added fenced blocks (directory tree and command snippets) for missing languages (MD040). To keep docs lint‑clean and improve rendering, consider:

  • Using ```text (or ```plaintext) for the directory tree under “Top-Level Source Organization”.
  • Using ```bash for shell command examples (e.g., the bun bd verification snippet).
  • Using an appropriate language (e.g., ```zig) if you later add Zig examples to these sections.

This is purely documentation hygiene; structure and content look good.

Also applies to: 220-229

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

164-164: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


176-176: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


185-185: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


196-196: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


208-208: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In CLAUDE.md around lines 140-218 (and also lines 220-229), the newly added
fenced code blocks lack language tags which triggers markdownlint MD040; update
the blocks by adding appropriate language identifiers — use ```text or
```plaintext for the directory tree block, use ```bash for any shell/command
snippets (e.g., bun bd verification), and use ```zig (or another specific
language) if you later add Zig examples — apply these changes to each offending
fenced block in the specified ranges.

Comment on lines +4 to +5
${CWD}/src/buntime/bindings/*.h
${CWD}/src/buntime/modules/*.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Confirm clang-format header coverage after tree move

BUN_H_SOURCES now globs only:

  • src/buntime/bindings/*.h
  • src/bruntime/modules/*.h

This matches the new layout, but any headers in other new trees (e.g. api/, jsc/, compat/, etc.) will not be picked up by clang-format via this target. Please double‑check that these are the only header roots you intend to format here, or expand the glob patterns if more .h locations exist.

🤖 Prompt for AI Agents
In cmake/analysis/RunClangFormat.cmake around lines 4-5, the current globs only
include ${CWD}/src/buntime/bindings/*.h and ${CWD}/src/buntime/modules/*.h which
will miss headers moved into other roots (api/, jsc/, compat/, etc.); verify the
full set of header root directories that should be formatted and either add
explicit glob entries for each missing root (for example api/**/*.h, jsc/**/*.h,
compat/**/*.h) or broaden the pattern (e.g., src/**/*.h) to cover all expected
.h locations, ensuring the paths match the actual directory names in the tree.

Comment thread PLAN.md
Comment on lines +15 to +21
| "Fix Postgres" | `src/sql/postgres/` |
| "Fix MySQL" | `src/sql/mysql/` |
| "Fix Valkey/Redis" | `src/valkey/` |
| "Fix S3" | `src/s3/` (core) or `buntime/api/s3/` (JS bindings) |
| "Fix Bake" | `src/bake/` |
| "Fix Bun.serve()" | `src/buntime/api/server/` |
| "Fix fetch()" | `src/buntime/web/fetch/` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten a couple of path references for consistency in the plan

  • In the “Fix S3” row, all other locations are rooted at src/…, but the second location is buntime/api/s3/. Consider making it src/buntime/api/s3/ so it visually matches the rest of the table and CLAUDE.md.
  • In the “Don’t Forget” section, bun-spawn.cpp, spawn.cpp → api/bun/spawn/ doesn’t correspond to a documented subdirectory in the buntime/api tree above. If the intent is to eventually have src/buntime/api/bun/spawn/, it may help to spell that out explicitly; otherwise, rephrase to match the actual destination directory name you plan to use.

Also applies to: 1107-1112

🤖 Prompt for AI Agents
In PLAN.md around lines 15 to 21 (and also apply same change to lines 1107 to
1112), tighten path references for consistency by changing the “Fix S3” second
location from buntime/api/s3/ to src/buntime/api/s3/ so it matches the other
src/... roots and CLAUDE.md, and update the “Don’t Forget” entry mapping
bun-spawn.cpp, spawn.cpp → api/bun/spawn/ to the explicit intended destination
(for example src/buntime/api/bun/spawn/) or rephrase it to match the actual
directory you plan to use; make the edits so all table rows and the “Don’t
Forget” line use consistent src/ rooted paths and accurate target directories.

#include <JavaScriptCore/StructureCache.h>

#include <webcore/SerializedScriptValue.h>
#include "SerializedScriptValue.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check if SerializedScriptValue.h exists and where it's located
find . -name "SerializedScriptValue.h" -type f 2>/dev/null

Repository: oven-sh/bun

Length of output: 110


🏁 Script executed:

# Check the BunProcess.cpp file, specifically lines 50-55 and around line 208
wc -l src/buntime/api/process/BunProcess.cpp

Repository: oven-sh/bun

Length of output: 98


🏁 Script executed:

# If it's not too large, read the relevant sections
head -220 src/buntime/api/process/BunProcess.cpp | tail -175

Repository: oven-sh/bun

Length of output: 6683


🏁 Script executed:

# Check for llhttp directory structure
find . -type d -name "llhttp" 2>/dev/null | head -20

Repository: oven-sh/bun

Length of output: 85


🏁 Script executed:

# Look for CMakeLists.txt files that might configure include directories
find . -name "CMakeLists.txt" -type f 2>/dev/null | grep -E "(api|process)" | head -10

Repository: oven-sh/bun

Length of output: 94


🏁 Script executed:

# Find CMakeLists.txt near BunProcess.cpp
find ./src/buntime/api -name "CMakeLists.txt" -type f

Repository: oven-sh/bun

Length of output: 94


🏁 Script executed:

# Check if there's a CMakeLists.txt in the process directory
find ./src/buntime/api/process -type f | head -20

Repository: oven-sh/bun

Length of output: 1052


🏁 Script executed:

# Search for how the include directories are set up - look for files that might include BunProcess
rg "BunProcess.cpp" --type cmake

Repository: oven-sh/bun

Length of output: 131


🏁 Script executed:

# Verify the exact line 208 to confirm the comment
sed -n '205,210p' src/buntime/api/process/BunProcess.cpp

Repository: oven-sh/bun

Length of output: 644


🏁 Script executed:

# Check if README.md exists at the current path vs old path
ls -la ./src/buntime/node/http/llhttp/README.md 2>/dev/null || echo "File not found at current path"
ls -la ./src/buntime/bindings/node/http/llhttp/README.md 2>/dev/null || echo "File not found at old path"

Repository: oven-sh/bun

Length of output: 170


🏁 Script executed:

# Check the BuildBun.cmake file to see how include directories are set
grep -A 20 -B 5 "BunProcess.cpp" cmake/targets/BuildBun.cmake | head -50

Repository: oven-sh/bun

Length of output: 1110


🏁 Script executed:

# Look for include_directories or target_include_directories in BuildBun.cmake that might handle SerializedScriptValue.h
rg "include_directories|target_include_directories" cmake/targets/BuildBun.cmake -A 3 | head -60

Repository: oven-sh/bun

Length of output: 730


🏁 Script executed:

# Search for where SerializedScriptValue.h include paths are configured
rg "SerializedScriptValue" . --type cmake

Repository: oven-sh/bun

Length of output: 37


🏁 Script executed:

# Check if there's a CMakeLists.txt that might set up include paths for src/buntime/api/process
find ./src/buntime -name "CMakeLists.txt" | xargs grep -l "api/process" 2>/dev/null

Repository: oven-sh/bun

Length of output: 39


🏁 Script executed:

# Look for any include path configurations for web/serialization
rg "web/serialization|web.*include" . --type cmake | head -20

Repository: oven-sh/bun

Length of output: 124


🏁 Script executed:

# Verify the exact include directory configuration in BuildBun.cmake for web/serialization
grep -B 5 -A 5 "src/buntime/web/serialization" cmake/targets/BuildBun.cmake

Repository: oven-sh/bun

Length of output: 371


🏁 Script executed:

# Check if there are any other references to the old bindings path in comments
rg "bindings/node/http/llhttp" . --type cpp --type cmake | head -20

Repository: oven-sh/bun

Length of output: 168


🏁 Script executed:

# Verify that the new llhttp path matches the directory structure
ls -la ./src/buntime/node/http/llhttp/ | head -20

Repository: oven-sh/bun

Length of output: 524


Fix stale llhttp README path in comment at line 208

The comment references src/buntime/bindings/node/http/llhttp/README.md, but the file is now at src/buntime/node/http/llhttp/README.md. Update the comment to point to the correct location.

The #include "SerializedScriptValue.h" at line 52 is correct; the directory src/buntime/web/serialization is explicitly in the CMake include path for this target.

🧰 Tools
🪛 Cppcheck (2.19.0)

[information] 52-52: Include file

(missingInclude)

🤖 Prompt for AI Agents
In src/buntime/api/process/BunProcess.cpp around lines 52-52, leave the #include
"SerializedScriptValue.h" unchanged (it's correct), but update the stale comment
at line ~208 that references src/buntime/bindings/node/http/llhttp/README.md to
the new path src/buntime/node/http/llhttp/README.md; open the file, locate the
comment at line 208, replace the old path with the new one, and save the file.

Comment on lines +25 to +30
#define UV_PLATFORM_LOOP_FIELDS \
int fs_fd;

#define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \
char *dir_filename; \
#define UV_PLATFORM_FS_EVENT_FIELDS \
uv__io_t event_watcher; \
char* dir_filename;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Style‑only edits in vendored libuv header

These changes are purely formatting/pointer‑style; the macros still expand identically and won’t affect behavior. To keep future libuv updates straightforward, consider avoiding style‑only edits in vendored headers unless you’re standardizing on a repo‑wide C style here.

🤖 Prompt for AI Agents
In src/buntime/compat/libuv/uv/aix.h around lines 25 to 30, the PR contains
style-only edits to macro formatting/pointer style in vendored libuv headers;
revert these changes so the macros exactly match the upstream libuv file
(restore original whitespace and pointer style for UV_PLATFORM_LOOP_FIELDS and
UV_PLATFORM_FS_EVENT_FIELDS) and avoid touching other vendored headers unless
you intend a repo-wide C style standardization and provide a separate, tracked
change for that.

@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Closing this PR because it has been inactive for more than 90 days.

@github-actions github-actions Bot closed this Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant