Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jdx
Copy link
Owner

@jdx jdx commented Jul 29, 2025

When tool stubs use the HTTP backend with version "latest" (the default),
generate a stable version string based on the URL hash. This prevents
repeated installations of the same tool when the URL hasn't changed.

The version format becomes "url-{8-char-hash}" instead of "latest",
ensuring consistent caching behavior and avoiding reinstallation on
every run.

πŸ€– Generated with Claude Code

Co-Authored-By: Claude [email protected]

When tool stubs use the HTTP backend with version "latest" (the default),
generate a stable version string based on the URL hash. This prevents
repeated installations of the same tool when the URL hasn't changed.

The version format becomes "url-{8-char-hash}" instead of "latest",
ensuring consistent caching behavior and avoiding reinstallation on
every run.

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings July 29, 2025 11:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This fix addresses an issue where HTTP-backed tool stubs with "latest" versions were being repeatedly installed due to unstable version strings. The change generates a stable version string based on the URL hash for HTTP backends using "latest" versions.

  • Modifies the to_tool_request method to generate hash-based versions for HTTP backends
  • Adds URL hash generation logic to create stable version identifiers
  • Imports the lookup_platform_key helper function for platform-specific URL lookups


ToolRequest::new_opts(backend_arg.into(), &self.version, options, source)
// For HTTP backend with "latest" version, use URL hash as version for stability
let version = if self.tool_name.starts_with("http:") && self.version == "latest" {
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition only checks for 'http:' URLs but doesn't include 'https:' URLs. This will miss HTTPS-based tool stubs that should also benefit from stable versioning.

Suggested change
let version = if self.tool_name.starts_with("http:") && self.version == "latest" {
let version = if (self.tool_name.starts_with("http:") || self.tool_name.starts_with("https:")) && self.version == "latest" {

Copilot uses AI. Check for mistakes.

lookup_platform_key(&options, "url").or_else(|| opts.get("url").cloned())
{
// Use first 8 chars of URL hash as version
format!("url-{}", &hash::hash_to_str(&url)[..8])
Copy link

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String slicing with [..8] can panic if the hash string is shorter than 8 characters. Consider using get(..8).unwrap_or(&hash) or ensure the hash function always returns sufficient characters.

Suggested change
format!("url-{}", &hash::hash_to_str(&url)[..8])
{
let hash = hash::hash_to_str(&url);
format!("url-{}", hash.get(..8).unwrap_or(&hash))
}

Copilot uses AI. Check for mistakes.

Copy link

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.7.30 x -- echo 18.1 Β± 0.5 17.7 26.2 1.00
mise x -- echo 18.4 Β± 0.3 17.8 21.1 1.01 Β± 0.03

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.7.30 env 17.6 Β± 0.4 17.0 22.7 1.00
mise env 17.7 Β± 0.3 17.2 19.7 1.01 Β± 0.03

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.7.30 hook-env 17.3 Β± 0.2 16.8 18.6 1.00
mise hook-env 17.5 Β± 0.4 17.0 21.0 1.01 Β± 0.03

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.7.30 ls 15.8 Β± 0.5 15.3 21.7 1.00
mise ls 16.1 Β± 0.2 15.6 17.0 1.02 Β± 0.03

xtasks/test/perf

Command mise-2025.7.30 mise Variance
install (cached) 187ms βœ… 129ms +44%
ls (cached) 80ms 81ms -1%
bin-paths (cached) 64ms 65ms -1%
task-ls (cached) 491ms 493ms +0%

βœ… Performance improvement: install cached is 44%

@jdx jdx enabled auto-merge (squash) July 29, 2025 11:37
@jdx jdx merged commit ce5fdfd into main Jul 29, 2025
33 of 34 checks passed
@jdx jdx deleted the tool-stub branch July 29, 2025 11:37
jdx pushed a commit that referenced this pull request Jul 29, 2025
### πŸš€ Features

- **(tool-stubs)** append to existing tool-stub files instead of
overwriting by [@jdx](https://github.com/jdx) in
[#5835](#5835)
- **(tool-stubs)** add auto-platform detection from URLs by
[@jdx](https://github.com/jdx) in
[#5836](#5836)
- Add sops.strict setting for non-strict decryption mode by
[@pepicrft](https://github.com/pepicrft) in
[#5378](#5378)

### πŸ› Bug Fixes

- **(tool-stub)** use URL hash as version for HTTP backend with "latest"
by [@jdx](https://github.com/jdx) in
[#5828](#5828)
- **(tool-stubs)** fix -v and --help flags by
[@jdx](https://github.com/jdx) in
[#5829](#5829)
- **(tool-stubs)** use 'checksum' field instead of 'blake3' in generated
stubs by [@jdx](https://github.com/jdx) in
[#5834](#5834)
- dotnet SearchQueryService fallback by
[@acesyde](https://github.com/acesyde) in
[#5824](#5824)
- registry.toml - Specify sbt dependency on java by
[@jatcwang](https://github.com/jatcwang) in
[#5827](#5827)

### πŸ§ͺ Testing

- remove has test which is failing by [@jdx](https://github.com/jdx) in
[4aa9cc9](4aa9cc9)

### New Contributors

- @jatcwang made their first contribution in
[#5827](#5827)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant