@r1z4x/tezgah 1.5.1 → 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.
Files changed (81) hide show
  1. package/CHANGELOG.md +126 -1
  2. package/MANIFEST +11 -0
  3. package/README.md +6 -3
  4. package/bin/consult +13 -10
  5. package/bin/tezgah-docs +18 -16
  6. package/bin/tezgah-doctor +152 -0
  7. package/bin/tezgah-research +286 -12
  8. package/bin/tezgah-route +48 -1
  9. package/bin/tezgah-setup +27 -14
  10. package/bin/tezgah-task +771 -46
  11. package/bin/tezgah-taste +48 -10
  12. package/docs/architecture.md +7 -4
  13. package/docs/citations-baseline.json +1 -1
  14. package/docs/clarity-baseline.json +5 -5
  15. package/docs/contract.md +112 -25
  16. package/docs/evidence.md +201 -28
  17. package/docs/feature-audit.md +25 -4
  18. package/docs/gate.md +70 -33
  19. package/docs/glossary.md +4 -4
  20. package/docs/hosts.md +8 -8
  21. package/docs/index.json +30 -10
  22. package/docs/judge.md +9 -3
  23. package/docs/models.md +35 -2
  24. package/docs/operations.md +103 -3
  25. package/docs/research.md +392 -13
  26. package/docs/skills.md +24 -6
  27. package/docs/status-line.md +5 -5
  28. package/docs/testing.md +2 -2
  29. package/docs/vision.md +12 -4
  30. package/hooks/hooks.json +2 -2
  31. package/hooks/lang/en.json +323 -0
  32. package/hooks/lang/tr.json +344 -0
  33. package/hooks/projects-posttooluse.py +24 -5
  34. package/hooks/projects-pretooluse.py +9 -4
  35. package/hooks/projects-stop.py +28 -16
  36. package/hooks/tezgah_agents.py +29 -9
  37. package/hooks/tezgah_clarity.py +7 -3
  38. package/hooks/tezgah_components.py +2 -1
  39. package/hooks/tezgah_context.py +460 -390
  40. package/hooks/tezgah_gate.py +640 -104
  41. package/hooks/tezgah_integrity.py +1480 -197
  42. package/hooks/tezgah_models.py +337 -15
  43. package/hooks/tezgah_paths.py +103 -10
  44. package/hooks/tezgah_policy.py +286 -130
  45. package/hooks/tezgah_product.py +107 -0
  46. package/hooks/tezgah_rank.py +29 -27
  47. package/hooks/tezgah_replay.py +200 -30
  48. package/hooks/tezgah_research.py +1297 -12
  49. package/hooks/tezgah_skill_pick.py +58 -17
  50. package/hooks/tezgah_stopspec.py +7 -0
  51. package/hooks/tezgah_store.py +74 -27
  52. package/hooks/tezgah_task.py +917 -8
  53. package/hosts/codex/hook.py +9 -10
  54. package/hosts/cursor/hook.py +21 -14
  55. package/hosts/dsh/hooks.json +2 -2
  56. package/hosts/omp/hook.py +44 -23
  57. package/hosts/omp/tezgah-hook.ts.in +93 -7
  58. package/hosts/opencode/plugins/tezgah.js +119 -39
  59. package/output-styles/tezgah.md +76 -42
  60. package/package.json +1 -1
  61. package/skills/analyze-app/SKILL.md +57 -0
  62. package/skills/design-contract/EVALS.md +24 -1
  63. package/skills/design-contract/SKILL.md +17 -1
  64. package/skills/design-contract/data-views.md +86 -0
  65. package/skills/feature-audit/SKILL.md +32 -3
  66. package/skills/i-have-adhd/EVALS.md +22 -2
  67. package/skills/i-have-adhd/SKILL.md +12 -5
  68. package/skills/plan-add/EVALS.md +8 -8
  69. package/skills/plan-add/SKILL.md +22 -21
  70. package/skills/plan-sync/EVALS.md +2 -2
  71. package/skills/plan-sync/SKILL.md +14 -8
  72. package/skills/pm-frameworks/SKILL.md +6 -0
  73. package/skills/ponytail/EVALS.md +21 -2
  74. package/skills/ponytail/SKILL.md +4 -4
  75. package/skills/product-analysis/EVALS.md +23 -1
  76. package/skills/product-analysis/SKILL.md +50 -11
  77. package/skills/product-flow/EVALS.md +81 -0
  78. package/skills/product-flow/SKILL.md +91 -0
  79. package/skills/research/SKILL.md +99 -2
  80. package/skills/tezgah-contract/EVALS.md +52 -7
  81. package/skills/tezgah-contract/SKILL.md +204 -85
