Fix import.meta.dir fallback handling in build scripts

This commit is contained in:
nirholas
2026-03-31 11:18:17 +00:00
parent ed9c151933
commit cf482195ff
6 changed files with 88 additions and 3 deletions

View File

@@ -9,6 +9,7 @@
[![React + Ink](https://img.shields.io/badge/UI-React_%2B_Ink-61DAFB?logo=react&logoColor=black)](#tech-stack)
[![Files](https://img.shields.io/badge/~1,900_files-source_only-grey)](#directory-structure)
[![MCP Server](https://img.shields.io/badge/MCP-Explorer_Server-blueviolet)](#-explore-with-mcp-server)
[![npm](https://img.shields.io/npm/v/claude-code-explorer-mcp?label=npm&color=cb3837&logo=npm)](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 \

View File

@@ -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`)
}
}

View File

@@ -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')

View 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
View 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
View 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
}