agentpack-cli 0.3.2__tar.gz → 0.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/PKG-INFO +6 -6
  2. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/README.md +5 -5
  3. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/pyproject.toml +1 -1
  4. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/__init__.py +1 -1
  5. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/doctor.py +1 -0
  6. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/hook_cmd.py +17 -5
  7. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/git_hooks.py +4 -7
  8. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/global_install.py +53 -11
  9. agentpack_cli-0.3.4/src/agentpack/integrations/platform.py +59 -0
  10. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/.gitignore +0 -0
  11. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/LICENSE +0 -0
  12. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/__init__.py +0 -0
  13. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/antigravity.py +0 -0
  14. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/base.py +0 -0
  15. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/claude.py +0 -0
  16. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/codex.py +0 -0
  17. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/cursor.py +0 -0
  18. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/detect.py +0 -0
  19. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/generic.py +0 -0
  20. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/windsurf.py +0 -0
  21. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/__init__.py +0 -0
  22. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/dependency_graph.py +0 -0
  23. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/go_imports.py +0 -0
  24. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/java_imports.py +0 -0
  25. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/js_ts_imports.py +0 -0
  26. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/monorepo.py +0 -0
  27. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/naming_signals.py +0 -0
  28. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/python_imports.py +0 -0
  29. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/ranking.py +0 -0
  30. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/repo_map.py +0 -0
  31. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/role_inference.py +0 -0
  32. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/rust_imports.py +0 -0
  33. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/symbols.py +0 -0
  34. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/task_classifier.py +0 -0
  35. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/tests.py +0 -0
  36. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/application/__init__.py +0 -0
  37. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/application/pack_service.py +0 -0
  38. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/cli.py +0 -0
  39. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/__init__.py +0 -0
  40. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/_shared.py +0 -0
  41. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/benchmark.py +0 -0
  42. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/claude_cmd.py +0 -0
  43. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/diff.py +0 -0
  44. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/explain.py +0 -0
  45. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/init.py +0 -0
  46. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/install.py +0 -0
  47. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/mcp_cmd.py +0 -0
  48. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/monitor.py +0 -0
  49. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/pack.py +0 -0
  50. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/quickstart.py +0 -0
  51. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/repair.py +0 -0
  52. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/scan.py +0 -0
  53. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/stats.py +0 -0
  54. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/status.py +0 -0
  55. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/summarize.py +0 -0
  56. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/tune.py +0 -0
  57. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/watch.py +0 -0
  58. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/__init__.py +0 -0
  59. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/bootstrap.py +0 -0
  60. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/cache.py +0 -0
  61. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/config.py +0 -0
  62. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/context_pack.py +0 -0
  63. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/diff.py +0 -0
  64. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/git.py +0 -0
  65. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/git_hooks.py +0 -0
  66. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/global_install.py +0 -0
  67. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/ignore.py +0 -0
  68. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/merkle.py +0 -0
  69. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/models.py +0 -0
  70. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/redactor.py +0 -0
  71. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/scanner.py +0 -0
  72. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/snapshot.py +0 -0
  73. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/token_estimator.py +0 -0
  74. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/vscode_tasks.py +0 -0
  75. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/data/agentpack.md +0 -0
  76. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/__init__.py +0 -0
  77. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/antigravity.py +0 -0
  78. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/claude.py +0 -0
  79. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/codex.py +0 -0
  80. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/cursor.py +0 -0
  81. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/windsurf.py +0 -0
  82. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/__init__.py +0 -0
  83. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/agents.py +0 -0
  84. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/vscode_tasks.py +0 -0
  85. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/mcp_server.py +0 -0
  86. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/__init__.py +0 -0
  87. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/compact.py +0 -0
  88. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/markdown.py +0 -0
  89. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/receipts.py +0 -0
  90. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/session/__init__.py +0 -0
  91. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/session/state.py +0 -0
  92. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/summaries/__init__.py +0 -0
  93. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/summaries/base.py +0 -0
  94. {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/summaries/offline.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentpack-cli
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Summary: Local context engine for AI coding agents that ranks relevant files and builds task-focused context packs.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -46,9 +46,9 @@ Description-Content-Type: text/markdown
46
46
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
47
47
  [![CI](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml/badge.svg)](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
48
48
 
49
- > **Status: alpha (v0.3.2).** Works, tested, used in real sessions. Python and JavaScript/TypeScript are the best-supported languages. Public benchmark proof exists for the current suite, but broader repo coverage is still growing. API may change before 1.0.
49
+ > **Status: alpha (v0.3.4).** Works, tested, used in real sessions. Python and JavaScript/TypeScript are the best-supported languages. Public benchmark proof exists for the current suite, but broader repo coverage is still growing. API may change before 1.0.
50
50
  >
51
- > **Platform note:** macOS and Linux are fully supported. Windows support is not yet implemented (git hooks use POSIX shell; the Claude Code session hooks use `python3`/`rm -f`). Contributions welcome.
51
+ > **Platform note:** macOS, Linux, and Windows are supported. Windows support targets PowerShell plus Git for Windows. `cmd.exe` and bare Git setups are not a supported path yet.
52
52
 
53
53
  **Local context engine for AI coding agents.**
54
54
 
@@ -584,7 +584,7 @@ agentpack global-install --agent antigravity # Antigravity
584
584
 
585
585
  What it does:
586
586
  - **Git template hooks** (`~/.git-templates/hooks/`) — git copies these into every repo on `git init` / `git clone`. On `post-commit`, `post-merge`, `post-checkout`: silently repacks **only if `.agentpack/config.toml` exists** — no-op in repos that haven't opted in.
587
- - **Shell cd hook** (`~/.zshrc` or `~/.bashrc`) — on `cd`, repacks if stale **only in opted-in repos**. Never touches repos without `.agentpack/config.toml`. Never auto-inits.
587
+ - **Shell cd hook** (`~/.zshrc`, `~/.bashrc`, or the PowerShell profile on Windows) — on `cd` or prompt refresh, repacks if stale **only in opted-in repos**. Never touches repos without `.agentpack/config.toml`. Never auto-inits.
588
588
  - **Agent config** — same agent-specific files that `agentpack init --agent <x>` or `agentpack install --agent <x>` writes for the current project.
589
589
 
590
590
  All changes are idempotent, reversible, and non-destructive. Existing hooks and rc files are appended to, never overwritten. Repos you haven't explicitly run `agentpack init` in are never touched.
@@ -1513,7 +1513,7 @@ src/agentpack/
1513
1513
 
1514
1514
  ## Known limitations
1515
1515
 
1516
- - **Windows**: not supported. Git hooks use POSIX shell (`#!/bin/sh`, `>/dev/null 2>&1 &`). The Claude Code session hooks use `python3` and `rm -f`. Contributions welcome.
1516
+ - **Windows**: supported with PowerShell plus Git for Windows. AgentPack installs cross-platform Git hook launchers and a PowerShell profile hook for opted-in repos. `cmd.exe` is not a first-class workflow yet.
1517
1517
  - **Monorepos**: workspace-aware ranking supports npm/pnpm, Cargo, and `go.work` layouts. `--workspace` creates filtered per-workspace outputs. Package dependency hints currently come from npm/pnpm `package.json`; Cargo/Go workspace membership is detected, but package-manager dependency edges for Cargo/Go are not yet modeled.
1518
1518
  - **Public benchmark proof**: `benchmarks/public-repos.toml` is a curated smoke suite over real public commits, and `benchmarks/results/2026-05-15-public.md` records the current proof run. Treat it as a floor, not a leaderboard; expand cases before broad external claims.
1519
1519
  - **Symbol extraction**: Python (AST, full) and JavaScript/TypeScript (regex, arrow functions + classes) are well-supported. Go, Rust, Java, Kotlin have import graph traversal but no symbol extraction — they fall back to file-level summaries.
@@ -1585,7 +1585,7 @@ For npm publish, configure GitHub secret `NPM_TOKEN`. The token must publish to
1585
1585
  Good contribution areas:
1586
1586
 
1587
1587
  - More real-world benchmark fixtures and public repo eval cases
1588
- - Windows support for hooks and session integrations
1588
+ - Better Windows ergonomics beyond the supported PowerShell + Git for Windows path
1589
1589
  - Better symbol extraction for Go, Rust, Java, and Kotlin
1590
1590
  - More precise import/dependency resolution for framework-heavy repos
1591
1591
  - Ranking regressions with `expected_files` cases that reproduce misses
@@ -7,9 +7,9 @@
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
  [![CI](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml/badge.svg)](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
9
9
 
10
- > **Status: alpha (v0.3.2).** Works, tested, used in real sessions. Python and JavaScript/TypeScript are the best-supported languages. Public benchmark proof exists for the current suite, but broader repo coverage is still growing. API may change before 1.0.
10
+ > **Status: alpha (v0.3.4).** Works, tested, used in real sessions. Python and JavaScript/TypeScript are the best-supported languages. Public benchmark proof exists for the current suite, but broader repo coverage is still growing. API may change before 1.0.
11
11
  >
12
- > **Platform note:** macOS and Linux are fully supported. Windows support is not yet implemented (git hooks use POSIX shell; the Claude Code session hooks use `python3`/`rm -f`). Contributions welcome.
12
+ > **Platform note:** macOS, Linux, and Windows are supported. Windows support targets PowerShell plus Git for Windows. `cmd.exe` and bare Git setups are not a supported path yet.
13
13
 
14
14
  **Local context engine for AI coding agents.**
15
15
 
@@ -545,7 +545,7 @@ agentpack global-install --agent antigravity # Antigravity
545
545
 
546
546
  What it does:
547
547
  - **Git template hooks** (`~/.git-templates/hooks/`) — git copies these into every repo on `git init` / `git clone`. On `post-commit`, `post-merge`, `post-checkout`: silently repacks **only if `.agentpack/config.toml` exists** — no-op in repos that haven't opted in.
548
- - **Shell cd hook** (`~/.zshrc` or `~/.bashrc`) — on `cd`, repacks if stale **only in opted-in repos**. Never touches repos without `.agentpack/config.toml`. Never auto-inits.
548
+ - **Shell cd hook** (`~/.zshrc`, `~/.bashrc`, or the PowerShell profile on Windows) — on `cd` or prompt refresh, repacks if stale **only in opted-in repos**. Never touches repos without `.agentpack/config.toml`. Never auto-inits.
549
549
  - **Agent config** — same agent-specific files that `agentpack init --agent <x>` or `agentpack install --agent <x>` writes for the current project.
550
550
 
551
551
  All changes are idempotent, reversible, and non-destructive. Existing hooks and rc files are appended to, never overwritten. Repos you haven't explicitly run `agentpack init` in are never touched.
@@ -1474,7 +1474,7 @@ src/agentpack/
1474
1474
 
1475
1475
  ## Known limitations
1476
1476
 
1477
- - **Windows**: not supported. Git hooks use POSIX shell (`#!/bin/sh`, `>/dev/null 2>&1 &`). The Claude Code session hooks use `python3` and `rm -f`. Contributions welcome.
1477
+ - **Windows**: supported with PowerShell plus Git for Windows. AgentPack installs cross-platform Git hook launchers and a PowerShell profile hook for opted-in repos. `cmd.exe` is not a first-class workflow yet.
1478
1478
  - **Monorepos**: workspace-aware ranking supports npm/pnpm, Cargo, and `go.work` layouts. `--workspace` creates filtered per-workspace outputs. Package dependency hints currently come from npm/pnpm `package.json`; Cargo/Go workspace membership is detected, but package-manager dependency edges for Cargo/Go are not yet modeled.
1479
1479
  - **Public benchmark proof**: `benchmarks/public-repos.toml` is a curated smoke suite over real public commits, and `benchmarks/results/2026-05-15-public.md` records the current proof run. Treat it as a floor, not a leaderboard; expand cases before broad external claims.
1480
1480
  - **Symbol extraction**: Python (AST, full) and JavaScript/TypeScript (regex, arrow functions + classes) are well-supported. Go, Rust, Java, Kotlin have import graph traversal but no symbol extraction — they fall back to file-level summaries.
@@ -1546,7 +1546,7 @@ For npm publish, configure GitHub secret `NPM_TOKEN`. The token must publish to
1546
1546
  Good contribution areas:
1547
1547
 
1548
1548
  - More real-world benchmark fixtures and public repo eval cases
1549
- - Windows support for hooks and session integrations
1549
+ - Better Windows ergonomics beyond the supported PowerShell + Git for Windows path
1550
1550
  - Better symbol extraction for Go, Rust, Java, and Kotlin
1551
1551
  - More precise import/dependency resolution for framework-heavy repos
1552
1552
  - Ranking regressions with `expected_files` cases that reproduce misses
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "agentpack-cli"
3
- version = "0.3.2"
3
+ version = "0.3.4"
4
4
  description = "Local context engine for AI coding agents that ranks relevant files and builds task-focused context packs."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,3 +1,3 @@
1
1
  """AgentPack — task-aware context packing for AI coding agents."""
2
2
 
3
- __version__ = "0.3.2"
3
+ __version__ = "0.3.4"
@@ -154,6 +154,7 @@ def register(app: typer.Typer) -> None:
154
154
  "context.claude.md" in cmd
155
155
  or ".context_injected" in cmd
156
156
  or (".mcp_reminded" in cmd and "python3" in cmd)
157
+ or ("agentpack pack" in cmd and "GitAutoRepack" not in cmd)
157
158
  for cmd in all_cmds
158
159
  )
159
160
 
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  import json
4
4
  import re
5
- import subprocess
6
5
  import sys
7
6
  from pathlib import Path
8
7
 
@@ -11,6 +10,7 @@ import typer
11
10
  from agentpack.commands._shared import _root
12
11
  from agentpack.core import git as _git
13
12
  from agentpack.core.config import load_config
13
+ from agentpack.integrations.platform import cli_module_argv, detached_popen
14
14
 
15
15
  _TASK_FILE = ".agentpack/task.md"
16
16
  _TASK_FILE_DEFAULT_MARKER = "Write or update the current coding task here."
@@ -55,6 +55,7 @@ def register(app: typer.Typer) -> None:
55
55
  @app.command(name="hook")
56
56
  def hook(
57
57
  event: str = typer.Option("UserPromptSubmit", "--event", help="Hook event name."),
58
+ agent: str = typer.Option("auto", "--agent", help="Agent name for git auto-repack hooks."),
58
59
  ) -> None:
59
60
  """Run as a Claude Code hook. Reads stdin (JSON), emits additionalContext."""
60
61
  root = _root()
@@ -62,6 +63,8 @@ def register(app: typer.Typer) -> None:
62
63
  _run_user_prompt_submit(root)
63
64
  elif event == "SessionStart":
64
65
  _run_session_start(root)
66
+ elif event == "GitAutoRepack":
67
+ _run_git_auto_repack(root, agent)
65
68
  else:
66
69
  sys.exit(0)
67
70
 
@@ -266,6 +269,16 @@ def _run_session_start(root: Path) -> None:
266
269
  # No output needed — SessionStart hooks don't inject additionalContext
267
270
 
268
271
 
272
+ def _run_git_auto_repack(root: Path, agent: str) -> None:
273
+ config_path = root / ".agentpack" / "config.toml"
274
+ if not config_path.exists():
275
+ return
276
+ detached_popen(
277
+ cli_module_argv("pack", "--agent", agent, "--task", "auto", "--mode", "balanced"),
278
+ cwd=root,
279
+ )
280
+
281
+
269
282
  def _run_user_prompt_submit(root: Path) -> None:
270
283
  snap_sentinel = root / ".agentpack" / ".mcp_reminded"
271
284
 
@@ -311,10 +324,9 @@ def _run_user_prompt_submit(root: Path) -> None:
311
324
  _write_task_md(root, task)
312
325
  except Exception:
313
326
  pass
314
- subprocess.Popen(
315
- ["agentpack", "pack", "--task", "auto", "--mode", "balanced", "--since", "HEAD~1"],
316
- stdout=subprocess.DEVNULL,
317
- stderr=subprocess.DEVNULL,
327
+ detached_popen(
328
+ cli_module_argv("pack", "--task", "auto", "--mode", "balanced", "--since", "HEAD~1"),
329
+ cwd=root,
318
330
  )
319
331
  try:
320
332
  snap_sentinel.write_text(current_hash or "1")
@@ -3,6 +3,8 @@ from __future__ import annotations
3
3
  import stat
4
4
  from pathlib import Path
5
5
 
6
+ from agentpack.integrations.platform import cli_module_argv, shell_join
7
+
6
8
  # Hooks that indicate the working tree changed and the pack may be stale.
7
9
  _HOOK_EVENTS = ("post-commit", "post-merge", "post-checkout")
8
10
 
@@ -10,14 +12,9 @@ _AGENTPACK_MARKER = "# agentpack:auto-repack"
10
12
 
11
13
 
12
14
  def _hook_script(agent: str) -> str:
13
- # Use --agent auto so detection runs at hook time, not install time.
14
- # The agent arg is kept for callers that want an explicit override.
15
15
  effective = agent if agent not in ("auto", "") else "auto"
16
- return (
17
- f"{_AGENTPACK_MARKER}\n"
18
- f"agentpack pack --agent {effective} --task auto --mode balanced "
19
- f">/dev/null 2>&1 &\n"
20
- )
16
+ command = shell_join(cli_module_argv("hook", "--event", "GitAutoRepack", "--agent", effective))
17
+ return f"{_AGENTPACK_MARKER}\n{command}\n"
21
18
 
22
19
 
23
20
  def install_git_hooks(root: Path, agent: str) -> dict[str, str]:
@@ -5,6 +5,14 @@ import re
5
5
  import stat
6
6
  from pathlib import Path
7
7
 
8
+ from agentpack.integrations.platform import (
9
+ cli_module_argv,
10
+ is_windows,
11
+ powershell_command,
12
+ powershell_start_process,
13
+ shell_join,
14
+ )
15
+
8
16
  # ---------------------------------------------------------------------------
9
17
  # Git template hooks — copied into .git/hooks/ on every git init / git clone
10
18
  # ---------------------------------------------------------------------------
@@ -12,28 +20,22 @@ from pathlib import Path
12
20
  _GIT_TEMPLATE_DIR = Path.home() / ".git-templates"
13
21
  _AGENTPACK_MARKER = "# agentpack:global"
14
22
 
15
- _REPACK_CMD = """\
16
- ( agentpack pack --task auto --mode balanced >/dev/null 2>&1 &
17
- _ap_pid=$! ; ( sleep 30 && kill $_ap_pid 2>/dev/null ) &
18
- )"""
23
+ _REPACK_CMD = shell_join(cli_module_argv("hook", "--event", "GitAutoRepack", "--agent", "auto"))
19
24
 
20
25
  _POST_CHECKOUT_SCRIPT = """\
21
26
  #!/bin/sh
22
27
  # agentpack:global
23
- # Repack only if this repo has already been opted in to agentpack.
24
- [ -f .agentpack/config.toml ] && """ + _REPACK_CMD.strip() + "\n"
28
+ """ + _REPACK_CMD.strip() + "\n"
25
29
 
26
30
  _POST_COMMIT_SCRIPT = """\
27
31
  #!/bin/sh
28
32
  # agentpack:global
29
- # Repack only if this repo has already been opted in to agentpack.
30
- [ -f .agentpack/config.toml ] && """ + _REPACK_CMD.strip() + "\n"
33
+ """ + _REPACK_CMD.strip() + "\n"
31
34
 
32
35
  _POST_MERGE_SCRIPT = """\
33
36
  #!/bin/sh
34
37
  # agentpack:global
35
- # Repack only if this repo has already been opted in to agentpack.
36
- [ -f .agentpack/config.toml ] && """ + _REPACK_CMD.strip() + "\n"
38
+ """ + _REPACK_CMD.strip() + "\n"
37
39
 
38
40
  _HOOK_SCRIPTS = {
39
41
  "post-checkout": _POST_CHECKOUT_SCRIPT,
@@ -172,6 +174,38 @@ if [[ "$PROMPT_COMMAND" != *"_agentpack_chpwd"* ]]; then
172
174
  fi
173
175
  # agentpack:chpwd:end"""
174
176
 
177
+ _POWERSHELL_STATUS = powershell_command(cli_module_argv("status"))
178
+ _POWERSHELL_SESSION_START = powershell_start_process(cli_module_argv("session", "start", "--silent"))
179
+ _POWERSHELL_PACK = powershell_start_process(cli_module_argv("pack", "--task", "auto", "--mode", "balanced"))
180
+
181
+ _POWERSHELL_HOOK = f"""\
182
+ # agentpack:chpwd:start
183
+ function global:Invoke-AgentPackChpwd {{
184
+ if (Test-Path ".agentpack/config.toml") {{
185
+ if (-not (Test-Path ".agentpack/context.md") -and -not (Test-Path ".agentpack/session.json")) {{
186
+ {_POWERSHELL_SESSION_START}
187
+ }} else {{
188
+ {_POWERSHELL_STATUS} *> $null
189
+ if ($LASTEXITCODE -ne 0) {{
190
+ {_POWERSHELL_PACK}
191
+ }}
192
+ }}
193
+ }}
194
+ }}
195
+ if (-not (Get-Command __agentpack_original_prompt -ErrorAction SilentlyContinue)) {{
196
+ Set-Item -Path Function:\\__agentpack_original_prompt -Value $function:prompt
197
+ }}
198
+ function global:prompt {{
199
+ Invoke-AgentPackChpwd
200
+ if (Get-Command __agentpack_original_prompt -ErrorAction SilentlyContinue) {{
201
+ & __agentpack_original_prompt
202
+ }} else {{
203
+ "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
204
+ }}
205
+ }}
206
+ Invoke-AgentPackChpwd
207
+ # agentpack:chpwd:end"""
208
+
175
209
  _BLOCK_RE = re.compile(
176
210
  r"# agentpack:chpwd:start.*?# agentpack:chpwd:end\n?",
177
211
  re.DOTALL,
@@ -179,6 +213,11 @@ _BLOCK_RE = re.compile(
179
213
 
180
214
 
181
215
  def _detect_rc_file() -> Path | None:
216
+ if is_windows():
217
+ home = Path.home()
218
+ modern = home / "Documents" / "PowerShell" / "Microsoft.PowerShell_profile.ps1"
219
+ legacy = home / "Documents" / "WindowsPowerShell" / "Microsoft.PowerShell_profile.ps1"
220
+ return modern if modern.exists() or not legacy.exists() else legacy
182
221
  shell = os.environ.get("SHELL", "")
183
222
  if "zsh" in shell:
184
223
  return Path.home() / ".zshrc"
@@ -195,7 +234,10 @@ def install_shell_hook(rc_file: Path | None = None, dry_run: bool = False) -> tu
195
234
  if target is None:
196
235
  return "skipped (unknown shell)", None
197
236
 
198
- shell_hook = _ZSH_HOOK if "zsh" in str(target) else _BASH_HOOK
237
+ if target.suffix.lower() == ".ps1" or is_windows():
238
+ shell_hook = _POWERSHELL_HOOK
239
+ else:
240
+ shell_hook = _ZSH_HOOK if "zsh" in str(target) else _BASH_HOOK
199
241
 
200
242
  if target.exists():
201
243
  content = target.read_text()
@@ -0,0 +1,59 @@
1
+ from __future__ import annotations
2
+
3
+ import shlex
4
+ import subprocess
5
+ import sys
6
+ from pathlib import Path
7
+
8
+
9
+ def is_windows(platform: str | None = None) -> bool:
10
+ value = platform or sys.platform
11
+ return value.startswith("win")
12
+
13
+
14
+ def cli_module_argv(*args: str, python_executable: str | None = None) -> list[str]:
15
+ return [python_executable or sys.executable, "-m", "agentpack.cli", *args]
16
+
17
+
18
+ def shell_quote(value: str | Path) -> str:
19
+ return shlex.quote(str(value))
20
+
21
+
22
+ def shell_join(argv: list[str]) -> str:
23
+ return " ".join(shell_quote(part) for part in argv)
24
+
25
+
26
+ def powershell_quote(value: str | Path) -> str:
27
+ return "'" + str(value).replace("'", "''") + "'"
28
+
29
+
30
+ def powershell_command(argv: list[str]) -> str:
31
+ exe = powershell_quote(argv[0])
32
+ args = " ".join(powershell_quote(arg) for arg in argv[1:])
33
+ return f"& {exe} {args}"
34
+
35
+
36
+ def powershell_start_process(argv: list[str]) -> str:
37
+ exe = powershell_quote(argv[0])
38
+ arg_list = ", ".join(powershell_quote(arg) for arg in argv[1:])
39
+ return f"Start-Process -WindowStyle Hidden -FilePath {exe} -ArgumentList @({arg_list}) | Out-Null"
40
+
41
+
42
+ def detached_popen(argv: list[str], *, cwd: Path | None = None) -> subprocess.Popen[str]:
43
+ kwargs: dict[str, object] = {
44
+ "cwd": str(cwd) if cwd else None,
45
+ "stdin": subprocess.DEVNULL,
46
+ "stdout": subprocess.DEVNULL,
47
+ "stderr": subprocess.DEVNULL,
48
+ "close_fds": True,
49
+ "text": True,
50
+ }
51
+ if is_windows():
52
+ kwargs["creationflags"] = (
53
+ getattr(subprocess, "DETACHED_PROCESS", 0)
54
+ | getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
55
+ | getattr(subprocess, "CREATE_NO_WINDOW", 0)
56
+ )
57
+ else:
58
+ kwargs["start_new_session"] = True
59
+ return subprocess.Popen(argv, **kwargs)
File without changes
File without changes