@r1z4x/tezgah 1.6.0 → 1.7.0
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.
- package/CHANGELOG.md +80 -1
- package/MANIFEST +5 -0
- package/README.md +6 -3
- package/bin/tezgah-docs +18 -16
- package/bin/tezgah-doctor +152 -0
- package/bin/tezgah-research +234 -10
- package/bin/tezgah-route +48 -1
- package/bin/tezgah-setup +26 -13
- package/bin/tezgah-task +589 -17
- package/bin/tezgah-taste +48 -10
- package/docs/architecture.md +7 -4
- package/docs/clarity-baseline.json +2 -2
- package/docs/contract.md +108 -24
- package/docs/evidence.md +201 -28
- package/docs/feature-audit.md +1 -1
- package/docs/gate.md +60 -22
- package/docs/glossary.md +4 -4
- package/docs/hosts.md +8 -8
- package/docs/index.json +11 -5
- package/docs/judge.md +9 -3
- package/docs/models.md +35 -2
- package/docs/operations.md +103 -3
- package/docs/research.md +346 -13
- package/docs/skills.md +1 -1
- package/docs/status-line.md +5 -5
- package/docs/testing.md +2 -2
- package/docs/vision.md +12 -4
- package/hooks/hooks.json +2 -2
- package/hooks/lang/en.json +323 -0
- package/hooks/lang/tr.json +344 -0
- package/hooks/projects-posttooluse.py +24 -5
- package/hooks/projects-pretooluse.py +9 -4
- package/hooks/projects-stop.py +28 -16
- package/hooks/tezgah_agents.py +29 -10
- package/hooks/tezgah_clarity.py +7 -3
- package/hooks/tezgah_context.py +425 -406
- package/hooks/tezgah_gate.py +583 -33
- package/hooks/tezgah_integrity.py +1480 -197
- package/hooks/tezgah_models.py +337 -15
- package/hooks/tezgah_paths.py +103 -10
- package/hooks/tezgah_policy.py +258 -126
- package/hooks/tezgah_rank.py +29 -27
- package/hooks/tezgah_replay.py +200 -30
- package/hooks/tezgah_research.py +1294 -9
- package/hooks/tezgah_stopspec.py +7 -0
- package/hooks/tezgah_store.py +74 -27
- package/hooks/tezgah_task.py +915 -6
- package/hosts/codex/hook.py +9 -10
- package/hosts/cursor/hook.py +21 -14
- package/hosts/dsh/hooks.json +2 -2
- package/hosts/omp/hook.py +44 -23
- package/hosts/omp/tezgah-hook.ts.in +93 -7
- package/hosts/opencode/plugins/tezgah.js +102 -2
- package/output-styles/tezgah.md +76 -42
- package/package.json +1 -1
- package/skills/i-have-adhd/EVALS.md +22 -2
- package/skills/i-have-adhd/SKILL.md +12 -5
- package/skills/plan-add/SKILL.md +5 -3
- package/skills/plan-sync/SKILL.md +5 -3
- package/skills/ponytail/EVALS.md +21 -2
- package/skills/ponytail/SKILL.md +4 -4
- package/skills/research/SKILL.md +89 -1
- package/skills/tezgah-contract/EVALS.md +52 -7
- package/skills/tezgah-contract/SKILL.md +151 -56
package/bin/tezgah-research
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
"""tezgah-research - the research workspace CLI.
|
|
3
3
|
|
|
4
4
|
tezgah-research init <slug> --ask "<the user's words>" [--question "..."]
|
|
5
|
-
[--method qualitative|measured] [--in "<covered>"]...
|
|
6
|
-
[--allow-open "<why>"] [--supersedes <slug>]
|
|
5
|
+
[--method qualitative|measured|exploratory] [--in "<covered>"]...
|
|
6
|
+
[--out "<left alone>"]... [--allow-open "<why>"] [--supersedes <slug>]
|
|
7
|
+
[--arena "<problem>" --budget "<budget>" [--evaluator <path> --metric "<m>"]]
|
|
8
|
+
scaffold a line
|
|
7
9
|
tezgah-research commit <slug> "<message>" commit the line in .tezgah's own repo
|
|
8
10
|
tezgah-research check [<slug>] [--json] [--strict] [--orx] [--all-lines] [-- <slug>]
|
|
9
11
|
the discipline checks
|
|
@@ -27,6 +29,14 @@
|
|
|
27
29
|
bring lines from another checkout, with history
|
|
28
30
|
tezgah-research next --topic <t> [--flow metric-dashboard|feature] [--json]
|
|
29
31
|
the product-flow steps of a topic and the next one
|
|
32
|
+
tezgah-research idea <slug> record one idea of an exploratory line from stdin
|
|
33
|
+
tezgah-research stage <slug> <idea> <stage> [--evidence "<ref or JSON>"] [--reason "<why>"]
|
|
34
|
+
move an idea to its next stage
|
|
35
|
+
tezgah-research match <slug> record one judged tournament match from stdin
|
|
36
|
+
tezgah-research board <slug> [--json] each idea's stage, score and next action
|
|
37
|
+
tezgah-research dedup <slug> [--threshold <(0,1]>] [--json]
|
|
38
|
+
cluster the proposed ideas, write nothing
|
|
39
|
+
tezgah-research yield [--json] [--all-lines] how far ideas got, per operator and family
|
|
30
40
|
|
|
31
41
|
A research line lives at <repo>/.tezgah/research/<slug>/ and holds the state an
|
|
32
42
|
auditable investigation needs: the question, the decision log, the findings, the
|
|
@@ -95,10 +105,18 @@ without it is refused. `compare` appends one cell to
|
|
|
95
105
|
`check` prints the same list of open lines after the per-line report, and so does
|
|
96
106
|
`status`, so neither state has to be discovered by being refused.
|
|
97
107
|
|
|
108
|
+
`init --method exploratory` (rules 7) opens a campaign instead of a question:
|
|
109
|
+
`--arena` and `--budget` (and, for a measurable arena, `--evaluator` with its
|
|
110
|
+
`--metric`, whose sha256 `init` records) are the lock committed before the
|
|
111
|
+
first idea. `idea`, `stage` and `match` append the campaign's rows under the
|
|
112
|
+
lock, each judged by the one function `check` applies to it; a `prior-art`
|
|
113
|
+
stage whose verdict is `known` takes `--reason` and is killed in the same
|
|
114
|
+
append. `board`, `dedup` and `yield` are reports: they write nothing and exit 0.
|
|
115
|
+
|
|
98
116
|
Exit codes: 0 clean, 1 problems found - a broken line for `check`, a refused
|
|
99
|
-
claim for `claim`, a refused row for `predict`,
|
|
100
|
-
one reason per problem, or a new line refused for
|
|
101
|
-
misuse.
|
|
117
|
+
claim for `claim`, a refused row for `predict`, `idea`, `stage` or `match`, which
|
|
118
|
+
writes nothing and prints one reason per problem, or a new line refused for
|
|
119
|
+
`init` over unfinished ones - 2 misuse.
|
|
102
120
|
"""
|
|
103
121
|
import json
|
|
104
122
|
import os
|
|
@@ -145,6 +163,7 @@ def cmd_init(args):
|
|
|
145
163
|
"and dashes" % args[0])
|
|
146
164
|
question, allow, supersedes = "", None, None
|
|
147
165
|
ask, tier, method, scope_in, scope_out = "", str(tr.DEFAULT_TIER), "", [], []
|
|
166
|
+
arena = {}
|
|
148
167
|
rest = args[1:]
|
|
149
168
|
while rest:
|
|
150
169
|
flag = rest.pop(0)
|
|
@@ -164,11 +183,34 @@ def cmd_init(args):
|
|
|
164
183
|
allow = rest.pop(0)
|
|
165
184
|
elif flag == "--supersedes" and rest:
|
|
166
185
|
supersedes = rest.pop(0)
|
|
186
|
+
elif flag in ("--arena", "--budget", "--evaluator", "--metric") and rest \
|
|
187
|
+
and flag not in arena:
|
|
188
|
+
arena[flag] = rest.pop(0)
|
|
167
189
|
else:
|
|
168
190
|
return misuse('init <slug> --ask "<the user\'s words>" [--tier quick|study|program]'
|
|
169
|
-
' [--method qualitative|measured] [--in "<covered>"]...'
|
|
191
|
+
' [--method qualitative|measured|exploratory] [--in "<covered>"]...'
|
|
170
192
|
' [--out "<left alone>"]... [--question "..."]'
|
|
171
|
-
' [--allow-open "<reason>"] [--supersedes <slug>]'
|
|
193
|
+
' [--allow-open "<reason>"] [--supersedes <slug>]'
|
|
194
|
+
' [--arena "<problem>" --budget "<budget>"'
|
|
195
|
+
' [--evaluator <path> --metric "<metric>"]]')
|
|
196
|
+
if method == "exploratory":
|
|
197
|
+
# The arena is the lock an exploratory line commits before its first idea,
|
|
198
|
+
# so a line without one is a call that cannot work, not a line to repair.
|
|
199
|
+
if not all(arena.get(f, "").strip() for f in ("--arena", "--budget")):
|
|
200
|
+
return misuse('--method exploratory needs --arena "<the problem, verbatim>" '
|
|
201
|
+
'and --budget "<ideas, pilots, full runs, wall time>"')
|
|
202
|
+
if bool(arena.get("--evaluator", "").strip()) != bool(
|
|
203
|
+
arena.get("--metric", "").strip()):
|
|
204
|
+
return misuse("--evaluator and --metric go together: the file that scores a "
|
|
205
|
+
"candidate and the number it returns")
|
|
206
|
+
evaluator = arena.get("--evaluator", "").strip()
|
|
207
|
+
if evaluator and (os.path.isabs(evaluator) or ".." in evaluator.split("/")
|
|
208
|
+
or not os.path.isfile(os.path.join(repo_root(os.getcwd()),
|
|
209
|
+
evaluator))):
|
|
210
|
+
return misuse("--evaluator %r is not a file under the repository" % evaluator)
|
|
211
|
+
elif arena:
|
|
212
|
+
return misuse("--arena, --budget, --evaluator and --metric belong to "
|
|
213
|
+
"--method exploratory")
|
|
172
214
|
problems = tr.ask_problems(ask, tier)
|
|
173
215
|
if problems:
|
|
174
216
|
for problem in problems:
|
|
@@ -211,9 +253,14 @@ def cmd_init(args):
|
|
|
211
253
|
"init %s --supersedes %s" % (", ".join(twins), slug, twins[0]))
|
|
212
254
|
return 1
|
|
213
255
|
created = time.strftime("%Y-%m-%d")
|
|
256
|
+
record = None
|
|
257
|
+
if method == "exploratory":
|
|
258
|
+
record = tr.arena_record(repo, arena["--arena"], arena["--budget"],
|
|
259
|
+
arena.get("--evaluator", "").strip(),
|
|
260
|
+
arena.get("--metric", "").strip())
|
|
214
261
|
made = tr.init(repo, slug, question=question, created=created,
|
|
215
262
|
supersedes=supersedes, ask=ask, tier=tier, method=method,
|
|
216
|
-
scope_in=scope_in, scope_out=scope_out)
|
|
263
|
+
scope_in=scope_in, scope_out=scope_out, arena=record)
|
|
217
264
|
if allow is not None:
|
|
218
265
|
problem = tr.note_open(repo, slug, allow, created)
|
|
219
266
|
if problem:
|
|
@@ -224,7 +271,14 @@ def cmd_init(args):
|
|
|
224
271
|
print(" wrote %s" % path)
|
|
225
272
|
for problem in tr.scope_problems(tr.line_state(repo, slug)):
|
|
226
273
|
print(" owed: %s" % problem)
|
|
227
|
-
if method == "
|
|
274
|
+
if method == "exploratory":
|
|
275
|
+
print("\nnext: commit the arena now, before any idea - `tezgah-research commit "
|
|
276
|
+
"%s \"arena\"`; an idea committed with it or before it is refused. Then "
|
|
277
|
+
"record ideas (`tezgah-research idea %s`, one JSON row on stdin, each "
|
|
278
|
+
"naming its operator, generator and kill result), commit them, and "
|
|
279
|
+
"follow `tezgah-research board %s`: dedup, prior art, matches, pilots, a "
|
|
280
|
+
"full run, a confirmation on unseen data." % (slug, slug, slug))
|
|
281
|
+
elif method == "qualitative":
|
|
228
282
|
print("\nnext: read the primary sources for each state.json scope.in item "
|
|
229
283
|
"(`orx discover`, `orx paper`), save each to literature/ as you read "
|
|
230
284
|
"it, and record every claim with a `trace` naming the S<n> it answers "
|
|
@@ -589,6 +643,172 @@ def cmd_compare(args):
|
|
|
589
643
|
return 0
|
|
590
644
|
|
|
591
645
|
|
|
646
|
+
def _campaign_slug(args, usage, count=1):
|
|
647
|
+
"""(repo, slug, None) for a campaign command's line, or (None, None, exit code)."""
|
|
648
|
+
if len(args) < count:
|
|
649
|
+
return None, None, misuse(usage)
|
|
650
|
+
repo = repo_root(os.getcwd())
|
|
651
|
+
known = tr.slugs(repo)
|
|
652
|
+
if args[0] not in known:
|
|
653
|
+
return None, None, misuse("no such research line (have: %s)"
|
|
654
|
+
% (", ".join(known) or "none"))
|
|
655
|
+
return repo, args[0], None
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
def _stdin_row(what):
|
|
659
|
+
"""(row, None) for the one JSON object on stdin, or (None, exit code)."""
|
|
660
|
+
try:
|
|
661
|
+
body = sys.stdin.buffer.read().decode("utf-8")
|
|
662
|
+
row = json.loads(body)
|
|
663
|
+
except (UnicodeDecodeError, ValueError):
|
|
664
|
+
return None, misuse("%s needs one JSON object on stdin" % what)
|
|
665
|
+
if not isinstance(row, dict):
|
|
666
|
+
return None, misuse("%s needs one JSON object on stdin" % what)
|
|
667
|
+
return row, None
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
def _refused(slug, problems):
|
|
671
|
+
for problem in problems:
|
|
672
|
+
print("FAIL %s: %s" % (slug, problem))
|
|
673
|
+
return 1 if problems else 0
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def cmd_idea(args):
|
|
677
|
+
"""Record one idea of an exploratory line from stdin (`append_idea`)."""
|
|
678
|
+
repo, slug, code = _campaign_slug(args, "idea <slug>")
|
|
679
|
+
if code is not None or len(args) != 1:
|
|
680
|
+
return code if code is not None else misuse("idea <slug>")
|
|
681
|
+
row, code = _stdin_row("idea")
|
|
682
|
+
if code is not None:
|
|
683
|
+
return code
|
|
684
|
+
try:
|
|
685
|
+
iid, problems = tr.append_idea(repo, slug, row)
|
|
686
|
+
except OSError as exc:
|
|
687
|
+
iid, problems = row.get("id"), ["cannot append to ideas.jsonl: %s" % exc]
|
|
688
|
+
if _refused(slug, problems):
|
|
689
|
+
return 1
|
|
690
|
+
print("idea %s recorded" % iid)
|
|
691
|
+
return 0
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
def cmd_stage(args):
|
|
695
|
+
"""Move one idea to a stage, with the evidence that stage takes (a path or a
|
|
696
|
+
JSON object) and the reason a kill - or a known prior art - owes."""
|
|
697
|
+
usage = ('stage <slug> <idea> <stage> [--evidence "<ref or JSON>"] '
|
|
698
|
+
'[--reason "<why>"]')
|
|
699
|
+
repo, slug, code = _campaign_slug(args, usage, 3)
|
|
700
|
+
if code is not None:
|
|
701
|
+
return code
|
|
702
|
+
row = {"idea": args[1], "stage": args[2]}
|
|
703
|
+
reason, rest = None, args[3:]
|
|
704
|
+
while rest:
|
|
705
|
+
flag = rest.pop(0)
|
|
706
|
+
if flag == "--evidence" and rest and "evidence" not in row:
|
|
707
|
+
text = rest.pop(0)
|
|
708
|
+
try:
|
|
709
|
+
row["evidence"] = json.loads(text) if text.lstrip()[:1] in "{[" \
|
|
710
|
+
and text.strip() else text
|
|
711
|
+
except ValueError:
|
|
712
|
+
return misuse("--evidence starts like JSON and does not parse")
|
|
713
|
+
elif flag == "--reason" and rest and reason is None:
|
|
714
|
+
reason = rest.pop(0)
|
|
715
|
+
else:
|
|
716
|
+
return misuse(usage)
|
|
717
|
+
row["date"] = time.strftime("%Y-%m-%d")
|
|
718
|
+
kill_reason = None
|
|
719
|
+
if row["stage"] == "killed":
|
|
720
|
+
row["reason"] = reason
|
|
721
|
+
else:
|
|
722
|
+
kill_reason = reason
|
|
723
|
+
try:
|
|
724
|
+
problems = tr.append_stage(repo, slug, {k: v for k, v in row.items()
|
|
725
|
+
if v is not None}, kill_reason)
|
|
726
|
+
except OSError as exc:
|
|
727
|
+
problems = ["cannot append to stages.jsonl: %s" % exc]
|
|
728
|
+
if _refused(slug, problems):
|
|
729
|
+
return 1
|
|
730
|
+
killed = row["stage"] == "prior-art" and kill_reason \
|
|
731
|
+
and isinstance(row.get("evidence"), dict) \
|
|
732
|
+
and row["evidence"].get("verdict") == "known"
|
|
733
|
+
print("%s: %s recorded%s" % (row["idea"], row["stage"],
|
|
734
|
+
" and killed (%s)" % kill_reason if killed else ""))
|
|
735
|
+
return 0
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def cmd_match(args):
|
|
739
|
+
"""Record one judged tournament match from stdin (`append_match`)."""
|
|
740
|
+
repo, slug, code = _campaign_slug(args, "match <slug>")
|
|
741
|
+
if code is not None or len(args) != 1:
|
|
742
|
+
return code if code is not None else misuse("match <slug>")
|
|
743
|
+
row, code = _stdin_row("match")
|
|
744
|
+
if code is not None:
|
|
745
|
+
return code
|
|
746
|
+
try:
|
|
747
|
+
problems = tr.append_match(repo, slug, row)
|
|
748
|
+
except OSError as exc:
|
|
749
|
+
problems = ["cannot append to tournament.jsonl: %s" % exc]
|
|
750
|
+
if _refused(slug, problems):
|
|
751
|
+
return 1
|
|
752
|
+
print("match %s v %s recorded" % (row.get("a"), row.get("b")))
|
|
753
|
+
return 0
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
def cmd_board(args):
|
|
757
|
+
"""The campaign's board: a report a fresh session resumes from, exit 0."""
|
|
758
|
+
flags = [a for a in args if a != "--json"]
|
|
759
|
+
repo, slug, code = _campaign_slug(flags, "board <slug> [--json]")
|
|
760
|
+
if code is not None or len(flags) != 1:
|
|
761
|
+
return code if code is not None else misuse("board <slug> [--json]")
|
|
762
|
+
report = tr.board(repo, slug)
|
|
763
|
+
if "--json" in args:
|
|
764
|
+
print(json.dumps(report, indent=2))
|
|
765
|
+
return 0
|
|
766
|
+
for line in tr.board_text(report):
|
|
767
|
+
print(line)
|
|
768
|
+
return 0
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def cmd_dedup(args):
|
|
772
|
+
"""Cluster the proposed ideas by statement; writes nothing, exit 0."""
|
|
773
|
+
usage = "dedup <slug> [--threshold <(0,1]>] [--json]"
|
|
774
|
+
rest, threshold, as_json = list(args), None, False
|
|
775
|
+
if "--json" in rest:
|
|
776
|
+
rest.remove("--json")
|
|
777
|
+
as_json = True
|
|
778
|
+
if "--threshold" in rest:
|
|
779
|
+
i = rest.index("--threshold")
|
|
780
|
+
try:
|
|
781
|
+
threshold = float(rest[i + 1])
|
|
782
|
+
except (IndexError, ValueError):
|
|
783
|
+
return misuse(usage)
|
|
784
|
+
if not 0 < threshold <= 1:
|
|
785
|
+
return misuse("--threshold is a similarity in (0, 1]")
|
|
786
|
+
rest = rest[:i] + rest[i + 2:]
|
|
787
|
+
repo, slug, code = _campaign_slug(rest, usage)
|
|
788
|
+
if code is not None or len(rest) != 1:
|
|
789
|
+
return code if code is not None else misuse(usage)
|
|
790
|
+
report = tr.dedup(repo, slug, threshold)
|
|
791
|
+
if as_json:
|
|
792
|
+
print(json.dumps(report, indent=2))
|
|
793
|
+
return 0
|
|
794
|
+
for line in tr.dedup_text(report, slug):
|
|
795
|
+
print(line)
|
|
796
|
+
return 0
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
def cmd_yield(args):
|
|
800
|
+
"""Per operator and generator family, how far the ideas got; exit 0."""
|
|
801
|
+
if [a for a in args if a not in ("--json", "--all-lines")]:
|
|
802
|
+
return misuse("yield [--json] [--all-lines]")
|
|
803
|
+
report = tr.yield_report(repo_root(os.getcwd()), all_lines="--all-lines" in args)
|
|
804
|
+
if "--json" in args:
|
|
805
|
+
print(json.dumps(report, indent=2))
|
|
806
|
+
return 0
|
|
807
|
+
for line in tr.yield_text(report):
|
|
808
|
+
print(line)
|
|
809
|
+
return 0
|
|
810
|
+
|
|
811
|
+
|
|
592
812
|
def cmd_next(args):
|
|
593
813
|
"""The product-flow steps of one topic with their status, then the first
|
|
594
814
|
missing or due step's skill and command; a report, so exit 0."""
|
|
@@ -830,9 +1050,13 @@ def main(argv):
|
|
|
830
1050
|
return cmd_seal(rest)
|
|
831
1051
|
if cmd == "import":
|
|
832
1052
|
return cmd_import(rest)
|
|
1053
|
+
campaign = {"idea": cmd_idea, "stage": cmd_stage, "match": cmd_match,
|
|
1054
|
+
"board": cmd_board, "dedup": cmd_dedup, "yield": cmd_yield}
|
|
1055
|
+
if cmd in campaign:
|
|
1056
|
+
return campaign[cmd](rest)
|
|
833
1057
|
return misuse("unknown command %r (init, commit, check, status, --all, claim, predict, "
|
|
834
1058
|
"components, migrate, source, compare, verdict, conclude, migrate-layout, "
|
|
835
|
-
"close, seal, import, next)" % cmd)
|
|
1059
|
+
"close, seal, import, next, idea, stage, match, board, dedup, yield)" % cmd)
|
|
836
1060
|
|
|
837
1061
|
|
|
838
1062
|
if __name__ == "__main__":
|
package/bin/tezgah-route
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
tezgah-route --refresh re-read prices/ids (OpenRouter),
|
|
7
7
|
resolve opencode selectors
|
|
8
8
|
tezgah-route --mode auto|anthropic|any omp's family, then re-apply omp
|
|
9
|
+
tezgah-route --health probe the other funded families;
|
|
10
|
+
one at a limit leaves the chain
|
|
11
|
+
until its reset; re-apply omp
|
|
12
|
+
tezgah-route --fallback vendor|any|none what a chain falls back to, then
|
|
13
|
+
re-apply omp
|
|
9
14
|
tezgah-route --report each route's first check, by tier
|
|
10
15
|
|
|
11
16
|
A brief naming stored data, a migration, credentials, the gate or security goes to
|
|
@@ -39,12 +44,14 @@ import argparse
|
|
|
39
44
|
import json
|
|
40
45
|
import os
|
|
41
46
|
import sys
|
|
47
|
+
import time
|
|
42
48
|
|
|
43
49
|
HERE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
44
50
|
sys.path.insert(0, os.path.join(HERE, "hooks"))
|
|
45
51
|
import tezgah_integrity as ti # noqa: E402
|
|
46
52
|
import tezgah_judge # noqa: E402
|
|
47
53
|
import tezgah_models as tm # noqa: E402
|
|
54
|
+
import tezgah_paths as tp # noqa: E402
|
|
48
55
|
|
|
49
56
|
|
|
50
57
|
def main(argv):
|
|
@@ -62,6 +69,12 @@ def main(argv):
|
|
|
62
69
|
parser.add_argument("--refresh", action="store_true",
|
|
63
70
|
help="re-read prices and ids, resolve opencode selectors")
|
|
64
71
|
parser.add_argument("--mode", choices=tm.MODES, help="omp's family, then re-apply")
|
|
72
|
+
parser.add_argument("--health", action="store_true",
|
|
73
|
+
help="probe the other funded families, record the ones at a "
|
|
74
|
+
"limit until their reset, then re-apply omp's chain")
|
|
75
|
+
parser.add_argument("--fallback", choices=tp.FALLBACKS,
|
|
76
|
+
help="which families a chain falls back to (config.json "
|
|
77
|
+
"`fallback`), then re-apply")
|
|
65
78
|
parser.add_argument("--report", action="store_true",
|
|
66
79
|
help="every ledger's routes joined to the first check after each")
|
|
67
80
|
args = parser.parse_args(argv[1:])
|
|
@@ -89,6 +102,40 @@ def main(argv):
|
|
|
89
102
|
print(line("%s %s" % (via, tier), counts))
|
|
90
103
|
print(line("jev-below-static", below))
|
|
91
104
|
return 0
|
|
105
|
+
if args.fallback:
|
|
106
|
+
# config.json `fallback` has one other writer: none. A config that does not
|
|
107
|
+
# parse is refused, not replaced (like tezgah-setup --jev).
|
|
108
|
+
try:
|
|
109
|
+
with open(tp.CONFIG, encoding="utf-8") as fh:
|
|
110
|
+
cfg = json.load(fh)
|
|
111
|
+
except FileNotFoundError:
|
|
112
|
+
cfg = {}
|
|
113
|
+
except (OSError, ValueError):
|
|
114
|
+
print("%s is not valid JSON; fallback not set" % tp.CONFIG, file=sys.stderr)
|
|
115
|
+
return 1
|
|
116
|
+
if cfg.get("fallback") != args.fallback:
|
|
117
|
+
cfg["fallback"] = args.fallback
|
|
118
|
+
os.makedirs(os.path.dirname(tp.CONFIG), exist_ok=True)
|
|
119
|
+
tmp = tp.CONFIG + ".tmp"
|
|
120
|
+
with open(tmp, "w", encoding="utf-8") as fh:
|
|
121
|
+
json.dump(cfg, fh, indent=2, sort_keys=True)
|
|
122
|
+
fh.write("\n")
|
|
123
|
+
os.replace(tmp, tp.CONFIG)
|
|
124
|
+
print("fallback: %s (%s)" % (args.fallback, tp.CONFIG))
|
|
125
|
+
print(tm.apply_omp() or "omp not answering; the chain applies at the next setup")
|
|
126
|
+
return 0
|
|
127
|
+
if args.health:
|
|
128
|
+
mode = tm.omp_mode()
|
|
129
|
+
data = tm.refresh_health(mode)
|
|
130
|
+
for family in tm.funded_families(live=False):
|
|
131
|
+
row = data["down"].get(family)
|
|
132
|
+
state = ("the mode's own family, not probed" if family == mode else
|
|
133
|
+
"down until %s - %s" % (time.strftime("%Y-%m-%d %H:%M",
|
|
134
|
+
time.localtime(row["until"])),
|
|
135
|
+
row.get("reason", "")) if row else "up")
|
|
136
|
+
print("%s: %s" % (family, state))
|
|
137
|
+
print(tm.apply_omp() or "omp not answering; the chain applies at the next setup")
|
|
138
|
+
return 0
|
|
92
139
|
if args.mode:
|
|
93
140
|
data = tm.overlay()
|
|
94
141
|
data.pop("mode", None)
|
|
@@ -102,7 +149,7 @@ def main(argv):
|
|
|
102
149
|
return 0
|
|
103
150
|
if not brief:
|
|
104
151
|
print("usage: tezgah-route \"<brief>\" [--phase P] [--json] | --check | --refresh "
|
|
105
|
-
"| --mode M | --report", file=sys.stderr)
|
|
152
|
+
"| --mode M | --health | --fallback F | --report", file=sys.stderr)
|
|
106
153
|
return 2
|
|
107
154
|
ask = tezgah_judge.ask if tezgah_judge.available() else None
|
|
108
155
|
out = tm.route(brief, args.phase, ask)
|
package/bin/tezgah-setup
CHANGED
|
@@ -233,8 +233,9 @@ MATERIALISED = os.path.join(tp.CONFIG_DIR, "materialised")
|
|
|
233
233
|
# name too - a switch left behind is a rule that stays silent with no file saying why.
|
|
234
234
|
OFF_SWITCH_NAMES = ("adhd-off", "agents-off", "consult-off", "docs-judge-off", "exec-mode.off",
|
|
235
235
|
"judge-off", "lang-off", "orchestrate-off", "ponytail-auto.off",
|
|
236
|
-
"pretooluse-off", "reminder-off", "research-off", "
|
|
237
|
-
"
|
|
236
|
+
"pretooluse-off", "reminder-off", "research-off", "slices-off",
|
|
237
|
+
"spec-off", "task-off", "triage-off", "update-check-off", "verify-off",
|
|
238
|
+
"workspace-off")
|
|
238
239
|
# The ~/.config/tezgah entries this installer generates. A full uninstall
|
|
239
240
|
# removes exactly these (plus any `*.off` switch and the `.tezgah-bak` of one of
|
|
240
241
|
# these names) and keeps anything else: a file the user put there is not
|
|
@@ -314,9 +315,11 @@ CURSOR_HOOK_EVENTS = {
|
|
|
314
315
|
# makes a config written before this existed behave exactly as it used to.
|
|
315
316
|
# --enable/--disable/--devtools and the wizard set it before anything is written.
|
|
316
317
|
FEATURES = None
|
|
317
|
-
# The `
|
|
318
|
-
#
|
|
319
|
-
|
|
318
|
+
# The `language` this run stores (--language, or its older spelling
|
|
319
|
+
# --reply-lang); None keeps what config.json says. A first install with no flag
|
|
320
|
+
# takes the environment's (`tp.env_language`); a config made before the key
|
|
321
|
+
# existed is pinned to `tr`, the default it ran under (tezgah_paths.language).
|
|
322
|
+
LANGUAGE = None
|
|
320
323
|
OK, NO = " ok ", " MISS "
|
|
321
324
|
|
|
322
325
|
|
|
@@ -1028,6 +1031,10 @@ def install_common(new_roots, hosts):
|
|
|
1028
1031
|
cfg = read_config(tp.CONFIG, {})
|
|
1029
1032
|
own = cfg is not None
|
|
1030
1033
|
cfg = cfg if own else {}
|
|
1034
|
+
# a first install is a config no install wrote yet: `--jev` alone writes
|
|
1035
|
+
# the file too, so its existence says nothing; an install always writes
|
|
1036
|
+
# `roots` and `prefix`
|
|
1037
|
+
first = not any(key in cfg for key in ("roots", "prefix"))
|
|
1031
1038
|
cfg["roots"] = [expand(r) for r in new_roots] if new_roots else \
|
|
1032
1039
|
(tp.roots() or [tp.DEFAULT_ROOT])
|
|
1033
1040
|
if tp.codegraph_bin():
|
|
@@ -1044,8 +1051,13 @@ def install_common(new_roots, hosts):
|
|
|
1044
1051
|
# anywhere, so it moves the tree the install actually used instead of the
|
|
1045
1052
|
# XDG default. An explicit --prefix or TEZGAH_PREFIX still wins over it.
|
|
1046
1053
|
cfg["prefix"] = INSTALL_PREFIX
|
|
1047
|
-
if
|
|
1048
|
-
cfg["
|
|
1054
|
+
if LANGUAGE:
|
|
1055
|
+
cfg["language"] = LANGUAGE
|
|
1056
|
+
elif not any(key in cfg for key in ("language", "reply_lang")):
|
|
1057
|
+
# an existing `reply_lang` is never rewritten; only a config with
|
|
1058
|
+
# neither key gets one: the locale's on a first install, `tr` on an
|
|
1059
|
+
# older one, so an upgrade changes no one's reply language
|
|
1060
|
+
cfg["language"] = tp.env_language() if first else "tr"
|
|
1049
1061
|
if own:
|
|
1050
1062
|
write_json(tp.CONFIG, cfg)
|
|
1051
1063
|
print("%s %s roots=%s" % (OK, tp.CONFIG, cfg["roots"]))
|
|
@@ -5520,7 +5532,7 @@ def upgrade(version, dry_run):
|
|
|
5520
5532
|
so its farm links would point back into it. The hosts and roots come from
|
|
5521
5533
|
config.json, so an upgrade does not re-ask the install questions. Nothing
|
|
5522
5534
|
else calls this: a flag never upgrades tezgah as a side effect of another
|
|
5523
|
-
(hooks/tezgah_policy.py:
|
|
5535
|
+
(hooks/tezgah_policy.py:812). Prints every step before running it, and
|
|
5524
5536
|
`--dry-run` stops after the printing."""
|
|
5525
5537
|
cfg = tp.config()
|
|
5526
5538
|
hosts = cfg.get("hosts") or detected_hosts()
|
|
@@ -5713,10 +5725,11 @@ def main(argv):
|
|
|
5713
5725
|
version=tezgah_context.version() or "unknown")
|
|
5714
5726
|
ap.add_argument("--roots")
|
|
5715
5727
|
ap.add_argument("--hosts")
|
|
5716
|
-
ap.add_argument("--reply-lang", choices=tp.
|
|
5728
|
+
ap.add_argument("--language", "--reply-lang", choices=tp.languages(),
|
|
5717
5729
|
help="with --install: the language replies are asked for and "
|
|
5718
|
-
"the Stop rule checks (config.json `
|
|
5719
|
-
"
|
|
5730
|
+
"the Stop rule checks (config.json `language`; a first "
|
|
5731
|
+
"install takes LANGUAGE/LC_ALL/LC_MESSAGES/LANG, `en` "
|
|
5732
|
+
"when none names a pack; `any` checks none)")
|
|
5720
5733
|
ap.add_argument("--jev", type=tp.jev_name, choices=tp.JEV_CHOICES,
|
|
5721
5734
|
help="the carrier the judgement seam reaches the Jev model "
|
|
5722
5735
|
"through (config.json `jev`; `auto` tries every one "
|
|
@@ -5736,9 +5749,9 @@ def main(argv):
|
|
|
5736
5749
|
# so it is taken off before the flags are parsed (`--dry-run` still reads)
|
|
5737
5750
|
command = argv[1:2] == ["update"]
|
|
5738
5751
|
args = ap.parse_args(argv[2:] if command else argv[1:])
|
|
5739
|
-
global FEATURES, INSTALL_PREFIX, HOST_DEPS,
|
|
5752
|
+
global FEATURES, INSTALL_PREFIX, HOST_DEPS, LANGUAGE
|
|
5740
5753
|
HOST_DEPS = args.host_deps
|
|
5741
|
-
|
|
5754
|
+
LANGUAGE = args.language
|
|
5742
5755
|
select_code = 0
|
|
5743
5756
|
# --devtools is --enable <id> and nothing else: one code path, so the flag
|
|
5744
5757
|
# cannot reach the selection in a way the explicit command does not.
|