substratum-cli 0.1.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 (42) hide show
  1. substratum_cli/README.md +51 -0
  2. substratum_cli/__init__.py +6 -0
  3. substratum_cli/__main__.py +7 -0
  4. substratum_cli/_vendor/__init__.py +0 -0
  5. substratum_cli/_vendor/_pro_test_derive.py +169 -0
  6. substratum_cli/account.py +62 -0
  7. substratum_cli/cli.py +185 -0
  8. substratum_cli/codes.py +114 -0
  9. substratum_cli/commands/__init__.py +0 -0
  10. substratum_cli/commands/apply.py +49 -0
  11. substratum_cli/commands/auth.py +37 -0
  12. substratum_cli/commands/commit.py +40 -0
  13. substratum_cli/commands/explain.py +63 -0
  14. substratum_cli/commands/failing.py +80 -0
  15. substratum_cli/commands/fix.py +48 -0
  16. substratum_cli/commands/history.py +15 -0
  17. substratum_cli/commands/init_cmd.py +155 -0
  18. substratum_cli/commands/replay.py +68 -0
  19. substratum_cli/commands/scaffold.py +71 -0
  20. substratum_cli/commands/show.py +18 -0
  21. substratum_cli/commands/undo.py +28 -0
  22. substratum_cli/commands/verify.py +193 -0
  23. substratum_cli/commands/write.py +42 -0
  24. substratum_cli/config.py +49 -0
  25. substratum_cli/diffs.py +106 -0
  26. substratum_cli/engine.py +154 -0
  27. substratum_cli/gitio.py +102 -0
  28. substratum_cli/langscan.py +110 -0
  29. substratum_cli/product_ops.py +639 -0
  30. substratum_cli/refusals.py +127 -0
  31. substratum_cli/remote.py +140 -0
  32. substratum_cli/render.py +332 -0
  33. substratum_cli/result.py +185 -0
  34. substratum_cli/run_store.py +162 -0
  35. substratum_cli/runid.py +69 -0
  36. substratum_cli/session.py +558 -0
  37. substratum_cli/style.py +128 -0
  38. substratum_cli-0.1.0.dist-info/METADATA +69 -0
  39. substratum_cli-0.1.0.dist-info/RECORD +42 -0
  40. substratum_cli-0.1.0.dist-info/WHEEL +5 -0
  41. substratum_cli-0.1.0.dist-info/entry_points.txt +2 -0
  42. substratum_cli-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,128 @@
