edify-agents-cli 0.2.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.
- edify/__init__.py +19 -0
- edify/__main__.py +6 -0
- edify/_toml.py +286 -0
- edify/agents.py +261 -0
- edify/anim.py +499 -0
- edify/assets/commands/build.md +64 -0
- edify/assets/commands/plan.md +68 -0
- edify/assets/commands/spec.md +63 -0
- edify/assets/commands/tasks.md +65 -0
- edify/assets/commands/verify.md +67 -0
- edify/assets/formats/plan.example.md +455 -0
- edify/assets/formats/plan.format.md +128 -0
- edify/assets/formats/spec.example.md +483 -0
- edify/assets/formats/spec.format.md +116 -0
- edify/assets/formats/tasks.example.md +712 -0
- edify/assets/formats/tasks.format.md +199 -0
- edify/assets/harvest/harvest.md +91 -0
- edify/assets/harvest/sources.md +295 -0
- edify/assets/harvest/vocab.md +52 -0
- edify/assets/manifest.md +30 -0
- edify/assets/mcp/default-registry.md +66 -0
- edify/assets/skills/adversary.md +61 -0
- edify/assets/skills/debugger.md +64 -0
- edify/assets/skills/implementer-general.md +53 -0
- edify/assets/skills/implementer-go.md +63 -0
- edify/assets/skills/implementer-node.md +61 -0
- edify/assets/skills/implementer-postgres.md +63 -0
- edify/assets/skills/implementer-python.md +65 -0
- edify/assets/skills/implementer-react.md +65 -0
- edify/assets/skills/planner.md +58 -0
- edify/assets/skills/test-writer-node.md +64 -0
- edify/assets/skills/test-writer-python.md +60 -0
- edify/assets/skills/verifier.md +67 -0
- edify/assets/templates/CLAUDE.md +18 -0
- edify/assets.py +77 -0
- edify/cli.py +681 -0
- edify/commands/__init__.py +1 -0
- edify/commands/check_cmd.py +72 -0
- edify/commands/doctor_cmd.py +206 -0
- edify/commands/feedback_cmd.py +90 -0
- edify/commands/governance_cmd.py +65 -0
- edify/commands/graph_cmd.py +156 -0
- edify/commands/harvest_cmd.py +538 -0
- edify/commands/init_cmd.py +333 -0
- edify/commands/init_new_cmd.py +151 -0
- edify/commands/license_cmd.py +80 -0
- edify/commands/mcp_cmd.py +159 -0
- edify/commands/self_cmd.py +185 -0
- edify/commands/setup_cmd.py +79 -0
- edify/commands/skills_cmd.py +177 -0
- edify/commands/upgrade_cmd.py +178 -0
- edify/context.py +57 -0
- edify/conventions.py +275 -0
- edify/detect.py +313 -0
- edify/distribution.py +40 -0
- edify/errors.py +66 -0
- edify/feedback.py +207 -0
- edify/formats/__init__.py +11 -0
- edify/formats/check.py +573 -0
- edify/formats/document.py +238 -0
- edify/formats/finding.py +50 -0
- edify/formats/fix.py +114 -0
- edify/formats/mcp.py +126 -0
- edify/formats/plan.py +151 -0
- edify/formats/skill.py +139 -0
- edify/formats/spec.py +164 -0
- edify/formats/tasks.py +321 -0
- edify/governance.py +316 -0
- edify/graph/__init__.py +11 -0
- edify/graph/extract.py +351 -0
- edify/graph/ignore.py +107 -0
- edify/graph/langs/__init__.py +93 -0
- edify/graph/langs/ctags.py +145 -0
- edify/graph/langs/markdown.py +41 -0
- edify/graph/langs/patterns.py +361 -0
- edify/graph/langs/python_ast.py +154 -0
- edify/graph/langs/sqlish.py +86 -0
- edify/graph/model.py +102 -0
- edify/graph/queries.py +211 -0
- edify/graph/store.py +157 -0
- edify/harvest/__init__.py +28 -0
- edify/harvest/ledger.py +191 -0
- edify/harvest/screen.py +236 -0
- edify/harvest/sources.py +298 -0
- edify/host.py +345 -0
- edify/interview.py +354 -0
- edify/library.py +176 -0
- edify/licensing/__init__.py +30 -0
- edify/licensing/ed25519.py +154 -0
- edify/licensing/projects.py +223 -0
- edify/licensing/tier.py +172 -0
- edify/licensing/token.py +149 -0
- edify/paths.py +282 -0
- edify/selfinstall.py +244 -0
- edify/skills.py +108 -0
- edify/tsv.py +109 -0
- edify/ui.py +334 -0
- edify_agents_cli-0.2.0.dist-info/METADATA +408 -0
- edify_agents_cli-0.2.0.dist-info/RECORD +102 -0
- edify_agents_cli-0.2.0.dist-info/WHEEL +4 -0
- edify_agents_cli-0.2.0.dist-info/entry_points.txt +2 -0
- edify_agents_cli-0.2.0.dist-info/licenses/LICENSE +21 -0
edify/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""EDIFY — three documents and a map.
|
|
2
|
+
|
|
3
|
+
A harness that sits around an AI coding agent and makes it work reliably on large
|
|
4
|
+
codebases. This package is the `edify` binary: it installs the harness, builds and
|
|
5
|
+
queries the graph, resolves skills, and checks formats.
|
|
6
|
+
|
|
7
|
+
It is not the agent runtime and it never wraps a model.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.2.0"
|
|
11
|
+
|
|
12
|
+
# The on-disk contract version for `.edify/graph/`. Bumping it means an existing
|
|
13
|
+
# graph is rebuilt rather than misread.
|
|
14
|
+
GRAPH_SCHEMA = 1
|
|
15
|
+
|
|
16
|
+
# The on-disk contract version for `.edify/skills/index.tsv`.
|
|
17
|
+
INDEX_SCHEMA = 1
|
|
18
|
+
|
|
19
|
+
__all__ = ["__version__", "GRAPH_SCHEMA", "INDEX_SCHEMA"]
|
edify/__main__.py
ADDED
edify/_toml.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"""`tomllib` on 3.11+, and a small reader of the same shape on 3.10.
|
|
2
|
+
|
|
3
|
+
The package supports 3.10 and has no runtime dependencies, so `tomli` is not an
|
|
4
|
+
option. The fallback reads what manifests and tool configs actually hold: tables,
|
|
5
|
+
arrays of tables, dotted and quoted keys, strings (basic, literal, multi-line),
|
|
6
|
+
integers, floats, booleans, arrays and inline tables. Dates come back as their text.
|
|
7
|
+
Anything it cannot read raises `TOMLDecodeError`, which every caller already treats
|
|
8
|
+
as "no data" — a degraded answer, never a crash.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import re
|
|
14
|
+
from typing import IO, Any
|
|
15
|
+
|
|
16
|
+
try: # pragma: no cover - which branch runs depends on the interpreter
|
|
17
|
+
import tomllib as _stdlib
|
|
18
|
+
except ModuleNotFoundError: # Python 3.10
|
|
19
|
+
_stdlib = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class _FallbackDecodeError(ValueError):
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
TOMLDecodeError = _stdlib.TOMLDecodeError if _stdlib else _FallbackDecodeError
|
|
27
|
+
|
|
28
|
+
_BARE_KEY = re.compile(r"[A-Za-z0-9_-]+")
|
|
29
|
+
_NUMBER = re.compile(r"[+-]?(?:0x[0-9A-Fa-f_]+|0o[0-7_]+|0b[01_]+|inf|nan|[0-9_]+(?:\.[0-9_]+)?(?:[eE][+-]?[0-9_]+)?)")
|
|
30
|
+
_DATE = re.compile(r"\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}:\d{2}(?:\.\d+)?")
|
|
31
|
+
_ESCAPES = {"b": "\b", "t": "\t", "n": "\n", "f": "\f", "r": "\r", '"': '"', "\\": "\\"}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load(fh: IO[bytes]) -> dict[str, Any]:
|
|
35
|
+
if _stdlib is not None:
|
|
36
|
+
return _stdlib.load(fh)
|
|
37
|
+
try:
|
|
38
|
+
return loads(fh.read().decode("utf-8"))
|
|
39
|
+
except UnicodeDecodeError as e:
|
|
40
|
+
raise _FallbackDecodeError(str(e)) from e
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def loads(text: str) -> dict[str, Any]:
|
|
44
|
+
if _stdlib is not None:
|
|
45
|
+
return _stdlib.loads(text)
|
|
46
|
+
return _Parser(text).document()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class _Parser:
|
|
50
|
+
def __init__(self, text: str) -> None:
|
|
51
|
+
self.s = text.replace("\r\n", "\n")
|
|
52
|
+
self.i = 0
|
|
53
|
+
|
|
54
|
+
# -- helpers ------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
def fail(self, what: str) -> None:
|
|
57
|
+
line = self.s.count("\n", 0, self.i) + 1
|
|
58
|
+
raise _FallbackDecodeError(f"{what} (line {line})")
|
|
59
|
+
|
|
60
|
+
def peek(self, n: int = 1) -> str:
|
|
61
|
+
return self.s[self.i : self.i + n]
|
|
62
|
+
|
|
63
|
+
def blank(self, newlines: bool = False) -> None:
|
|
64
|
+
"""Skip spaces and tabs, comments, and (when asked) newlines."""
|
|
65
|
+
while self.i < len(self.s):
|
|
66
|
+
c = self.s[self.i]
|
|
67
|
+
if c in " \t" or (newlines and c == "\n"):
|
|
68
|
+
self.i += 1
|
|
69
|
+
elif c == "#":
|
|
70
|
+
end = self.s.find("\n", self.i)
|
|
71
|
+
self.i = len(self.s) if end < 0 else end
|
|
72
|
+
else:
|
|
73
|
+
break
|
|
74
|
+
|
|
75
|
+
def expect(self, token: str) -> None:
|
|
76
|
+
if not self.s.startswith(token, self.i):
|
|
77
|
+
self.fail(f"expected {token!r}")
|
|
78
|
+
self.i += len(token)
|
|
79
|
+
|
|
80
|
+
# -- structure ----------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
def document(self) -> dict[str, Any]:
|
|
83
|
+
root: dict[str, Any] = {}
|
|
84
|
+
table = root
|
|
85
|
+
while True:
|
|
86
|
+
self.blank(newlines=True)
|
|
87
|
+
if self.i >= len(self.s):
|
|
88
|
+
return root
|
|
89
|
+
if self.peek(2) == "[[":
|
|
90
|
+
self.i += 2
|
|
91
|
+
path = self.key()
|
|
92
|
+
self.expect("]]")
|
|
93
|
+
parent = self.descend(root, path[:-1])
|
|
94
|
+
items = parent.setdefault(path[-1], [])
|
|
95
|
+
if not isinstance(items, list):
|
|
96
|
+
self.fail("array of tables redefines a key")
|
|
97
|
+
table = {}
|
|
98
|
+
items.append(table)
|
|
99
|
+
elif self.peek() == "[":
|
|
100
|
+
self.i += 1
|
|
101
|
+
path = self.key()
|
|
102
|
+
self.expect("]")
|
|
103
|
+
table = self.descend(root, path)
|
|
104
|
+
else:
|
|
105
|
+
path = self.key()
|
|
106
|
+
self.blank()
|
|
107
|
+
self.expect("=")
|
|
108
|
+
self.blank()
|
|
109
|
+
value = self.value()
|
|
110
|
+
self.descend(table, path[:-1])[path[-1]] = value
|
|
111
|
+
self.blank()
|
|
112
|
+
if self.i < len(self.s) and self.s[self.i] != "\n":
|
|
113
|
+
self.fail("expected the end of the line")
|
|
114
|
+
|
|
115
|
+
def descend(self, table: dict[str, Any], path: list[str]) -> dict[str, Any]:
|
|
116
|
+
for part in path:
|
|
117
|
+
nxt = table.setdefault(part, {})
|
|
118
|
+
if isinstance(nxt, list) and nxt and isinstance(nxt[-1], dict):
|
|
119
|
+
nxt = nxt[-1]
|
|
120
|
+
if not isinstance(nxt, dict):
|
|
121
|
+
self.fail(f"{part!r} is not a table")
|
|
122
|
+
table = nxt
|
|
123
|
+
return table
|
|
124
|
+
|
|
125
|
+
def key(self) -> list[str]:
|
|
126
|
+
parts = []
|
|
127
|
+
while True:
|
|
128
|
+
self.blank()
|
|
129
|
+
c = self.peek()
|
|
130
|
+
if c == '"':
|
|
131
|
+
parts.append(self.basic_string())
|
|
132
|
+
elif c == "'":
|
|
133
|
+
parts.append(self.literal_string())
|
|
134
|
+
else:
|
|
135
|
+
m = _BARE_KEY.match(self.s, self.i)
|
|
136
|
+
if not m:
|
|
137
|
+
self.fail("expected a key")
|
|
138
|
+
parts.append(m.group())
|
|
139
|
+
self.i = m.end()
|
|
140
|
+
self.blank()
|
|
141
|
+
if self.peek() != ".":
|
|
142
|
+
return parts
|
|
143
|
+
self.i += 1
|
|
144
|
+
|
|
145
|
+
# -- values -------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
def value(self) -> Any:
|
|
148
|
+
c = self.peek()
|
|
149
|
+
if self.peek(3) == '"""':
|
|
150
|
+
return self.multiline('"""')
|
|
151
|
+
if self.peek(3) == "'''":
|
|
152
|
+
return self.multiline("'''")
|
|
153
|
+
if c == '"':
|
|
154
|
+
return self.basic_string()
|
|
155
|
+
if c == "'":
|
|
156
|
+
return self.literal_string()
|
|
157
|
+
if c == "[":
|
|
158
|
+
return self.array()
|
|
159
|
+
if c == "{":
|
|
160
|
+
return self.inline_table()
|
|
161
|
+
if self.s.startswith("true", self.i):
|
|
162
|
+
self.i += 4
|
|
163
|
+
return True
|
|
164
|
+
if self.s.startswith("false", self.i):
|
|
165
|
+
self.i += 5
|
|
166
|
+
return False
|
|
167
|
+
m = _DATE.match(self.s, self.i)
|
|
168
|
+
if m:
|
|
169
|
+
self.i = m.end()
|
|
170
|
+
return m.group()
|
|
171
|
+
m = _NUMBER.match(self.s, self.i)
|
|
172
|
+
if m and m.group():
|
|
173
|
+
self.i = m.end()
|
|
174
|
+
return _number(m.group())
|
|
175
|
+
self.fail("expected a value")
|
|
176
|
+
|
|
177
|
+
def basic_string(self) -> str:
|
|
178
|
+
self.expect('"')
|
|
179
|
+
out = []
|
|
180
|
+
while True:
|
|
181
|
+
if self.i >= len(self.s) or self.s[self.i] == "\n":
|
|
182
|
+
self.fail("unterminated string")
|
|
183
|
+
c = self.s[self.i]
|
|
184
|
+
self.i += 1
|
|
185
|
+
if c == '"':
|
|
186
|
+
return "".join(out)
|
|
187
|
+
out.append(self.escape() if c == "\\" else c)
|
|
188
|
+
|
|
189
|
+
def escape(self) -> str:
|
|
190
|
+
c = self.peek()
|
|
191
|
+
self.i += 1
|
|
192
|
+
if c in _ESCAPES:
|
|
193
|
+
return _ESCAPES[c]
|
|
194
|
+
if c in "uU":
|
|
195
|
+
n = 4 if c == "u" else 8
|
|
196
|
+
code = self.s[self.i : self.i + n]
|
|
197
|
+
self.i += n
|
|
198
|
+
try:
|
|
199
|
+
return chr(int(code, 16))
|
|
200
|
+
except ValueError:
|
|
201
|
+
self.fail("bad unicode escape")
|
|
202
|
+
self.fail("bad escape")
|
|
203
|
+
return ""
|
|
204
|
+
|
|
205
|
+
def literal_string(self) -> str:
|
|
206
|
+
self.expect("'")
|
|
207
|
+
end = self.s.find("'", self.i)
|
|
208
|
+
nl = self.s.find("\n", self.i)
|
|
209
|
+
if end < 0 or (0 <= nl < end):
|
|
210
|
+
self.fail("unterminated string")
|
|
211
|
+
text = self.s[self.i : end]
|
|
212
|
+
self.i = end + 1
|
|
213
|
+
return text
|
|
214
|
+
|
|
215
|
+
def multiline(self, quote: str) -> str:
|
|
216
|
+
self.i += 3
|
|
217
|
+
if self.peek() == "\n":
|
|
218
|
+
self.i += 1
|
|
219
|
+
end = self.s.find(quote, self.i)
|
|
220
|
+
if end < 0:
|
|
221
|
+
self.fail("unterminated string")
|
|
222
|
+
while self.s.startswith(quote[0], end + 3) and end + 3 < len(self.s):
|
|
223
|
+
end += 1 # up to two quotes may sit right before the closing three
|
|
224
|
+
raw = self.s[self.i : end]
|
|
225
|
+
self.i = end + 3
|
|
226
|
+
if quote == "'''":
|
|
227
|
+
return raw
|
|
228
|
+
raw = re.sub(r"\\[ \t]*\n\s*", "", raw) # line-ending backslash
|
|
229
|
+
out, k = [], 0
|
|
230
|
+
while k < len(raw):
|
|
231
|
+
if raw[k] == "\\":
|
|
232
|
+
sub = _Parser(raw)
|
|
233
|
+
sub.i = k + 1
|
|
234
|
+
out.append(sub.escape())
|
|
235
|
+
k = sub.i
|
|
236
|
+
else:
|
|
237
|
+
out.append(raw[k])
|
|
238
|
+
k += 1
|
|
239
|
+
return "".join(out)
|
|
240
|
+
|
|
241
|
+
def array(self) -> list[Any]:
|
|
242
|
+
self.expect("[")
|
|
243
|
+
items: list[Any] = []
|
|
244
|
+
while True:
|
|
245
|
+
self.blank(newlines=True)
|
|
246
|
+
if self.peek() == "]":
|
|
247
|
+
self.i += 1
|
|
248
|
+
return items
|
|
249
|
+
items.append(self.value())
|
|
250
|
+
self.blank(newlines=True)
|
|
251
|
+
if self.peek() == ",":
|
|
252
|
+
self.i += 1
|
|
253
|
+
elif self.peek() != "]":
|
|
254
|
+
self.fail("expected ',' or ']'")
|
|
255
|
+
|
|
256
|
+
def inline_table(self) -> dict[str, Any]:
|
|
257
|
+
self.expect("{")
|
|
258
|
+
table: dict[str, Any] = {}
|
|
259
|
+
self.blank()
|
|
260
|
+
if self.peek() == "}":
|
|
261
|
+
self.i += 1
|
|
262
|
+
return table
|
|
263
|
+
while True:
|
|
264
|
+
path = self.key()
|
|
265
|
+
self.blank()
|
|
266
|
+
self.expect("=")
|
|
267
|
+
self.blank()
|
|
268
|
+
self.descend(table, path[:-1])[path[-1]] = self.value()
|
|
269
|
+
self.blank()
|
|
270
|
+
if self.peek() == "}":
|
|
271
|
+
self.i += 1
|
|
272
|
+
return table
|
|
273
|
+
self.expect(",")
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _number(text: str) -> int | float:
|
|
277
|
+
t = text.replace("_", "")
|
|
278
|
+
sign = -1 if t.startswith("-") else 1
|
|
279
|
+
body = t.lstrip("+-")
|
|
280
|
+
if body in ("inf", "nan"):
|
|
281
|
+
return sign * float(body)
|
|
282
|
+
if body[:2] in ("0x", "0o", "0b"):
|
|
283
|
+
return sign * int(body, 0)
|
|
284
|
+
if any(ch in body for ch in ".eE"):
|
|
285
|
+
return float(t)
|
|
286
|
+
return int(t)
|
edify/agents.py
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"""Every agent runtime EDIFY installs into, and where each one looks.
|
|
2
|
+
|
|
3
|
+
`.edify/` is canonical. A runtime does not read it — each one discovers its own
|
|
4
|
+
instructions and its own commands somewhere else, and they do not agree on a single
|
|
5
|
+
path between them. Claude Code reads `CLAUDE.md` and `.claude/`; Codex and Cursor read
|
|
6
|
+
`AGENTS.md`; Gemini reads `GEMINI.md`; Copilot reads `.github/copilot-instructions.md`.
|
|
7
|
+
An install that writes only `CLAUDE.md` is an install that is invisible to five of the
|
|
8
|
+
six tools a team actually has open.
|
|
9
|
+
|
|
10
|
+
So this module is the table, and it is only a table: paths, suffixes, and the shape
|
|
11
|
+
each runtime expects. Nothing here reads or writes a file — `host.py` does that, once,
|
|
12
|
+
for whichever targets were chosen. Adding a runtime is adding a row, not a code path.
|
|
13
|
+
|
|
14
|
+
Two things every row shares, and they are the reason the mirror is safe to re-run:
|
|
15
|
+
|
|
16
|
+
**Everything generated carries `MARKER_TEXT`.** That is what makes a file ours to
|
|
17
|
+
replace and, just as importantly, what makes a file somebody wrote by hand not ours.
|
|
18
|
+
It appears as an HTML comment in Markdown and a `#` comment in TOML, so the check is
|
|
19
|
+
for the text and not for the punctuation around it.
|
|
20
|
+
|
|
21
|
+
**Instruction files are merged, never overwritten.** EDIFY owns the block between
|
|
22
|
+
`BLOCK_BEGIN` and `BLOCK_END` in a file that belongs to the repository. Somebody wrote
|
|
23
|
+
the rest of `AGENTS.md` on purpose.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
from dataclasses import dataclass
|
|
29
|
+
|
|
30
|
+
# The block EDIFY owns inside somebody else's instruction file.
|
|
31
|
+
BLOCK_BEGIN = "<!-- edify:begin -->"
|
|
32
|
+
BLOCK_END = "<!-- edify:end -->"
|
|
33
|
+
|
|
34
|
+
# The text every generated pointer carries. `written_by_edify` looks for this and not
|
|
35
|
+
# for a whole comment, because a TOML command file cannot hold an HTML one.
|
|
36
|
+
MARKER_TEXT = "edify:generated"
|
|
37
|
+
MARKER_MD = f"<!-- {MARKER_TEXT} — this file is a pointer; edit the file it names -->"
|
|
38
|
+
MARKER_TOML = f"# {MARKER_TEXT} — this file is a pointer; edit the file it names"
|
|
39
|
+
|
|
40
|
+
# The shape the command pointers had before there was a marker. A repository that ran
|
|
41
|
+
# an earlier `init` has six of them, and without this they would all be treated as
|
|
42
|
+
# somebody's own files and never brought up to date.
|
|
43
|
+
LEGACY_MARKERS = ("That file is the contract; this one only points at it.",)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass(frozen=True)
|
|
47
|
+
class Instructions:
|
|
48
|
+
"""One instruction file a runtime reads at the start of every session.
|
|
49
|
+
|
|
50
|
+
`style` is the wrapper the runtime needs around the block, not the block itself:
|
|
51
|
+
`plain` is Markdown as written, `mdc` is Cursor's rule format, which is Markdown
|
|
52
|
+
with a frontmatter header that decides when the rule applies.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
path: str
|
|
56
|
+
style: str = "plain" # plain | mdc
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class Target:
|
|
61
|
+
"""One agent runtime: what it reads, and where it discovers commands."""
|
|
62
|
+
|
|
63
|
+
id: str
|
|
64
|
+
label: str
|
|
65
|
+
instructions: tuple[Instructions, ...]
|
|
66
|
+
commands: str = "" # directory for one command pointer per EDIFY command
|
|
67
|
+
command_suffix: str = ".md"
|
|
68
|
+
command_format: str = "markdown" # markdown | toml
|
|
69
|
+
skills: str = "" # directory holding one directory per skill
|
|
70
|
+
skill_file: str = "SKILL.md"
|
|
71
|
+
agents: str = "" # directory holding one flat file per subagent
|
|
72
|
+
notes: str = ""
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def instruction_paths(self) -> tuple[str, ...]:
|
|
76
|
+
return tuple(i.path for i in self.instructions)
|
|
77
|
+
|
|
78
|
+
def trees(self) -> tuple[tuple[str, str], ...]:
|
|
79
|
+
"""`(directory, glob)` for every family of generated pointers this row has.
|
|
80
|
+
|
|
81
|
+
Everything that has to walk a runtime's own tree — the governance scan, the
|
|
82
|
+
clearing `init new` does first, the staleness check — walks it through here,
|
|
83
|
+
so a row added above is covered by all three without touching any of them.
|
|
84
|
+
"""
|
|
85
|
+
out: list[tuple[str, str]] = []
|
|
86
|
+
if self.commands:
|
|
87
|
+
out.append((self.commands, f"*{self.command_suffix}"))
|
|
88
|
+
if self.skills:
|
|
89
|
+
out.append((self.skills, f"*/{self.skill_file}"))
|
|
90
|
+
if self.agents:
|
|
91
|
+
out.append((self.agents, "*.md"))
|
|
92
|
+
return tuple(out)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# -- the table ---------------------------------------------------------------
|
|
96
|
+
# Ordered as a person would read them: the runtime EDIFY was built against first,
|
|
97
|
+
# then the ones that share `AGENTS.md`, then the rest, then the fallback that is
|
|
98
|
+
# nothing but `AGENTS.md` for a tool nobody has written a row for yet.
|
|
99
|
+
|
|
100
|
+
TARGETS: tuple[Target, ...] = (
|
|
101
|
+
Target(
|
|
102
|
+
id="claude",
|
|
103
|
+
label="Claude Code",
|
|
104
|
+
instructions=(Instructions("CLAUDE.md"),),
|
|
105
|
+
commands=".claude/commands",
|
|
106
|
+
skills=".claude/skills",
|
|
107
|
+
agents=".claude/agents",
|
|
108
|
+
notes="commands, skills, and spawnable subagents",
|
|
109
|
+
),
|
|
110
|
+
Target(
|
|
111
|
+
id="codex",
|
|
112
|
+
label="OpenAI Codex",
|
|
113
|
+
instructions=(Instructions("AGENTS.md"),),
|
|
114
|
+
commands=".codex/prompts",
|
|
115
|
+
notes="AGENTS.md and saved prompts",
|
|
116
|
+
),
|
|
117
|
+
Target(
|
|
118
|
+
id="cursor",
|
|
119
|
+
label="Cursor",
|
|
120
|
+
instructions=(Instructions("AGENTS.md"), Instructions(".cursor/rules/edify.mdc", style="mdc")),
|
|
121
|
+
commands=".cursor/commands",
|
|
122
|
+
notes="AGENTS.md, an always-on rule, and slash commands",
|
|
123
|
+
),
|
|
124
|
+
Target(
|
|
125
|
+
id="gemini",
|
|
126
|
+
label="Gemini CLI",
|
|
127
|
+
instructions=(Instructions("GEMINI.md"),),
|
|
128
|
+
commands=".gemini/commands",
|
|
129
|
+
command_suffix=".toml",
|
|
130
|
+
command_format="toml",
|
|
131
|
+
notes="GEMINI.md and TOML custom commands",
|
|
132
|
+
),
|
|
133
|
+
Target(
|
|
134
|
+
id="copilot",
|
|
135
|
+
label="GitHub Copilot",
|
|
136
|
+
instructions=(Instructions(".github/copilot-instructions.md"),),
|
|
137
|
+
commands=".github/prompts",
|
|
138
|
+
command_suffix=".prompt.md",
|
|
139
|
+
notes="repository instructions and prompt files",
|
|
140
|
+
),
|
|
141
|
+
Target(
|
|
142
|
+
id="windsurf",
|
|
143
|
+
label="Windsurf",
|
|
144
|
+
instructions=(Instructions(".windsurf/rules/edify.md"),),
|
|
145
|
+
commands=".windsurf/workflows",
|
|
146
|
+
notes="a repository rule and workflows",
|
|
147
|
+
),
|
|
148
|
+
Target(
|
|
149
|
+
id="agents",
|
|
150
|
+
label="any other agent",
|
|
151
|
+
instructions=(Instructions("AGENTS.md"),),
|
|
152
|
+
notes="AGENTS.md only — the file the rest of them read",
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
BY_ID = {t.id: t for t in TARGETS}
|
|
157
|
+
|
|
158
|
+
# What `edify init new` installs when nobody says otherwise. Every row: the whole
|
|
159
|
+
# point of the command is a folder that works in whichever tool is opened next.
|
|
160
|
+
ALL_IDS = tuple(t.id for t in TARGETS)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def present(target: Target, root) -> bool:
|
|
164
|
+
"""Whether this runtime is already set up in this folder.
|
|
165
|
+
|
|
166
|
+
The test is a directory the runtime keeps its own commands in, never an
|
|
167
|
+
instruction file. `AGENTS.md` is three rows' answer and is just as likely to have
|
|
168
|
+
been written by somebody who has never run EDIFY, and treating it as evidence
|
|
169
|
+
would have `init` quietly start writing into `.codex/` and `.cursor/` in a
|
|
170
|
+
repository that asked for neither.
|
|
171
|
+
"""
|
|
172
|
+
return any((root / directory).is_dir() for directory, _ in target.trees())
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def present_targets(root) -> list[Target]:
|
|
176
|
+
return [t for t in TARGETS if present(t, root)]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def resolve(spec: str, host: str = "claude", root=None) -> list[Target]:
|
|
180
|
+
"""Which runtimes to write for.
|
|
181
|
+
|
|
182
|
+
all | * every row in the table
|
|
183
|
+
none nothing — `.edify/` only
|
|
184
|
+
<ids…> exactly these, comma- or space-separated
|
|
185
|
+
"" (unset) whichever runtimes are already set up here, and `--host`
|
|
186
|
+
when none are — which is what `init` has always done in a
|
|
187
|
+
folder nobody has run `init new` in
|
|
188
|
+
|
|
189
|
+
That last rule is what keeps a folder honest. `init new` writes six instruction
|
|
190
|
+
files; a plain `edify init` a week later must bring all six up to date, because
|
|
191
|
+
five stale ones and one current one is worse than the state before either ran.
|
|
192
|
+
|
|
193
|
+
An unknown id is not silently dropped: a person who typed `--agents cursur` asked
|
|
194
|
+
for Cursor and would otherwise be told everything worked.
|
|
195
|
+
"""
|
|
196
|
+
from .errors import EdifyError
|
|
197
|
+
|
|
198
|
+
wanted = (spec or "").strip().lower()
|
|
199
|
+
if not wanted:
|
|
200
|
+
if host != "none" and root is not None:
|
|
201
|
+
already = present_targets(root)
|
|
202
|
+
if already:
|
|
203
|
+
return already
|
|
204
|
+
wanted = "none" if host == "none" else host
|
|
205
|
+
if wanted in ("all", "*", "every"):
|
|
206
|
+
return list(TARGETS)
|
|
207
|
+
if wanted in ("none", "-"):
|
|
208
|
+
return []
|
|
209
|
+
|
|
210
|
+
picked: list[Target] = []
|
|
211
|
+
unknown: list[str] = []
|
|
212
|
+
for token in wanted.replace(",", " ").split():
|
|
213
|
+
target = BY_ID.get(token)
|
|
214
|
+
if target is None:
|
|
215
|
+
unknown.append(token)
|
|
216
|
+
elif target not in picked:
|
|
217
|
+
picked.append(target)
|
|
218
|
+
if unknown:
|
|
219
|
+
raise EdifyError(
|
|
220
|
+
f"no agent runtime called `{unknown[0]}`",
|
|
221
|
+
hint=f"known ids: {', '.join(ALL_IDS)} — or `all`, or `none`",
|
|
222
|
+
)
|
|
223
|
+
return picked
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def instruction_files(targets: list[Target]) -> list[Instructions]:
|
|
227
|
+
"""Every instruction file these targets read, deduplicated and in table order.
|
|
228
|
+
|
|
229
|
+
`AGENTS.md` is three rows' answer and one file on disk. Writing it once is not an
|
|
230
|
+
optimisation — writing it three times would merge EDIFY's block into a file that
|
|
231
|
+
already had EDIFY's block, twice.
|
|
232
|
+
"""
|
|
233
|
+
seen: dict[str, Instructions] = {}
|
|
234
|
+
for target in targets:
|
|
235
|
+
for item in target.instructions:
|
|
236
|
+
seen.setdefault(item.path, item)
|
|
237
|
+
return list(seen.values())
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def all_trees() -> tuple[tuple[str, str], ...]:
|
|
241
|
+
"""Every generated-pointer directory in the table, for the scans that walk them all.
|
|
242
|
+
|
|
243
|
+
Governance and clearing are about what is *on disk*, not about what was chosen
|
|
244
|
+
this run: a folder set up for Cursor last month and for Claude today still has
|
|
245
|
+
Cursor's pointers in it, and both of them are EDIFY's.
|
|
246
|
+
"""
|
|
247
|
+
out: list[tuple[str, str]] = []
|
|
248
|
+
for target in TARGETS:
|
|
249
|
+
for tree in target.trees():
|
|
250
|
+
if tree not in out:
|
|
251
|
+
out.append(tree)
|
|
252
|
+
return tuple(out)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def all_instruction_paths() -> tuple[str, ...]:
|
|
256
|
+
seen: list[str] = []
|
|
257
|
+
for target in TARGETS:
|
|
258
|
+
for item in target.instructions:
|
|
259
|
+
if item.path not in seen:
|
|
260
|
+
seen.append(item.path)
|
|
261
|
+
return tuple(seen)
|