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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""`edify check` — the whole validation story, and it is a command, not a gate.
|
|
2
|
+
|
|
3
|
+
A person runs it, or CI runs it, and it prints what is wrong. Nothing halts a
|
|
4
|
+
session. `--exit-code` exists because a customer who needs a hard block should own
|
|
5
|
+
one; that is the honest scope: advisory means advisory.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from ..context import Context
|
|
11
|
+
from ..formats.check import check_repository
|
|
12
|
+
from ..formats.finding import Level
|
|
13
|
+
from ..formats.fix import fix_repository
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def run(ctx: Context) -> int:
|
|
17
|
+
ctx.layout.require_installed()
|
|
18
|
+
out = ctx.out
|
|
19
|
+
|
|
20
|
+
repairs = []
|
|
21
|
+
if ctx.args.fix:
|
|
22
|
+
store = ctx.store if ctx.store.exists() else None
|
|
23
|
+
repairs = fix_repository(ctx.layout, store)
|
|
24
|
+
for repair in repairs:
|
|
25
|
+
out.line(f"fixed {repair.file}:{repair.line} — {repair.what}")
|
|
26
|
+
if repairs:
|
|
27
|
+
out.line("")
|
|
28
|
+
|
|
29
|
+
findings = check_repository(ctx.layout, ctx.store if ctx.store.exists() else None)
|
|
30
|
+
if not ctx.store.exists():
|
|
31
|
+
out.note("no graph — reference resolution was skipped. Run `edify graph build` for the full check.")
|
|
32
|
+
|
|
33
|
+
errors = [f for f in findings if f.level is Level.ERROR]
|
|
34
|
+
warnings = [f for f in findings if f.level is Level.WARN]
|
|
35
|
+
infos = [f for f in findings if f.level is Level.INFO]
|
|
36
|
+
|
|
37
|
+
out.data(
|
|
38
|
+
{
|
|
39
|
+
"findings": [f.as_dict() for f in findings],
|
|
40
|
+
"repairs": [r.__dict__ for r in repairs],
|
|
41
|
+
"errors": len(errors),
|
|
42
|
+
"warnings": len(warnings),
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
for finding in findings:
|
|
47
|
+
if finding.level is Level.ERROR:
|
|
48
|
+
out.line(_marked(ctx.out, finding.render(), "blocked"))
|
|
49
|
+
elif finding.level is Level.WARN:
|
|
50
|
+
out.line(_marked(ctx.out, finding.render(), "advisory"))
|
|
51
|
+
else:
|
|
52
|
+
out.line(finding.render())
|
|
53
|
+
|
|
54
|
+
if findings:
|
|
55
|
+
out.line("")
|
|
56
|
+
out.line(f"{len(errors)} errors · {len(warnings)} warnings · {len(infos)} notes")
|
|
57
|
+
if not findings:
|
|
58
|
+
out.line("nothing to report")
|
|
59
|
+
|
|
60
|
+
if ctx.args.exit_code and errors:
|
|
61
|
+
return 2
|
|
62
|
+
if ctx.args.exit_code and ctx.args.strict and warnings:
|
|
63
|
+
return 2
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _marked(out, text: str, kind: str) -> str:
|
|
68
|
+
"""The finding's first line carries the state mark and the colour; the hint
|
|
69
|
+
under it is muted, so it reads as the explanation and not as a second alarm."""
|
|
70
|
+
head, _, rest = text.partition("\n")
|
|
71
|
+
line = out.state(head, kind)
|
|
72
|
+
return line + ("\n" + out.c(rest, "dim") if rest else "")
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"""`edify doctor` — does the install work here.
|
|
2
|
+
|
|
3
|
+
Five checks and a green/amber/red line, where amber means "this works but degraded,
|
|
4
|
+
and here is which part". Not the twelve-probe apparatus of the previous design:
|
|
5
|
+
there are no hooks to probe, no runtime surface to pin, and no compiled targets to
|
|
6
|
+
hash.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import subprocess
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
|
|
14
|
+
from .. import __version__, assets, governance, skills as skills_index
|
|
15
|
+
from ..commands.init_cmd import _instruction_body
|
|
16
|
+
from ..context import Context
|
|
17
|
+
from ..detect import detect
|
|
18
|
+
from ..formats import skill as skill_format
|
|
19
|
+
from ..graph.langs import ctags
|
|
20
|
+
|
|
21
|
+
GREEN, AMBER, RED = "ok", "degraded", "broken"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class Check:
|
|
26
|
+
name: str
|
|
27
|
+
state: str
|
|
28
|
+
detail: str
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run(ctx: Context) -> int:
|
|
32
|
+
checks = [
|
|
33
|
+
_install(ctx),
|
|
34
|
+
_extractor(ctx),
|
|
35
|
+
_graph(ctx),
|
|
36
|
+
_index(ctx),
|
|
37
|
+
_governance(ctx),
|
|
38
|
+
_claude(ctx),
|
|
39
|
+
_license(ctx),
|
|
40
|
+
]
|
|
41
|
+
ctx.out.data([c.__dict__ for c in checks])
|
|
42
|
+
|
|
43
|
+
for check in checks:
|
|
44
|
+
kind = {GREEN: "pass", AMBER: "advisory", RED: "blocked"}[check.state]
|
|
45
|
+
ctx.out.line(f"{ctx.out.state(check.state, kind, 9)} {check.name.ljust(12)} {check.detail}")
|
|
46
|
+
|
|
47
|
+
ctx.out.line("")
|
|
48
|
+
if any(c.state == RED for c in checks):
|
|
49
|
+
ctx.out.line(ctx.out.c("red — something here does not work", "blocked"))
|
|
50
|
+
return 1
|
|
51
|
+
if any(c.state == AMBER for c in checks):
|
|
52
|
+
ctx.out.line(ctx.out.c("amber — this works, degraded, in the places named above", "advisory"))
|
|
53
|
+
return 0
|
|
54
|
+
ctx.out.line(ctx.out.c("green", "signal"))
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# ---------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _install(ctx: Context) -> Check:
|
|
62
|
+
if not ctx.layout.installed():
|
|
63
|
+
return Check("install", RED, f"no .edify/ under {ctx.layout.root} — run `edify init`")
|
|
64
|
+
try:
|
|
65
|
+
root = assets.asset_root()
|
|
66
|
+
except Exception as exc: # the methodology tree is missing from the install
|
|
67
|
+
return Check("install", RED, str(exc))
|
|
68
|
+
count = len(list((root / "skills").glob("*.md")))
|
|
69
|
+
return Check("install", GREEN, f"edify {__version__} · library of {count} skill entries")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _extractor(ctx: Context) -> Check:
|
|
73
|
+
external = ctags.available()
|
|
74
|
+
if external:
|
|
75
|
+
return Check("extractor", GREEN, f"{ctags.version()} · syntax-tree parsing")
|
|
76
|
+
return Check(
|
|
77
|
+
"extractor",
|
|
78
|
+
AMBER,
|
|
79
|
+
"built-in backend: Python is parsed exactly, everything else is scanned"
|
|
80
|
+
" — install Universal Ctags for parse-grade precision on the rest",
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _graph(ctx: Context) -> Check:
|
|
85
|
+
if not ctx.store.exists():
|
|
86
|
+
return Check("graph", RED, "no graph on disk — run `edify graph build`")
|
|
87
|
+
problems = ctx.store.verify_checksums()
|
|
88
|
+
if problems:
|
|
89
|
+
return Check("graph", RED, problems[0])
|
|
90
|
+
|
|
91
|
+
meta = ctx.store.meta
|
|
92
|
+
detail = f"{meta.get('nodes', '?')} nodes · {meta.get('edges', '?')} edges"
|
|
93
|
+
uncovered = meta.get("languages_uncovered", "-")
|
|
94
|
+
if uncovered not in ("-", ""):
|
|
95
|
+
detail += f" · no nodes for {uncovered}"
|
|
96
|
+
if meta.get("truncated_at"):
|
|
97
|
+
return Check("graph", AMBER, detail + f" · truncated at {meta['truncated_at']} (free plan)")
|
|
98
|
+
|
|
99
|
+
head = _head(ctx)
|
|
100
|
+
recorded = meta.get("commit", "-")
|
|
101
|
+
if head and recorded not in ("-", "") and head != recorded:
|
|
102
|
+
return Check("graph", AMBER, detail + " · built from a different commit — re-run `edify graph build`")
|
|
103
|
+
if uncovered not in ("-", ""):
|
|
104
|
+
return Check("graph", AMBER, detail)
|
|
105
|
+
return Check("graph", GREEN, detail)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _index(ctx: Context) -> Check:
|
|
109
|
+
entries = skill_format.load_all(ctx.layout.skills_dir, ctx.layout.root)
|
|
110
|
+
if not entries:
|
|
111
|
+
return Check("skills", RED, "no skills installed — run `edify init`")
|
|
112
|
+
if not ctx.layout.skills_index.is_file():
|
|
113
|
+
return Check("skills", RED, "no index.tsv — run `edify skills index`")
|
|
114
|
+
|
|
115
|
+
roles = {s.role for s in entries if s.role}
|
|
116
|
+
unresolvable = []
|
|
117
|
+
for role in sorted(roles):
|
|
118
|
+
try:
|
|
119
|
+
skills_index.resolve(ctx.layout, role, "3")
|
|
120
|
+
except Exception:
|
|
121
|
+
unresolvable.append(role)
|
|
122
|
+
if unresolvable:
|
|
123
|
+
return Check("skills", RED, "these roles do not resolve: " + ", ".join(unresolvable))
|
|
124
|
+
|
|
125
|
+
over = [s.rel for s in entries if s.over_budget]
|
|
126
|
+
if over:
|
|
127
|
+
return Check("skills", AMBER, f"{len(entries)} entries · over budget: {', '.join(over[:3])}")
|
|
128
|
+
return Check("skills", GREEN, f"{len(entries)} entries · every role resolves")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _governance(ctx: Context) -> Check:
|
|
132
|
+
"""Amber, never red. A ledger that disagrees with the disk is information."""
|
|
133
|
+
if not ctx.layout.governance.is_file():
|
|
134
|
+
return Check("governance", AMBER, "no ledger — run `edify governance rebuild`")
|
|
135
|
+
try:
|
|
136
|
+
recorded = governance.load(ctx.layout)
|
|
137
|
+
problems = governance.verify(ctx.layout)
|
|
138
|
+
except Exception as exc: # an unreadable ledger is a real fault, not a nuance
|
|
139
|
+
return Check("governance", RED, str(exc))
|
|
140
|
+
|
|
141
|
+
serious = [p for p in problems if p.serious]
|
|
142
|
+
if serious:
|
|
143
|
+
first = serious[0]
|
|
144
|
+
return Check(
|
|
145
|
+
"governance",
|
|
146
|
+
AMBER,
|
|
147
|
+
f"{len(recorded)} files recorded · {len(serious)} differ — {first.path} is {first.state}",
|
|
148
|
+
)
|
|
149
|
+
detail = f"{len(recorded)} files recorded · each with an origin, a licence, and a hash"
|
|
150
|
+
edited = len(problems) - len(serious)
|
|
151
|
+
if edited:
|
|
152
|
+
detail += f" · {edited} edited by this repository, which is allowed"
|
|
153
|
+
return Check("governance", GREEN, detail)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _claude(ctx: Context) -> Check:
|
|
157
|
+
"""Every instruction file on disk, not only Claude's.
|
|
158
|
+
|
|
159
|
+
A folder set up by `edify init new` has five or six of them and they all carry the
|
|
160
|
+
same block, so one of them going stale — a command renamed, the graph section
|
|
161
|
+
edited away — is the same failure whichever file it happened in. The check is named
|
|
162
|
+
for `CLAUDE.md` because that is the one every install has.
|
|
163
|
+
"""
|
|
164
|
+
present = [p for p in ctx.layout.instruction_files() if p.is_file()]
|
|
165
|
+
if not present:
|
|
166
|
+
return Check("CLAUDE.md", RED, "missing — run `edify init`")
|
|
167
|
+
|
|
168
|
+
expected = _instruction_body(ctx, detect(ctx.layout.root))
|
|
169
|
+
wanted = [line for line in expected.splitlines() if line.strip().startswith("/")]
|
|
170
|
+
for path in present:
|
|
171
|
+
rel = ctx.layout.rel(path)
|
|
172
|
+
text = path.read_text(encoding="utf-8", errors="replace")
|
|
173
|
+
if ".edify/graph/" not in text:
|
|
174
|
+
return Check("CLAUDE.md", AMBER, f"{rel} does not point at the graph, which is the one thing it is for")
|
|
175
|
+
if [line for line in wanted if line not in text]:
|
|
176
|
+
return Check("CLAUDE.md", AMBER, f"{rel} does not list every command `edify init` would write")
|
|
177
|
+
|
|
178
|
+
named = ", ".join(ctx.layout.rel(p) for p in present)
|
|
179
|
+
return Check("CLAUDE.md", GREEN, f"{len(present)} instruction file(s) · {named} · each points at the graph")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _license(ctx: Context) -> Check:
|
|
183
|
+
ent = ctx.entitlement
|
|
184
|
+
if ent.problem:
|
|
185
|
+
return Check("license", AMBER, f"running free — {ent.problem}")
|
|
186
|
+
if ent.paid and ent.license and ent.license.days_left in range(0, 15):
|
|
187
|
+
return Check("license", AMBER, f"{ent.plan} · expires in {ent.license.days_left} days")
|
|
188
|
+
|
|
189
|
+
if ent.paid:
|
|
190
|
+
return Check("license", GREEN, f"{ent.plan} · team edition licensed")
|
|
191
|
+
return Check("license", GREEN, "public edition · uncapped")
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _head(ctx: Context) -> str:
|
|
195
|
+
try:
|
|
196
|
+
out = subprocess.run(
|
|
197
|
+
["git", "rev-parse", "HEAD"],
|
|
198
|
+
cwd=str(ctx.layout.root),
|
|
199
|
+
capture_output=True,
|
|
200
|
+
text=True,
|
|
201
|
+
timeout=10,
|
|
202
|
+
check=False,
|
|
203
|
+
)
|
|
204
|
+
except (OSError, subprocess.SubprocessError):
|
|
205
|
+
return ""
|
|
206
|
+
return out.stdout.strip() if out.returncode == 0 else ""
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""`edify feedback` — say how this is going, to a file on this machine.
|
|
2
|
+
|
|
3
|
+
The command writes and prints. It never opens a socket: `edify upgrade` is the only
|
|
4
|
+
command in this CLI that does, and adding a second one for a satisfaction survey
|
|
5
|
+
would trade the product's central claim for a funnel metric.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .. import feedback
|
|
11
|
+
from ..context import Context
|
|
12
|
+
from ..errors import EdifyError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def new(ctx: Context) -> int:
|
|
16
|
+
message = (getattr(ctx.args, "message", None) or "").strip()
|
|
17
|
+
|
|
18
|
+
if message:
|
|
19
|
+
entry = feedback.Entry(answers={"doing": message})
|
|
20
|
+
else:
|
|
21
|
+
entry = feedback.interview(ctx.out)
|
|
22
|
+
if entry is None:
|
|
23
|
+
raise EdifyError(
|
|
24
|
+
"there is no terminal here to ask",
|
|
25
|
+
hint='use `edify feedback --message "..."`, which needs no prompt',
|
|
26
|
+
)
|
|
27
|
+
if not any(v.strip() for v in entry.answers.values()):
|
|
28
|
+
ctx.out.line("nothing written — every answer was empty")
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
path = feedback.write(entry)
|
|
32
|
+
ctx.out.data({"path": str(path), "sent": False, "how": feedback.how_to_send(path)})
|
|
33
|
+
ctx.out.line(f"written {path}")
|
|
34
|
+
ctx.out.line("")
|
|
35
|
+
ctx.out.line("Nothing left this machine. When you want us to read it:")
|
|
36
|
+
for line in feedback.how_to_send(path):
|
|
37
|
+
ctx.out.line(f" {line}")
|
|
38
|
+
return 0
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def list_(ctx: Context) -> int:
|
|
42
|
+
entries = feedback.existing()
|
|
43
|
+
ctx.out.data([str(p) for p in entries])
|
|
44
|
+
if not entries:
|
|
45
|
+
ctx.out.line("nothing written yet — `edify feedback` asks four questions")
|
|
46
|
+
return 0
|
|
47
|
+
for path in entries:
|
|
48
|
+
first = _subject(path)
|
|
49
|
+
ctx.out.line(f"{path.stem} {first}")
|
|
50
|
+
ctx.out.line("")
|
|
51
|
+
ctx.out.line(f"{len(entries)} in {feedback.directory()} · none of it has been sent anywhere")
|
|
52
|
+
return 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def show(ctx: Context) -> int:
|
|
56
|
+
entries = feedback.existing()
|
|
57
|
+
if not entries:
|
|
58
|
+
ctx.out.line("nothing written yet")
|
|
59
|
+
return 0
|
|
60
|
+
wanted = getattr(ctx.args, "which", None)
|
|
61
|
+
path = entries[-1]
|
|
62
|
+
if wanted:
|
|
63
|
+
matches = [p for p in entries if p.stem == wanted or p.stem.lstrip("0") == wanted.lstrip("0")]
|
|
64
|
+
if not matches:
|
|
65
|
+
raise EdifyError(f"no feedback entry `{wanted}`", hint="`edify feedback list` shows them")
|
|
66
|
+
path = matches[0]
|
|
67
|
+
ctx.out.data({"path": str(path), "body": path.read_text(encoding="utf-8")})
|
|
68
|
+
ctx.out.line(path.read_text(encoding="utf-8").rstrip())
|
|
69
|
+
return 0
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def off(ctx: Context) -> int:
|
|
73
|
+
feedback.set_enabled(False)
|
|
74
|
+
ctx.out.line("the feedback invitation will not appear again")
|
|
75
|
+
ctx.out.line(f"turn it back on with `edify feedback on` · state lives in {feedback.state_path()}")
|
|
76
|
+
return 0
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def on(ctx: Context) -> int:
|
|
80
|
+
feedback.set_enabled(True)
|
|
81
|
+
ctx.out.line("the feedback invitation is on — at most one line, once per released version")
|
|
82
|
+
return 0
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _subject(path) -> str:
|
|
86
|
+
for line in path.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
87
|
+
stripped = line.strip()
|
|
88
|
+
if stripped and not stripped.startswith(("#", "-")):
|
|
89
|
+
return stripped[:70]
|
|
90
|
+
return "(no answers)"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""`edify governance` — what EDIFY put here, and whether it is still what it put.
|
|
2
|
+
|
|
3
|
+
Three subcommands and no enforcement. `verify` prints and, with `--exit-code`,
|
|
4
|
+
returns non-zero so a customer who needs a hard block owns one in their own CI. The
|
|
5
|
+
same honest scope `edify check` has, for the same reason.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .. import governance
|
|
11
|
+
from ..context import Context
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def list_(ctx: Context) -> int:
|
|
15
|
+
ctx.layout.require_installed()
|
|
16
|
+
records = governance.load(ctx.layout) if ctx.layout.governance.is_file() else governance.scan(ctx.layout)
|
|
17
|
+
|
|
18
|
+
ctx.out.data([r.as_dict() for r in records])
|
|
19
|
+
ctx.out.table(
|
|
20
|
+
["path", "kind", "origin", "provenance", "license", "source"],
|
|
21
|
+
[[r.path, r.kind, r.origin, r.provenance, r.license, r.source] for r in records],
|
|
22
|
+
)
|
|
23
|
+
counts = governance.summary(records)
|
|
24
|
+
ctx.out.line("")
|
|
25
|
+
ctx.out.line(
|
|
26
|
+
f"{len(records)} files · " + " · ".join(f"{n} {origin}" for origin, n in sorted(counts.items()))
|
|
27
|
+
)
|
|
28
|
+
return 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def verify(ctx: Context) -> int:
|
|
32
|
+
ctx.layout.require_installed()
|
|
33
|
+
problems = governance.verify(ctx.layout)
|
|
34
|
+
|
|
35
|
+
ctx.out.data(
|
|
36
|
+
{
|
|
37
|
+
"problems": [p.as_dict() for p in problems],
|
|
38
|
+
"serious": sum(1 for p in problems if p.serious),
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
for problem in problems:
|
|
43
|
+
# `edited` and `unknown-origin` are not serious, so both print dim.
|
|
44
|
+
kind = "blocked" if problem.state == "missing" else "advisory" if problem.serious else "uncovered"
|
|
45
|
+
ctx.out.line(f"{ctx.out.state(problem.state, kind, 10)} {problem.path} {problem.detail}")
|
|
46
|
+
|
|
47
|
+
serious = [p for p in problems if p.serious]
|
|
48
|
+
if not problems:
|
|
49
|
+
ctx.out.line("every governed file is what the ledger says it is")
|
|
50
|
+
else:
|
|
51
|
+
ctx.out.line("")
|
|
52
|
+
ctx.out.line(f"{len(serious)} to look at · {len(problems) - len(serious)} edited by this repository")
|
|
53
|
+
|
|
54
|
+
if getattr(ctx.args, "exit_code", False) and serious:
|
|
55
|
+
return 2
|
|
56
|
+
return 0
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def rebuild(ctx: Context) -> int:
|
|
60
|
+
"""Re-baseline. Run it after a deliberate change, so the next `verify` is quiet."""
|
|
61
|
+
ctx.layout.require_installed()
|
|
62
|
+
records = governance.rebuild(ctx.layout)
|
|
63
|
+
ctx.out.data({"files": len(records), "ledger": ctx.layout.rel(ctx.layout.governance)})
|
|
64
|
+
ctx.out.line(f"{len(records)} files recorded in {ctx.layout.rel(ctx.layout.governance)}")
|
|
65
|
+
return 0
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""`edify graph` — build the map and ask it questions.
|
|
2
|
+
|
|
3
|
+
Six subcommands, all mechanical, all sub-second on a laptop. These are the commands
|
|
4
|
+
`CLAUDE.md` points at, and the only part of the CLI a model invokes routinely.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from .. import anim
|
|
10
|
+
from ..context import Context
|
|
11
|
+
from ..graph import extract, queries
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def build(ctx: Context) -> int:
|
|
15
|
+
ctx.layout.require_installed()
|
|
16
|
+
with anim.spinner(ctx.out, "reading every file, building the map"):
|
|
17
|
+
result = extract.build(ctx.layout, backend=ctx.args.extractor)
|
|
18
|
+
|
|
19
|
+
ctx.out.data(result.as_dict())
|
|
20
|
+
ctx.out.line(
|
|
21
|
+
f"{result.nodes} nodes · {result.edges} edges · {result.files} files"
|
|
22
|
+
f" · {result.backend}"
|
|
23
|
+
)
|
|
24
|
+
covered = ", ".join(f"{k} ({v})" for k, v in sorted(result.languages.items()))
|
|
25
|
+
if covered:
|
|
26
|
+
ctx.out.line(f"covered: {covered}")
|
|
27
|
+
if result.uncovered:
|
|
28
|
+
ctx.out.line(
|
|
29
|
+
"not covered: "
|
|
30
|
+
+ ", ".join(f"{k} ({v} files)" for k, v in sorted(result.uncovered.items()))
|
|
31
|
+
)
|
|
32
|
+
ctx.out.note("a language the extractor does not handle has no nodes. That gap is stated, not filled.")
|
|
33
|
+
return 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def update(ctx: Context) -> int:
|
|
37
|
+
ctx.layout.require_installed()
|
|
38
|
+
ctx.store.require()
|
|
39
|
+
with anim.spinner(ctx.out, f"re-extracting {len(ctx.args.dirs)} director(ies)"):
|
|
40
|
+
result = extract.build(
|
|
41
|
+
ctx.layout,
|
|
42
|
+
backend=ctx.args.extractor,
|
|
43
|
+
subdirs=ctx.args.dirs,
|
|
44
|
+
)
|
|
45
|
+
ctx.out.data(result.as_dict())
|
|
46
|
+
ctx.out.line(f"{result.nodes} nodes · {result.edges} edges (re-extracted {len(ctx.args.dirs)} directories)")
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def where(ctx: Context) -> int:
|
|
51
|
+
ctx.store.require()
|
|
52
|
+
hits = queries.where(ctx.store, ctx.args.name, kind=ctx.args.kind)
|
|
53
|
+
ctx.out.data([_node(n) for n in hits])
|
|
54
|
+
if not hits:
|
|
55
|
+
ctx.out.line(f"nothing named `{ctx.args.name}` in the graph")
|
|
56
|
+
return 1
|
|
57
|
+
for node in hits:
|
|
58
|
+
ctx.out.line(f"{node.ref}\t{node.kind}\t{node.name}")
|
|
59
|
+
return 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def dependents(ctx: Context) -> int:
|
|
63
|
+
ctx.store.require()
|
|
64
|
+
hits = queries.dependents(ctx.store, ctx.args.symbol, depth=ctx.args.depth)
|
|
65
|
+
ctx.out.data([_node(n) for n in hits])
|
|
66
|
+
if not hits:
|
|
67
|
+
ctx.out.line(f"nothing in this repository depends on `{ctx.args.symbol}`")
|
|
68
|
+
return 0
|
|
69
|
+
for node in hits:
|
|
70
|
+
ctx.out.line(f"{node.ref}\t{node.kind}\t{node.name}")
|
|
71
|
+
return 0
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def references(ctx: Context) -> int:
|
|
75
|
+
ctx.store.require()
|
|
76
|
+
hits = queries.references(ctx.store, ctx.args.name)
|
|
77
|
+
ctx.out.data([_node(n) for n in hits])
|
|
78
|
+
for node in hits:
|
|
79
|
+
ctx.out.line(f"{node.ref}\t{node.kind}\t{node.name}")
|
|
80
|
+
if not hits:
|
|
81
|
+
ctx.out.line(f"no references to `{ctx.args.name}` in this repository")
|
|
82
|
+
return 0
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def defines(ctx: Context) -> int:
|
|
86
|
+
ctx.store.require()
|
|
87
|
+
hits = queries.defines(ctx.store, ctx.args.file)
|
|
88
|
+
ctx.out.data([_node(n) for n in hits])
|
|
89
|
+
if not hits:
|
|
90
|
+
ctx.out.line(f"`{ctx.args.file}` defines nothing the graph indexes")
|
|
91
|
+
return 0
|
|
92
|
+
for node in hits:
|
|
93
|
+
ctx.out.line(f"{node.line}\t{node.kind}\t{node.name}")
|
|
94
|
+
return 0
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def overlap(ctx: Context) -> int:
|
|
98
|
+
ctx.store.require()
|
|
99
|
+
a = _split(ctx.args.a)
|
|
100
|
+
b = _split(ctx.args.b)
|
|
101
|
+
result = queries.overlap(ctx.store, a, b, depth=ctx.args.depth)
|
|
102
|
+
ctx.out.data(
|
|
103
|
+
{
|
|
104
|
+
"safe": result.safe,
|
|
105
|
+
"overlapping": sorted(result.overlapping),
|
|
106
|
+
"a_radius": sorted(result.a_radius),
|
|
107
|
+
"b_radius": sorted(result.b_radius),
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
if result.safe:
|
|
111
|
+
ctx.out.line("disjoint — these may run in parallel")
|
|
112
|
+
return 0
|
|
113
|
+
ctx.out.line("overlapping:")
|
|
114
|
+
for path in sorted(result.overlapping):
|
|
115
|
+
ctx.out.line(f" {path}")
|
|
116
|
+
return 1
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def stat(ctx: Context) -> int:
|
|
120
|
+
ctx.store.require()
|
|
121
|
+
meta = ctx.store.meta
|
|
122
|
+
kinds: dict[str, int] = {}
|
|
123
|
+
for node in ctx.store.nodes:
|
|
124
|
+
kinds[node.kind] = kinds.get(node.kind, 0) + 1
|
|
125
|
+
relations: dict[str, int] = {}
|
|
126
|
+
for edge in ctx.store.edges:
|
|
127
|
+
relations[edge.relation] = relations.get(edge.relation, 0) + 1
|
|
128
|
+
|
|
129
|
+
ctx.out.data({"meta": meta, "kinds": kinds, "relations": relations})
|
|
130
|
+
ctx.out.table(["kind", "count"], [[k, str(v)] for k, v in sorted(kinds.items())])
|
|
131
|
+
ctx.out.line("")
|
|
132
|
+
ctx.out.table(["relation", "count"], [[k, str(v)] for k, v in sorted(relations.items())])
|
|
133
|
+
ctx.out.line("")
|
|
134
|
+
for key in ("commit", "extractor", "extractor_version", "languages_covered", "languages_uncovered"):
|
|
135
|
+
if key in meta:
|
|
136
|
+
ctx.out.line(f"{key}: {meta[key]}")
|
|
137
|
+
problems = ctx.store.verify_checksums()
|
|
138
|
+
for problem in problems:
|
|
139
|
+
ctx.out.warn(problem)
|
|
140
|
+
return 0
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _split(value: str) -> list[str]:
|
|
144
|
+
return [p.strip() for p in value.replace(",", " ").split() if p.strip()]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _node(node) -> dict[str, object]:
|
|
148
|
+
return {
|
|
149
|
+
"id": node.id,
|
|
150
|
+
"kind": node.kind,
|
|
151
|
+
"file": node.file,
|
|
152
|
+
"line": node.line,
|
|
153
|
+
"name": node.name,
|
|
154
|
+
"ref": node.ref,
|
|
155
|
+
"fingerprint": node.fingerprint,
|
|
156
|
+
}
|