leyline-code 0.8.1__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 (65) hide show
  1. leyline/__init__.py +3 -0
  2. leyline/adapters/__init__.py +19 -0
  3. leyline/adapters/csharp.py +1026 -0
  4. leyline/adapters/generic.py +844 -0
  5. leyline/adapters/python.py +929 -0
  6. leyline/adapters/typescript.py +1512 -0
  7. leyline/affected.py +509 -0
  8. leyline/agent_skills.py +311 -0
  9. leyline/change.py +500 -0
  10. leyline/channels.py +1782 -0
  11. leyline/cli.py +1029 -0
  12. leyline/cluster.py +149 -0
  13. leyline/context.py +531 -0
  14. leyline/coupling.py +485 -0
  15. leyline/coverage.py +376 -0
  16. leyline/diagrams.py +680 -0
  17. leyline/diff.py +1078 -0
  18. leyline/drift.py +747 -0
  19. leyline/exact.py +410 -0
  20. leyline/explain.py +973 -0
  21. leyline/export.py +673 -0
  22. leyline/fncoupling.py +328 -0
  23. leyline/formats.py +923 -0
  24. leyline/grade.py +207 -0
  25. leyline/incremental.py +931 -0
  26. leyline/indexer.py +3733 -0
  27. leyline/learnings.py +743 -0
  28. leyline/loop.py +584 -0
  29. leyline/model.py +142 -0
  30. leyline/outline.py +1066 -0
  31. leyline/packing.py +86 -0
  32. leyline/patterns.py +478 -0
  33. leyline/pr.py +1249 -0
  34. leyline/props.py +255 -0
  35. leyline/query.py +683 -0
  36. leyline/quick.py +853 -0
  37. leyline/related.py +266 -0
  38. leyline/removal.py +231 -0
  39. leyline/renames.py +231 -0
  40. leyline/rereview.py +375 -0
  41. leyline/roslyn_refs/Program.cs +179 -0
  42. leyline/roslyn_refs/RoslynRefs.csproj +16 -0
  43. leyline/rules.py +171 -0
  44. leyline/schema.sql +178 -0
  45. leyline/scip_pb2.py +97 -0
  46. leyline/server.py +1230 -0
  47. leyline/skills/leyline-adversarial-review/SKILL.md +121 -0
  48. leyline/skills/leyline-ask/SKILL.md +57 -0
  49. leyline/skills/leyline-change-impact/SKILL.md +79 -0
  50. leyline/skills/leyline-explain-flow/SKILL.md +70 -0
  51. leyline/skills/leyline-explore-module/SKILL.md +55 -0
  52. leyline/skills/leyline-pr-review/SKILL.md +77 -0
  53. leyline/skills/leyline-quick-change/SKILL.md +63 -0
  54. leyline/skills/leyline-spec/SKILL.md +179 -0
  55. leyline/skills/leyline-tour/SKILL.md +46 -0
  56. leyline/spec.py +1819 -0
  57. leyline/store.py +560 -0
  58. leyline/tours.py +352 -0
  59. leyline/verdicts.py +390 -0
  60. leyline/viewer/viewer.html +1622 -0
  61. leyline_code-0.8.1.dist-info/METADATA +1325 -0
  62. leyline_code-0.8.1.dist-info/RECORD +65 -0
  63. leyline_code-0.8.1.dist-info/WHEEL +4 -0
  64. leyline_code-0.8.1.dist-info/entry_points.txt +2 -0
  65. leyline_code-0.8.1.dist-info/licenses/LICENSE +674 -0
