fix: fall back to well-known path when CLAUDE_PLUGIN_DATA is not injected#14
Merged
Merged
Conversation
…cted Previously, /clone:api-key import-env and set failed with an error when CLAUDE_PLUGIN_DATA was not set by the Claude Code harness. status also fell through to demo fallback even when a token was already saved. Now pluginDataDir() returns ~/.claude/plugins/data/clone-clone-labs as a fallback so token reads and writes work regardless of whether the harness injects the env var. status output labels the path as a fallback when CLAUDE_PLUGIN_DATA is not present so users can tell the difference. Test isolation: runHook in stop-hook-v2.test.mjs now always sets CLAUDE_PLUGIN_DATA to a temporary workdir-local path instead of deleting it, preventing the developer's saved token from leaking into test assertions.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
/clone:api-key import-envandsetfailed with an error whenCLAUDE_PLUGIN_DATAwas not set:statusalso fell through to demo fallback even when a token was already saved, because withoutCLAUDE_PLUGIN_DATAthe script had no idea where to look.Root cause
CLAUDE_PLUGIN_DATAis only injected by the Claude Code harness when the skill runs inside a session. Running the script outside the harness (or when the env var is missing for any reason) left the storage path completely unknown.Changes
pluginDataDir()now falls back to~/.claude/plugins/data/clone-clone-labswhenCLAUDE_PLUGIN_DATAis not setthrowfromwritePluginConfigToken()— a fallback path is always availablestatusoutput labels the path as(fallback path — CLAUDE_PLUGIN_DATA not injected)so users can tell the differencerunHookinstop-hook-v2.test.mjsnow always setsCLAUDE_PLUGIN_DATAto a temporary workdir-local path instead of deleting it, preventing the developer's saved token from leaking into test assertionsVerification
import-envsucceeds withoutCLAUDE_PLUGIN_DATA— token saved to fallback pathstatuscorrectly reportssource: plugin configafter saving