@@ -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>"]... [--out "<left alone>"]...
6
- [--allow-open "<why>"] [--supersedes <slug>] scaffold a line
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
@@ -16,11 +18,25 @@
16
18
  tezgah-research source <slug> <hypothesis> --run <orxRunId> [--command "<cmd>"]
17
19
  [--scope real|fixture|derived] [--fixture "<what was generated>"]
18
20
  tezgah-research compare <slug> <decision> record one variants x criteria cell from stdin
21
+ tezgah-research verdict <slug> <id> met|not-met|unanswerable --evidence "<ref>"
22
+ record one success criterion's verdict
23
+ tezgah-research conclude <slug> conclude a line whose criteria all carry a verdict
24
+ tezgah-research migrate-layout move flat research/<slug> into open/ or done/
19
25
  tezgah-research close <slug> --limit "<reason>" conclude a line as a deliberate limit
20
26
  tezgah-research seal <slug> [--history-lost] --ack "<owner decision>"
21
27
  seal a line concluded before seals existed
22
28
  tezgah-research import <checkout> [<slug>] [--allow-open "<why>"]
23
29
  bring lines from another checkout, with history
30
+ tezgah-research next --topic <t> [--flow metric-dashboard|feature] [--json]
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
24
40
 
25
41
  A research line lives at <repo>/.tezgah/research/<slug>/ and holds the state an
26
42
  auditable investigation needs: the question, the decision log, the findings, the
@@ -89,10 +105,18 @@ without it is refused. `compare` appends one cell to
89
105
  `check` prints the same list of open lines after the per-line report, and so does
90
106
  `status`, so neither state has to be discovered by being refused.
91
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
+
92
116
  Exit codes: 0 clean, 1 problems found - a broken line for `check`, a refused
