✨ Fix import.meta.dir fallback handling in build scripts
This commit is contained in:
12
README.md
12
README.md
@@ -9,6 +9,7 @@
|
||||
[](#tech-stack)
|
||||
[](#directory-structure)
|
||||
[](#-explore-with-mcp-server)
|
||||
[](https://www.npmjs.com/package/claude-code-explorer-mcp)
|
||||
|
||||
> The original unmodified leaked source is preserved in the [`backup` branch](https://github.com/nirholas/claude-code/tree/backup).
|
||||
|
||||
@@ -83,7 +84,16 @@ Also see: [CONTRIBUTING.md](CONTRIBUTING.md) · [MCP Server README](mcp-server/R
|
||||
|
||||
This repo ships an [MCP server](https://modelcontextprotocol.io/) that lets any MCP-compatible client (Claude Code, Claude Desktop, VS Code Copilot, Cursor) explore the full source interactively.
|
||||
|
||||
### One-liner setup
|
||||
### Install from npm
|
||||
|
||||
The MCP server is published as [`claude-code-explorer-mcp`](https://www.npmjs.com/package/claude-code-explorer-mcp) on npm — no need to clone the repo:
|
||||
|
||||
```bash
|
||||
# Claude Code
|
||||
claude mcp add claude-code-explorer -- npx -y claude-code-explorer-mcp
|
||||
```
|
||||
|
||||
### One-liner setup (from source)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/nirholas/claude-code.git ~/claude-code \
|
||||
|
||||
@@ -174,7 +174,7 @@ async function main() {
|
||||
const outFiles = Object.entries(result.metafile.outputs)
|
||||
for (const [file, info] of outFiles) {
|
||||
if (file.endsWith('.mjs')) {
|
||||
const sizeMB = (info.bytes / 1024 / 1024).toFixed(2)
|
||||
const sizeMB = ((info as { bytes: number }).bytes / 1024 / 1024).toFixed(2)
|
||||
console.log(`\n ${file}: ${sizeMB} MB`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,13 @@
|
||||
import { readFileSync, writeFileSync, mkdirSync, copyFileSync, existsSync, chmodSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
|
||||
const ROOT = resolve(import.meta.dir, '..')
|
||||
// Bun: import.meta.dir — Node 21+: import.meta.dirname — fallback
|
||||
const __dir: string =
|
||||
(import.meta as ImportMeta & { dir?: string; dirname?: string }).dir ??
|
||||
(import.meta as ImportMeta & { dir?: string; dirname?: string }).dirname ??
|
||||
new URL('.', import.meta.url).pathname
|
||||
|
||||
const ROOT = resolve(__dir, '..')
|
||||
const DIST = resolve(ROOT, 'dist')
|
||||
const NPM_DIR = resolve(DIST, 'npm')
|
||||
const CLI_BUNDLE = resolve(DIST, 'cli.mjs')
|
||||
|
||||
22
src/constants/querySource.ts
Normal file
22
src/constants/querySource.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* QuerySource identifies where a query originated from.
|
||||
* Used for analytics, retry logic, and cache control decisions.
|
||||
*/
|
||||
export type QuerySource =
|
||||
| 'repl_main_thread'
|
||||
| 'sdk'
|
||||
| 'compact'
|
||||
| 'side_question'
|
||||
| 'agent'
|
||||
| 'agent:custom'
|
||||
| 'agent:explore'
|
||||
| 'agent:plan'
|
||||
| 'tool_use_summary'
|
||||
| 'advisor'
|
||||
| 'hook'
|
||||
| 'session_memory'
|
||||
| 'magic_docs'
|
||||
| 'skill_search'
|
||||
| 'classifier'
|
||||
| 'bridge'
|
||||
| (string & {}) // Allow other string values for extensibility
|
||||
37
src/query/transitions.ts
Normal file
37
src/query/transitions.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Transition types for the query loop.
|
||||
*
|
||||
* Terminal: why the loop exited (returned).
|
||||
* Continue: why the loop continued to the next iteration (not returned).
|
||||
*/
|
||||
|
||||
/** Terminal transition — the query loop returned. */
|
||||
export type Terminal = {
|
||||
reason:
|
||||
| 'completed'
|
||||
| 'blocking_limit'
|
||||
| 'image_error'
|
||||
| 'model_error'
|
||||
| 'aborted_streaming'
|
||||
| 'aborted_tools'
|
||||
| 'prompt_too_long'
|
||||
| 'stop_hook_prevented'
|
||||
| 'hook_stopped'
|
||||
| 'max_turns'
|
||||
| (string & {})
|
||||
error?: unknown
|
||||
}
|
||||
|
||||
/** Continue transition — the loop will iterate again. */
|
||||
export type Continue = {
|
||||
reason:
|
||||
| 'tool_use'
|
||||
| 'reactive_compact_retry'
|
||||
| 'max_output_tokens_recovery'
|
||||
| 'max_output_tokens_escalate'
|
||||
| 'collapse_drain_retry'
|
||||
| 'stop_hook_blocking'
|
||||
| 'token_budget_continuation'
|
||||
| 'queued_command'
|
||||
| (string & {})
|
||||
}
|
||||
10
src/types/bun-globals.d.ts
vendored
Normal file
10
src/types/bun-globals.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// Bun runtime global type augmentations.
|
||||
// The bun-types package provides these when installed; this file acts as a
|
||||
// lightweight fallback so the project type-checks without it.
|
||||
|
||||
interface ImportMeta {
|
||||
/** Bun: absolute path of the directory containing the current file */
|
||||
dir: string
|
||||
/** Node 21+ / Bun: same as dir */
|
||||
dirname: string
|
||||
}
|
||||
Reference in New Issue
Block a user