reconstruct and build @anthropic-ai/claude-code source from source map

- Extract 4756 source files from cli.js.map (57MB)
- Set up Bun build system with bun:bundle feature flag shim
- Configure 90+ compile-time feature flags matching production defaults
- Inject MACRO constants (VERSION, BUILD_TIME, etc.)
- Create stubs for private packages (color-diff-napi, modifiers-napi, etc.)
- Install all public dependencies via pnpm
- Patch commander v14 to allow multi-char short flags (-d2e)
- Build output: dist/cli.js (22MB), verified working
This commit is contained in:
janlaywss
2026-03-31 19:19:50 +08:00
commit 6187147b74
37865 changed files with 5438634 additions and 0 deletions

View File

@@ -0,0 +1 @@
../../has-flag@5.0.1/node_modules/has-flag

View File

@@ -0,0 +1 @@
../../supports-color@10.2.2/node_modules/supports-color

View File

@@ -0,0 +1,10 @@
export function createSupportsHyperlinks() {
return false;
}
const supportsHyperlinks = {
stdout: createSupportsHyperlinks(),
stderr: createSupportsHyperlinks(),
};
export default supportsHyperlinks;

View File

@@ -0,0 +1,25 @@
/**
Creates a supports hyperlinks check for a given stream.
@param stream - Optional stream to check for hyperlink support.
@returns boolean indicating whether hyperlinks are supported.
*/
export function createSupportsHyperlinks(stream?: {isTTY?: boolean}): boolean;
/**
Object containing hyperlink support status for stdout and stderr.
*/
type SupportsHyperlinks = {
/**
Whether stdout supports hyperlinks.
*/
stdout: boolean;
/**
Whether stderr supports hyperlinks.
*/
stderr: boolean;
};
declare const supportsHyperlinks: SupportsHyperlinks;
export default supportsHyperlinks;

View File

@@ -0,0 +1,157 @@
import process from 'node:process';
import {createSupportsColor} from 'supports-color';
import hasFlag from 'has-flag';
function parseVersion(versionString = '') {
if (/^\d{3,4}$/.test(versionString)) {
// Env var doesn't always use dots. example: 4601 => 46.1.0
const match = /(\d{1,2})(\d{2})/.exec(versionString) ?? [];
return {
major: 0,
minor: Number.parseInt(match[1], 10),
patch: Number.parseInt(match[2], 10),
};
}
const versions = (versionString ?? '').split('.').map(n => Number.parseInt(n, 10));
return {
major: versions[0],
minor: versions[1],
patch: versions[2],
};
}
// eslint-disable-next-line complexity
export function createSupportsHyperlinks(stream) {
const {
CI,
CURSOR_TRACE_ID,
FORCE_HYPERLINK,
NETLIFY,
TEAMCITY_VERSION,
TERM_PROGRAM,
TERM_PROGRAM_VERSION,
VTE_VERSION,
TERM,
} = process.env;
if (FORCE_HYPERLINK) {
return !(FORCE_HYPERLINK.length > 0 && Number.parseInt(FORCE_HYPERLINK, 10) === 0);
}
if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
return false;
}
if (hasFlag('hyperlink=true') || hasFlag('hyperlink=always')) {
return true;
}
// Netlify does not run a TTY, it does not need `supportsColor` check
if (NETLIFY) {
return true;
}
// If they specify no colors, they probably don't want hyperlinks.
if (!createSupportsColor(stream)) {
return false;
}
if (stream && !stream.isTTY) {
return false;
}
// Windows Terminal
if ('WT_SESSION' in process.env) {
return true;
}
if (process.platform === 'win32') {
return false;
}
if (CI) {
return false;
}
if (TEAMCITY_VERSION) {
return false;
}
if (TERM_PROGRAM) {
const version = parseVersion(TERM_PROGRAM_VERSION);
switch (TERM_PROGRAM) {
case 'iTerm.app': {
if (version.major === 3) {
return version.minor >= 1;
}
return version.major > 3;
}
case 'WezTerm': {
// WezTerm packaged by Nix uses their own version scheme.
if (/^0-unstable-\d{4}-\d{2}-\d{2}$/.test(TERM_PROGRAM_VERSION)) {
const date = TERM_PROGRAM_VERSION.slice('0-unstable-'.length);
return date >= '2020-06-20';
}
// This number is a date and reads better grouped as such.
// eslint-disable-next-line unicorn/numeric-separators-style
return version.major >= 2020_06_20;
}
case 'vscode': {
// Cursor forked VS Code and supports hyperlinks in 0.x.x
if (CURSOR_TRACE_ID) {
return true;
}
// eslint-disable-next-line @stylistic/no-mixed-operators
return version.major > 1 || version.major === 1 && version.minor >= 72;
}
case 'ghostty': {
return true;
}
case 'zed': {
return true;
}
// No default
}
}
if (VTE_VERSION) {
// 0.50.0 was supposed to support hyperlinks, but throws a segfault
if (VTE_VERSION === '0.50.0') {
return false;
}
const version = parseVersion(VTE_VERSION);
return version.major > 0 || version.minor >= 50;
}
switch (TERM) {
case 'alacritty': {
// Support added in v0.11 (2022-10-13)
return true;
}
case 'xterm-kitty': {
return true;
}
// No default
}
return false;
}
const supportsHyperlinks = {
stdout: createSupportsHyperlinks(process.stdout),
stderr: createSupportsHyperlinks(process.stderr),
};
export default supportsHyperlinks;