1
+ """The Substratum terminal design language: The Sovereign Seal.
2
+
3
+ A result is a sealed certificate, not a chat turn: a verdict-tinted left rail closed by a foot,
4
+ uppercase channel labels scanning down a grey gutter, one verdict accent (green proven / cyan
5
+ refused) + gold for the next executable move + two greys. Line 1 is always the exact parseable
6
+ grammar. Degrades cleanly: NO_COLOR / non-TTY strips SGR (glyphs + words carry meaning); ascii
7
+ mode swaps glyphs. Restraint is the brand: precision instrument, not decoration.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import sys
13
+
14
+ # ---- palette (256-color, 8/16 fallback folded to the same escapes for portability) ----
15
+ PROVEN = "\033[38;5;42m"
16
+ PROVEN_B = "\033[1;38;5;42m"
17
+ REFUSED = "\033[38;5;44m"
18
+ REFUSED_B = "\033[1;38;5;44m"
19
+ FAULT = "\033[38;5;160m" # tool crash only, appears on no normal screen
20
+ FAILC = "\033[38;5;208m" # a verified NO: gate ran, patch did not pass (amber, not crash-red)
21
+ FAILC_B = "\033[1;38;5;208m"
22
+ GOLD = "\033[38;5;179m" # the next move: provenance, flip steps, transitions, brand mark
23
+ LABEL = "\033[38;5;245m" # uppercase channel labels, run=, code=, secondary facts
24
+ CHROME = "\033[38;5;240m" # hairline, separators, diff context, "base FAIL" (never red)
25
+ RESET = "\033[0m"
26
+ BOLD = "\033[1m"
27
+
28
+ # ---- glyphs + ascii degrade ----
29
+ _G = {"rail": "│", "foot": "└", "bar": "─", "brand": "◆", "lamp": "●",
30
+ "ok": "✓", "wall": "○", "arrow": "→", "dot": "·",
31
+ "ftl": "┌", "ftr": "┐", "fbl": "└", "fbr": "┘", "tee": "├"}
32
+ _ASCII = {"rail": "|", "foot": "+", "bar": "-", "brand": "*", "lamp": "o",
33
+ "ok": "ok", "wall": "--", "arrow": "->", "dot": "-",
34
+ "ftl": "+", "ftr": "+", "fbl": "+", "fbr": "+", "tee": "+"}
35
+
36
+
37
+ def use_color(stream=None, force: str | None = None) -> bool:
38
+ if force == "never":
39
+ return False
40
+ if force == "always":
41
+ return True
42
+ if os.environ.get("NO_COLOR"):
43
+ return False
44
+ return bool(getattr(stream or sys.stdout, "isatty", lambda: False)())
45
+
46
+
47
+ def use_ascii() -> bool:
48
+ if os.environ.get("SUBSTRATUM_ASCII"):
49
+ return True
50
+ enc = (getattr(sys.stdout, "encoding", "") or "").lower()
51
+ return "utf" not in enc
52
+
53
+
54
+ def width(lo: int = 50, hi: int = 100) -> int:
55
+ """The usable render width: the terminal columns, clamped so nothing overflows a narrow pane
56
+ or sprawls on an ultrawide one. Everything (rules, wraps, truncation) derives from this."""
57
+ try:
58
+ import shutil
59
+ cols = shutil.get_terminal_size((80, 24)).columns
60
+ except Exception:
61
+ cols = 80
62
+ return max(lo, min(hi, cols))
63
+
64
+
65
+ _ANSI = None
66
+
67
+
68
+ def visible_len(s: str) -> int:
69
+ """Column count ignoring ANSI SGR codes -- so framed right borders align even on colored text."""
70
+ global _ANSI
71
+ if _ANSI is None:
72
+ import re
73
+ _ANSI = re.compile(r"\033\[[0-9;]*m")
74
+ return len(_ANSI.sub("", s))
75
+
76
+
77
+ def frame(inner, label: str = "", width: int = 72, chrome: str = CHROME, color: bool = True):
78
+ """Wrap rendered content lines in a light box (└-style square corners, chrome-grey). Used
79
+ sparingly -- to visually group a distinct 'card' (a quoted synopsis, a callout) -- never as
80
+ default decoration. `inner` lines may contain ANSI; the right border is padded ANSI-aware."""
81
+ def fc(s):
82
+ return (chrome + s + RESET) if color and chrome else s
83
+ iw = width - 4 # inner content columns (│ + space ... space + │)
84
+ lab = f" {label} " if label else g("bar")
85
+ fill = max(0, width - 2 - len(lab) - 1) # ftl + [lab] + fill + ftr
86
+ out = [fc(g("ftl") + g("bar") + lab + g("bar") * fill + g("ftr"))]
87
+ for ln in inner:
88
+ pad = " " * max(0, iw - visible_len(ln))
89
+ out.append(fc(g("rail")) + " " + ln + pad + " " + fc(g("rail")))
90
+ out.append(fc(g("fbl") + g("bar") * (width - 2) + g("fbr")))
91
+ return out
92
+
93
+
94
+ def ellipsize(s: str, n: int) -> str:
95
+ """Truncate to n columns with a single-char ellipsis; never leaves a dangling separator."""
96
+ s = s or ""
97
+ if len(s) <= n:
98
+ return s
99
+ if n <= 1:
100
+ return s[:n]
101
+ return s[:n - 1].rstrip(" ·-/") + ("…" if not use_ascii() else "~")
102
+
103
+
104
+ def g(name: str) -> str:
105
+ return (_ASCII if use_ascii() else _G)[name]
106
+
107
+
108
+ class Painter:
109
+ """Small stateful painter so a renderer can `p = Painter(color)` then `p(text, PROVEN)`."""
110
+ def __init__(self, color: bool):
111
+ self.color = color
112
+
113
+ def __call__(self, s: str, code: str = "") -> str:
114
+ return f"{code}{s}{RESET}" if (self.color and code) else s
115
+
116
+ def rule(self, width: int = 76, code: str = CHROME) -> str:
117
+ return self(g("bar") * width, code)
118
+
119
+
120
+ def verdict_color(verdict: str) -> str:
121
+ from . import codes
122
+ if verdict in (codes.VERIFIED, codes.PASS):
123
+ return PROVEN
124
+ if verdict in (codes.REFUSED, codes.UNVERIFIABLE):
125
+ return REFUSED
126
+ if verdict == codes.FAIL:
127
+ return FAILC # a verified NO, not a crash
128
+ return FAULT
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: substratum-cli
3
+ Version: 0.1.0
4
+ Summary: Substratum: verified-or-refused code, with provenance. The terminal over the comprehension engine.
5
+ Author: Substratum
6
+ License: LicenseRef-Proprietary
7
+ Project-URL: Homepage, https://substratum-api.fly.dev
8
+ Keywords: code-generation,verification,deterministic,provenance,developer-tools
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Code Generators
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ Provides-Extra: engine
17
+ Requires-Dist: numpy>=1.24; extra == "engine"
18
+
19
+ # Substratum
20
+
21
+ **Verified-or-refused code, with provenance.** Substratum is a deterministic comprehension engine
22
+ for code. It never streams tokens and hopes — it produces a change only when that change passes a
23
+ gate, and otherwise returns an honest, actionable refusal. Every result carries a run id you can
24
+ replay byte-for-byte.
25
+
26
+ ```
27
+ pip install substratum-cli
28
+ ```
29
+
30
+ Then, in any repository:
31
+
32
+ ```
33
+ substratum # open the interactive session (warms, then drives)
34
+ ```
35
+
36
+ ## What it does
37
+
38
+ - **`summarize`** — describe the codebase in plain English, grounded in its real symbols (not a guess).
39
+ - **`failing`** — run the suite and list the failing tests; each becomes a ready fix target.
40
+ - **`verify`** — gate a diff (stdin, `--staged`, `--commit`): PASS / FAIL / per-hunk. The wedge — point
41
+ it at any tool's diff and it tells you, deterministically, whether the change is real.
42
+ - **`fix`** — produce a verified fix for a failing test, or a named refusal.
43
+ - **`write`** — greenfield code from plain intent (derive-or-refuse; no test required).
44
+ - **`runs` / `show` / `replay` / `undo` / `apply` / `commit`** — a proof-carrying memory of every run.
45
+
46
+ `summarize`, `failing`, and `verify` run **entirely on your machine** — no account, no network, no code
47
+ leaves your repo. They work air-gapped.
48
+
49
+ ## The hosted engine (optional)
50
+
51
+ `fix` and `write` draw on a large mined library. During the demo that library is hosted:
52
+
53
+ ```
54
+ substratum login # GitHub device flow; connects to the hosted engine
55
+ ```
56
+
57
+ When logged in, `write` sends only your intent + signature, and `fix` receives a *candidate* that your
58
+ machine then gates locally — so your code and your tests never leave your machine. `substratum logout`
59
+ returns to fully-local operation.
60
+
61
+ ## The law
62
+
63
+ Never render unproven code. A refusal is a deliverable, not an error. Determinism is a button you
64
+ press to catch us: run the same request twice and get the same run id, or `replay` any run and get a
65
+ byte-identical result.
66
+
67
+ Coverage grows with data. Today the engine refuses more than it resolves, by design — the surface is
68
+ built to feel complete at thin coverage, and the same commands silently resolve more as the library
69
+ scales, with zero change on your end.
@@ -0,0 +1,42 @@
1
+ substratum_cli/README.md,sha256=Fzt_fRbyrwNZnBO5vQ9aIlps_voQ-NA9rOcX7aialKk,2259
2
+ substratum_cli/__init__.py,sha256=GQLqd9kDC5Wh7CkuR5ZUrZkfkoLa62rwsXimK8UG2jM,301
3
+ substratum_cli/__main__.py,sha256=kKR2BJYlcJyeuv6cu675Pev9JPtDE13h_1PFuHRCUtA,138
4
+ substratum_cli/account.py,sha256=aQ8HwCHt_Q85mC6YF35LXFU74uq6wLsq8q9_E3Az6WM,1529
5
+ substratum_cli/cli.py,sha256=drrWFUy4jqhNKdw95yF4tpHNBBHIWJyJf7y75q5OVJw,8682
6
+ substratum_cli/codes.py,sha256=IrPLMi7bXSw5sLGu-yWg-geMYI_MIGKtsBJXTHOHAzU,5234
7
+ substratum_cli/config.py,sha256=1MurFz5Skq9b6RxZ52qc9HWaf20sLj_Jn1jXBSCnL7c,1800
8
+ substratum_cli/diffs.py,sha256=PdZjBN6ixGTXDImwffrv9sGFaSrok_ONe0rw7bWsclQ,3777
9
+ substratum_cli/engine.py,sha256=cywugUEjkLhZScat2-I43ajW4FCFeYsw-LfgshjlipM,6329
10
+ substratum_cli/gitio.py,sha256=jK_CN_Lk9sineIKWomCeKrw0tUqCUSCEyfGa_vYUvf4,4034
11
+ substratum_cli/langscan.py,sha256=xyWlvX34_PkYfxkSbhnGdcNbfeVOh4UyPgVF9L22tc0,4837
12
+ substratum_cli/product_ops.py,sha256=ZaDcjhCqyRXCo189i7hYgEUsxoG6O09GtLp9J8UI_bE,30044
13
+ substratum_cli/refusals.py,sha256=wW90inTuvGFgN9LM2vbClzeserQ-yCldly0nXQ6RjPE,6326
14
+ substratum_cli/remote.py,sha256=3C1vhdL5P_oUJETd_n16BZHL0klBS5wEgCDFhhC7SrU,5879
15
+ substratum_cli/render.py,sha256=z_N5fZFyvoMzzFWhJENM6AgZYQ-8Jl10SYNW7ql1IRc,17020
16
+ substratum_cli/result.py,sha256=ahMPgBEyR8WIKzOfi47SJh7WGyLih3vo6cDQksVWm6M,7612
17
+ substratum_cli/run_store.py,sha256=Ve1qkwZVyGMYrK0gUhhIRDifETD1sMFXxr6NefD1yhI,5939
18
+ substratum_cli/runid.py,sha256=a6xh6KQ9-UjysWc1Eu8eX1dZ0XFx_pw5lleXu5Ip_Y8,2808
19
+ substratum_cli/session.py,sha256=pSc7TDi_QZ3nQRaiFuwLBjuSxRKcOAQM5HQiHsB-9r0,26658
20
+ substratum_cli/style.py,sha256=E_-IfAww0Frv_fnQSFhIfN8ySFX0uxqaydgpEgYJO3k,5031
21
+ substratum_cli/_vendor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ substratum_cli/_vendor/_pro_test_derive.py,sha256=uZvW6wZ0wvfvqu6K2JuThIhDrTGACUNfAPWL5H-_TEs,7728
23
+ substratum_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ substratum_cli/commands/apply.py,sha256=eLcoCz-gAFg5kwEn4MtvclLij5_eMx7UnWgT_B60Xhw,2458
25
+ substratum_cli/commands/auth.py,sha256=dddOVNji5Aqdys57ZLhpvsOegjWEOQkvUwYrSa5wCTc,1234
26
+ substratum_cli/commands/commit.py,sha256=-noxEt3RFR3hsE41oKl7Fpczq5cWr3QkCtOGfHHpjA8,2069
27
+ substratum_cli/commands/explain.py,sha256=pEPAoImd9iI1mA9a69wndXWRJ_oYHph1VAe3I0TM0sQ,3011
28
+ substratum_cli/commands/failing.py,sha256=CT6aO3_k6bKjUUbPG_E0Aj1RSNXVSxqtgeNiHH9ns8A,3808
29
+ substratum_cli/commands/fix.py,sha256=CRWie3MZxg0yMpVhVQcvRRYWO6qmOW2vU0rTTO6jTVg,1968
30
+ substratum_cli/commands/history.py,sha256=GySClYcClMBF0aWL8e7rhvBX45nO3ICBR4mhuXB2lF0,762
31
+ substratum_cli/commands/init_cmd.py,sha256=B0a8Dhja0axKFnUvnjsJbo7fWXk78zfqD3NMj1Bz-wI,6446
32
+ substratum_cli/commands/replay.py,sha256=mERTsnMWctqEpLKN5ZKo5jXWmrWAUyRjSV-RQpjhg1g,3234
33
+ substratum_cli/commands/scaffold.py,sha256=r2oXNDvmQJ4wnAHCUjEHM42_UUNSu_JCEZONTHAzvQI,2888
34
+ substratum_cli/commands/show.py,sha256=tNrpHkw2Z6D2uvBRVr2VuIgw3SBX8HGUYw1WA5Gbqfw,747
35
+ substratum_cli/commands/undo.py,sha256=j05xTUSDolwxLYPPsjRq1wqNyEMFT22cto0rnwN3BM8,1457
36
+ substratum_cli/commands/verify.py,sha256=s5sh8DZ298vRBtciT3Vhdkg7_jxUbpNDzxD20C_JgFA,8989
37
+ substratum_cli/commands/write.py,sha256=fIok4BdA7lza2aNV7jCoOUQTWUmqbTgcDF4dyxxUJGw,1795
38
+ substratum_cli-0.1.0.dist-info/METADATA,sha256=494ln2VkcJ_u3fCLbOB0eC9SYIuOI4DVjAhOkb9lqug,2975
39
+ substratum_cli-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
40
+ substratum_cli-0.1.0.dist-info/entry_points.txt,sha256=Yl-xx8POZmRzUQRLBCYt2zGm9UyJzC10z1Sbc8TZgCE,55
41
+ substratum_cli-0.1.0.dist-info/top_level.txt,sha256=0PeZNTR-72BY-tLcRrBvAPmene4DuT0BZ1n74x7hY6o,15
42
+ substratum_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ substratum = substratum_cli.cli:main
@@ -0,0 +1 @@
1
+ substratum_cli