93
- claim for `claim`, a refused row for `predict`, which writes nothing and prints
94
- one reason per problem, or a new line refused for `init` over unfinished ones - 2
95
- 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.
96
120
  """
97
121
  import json
98
122
  import os
@@ -103,6 +127,7 @@ import time
103
127
  HERE = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
104
128
  sys.path.insert(0, os.path.join(HERE, "hooks"))
105
129
  import tezgah_paths as tp # noqa: E402
130
+ import tezgah_product as tp_product # noqa: E402
106
131
  import tezgah_research as tr # noqa: E402
107
132
 
108
133
 
@@ -138,6 +163,7 @@ def cmd_init(args):
138
163
  "and dashes" % args[0])
139
164
  question, allow, supersedes = "", None, None
140
165
  ask, tier, method, scope_in, scope_out = "", str(tr.DEFAULT_TIER), "", [], []
166
+ arena = {}
141
167
  rest = args[1:]
142
168
  while rest:
143
169
  flag = rest.pop(0)
@@ -157,11 +183,34 @@ def cmd_init(args):
157
183
  allow = rest.pop(0)
158
184
  elif flag == "--supersedes" and rest:
159
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)
160
189
  else:
161
190
  return misuse('init <slug> --ask "<the user\'s words>" [--tier quick|study|program]'
162
- ' [--method qualitative|measured] [--in "<covered>"]...'
191
+ ' [--method qualitative|measured|exploratory] [--in "<covered>"]...'
163
192
  ' [--out "<left alone>"]... [--question "..."]'
164
- ' [--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")
165
214
  problems = tr.ask_problems(ask, tier)
166
215
  if problems:
167
216
  for problem in problems:
@@ -204,9 +253,14 @@ def cmd_init(args):
204
253
  "init %s --supersedes %s" % (", ".join(twins), slug, twins[0]))
205
254
  return 1
206
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())
207
261
  made = tr.init(repo, slug, question=question, created=created,
208
262
  supersedes=supersedes, ask=ask, tier=tier, method=method,
209
- scope_in=scope_in, scope_out=scope_out)
263
+ scope_in=scope_in, scope_out=scope_out, arena=record)
210
264
  if allow is not None:
211
265
  problem = tr.note_open(repo, slug, allow, created)
212
266
  if problem:
@@ -217,7 +271,14 @@ def cmd_init(args):
217
271
  print(" wrote %s" % path)
218
272
  for problem in tr.scope_problems(tr.line_state(repo, slug)):
219
273
  print(" owed: %s" % problem)
220
- if method == "qualitative":
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":
221
282
  print("\nnext: read the primary sources for each state.json scope.in item "
222
283
  "(`orx discover`, `orx paper`), save each to literature/ as you read "
223
284
  "it, and record every claim with a `trace` naming the S<n> it answers "
@@ -245,12 +306,17 @@ def cmd_commit(args):
245
306
  known = tr.slugs(repo)
246
307
  if slug not in known:
247
308
  return misuse("no such research line (have: %s)" % (", ".join(known) or "none"))
309
+ return commit_path(repo, tr.line_dir(repo, slug), message)
310
+
311
+
312
+ def commit_path(repo, path, message):
313
+ """Stage and commit `path` alone in the private repository of `repo`."""
248
314
  ws = tp.ensure_workspace(repo)
249
315
  if ws is None:
250
316
  print("commit refused: %s is not a git work tree (or .tezgah could not be "
251
317
  "set up), so there is no private repository to commit into" % repo)
252
318
  return 1
253
- rel = os.path.relpath(tr.line_dir(repo, slug), ws)
319
+ rel = os.path.relpath(path, ws)
254
320
  try:
255
321
  done = tp.ws_git(repo, "add", "-A", "--", rel)
256
322
  if not done.returncode:
@@ -298,6 +364,7 @@ def cmd_check(args):
298
364
  print("warn %s: %s" % (slug, warn))
299
365
  else:
300
366
  print("no research line under %s" % tr.root(repo))
367
+ lines = len(report)
301
368
  if ask_orx:
302
369
  # The registry is the repository's, not a line's, so this runs whatever the
303
370
  # lines look like - which is also why it is only asked for when --orx says so.
@@ -313,7 +380,7 @@ def cmd_check(args):
313
380
  print(json.dumps(report, indent=2))
314
381
  return 1 if problems else 0
315
382
  if not problems:
316
- print("research: %d line(s) ok" % len(report))
383
+ print("research: %d line(s) ok" % lines)
317
384
  if not rest and not all_lines:
318
385
  done = [slug for slug in known if tr.sealed(repo, slug)]
319
386
  if done:
@@ -576,6 +643,206 @@ def cmd_compare(args):
576
643
  return 0
577
644
 
578
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
+
812
+ def cmd_next(args):
813
+ """The product-flow steps of one topic with their status, then the first
814
+ missing or due step's skill and command; a report, so exit 0."""
815
+ usage = "next --topic <t> [--flow %s] [--json]" % "|".join(tp_product.FLOWS)
816
+ opts, as_json, rest = {}, False, list(args)
817
+ while rest:
818
+ arg = rest.pop(0)
819
+ if arg == "--json":
820
+ as_json = True
821
+ elif arg in ("--topic", "--flow") and rest and arg not in opts:
822
+ opts[arg] = rest.pop(0)
823
+ else:
824
+ return misuse(usage)
825
+ flow = opts.get("--flow", "metric-dashboard")
826
+ if "--topic" not in opts:
827
+ return misuse(usage)
828
+ if flow not in tp_product.FLOWS:
829
+ return misuse("unknown flow %r (%s)" % (flow, ", ".join(tp_product.FLOWS)))
830
+ topic = opts["--topic"]
831
+ steps = tp_product.next_steps(repo_root(os.getcwd()), topic, flow)
832
+ if as_json:
833
+ # the step list next_steps returns; the next step is its first
834
+ # missing or due entry
835
+ print(json.dumps(steps, indent=2))
836
+ return 0
837
+ first = next((s for s in steps if s["status"] in ("missing", "due")), None)
838
+ for n, step in enumerate(steps, 1):
839
+ print("%d. %s [%s] %s - %s" % (n, step["id"], step["status"], step["skill"],
840
+ step["detail"]))
841
+ print("next: %s - %s" % (first["skill"], first["command"]) if first
842
+ else "next: nothing left")
843
+ return 0
844
+
845
+
579
846
  def cmd_verdict(args):