View File

@@ -0,0 +1,10 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Copyright (c) James Talmage <james@talmage.io> (https://github.com/jamestalmage)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,47 @@
{
"name": "supports-hyperlinks",
"version": "4.4.0",
"description": "Detect whether a terminal supports hyperlinks",
"license": "MIT",
"repository": "chalk/supports-hyperlinks",
"funding": "https://github.com/chalk/supports-hyperlinks?sponsor=1",
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=20"
},
"scripts": {
"test": "xo && ava && tsc --lib es2022 index.d.ts"
},
"files": [
"index.js",
"index.d.ts",
"browser.js"
],
"browser": "browser.js",
"keywords": [
"link",
"terminal",
"hyperlink",
"cli",
"detect",
"check",
"ansi",
"escapes",
"console"
],
"dependencies": {
"has-flag": "^5.0.1",
"supports-color": "^10.2.2"
},
"devDependencies": {
"ava": "^6.4.1",
"codecov": "^3.8.3",
"typescript": "^5.9.3",
"xo": "^1.2.3"
}
}

View File

@@ -0,0 +1,39 @@
# supports-hyperlinks
> Detect whether a terminal supports hyperlinks
Terminal emulators are [starting to support hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda). While many terminals have long detected URL's and linkified them, allowing you to Command-Click or Control-Click them to open a browser, you were forced to print the long unsightly URL's on the screen. As of spring 2017 [a few terminals](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) began supporting HTML like links, where the link text and destination could be specified separately.
This module allows you to detect if hyperlinks are supported in the current Terminal.
As this is a new development, we anticipate the list of supported terminals to grow rapidly. Please open an issue or submit a PR as new terminals implement support.
## Install
```sh
npm install supports-hyperlinks
```
## Usage
```js
import supportsHyperlinks from 'supports-hyperlinks';
if (supportsHyperlinks.stdout) {
console.log('Terminal stdout supports hyperlinks');
}
if (supportsHyperlinks.stderr) {
console.log('Terminal stderr supports hyperlinks');
}
```
## API
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is a `boolean`, indicating whether or not hyperlinks are supported.
## Info
Obeys the `--no-hyperlinks`, `--hyperlink=always`, and `--hyperlink=never` CLI flags.
Can be overridden by the user with the flags `--hyperlinks=always` and `--no-hyperlinks`. For situations where using those flags are not possible, add the environment variable `FORCE_HYPERLINK=1` to forcefully enable hyperlinks or `FORCE_HYPERLINK=0` to forcefully disable. The use of `FORCE_HYPERLINK` overrides all other hyperlink support checks.