-
Notifications
You must be signed in to change notification settings - Fork 0
Make launcher cross-platform #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e26031
Use cross-platform temp dir
anirudh-bijay-glean 7519535
Replace `start.sh` with cross-platform `start.mjs`
anirudh-bijay-glean b858f68
Bump plugin version
anirudh-bijay-glean 6be821c
Merge branch 'main' into anirudh/windows-support
anirudh-bijay-glean 0c6e57d
Merge branch 'main' into anirudh/windows-support
anirudh-bijay-glean 267ea03
Update pre-commit hook to check `start.mjs` instead of `start.sh`
anirudh-bijay-glean de24111
Merge branch 'main' into anirudh/windows-support
anirudh-bijay-glean 876f713
Bump version to 0.2.38
anirudh-bijay-glean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/usr/bin/env node | ||
| // @ts-check | ||
| // Invoked by the plugin host (Claude Code, Codex, or Cursor) to launch the Glean | ||
| // MCP server. The plugin ships a single-file esbuild output at dist/index.js with | ||
| // every non-builtin inlined — no node_modules next to it. This script handles | ||
| // env sanitation before launching the plugin proper. | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| import { execFileSync } from "node:child_process"; | ||
|
|
||
| // Treat empty strings and un-interpolated "${VAR}" placeholders (which a host | ||
| // may pass through verbatim when a variable is unset) as "not set" — matching | ||
| // the bundle's own readEnv / resolveSessionId guards. | ||
| /** @param {string | undefined} v @returns {string | undefined} */ | ||
| function val(v) { | ||
| if (v === undefined) return undefined; | ||
| const t = v.trim(); | ||
| if (t === "" || t.startsWith("${")) return undefined; | ||
| return t; | ||
| } | ||
|
|
||
| const launchCwd = process.cwd(); | ||
|
|
||
| // Resolve where credentials, caches, and config are stored. | ||
| // CLAUDE_PLUGIN_DATA is the managed lifecycle dir provided by the plugin host. | ||
| const pluginDataDir = | ||
| val(process.env.CLAUDE_PLUGIN_DATA) ?? | ||
| path.join(os.homedir() || os.tmpdir(), ".glean"); | ||
| process.env.PLUGIN_DATA_DIR = pluginDataDir; | ||
|
|
||
| // Discovered skill files are written under the data dir by default, so the | ||
| // skills cache tracks PLUGIN_DATA_DIR instead of being resolved separately. | ||
| let skillsBaseDir = path.join(pluginDataDir, "glean-skills-cache"); | ||
|
|
||
| // Opt-in: when USE_CLAUDE_PROJECT_DIR=1, route the skills cache under the launch | ||
| // project's .claude/tmp/ so the glean_run skill's allowed-tools Read glob can | ||
| // match cache files via a path anchored to the project root. projectDir is the | ||
| // git repo root for the launch cwd, falling back to the launch cwd when it is | ||
| // not inside a git repo (or git is unavailable). | ||
| if (process.env.USE_CLAUDE_PROJECT_DIR === "1") { | ||
| let projectDir = launchCwd; | ||
| try { | ||
| const top = execFileSync( | ||
| "git", | ||
| ["-C", launchCwd, "rev-parse", "--show-toplevel"], | ||
| { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }, | ||
| ).trim(); | ||
| if (top) projectDir = top; | ||
| } catch { | ||
| /* not a git repo or git missing: keep the launch cwd fallback */ | ||
| } | ||
| skillsBaseDir = path.join(projectDir, ".claude", "tmp", "glean-skills-cache"); | ||
| } | ||
| process.env.SKILLS_BASE_DIR = skillsBaseDir; | ||
|
|
||
| // Resolve the chat session id host-side. Host-awareness lives here, not in the | ||
| // plugin: the launcher reads whatever variable this host exposes and exports the | ||
| // normalized GLEAN_SESSION_ID that the Node bundle reads. Claude Code exposes | ||
| // CLAUDE_CODE_SESSION_ID; Codex exposes the conversation id as CODEX_THREAD_ID. | ||
| // Hosts that expose no session id (Cursor) leave it unset, and the plugin falls | ||
| // back to a generated per-process id. | ||
| const sessionId = | ||
| val(process.env.CLAUDE_CODE_SESSION_ID) ?? val(process.env.CODEX_THREAD_ID); | ||
| if (sessionId !== undefined) { | ||
| process.env.GLEAN_SESSION_ID = sessionId; | ||
| } | ||
|
|
||
| // Boot the server in-process. Import via a file URL resolved against this | ||
| // module so the dynamic specifier works regardless of cwd and on Windows paths. | ||
| await import(new URL("./dist/index.js", import.meta.url).href); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ zip -r "$OUT" \ | |
| .mcp.json \ | ||
| dist \ | ||
| skills \ | ||
| start.sh \ | ||
| start.mjs \ | ||
| package.json \ | ||
| >/dev/null | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.