580
847
  """Record one success criterion's verdict, with the evidence it rests on."""
581
848
  if len(args) < 3:
@@ -769,6 +1036,8 @@ def main(argv):
769
1036
  return cmd_source(rest)
770
1037
  if cmd == "compare":
771
1038
  return cmd_compare(rest)
1039
+ if cmd == "next":
1040
+ return cmd_next(rest)
772
1041
  if cmd == "verdict":
773
1042
  return cmd_verdict(rest)
774
1043
  if cmd == "conclude":
@@ -781,8 +1050,13 @@ def main(argv):
781
1050
  return cmd_seal(rest)
782
1051
  if cmd == "import":
783
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)
784
1057
  return misuse("unknown command %r (init, commit, check, status, --all, claim, predict, "
785
- "components, migrate, source, compare, close, seal, import)" % cmd)
1058
+ "components, migrate, source, compare, verdict, conclude, migrate-layout, "
1059
+ "close, seal, import, next, idea, stage, match, board, dedup, yield)" % cmd)
786
1060
 
787
1061
 
788
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
@@ -187,7 +187,7 @@ OMP_LESSONS = ("Read `.tezgah/lessons.md` in the repository if it exists and tre
187
187
  LOCAL_BIN = os.path.join(HOME, ".local", "bin")
188
188
  SKILLS = ["harness", "tezgah-contract", "ponytail", "i-have-adhd", "no-ai-slop",
189
189
  "analyze-app", "plan-add", "plan-status", "plan-sync", "research",
190
- "product-analysis", "feature-audit", "design-contract",
190
+ "product-analysis", "product-flow", "feature-audit", "design-contract",
191
191
  "design-library", "pm-frameworks", "ai-research", "rl-env"]
192
192
 
193
193
 
@@ -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", "spec-off", "task-off",
237
- "triage-off", "update-check-off", "verify-off", "workspace-off")
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 `reply_lang` this run stores (--reply-lang); None keeps what config.json
318
- # says, and a config without the key reads as `tr` (tezgah_paths.reply_lang).
319
- REPLY_LANG = None
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 REPLY_LANG:
1048
- cfg["reply_lang"] = REPLY_LANG
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:792). Prints every step before running it, and
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.REPLY_LANGS,
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 `reply_lang`; `tr` "
5719
- "when unset, `any` checks none)")
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, REPLY_LANG
5752
+ global FEATURES, INSTALL_PREFIX, HOST_DEPS, LANGUAGE
5740
5753
  HOST_DEPS = args.host_deps
5741
- REPLY_LANG = args.reply_lang
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.