leyline/model.py ADDED
@@ -0,0 +1,142 @@
1
+ """Language-neutral records that adapters emit and the indexer resolves.
2
+
3
+ The records have slots: a large repository holds millions of them at once, and without a dict each one is
4
+ about half the size."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass, field
9
+ from typing import Optional
10
+
11
+
12
+ @dataclass(slots=True)
13
+ class Node:
14
+ id: str
15
+ kind: str # repo, module, file, type, callable, field, entry_point, external, test
16
+ name: str
17
+ parent_id: Optional[str] = None
18
+ language: Optional[str] = None
19
+ path: Optional[str] = None
20
+ span_start: Optional[int] = None # 1-based line
21
+ span_end: Optional[int] = None
22
+ content_hash: Optional[str] = None
23
+ attrs: dict = field(default_factory=dict)
24
+
25
+
26
+ @dataclass(slots=True)
27
+ class Edge:
28
+ kind: str
29
+ src_id: str
30
+ dst_id: str
31
+ precision: str = "exact" # exact | heuristic | observed
32
+ attrs: dict = field(default_factory=dict)
33
+
34
+
35
+ @dataclass(slots=True)
36
+ class TypeRef:
37
+ """A use of a type by name, to be resolved against the workspace."""
38
+
39
+ src_id: str
40
+ names: list[str] # every identifier in the type expression, e.g. List<Foo> -> [List, Foo]
41
+ role: str # param | return | field_type | local | base | instantiate
42
+ line: Optional[int] = None
43
+
44
+
45
+ @dataclass(slots=True)
46
+ class CallSite:
47
+ """An unresolved call, with whatever the adapter could tell about its receiver."""
48
+
49
+ src_id: str # enclosing callable
50
+ name: str # method or function name
51
+ receiver: Optional[str] # None (bare call), 'this', a type name, or a variable name
52
+ receiver_type: Optional[str] # declared type of the receiver if the adapter inferred it
53
+ argc: int
54
+ line: int
55
+ enclosing_type: Optional[str] = None # id of the type the caller lives in
56
+ col: int = 0
57
+ args: tuple = () # per argument: a lambda's parameter count (int), a known type name (str), or None
58
+ targs: int = 0 # explicit type arguments on the call: M<int>() has 1
59
+ chain: Optional["CallSite"] = None # the call whose result this one is made on: a.Make().Run()
60
+ ref: bool = False # not a call: the function is handed over by name (onClick={save}) for someone else to call
61
+ attr: bool = False # not a call: an attribute read, as the receiver of one (`app.config` in app.config.load())
62
+
63
+
64
+ @dataclass(slots=True)
65
+ class EventUse:
66
+ """A place where an event is raised or subscribed to."""
67
+
68
+ kind: str # raise | subscribe
69
+ src_id: str # enclosing callable
70
+ event: str # event member name
71
+ receiver: Optional[str] # as in CallSite; None means the enclosing type's own event
72
+ receiver_type: Optional[str]
73
+ handler: Optional[str] # method name for a method-group handler, None for a lambda
74
+ line: int
75
+ enclosing_type: Optional[str] = None
76
+
77
+
78
+ @dataclass(slots=True)
79
+ class FieldUse:
80
+ """A place where a member that may be a field is read or assigned."""
81
+
82
+ src_id: str # enclosing callable
83
+ name: str
84
+ receiver: Optional[str] # as in CallSite; None means a bare name
85
+ receiver_type: Optional[str]
86
+ access: str # r | w | rw | i (set while the object is being created: new Foo { a = 1 })
87
+ line: int
88
+ enclosing_type: Optional[str] = None
89
+ chain: Optional[CallSite] = None
90
+
91
+
92
+ @dataclass(slots=True)
93
+ class Endpoint:
94
+ """One end of a channel that is not a call: an HTTP route or request, a file read or written, a registration
95
+ in a dependency-injection container, a message published or handled, a table read or written, an RPC."""
96
+
97
+ channel: str # http | file | di | queue | db | rpc
98
+ role: str # serve | call | write | read; di: provide | inject | depend | start; queue: publish | subscribe; db: table
99
+ src_id: str
100
+ address: str # the route or request path (empty for files), the topic, table, service, or service/method
101
+ line: int
102
+ method: Optional[str] = None # the HTTP method; for the other channels, the shape that was recognised
103
+ literals: list[str] = field(default_factory=list) # string literals in the call; di: the implementation
104
+ handler: Optional[str] = None # the function a subscription or task names, as written
105
+
106
+
107
+ @dataclass(slots=True)
108
+ class Spawn:
109
+ """A place where another program is launched."""
110
+
111
+ src_id: str
112
+ strings: list[str] # string literals in the launch call, constants resolved
113
+ file_strings: list[str] # every other string literal in the file, as a weaker hint
114
+ pipes: bool # the launcher wires up stdin or stdout
115
+ line: int
116
+
117
+
118
+ @dataclass(slots=True)
119
+ class ImportRef:
120
+ src_id: str # file id
121
+ target: str # namespace or module path as written
122
+ symbols: list[str] = field(default_factory=list)
123
+ alias: Optional[str] = None
124
+ is_static: bool = False
125
+
126
+
127
+ @dataclass(slots=True)
128
+ class FileResult:
129
+ nodes: list[Node] = field(default_factory=list)
130
+ edges: list[Edge] = field(default_factory=list)
131
+ type_refs: list[TypeRef] = field(default_factory=list)
132
+ calls: list[CallSite] = field(default_factory=list)
133
+ imports: list[ImportRef] = field(default_factory=list)
134
+ events: list[EventUse] = field(default_factory=list)
135
+ field_uses: list[FieldUse] = field(default_factory=list)
136
+ endpoints: list[Endpoint] = field(default_factory=list)
137
+ path_strings: dict[str, list[str]] = field(default_factory=dict) # function -> path-like literals in its body
138
+ spawns: list[Spawn] = field(default_factory=list)
139
+ # Namespaces (C#) or module paths (Python) this file declares.
140
+ declares: list[str] = field(default_factory=list)
141
+ # Module-level variables whose type the file states (Python: `g: Globals = ...`, `app = Flask()`).
142
+ var_types: dict[str, str] = field(default_factory=dict)