agentgov-cli 0.1.14__tar.gz → 0.1.16__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 (30) hide show
  1. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/.gitignore +9 -0
  2. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/PKG-INFO +4 -2
  3. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/README.md +3 -1
  4. agentgov_cli-0.1.16/agentgov_cli/__init__.py +19 -0
  5. agentgov_cli-0.1.16/agentgov_cli/claude_env.py +69 -0
  6. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/client_assets/commands/workitem.md +6 -1
  7. agentgov_cli-0.1.16/agentgov_cli/client_assets/hooks/pretooluse_pathguard.py +715 -0
  8. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/client_assets/hooks/userpromptsubmit_workitem.py +569 -69
  9. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/client_assets/statusline/agentgov_statusline.sh +2 -2
  10. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/doctor.py +167 -30
  11. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/install.py +142 -7
  12. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/uninstall.py +52 -17
  13. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/workitem.py +17 -6
  14. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/wrap.py +43 -15
  15. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/gateway_process.py +40 -23
  16. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/pyproject.toml +1 -1
  17. agentgov_cli-0.1.14/agentgov_cli/__init__.py +0 -3
  18. agentgov_cli-0.1.14/agentgov_cli/client_assets/hooks/pretooluse_pathguard.py +0 -303
  19. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/asset_manifest.py +0 -0
  20. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/client_assets/hooks/sessionstart_register.py +0 -0
  21. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/client_assets/managed-settings.json.tmpl +0 -0
  22. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/__init__.py +0 -0
  23. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/gateway.py +0 -0
  24. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/login.py +0 -0
  25. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/register_device.py +0 -0
  26. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/commands/status.py +0 -0
  27. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/loopback.py +0 -0
  28. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/main.py +0 -0
  29. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/agentgov_cli/port_resolver.py +0 -0
  30. {agentgov_cli-0.1.14 → agentgov_cli-0.1.16}/hatch_build.py +0 -0
@@ -85,3 +85,12 @@ cli/agentgov_cli/client_assets/
85
85
 
86
86
  # Scratch dir used by tooling when the system temp dir is unavailable.
87
87
  .wf-tmp/
88
+
89
+ # One-time scripts, patch drivers, debug output and generated diagrams, per the
90
+ # root CLAUDE.md file-organization rules. These are working files by definition —
91
+ # the repo-root CLAUDE.md sends them here precisely so they stay out of the tree,
92
+ # and without this rule `git add -A` sweeps them into a commit. Ignored as a
93
+ # directory rather than by pattern because the whole point of the directory is
94
+ # that anything may land in it.
95
+ temp/
96
+ .gstack/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: agentgov-cli
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: AgentGov CLI — wrap Claude Code, bind work items, check gateway health.
5
5
  Author: AgentGov Contributors
6
6
  License: Apache-2.0
