From cf482195ff2d351d1545db7a2e53a16408c6afe1 Mon Sep 17 00:00:00 2001 From: nirholas Date: Tue, 31 Mar 2026 11:18:17 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Fix=20import.meta.dir=20fallback=20?= =?UTF-8?q?handling=20in=20build=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++++++++- scripts/build-bundle.ts | 2 +- scripts/package-npm.ts | 8 +++++++- src/constants/querySource.ts | 22 +++++++++++++++++++++ src/query/transitions.ts | 37 ++++++++++++++++++++++++++++++++++++ src/types/bun-globals.d.ts | 10 ++++++++++ 6 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 src/constants/querySource.ts create mode 100644 src/query/transitions.ts create mode 100644 src/types/bun-globals.d.ts diff --git a/README.md b/README.md index dead1ca..68447d3 100644 --- a/README.md +++ b/README.md @@ -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 \ diff --git a/scripts/build-bundle.ts b/scripts/build-bundle.ts index 5e2f14c..79c5890 100644 --- a/scripts/build-bundle.ts +++ b/scripts/build-bundle.ts @@ -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`) } } diff --git a/scripts/package-npm.ts b/scripts/package-npm.ts index 0c12d49..f5d39e3 100644 --- a/scripts/package-npm.ts +++ b/scripts/package-npm.ts @@ -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') diff --git a/src/constants/querySource.ts b/src/constants/querySource.ts new file mode 100644 index 0000000..eba291a --- /dev/null +++ b/src/constants/querySource.ts @@ -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 diff --git a/src/query/transitions.ts b/src/query/transitions.ts new file mode 100644 index 0000000..d0655ae --- /dev/null +++ b/src/query/transitions.ts @@ -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 & {}) +} diff --git a/src/types/bun-globals.d.ts b/src/types/bun-globals.d.ts new file mode 100644 index 0000000..23fc01f --- /dev/null +++ b/src/types/bun-globals.d.ts @@ -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 +}