Repository navigation
Rename the agent plugin basecamp → basecamp-cli #840
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 all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c699183
Rename the agent plugin basecamp → basecamp-cli
jeremy c3470d5
Give the Codex legacy-plugin removal its own timeout
jeremy b779d64
Never let a legacy-plugin migration reach an unscoped uninstall; flag…
jeremy a756803
README: leave removing the old plugin key to setup's per-scope check
jeremy 4b6b7f2
Migrate a project or local legacy plugin only from the directory it b…
jeremy 04dce49
Point a failed Codex legacy removal at setup, not a bare plugin remove
jeremy 3bf8a39
Treat the pre-rename plugin key as stale instead of telling it apart …
jeremy e53d5f7
Seed the project-scope legacy fixture in the directory setup runs from
jeremy 97c0896
Tell installs under the pre-rename plugin id to switch to basecamp-cl…
jeremy f454d06
Deliver the rename notice through pre-commit-snapshot so older CLIs s…
jeremy e1f9930
Document the basecamp alias window and the one-time rename notice
jeremy dcd43bb
Pin the rename-notice hook count, decode its JSON in tests, and scope…
jeremy 917e451
Remove the old Codex plugin ID only once basecamp-cli is enabled
jeremy 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
Some comments aren't visible on the classic Files Changed page.
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
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,109 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/basecamp/basecamp-cli/internal/harness" | ||
| ) | ||
|
|
||
| // pluginRenameNoticeMarker records that the rename notice was shown for one | ||
| // plugin install, so it appears once rather than every session. | ||
| const pluginRenameNoticeMarker = "plugin-rename-notice-shown" | ||
|
|
||
| // emitPluginRenameNotice tells someone still running this plugin under its | ||
| // pre-rename id that it is now basecamp-cli. During the deprecation window the | ||
| // marketplace keeps "basecamp" as an alias with the same source, so the plugin | ||
| // keeps working; this nudges toward `basecamp setup`, once. | ||
| // | ||
| // The alias and basecamp-cli install the same files, so the manifest can't | ||
| // tell them apart. The plugin root can: agents cache each install under | ||
| // <marketplace>/<plugin id>/<version>. Anything other than an install as | ||
| // basecamp@37signals stays silent, so the hook injects nothing into normal | ||
| // sessions. | ||
| func emitPluginRenameNotice(cmd *cobra.Command) { | ||
| root := agentPluginRoot() | ||
| if !isLegacyPluginRoot(root) { | ||
| return | ||
| } | ||
| dir := agentPluginDataDir() | ||
| if dir == "" { | ||
| dir = agentHookStateDir(cmd.Context()) | ||
| } | ||
| if dir == "" || !claimOnce(filepath.Join(dir, pluginRenameNoticeMarker)) { | ||
| return | ||
| } | ||
| message := "The Basecamp plugin is now `" + harness.ClaudePluginName + "`. " + | ||
| "This copy still runs under its old name `" + harness.ClaudeLegacyPluginKey + "`, which keeps working for now. " + | ||
| "Run `" + legacyPluginSetupCommand(root) + "` to switch." | ||
| _ = json.NewEncoder(cmd.OutOrStdout()).Encode(map[string]any{ | ||
| "systemMessage": message, | ||
| "hookSpecificOutput": map[string]string{ | ||
| "hookEventName": "SessionStart", | ||
| "additionalContext": "Mention this to the user once: " + message, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| // agentPluginRoot is the plugin's install directory as the agent reports it: | ||
| // Claude Code sets CLAUDE_PLUGIN_ROOT, Codex sets PLUGIN_ROOT (and the | ||
| // Claude name too). | ||
| func agentPluginRoot() string { | ||
| if root := os.Getenv("CLAUDE_PLUGIN_ROOT"); root != "" { | ||
| return root | ||
| } | ||
| return os.Getenv("PLUGIN_ROOT") | ||
| } | ||
|
|
||
| func agentPluginDataDir() string { | ||
| if dir := os.Getenv("CLAUDE_PLUGIN_DATA"); dir != "" { | ||
| return dir | ||
| } | ||
| return os.Getenv("PLUGIN_DATA") | ||
| } | ||
|
|
||
| // isLegacyPluginRoot reports whether root is a cached install of | ||
| // basecamp@37signals: .../37signals/basecamp/<version>. | ||
| func isLegacyPluginRoot(root string) bool { | ||
| if root == "" { | ||
| return false | ||
| } | ||
| plugin := filepath.Dir(filepath.Clean(root)) | ||
| return filepath.Base(plugin) == harness.LegacyPluginName && filepath.Base(filepath.Dir(plugin)) == harness.ClaudeMarketplaceName | ||
| } | ||
|
|
||
| // legacyPluginSetupCommand names the setup command for the agent that owns | ||
| // root, falling back to setting up every detected agent. | ||
| func legacyPluginSetupCommand(root string) string { | ||
| if home, err := os.UserHomeDir(); err == nil { | ||
| for agent, dir := range map[string]string{"claude": ".claude", "codex": ".codex"} { | ||
| if rel, err := filepath.Rel(filepath.Join(home, dir), root); err == nil && filepath.IsLocal(rel) { | ||
| return "basecamp setup " + agent | ||
| } | ||
| } | ||
| } | ||
| if codexHome := os.Getenv("CODEX_HOME"); codexHome != "" { | ||
| if rel, err := filepath.Rel(codexHome, root); err == nil && filepath.IsLocal(rel) { | ||
| return "basecamp setup codex" | ||
| } | ||
| } | ||
| return "basecamp setup agents" | ||
| } | ||
|
|
||
| // claimOnce creates marker, reporting whether this call created it. Any | ||
| // failure counts as already shown: a notice that can't be recorded would | ||
| // otherwise repeat every session. | ||
| func claimOnce(marker string) bool { | ||
| if err := os.MkdirAll(filepath.Dir(marker), 0o700); err != nil { | ||
| return false | ||
| } | ||
| f, err := os.OpenFile(marker, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600) //nolint:gosec // G304: marker under the agent's plugin data dir | ||
| if err != nil { | ||
| return false | ||
| } | ||
| _ = f.Close() | ||
| return true | ||
| } |
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
Oops, something went wrong.
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.