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/graph/ignore.py ADDED
@@ -0,0 +1,107 @@
1
+ """What the walk does not descend into.
2
+
3
+ Three sources, in order: a built-in list of directories that are never source, the
4
+ repository's `.gitignore` (the common subset — directory names, suffix globs, and
5
+ anchored paths), and `.edifyignore` when a repository needs to say something the
6
+ first two do not.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import fnmatch
12
+ from pathlib import Path
13
+
14
+ # Directories that are never source in any stack we cover. Matched by exact name
15
+ # at any depth, which is the only rule that stays correct in a monorepo.
16
+ ALWAYS_SKIP_DIRS = frozenset(
17
+ {
18
+ ".git", ".hg", ".svn", ".edify", ".idea", ".vscode", ".vs",
19
+ "node_modules", "bower_components", "vendor", "third_party",
20
+ "__pycache__", ".mypy_cache", ".ruff_cache", ".pytest_cache", ".tox",
21
+ ".venv", "venv", "env", "virtualenv", ".eggs",
22
+ "dist", "build", "out", "target", "bin", "obj", ".next", ".nuxt",
23
+ ".svelte-kit", ".turbo", ".parcel-cache", ".cache", "coverage",
24
+ ".gradle", ".terraform", "Pods", "DerivedData", ".dart_tool",
25
+ "site-packages", ".pnpm-store", ".yarn",
26
+ "__MACOSX", "Carthage",
27
+ }
28
+ )
29
+
30
+ # macOS bundle directories. They are named by suffix rather than by name, and a
31
+ # `.app` or `.framework` is a build product whose innards are not anybody's source.
32
+ ALWAYS_SKIP_DIR_SUFFIXES = (".dSYM", ".app", ".framework", ".xcassets", ".lproj")
33
+
34
+ # Files the operating system writes into a source tree without being asked.
35
+ ALWAYS_SKIP_NAMES = frozenset({".DS_Store", "Thumbs.db", "desktop.ini", ".localized", "Icon\r"})
36
+
37
+ ALWAYS_SKIP_SUFFIXES = frozenset(
38
+ {
39
+ ".min.js", ".min.css", ".map", ".lock", ".pyc", ".pyo", ".so", ".dll",
40
+ ".dylib", ".exe", ".class", ".jar", ".war", ".o", ".a", ".wasm",
41
+ ".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".ico", ".pdf",
42
+ ".zip", ".gz", ".tar", ".7z", ".mp4", ".mp3", ".woff", ".woff2", ".ttf",
43
+ ".eot", ".bin", ".db", ".sqlite", ".sqlite3", ".parquet",
44
+ }
45
+ )
46
+
47
+ # Anything larger than this is generated, vendored, or data. Indexing it costs
48
+ # more than it returns and pollutes the map with names nobody wrote.
49
+ MAX_FILE_BYTES = 1_500_000
50
+
51
+
52
+ class IgnoreRules:
53
+ def __init__(self, root: Path):
54
+ self.root = root
55
+ self.dir_names: set[str] = set(ALWAYS_SKIP_DIRS)
56
+ self.globs: list[str] = []
57
+ self.anchored: list[str] = []
58
+ self._load(root / ".gitignore")
59
+ self._load(root / ".edifyignore")
60
+
61
+ def _load(self, path: Path) -> None:
62
+ if not path.is_file():
63
+ return
64
+ try:
65
+ text = path.read_text(encoding="utf-8", errors="replace")
66
+ except OSError:
67
+ return
68
+ for raw in text.splitlines():
69
+ line = raw.strip()
70
+ if not line or line.startswith("#") or line.startswith("!"):
71
+ continue
72
+ if line.endswith("/"):
73
+ stripped = line.rstrip("/")
74
+ if "/" not in stripped:
75
+ self.dir_names.add(stripped)
76
+ else:
77
+ self.anchored.append(stripped.lstrip("/"))
78
+ continue
79
+ if line.startswith("/"):
80
+ self.anchored.append(line.lstrip("/"))
81
+ elif "/" in line:
82
+ self.anchored.append(line)
83
+ else:
84
+ self.globs.append(line)
85
+
86
+ def skip_dir(self, name: str, rel: str) -> bool:
87
+ if name in self.dir_names:
88
+ return True
89
+ if name.endswith(ALWAYS_SKIP_DIR_SUFFIXES):
90
+ return True
91
+ # `.claude/` holds generated command pointers, not source. `.github/` holds
92
+ # the CI job whose real commands the conventions scrape reads, so it stays.
93
+ if name.startswith(".") and name != ".github":
94
+ return True
95
+ return any(fnmatch.fnmatch(rel, pattern) for pattern in self.anchored)
96
+
97
+ def skip_file(self, name: str, rel: str, size: int) -> bool:
98
+ if name in ALWAYS_SKIP_NAMES:
99
+ return True
100
+ lowered = name.lower()
101
+ if any(lowered.endswith(suffix) for suffix in ALWAYS_SKIP_SUFFIXES):
102
+ return True
103
+ if size > MAX_FILE_BYTES:
104
+ return True
105
+ if any(fnmatch.fnmatch(name, pattern) for pattern in self.globs):
106
+ return True
107
+ return any(fnmatch.fnmatch(rel, pattern) for pattern in self.anchored)
@@ -0,0 +1,93 @@
1
+ """Per-language extraction.
2
+
3
+ Two backends ship. `python_ast` parses with the standard library's syntax tree and
4
+ is exact. `patterns` is a declarative line scanner covering the rest, and it is
5
+ honest about being a scanner: `meta.method_<lang>` records which one produced a
6
+ language's nodes, so nobody mistakes a scan for a parse.
7
+
8
+ A third backend, `ctags`, wraps a pinned external extractor when one is installed.
9
+ Whichever runs, the output is the same TSV contract — the contract is the asset.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from pathlib import Path
15
+
16
+ from ..model import Extraction
17
+ from . import markdown, patterns, python_ast, sqlish
18
+
19
+ # extension → language id. A language absent from this table produces a file node
20
+ # and nothing else, which is the visible-gap behaviour the design requires.
21
+ EXTENSIONS: dict[str, str] = {
22
+ ".py": "python",
23
+ ".pyi": "python",
24
+ ".js": "javascript",
25
+ ".jsx": "javascript",
26
+ ".mjs": "javascript",
27
+ ".cjs": "javascript",
28
+ ".ts": "typescript",
29
+ ".tsx": "typescript",
30
+ ".mts": "typescript",
31
+ ".cts": "typescript",
32
+ ".vue": "vue",
33
+ ".svelte": "svelte",
34
+ ".go": "go",
35
+ ".rs": "rust",
36
+ ".java": "java",
37
+ ".kt": "kotlin",
38
+ ".kts": "kotlin",
39
+ ".cs": "csharp",
40
+ ".swift": "swift",
41
+ ".rb": "ruby",
42
+ ".php": "php",
43
+ ".sql": "sql",
44
+ ".c": "c",
45
+ ".h": "c",
46
+ ".cc": "cpp",
47
+ ".cpp": "cpp",
48
+ ".cxx": "cpp",
49
+ ".hpp": "cpp",
50
+ ".hh": "cpp",
51
+ ".m": "objc",
52
+ ".scala": "scala",
53
+ ".dart": "dart",
54
+ ".lua": "lua",
55
+ ".ex": "elixir",
56
+ ".exs": "elixir",
57
+ ".sh": "shell",
58
+ ".bash": "shell",
59
+ ".md": "markdown",
60
+ ".markdown": "markdown",
61
+ }
62
+
63
+ # Which backend owns which language. Everything not listed falls to `patterns`.
64
+ _EXACT = {"python": "ast", "markdown": "structural", "sql": "structural"}
65
+
66
+
67
+ def language_for(path: Path) -> str | None:
68
+ return EXTENSIONS.get(path.suffix.lower())
69
+
70
+
71
+ def method_for(language: str) -> str:
72
+ """`ast`, `structural`, or `scan` — recorded in meta so the gap is visible."""
73
+ if language in _EXACT:
74
+ return _EXACT[language]
75
+ if language in patterns.RULES:
76
+ return "scan"
77
+ return "none"
78
+
79
+
80
+ def extract_file(rel_path: str, source: str, language: str) -> Extraction:
81
+ """Run the right backend over one file's text."""
82
+ if language == "python":
83
+ return python_ast.extract(rel_path, source)
84
+ if language == "markdown":
85
+ return markdown.extract(rel_path, source)
86
+ if language == "sql":
87
+ return sqlish.extract(rel_path, source)
88
+ return patterns.extract(rel_path, source, language)
89
+
90
+
91
+ def covered_languages() -> list[str]:
92
+ covered = set(_EXACT) | set(patterns.RULES)
93
+ return sorted(covered)
@@ -0,0 +1,145 @@
1
+ """Adapter for a pinned external extractor.
2
+
3
+ The design's preferred extractor is a third-party static binary with syntax-tree
4
+ parsing and broad language coverage, wrapped so it emits our TSV contract. This is
5
+ that wrapper. The contract is the asset; the extractor is replaceable by
6
+ construction, and this module is the only thing that has to change when it is
7
+ replaced.
8
+
9
+ Nothing here is required. With no external extractor present the built-in backends
10
+ run and `meta` records which one produced each language.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import json
16
+ import shutil
17
+ import subprocess
18
+ from pathlib import Path
19
+
20
+ from ..model import Edge, Extraction, Node, fingerprint, node_id
21
+
22
+ # ctags kinds → our node kinds. Anything unmapped is dropped rather than guessed.
23
+ _KIND_MAP = {
24
+ "function": "symbol",
25
+ "func": "symbol",
26
+ "method": "symbol",
27
+ "class": "symbol",
28
+ "struct": "symbol",
29
+ "interface": "symbol",
30
+ "trait": "symbol",
31
+ "enum": "symbol",
32
+ "enumerator": "symbol",
33
+ "constant": "symbol",
34
+ "variable": "symbol",
35
+ "member": "symbol",
36
+ "typedef": "symbol",
37
+ "type": "symbol",
38
+ "module": "module",
39
+ "namespace": "module",
40
+ "package": "package",
41
+ "table": "table",
42
+ }
43
+
44
+
45
+ def available(binary: str = "ctags") -> str | None:
46
+ """The resolved path of the external extractor, or None."""
47
+ path = shutil.which(binary)
48
+ if not path:
49
+ return None
50
+ try:
51
+ out = subprocess.run(
52
+ [path, "--version"], capture_output=True, text=True, timeout=10, check=False
53
+ )
54
+ except (OSError, subprocess.SubprocessError):
55
+ return None
56
+ # Only the Universal variant emits the JSON we parse. The exuberant one does
57
+ # not, and quietly producing nothing would be worse than declining.
58
+ if "Universal Ctags" not in (out.stdout or "") + (out.stderr or ""):
59
+ return None
60
+ return path
61
+
62
+
63
+ def version(binary: str = "ctags") -> str:
64
+ path = shutil.which(binary)
65
+ if not path:
66
+ return "-"
67
+ try:
68
+ out = subprocess.run(
69
+ [path, "--version"], capture_output=True, text=True, timeout=10, check=False
70
+ )
71
+ except (OSError, subprocess.SubprocessError):
72
+ return "-"
73
+ first = (out.stdout or out.stderr or "").splitlines()
74
+ return first[0].strip() if first else "-"
75
+
76
+
77
+ def extract_tree(root: Path, files: list[str], binary: str = "ctags") -> Extraction:
78
+ """Run the external extractor over an explicit file list.
79
+
80
+ The file list comes from our own walk, so the extractor never decides what is
81
+ in scope — ignore rules stay in one place.
82
+ """
83
+ out = Extraction()
84
+ path = available(binary)
85
+ if not path or not files:
86
+ return out
87
+
88
+ # A file list on stdin keeps the command line under every platform's limit.
89
+ listing = "\n".join(files)
90
+ try:
91
+ proc = subprocess.run(
92
+ [
93
+ path,
94
+ "--output-format=json",
95
+ "--fields=+nKz",
96
+ "--extras=",
97
+ "-L",
98
+ "-",
99
+ "-f",
100
+ "-",
101
+ ],
102
+ input=listing,
103
+ capture_output=True,
104
+ text=True,
105
+ cwd=str(root),
106
+ timeout=600,
107
+ check=False,
108
+ )
109
+ except (OSError, subprocess.SubprocessError):
110
+ return out
111
+
112
+ seen_files: set[str] = set()
113
+ for line in proc.stdout.splitlines():
114
+ line = line.strip()
115
+ if not line or not line.startswith("{"):
116
+ continue
117
+ try:
118
+ tag = json.loads(line)
119
+ except json.JSONDecodeError:
120
+ continue
121
+ if tag.get("_type") != "tag":
122
+ continue
123
+ rel = Path(tag.get("path", "")).as_posix().lstrip("./")
124
+ name = tag.get("name")
125
+ kind = _KIND_MAP.get(str(tag.get("kind", "")).lower())
126
+ if not rel or not name or not kind:
127
+ continue
128
+ lineno = int(tag.get("line", 1) or 1)
129
+ scope = tag.get("scope")
130
+ qualified = f"{scope}.{name}" if scope else name
131
+
132
+ file_id = node_id("file", rel, ".")
133
+ if rel not in seen_files:
134
+ seen_files.add(rel)
135
+ module_id = node_id("module", rel, ".")
136
+ out.nodes.append(Node(module_id, "module", rel, 1, rel.rsplit("/", 1)[-1]))
137
+ out.edges.append(Edge(file_id, "defines", module_id))
138
+
139
+ sym_id = node_id(kind, rel, qualified)
140
+ signature = tag.get("signature") or tag.get("pattern") or qualified
141
+ out.nodes.append(Node(sym_id, kind, rel, lineno, qualified, fingerprint(str(signature))))
142
+ out.edges.append(Edge(node_id("module", rel, "."), "defines", sym_id))
143
+ if tag.get("language"):
144
+ out.languages.add(str(tag["language"]).lower())
145
+ return out
@@ -0,0 +1,41 @@
1
+ """Markdown headings as `doc-section` nodes.
2
+
3
+ Structural rather than scanned: a heading is a heading. This is what lets a spec's
4
+ `## Assertions` block be cited as `file:line` and what makes `documents` edges
5
+ possible between a document section and the module it describes.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import re
11
+
12
+ from ..model import Edge, Extraction, Node, fingerprint, node_id
13
+
14
+ _HEADING = re.compile(r"^(?P<hashes>#{1,6})\s+(?P<title>.+?)\s*#*\s*$")
15
+ _FENCE = re.compile(r"^\s*(```|~~~)")
16
+
17
+
18
+ def extract(rel_path: str, source: str) -> Extraction:
19
+ out = Extraction(languages={"markdown"})
20
+ file_id = node_id("file", rel_path, ".")
21
+ in_fence = False
22
+ stack: list[str] = []
23
+
24
+ for lineno, raw in enumerate(source.splitlines(), start=1):
25
+ if _FENCE.match(raw):
26
+ in_fence = not in_fence
27
+ continue
28
+ if in_fence:
29
+ continue
30
+ m = _HEADING.match(raw)
31
+ if not m:
32
+ continue
33
+ depth = len(m.group("hashes"))
34
+ title = m.group("title").strip()
35
+ del stack[depth - 1 :]
36
+ stack.append(title)
37
+ name = " > ".join(stack)
38
+ sec_id = node_id("doc-section", rel_path, name)
39
+ out.nodes.append(Node(sec_id, "doc-section", rel_path, lineno, name, fingerprint(title)))
40
+ out.edges.append(Edge(file_id, "defines", sec_id))
41
+ return out