principal-engineer 0.1.0__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 (62) hide show
  1. principal_engineer-0.1.0/LICENSE +21 -0
  2. principal_engineer-0.1.0/PKG-INFO +132 -0
  3. principal_engineer-0.1.0/README.md +112 -0
  4. principal_engineer-0.1.0/principal_engineer/__init__.py +0 -0
  5. principal_engineer-0.1.0/principal_engineer/_run.py +12 -0
  6. principal_engineer-0.1.0/principal_engineer/adapters/__init__.py +24 -0
  7. principal_engineer-0.1.0/principal_engineer/adapters/antigravity.py +252 -0
  8. principal_engineer-0.1.0/principal_engineer/adapters/base.py +205 -0
  9. principal_engineer-0.1.0/principal_engineer/adapters/claude_code.py +297 -0
  10. principal_engineer-0.1.0/principal_engineer/adapters/codex.py +259 -0
  11. principal_engineer-0.1.0/principal_engineer/config.example.json +53 -0
  12. principal_engineer-0.1.0/principal_engineer/features/core-bootstrap/AGENTS.snippet.md +8 -0
  13. principal_engineer-0.1.0/principal_engineer/features/discipline/SKILL.md +13 -0
  14. principal_engineer-0.1.0/principal_engineer/features/feasibility-gate/SKILL.md +17 -0
  15. principal_engineer-0.1.0/principal_engineer/features/memory/SKILL.md +13 -0
  16. principal_engineer-0.1.0/principal_engineer/features/plan-persistence/SKILL.md +15 -0
  17. principal_engineer-0.1.0/principal_engineer/features/research/SKILL.md +12 -0
  18. principal_engineer-0.1.0/principal_engineer/memory/__init__.py +13 -0
  19. principal_engineer-0.1.0/principal_engineer/memory/core.py +120 -0
  20. principal_engineer-0.1.0/principal_engineer/memory/mcp_server.py +240 -0
  21. principal_engineer-0.1.0/principal_engineer/memory/secrets.py +84 -0
  22. principal_engineer-0.1.0/principal_engineer/memory/store.py +515 -0
  23. principal_engineer-0.1.0/principal_engineer/panel/__init__.py +5 -0
  24. principal_engineer-0.1.0/principal_engineer/panel/app.py +453 -0
  25. principal_engineer-0.1.0/principal_engineer/panel/controller.py +211 -0
  26. principal_engineer-0.1.0/principal_engineer/research/__init__.py +16 -0
  27. principal_engineer-0.1.0/principal_engineer/research/cache.py +188 -0
  28. principal_engineer-0.1.0/principal_engineer/research/mcp_server.py +239 -0
  29. principal_engineer-0.1.0/principal_engineer/research/providers.py +224 -0
  30. principal_engineer-0.1.0/principal_engineer/research/reader.py +173 -0
  31. principal_engineer-0.1.0/principal_engineer/tools/__init__.py +1 -0
  32. principal_engineer-0.1.0/principal_engineer/tools/budgets.py +131 -0
  33. principal_engineer-0.1.0/principal_engineer/tools/cli.py +417 -0
  34. principal_engineer-0.1.0/principal_engineer/tools/file_ops.py +180 -0
  35. principal_engineer-0.1.0/principal_engineer/tools/githook.py +60 -0
  36. principal_engineer-0.1.0/principal_engineer/tools/handoff.py +121 -0
  37. principal_engineer-0.1.0/principal_engineer/tools/hook_runner.py +254 -0
  38. principal_engineer-0.1.0/principal_engineer/tools/installer.py +587 -0
  39. principal_engineer-0.1.0/principal_engineer/tools/plugin_sync.py +59 -0
  40. principal_engineer-0.1.0/principal_engineer/tools/repomap.py +125 -0
  41. principal_engineer-0.1.0/principal_engineer/tools/trim_run.py +97 -0
  42. principal_engineer-0.1.0/principal_engineer/tools/verify.py +286 -0
  43. principal_engineer-0.1.0/principal_engineer.egg-info/PKG-INFO +132 -0
  44. principal_engineer-0.1.0/principal_engineer.egg-info/SOURCES.txt +60 -0
  45. principal_engineer-0.1.0/principal_engineer.egg-info/dependency_links.txt +1 -0
  46. principal_engineer-0.1.0/principal_engineer.egg-info/entry_points.txt +2 -0
  47. principal_engineer-0.1.0/principal_engineer.egg-info/top_level.txt +1 -0
  48. principal_engineer-0.1.0/pyproject.toml +36 -0
  49. principal_engineer-0.1.0/setup.cfg +4 -0
  50. principal_engineer-0.1.0/tests/test_codex_hooks_and_status.py +76 -0
  51. principal_engineer-0.1.0/tests/test_context_tools.py +103 -0
  52. principal_engineer-0.1.0/tests/test_enforcement.py +87 -0
  53. principal_engineer-0.1.0/tests/test_hooks.py +258 -0
  54. principal_engineer-0.1.0/tests/test_installer.py +284 -0
  55. principal_engineer-0.1.0/tests/test_memory.py +224 -0
  56. principal_engineer-0.1.0/tests/test_panel.py +112 -0
  57. principal_engineer-0.1.0/tests/test_plan_persistence.py +207 -0
  58. principal_engineer-0.1.0/tests/test_plugin.py +56 -0
  59. principal_engineer-0.1.0/tests/test_preflight_env.py +143 -0
  60. principal_engineer-0.1.0/tests/test_recall.py +49 -0
  61. principal_engineer-0.1.0/tests/test_research.py +192 -0
  62. principal_engineer-0.1.0/tests/test_verify.py +206 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Principal Engineer Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: principal-engineer
