principal-engineer 0.1.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.
- principal_engineer/__init__.py +0 -0
- principal_engineer/_run.py +12 -0
- principal_engineer/adapters/__init__.py +24 -0
- principal_engineer/adapters/antigravity.py +252 -0
- principal_engineer/adapters/base.py +205 -0
- principal_engineer/adapters/claude_code.py +297 -0
- principal_engineer/adapters/codex.py +259 -0
- principal_engineer/config.example.json +53 -0
- principal_engineer/features/core-bootstrap/AGENTS.snippet.md +8 -0
- principal_engineer/features/discipline/SKILL.md +13 -0
- principal_engineer/features/feasibility-gate/SKILL.md +17 -0
- principal_engineer/features/memory/SKILL.md +13 -0
- principal_engineer/features/plan-persistence/SKILL.md +15 -0
- principal_engineer/features/research/SKILL.md +12 -0
- principal_engineer/memory/__init__.py +13 -0
- principal_engineer/memory/core.py +120 -0
- principal_engineer/memory/mcp_server.py +240 -0
- principal_engineer/memory/secrets.py +84 -0
- principal_engineer/memory/store.py +515 -0
- principal_engineer/panel/__init__.py +5 -0
- principal_engineer/panel/app.py +453 -0
- principal_engineer/panel/controller.py +211 -0
- principal_engineer/research/__init__.py +16 -0
- principal_engineer/research/cache.py +188 -0
- principal_engineer/research/mcp_server.py +239 -0
- principal_engineer/research/providers.py +224 -0
- principal_engineer/research/reader.py +173 -0
- principal_engineer/tools/__init__.py +1 -0
- principal_engineer/tools/budgets.py +131 -0
- principal_engineer/tools/cli.py +417 -0
- principal_engineer/tools/file_ops.py +180 -0
- principal_engineer/tools/githook.py +60 -0
- principal_engineer/tools/handoff.py +121 -0
- principal_engineer/tools/hook_runner.py +254 -0
- principal_engineer/tools/installer.py +587 -0
- principal_engineer/tools/plugin_sync.py +59 -0
- principal_engineer/tools/repomap.py +125 -0
- principal_engineer/tools/trim_run.py +97 -0
- principal_engineer/tools/verify.py +286 -0
- principal_engineer-0.1.0.dist-info/METADATA +132 -0
- principal_engineer-0.1.0.dist-info/RECORD +45 -0
- principal_engineer-0.1.0.dist-info/WHEEL +5 -0
- principal_engineer-0.1.0.dist-info/entry_points.txt +2 -0
- principal_engineer-0.1.0.dist-info/licenses/LICENSE +21 -0
- principal_engineer-0.1.0.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -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
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"""Base contract and pure operation models for agent adapters."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from abc import ABC, abstractmethod
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Mapping
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class AdapterStatus:
|
|
14
|
+
"""Detection and capability report for one agent on the host."""
|
|
15
|
+
|
|
16
|
+
name: str
|
|
17
|
+
present: bool
|
|
18
|
+
reason: str
|
|
19
|
+
tested_version: str
|
|
20
|
+
doc_verified_date: str
|
|
21
|
+
enforcement_mode: str # "Hook-enforced" | "Advisory"
|
|
22
|
+
config_root: Path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class FileOperation:
|
|
27
|
+
"""Pure description of one install/uninstall file mutation."""
|
|
28
|
+
|
|
29
|
+
path: Path
|
|
30
|
+
kind: str # "copy_file" | "marked_block" | "json_merge" | "remove_file" | "remove_block" | "remove_json"
|
|
31
|
+
content: str = ""
|
|
32
|
+
block_id: str = ""
|
|
33
|
+
marker_style: str = "md"
|
|
34
|
+
json_section: str = ""
|
|
35
|
+
json_items: dict[str, Any] = field(default_factory=dict)
|
|
36
|
+
json_remove_prefix: str = ""
|
|
37
|
+
description: str = ""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass(frozen=True)
|
|
41
|
+
class CommandOperation:
|
|
42
|
+
"""Optional external CLI operation (e.g., `claude mcp add-json` / `remove`)."""
|
|
43
|
+
|
|
44
|
+
args: tuple[str, ...]
|
|
45
|
+
description: str
|
|
46
|
+
fallback_file_op: FileOperation | None = None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@dataclass
|
|
50
|
+
class InstallPlan:
|
|
51
|
+
"""Pure plan produced by an adapter for `--dry-run` or execution."""
|
|
52
|
+
|
|
53
|
+
agent: str
|
|
54
|
+
file_ops: list[FileOperation] = field(default_factory=list)
|
|
55
|
+
command_ops: list[CommandOperation] = field(default_factory=list)
|
|
56
|
+
notes: list[str] = field(default_factory=list)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def quote_cmd_arg(value: str) -> str:
|
|
60
|
+
"""Quote an executable or file path safely for shell-free JSON/command strings."""
|
|
61
|
+
if any(ch in value for ch in (' ', '\t', '"')):
|
|
62
|
+
escaped = value.replace('"', '\\"')
|
|
63
|
+
return f'"{escaped}"'
|
|
64
|
+
return value
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
HOOK_MODULE = "principal_engineer.tools.hook_runner"
|
|
68
|
+
MEMORY_MCP_MODULE = "principal_engineer.memory.mcp_server"
|
|
69
|
+
RESEARCH_MCP_MODULE = "principal_engineer.research.mcp_server"
|
|
70
|
+
|
|
71
|
+
_RUN_SCRIPT = Path(__file__).resolve().parent.parent / "_run.py"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def is_package_installed() -> bool:
|
|
75
|
+
"""True when `principal-engineer` is really installed (pip/pipx/editable), so `python -m` resolves.
|
|
76
|
+
|
|
77
|
+
Only `.dist-info` metadata counts: a stray `*.egg-info` left in a source checkout by a build
|
|
78
|
+
would otherwise look installed whenever the checkout root is on `sys.path`.
|
|
79
|
+
"""
|
|
80
|
+
from importlib import metadata
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
dist = metadata.distribution("principal-engineer")
|
|
84
|
+
except metadata.PackageNotFoundError:
|
|
85
|
+
return False
|
|
86
|
+
meta_dir = getattr(dist, "_path", None)
|
|
87
|
+
return meta_dir is None or str(meta_dir).endswith(".dist-info")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def module_launch_args(module: str) -> list[str]:
|
|
91
|
+
"""Interpreter arguments that start `module`: `-m` when installed, else the checkout launcher."""
|
|
92
|
+
if is_package_installed():
|
|
93
|
+
return ["-m", module]
|
|
94
|
+
return [str(_RUN_SCRIPT), module]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def build_hook_command(python_exe: str, agent: str, event: str, data_dir: Path) -> str:
|
|
98
|
+
"""Build a portable hook invocation without shell syntax."""
|
|
99
|
+
launch = " ".join(quote_cmd_arg(a) for a in module_launch_args(HOOK_MODULE))
|
|
100
|
+
return (
|
|
101
|
+
f"{quote_cmd_arg(python_exe)} {launch} "
|
|
102
|
+
f"--agent {agent} --event {event} --data-dir {quote_cmd_arg(str(data_dir))}"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def mcp_args(module: str, data_dir: Path) -> list[str]:
|
|
107
|
+
"""Arguments for launching an MCP server module with `python_exe`."""
|
|
108
|
+
return [*module_launch_args(module), "--data-dir", str(data_dir)]
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
STRICTNESS_RULES: dict[str, str] = {
|
|
112
|
+
"occasionally": (
|
|
113
|
+
"Ask the user before coding only when the task looks impossible or hits a critical blocker."
|
|
114
|
+
),
|
|
115
|
+
"usually": (
|
|
116
|
+
"Ask the user before coding whenever a high-risk or costly uncertainty could be resolved with one answer."
|
|
117
|
+
),
|
|
118
|
+
"always": (
|
|
119
|
+
"Ask the user before coding on any uncertainty in your assumptions or stop condition."
|
|
120
|
+
),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
SKILL_FEATURE_MAP: dict[str, tuple[str, str]] = {
|
|
124
|
+
"memory": ("principal-memory", "memory"),
|
|
125
|
+
"plan-persistence": ("principal-plan-persistence", "plan-persistence"),
|
|
126
|
+
"discipline": ("principal-discipline", "discipline"),
|
|
127
|
+
"feasibility-gate": ("principal-feasibility-gate", "feasibility-gate"),
|
|
128
|
+
"research": ("principal-research", "research"),
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
ALL_SKILL_NAMES: tuple[str, ...] = tuple(name for name, _folder in SKILL_FEATURE_MAP.values())
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def render_skill_content(skill_name: str, raw_text: str, config: Mapping[str, Any] | None = None) -> str:
|
|
135
|
+
"""Render dynamic placeholders (such as feasibility strictness) in a SKILL.md."""
|
|
136
|
+
if skill_name != "principal-feasibility-gate":
|
|
137
|
+
return raw_text
|
|
138
|
+
raw_level = str((config or {}).get("feasibility_strictness", "usually")).strip().lower()
|
|
139
|
+
rule_text = STRICTNESS_RULES.get(raw_level, STRICTNESS_RULES["usually"])
|
|
140
|
+
return raw_text.replace("{{STRICTNESS_RULE}}", rule_text)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def selected_skill_dirs(repo_root: Path, enabled_features: list[str]) -> list[tuple[str, Path]]:
|
|
144
|
+
"""Return `(skill_folder_name, skill_md_path)` pairs enabled by config."""
|
|
145
|
+
out: list[tuple[str, Path]] = []
|
|
146
|
+
for feat in enabled_features:
|
|
147
|
+
entry = SKILL_FEATURE_MAP.get(feat)
|
|
148
|
+
if not entry:
|
|
149
|
+
continue
|
|
150
|
+
skill_name, folder = entry
|
|
151
|
+
skill_path = repo_root / "features" / folder / "SKILL.md"
|
|
152
|
+
if skill_path.exists():
|
|
153
|
+
out.append((skill_name, skill_path))
|
|
154
|
+
return out
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class BaseAdapter(ABC):
|
|
158
|
+
"""Abstract adapter implemented once per supported coding agent."""
|
|
159
|
+
|
|
160
|
+
name: str
|
|
161
|
+
tested_version: str
|
|
162
|
+
doc_verified_date: str
|
|
163
|
+
enforcement_mode: str
|
|
164
|
+
|
|
165
|
+
@abstractmethod
|
|
166
|
+
def detect(
|
|
167
|
+
self,
|
|
168
|
+
home_dir: Path,
|
|
169
|
+
project_dir: Path,
|
|
170
|
+
env: Mapping[str, str] | None = None,
|
|
171
|
+
) -> AdapterStatus:
|
|
172
|
+
"""Detect if this agent is configured or installed on the machine."""
|
|
173
|
+
|
|
174
|
+
@abstractmethod
|
|
175
|
+
def plan_install(
|
|
176
|
+
self,
|
|
177
|
+
*,
|
|
178
|
+
repo_root: Path,
|
|
179
|
+
data_dir: Path,
|
|
180
|
+
home_dir: Path,
|
|
181
|
+
project_dir: Path,
|
|
182
|
+
scope: str,
|
|
183
|
+
enabled_features: list[str],
|
|
184
|
+
python_exe: str,
|
|
185
|
+
env: Mapping[str, str] | None = None,
|
|
186
|
+
config: Mapping[str, Any] | None = None,
|
|
187
|
+
) -> InstallPlan:
|
|
188
|
+
"""Produce pure install operations without touching disk."""
|
|
189
|
+
|
|
190
|
+
@abstractmethod
|
|
191
|
+
def plan_uninstall(
|
|
192
|
+
self,
|
|
193
|
+
*,
|
|
194
|
+
home_dir: Path,
|
|
195
|
+
project_dir: Path,
|
|
196
|
+
scope: str,
|
|
197
|
+
env: Mapping[str, str] | None = None,
|
|
198
|
+
) -> InstallPlan:
|
|
199
|
+
"""Produce pure uninstall operations without touching disk."""
|
|
200
|
+
|
|
201
|
+
@staticmethod
|
|
202
|
+
def _env_path(env: Mapping[str, str] | None, var: str) -> Path | None:
|
|
203
|
+
source = env if env is not None else os.environ
|
|
204
|
+
val = source.get(var, "").strip()
|
|
205
|
+
return Path(val) if val else None
|