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.
Files changed (102) hide show
  1. edify/__init__.py +19 -0
  2. edify/__main__.py +6 -0
  3. edify/_toml.py +286 -0
  4. edify/agents.py +261 -0
  5. edify/anim.py +499 -0
  6. edify/assets/commands/build.md +64 -0
  7. edify/assets/commands/plan.md +68 -0
  8. edify/assets/commands/spec.md +63 -0
  9. edify/assets/commands/tasks.md +65 -0
  10. edify/assets/commands/verify.md +67 -0
  11. edify/assets/formats/plan.example.md +455 -0
  12. edify/assets/formats/plan.format.md +128 -0
  13. edify/assets/formats/spec.example.md +483 -0
  14. edify/assets/formats/spec.format.md +116 -0
  15. edify/assets/formats/tasks.example.md +712 -0
  16. edify/assets/formats/tasks.format.md +199 -0
  17. edify/assets/harvest/harvest.md +91 -0
  18. edify/assets/harvest/sources.md +295 -0
  19. edify/assets/harvest/vocab.md +52 -0
  20. edify/assets/manifest.md +30 -0
  21. edify/assets/mcp/default-registry.md +66 -0
  22. edify/assets/skills/adversary.md +61 -0
  23. edify/assets/skills/debugger.md +64 -0
  24. edify/assets/skills/implementer-general.md +53 -0
  25. edify/assets/skills/implementer-go.md +63 -0
  26. edify/assets/skills/implementer-node.md +61 -0
  27. edify/assets/skills/implementer-postgres.md +63 -0
  28. edify/assets/skills/implementer-python.md +65 -0
  29. edify/assets/skills/implementer-react.md +65 -0
  30. edify/assets/skills/planner.md +58 -0
  31. edify/assets/skills/test-writer-node.md +64 -0
  32. edify/assets/skills/test-writer-python.md +60 -0
  33. edify/assets/skills/verifier.md +67 -0
  34. edify/assets/templates/CLAUDE.md +18 -0
  35. edify/assets.py +77 -0
  36. edify/cli.py +681 -0
  37. edify/commands/__init__.py +1 -0
  38. edify/commands/check_cmd.py +72 -0
  39. edify/commands/doctor_cmd.py +206 -0
  40. edify/commands/feedback_cmd.py +90 -0
  41. edify/commands/governance_cmd.py +65 -0
  42. edify/commands/graph_cmd.py +156 -0
  43. edify/commands/harvest_cmd.py +538 -0
  44. edify/commands/init_cmd.py +333 -0
  45. edify/commands/init_new_cmd.py +151 -0
  46. edify/commands/license_cmd.py +80 -0
  47. edify/commands/mcp_cmd.py +159 -0
  48. edify/commands/self_cmd.py +185 -0
  49. edify/commands/setup_cmd.py +79 -0
  50. edify/commands/skills_cmd.py +177 -0
  51. edify/commands/upgrade_cmd.py +178 -0
  52. edify/context.py +57 -0
  53. edify/conventions.py +275 -0
  54. edify/detect.py +313 -0
  55. edify/distribution.py +40 -0
  56. edify/errors.py +66 -0
  57. edify/feedback.py +207 -0
  58. edify/formats/__init__.py +11 -0
  59. edify/formats/check.py +573 -0
  60. edify/formats/document.py +238 -0
  61. edify/formats/finding.py +50 -0
  62. edify/formats/fix.py +114 -0
  63. edify/formats/mcp.py +126 -0
  64. edify/formats/plan.py +151 -0
  65. edify/formats/skill.py +139 -0
  66. edify/formats/spec.py +164 -0
  67. edify/formats/tasks.py +321 -0
  68. edify/governance.py +316 -0
  69. edify/graph/__init__.py +11 -0
  70. edify/graph/extract.py +351 -0
  71. edify/graph/ignore.py +107 -0
  72. edify/graph/langs/__init__.py +93 -0
  73. edify/graph/langs/ctags.py +145 -0
  74. edify/graph/langs/markdown.py +41 -0
  75. edify/graph/langs/patterns.py +361 -0
  76. edify/graph/langs/python_ast.py +154 -0
  77. edify/graph/langs/sqlish.py +86 -0
  78. edify/graph/model.py +102 -0
  79. edify/graph/queries.py +211 -0
  80. edify/graph/store.py +157 -0
  81. edify/harvest/__init__.py +28 -0
  82. edify/harvest/ledger.py +191 -0
  83. edify/harvest/screen.py +236 -0
  84. edify/harvest/sources.py +298 -0
  85. edify/host.py +345 -0
  86. edify/interview.py +354 -0
  87. edify/library.py +176 -0
  88. edify/licensing/__init__.py +30 -0
  89. edify/licensing/ed25519.py +154 -0
  90. edify/licensing/projects.py +223 -0
  91. edify/licensing/tier.py +172 -0
  92. edify/licensing/token.py +149 -0
  93. edify/paths.py +282 -0
  94. edify/selfinstall.py +244 -0
  95. edify/skills.py +108 -0
  96. edify/tsv.py +109 -0
  97. edify/ui.py +334 -0
  98. edify_agents_cli-0.2.0.dist-info/METADATA +408 -0
  99. edify_agents_cli-0.2.0.dist-info/RECORD +102 -0
  100. edify_agents_cli-0.2.0.dist-info/WHEEL +4 -0
  101. edify_agents_cli-0.2.0.dist-info/entry_points.txt +2 -0
  102. edify_agents_cli-0.2.0.dist-info/licenses/LICENSE +21 -0