@@ -29,7 +29,9 @@ Part of the AgentGov project — see [github.com/deepakahu/agentGov](https://git
29
29
  ## Install
30
30
 
31
31
  ```bash
32
- pip install agentgov agentgov-gateway
32
+ # Both distributions, always together: the CLI and the gateway ship separately
33
+ # and a version skew between them is not detectable from the CLI side.
34
+ pip install -U agentgov-cli agentgov-gateway
33
35
  ```
34
36
 
35
37
  ## First-time setup
@@ -9,7 +9,9 @@ Part of the AgentGov project — see [github.com/deepakahu/agentGov](https://git
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- pip install agentgov agentgov-gateway
12
+ # Both distributions, always together: the CLI and the gateway ship separately
13
+ # and a version skew between them is not detectable from the CLI side.
14
+ pip install -U agentgov-cli agentgov-gateway
13
15
  ```
14
16
 
15
17
  ## First-time setup
@@ -0,0 +1,19 @@
1
+ """AgentGov CLI. Developer-laptop tool: wrap · workitem · status · doctor."""
2
+
3
+ from importlib.metadata import PackageNotFoundError
4
+ from importlib.metadata import version as _pkg_version
5
+
6
+ # ONE source of truth: pyproject.toml, read back through the installed package
7
+ # metadata. This was a hand-maintained literal stuck at "0.1.0" while pyproject
8
+ # said 0.1.14 — the same drift that was fixed in agentgov_gateway/__init__.py
9
+ # and not carried across. Nothing reads it yet, which is precisely why it was
10
+ # free to rot; the first `--version` flag anyone adds would have shipped a lie.
11
+ #
12
+ # The fallback covers running straight from a source checkout, where nothing is
13
+ # installed and there is no metadata to read.
14
+ try:
15
+ __version__ = _pkg_version("agentgov-cli")
16
+ except PackageNotFoundError: # pragma: no cover — source checkout only
17
+ __version__ = "0.0.0+source"
18
+
19
+ __all__ = ["__version__"]
@@ -0,0 +1,69 @@
1
+ """What AgentGov puts into Claude Code's environment to route it through the gateway.
2
+
3
+ Two variables, always set together:
4
+
5
+ ANTHROPIC_BASE_URL points Claude Code at the gateway.
6
+ _CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL tells Claude Code that whatever is at
7
+ that URL forwards to api.anthropic.com.
8
+
9
+ WHY THE SECOND ONE IS NOT OPTIONAL
10
+ ----------------------------------
11
+ Claude Code decides how large a model's context window is before it sends a
12
+ request, and it only trusts a model's native 1M window when it believes it is
13
+ talking to Anthropic directly. Its test for that is literal: `ANTHROPIC_BASE_URL`
14
+ unset, or its host equal to `api.anthropic.com`. A base URL of `localhost:8000`
15
+ fails the test, so a natively-1M model such as `claude-opus-5` is given a 200k
16
+ window instead, and auto-compaction fires at roughly 165k tokens — five to six
17
+ times as often as the same model ungoverned. Observed on a developer machine:
18
+ four automatic compactions in seventy minutes, at 166k, 167k and 172k tokens, in
19
+ a session that had earlier reached 541k without one. The gateway relayed every
20
+ byte faithfully; the mistake was the client's belief about the window.
21
+
22
+ The override is Claude Code's own escape hatch for exactly this shape — a proxy
23
+ in front of the real API. Verified by reading the Claude Code 2.1.233 binary:
24
+ its first-party check returns true when the variable is set and otherwise
25
+ requires the `api.anthropic.com` host, and the context-window function falls
26
+ through to 200000 whenever that check is false and the model string carries no
27
+ explicit `[1m]` suffix. The name is internal to Claude Code and could change in
28
+ a later release, so `agentgov doctor` and the SessionStart hook both report when
29
+ it is missing, and the symptom to re-check after a Claude Code upgrade is the
30
+ one above.
31
+ """
32
+
33
+ from __future__ import annotations
34
+
35
+ from collections.abc import Mapping
36
+
37
+ FIRST_PARTY_OVERRIDE = "_CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL"
38
+
39
+ # The Claude Code release whose binary the behaviour above was read from.
40
+ CLAUDE_CODE_VERIFIED = "2.1.233"
41
+
42
+
43
+ def routing_env(gateway_url: str) -> dict[str, str]:
44
+ """The environment that routes Claude Code through `gateway_url`, complete."""
45
+ return {"ANTHROPIC_BASE_URL": gateway_url, FIRST_PARTY_OVERRIDE: "1"}
46
+
47
+
48
+ def is_routed(env: Mapping[str, str]) -> bool:
49
+ return bool((env.get("ANTHROPIC_BASE_URL") or "").strip())
50
+
51
+
52
+ def lacks_first_party_override(env: Mapping[str, str]) -> bool:
53
+ """True when Claude Code is routed through a proxy but never told it is first-party.
54
+
55
+ That is the configuration that shrinks the context window. An unrouted
56
+ environment is fine by definition, and so is one that carries the override.
57
+ """
58
+ return is_routed(env) and not (env.get(FIRST_PARTY_OVERRIDE) or "").strip()
59
+
60
+
61
+ # One sentence, shared by `agentgov doctor` and the SessionStart hook (which
62
+ # inlines a copy, because hooks run outside this package). A test keeps the
63
+ # hook's copy identical.
64
+ CONTEXT_WINDOW_WARNING = (
65
+ "Claude Code is routed through the gateway without "
66
+ f"{FIRST_PARTY_OVERRIDE}=1, so it assumes a 200k context window and "
67
+ "compacts early. Run `agentgov install` again to regenerate the routing "
68
+ "settings, or launch with `agentgov wrap claude`; then restart Claude Code."
69
+ )
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Bind this session to a work item — ticket id, URL, or any short label
2
+ description: Bind without sending a prompt. Usually unnecessary — write [PROJ-1234] at the start of your prompt instead
3
3
  allowed-tools: Bash(agentgov workitem:*)
4
4
  argument-hint: <PROJ-1234 | https://tracker/issue/42 | any short label>
5
5
  ---
@@ -9,6 +9,11 @@ argument-hint: <PROJ-1234 | https://tracker/issue/42 | any short label>
9
9
  The command above has already run and its output is shown. Relay that output to
10
10
  the user verbatim — do not restate, reformat, or interpret it — and then stop.
11
11
 
12
+ This command is the SECONDARY way to bind. The primary way is to open a prompt
13
+ with the work item in square brackets — `[PROJ-1234] add the retry loop` — which
14
+ binds and asks in one message. This command exists for binding without sending a
15
+ prompt, and for the `accept` verb.
16
+
12
17
  If it reported a successful bind, simply acknowledge it and carry on with
13
18
  whatever the user was doing. If it reported a failure, show the message as-is;
14
19
  it already contains the remediation step.