Skip to content

Open source CapCut alternative.

TypeScript

fix(app): never gate a capability probe behind a consent prompt

David Lecf5ed7603363
diff --git a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
index 10b9f168..ed3af0b6 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
+++ b/apps/Donkey/Sources/DonkeyRuntime/Resources/BuiltInSkills/system-tools/SKILL.md
@@ -36,7 +36,6 @@ Use `shell_exec` as the first choice for anything an expert terminal user would
- Battery / power: `pmset -g batt`. Hardware/software: `system_profiler SPHardwareDataType`, `sw_vers`.
- Disk: `df -h`. Network: `networksetup -getairportpower en0`, `networksetup -getinfo Wi-Fi`.
- A preference's current value: `defaults read com.apple.dock autohide`.
-- Tool availability/version (to decide what's possible): `which gh`, `python3 --version`.
## Change settings (asks for consent first)
- App/UI preferences: `defaults write com.apple.dock autohide -bool true` then `killall Dock` to apply.
diff --git a/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift b/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift
index 09c63130..55e5eca9 100644
--- a/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift
+++ b/apps/Donkey/Sources/DonkeyRuntime/ShellCommandClassifier.swift
@@ -318,6 +318,18 @@ public enum ShellCommandClassifier {
return ShellCommandClassification(tier: .reversibleWrite, signature: "sed -i", reason: "edits a file in place")
}
return ShellCommandClassification(tier: .read, signature: "sed", reason: nil)
+ case "python3", "python", "ruby", "perl", "node":
+ // A bare version/help probe of an interpreter prints a string and exits — it runs no script, so
+ // it is a read like `which`/`command -v`, never a "runs a … script" consent prompt. This is what
+ // keeps a stray `python3 --version` capability probe from gating an otherwise read-only chain
+ // (the bug that put an Approve/Deny in front of a video clip). Restricted to the unambiguous long
+ // flags: `python -v` means verbose (it drops into an interactive REPL), so only `--version` /
+ // `--help` — never the short forms — qualify. Any other argument (a `-c`, an `-e`, a script path)
+ // returns nil and falls through to the "runs a … script" reversibleWrite mapping below.
+ if !tokens.isEmpty, tokens.allSatisfy({ $0 == "--version" || $0 == "--help" }) {
+ return ShellCommandClassification(tier: .read, signature: "\(executable) --version", reason: nil)
+ }
+ return nil
default:
return nil
}
diff --git a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift
index 55063cf7..bc8c9ed2 100644
--- a/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift
+++ b/apps/Donkey/Tests/DonkeyRuntimeTests/ShellCommandClassifierTests.swift
@@ -71,6 +71,22 @@ struct ShellCommandClassifierTests {
#expect(tier("\"/Users/me/Library/Application Support/Donkey/donkey-tools/yt-dlp\" --exec 'rm -rf ~' 'https://youtu.be/x'") == .highRisk)
}
+ @Test
+ func versionAndHelpProbesNeverPrompt() {
+ // A version/existence probe prints a string and exits — a read like `which`, even for an
+ // interpreter. This is the exact chain the screenshot prompted on: a stray capability probe must
+ // never put an Approve/Deny in front of a video clip.
+ #expect(tier("uname -a; sw_vers; python3 --version; which python3") == .read)
+ #expect(tier("python3 --version") == .read)
+ #expect(tier("node --version") == .read)
+ #expect(tier("ruby --help") == .read)
+ // But an interpreter that actually runs code still prompts — only the bare version/help flags are
+ // a read; `-c`, a script path, or a bare REPL keep the "runs a script" gate.
+ #expect(tier("python3 -c 'print(1)'") == .reversibleWrite)
+ #expect(tier("python3 map.py --version") == .reversibleWrite)
+ #expect(tier("python3") == .reversibleWrite)
+ }
+
@Test
func commandExecutionFlagsAreHighRiskEvenOnTrustedTools() {
// yt-dlp's --exec runs an arbitrary command after download — it must never run silently, even