Skip to content

Commit 4d8f925

Browse files
authored
Merge pull request #684 from stakpak/refactor/rename-shell-tool-approvals-crate
refactor: rename shell tool approvals crate
2 parents 6042a24 + 16f7be7 commit 4d8f925

8 files changed

Lines changed: 53 additions & 45 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
# Branches trigger builds only (no release)
66
# - main: production builds
7-
# - beta: beta channel builds
7+
# - beta: beta channel builds
88
branches: [main, beta]
99
# Tags trigger full release workflow
1010
# - v1.2.3: stable release
@@ -218,11 +218,11 @@ jobs:
218218
VERSION=${VERSION#v}
219219
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
220220
echo "Tag version: $VERSION"
221-
221+
222222
# Verify version matches Cargo.toml
223223
CARGO_VERSION=$(grep -m1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
224224
echo "Cargo.toml version: $CARGO_VERSION"
225-
225+
226226
if [ "$VERSION" != "$CARGO_VERSION" ]; then
227227
echo "Warning: Tag version ($VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
228228
echo "Updating Cargo.toml to match tag version"
@@ -238,9 +238,9 @@ jobs:
238238
run: |
239239
set -e
240240
VERSION=${{ steps.get_version.outputs.VERSION }}
241-
241+
242242
echo "Publishing workspace members to crates.io version $VERSION"
243-
243+
244244
# Function to publish a package, skip if already published
245245
publish_package() {
246246
local pkg=$1
@@ -263,7 +263,7 @@ jobs:
263263
exit 1
264264
fi
265265
}
266-
266+
267267
# Publish dependencies first, then the main crate
268268
# Order matters: publish dependencies before dependents
269269
publish_package stakai
@@ -272,13 +272,14 @@ jobs:
272272
publish_package stakpak-mcp-client
273273
publish_package stakpak-mcp-server
274274
publish_package stakpak-mcp-proxy
275+
publish_package stakpak-shell-tool-approvals
275276
publish_package stakpak-agent-core
276277
publish_package stakpak-gateway
277278
publish_package stakpak-server
278279
publish_package stakpak-tui
279280
# Finally publish the main CLI crate
280281
publish_package stakpak
281-
282+
282283
echo "All packages published successfully!"
283284
env:
284285
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
@@ -317,7 +318,7 @@ jobs:
317318
steps:
318319
- uses: actions/checkout@v4
319320
with:
320-
fetch-depth: 0 # Need full history for git-cliff
321+
fetch-depth: 0 # Need full history for git-cliff
321322

322323
- name: Install git-cliff
323324
run: cargo install git-cliff
@@ -327,15 +328,15 @@ jobs:
327328
VERSION=${GITHUB_REF#refs/tags/}
328329
# Get the previous tag to generate notes between tags
329330
PREV_TAG=$(git describe --tags --abbrev=0 "$VERSION^" 2>/dev/null || echo "")
330-
331+
331332
if [ -z "$PREV_TAG" ]; then
332333
echo "No previous tag found, skipping release notes generation"
333334
exit 0
334335
fi
335-
336+
336337
# Generate notes between previous and current tag
337338
git-cliff "$PREV_TAG..$VERSION" --strip all > release_notes.md
338-
339+
339340
# Check if release notes are empty
340341
if [ ! -s release_notes.md ]; then
341342
echo "No commits found between $PREV_TAG and $VERSION"
@@ -347,19 +348,19 @@ jobs:
347348
- name: Update GitHub Release
348349
run: |
349350
VERSION=${GITHUB_REF#refs/tags/}
350-
351+
351352
# Check if release notes file exists and has content
352353
if [ ! -f release_notes.md ]; then
353354
echo "Release notes file not found, skipping update"
354355
exit 0
355356
fi
356-
357+
357358
# Check if file is empty or only contains whitespace
358359
if [ ! -s release_notes.md ] || ! grep -q '[^[:space:]]' release_notes.md; then
359360
echo "Release notes file is empty, skipping update"
360361
exit 0
361362
fi
362-
363+
363364
echo "Updating release notes for $VERSION"
364365
gh release edit "$VERSION" --notes-file release_notes.md || echo "Failed to update release notes, continuing anyway"
365366
env:
@@ -381,7 +382,7 @@ jobs:
381382
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
382383
VERSION: ${{ needs.setup.outputs.version }}
383384
run: |
384-
385+
385386
curl -L "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/stakpak-darwin-x86_64.tar.gz" -o stakpak-darwin-x86_64.tar.gz
386387
curl -L "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/stakpak-darwin-aarch64.tar.gz" -o stakpak-darwin-aarch64.tar.gz
387388
curl -L "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/stakpak-linux-x86_64.tar.gz" -o stakpak-linux-x86_64.tar.gz
@@ -397,7 +398,7 @@ jobs:
397398
desc "Stakpak CLI tool"
398399
homepage "https://github.com/stakpak/stakpak"
399400
version "${VERSION}"
400-
401+
401402
on_macos do
402403
if Hardware::CPU.arm?
403404
url "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/stakpak-darwin-aarch64.tar.gz"
@@ -407,7 +408,7 @@ jobs:
407408
sha256 "${SHA256_DARWIN_X64}"
408409
end
409410
end
410-
411+
411412
on_linux do
412413
if Hardware::CPU.arm?
413414
url "https://github.com/${{ github.repository }}/releases/download/v${VERSION}/stakpak-linux-aarch64.tar.gz"
@@ -417,7 +418,7 @@ jobs:
417418
sha256 "${SHA256_LINUX_X64}"
418419
end
419420
end
420-
421+
421422
def install
422423
bin.install "stakpak"
423424
end

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ stakpak-gateway = { path = "libs/gateway", version = "0.3.72" }
3737
stakpak-server = { path = "libs/server", version = "0.3.72" }
3838
stakpak-tui = { path = "tui", version = "0.3.72" }
3939
stakpak-shared = { path = "libs/shared", version = "0.3.72" }
40-
shell-tool-approvals = { path = "libs/shell-tool-approvals", version = "0.3.71" }
40+
stakpak-shell-tool-approvals = { path = "libs/shell-tool-approvals", version = "0.3.72" }
4141
serde = { version = "1.0.215", features = ["derive"] }
4242
serde_json = "1.0.133"
4343
uuid = { version = "1.10.0", features = ["serde", "v4"] }

libs/agent-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tokio = { workspace = true }
1717
chrono = { workspace = true }
1818
async-trait = { workspace = true }
1919
thiserror = { workspace = true }
20-
shell-tool-approvals = { workspace = true }
20+
stakpak-shell-tool-approvals = { workspace = true }
2121
tokio-util = { version = "0.7", features = ["rt"] }
2222

2323
[dev-dependencies]

libs/agent-core/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl ToolApprovalPolicy {
203203
Vec::new()
204204
};
205205

206-
match shell_tool_approvals::resolve_hierarchical_policy(
206+
match stakpak_shell_tool_approvals::resolve_hierarchical_policy(
207207
command_str,
208208
stripped,
209209
&fallback_scopes,
@@ -730,7 +730,7 @@ mod tests {
730730
default: ToolApprovalAction::Approve,
731731
};
732732
// The outer command is "sh", but the inner script contains "rm"
733-
// shell_tool_approvals recursively extracts inner commands from "sh -c '...'"
733+
// stakpak_shell_tool_approvals recursively extracts inner commands from "sh -c '...'"
734734
assert_eq!(
735735
policy.action_for(
736736
"run_command",

libs/shell-tool-approvals/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "shell-tool-approvals"
2+
name = "stakpak-shell-tool-approvals"
33
version = { workspace = true }
44
edition = "2024"
55
description = "Shell command parsing and hierarchical scope resolution for tool approval"

tui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ homepage = { workspace = true }
1111
stakai = { workspace = true }
1212
stakpak-shared = { workspace = true }
1313
stakpak-api = { workspace = true }
14-
shell-tool-approvals = { workspace = true }
14+
stakpak-shell-tool-approvals = { workspace = true }
1515
regex = { workspace = true }
1616
serde = { workspace = true }
1717
serde_json = { workspace = true }

tui/src/services/auto_approve.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn resolve_shell_scope(
412412
Vec::new()
413413
};
414414

415-
match shell_tool_approvals::resolve_hierarchical_policy(
415+
match stakpak_shell_tool_approvals::resolve_hierarchical_policy(
416416
command_str,
417417
tool_name,
418418
&fallback_scopes,
@@ -726,34 +726,41 @@ mod tests {
726726

727727
#[test]
728728
fn matches_pattern_exact() {
729-
assert!(shell_tool_approvals::matches_pattern("push", "push"));
730-
assert!(!shell_tool_approvals::matches_pattern("push", "pull"));
729+
assert!(stakpak_shell_tool_approvals::matches_pattern(
730+
"push", "push"
731+
));
732+
assert!(!stakpak_shell_tool_approvals::matches_pattern(
733+
"push", "pull"
734+
));
731735
}
732736

733737
#[test]
734738
fn matches_pattern_glob() {
735-
assert!(shell_tool_approvals::matches_pattern(
739+
assert!(stakpak_shell_tool_approvals::matches_pattern(
736740
"*.prod.*",
737741
"api.prod.example.com"
738742
));
739-
assert!(!shell_tool_approvals::matches_pattern(
743+
assert!(!stakpak_shell_tool_approvals::matches_pattern(
740744
"*.prod.*",
741745
"api.staging.example.com"
742746
));
743747
}
744748

745749
#[test]
746750
fn matches_pattern_regex() {
747-
assert!(shell_tool_approvals::matches_pattern("re:^push$", "push"));
748-
assert!(!shell_tool_approvals::matches_pattern(
751+
assert!(stakpak_shell_tool_approvals::matches_pattern(
752+
"re:^push$",
753+
"push"
754+
));
755+
assert!(!stakpak_shell_tool_approvals::matches_pattern(
749756
"re:^push$",
750757
"push-force"
751758
));
752759
}
753760

754761
#[test]
755762
fn matches_pattern_invalid_regex_returns_false() {
756-
assert!(!shell_tool_approvals::matches_pattern(
763+
assert!(!stakpak_shell_tool_approvals::matches_pattern(
757764
"re:[invalid",
758765
"anything"
759766
));

0 commit comments

Comments
 (0)