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.
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/PKG-INFO +6 -6
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/README.md +5 -5
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/pyproject.toml +1 -1
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/__init__.py +1 -1
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/doctor.py +1 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/hook_cmd.py +17 -5
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/git_hooks.py +4 -7
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/global_install.py +53 -11
- agentpack_cli-0.3.4/src/agentpack/integrations/platform.py +59 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/.gitignore +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/LICENSE +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/antigravity.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/base.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/claude.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/codex.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/cursor.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/detect.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/generic.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/adapters/windsurf.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/dependency_graph.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/go_imports.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/java_imports.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/js_ts_imports.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/monorepo.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/naming_signals.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/python_imports.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/ranking.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/repo_map.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/role_inference.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/rust_imports.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/symbols.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/task_classifier.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/analysis/tests.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/application/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/application/pack_service.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/cli.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/_shared.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/benchmark.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/claude_cmd.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/diff.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/explain.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/init.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/install.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/mcp_cmd.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/monitor.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/pack.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/quickstart.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/repair.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/scan.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/stats.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/status.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/summarize.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/tune.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/commands/watch.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/bootstrap.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/cache.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/config.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/context_pack.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/diff.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/git.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/git_hooks.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/global_install.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/ignore.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/merkle.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/models.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/redactor.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/scanner.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/snapshot.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/token_estimator.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/core/vscode_tasks.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/data/agentpack.md +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/antigravity.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/claude.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/codex.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/cursor.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/installers/windsurf.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/agents.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/integrations/vscode_tasks.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/mcp_server.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/compact.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/markdown.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/renderers/receipts.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/session/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/session/state.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/summaries/__init__.py +0 -0
- {agentpack_cli-0.3.2 → agentpack_cli-0.3.4}/src/agentpack/summaries/base.py +0 -0
- {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.
|
|
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
|
[](https://opensource.org/licenses/MIT)
|
|
47
47
|
[](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
|
|
48
48
|
|
|
49
|
-
> **Status: alpha (v0.3.
|
|
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
|
|
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
|
|
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**:
|
|
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
|
|
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
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
[](https://github.com/vishal2612200/agentpack/actions/workflows/ci.yml)
|
|
9
9
|
|
|
10
|
-
> **Status: alpha (v0.3.
|
|
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
|
|
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
|
|
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**:
|
|
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
|
|
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
|
|
@@ -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
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|