3
+ Version: 0.1.0
4
+ Summary: Make AI coding agents work like a real engineer: shared memory, plan persistence, verification, feasibility gate.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/TGMpea/principal-engineer-kit
7
+ Keywords: ai,agents,claude-code,codex,antigravity,mcp,memory
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # Principal Engineer
22
+
23
+ > Make AI coding agents work like a real engineer — remember decisions across sessions, resume plans without context bloat, verify before claiming done, and check feasibility before burning tokens.
24
+
25
+ **Status:** `v0.1.0` (`M0–M6 Complete` · Windows, macOS & Linux · Python 3.10+ standard library only)
26
+
27
+ ## Why This Exists
28
+
29
+ - **Stop goldfish memory:** Decisions, setup facts, and pitfalls live in one local SQLite store (`~/.principal/memory.db`) shared across all installed agents, with only a tiny core loaded at startup.
30
+ - **Keep context cheap:** Plans split into small task cards plus one overwritten handoff note; hooks and scripts handle saving, repo mapping, and log trimming at near-zero LLM token cost.
31
+ - **Prove, don't claim:** A fast `principal verify` check blocks incomplete or unverified "done" claims wherever the agent supports lifecycle hooks.
32
+ - **Local-first & offline:** Memory, planning, repo mapping, verification, and the desktop control panel run 100% offline with zero external Python packages. Web research is optional and disabled by default.
33
+
34
+ ## Supported Agents (v1)
35
+
36
+ | Agent | Rules & Skills | Persistent Memory & Research (MCP) | Lifecycle Enforcement | Notes |
37
+ | :--- | :--- | :--- | :--- | :--- |
38
+ | **Antigravity** | Native plugin bundle (`rules/AGENTS.md` + `skills/`) | Stdio MCP (`mcp_config.json`) | **Hook-enforced** (`Stop`, `SessionStart`, `PostToolUse`) | Isolated plugin install/uninstall |
39
+ | **Claude Code** | `~/.claude/CLAUDE.md` + `~/.claude/skills/` | Stdio MCP (`claude mcp add-json` / `~/.claude.json`) | **Hook-enforced** (`Stop`, `SessionStart` post-compact, `PreCompact`, `PostToolUse`) | Re-injects context after compaction |
40
+ | **Codex CLI** | `~/.codex/AGENTS.md` + `~/.agents/skills/` | Stdio MCP (`~/.codex/config.toml`) | **Hook-enforced** | `Stop`/`SessionStart` in `~/.codex/hooks.json`; live block verified on 0.174.0. Codex asks you to trust the hooks once (`/hooks`) |
41
+
42
+ ## Install
43
+
44
+ Requirements: **Python 3.10+**, no third-party packages. Not yet on PyPI: install from a clone.
45
+
46
+ ```bash
47
+ git clone <this repo> && cd principal-engineer
48
+ python install.py # pipx if present, else a private venv in ~/.principal/venv; then runs `principal install`
49
+ # or
50
+ pipx install . # then: principal install
51
+ # or (development)
52
+ pip install -e . # then: principal install
53
+ ```
54
+
55
+ `python install.py -- --scope project` passes flags through to `principal install`. `principal install` previews changes and asks before writing (`--yes` skips the prompt). Without a pip/pipx install, hooks use a `_run.py` launcher pointing at the checkout; `principal doctor` warns about that.
56
+
57
+ ```bash
58
+ principal install --dry-run # preview every file that would be touched
59
+ principal install # global install for all detected agents (or --scope project)
60
+ principal status # per-agent state, drift, FTS5, Python path
61
+ principal uninstall # revert everything
62
+ ```
63
+
64
+ ### Claude Code only: plugin install
65
+
66
+ ```text
67
+ /plugin marketplace add TGMpea/principal-engineer-kit
68
+ /plugin install principal-engineer@principal-engineer
69
+ ```
70
+
71
+ Needs `python` (or `python3`) on PATH. Not live-verified yet (only `claude plugin validate`). Do not combine with `principal install` for Claude Code, or hooks run twice. After editing `features/`, run `python -m principal_engineer.tools.plugin_sync` to refresh `skills/`.
72
+
73
+ ## Commands
74
+
75
+ | Command | Purpose |
76
+ | :--- | :--- |
77
+ | `principal install` / `update` | Install or refresh enabled features (`--dry-run`, `--scope global\|project`, `--config`, `-y`) |
78
+ | `principal status` | Agent detection, enforcement mode, drift, FTS5, Python path, CLI version warnings vs. tested versions (`--json`) |
79
+ | `principal status --prune` | Drop manifest entries whose files no longer exist |
80
+ | `principal doctor` | Status plus an actionable fix per problem |
81
+ | `principal verify` | Run `budgets`, `evidence`, `patterns`, `integrity` (`--checks`, `--json`) |
82
+ | `principal verify --install-git-hook` | Git `pre-commit` hook running `verify`; works with any agent, including Codex (`--remove-git-hook` undoes it) |
83
+ | `principal budgets` | Measure token and line-count budgets |
84
+ | `principal panel` | Native `tkinter` control panel, no open ports |
85
+ | `principal uninstall` | Revert generated blocks, skills, hooks, MCP registrations (`--dry-run`, `--scope`) |
86
+ | `principal mem <cmd>` | `search`, `add`, `supersede`, `core`, `stats` on the shared memory store |
87
+ | `principal handoff` / `repomap` / `run` | Overwrite `.principal/plan/handoff.md`, build a symbol map, run a command with trimmed output |
88
+ | `principal research <cmd>` | Optional cached `search` / `read` / `stats` (disabled by default) |
89
+
90
+ Global flags `--data-dir` and `--project-dir` override `~/.principal` and the working directory.
91
+
92
+ ## Configuration
93
+
94
+ `~/.principal/config.json` (or `--config`), starting from the packaged `config.example.json`: per-agent `enabled` and `features`, `feasibility_strictness` (`occasionally|usually|always`), `budgets`, `research`, and `verify` (`patterns_block_stop`, `feasibility_required`). Suppress a pattern finding on one line with `# principal-ignore`.
95
+
96
+ ## Safety
97
+
98
+ - Managed text lives in marked blocks or JSON entries tagged `_managed_by: "principal-engineer"`; your own content is preserved on update and uninstall.
99
+ - Each file is backed up once under `~/.principal/backups/` before its first edit; `manifest.json` records what was written. Writes are atomic.
100
+ - `--dry-run` shows the full plan without touching anything. Uninstall restores the original tree.
101
+ - Secret-looking text is refused by the memory store. No network use unless you enable `research`.
102
+ - Project-scope install inside this tool's own checkout is refused without `--allow-self-install`.
103
+
104
+ ## Limits
105
+
106
+ - Prompt rules are advisory: an agent can still ignore them. Only hooks and the git hook actually block.
107
+ - Codex hooks stay inactive until you trust them once (`/hooks` in the TUI); the trust hash changes if the hook command changes (e.g. after `principal update`). The git pre-commit hook is the agent-independent backstop.
108
+ - Antigravity Stop fires live, but a real block has not been observed; the Claude Code hook is not verified live.
109
+ - `principal verify` checks structure and diffs, not whether code is correct.
110
+ - CI on macOS/Linux and the pipx path are untested by the author so far; Python is still required.
111
+
112
+ ## Token Budget Targets
113
+
114
+ | Artifact | Target Budget |
115
+ | :--- | :--- |
116
+ | Always-loaded snippet per session | <= 350 tokens |
117
+ | Core memory file (`core.md`) | <= 20 lines/project + <= 15 lines global |
118
+ | Plan index (`index.md`) | <= 40 lines |
119
+ | Handoff note (`handoff.md`) | <= 30 lines (overwritten, never appended) |
120
+ | One memory search lookup | <= 400 tokens (max 5 short snippets) |
121
+
122
+ ## Documentation & Guides
123
+
124
+ - [Adding a New Agent Adapter](docs/adding-an-adapter.md)
125
+ - [Troubleshooting](docs/troubleshooting.md)
126
+ - [Architecture Decisions Log](docs/decisions.md)
127
+ - [Optional Config Examples](examples/README.md)
128
+ - [Contributing](CONTRIBUTING.md) · [Security Policy](SECURITY.md) · [Changelog](CHANGELOG.md)
129
+
130
+ ## License
131
+
132
+ [MIT](LICENSE)
@@ -0,0 +1,112 @@
1
+ # Principal Engineer
2
+
3
+ > Make AI coding agents work like a real engineer — remember decisions across sessions, resume plans without context bloat, verify before claiming done, and check feasibility before burning tokens.
4
+
5
+ **Status:** `v0.1.0` (`M0–M6 Complete` · Windows, macOS & Linux · Python 3.10+ standard library only)
6
+
7
+ ## Why This Exists
8
+
9
+ - **Stop goldfish memory:** Decisions, setup facts, and pitfalls live in one local SQLite store (`~/.principal/memory.db`) shared across all installed agents, with only a tiny core loaded at startup.
10
+ - **Keep context cheap:** Plans split into small task cards plus one overwritten handoff note; hooks and scripts handle saving, repo mapping, and log trimming at near-zero LLM token cost.
11
+ - **Prove, don't claim:** A fast `principal verify` check blocks incomplete or unverified "done" claims wherever the agent supports lifecycle hooks.
12
+ - **Local-first & offline:** Memory, planning, repo mapping, verification, and the desktop control panel run 100% offline with zero external Python packages. Web research is optional and disabled by default.
13
+
14
+ ## Supported Agents (v1)
15
+
16
+ | Agent | Rules & Skills | Persistent Memory & Research (MCP) | Lifecycle Enforcement | Notes |
17
+ | :--- | :--- | :--- | :--- | :--- |
18
+ | **Antigravity** | Native plugin bundle (`rules/AGENTS.md` + `skills/`) | Stdio MCP (`mcp_config.json`) | **Hook-enforced** (`Stop`, `SessionStart`, `PostToolUse`) | Isolated plugin install/uninstall |
19
+ | **Claude Code** | `~/.claude/CLAUDE.md` + `~/.claude/skills/` | Stdio MCP (`claude mcp add-json` / `~/.claude.json`) | **Hook-enforced** (`Stop`, `SessionStart` post-compact, `PreCompact`, `PostToolUse`) | Re-injects context after compaction |
20
+ | **Codex CLI** | `~/.codex/AGENTS.md` + `~/.agents/skills/` | Stdio MCP (`~/.codex/config.toml`) | **Hook-enforced** | `Stop`/`SessionStart` in `~/.codex/hooks.json`; live block verified on 0.174.0. Codex asks you to trust the hooks once (`/hooks`) |
21
+
22
+ ## Install
23
+
24
+ Requirements: **Python 3.10+**, no third-party packages. Not yet on PyPI: install from a clone.
25
+
26
+ ```bash
27
+ git clone <this repo> && cd principal-engineer
28
+ python install.py # pipx if present, else a private venv in ~/.principal/venv; then runs `principal install`
29
+ # or
30
+ pipx install . # then: principal install
31
+ # or (development)
32
+ pip install -e . # then: principal install
33
+ ```
34
+
35
+ `python install.py -- --scope project` passes flags through to `principal install`. `principal install` previews changes and asks before writing (`--yes` skips the prompt). Without a pip/pipx install, hooks use a `_run.py` launcher pointing at the checkout; `principal doctor` warns about that.
36
+
37
+ ```bash
38
+ principal install --dry-run # preview every file that would be touched
39
+ principal install # global install for all detected agents (or --scope project)
40
+ principal status # per-agent state, drift, FTS5, Python path
41
+ principal uninstall # revert everything
42
+ ```
43
+
44
+ ### Claude Code only: plugin install
45
+
46
+ ```text
47
+ /plugin marketplace add TGMpea/principal-engineer-kit
48
+ /plugin install principal-engineer@principal-engineer
49
+ ```
50
+
51
+ Needs `python` (or `python3`) on PATH. Not live-verified yet (only `claude plugin validate`). Do not combine with `principal install` for Claude Code, or hooks run twice. After editing `features/`, run `python -m principal_engineer.tools.plugin_sync` to refresh `skills/`.
52
+
53
+ ## Commands
54
+
55
+ | Command | Purpose |
56
+ | :--- | :--- |
57
+ | `principal install` / `update` | Install or refresh enabled features (`--dry-run`, `--scope global\|project`, `--config`, `-y`) |
58
+ | `principal status` | Agent detection, enforcement mode, drift, FTS5, Python path, CLI version warnings vs. tested versions (`--json`) |
59
+ | `principal status --prune` | Drop manifest entries whose files no longer exist |
60
+ | `principal doctor` | Status plus an actionable fix per problem |
61
+ | `principal verify` | Run `budgets`, `evidence`, `patterns`, `integrity` (`--checks`, `--json`) |
62
+ | `principal verify --install-git-hook` | Git `pre-commit` hook running `verify`; works with any agent, including Codex (`--remove-git-hook` undoes it) |
63
+ | `principal budgets` | Measure token and line-count budgets |
64
+ | `principal panel` | Native `tkinter` control panel, no open ports |
65
+ | `principal uninstall` | Revert generated blocks, skills, hooks, MCP registrations (`--dry-run`, `--scope`) |
66
+ | `principal mem <cmd>` | `search`, `add`, `supersede`, `core`, `stats` on the shared memory store |
67
+ | `principal handoff` / `repomap` / `run` | Overwrite `.principal/plan/handoff.md`, build a symbol map, run a command with trimmed output |
68
+ | `principal research <cmd>` | Optional cached `search` / `read` / `stats` (disabled by default) |
69
+
70
+ Global flags `--data-dir` and `--project-dir` override `~/.principal` and the working directory.
71
+
72
+ ## Configuration
73
+
74
+ `~/.principal/config.json` (or `--config`), starting from the packaged `config.example.json`: per-agent `enabled` and `features`, `feasibility_strictness` (`occasionally|usually|always`), `budgets`, `research`, and `verify` (`patterns_block_stop`, `feasibility_required`). Suppress a pattern finding on one line with `# principal-ignore`.
75
+
76
+ ## Safety
77
+
78
+ - Managed text lives in marked blocks or JSON entries tagged `_managed_by: "principal-engineer"`; your own content is preserved on update and uninstall.
79
+ - Each file is backed up once under `~/.principal/backups/` before its first edit; `manifest.json` records what was written. Writes are atomic.
80
+ - `--dry-run` shows the full plan without touching anything. Uninstall restores the original tree.
81
+ - Secret-looking text is refused by the memory store. No network use unless you enable `research`.
82
+ - Project-scope install inside this tool's own checkout is refused without `--allow-self-install`.
83
+
84
+ ## Limits
85
+
86
+ - Prompt rules are advisory: an agent can still ignore them. Only hooks and the git hook actually block.
87
+ - Codex hooks stay inactive until you trust them once (`/hooks` in the TUI); the trust hash changes if the hook command changes (e.g. after `principal update`). The git pre-commit hook is the agent-independent backstop.
88
+ - Antigravity Stop fires live, but a real block has not been observed; the Claude Code hook is not verified live.
89
+ - `principal verify` checks structure and diffs, not whether code is correct.
90
+ - CI on macOS/Linux and the pipx path are untested by the author so far; Python is still required.
91
+
92
+ ## Token Budget Targets
93
+
94
+ | Artifact | Target Budget |
95
+ | :--- | :--- |
96
+ | Always-loaded snippet per session | <= 350 tokens |
97
+ | Core memory file (`core.md`) | <= 20 lines/project + <= 15 lines global |
98
+ | Plan index (`index.md`) | <= 40 lines |
99
+ | Handoff note (`handoff.md`) | <= 30 lines (overwritten, never appended) |
100
+ | One memory search lookup | <= 400 tokens (max 5 short snippets) |
101
+
102
+ ## Documentation & Guides
103
+
104
+ - [Adding a New Agent Adapter](docs/adding-an-adapter.md)
105
+ - [Troubleshooting](docs/troubleshooting.md)
106
+ - [Architecture Decisions Log](docs/decisions.md)
107
+ - [Optional Config Examples](examples/README.md)
108
+ - [Contributing](CONTRIBUTING.md) · [Security Policy](SECURITY.md) · [Changelog](CHANGELOG.md)
109
+
110
+ ## License
111
+
112
+ [MIT](LICENSE)
@@ -0,0 +1,12 @@
1
+ """Launcher for checkouts that are not pip-installed: `python _run.py <module> [args...]`."""
2
+
3
+ import runpy
4
+ import sys
5
+ from pathlib import Path
6
+
7
+ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
8
+
9
+ if __name__ == "__main__":
10
+ module = sys.argv[1]
11
+ sys.argv = [module, *sys.argv[2:]]
12
+ runpy.run_module(module, run_name="__main__", alter_sys=True)
@@ -0,0 +1,24 @@
1
+ """Cross-platform agent adapters for Principal Engineer."""
2
+
3
+ from principal_engineer.adapters.antigravity import AntigravityAdapter
4
+ from principal_engineer.adapters.base import AdapterStatus, BaseAdapter, CommandOperation, FileOperation, InstallPlan
5
+ from principal_engineer.adapters.claude_code import ClaudeCodeAdapter
6
+ from principal_engineer.adapters.codex import CodexAdapter
7
+
8
+ ALL_ADAPTERS: dict[str, BaseAdapter] = {
9
+ "antigravity": AntigravityAdapter(),
10
+ "claude-code": ClaudeCodeAdapter(),
11
+ "codex": CodexAdapter(),
12
+ }
13
+
14
+ __all__ = [
15
+ "ALL_ADAPTERS",
16
+ "AdapterStatus",
17
+ "AntigravityAdapter",
18
+ "BaseAdapter",
19
+ "ClaudeCodeAdapter",
20
+ "CodexAdapter",
21
+ "CommandOperation",
22
+ "FileOperation",
23
+ "InstallPlan",
24
+ ]
@@ -0,0 +1,252 @@
1
+ """Antigravity adapter using isolated native plugin bundles (and project .agents/)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import shutil
7
+ from pathlib import Path
8
+ from typing import Mapping
9
+
10
+ from principal_engineer.adapters.base import (
11
+ ALL_SKILL_NAMES,
12
+ AdapterStatus,
13
+ BaseAdapter,
14
+ FileOperation,
15
+ InstallPlan,
16
+ MEMORY_MCP_MODULE,
17
+ RESEARCH_MCP_MODULE,
18
+ build_hook_command,
19
+ mcp_args,
20
+ render_skill_content,
21
+ selected_skill_dirs,
22
+ )
23
+
24
+ PLUGIN_DIR_NAME = "principal-engineer"
25
+
26
+
27
+ class AntigravityAdapter(BaseAdapter):
28
+ """Adapter for Google Antigravity (IDE / App / CLI)."""
29
+
30
+ name = "antigravity"
31
+ tested_version = "Antigravity 2.x (live-verified: plugin discovery, SessionStart/Stop hooks, MCP memory)"
32
+ doc_verified_date = "2026-12-06"
33
+ enforcement_mode = "Hook-enforced"
34
+
35
+ def _global_config_root(
36
+ self, home_dir: Path, env: Mapping[str, str] | None = None
37
+ ) -> Path:
38
+ override = self._env_path(env, "ANTIGRAVITY_CONFIG_DIR")
39
+ if override is not None:
40
+ return override
41
+ return home_dir / ".gemini" / "config"
42
+
43
+ def detect(
44
+ self,
45
+ home_dir: Path,
46
+ project_dir: Path,
47
+ env: Mapping[str, str] | None = None,
48
+ ) -> AdapterStatus:
49
+ global_root = self._global_config_root(home_dir, env)
50
+ project_agents = project_dir / ".agents"
51
+ has_cli = shutil.which("agy") is not None
52
+ present = global_root.exists() or project_agents.exists() or has_cli
53
+ reason = (
54
+ f"Found config at {global_root}"
55
+ if global_root.exists()
56
+ else ("Found `agy` CLI" if has_cli else "Not detected on machine")
57
+ )
58
+ return AdapterStatus(
59
+ name=self.name,
60
+ present=present,
61
+ reason=reason,
62
+ tested_version=self.tested_version,
63
+ doc_verified_date=self.doc_verified_date,
64
+ enforcement_mode=self.enforcement_mode,
65
+ config_root=global_root,
66
+ )
67
+
68
+ def _plugin_root(self, home_dir: Path, project_dir: Path, scope: str, env: Mapping[str, str] | None) -> Path:
69
+ if scope == "project":
70
+ return project_dir / ".agents" / "plugins" / PLUGIN_DIR_NAME
71
+ return self._global_config_root(home_dir, env) / "plugins" / PLUGIN_DIR_NAME
72
+
73
+ def plan_install(
74
+ self,
75
+ *,
76
+ repo_root: Path,
77
+ data_dir: Path,
78
+ home_dir: Path,
79
+ project_dir: Path,
80
+ scope: str,
81
+ enabled_features: list[str],
82
+ python_exe: str,
83
+ env: Mapping[str, str] | None = None,
84
+ config: Mapping[str, object] | None = None,
85
+ ) -> InstallPlan:
86
+ plugin_root = self._plugin_root(home_dir, project_dir, scope, env)
87
+ snippet_text = (
88
+ repo_root / "features" / "core-bootstrap" / "AGENTS.snippet.md"
89
+ ).read_text(encoding="utf-8")
90
+
91
+ plan = InstallPlan(agent=self.name)
92
+ manifest_json = json.dumps(
93
+ {
94
+ "name": PLUGIN_DIR_NAME,
95
+ "description": "Principal Engineer discipline, memory, and plan persistence.",
96
+ },
97
+ indent=2,
98
+ ) + "\n"
99
+ plan.file_ops.append(
100
+ FileOperation(
101
+ path=plugin_root / "plugin.json",
102
+ kind="copy_file",
103
+ content=manifest_json,
104
+ description="Write Antigravity native plugin manifest",
105
+ )
106
+ )
107
+ if scope == "project":
108
+ # Antigravity reads the project-root AGENTS.md, which Codex also uses. Sharing one
109
+ # marked block (id "core") keeps a single copy instead of loading the rules twice.
110
+ plan.file_ops.append(
111
+ FileOperation(
112
+ path=project_dir / "AGENTS.md",
113
+ kind="marked_block",
114
+ content=snippet_text,
115
+ block_id="core",
116
+ marker_style="md",
117
+ description="Upsert core bootstrap block in project AGENTS.md (shared with Codex)",
118
+ )
119
+ )
120
+ plan.file_ops.append(
121
+ FileOperation(
122
+ path=plugin_root / "rules" / "AGENTS.md",
123
+ kind="remove_file",
124
+ description="Remove duplicate plugin rules file (project AGENTS.md is used)",
125
+ )
126
+ )
127
+ else:
128
+ plan.file_ops.append(
129
+ FileOperation(
130
+ path=plugin_root / "rules" / "AGENTS.md",
131
+ kind="copy_file",
132
+ content=snippet_text,
133
+ description="Write Antigravity plugin bootstrap rules",
134
+ )
135
+ )
136
+
137
+ for skill_name, skill_src in selected_skill_dirs(repo_root, enabled_features):
138
+ rendered = render_skill_content(
139
+ skill_name, skill_src.read_text(encoding="utf-8"), config
140
+ )
141
+ plan.file_ops.append(
142
+ FileOperation(
143
+ path=plugin_root / "skills" / skill_name / "SKILL.md",
144
+ kind="copy_file",
145
+ content=rendered,
146
+ description=f"Install Antigravity skill {skill_name}",
147
+ )
148
+ )
149
+
150
+ mcp_servers: dict[str, object] = {}
151
+ if "memory" in enabled_features:
152
+ mcp_servers["principal-memory"] = {
153
+ "command": python_exe,
154
+ "args": mcp_args(MEMORY_MCP_MODULE, data_dir),
155
+ }
156
+ if "research" in enabled_features:
157
+ mcp_servers["principal-research"] = {
158
+ "command": python_exe,
159
+ "args": mcp_args(RESEARCH_MCP_MODULE, data_dir),
160
+ }
161
+ if mcp_servers:
162
+ plan.file_ops.append(
163
+ FileOperation(
164
+ path=plugin_root / "mcp_config.json",
165
+ kind="copy_file",
166
+ content=json.dumps({"mcpServers": mcp_servers}, indent=2) + "\n",
167
+ description="Register Antigravity plugin stdio MCP servers",
168
+ )
169
+ )
170
+
171
+ hooks_cfg = {
172
+ "principal-engineer": {
173
+ "SessionStart": [
174
+ {
175
+ "type": "command",
176
+ "command": build_hook_command(
177
+ python_exe, self.name, "session_start", data_dir
178
+ ),
179
+ "timeout": 10,
180
+ }
181
+ ],
182
+ "PostToolUse": [
183
+ {
184
+ "matcher": "run_command",
185
+ "hooks": [
186
+ {
187
+ "type": "command",
188
+ "command": build_hook_command(
189
+ python_exe, self.name, "post_tool", data_dir
190
+ ),
191
+ "timeout": 10,
192
+ }
193
+ ],
194
+ }
195
+ ],
196
+ "Stop": [
197
+ {
198
+ "type": "command",
199
+ "command": build_hook_command(
200
+ python_exe, self.name, "stop", data_dir
201
+ ),
202
+ "timeout": 15,
203
+ }
204
+ ],
205
+ }
206
+ }
207
+ plan.file_ops.append(
208
+ FileOperation(
209
+ path=plugin_root / "hooks.json",
210
+ kind="copy_file",
211
+ content=json.dumps(hooks_cfg, indent=2) + "\n",
212
+ description="Write Antigravity plugin lifecycle hooks",
213
+ )
214
+ )
215
+ return plan
216
+
217
+ def plan_uninstall(
218
+ self,
219
+ *,
220
+ home_dir: Path,
221
+ project_dir: Path,
222
+ scope: str,
223
+ env: Mapping[str, str] | None = None,
224
+ ) -> InstallPlan:
225
+ plugin_root = self._plugin_root(home_dir, project_dir, scope, env)
226
+ plan = InstallPlan(agent=self.name)
227
+ rel_paths = [
228
+ "plugin.json",
229
+ "rules/AGENTS.md",
230
+ "mcp_config.json",
231
+ "hooks.json",
232
+ *(f"skills/{skill_name}/SKILL.md" for skill_name in ALL_SKILL_NAMES),
233
+ ]
234
+ for rel in rel_paths:
235
+ plan.file_ops.append(
236
+ FileOperation(
237
+ path=plugin_root / rel,
238
+ kind="remove_file",
239
+ description=f"Remove Antigravity plugin file {rel}",
240
+ )
241
+ )
242
+ if scope == "project":
243
+ plan.file_ops.append(
244
+ FileOperation(
245
+ path=project_dir / "AGENTS.md",
246
+ kind="remove_block",
247
+ block_id="core",
248
+ marker_style="md",
249
+ description="Remove shared Principal Engineer block from project AGENTS.md",
250
+ )
251
+ )
252
+ return plan