-
Notifications
You must be signed in to change notification settings - Fork 1
fix(pi): standardize on name when installing/updating #86
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ const OPENCODE_PACKAGE: &str = "@braintrust/trace-opencode"; | |
| const PI_PACKAGE: &str = "@braintrust/pi-extension"; | ||
| const OPENCODE_PACKAGE_MANIFEST: &str = | ||
| include_str!("../../src/plugins/opencode/content/package.json"); | ||
| const PI_PACKAGE_MANIFEST: &str = include_str!("../../src/plugins/pi/content/package.json"); | ||
| const ANTIGRAVITY_PLUGIN: &str = "braintrust-antigravity-tracing"; | ||
| const LEGACY_CLAUDE_TRACING_ENV_KEYS: [&str; 2] = ["BRAINTRUST_CC_PROJECT", "BRAINTRUST_CC_DEBUG"]; | ||
| #[cfg(unix)] | ||
|
|
@@ -53,11 +52,8 @@ fn opencode_plugin_spec() -> anyhow::Result<String> { | |
| npm_major_spec(OPENCODE_PACKAGE, OPENCODE_PACKAGE_MANIFEST) | ||
| } | ||
|
|
||
| pub(crate) fn pi_plugin_spec() -> anyhow::Result<String> { | ||
| Ok(format!( | ||
| "npm:{}", | ||
| npm_major_spec(PI_PACKAGE, PI_PACKAGE_MANIFEST)? | ||
| )) | ||
| pub(crate) fn pi_plugin_spec() -> String { | ||
| format!("npm:{PI_PACKAGE}") | ||
| } | ||
|
|
||
| fn version_is_older(installed: &str, expected: &str) -> bool { | ||
|
|
@@ -139,10 +135,10 @@ fn pi_update_required() -> bool { | |
| return false; | ||
| } | ||
| let installed = String::from_utf8_lossy(&output.stdout); | ||
| let expected = pi_plugin_spec(); | ||
| installed.lines().any(|line| { | ||
| let plugin = line.trim(); | ||
| plugin.starts_with("npm:@braintrust/pi-extension") | ||
| && Some(plugin) != pi_plugin_spec().ok().as_deref() | ||
| plugin.starts_with(&expected) && plugin != expected | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -673,18 +669,18 @@ fn disable_opencode() -> anyhow::Result<()> { | |
| } | ||
|
|
||
| fn setup_pi(runner: &mut impl CommandRunner) -> anyhow::Result<()> { | ||
| let plugin = pi_plugin_spec()?; | ||
| let plugin = pi_plugin_spec(); | ||
| runner.run("pi", &["install", &plugin]) | ||
| } | ||
|
|
||
| fn disable_pi(runner: &mut impl CommandRunner) -> anyhow::Result<()> { | ||
| let plugin = pi_plugin_spec()?; | ||
| let plugin = pi_plugin_spec(); | ||
| runner.run("pi", &["uninstall", &plugin]) | ||
|
Comment on lines
+677
to
678
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Users who enabled Pi with any prior release have the configured source Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| fn update_pi(runner: &mut impl CommandRunner) -> anyhow::Result<()> { | ||
| let package = format!("npm:{PI_PACKAGE}"); | ||
| runner.run("pi", &["update", &package]) | ||
| let plugin = pi_plugin_spec(); | ||
| runner.run("pi", &["update", &plugin]) | ||
| } | ||
|
|
||
| fn antigravity_home(config_dir: &Path) -> anyhow::Result<&Path> { | ||
|
|
@@ -1333,12 +1329,12 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn pi_installs_the_published_extension_range() { | ||
| fn pi_installs_the_latest_published_extension() { | ||
| let mut runner = FakeRunner::new([]); | ||
|
|
||
| setup_pi(&mut runner).unwrap(); | ||
|
|
||
| assert!(runner.called(&format!("pi install {}", pi_plugin_spec().unwrap()))); | ||
| assert!(runner.called("pi install npm:@braintrust/pi-extension")); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
@@ -1672,7 +1668,7 @@ mod tests { | |
|
|
||
| let mut pi = FakeRunner::new([]); | ||
| disable_pi(&mut pi).unwrap(); | ||
| assert!(pi.called(&format!("pi uninstall {}", pi_plugin_spec().unwrap()))); | ||
| assert!(pi.called("pi uninstall npm:@braintrust/pi-extension")); | ||
| } | ||
|
|
||
| #[test] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For every installation created by the new
setup_pi,pi listreports the same unversioned sourcenpm:@braintrust/pi-extension, so this predicate remains false even after a newer extension is published and the locally resolved package is stale. Consequentlyupdate_warning("pi")can no longer prompt these users to runbt trace update pi; inspect Pi's installed/resolved version rather than comparing the configured source string.Useful? React with 👍 / 👎.