Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/integration/assets/antigravity_cli/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=antigravity_cli
# HERDR_INTEGRATION_VERSION=1
# HERDR_INTEGRATION_VERSION=2

# Session-only: this hook reports the Antigravity conversation so Herdr can
# resume the pane. Lifecycle state comes from Herdr's screen detection.
Expand Down Expand Up @@ -33,6 +33,7 @@ $conversationId = if ($payload.conversationId -is [string]) { $payload.conversat
if ([string]::IsNullOrWhiteSpace($conversationId)) { Exit-Hook }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
try {
$sessionArgs = @(
"pane",
Expand All @@ -50,7 +51,7 @@ try {
if ($payload.transcriptPath -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.transcriptPath)) {
$sessionArgs += @("--agent-session-path", "$($payload.transcriptPath)")
}
& herdr @sessionArgs 2>$null | Out-Null
& $herdr @sessionArgs 2>$null | Out-Null
} catch {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=antigravity_cli
# HERDR_INTEGRATION_VERSION=1
# HERDR_INTEGRATION_VERSION=2

# Session-only: this hook reports the Antigravity conversation so Herdr can
# resume the pane. Lifecycle state comes from Herdr's screen detection.
Expand Down
5 changes: 3 additions & 2 deletions src/integration/assets/claude/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=claude
# HERDR_INTEGRATION_VERSION=7
# HERDR_INTEGRATION_VERSION=8

param([string]$Action = "")

Expand All @@ -24,6 +24,7 @@ $sessionId = $payload.session_id
if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
try {
$args = @(
"pane",
Expand All @@ -44,6 +45,6 @@ try {
if ($payload.hook_event_name -eq "SessionStart" -and $payload.source -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.source)) {
$args += @("--session-start-source", "$($payload.source)")
}
& herdr @args 2>$null | Out-Null
& $herdr @args 2>$null | Out-Null
} catch {
}
2 changes: 1 addition & 1 deletion src/integration/assets/claude/herdr-agent-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=claude
# HERDR_INTEGRATION_VERSION=7
# HERDR_INTEGRATION_VERSION=8

set -eu

Expand Down
5 changes: 3 additions & 2 deletions src/integration/assets/codex/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=codex
# HERDR_INTEGRATION_VERSION=7
# HERDR_INTEGRATION_VERSION=8

param([string]$Action = "")

Expand All @@ -25,6 +25,7 @@ if ([string]::IsNullOrWhiteSpace($payload.transcript_path)) { exit 0 }
if (-not [string]::IsNullOrWhiteSpace($env:CODEX_THREAD_ID) -and $env:CODEX_THREAD_ID -ne $sessionId) { exit 0 }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
try {
$args = @(
"pane",
Expand All @@ -42,6 +43,6 @@ try {
if ($payload.hook_event_name -eq "SessionStart" -and $payload.source -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.source)) {
$args += @("--session-start-source", "$($payload.source)")
}
& herdr @args 2>$null | Out-Null
& $herdr @args 2>$null | Out-Null
} catch {
}
2 changes: 1 addition & 1 deletion src/integration/assets/codex/herdr-agent-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=codex
# HERDR_INTEGRATION_VERSION=7
# HERDR_INTEGRATION_VERSION=8

set -eu

Expand Down
5 changes: 3 additions & 2 deletions src/integration/assets/copilot/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=copilot
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

if ($env:HERDR_ENV -ne "1") { exit 0 }
if ([string]::IsNullOrWhiteSpace($env:HERDR_PANE_ID)) { exit 0 }
Expand Down Expand Up @@ -49,4 +49,5 @@ if ([string]::IsNullOrWhiteSpace($sessionId)) {
if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
& herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:copilot --agent copilot --agent-session-id $sessionId --seq $seq 2>$null | Out-Null
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
& $herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:copilot --agent copilot --agent-session-id $sessionId --seq $seq 2>$null | Out-Null
2 changes: 1 addition & 1 deletion src/integration/assets/copilot/herdr-agent-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=copilot
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

set -eu

Expand Down
5 changes: 3 additions & 2 deletions src/integration/assets/droid/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=droid
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

param([string]$Action = "")

Expand All @@ -20,7 +20,8 @@ try {
if ($null -eq $payload -or [string]::IsNullOrWhiteSpace($payload.session_id)) { exit 0 }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
try {
& herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:droid --agent droid --agent-session-id $payload.session_id --seq $seq 2>$null | Out-Null
& $herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:droid --agent droid --agent-session-id $payload.session_id --seq $seq 2>$null | Out-Null
} catch {
}
2 changes: 1 addition & 1 deletion src/integration/assets/droid/herdr-agent-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=droid
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

set -eu

Expand Down
9 changes: 5 additions & 4 deletions src/integration/assets/kimi/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=kimi
# HERDR_INTEGRATION_VERSION=6
# HERDR_INTEGRATION_VERSION=7

param([string]$Action = "")

Expand All @@ -19,16 +19,17 @@ try {

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$sessionId = if ($null -ne $payload -and -not [string]::IsNullOrWhiteSpace($payload.session_id)) { $payload.session_id } else { $null }
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }

try {
if ($Action -eq "session") {
if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 }
& herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --agent-session-id $sessionId --session-start-source startup --seq $seq 2>$null | Out-Null
& $herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --agent-session-id $sessionId --session-start-source startup --seq $seq 2>$null | Out-Null
} else {
if ([string]::IsNullOrWhiteSpace($sessionId)) {
& herdr pane report-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --state $Action --seq $seq 2>$null | Out-Null
& $herdr pane report-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --state $Action --seq $seq 2>$null | Out-Null
} else {
& herdr pane report-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --state $Action --agent-session-id $sessionId --seq $seq 2>$null | Out-Null
& $herdr pane report-agent $env:HERDR_PANE_ID --source herdr:kimi --agent kimi --state $Action --agent-session-id $sessionId --seq $seq 2>$null | Out-Null
}
}
} catch {
Expand Down
2 changes: 1 addition & 1 deletion src/integration/assets/kimi/herdr-agent-state.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
# managed by herdr; reinstalling the integration replaces this file.
# HERDR_INTEGRATION_ID=kimi
# HERDR_INTEGRATION_VERSION=6
# HERDR_INTEGRATION_VERSION=7

action="${1:-}"
case "$action" in
Expand Down
5 changes: 3 additions & 2 deletions src/integration/assets/qodercli/herdr-agent-state.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# managed by herdr; reinstalling or updating the integration overwrites this file.
# add custom hooks beside this file instead of editing it.
# HERDR_INTEGRATION_ID=qodercli
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

param([string]$Action = "")

Expand All @@ -20,7 +20,8 @@ try {
if ($null -eq $payload -or [string]::IsNullOrWhiteSpace($payload.session_id)) { exit 0 }

$seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()
$herdr = if ([string]::IsNullOrWhiteSpace($env:HERDR_BIN_PATH)) { "herdr" } else { $env:HERDR_BIN_PATH }
try {
& herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:qodercli --agent qodercli --agent-session-id $payload.session_id --seq $seq 2>$null | Out-Null
& $herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:qodercli --agent qodercli --agent-session-id $payload.session_id --seq $seq 2>$null | Out-Null
} catch {
}
6 changes: 3 additions & 3 deletions src/integration/assets/qodercli/herdr-agent-state.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/sh
# managed by herdr; reinstalling the integration replaces this file.
# HERDR_INTEGRATION_ID=qodercli
# HERDR_INTEGRATION_VERSION=2
# HERDR_INTEGRATION_VERSION=3

[ "${1:-}" = "session" ] || exit 0
[ "${HERDR_ENV:-}" = "1" ] || exit 0
[ -n "${HERDR_SOCKET_PATH:-}" ] || exit 0
[ -n "${HERDR_PANE_ID:-}" ] || exit 0
command -v herdr >/dev/null 2>&1 || exit 0
command -v python3 >/dev/null 2>&1 || exit 0

python3 -c '
Expand All @@ -24,7 +23,8 @@ try:
raise ValueError
subprocess.run(
[
"herdr", "pane", "report-agent-session", os.environ["HERDR_PANE_ID"],
os.environ.get("HERDR_BIN_PATH") or "herdr",
"pane", "report-agent-session", os.environ["HERDR_PANE_ID"],
"--source", "herdr:qodercli", "--agent", "qodercli",
"--agent-session-id", session_id, "--seq", str(time.time_ns()),
],
Expand Down
14 changes: 7 additions & 7 deletions src/integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CLAUDE_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/claude/herdr-agent-state.sh")
};
const CLAUDE_INTEGRATION_VERSION: u32 = 7;
const CLAUDE_INTEGRATION_VERSION: u32 = 8;
const CODEX_HOOK_INSTALL_NAME: &str = if cfg!(windows) {
"herdr-agent-state.ps1"
} else {
Expand All @@ -49,7 +49,7 @@ const CODEX_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/codex/herdr-agent-state.sh")
};
const CODEX_INTEGRATION_VERSION: u32 = 7;
const CODEX_INTEGRATION_VERSION: u32 = 8;
const KIMI_HOOK_INSTALL_NAME: &str = if cfg!(windows) {
"herdr-agent-state.ps1"
} else {
Expand All @@ -60,7 +60,7 @@ const KIMI_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/kimi/herdr-agent-state.sh")
};
const KIMI_INTEGRATION_VERSION: u32 = 6;
const KIMI_INTEGRATION_VERSION: u32 = 7;
const KIMI_CONFIG_BLOCK_BEGIN: &str = "# >>> herdr kimi integration";
const KIMI_CONFIG_BLOCK_END: &str = "# <<< herdr kimi integration";
const KIMI_MIN_VERSION: &str = "0.14.0";
Expand Down Expand Up @@ -102,7 +102,7 @@ const COPILOT_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/copilot/herdr-agent-state.sh")
};
const COPILOT_INTEGRATION_VERSION: u32 = 2;
const COPILOT_INTEGRATION_VERSION: u32 = 3;
const COPILOT_HOOK_EVENTS: [&str; 1] = ["SessionStart"];
const COPILOT_REMOVED_LIFECYCLE_HOOK_EVENTS: [&str; 9] = [
"UserPromptSubmit",
Expand Down Expand Up @@ -152,7 +152,7 @@ const DROID_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/droid/herdr-agent-state.sh")
};
const DROID_INTEGRATION_VERSION: u32 = 2;
const DROID_INTEGRATION_VERSION: u32 = 3;
const DROID_HOOK_EVENTS: [(&str, &str); 1] = [("SessionStart", "session")];
const DROID_REMOVED_LIFECYCLE_HOOK_EVENTS: [(&str, &str); 9] = [
("SessionStart", "idle"),
Expand Down Expand Up @@ -190,7 +190,7 @@ const QODERCLI_HOOK_ASSET: &str = if cfg!(windows) {
} else {
include_str!("assets/qodercli/herdr-agent-state.sh")
};
const QODERCLI_INTEGRATION_VERSION: u32 = 2;
const QODERCLI_INTEGRATION_VERSION: u32 = 3;
const QODERCLI_HOOK_EVENTS: [(&str, &str); 1] = [("SessionStart", "session")];
const QODERCLI_REMOVED_LIFECYCLE_HOOK_EVENTS: [(&str, &str); 12] = [
("SessionStart", "idle"),
Expand Down Expand Up @@ -227,7 +227,7 @@ const ANTIGRAVITY_CLI_HOOK_ASSET: &str =
#[cfg(not(windows))]
const ANTIGRAVITY_CLI_HOOK_ASSET: &str =
include_str!("assets/antigravity_cli/herdr-agent-state.sh");
const ANTIGRAVITY_CLI_INTEGRATION_VERSION: u32 = 1;
const ANTIGRAVITY_CLI_INTEGRATION_VERSION: u32 = 2;
/// Antigravity CLI keys `hooks.json` by hook name, so every Herdr entry lives
/// under one Herdr-owned block that install rewrites and uninstall removes.
const ANTIGRAVITY_CLI_HOOK_BLOCK_NAME: &str = "herdr";
Expand Down
11 changes: 8 additions & 3 deletions src/integration/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ fn claude_v1_integration_status_is_outdated() {

assert_eq!(claude.path, hook_path);
assert_eq!(claude.installed_version, Some(1));
assert_eq!(claude.expected_version, 7);
assert_eq!(claude.expected_version, 8);
assert_eq!(claude.state, IntegrationStatusKind::Outdated);

std::env::remove_var("HOME");
Expand Down Expand Up @@ -1088,7 +1088,7 @@ fn claude_v2_integration_status_is_outdated() {

assert_eq!(claude.path, hook_path);
assert_eq!(claude.installed_version, Some(2));
assert_eq!(claude.expected_version, 7);
assert_eq!(claude.expected_version, 8);
assert_eq!(claude.state, IntegrationStatusKind::Outdated);

std::env::remove_var("HOME");
Expand Down Expand Up @@ -1221,7 +1221,7 @@ fn codex_v2_integration_status_is_outdated() {

assert_eq!(codex.path, hook_path);
assert_eq!(codex.installed_version, Some(2));
assert_eq!(codex.expected_version, 7);
assert_eq!(codex.expected_version, 8);
assert_eq!(codex.state, IntegrationStatusKind::Outdated);

std::env::remove_var("HOME");
Expand Down Expand Up @@ -2724,6 +2724,11 @@ fn bundled_integration_asset_versions_match_expected_versions() {
QODERCLI_INTEGRATION_VERSION,
),
("cursor", CURSOR_HOOK_ASSET, CURSOR_INTEGRATION_VERSION),
(
"antigravity_cli",
ANTIGRAVITY_CLI_HOOK_ASSET,
ANTIGRAVITY_CLI_INTEGRATION_VERSION,
),
(
"mastracode",
MASTRACODE_HOOK_ASSET,
Expand Down
Loading