terra4mice 0.1.0.dev15__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ultravioleta DAO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,441 @@
1
+ Metadata-Version: 2.4
2
+ Name: terra4mice
3
+ Version: 0.1.0.dev15
4
+ Summary: State-Driven Development Framework - Terraform for your codebase
5
+ Author-email: Ultravioleta DAO <ultravioletadao@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/0xultravioleta/terra4mice
8
+ Project-URL: Documentation, https://github.com/0xultravioleta/terra4mice#readme
9
+ Project-URL: Repository, https://github.com/0xultravioleta/terra4mice
10
+ Project-URL: Issues, https://github.com/0xultravioleta/terra4mice/issues
11
+ Keywords: development,state-management,terraform,vivecoding,specification,tracking
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Build Tools
22
+ Classifier: Topic :: Software Development :: Quality Assurance
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: pyyaml>=6.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-cov; extra == "dev"
30
+ Requires-Dist: black; extra == "dev"
31
+ Requires-Dist: mypy; extra == "dev"
32
+ Provides-Extra: ast
33
+ Requires-Dist: tree-sitter>=0.23.0; extra == "ast"
34
+ Requires-Dist: tree-sitter-language-pack>=0.4.0; extra == "ast"
35
+ Provides-Extra: all
36
+ Requires-Dist: terra4mice[ast,dev]; extra == "all"
37
+ Dynamic: license-file
38
+
39
+ # terra4mice
40
+
41
+ > State-Driven Development Framework
42
+ >
43
+ > "Software isn't done when it works. It's done when state converges with spec."
44
+
45
+ terra4mice applies Terraform's mental model to software development. While Terraform manages infrastructure, terra4mice manages **living development**.
46
+
47
+ ## The Problem
48
+
49
+ In livecoding, this happens:
50
+
51
+ 1. You implement A
52
+ 2. B breaks A
53
+ 3. You workaround with C
54
+ 4. D becomes a TODO
55
+ 5. Someone says "it works"
56
+ 6. Weeks later: D never existed
57
+
58
+ **The system doesn't know**:
59
+ - Which parts of the spec are complete
60
+ - Which parts are mocked
61
+ - Which parts only exist in your head
62
+
63
+ ## The Solution
64
+
65
+ ```
66
+ SPEC (desired state) -> What SHOULD exist (declarative YAML)
67
+ STATE (current state) -> What DOES exist (inferred/marked)
68
+ PLAN (diff) -> spec - state = work to do
69
+ APPLY (execution) -> Cycles until convergence
70
+ ```
71
+
72
+ ## Quick Start
73
+
74
+ ```bash
75
+ # Install
76
+ pip install terra4mice
77
+
78
+ # With deep AST analysis (optional, Python >=3.10)
79
+ pip install terra4mice[ast]
80
+
81
+ # Initialize in your project
82
+ cd my-project
83
+ terra4mice init
84
+
85
+ # See what's missing
86
+ terra4mice plan
87
+
88
+ # Auto-detect codebase state
89
+ terra4mice refresh
90
+
91
+ # List resources in state
92
+ terra4mice state list
93
+
94
+ # Mark something as implemented
95
+ terra4mice mark feature.auth_login --files src/auth.py
96
+
97
+ # CI report (JSON)
98
+ terra4mice ci --format json
99
+ ```
100
+
101
+ ## Commands
102
+
103
+ ### `terra4mice init`
104
+
105
+ Creates spec and state files:
106
+
107
+ ```bash
108
+ terra4mice init
109
+ # Created: terra4mice.spec.yaml
110
+ # Created: terra4mice.state.json
111
+ ```
112
+
113
+ ### `terra4mice plan`
114
+
115
+ Shows what's needed to converge:
116
+
117
+ ```
118
+ $ terra4mice plan
119
+
120
+ terra4mice will perform the following actions:
121
+
122
+ + feature.auth_login
123
+ # Resource declared in spec but not in state
124
+ + feature.auth_refresh
125
+ # Resource declared in spec but not in state
126
+ ~ feature.auth_logout
127
+ # Resource is partially implemented
128
+
129
+ Plan: 2 to create, 1 to update.
130
+ ```
131
+
132
+ With `--verbose`, plan shows function-level symbol tracking:
133
+
134
+ ```
135
+ $ terra4mice plan --verbose
136
+
137
+ ~ module.inference
138
+ # Resource is partially implemented
139
+ Symbols: 10/12 found
140
+ - format_report (missing)
141
+ - validate_config (missing)
142
+ ```
143
+
144
+ ### `terra4mice refresh`
145
+
146
+ Auto-detects codebase state using multiple strategies:
147
+
148
+ ```
149
+ $ terra4mice refresh
150
+
151
+ Scanning /my-project for resources...
152
+
153
+ Inference Report
154
+ ============================================================
155
+ IMPLEMENTED (5 resources)
156
+ module.models
157
+ Confidence: [##########] 100%
158
+ Files: src/models.py
159
+ Evidence: Explicit files found, AST analysis: 100% match
160
+ Symbols: 12/12 (100%)
161
+
162
+ PARTIAL (1 resources)
163
+ feature.auth
164
+ Confidence: [######----] 60%
165
+ Symbols: 5/8 (62%)
166
+ Missing: validate_token, refresh_session, logout_handler
167
+
168
+ MISSING (2 resources)
169
+ feature.payments
170
+ feature.notifications
171
+
172
+ Summary
173
+ Convergence: 68.8%
174
+ ```
175
+
176
+ Inference strategies (in priority order):
177
+ 1. **tree-sitter AST** (with `[ast]`) - verifies functions, classes, exports against spec attributes
178
+ 2. **stdlib ast** - basic Python analysis
179
+ 3. **Regex** - Solidity, TypeScript/JavaScript patterns
180
+ 4. **Heuristic** - config/docs file size
181
+
182
+ ### `terra4mice state list`
183
+
184
+ Lists all resources in state:
185
+
186
+ ```
187
+ $ terra4mice state list
188
+
189
+ feature.auth_login
190
+ feature.auth_refresh
191
+ module.payment_processor
192
+ ```
193
+
194
+ ### `terra4mice state show <address>`
195
+
196
+ Shows resource details including symbol-level tracking:
197
+
198
+ ```
199
+ $ terra4mice state show module.inference
200
+
201
+ # module.inference
202
+ type = "module"
203
+ name = "inference"
204
+ status = "implemented"
205
+ files = ["src/terra4mice/inference.py"]
206
+ symbols = 12 (10 implemented, 2 missing)
207
+ InferenceEngine class lines 94-686 (src/terra4mice/inference.py)
208
+ InferenceEngine.infer_all method lines 154-178 (src/terra4mice/inference.py)
209
+ InferenceEngine.infer_resource method lines 180-245 (src/terra4mice/inference.py)
210
+ format_inference_report function lines 719-787 (src/terra4mice/inference.py)
211
+ validate_config function [MISSING]
212
+ ```
213
+
214
+ ### `terra4mice mark <address>`
215
+
216
+ Marks a resource with a status:
217
+
218
+ ```bash
219
+ # Mark as implemented
220
+ terra4mice mark feature.auth_login --files src/auth.py
221
+
222
+ # Mark as partial
223
+ terra4mice mark feature.auth_refresh --status partial --reason "Missing token rotation"
224
+
225
+ # Mark as broken
226
+ terra4mice mark feature.auth_logout --status broken --reason "Tests failing"
227
+ ```
228
+
229
+ ### `terra4mice apply`
230
+
231
+ Interactive apply loop:
232
+
233
+ ```
234
+ $ terra4mice apply
235
+
236
+ ============================================================
237
+ Next: + feature.auth_login
238
+ Resource declared in spec but not in state
239
+
240
+ Attributes: {'endpoints': ['POST /auth/login']}
241
+
242
+ Action: [i]mplement, [p]artial, [s]kip, [q]uit? i
243
+ Files that implement this: src/auth.py, src/routes/login.py
244
+ Marked as implemented: feature.auth_login
245
+ ```
246
+
247
+ ### `terra4mice diff`
248
+
249
+ Compare two state snapshots to see what changed:
250
+
251
+ ```
252
+ $ terra4mice diff --old state.json.bak
253
+
254
+ terra4mice diff
255
+ ==================================================
256
+ Old: state.json.bak (serial 5)
257
+ New: terra4mice.state.json (serial 8)
258
+
259
+ Upgraded (3):
260
+ module.inference: partial -> implemented
261
+ module.analyzers: missing -> implemented
262
+ feature.ci: partial -> implemented
263
+
264
+ Convergence: 45.0% -> 78.3% (+33.3%)
265
+ ```
266
+
267
+ ### `terra4mice ci`
268
+
269
+ Output for CI/CD pipelines:
270
+
271
+ ```bash
272
+ # JSON (machine-readable)
273
+ terra4mice ci --format json
274
+
275
+ # Markdown (PR comments)
276
+ terra4mice ci --format markdown --comment pr-comment.md
277
+
278
+ # Fail if convergence < threshold
279
+ terra4mice ci --fail-under 80
280
+ ```
281
+
282
+ ## Spec File Format
283
+
284
+ ```yaml
285
+ # terra4mice.spec.yaml
286
+ version: "1"
287
+
288
+ resources:
289
+ feature:
290
+ auth_login:
291
+ attributes:
292
+ description: "User login"
293
+ endpoints: [POST /auth/login]
294
+ depends_on: []
295
+
296
+ auth_refresh:
297
+ attributes:
298
+ description: "Token refresh"
299
+ depends_on:
300
+ - feature.auth_login
301
+
302
+ module:
303
+ state_manager:
304
+ attributes:
305
+ class: StateManager
306
+ functions: [load, save, list, mark_created]
307
+ files:
308
+ - src/state_manager.py
309
+
310
+ endpoint:
311
+ api_users:
312
+ attributes:
313
+ method: GET
314
+ path: /api/users
315
+ depends_on:
316
+ - feature.auth_login
317
+ ```
318
+
319
+ ### Spec Attributes for AST Verification
320
+
321
+ With `terra4mice[ast]` installed, these attributes are verified against actual code:
322
+
323
+ ```yaml
324
+ attributes:
325
+ class: StateManager # verified in classes
326
+ functions: [load, save, list] # verified in defined functions
327
+ entities: [Resource, State] # verified in classes/interfaces/types/enums
328
+ exports: [WorkerRatingModal] # verified in exports (TS/JS)
329
+ imports: [useState, useEffect] # verified in imports
330
+ commands: [init, plan, refresh] # substring match in functions
331
+ strategies: [explicit_files] # substring match in functions+classes
332
+ ```
333
+
334
+ Supported languages: Python, TypeScript/TSX, JavaScript, Solidity.
335
+
336
+ ## State File Format
337
+
338
+ ```json
339
+ {
340
+ "version": "1",
341
+ "serial": 3,
342
+ "last_updated": "2026-01-27T15:30:00",
343
+ "resources": [
344
+ {
345
+ "type": "module",
346
+ "name": "inference",
347
+ "status": "implemented",
348
+ "files": ["src/terra4mice/inference.py"],
349
+ "symbols": {
350
+ "InferenceEngine": {
351
+ "name": "InferenceEngine",
352
+ "kind": "class",
353
+ "status": "implemented",
354
+ "line_start": 94,
355
+ "line_end": 686,
356
+ "file": "src/terra4mice/inference.py"
357
+ },
358
+ "format_report": {
359
+ "name": "format_report",
360
+ "kind": "function",
361
+ "status": "missing"
362
+ }
363
+ }
364
+ }
365
+ ]
366
+ }
367
+ ```
368
+
369
+ ## CI/CD Integration
370
+
371
+ ```yaml
372
+ # .github/workflows/terra4mice.yml
373
+ name: Check Convergence
374
+
375
+ on: [push, pull_request]
376
+
377
+ jobs:
378
+ check:
379
+ runs-on: ubuntu-latest
380
+ steps:
381
+ - uses: actions/checkout@v4
382
+ - uses: actions/setup-python@v5
383
+ with:
384
+ python-version: '3.11'
385
+ - run: pip install terra4mice[ast]
386
+ - run: terra4mice plan --detailed-exitcode
387
+ # Returns 2 if there are pending changes
388
+ ```
389
+
390
+ ## Roadmap
391
+
392
+ | Phase | Status | Description |
393
+ |-------|--------|-------------|
394
+ | 1 - MVP CLI | DONE | init, plan, refresh, state, mark, apply, ci, diff |
395
+ | 2 - tree-sitter AST | DONE | Multi-language deep analysis, spec attribute verification, symbol tracking |
396
+ | 3 - Multi-AI Contexts | PLANNED | Track which AI (Claude, Codex, Kimi) has context on what |
397
+ | 4 - CI/CD Integration | DONE | GitHub Action, PR comments, convergence badges |
398
+ | 5 - Apply Runner | PLANNED | Interactive apply loop, agent integration |
399
+ | 6 - Ecosystem Rollout | PLANNED | Deploy across Ultravioleta DAO projects |
400
+
401
+ ### Phase 3: Multi-AI Context Tracking (Next)
402
+
403
+ When multiple AIs work on the same project, each carries its own isolated context. Phase 3 adds a **context registry** to know which AI has context on what:
404
+
405
+ ```bash
406
+ terra4mice contexts list
407
+ # AGENT RESOURCE LAST SEEN STATUS
408
+ # claude-code module.inference 2min ago active
409
+ # codex feature.auth_login 1hr ago stale
410
+ # kimi-2.5 feature.frontend 30min ago active
411
+
412
+ terra4mice mark module.auth implemented --agent=codex
413
+ terra4mice contexts sync --from=claude-code --to=codex
414
+ ```
415
+
416
+ ## Philosophy
417
+
418
+ 1. **State before intention** - What exists, not what we want
419
+ 2. **Evidence before perception** - Tests, not "I think it works"
420
+ 3. **Convergence before speed** - Better slow and correct
421
+ 4. **Clarity before heroism** - Visible plan, not magic
422
+
423
+ ## Definition of Done
424
+
425
+ A project is complete when:
426
+
427
+ ```
428
+ $ terra4mice plan
429
+
430
+ No changes. State matches spec.
431
+ ```
432
+
433
+ Nothing else.
434
+
435
+ ## License
436
+
437
+ MIT - Public good for the developer community.
438
+
439
+ ## Contributing
440
+
441
+ PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.