edify/cli.py ADDED
@@ -0,0 +1,681 @@
1
+ """The `edify` binary.
2
+
3
+ A pure function over files. Every command reads files and writes files; none holds
4
+ state, opens a socket, or calls out to a network except `edify upgrade`, which
5
+ pulls a skill library, and `edify self update`, which builds a wheel and may fetch
6
+ its build backend. Both say so in their own docstrings, and both have an offline
7
+ mode that fails cleanly rather than reaching out.
8
+
9
+ Deterministic where it decides. `edify` may be invoked by a model; no `edify`
10
+ command lets a model decide what is installed, indexed, or resolved.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import argparse
16
+ import sys
17
+
18
+ from . import __version__
19
+ from . import agents as agent_table
20
+ from .context import build_context
21
+ from .errors import EdifyError
22
+
23
+ USAGE = """edify — three documents and a map
24
+
25
+ lifecycle
26
+ edify init new [PATH] a folder from zero, for every agent — asks first
27
+ edify setup [PATH] [--fresh] install everything into one folder, root pinned there
28
+ edify init [--yes] [--skills ...] detect · extract · choose skills · write CLAUDE.md
29
+ edify check [--fix] [--exit-code] format check over specs, tasks, and skill files
30
+ edify upgrade pull a newer skill library and re-index
31
+
32
+ graph
33
+ edify graph build full extraction
34
+ edify graph update <dir>... one or more directories — runs after each phase
35
+ edify graph where <name> file:line and signature
36
+ edify graph dependents <symbol> everything that breaks if this changes
37
+ edify graph references <name> who calls or imports this
38
+ edify graph defines <file> what this file exports
39
+ edify graph overlap <a> <b> do these file sets intersect, dependents included
40
+ edify graph stat what is in the map
41
+
42
+ skills
43
+ edify skills list what is installed, with provenance and license
44
+ edify skills resolve <role> <phase> [tech]
45
+ edify skills index re-sort the lookup table
46
+ edify skills add <path> install one entry
47
+ edify skills sync mirror the library into .claude/ — skills/<name>/SKILL.md,
48
+ agents/<name>.md by `kind`
49
+
50
+ harvest (EDIFY's own repository only)
51
+ edify harvest pick [--source N] which source to draw from, and what not to gather again
52
+ edify harvest stage --url ... --name ... --content PATH
53
+ edify harvest screen [ID...] licence · duplicate · injection, fail-closed
54
+ edify harvest propose ID --file PATH --case "..."
55
+ edify harvest admit ID --by NAME the human door — never unattended
56
+ edify harvest reject ID --reason "..."
57
+ edify harvest status the ledger, and the yield rows for sources.md
58
+
59
+ governance
60
+ edify governance list every file edify installed, and where it came from
61
+ edify governance verify the ledger against what is on disk
62
+ edify governance rebuild re-baseline after a deliberate change
63
+
64
+ servers
65
+ edify mcp list the registry, with what each entry is scoped to
66
+ edify mcp check each server responds and its version matches the pin
67
+ edify mcp for <role> <phase> what a spawn in this position would load
68
+
69
+ ship
70
+ edify doctor does the install work here
71
+ edify self where which edify is this, and where did it come from
72
+ edify self update [--from PATH] put an edited checkout behind the `edify` binary
73
+ edify license status|activate|deactivate
74
+ edify feedback [list|show|off|on] four questions, written to a file on this machine
75
+ edify version
76
+ """
77
+
78
+
79
+ # Read from the table rather than typed out, so help text and behaviour cannot drift.
80
+ # `agents` is pure data — no graph, no filesystem — so importing it here costs nothing.
81
+ _AGENT_IDS = ", ".join(agent_table.ALL_IDS)
82
+
83
+
84
+ def build_parser() -> argparse.ArgumentParser:
85
+ parser = argparse.ArgumentParser(
86
+ prog="edify",
87
+ description="A harness that makes an AI coding agent work reliably on large codebases.",
88
+ add_help=True,
89
+ )
90
+ parser.add_argument("--repo", metavar="PATH", help="the repository root (default: search upward from cwd)")
91
+ parser.add_argument("--json", action="store_true", help="machine-readable output on stdout")
92
+ parser.add_argument("--no-color", action="store_true", help="never emit ANSI colour")
93
+ parser.add_argument("--quiet", "-q", action="store_true", help="answers only, no notes")
94
+ parser.add_argument("--no-anim", action="store_true",
95
+ help="no banner and no animation; static lines instead")
96
+ parser.add_argument("--version", action="version", version=f"edify {__version__}")
97
+
98
+ sub = parser.add_subparsers(dest="command")
99
+
100
+ # -- lifecycle -------------------------------------------------------
101
+ # `setup` takes the same flags as `init` because it *is* `init` with the root
102
+ # pinned to one folder and force on. Anything accepted by one is accepted by both.
103
+ p_setup = sub.add_parser("setup", help="install everything into one folder, root pinned there")
104
+ p_setup.add_argument("path", nargs="?", default=".", help="the folder to install into (created if missing)")
105
+ p_setup.add_argument("--fresh", action="store_true",
106
+ help="remove edify's own files first — .edify/, its host pointers, its CLAUDE.md block")
107
+ p_setup.add_argument("--stack", default="auto", help="`auto`, or explicit tech ids to add to what was detected")
108
+ p_setup.add_argument("--no-graph", action="store_true", help="skip extraction (run `edify graph build` later)")
109
+ p_setup.add_argument("--extractor", default="builtin", choices=("builtin", "ctags"))
110
+ p_setup.add_argument("--host", default="claude", choices=("claude", "none"),
111
+ help="write the host runtime's command and skill pointers")
112
+ p_setup.add_argument("--agents", default="", metavar="all|none|IDS",
113
+ help=f"which agent runtimes to write files for ({_AGENT_IDS}); default: --host")
114
+ p_setup.add_argument("--skills", default="all", metavar="ask|all|none|NAMES",
115
+ help="which library entries to install (default: all — setup means everything)")
116
+ p_setup.add_argument("--yes", "-y", action="store_true", help="take every default answer, ask nothing")
117
+ p_setup.add_argument("--force", action="store_true", help="implied — setup always installs over its own files")
118
+ p_setup.set_defaults(func=_setup)
119
+
120
+ p_init = sub.add_parser("init", help="install the harness into this repository")
121
+ p_init.add_argument("--stack", default="auto", help="`auto`, or explicit tech ids to add to what was detected")
122
+ p_init.add_argument("--force", action="store_true", help="overwrite files init would otherwise keep")
123
+ p_init.add_argument("--no-graph", action="store_true", help="skip extraction (run `edify graph build` later)")
124
+ p_init.add_argument("--extractor", default="builtin", choices=("builtin", "ctags"))
125
+ p_init.add_argument("--host", default="claude", choices=("claude", "none"),
126
+ help="write thin command pointers for a host runtime")
127
+ p_init.add_argument("--skills", default="auto", metavar="ask|all|none|NAMES",
128
+ help="which library entries to install (default: ask when there is a terminal)")
129
+ p_init.add_argument("--yes", "-y", action="store_true",
130
+ help="take every default answer — install the whole matched set, ask nothing")
131
+ p_init.add_argument("--agents", default="", metavar="all|none|IDS",
132
+ help=f"which agent runtimes to write files for ({_AGENT_IDS}); default: --host")
133
+ p_init.set_defaults(func=_init)
134
+
135
+ # `init new` — the from-nothing install. It is a subcommand of `init` rather than
136
+ # a command of its own because it is the same install: one root, every runtime,
137
+ # and the questions detection cannot answer.
138
+ init_sub = p_init.add_subparsers(dest="init_command")
139
+ p_new = init_sub.add_parser(
140
+ "new", help="set a folder up from zero, for every agent, after asking what it is for"
141
+ )
142
+ p_new.add_argument("path", nargs="?", default=".", help="the folder to install into (created if missing)")
143
+ p_new.add_argument("--agents", default="all", metavar="all|none|IDS",
144
+ help=f"which agent runtimes to write files for ({_AGENT_IDS})")
145
+ p_new.add_argument("--stack", default="auto", help="`auto`, or explicit tech ids to add to what was detected")
146
+ p_new.add_argument("--skills", default="all", metavar="ask|all|none|NAMES",
147
+ help="which library entries to install (default: all — `new` means everything)")
148
+ p_new.add_argument("--no-interview", action="store_true",
149
+ help="install without asking anything; keeps an existing .edify/profile.md")
150
+ p_new.add_argument("--keep", action="store_true",
151
+ help="do not clear edify's own files first — reinstall over what is there")
152
+ p_new.add_argument("--no-graph", action="store_true", help="skip extraction (run `edify graph build` later)")
153
+ p_new.add_argument("--extractor", default="builtin", choices=("builtin", "ctags"))
154
+ p_new.add_argument("--host", default="claude", choices=("claude", "none"),
155
+ help="kept for symmetry with `init`; `--agents` is what decides here")
156
+ p_new.add_argument("--yes", "-y", action="store_true", help="take every default answer, ask nothing")
157
+ p_new.add_argument("--force", action="store_true", help="implied — `new` always installs over its own files")
158
+ p_new.set_defaults(func=_init_new)
159
+
160
+ p_check = sub.add_parser("check", help="report what is wrong with the documents")
161
+ p_check.add_argument("--fix", action="store_true", help="apply the mechanical repairs only")
162
+ p_check.add_argument("--exit-code", action="store_true", help="exit non-zero when there are errors (for CI)")
163
+ p_check.add_argument("--strict", action="store_true", help="with --exit-code, treat warnings as errors")
164
+ p_check.set_defaults(func=_check)
165
+
166
+ p_upgrade = sub.add_parser("upgrade", help="pull a newer skill library and re-index")
167
+ p_upgrade.add_argument("--channel", default="stable")
168
+ p_upgrade.add_argument("--archive", metavar="PATH", help="install from a local archive instead of the network")
169
+ p_upgrade.add_argument("--check", action="store_true", help="report what is available and change nothing")
170
+ p_upgrade.add_argument("--skills", default="auto", metavar="ask|all|none|NAMES",
171
+ help="which entries in the archive to install (default: ask when there is a terminal)")
172
+ p_upgrade.add_argument("--yes", "-y", action="store_true", help="install every valid entry, ask nothing")
173
+ p_upgrade.set_defaults(func=_upgrade)
174
+
175
+ # -- graph -----------------------------------------------------------
176
+ p_graph = sub.add_parser("graph", help="build and query the map")
177
+ graph_sub = p_graph.add_subparsers(dest="graph_command")
178
+
179
+ g_build = graph_sub.add_parser("build", help="full extraction")
180
+ g_build.add_argument("--extractor", default="builtin", choices=("builtin", "ctags"))
181
+ g_build.set_defaults(func=_graph_build)
182
+
183
+ g_update = graph_sub.add_parser("update", help="re-extract one or more directories")
184
+ g_update.add_argument("dirs", nargs="+")
185
+ g_update.add_argument("--extractor", default="builtin", choices=("builtin", "ctags"))
186
+ g_update.set_defaults(func=_graph_update)
187
+
188
+ g_where = graph_sub.add_parser("where", help="file:line and kind for a name")
189
+ g_where.add_argument("name")
190
+ g_where.add_argument("--kind", choices=("file", "module", "symbol", "route", "table", "package", "doc-section"))
191
+ g_where.set_defaults(func=_graph_where)
192
+
193
+ g_dep = graph_sub.add_parser("dependents", help="everything that breaks if this changes")
194
+ g_dep.add_argument("symbol")
195
+ g_dep.add_argument("--depth", type=int, default=1)
196
+ g_dep.set_defaults(func=_graph_dependents)
197
+
198
+ g_ref = graph_sub.add_parser("references", help="who calls or imports this")
199
+ g_ref.add_argument("name")
200
+ g_ref.set_defaults(func=_graph_references)
201
+
202
+ g_def = graph_sub.add_parser("defines", help="what this file exports")
203
+ g_def.add_argument("file")
204
+ g_def.set_defaults(func=_graph_defines)
205
+
206
+ g_ov = graph_sub.add_parser("overlap", help="do these two file sets intersect")
207
+ g_ov.add_argument("a")
208
+ g_ov.add_argument("b")
209
+ g_ov.add_argument("--depth", type=int, default=1)
210
+ g_ov.set_defaults(func=_graph_overlap)
211
+
212
+ g_stat = graph_sub.add_parser("stat", help="what is in the map")
213
+ g_stat.set_defaults(func=_graph_stat)
214
+
215
+ # -- skills ----------------------------------------------------------
216
+ p_skills = sub.add_parser("skills", help="the installed library and the spawn lookup")
217
+ skills_sub = p_skills.add_subparsers(dest="skills_command")
218
+
219
+ s_list = skills_sub.add_parser("list", help="what is installed, with provenance and licence")
220
+ s_list.set_defaults(func=_skills_list)
221
+
222
+ s_resolve = skills_sub.add_parser("resolve", help="the one file a spawn in this position loads")
223
+ s_resolve.add_argument("role")
224
+ s_resolve.add_argument("phase")
225
+ s_resolve.add_argument("tech", nargs="?")
226
+ s_resolve.set_defaults(func=_skills_resolve)
227
+
228
+ s_index = skills_sub.add_parser("index", help="re-sort the lookup table")
229
+ s_index.set_defaults(func=_skills_index)
230
+
231
+ s_add = skills_sub.add_parser("add", help="install one entry from a local file")
232
+ s_add.add_argument("path")
233
+ s_add.set_defaults(func=_skills_add)
234
+
235
+ s_sync = skills_sub.add_parser("sync", help="mirror the library into each runtime's skill directory")
236
+ s_sync.add_argument("--host", default="claude", choices=("claude", "none"))
237
+ s_sync.add_argument("--agents", default="", metavar="all|none|IDS",
238
+ help=f"which agent runtimes to mirror into ({_AGENT_IDS}); default: the ones set up here")
239
+ s_sync.set_defaults(func=_skills_sync)
240
+
241
+ # -- harvest ---------------------------------------------------------
242
+ # Four steps that run unattended and one that never does.
243
+ p_harvest = sub.add_parser("harvest", help="turn a public capability into a library entry")
244
+ harvest_sub = p_harvest.add_subparsers(dest="harvest_command")
245
+
246
+ h_pick = harvest_sub.add_parser("pick", help="which source to draw from, and what not to gather again")
247
+ h_pick.add_argument("--count", type=int, default=5, help="how many new candidates this run is aiming for")
248
+ h_pick.add_argument("--source", default="", metavar="NAME",
249
+ help="draw from this row instead of the best-scoring one")
250
+ h_pick.add_argument("--all", action="store_true", help="print every row with its score, not just the choice")
251
+ h_pick.set_defaults(func=_harvest_pick)
252
+
253
+ h_stage = harvest_sub.add_parser("stage", help="record one gathered artifact, or refuse a repeat")
254
+ h_stage.add_argument("--url", required=True, help="where it came from")
255
+ h_stage.add_argument("--name", required=True, help="the entry name it would take, [a-z0-9-]+")
256
+ h_stage.add_argument("--content", required=True, metavar="PATH", help="the raw bytes, already on disk")
257
+ h_stage.add_argument("--commit", default="", help="the commit hash it was read at")
258
+ h_stage.add_argument("--license", default="", help="the licence as found, or nothing — which means NONE-FOUND")
259
+ h_stage.add_argument("--source", default="", help="which row of sources.md this came from")
260
+ h_stage.set_defaults(func=_harvest_stage)
261
+
262
+ h_screen = harvest_sub.add_parser("screen", help="licence, duplicate, injection — mechanical and fail-closed")
263
+ h_screen.add_argument("ids", nargs="*", help="candidates to screen (default: everything staged)")
264
+ h_screen.set_defaults(func=_harvest_screen)
265
+
266
+ h_propose = harvest_sub.add_parser("propose", help="present a rewrite for admission")
267
+ h_propose.add_argument("id")
268
+ h_propose.add_argument("--file", required=True, metavar="PATH", help="the rewritten entry")
269
+ h_propose.add_argument("--case", required=True, help="one line: the scenario nothing in the library serves")
270
+ h_propose.set_defaults(func=_harvest_propose)
271
+
272
+ h_admit = harvest_sub.add_parser("admit", help="a person read it and says yes")
273
+ h_admit.add_argument("id")
274
+ h_admit.add_argument("--by", required=True, help="who read it")
275
+ h_admit.set_defaults(func=_harvest_admit)
276
+
277
+ h_reject = harvest_sub.add_parser("reject", help="a person read it and says no")
278
+ h_reject.add_argument("id")
279
+ h_reject.add_argument("--reason", required=True, help="why — this is what makes the next run cheap")
280
+ h_reject.add_argument("--by", default="", help="who read it")
281
+ h_reject.set_defaults(func=_harvest_reject)
282
+
283
+ h_status = harvest_sub.add_parser("status", help="the ledger, by state and by source")
284
+ h_status.set_defaults(func=_harvest_status)
285
+
286
+ # -- governance ------------------------------------------------------
287
+ p_gov = sub.add_parser("governance", help="what edify installed here, and whether it is unchanged")
288
+ gov_sub = p_gov.add_subparsers(dest="governance_command")
289
+
290
+ v_list = gov_sub.add_parser("list", help="every governed file, with origin and licence")
291
+ v_list.set_defaults(func=_governance_list)
292
+
293
+ v_verify = gov_sub.add_parser("verify", help="the ledger against what is on disk")
294
+ v_verify.add_argument("--exit-code", action="store_true",
295
+ help="exit non-zero when a governed file is missing, modified, or unrecorded")
296
+ v_verify.set_defaults(func=_governance_verify)
297
+
298
+ v_rebuild = gov_sub.add_parser("rebuild", help="re-baseline the ledger after a deliberate change")
299
+ v_rebuild.set_defaults(func=_governance_rebuild)
300
+
301
+ # -- mcp -------------------------------------------------------------
302
+ p_mcp = sub.add_parser("mcp", help="the server registry")
303
+ mcp_sub = p_mcp.add_subparsers(dest="mcp_command")
304
+
305
+ m_list = mcp_sub.add_parser("list", help="the registry, with what each entry is scoped to")
306
+ m_list.set_defaults(func=_mcp_list)
307
+
308
+ m_check = mcp_sub.add_parser("check", help="each server responds and its version matches the pin")
309
+ m_check.set_defaults(func=_mcp_check)
310
+
311
+ m_for = mcp_sub.add_parser("for", help="what a spawn in this position would load")
312
+ m_for.add_argument("role")
313
+ m_for.add_argument("phase")
314
+ m_for.set_defaults(func=_mcp_for)
315
+
316
+ # -- ship ------------------------------------------------------------
317
+ p_doctor = sub.add_parser("doctor", help="does the install work here")
318
+ p_doctor.set_defaults(func=_doctor)
319
+
320
+ # `self` is the binary talking about itself. Not `upgrade`, which pulls a newer
321
+ # skill library — two different things, kept under two names on purpose.
322
+ p_self = sub.add_parser("self", help="the `edify` binary itself: where it is, and updating it")
323
+ self_sub = p_self.add_subparsers(dest="self_command")
324
+
325
+ sf_where = self_sub.add_parser("where", help="which edify is this, and where did it come from")
326
+ sf_where.set_defaults(func=_self_where)
327
+
328
+ sf_update = self_sub.add_parser("update", help="reinstall the CLI from a source checkout")
329
+ sf_update.add_argument("--from", dest="from_path", metavar="PATH",
330
+ help="the checkout to install from (default: the one this code came from)")
331
+ sf_update.add_argument("--manager", default="", choices=("", "uv", "pipx", "pip"),
332
+ help="override the detected installer; `edify self where` prints what was detected")
333
+ sf_update.add_argument("--editable", action="store_true",
334
+ help="install in place, so later edits need no reinstall")
335
+ sf_update.add_argument("--offline", action="store_true",
336
+ help="never reach the network; fails cleanly when the build backend is not cached")
337
+ sf_update.add_argument("--dry-run", action="store_true",
338
+ help="print the install command and change nothing")
339
+ sf_update.set_defaults(func=_self_update)
340
+
341
+ p_license = sub.add_parser("license", help="what this machine is entitled to")
342
+ license_sub = p_license.add_subparsers(dest="license_command")
343
+ l_status = license_sub.add_parser("status", help="plan, entitlements, and limits")
344
+ l_status.set_defaults(func=_license_status)
345
+ l_activate = license_sub.add_parser("activate", help="install a licence token")
346
+ l_activate.add_argument("token", help="the token itself, or a path to a file containing it")
347
+ l_activate.set_defaults(func=_license_activate)
348
+ l_deactivate = license_sub.add_parser("deactivate", help="remove the licence from this machine")
349
+ l_deactivate.set_defaults(func=_license_deactivate)
350
+
351
+ p_feedback = sub.add_parser("feedback", help="how this is going — written to a file on this machine")
352
+ p_feedback.add_argument("--message", "-m", help="one line instead of the four questions")
353
+ p_feedback.set_defaults(func=_feedback_new)
354
+ feedback_sub = p_feedback.add_subparsers(dest="feedback_command")
355
+ f_list = feedback_sub.add_parser("list", help="what you have written, and where it is")
356
+ f_list.set_defaults(func=_feedback_list)
357
+ f_show = feedback_sub.add_parser("show", help="print one entry")
358
+ f_show.add_argument("which", nargs="?", help="the entry's number (default: the last one)")
359
+ f_show.set_defaults(func=_feedback_show)
360
+ f_off = feedback_sub.add_parser("off", help="never show the invitation again")
361
+ f_off.set_defaults(func=_feedback_off)
362
+ f_on = feedback_sub.add_parser("on", help="show the invitation again")
363
+ f_on.set_defaults(func=_feedback_on)
364
+
365
+ p_version = sub.add_parser("version", help="print the version")
366
+ p_version.set_defaults(func=_version)
367
+
368
+ return parser
369
+
370
+
371
+ # -- dispatch ---------------------------------------------------------------
372
+ # Imports live inside the handlers so `edify version` does not pay for the graph.
373
+
374
+
375
+ def _setup(ctx):
376
+ from .commands import setup_cmd
377
+
378
+ return setup_cmd.run(ctx)
379
+
380
+
381
+ def _init(ctx):
382
+ from .commands import init_cmd
383
+
384
+ return init_cmd.run(ctx)
385
+
386
+
387
+ def _init_new(ctx):
388
+ from .commands import init_new_cmd
389
+
390
+ return init_new_cmd.run(ctx)
391
+
392
+
393
+ def _check(ctx):
394
+ from .commands import check_cmd
395
+
396
+ return check_cmd.run(ctx)
397
+
398
+
399
+ def _upgrade(ctx):
400
+ from .commands import upgrade_cmd
401
+
402
+ return upgrade_cmd.run(ctx)
403
+
404
+
405
+ def _graph_build(ctx):
406
+ from .commands import graph_cmd
407
+
408
+ return graph_cmd.build(ctx)
409
+
410
+
411
+ def _graph_update(ctx):
412
+ from .commands import graph_cmd
413
+
414
+ return graph_cmd.update(ctx)
415
+
416
+
417
+ def _graph_where(ctx):
418
+ from .commands import graph_cmd
419
+
420
+ return graph_cmd.where(ctx)
421
+
422
+
423
+ def _graph_dependents(ctx):
424
+ from .commands import graph_cmd
425
+
426
+ return graph_cmd.dependents(ctx)
427
+
428
+
429
+ def _graph_references(ctx):
430
+ from .commands import graph_cmd
431
+
432
+ return graph_cmd.references(ctx)
433
+
434
+
435
+ def _graph_defines(ctx):
436
+ from .commands import graph_cmd
437
+
438
+ return graph_cmd.defines(ctx)
439
+
440
+
441
+ def _graph_overlap(ctx):
442
+ from .commands import graph_cmd
443
+
444
+ return graph_cmd.overlap(ctx)
445
+
446
+
447
+ def _graph_stat(ctx):
448
+ from .commands import graph_cmd
449
+
450
+ return graph_cmd.stat(ctx)
451
+
452
+
453
+ def _skills_list(ctx):
454
+ from .commands import skills_cmd
455
+
456
+ return skills_cmd.list_(ctx)
457
+
458
+
459
+ def _skills_resolve(ctx):
460
+ from .commands import skills_cmd
461
+
462
+ return skills_cmd.resolve(ctx)
463
+
464
+
465
+ def _skills_index(ctx):
466
+ from .commands import skills_cmd
467
+
468
+ return skills_cmd.index(ctx)
469
+
470
+
471
+ def _skills_add(ctx):
472
+ from .commands import skills_cmd
473
+
474
+ return skills_cmd.add(ctx)
475
+
476
+
477
+ def _skills_sync(ctx):
478
+ from .commands import skills_cmd
479
+
480
+ return skills_cmd.sync(ctx)
481
+
482
+
483
+ def _harvest_pick(ctx):
484
+ from .commands import harvest_cmd
485
+
486
+ return harvest_cmd.pick(ctx)
487
+
488
+
489
+ def _harvest_stage(ctx):
490
+ from .commands import harvest_cmd
491
+
492
+ return harvest_cmd.stage(ctx)
493
+
494
+
495
+ def _harvest_screen(ctx):
496
+ from .commands import harvest_cmd
497
+
498
+ return harvest_cmd.screen(ctx)
499
+
500
+
501
+ def _harvest_propose(ctx):
502
+ from .commands import harvest_cmd
503
+
504
+ return harvest_cmd.propose(ctx)
505
+
506
+
507
+ def _harvest_admit(ctx):
508
+ from .commands import harvest_cmd
509
+
510
+ return harvest_cmd.admit(ctx)
511
+
512
+
513
+ def _harvest_reject(ctx):
514
+ from .commands import harvest_cmd
515
+
516
+ return harvest_cmd.reject(ctx)
517
+
518
+
519
+ def _harvest_status(ctx):
520
+ from .commands import harvest_cmd
521
+
522
+ return harvest_cmd.status(ctx)
523
+
524
+
525
+ def _governance_list(ctx):
526
+ from .commands import governance_cmd
527
+
528
+ return governance_cmd.list_(ctx)
529
+
530
+
531
+ def _governance_verify(ctx):
532
+ from .commands import governance_cmd
533
+
534
+ return governance_cmd.verify(ctx)
535
+
536
+
537
+ def _governance_rebuild(ctx):
538
+ from .commands import governance_cmd
539
+
540
+ return governance_cmd.rebuild(ctx)
541
+
542
+
543
+ def _mcp_list(ctx):
544
+ from .commands import mcp_cmd
545
+
546
+ return mcp_cmd.list_(ctx)
547
+
548
+
549
+ def _mcp_check(ctx):
550
+ from .commands import mcp_cmd
551
+
552
+ return mcp_cmd.check(ctx)
553
+
554
+
555
+ def _mcp_for(ctx):
556
+ from .commands import mcp_cmd
557
+
558
+ return mcp_cmd.for_(ctx)
559
+
560
+
561
+ def _doctor(ctx):
562
+ from .commands import doctor_cmd
563
+
564
+ return doctor_cmd.run(ctx)
565
+
566
+
567
+ def _self_where(ctx):
568
+ from .commands import self_cmd
569
+
570
+ return self_cmd.where(ctx)
571
+
572
+
573
+ def _self_update(ctx):
574
+ from .commands import self_cmd
575
+
576
+ return self_cmd.update(ctx)
577
+
578
+
579
+ def _license_status(ctx):
580
+ from .commands import license_cmd
581
+
582
+ return license_cmd.status(ctx)
583
+
584
+
585
+ def _license_activate(ctx):
586
+ from .commands import license_cmd
587
+
588
+ return license_cmd.activate(ctx)
589
+
590
+
591
+ def _license_deactivate(ctx):
592
+ from .commands import license_cmd
593
+
594
+ return license_cmd.deactivate(ctx)
595
+
596
+
597
+ def _feedback_new(ctx):
598
+ from .commands import feedback_cmd
599
+
600
+ return feedback_cmd.new(ctx)
601
+
602
+
603
+ def _feedback_list(ctx):
604
+ from .commands import feedback_cmd
605
+
606
+ return feedback_cmd.list_(ctx)
607
+
608
+
609
+ def _feedback_show(ctx):
610
+ from .commands import feedback_cmd
611
+
612
+ return feedback_cmd.show(ctx)
613
+
614
+
615
+ def _feedback_off(ctx):
616
+ from .commands import feedback_cmd
617
+
618
+ return feedback_cmd.off(ctx)
619
+
620
+
621
+ def _feedback_on(ctx):
622
+ from .commands import feedback_cmd
623
+
624
+ return feedback_cmd.on(ctx)
625
+
626
+
627
+ def _version(ctx):
628
+ ctx.out.data({"version": __version__})
629
+ ctx.out.line(f"edify {__version__}")
630
+ return 0
631
+
632
+
633
+ # ---------------------------------------------------------------------------
634
+
635
+
636
+ def _invite(ctx, args) -> None:
637
+ """The one line asking how this is going, printed as the CLI opens.
638
+
639
+ Silent unless there is a real terminal, and at most once per released version.
640
+ It never asks anything here — a command that stops to interview you before doing
641
+ what you typed is a command people learn to avoid.
642
+ """
643
+ if getattr(args, "command", None) == "feedback":
644
+ return
645
+ from . import feedback
646
+
647
+ try:
648
+ feedback.maybe_invite(ctx.out)
649
+ except OSError:
650
+ pass # a feedback prompt is never a reason for a command to fail
651
+
652
+
653
+ def main(argv: list[str] | None = None) -> int:
654
+ parser = build_parser()
655
+ args = parser.parse_args(argv if argv is not None else sys.argv[1:])
656
+
657
+ if not getattr(args, "func", None):
658
+ # A family named with no subcommand prints that family's help, which is
659
+ # more useful than the top-level usage the user has already seen.
660
+ for family in ("graph", "skills", "harvest", "governance", "mcp", "license", "self"):
661
+ if getattr(args, "command", None) == family:
662
+ parser.parse_args([family, "--help"])
663
+ print(USAGE)
664
+ return 0 if getattr(args, "command", None) is None else 2
665
+
666
+ ctx = build_context(args)
667
+ _invite(ctx, args)
668
+ try:
669
+ return args.func(ctx) or 0
670
+ except EdifyError as exc:
671
+ ctx.out.error(exc.message, exc.hint)
672
+ return exc.exit_code
673
+ except KeyboardInterrupt:
674
+ ctx.out.error("interrupted")
675
+ return 130
676
+ except BrokenPipeError:
677
+ return 0
678
+
679
+
680
+ if __name__ == "__main__": # pragma: no cover
681
+ raise SystemExit(main())
@@ -0,0 +1 @@
1
+ """The command implementations. One module per family, as the CLI surface lists them."""