dotagents-cli 0.3.0__py3-none-any.whl

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.
dotagents/AGENTS.md ADDED
@@ -0,0 +1,125 @@
1
+ # dotagents — package API header
2
+
3
+ Public API of the installed `dotagents` package: the CLI umbrella plus the `_*.py`
4
+ helper modules that back it. This file ships inside the package so a consuming agent
5
+ can read it without the source. Full docs: https://jose-pr.github.io/dotagents/
6
+
7
+ ## Entry points
8
+
9
+ - `dotagents.cli.main(argv=None) -> int` — the `install.py` shim and
10
+ `python -m dotagents` entry point. Repoints zipapp sources, then dispatches through
11
+ `duho.app` with the discovered command set. Also the `dotagents` console script
12
+ (`[project.scripts]`).
13
+ - `dotagents.cli.Dotagents(LoggingArgs, Cli)` — the umbrella CLI class.
14
+ - Compiled command classes live in `dotagents.cli.<name>` (`init`, `overlays`,
15
+ `context`, `env`, `build_pyz`); each is a `class X(LoggingArgs, Cmd)` with a
16
+ `__call__`. That is the WHOLE shipped surface — dotagents bundles no command
17
+ module of its own. `link` / `sync` left the package with their logic (D85): the
18
+ opt-in **private-sync** overlay ships them, renamed `link-project` /
19
+ `sync-project`, from its own `cmds/` + `lib/_link.py`. `leak-check` is likewise
20
+ not in the repo — a personal command module the user keeps in their private
21
+ `<scope>/dotagents/cmds/` (D84). `audit` is repo CI tooling (`tools/audit.py`),
22
+ not a command.
23
+ - Command discovery layers sources, later wins: built-ins < bundled `cmds` <
24
+ overlay `cmds` (`<overlay-root>/cmds`) < scope `cmds` dirs (user + project) <
25
+ `$AGENTS_CMDS_PATH` < `--cmdspath`. The overlay + scope tiers come from one
26
+ Contract-A `get_file_paths` walk (`cli._cmds_dirs`), the same resolver that
27
+ backs `bin`/PATH.
28
+
29
+ ## Helper modules (public surface)
30
+
31
+ - `_agents` — `Agent` base type + per-agent adapters; `stamp_identity(...)` emits the
32
+ standardized `AGENTS_*` / `AGENT` identity vars.
33
+ - `_overlays` — `install_overlay` / `read_manifest` / `find_setup_script` /
34
+ `run_setup_script`; installs an overlay's files and collects its `routing` / `rules`
35
+ contributions to the managed `AGENTS.md` block. `DEFAULT_PRIORITY = 500`.
36
+ - `_scope` — `resolve_scope(global_scope, agents_dir=None)` and `resolve_source(...)`;
37
+ scope = *where installed overlays live* (user = the configurable store, project =
38
+ `<project>/.agents`), source = *where an overlay comes from* (bundled by default).
39
+ Installed overlays are **discovered** by presence, not tracked in a registry.
40
+ - `_context` — assemble the effective per-agent context (Plan 04); reads overlay
41
+ `priority` from the manifest (lower sorts earlier).
42
+ - `_env` — chained env-file assembly + `env.py` execution (frozen contract B):
43
+ `get_environment` / `get_diff` / `resolve_env_files` / `get_env_from_py` /
44
+ `get_env_from_file`. Bins onto PATH first, then two tiers (`pre.env*` then `env*`),
45
+ later-overrides-earlier. Identity seeded before the chain; proxy vars applied after.
46
+ - `_resolve` — `get_file_paths(*names, agents_dir, project_root, global_scope=False,
47
+ include_missing=False)`: the Contract-A precedence walk / filename resolution.
48
+ - `_merge` — managed-block merge for `init`'s `AGENTS.md` / `CLAUDE.md`, delimited by
49
+ `<!-- dotagents:begin -->` / `<!-- dotagents:end -->`. Detection is by marker
50
+ presence only, so it survives user reformatting. `begin_marker`/`end_marker`
51
+ override the pair for other comment syntaxes (`#` for TOML), and `append=True`
52
+ puts a first-time block at the END of the file — required for TOML, where a
53
+ `[table]` header captures every key line after it and a prepended block would
54
+ swallow the user's top-level keys.
55
+ - `_skills` — publish an overlay's `skills/<name>/` into a scope's shared skills dir
56
+ (symlink-preferred, copy fallback); unpublish removes only what the overlay
57
+ published, then sweeps broken symlinks. Pure stdlib.
58
+ - `_hooks` — additive, idempotent merge of our hooks into an agent's `settings.json`.
59
+ `hooks.<Event>` is a **list of matcher-objects** each holding its own `hooks` list,
60
+ not a flat command list. Foreign hooks are preserved verbatim, malformed entries
61
+ are dropped rather than raising, and invalid JSON raises `SystemExit` instead of
62
+ silently overwriting the user's file. Pure stdlib. Consumed by
63
+ `ClaudeAgent.wire_hooks` (`~/.claude/settings.json`: env via `$CLAUDE_ENV_FILE`
64
+ + context via stdout, plus `CwdChanged`) and `CodexAgent.wire_hooks`
65
+ (`<CODEX_HOME|~/.codex>/hooks.json`: context only — no env-file equivalent — and
66
+ never `config.toml`). Codex's hook JSON is structurally identical to Claude's, so
67
+ the same merge serves both. Gemini/Cursor/Copilot keep the base no-op: no
68
+ published schema to target.
69
+ - `_sync` — `PathSyncer` wrapper reproducing `install`'s backup/copy/report; requires
70
+ `pathlib_next.Path` instances (not plain `pathlib.Path`) and a pre-created parent dir.
71
+
72
+ ## Environment variables
73
+
74
+ The prefix split (D80): **`AGENTS_*`** names everything about the `.agents` / agent
75
+ world (paths, scope, overlays, sync) — non-secret, safe to emit; **`DOTAGENTS_*`** is
76
+ reserved for genuinely tool-internal config and secrets, so the "never print
77
+ `DOTAGENTS_*` values" leak guard (D48) stays a simple blanket ban over exactly the
78
+ sensitive set.
79
+
80
+ Config / path / sync vars (`AGENTS_*`, non-secret — read, and some emitted):
81
+
82
+ - `AGENTS_HOME` — the configurable user-scope store path (default `~/.agents`). Also
83
+ **emitted** by `dotagents env` (D79) and set for overlay setup scripts / sync hooks.
84
+ - `AGENTS_STORE_DIR` — per-project store location (absolute paths allowed).
85
+ - `AGENTS_OVERLAYS_SRC` — default overlay source dir for `overlays`.
86
+ - `AGENTS_CMDS_PATH` — extra command-module search paths (os.pathsep-split).
87
+ - `AGENTS_OVERLAY_DIR` — set for an overlay's setup script (its own installed dir).
88
+ - `AGENTS_REMOTE` / `AGENTS_SYNC_MESSAGE` — private-store sync (tokenless remote URL /
89
+ commit message).
90
+
91
+ Every reader above prefers the `AGENTS_*` name and falls back to the old
92
+ `DOTAGENTS_*` name (`DOTAGENTS_AGENTS_DIR`, `DOTAGENTS_STORE_DIR`,
93
+ `DOTAGENTS_OVERLAYS_SRC`, `DOTAGENTS_CMDS_PATH`, `DOTAGENTS_OVERLAY_DIR`,
94
+ `DOTAGENTS_AGENTS_REMOTE`, `DOTAGENTS_SYNC_MESSAGE`) for one release — deprecated,
95
+ removable next. Setters emit both names this release.
96
+
97
+ Tool-internal / secret vars (`DOTAGENTS_*` — kept; read, **never printed**):
98
+
99
+ - `DOTAGENTS_AGENTS_TOKEN` — **secret** (fine-grained PAT) for private-store auth.
100
+ - `DOTAGENTS_CLI_INSTALL` — pip spec to install the CLI itself (tool-specific).
101
+ - `DOTAGENTS_AUDIT_PATTERNS` — path to the machine-local audit-pattern file (tooling).
102
+
103
+ Emitted by the identity/env layer (safe to branch on in env files):
104
+ `AGENTS_HARNESS`, `AGENTS_VENDOR`, `AGENTS_MODEL`, `AGENTS_AGENT` / `AGENT`,
105
+ `AGENTS_CODE_SESSION_ID`, `AGENTS_PROXY`, `AGENTS_WEBFETCH_PROXY_URL`, plus the two
106
+ scope roots — `AGENTS_HOME` (the user store, `agents_dir`/`~/.agents`) and
107
+ `AGENTS_PROJECT_ROOT` (this project's root). Both are seeded only if unset, so a
108
+ harness/env can pin them. `resolve_scope` READS `AGENTS_PROJECT_ROOT` (then the
109
+ agent-native `CLAUDE_PROJECT_DIR`, then cwd) for the project scope's root.
110
+
111
+ ## Gotchas
112
+
113
+ - **Python 3.9 floor.** Files using bare `X | Y` unions in runtime-evaluated positions
114
+ need `from __future__ import annotations`. `Path.write_text(..., newline=...)` is
115
+ 3.10+, so wrapper-script writers use `open(path, "w", newline="")`.
116
+ - **Zipapp source shim.** Inside a `.pyz`, `Path(__file__)` is not a real file, so
117
+ duho's AST flag/help introspection degrades (`--from` → `--from-`, positionals lost).
118
+ `cli.main()` calls `_repoint_zipapp_sources()` first, extracting the built-in command
119
+ modules to real temp files. Discovered `cmds` modules are extracted by
120
+ `_package_data_dir` before import, so they need no repoint.
121
+ - **Package data in a `.pyz`.** `_package_data_dir()` resolves `skeleton/` and the
122
+ bundled payload via `importlib.resources` (a zip-backed `Traversable` is extracted to
123
+ a temp dir once), never `Path(__file__).exists()` (always False in a zipapp).
124
+ - **`pathlib_next` needs `typing_extensions` on Python < 3.10** (an upstream gap); a
125
+ 3.9 environment must `pip install typing_extensions`.
dotagents/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """dotagents: installable CLI for the dotagents agent-config payload."""
2
+
3
+ __version__ = "0.2.0"
dotagents/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from dotagents.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())