@yahyahammad/venastine 0.3.8 → 0.3.10

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 (130) hide show
  1. package/.env.example +19 -19
  2. package/CONFIG_ARCHITECTURE.md +2139 -2002
  3. package/LICENSE +201 -201
  4. package/README.md +1043 -1034
  5. package/agents/builtin/compactor.md +75 -75
  6. package/agents/builtin/explore.md +77 -77
  7. package/agents/builtin/pipeline-reviewer.md +100 -100
  8. package/agents/builtin/plan.md +106 -106
  9. package/agents/builtin/review.md +74 -74
  10. package/agents/manager.py +261 -261
  11. package/agents/subagent_tool.py +472 -472
  12. package/agents/tui_commands.py +238 -146
  13. package/bin/venastine.mjs +584 -528
  14. package/bin/venastine.py +73 -71
  15. package/cli_commands.py +848 -835
  16. package/config.yaml +64 -0
  17. package/config_edit.py +1301 -1301
  18. package/config_schema.py +987 -966
  19. package/config_update.py +749 -749
  20. package/core/agent_activity.py +256 -256
  21. package/core/ansi.py +452 -452
  22. package/core/approval.py +137 -137
  23. package/core/call_view.py +364 -364
  24. package/core/cancel.py +121 -121
  25. package/core/chatgpt_auth.py +747 -747
  26. package/core/claims_view.py +107 -107
  27. package/core/client.py +2756 -2715
  28. package/core/commands.py +464 -454
  29. package/core/compaction.py +1735 -1735
  30. package/core/config_loader.py +1982 -1982
  31. package/core/connect.py +686 -686
  32. package/core/events.py +123 -123
  33. package/core/file_mentions.py +280 -280
  34. package/core/interaction.py +411 -411
  35. package/core/loop.py +2566 -2566
  36. package/core/memory.py +482 -482
  37. package/core/pipeline_models.py +190 -190
  38. package/core/provider_errors.py +274 -234
  39. package/core/reasoning/authorization.py +130 -130
  40. package/core/reasoning/base.py +219 -219
  41. package/core/reasoning/confidence_scoring.py +484 -484
  42. package/core/reasoning/events.py +149 -149
  43. package/core/reasoning/orchestrator.py +1561 -1561
  44. package/core/reasoning/output_writer.py +345 -345
  45. package/core/reasoning/payload_validation.py +524 -524
  46. package/core/reasoning/pipeline_storage.py +427 -427
  47. package/core/reasoning/scholar.py +467 -458
  48. package/core/reasoning/source_corpus.py +433 -433
  49. package/core/reasoning/source_scoring.py +855 -855
  50. package/core/replay.py +315 -315
  51. package/core/shell_sessions.py +1553 -1553
  52. package/credentials.py +307 -307
  53. package/database.py +333 -333
  54. package/docs/PRIVACY.md +78 -78
  55. package/docs/SECURITY.md +114 -108
  56. package/docs/THIRD_PARTY_NOTICES.md +148 -148
  57. package/env_secrets.py +118 -118
  58. package/json_store.py +343 -343
  59. package/logging_setup.py +295 -295
  60. package/main.py +3433 -3433
  61. package/mcp_client/client.py +780 -733
  62. package/mcp_client/config.py +484 -484
  63. package/mcp_client/registration.py +343 -343
  64. package/memories/manager.py +147 -147
  65. package/memories/tui_commands.py +319 -239
  66. package/package.json +303 -303
  67. package/project_init/config_files.py +282 -282
  68. package/project_init/generator.py +728 -728
  69. package/project_init/manifest.py +418 -418
  70. package/project_init/tui_commands.py +147 -147
  71. package/prompts/critic_pass.md +24 -24
  72. package/prompts/revalidate.md +25 -25
  73. package/prompts/revise.md +17 -17
  74. package/prompts/source_grounding.md +66 -66
  75. package/prompts/system_prompts.py +316 -316
  76. package/providers.json.example +94 -94
  77. package/pyproject.toml +149 -149
  78. package/requirements.txt +314 -295
  79. package/safety/policy_enforcement.py +1082 -1082
  80. package/security/askpass.py +419 -419
  81. package/security/capability.py +207 -207
  82. package/security/confine.py +484 -484
  83. package/security/hosted.py +182 -182
  84. package/security/permissions.py +237 -237
  85. package/security/protected_paths.py +501 -501
  86. package/security/sandbox.py +4108 -4108
  87. package/skills/builtin/math/formal-specification.md +67 -67
  88. package/skills/builtin/math/numerical-methods.md +66 -66
  89. package/skills/builtin/research/experiment-design.md +62 -62
  90. package/skills/builtin/research/reproducibility.md +55 -55
  91. package/skills/builtin/research/source-evaluation.md +70 -70
  92. package/skills/builtin/research/statistical-inference.md +63 -63
  93. package/skills/builtin/research/technical-writing.md +59 -59
  94. package/skills/builtin/software/code-review.md +61 -61
  95. package/skills/builtin/software/debugging.md +61 -61
  96. package/skills/builtin/software/test-design.md +67 -67
  97. package/skills/tui_commands.py +110 -110
  98. package/storage.py +1338 -1338
  99. package/tools/base.py +465 -465
  100. package/tools/builtin/_math_common.py +667 -667
  101. package/tools/builtin/_net_common.py +1145 -267
  102. package/tools/builtin/_page_text.py +490 -0
  103. package/tools/builtin/_pdf_text.py +113 -0
  104. package/tools/builtin/arxiv.py +685 -681
  105. package/tools/builtin/fetch_url.py +639 -371
  106. package/tools/builtin/file_ops.py +720 -720
  107. package/tools/builtin/geometry.py +184 -184
  108. package/tools/builtin/load_skill.py +76 -76
  109. package/tools/builtin/pin.py +227 -227
  110. package/tools/builtin/probability_stats.py +224 -224
  111. package/tools/builtin/project_docs.py +464 -464
  112. package/tools/builtin/remember.py +175 -175
  113. package/tools/builtin/shell.py +980 -980
  114. package/tools/builtin/todo.py +149 -149
  115. package/tools/builtin/web_search.py +402 -328
  116. package/tools/context.py +159 -159
  117. package/tools/isolation.py +387 -387
  118. package/tools/registry.py +1252 -1242
  119. package/tui/app.py +8372 -8307
  120. package/tui/app.tcss +754 -739
  121. package/tui/commands.py +26 -26
  122. package/tui/diffs.py +286 -286
  123. package/tui/history.py +128 -128
  124. package/tui/hosted_driver.py +102 -102
  125. package/tui/markdown.py +1329 -1329
  126. package/tui/meters.py +364 -364
  127. package/tui/ravens.py +146 -146
  128. package/tui/screens.py +1255 -1197
  129. package/tui/themes.py +599 -599
  130. package/tui/widgets.py +3861 -3796
@@ -1,190 +1,190 @@
1
- """
2
- core/pipeline_models.py
3
-
4
- The model roles that are not the session model, remembered.
5
-
6
- ROADMAP_v2 §45 (SQ7). A research run reaches for three models: the
7
- generator (the session pair, `/model`), the CRITIC that grounds and
8
- critiques its claims (§11), and — since §45 — the EMBEDDER that scores how
9
- close a source is to the claim it was cited for. Only the first has ever
10
- been reachable without editing installed source. `CRITIC_MODEL` has sat in
11
- `config.py` since §11, which means the routing this project's own
12
- methodology calls essential ("a model checking its own output for errors
13
- shares that model's blind spots") was available only to whoever could edit
14
- the checkout.
15
-
16
- IN `core/`, NOT `tui/preferences.py`, AND THAT IS A LAYERING FACT. The
17
- pipeline reads these and D12 makes the TUI a shell that core must never
18
- import — WS6's argument for `core/model_windows.py`, unchanged, and §25's
19
- lesson about a capability the pipeline could not reach. It is equally not
20
- `core/session.py`, whose contract is that nothing there reaches disk.
21
-
22
- EVERY ROLE IN ONE FILE, so every writer reads, modifies and writes. RM4's
23
- shape and RM4's reason: a writer serialising only its own role would
24
- silently drop the others', each correct in its own test. They are one file
25
- rather than a module each because they are the same KIND of fact — which model plays
26
- which part in a run — and `model_windows.py` is next door as the example
27
- of when a second file is right instead (it holds a different kind of fact,
28
- keyed on a pair rather than naming one).
29
-
30
- PRECEDENCE: THE STORE OUTRANKS `config.py`. The opposite of
31
- `model_windows`, and for the opposite reason — there, a configured value
32
- could be confidently wrong about a deployment, so the person won. Here
33
- `config.py` is the harness's own default and the store is a choice
34
- someone made at a command prompt for this account, which is `/model`
35
- outranking `config.MODEL_NAME` exactly.
36
-
37
- WHY NOT `settings.json`. Choosing a provider is a grant (E2): a project's
38
- settings.json outranks the user's, so a cloned repo could otherwise point
39
- this harness's embedding calls — claim text and fetched page text — at a
40
- provider of its choosing. `embedder_model` and `critic_model` are
41
- therefore rejected there BY NAME, like `ensemble_models`, and this
42
- user-tier store is the route instead.
43
-
44
- A THIRD ROLE SINCE ROADMAP_v3 §57: `subagent`, set by `/submodel` in
45
- either shell. It is the model a SPAWNED child runs on when its own file
46
- pins neither half of a pair (SM6), at every depth and whatever its parent
47
- runs on (SM7) -- so a cheap child no longer has to run on its parent's
48
- expensive model. It is the same kind of fact as the other two, which part
49
- a model plays, and so it shares their file and their read-modify-write.
50
- It has NO `config.yaml` tier (SM5): `resolve` answers from this store or
51
- not at all, which is why its `_FALLBACK_ATTR` entry is None rather than a
52
- constant nobody sets. Nothing else reads it: the compactor, the pipeline
53
- reviewer and the initializer keep the session model (SM8).
54
- """
55
-
56
- import logging
57
- import os
58
- from typing import Optional
59
-
60
- import config
61
- from json_store import read_versioned, write_json_atomic
62
-
63
- logger = logging.getLogger(__name__)
64
-
65
- # Bumped when the SHAPE changes. An unknown version reads as an empty
66
- # store, which costs the remembered roles and falls back to config.py --
67
- # there is nothing here that was consented to, so the MCP store's careful
68
- # legacy handling has no counterpart.
69
- STORE_VERSION = 1
70
-
71
- # The roles this store knows. A role outside it is refused rather than
72
- # stored: a typo'd `/embeder` writing a key nothing reads would look like
73
- # it worked and change nothing, which is the failure mode this whole
74
- # module exists to remove for CRITIC_MODEL.
75
- ROLES = ("critic", "embedder", "subagent")
76
-
77
- # Which config.py constant answers when the store is silent. None means
78
- # nothing does: `subagent` is remembered or unset (§57, SM5).
79
- _FALLBACK_ATTR = {"critic": "CRITIC_MODEL", "embedder": "EMBEDDER_MODEL",
80
- "subagent": None}
81
-
82
-
83
- def store_path() -> str:
84
- # Call time, not import time: tests redirect it, and a moved config
85
- # directory is picked up without a restart. Every sibling store
86
- # resolves theirs the same way.
87
- return os.path.expanduser("~/.config/venastine/pipeline_models.json")
88
-
89
-
90
- def _read_raw() -> dict:
91
- data = read_versioned(store_path(), STORE_VERSION,
92
- "falling back to config.py for pipeline models.")
93
- roles = data.get("roles")
94
- return roles if isinstance(roles, dict) else {}
95
-
96
-
97
- def _write(roles: dict, action: str) -> bool:
98
- """Persist the whole map. True if it reached disk.
99
-
100
- A failure WARNS and returns False rather than raising, matching
101
- model_windows: the TUI routes WARNING+ into the transcript, so someone
102
- whose choice could not be saved is told at the moment they make it
103
- rather than discovering it at the next launch.
104
- """
105
- path = store_path()
106
- try:
107
- write_json_atomic(path, {"version": STORE_VERSION, "roles": roles},
108
- sort_keys=True)
109
- except OSError as exc:
110
- logger.warning("Could not %s the pipeline model in %s (%s).",
111
- action, path, exc)
112
- return False
113
- return True
114
-
115
-
116
- def _valid(entry) -> bool:
117
- """A whole pair or nothing.
118
-
119
- tui/preferences.py's rule, for its reason: a model name means nothing
120
- against the wrong provider, so half a record is no record. A
121
- hand-edited file with only one of the two is ignored rather than
122
- half-applied.
123
- """
124
- return (isinstance(entry, dict)
125
- and isinstance(entry.get("provider_name"), str)
126
- and isinstance(entry.get("model"), str)
127
- and bool(entry["provider_name"]) and bool(entry["model"]))
128
-
129
-
130
- def remembered(role: str) -> Optional[dict]:
131
- """What the user chose for `role`, or None. Ignores config.py."""
132
- entry = _read_raw().get(role)
133
- if not _valid(entry):
134
- return None
135
- return {"provider_name": entry["provider_name"], "model": entry["model"]}
136
-
137
-
138
- def resolve(role: str) -> Optional[dict]:
139
- """The pair actually in force for `role`: the store, else config.py,
140
- else None.
141
-
142
- THE ONE READER FOR THE PIPELINE. `orchestrator` and every shell ask
143
- this rather than reading `config.CRITIC_MODEL` directly, so a
144
- remembered choice reaches the CLI, the TUI and a spawned run alike --
145
- and so there is one precedence rule rather than one per caller.
146
- """
147
- if role not in ROLES:
148
- raise ValueError(f"unknown pipeline model role {role!r}; "
149
- f"expected one of {', '.join(ROLES)}")
150
- chosen = remembered(role)
151
- if chosen is not None:
152
- return chosen
153
- attr = _FALLBACK_ATTR[role]
154
- fallback = getattr(config, attr, None) if attr else None
155
- return fallback if _valid(fallback) else None
156
-
157
-
158
- def remember(role: str, provider_name: str, model: str) -> bool:
159
- """Record a pair for `role`. True if it reached disk."""
160
- if role not in ROLES:
161
- raise ValueError(f"unknown pipeline model role {role!r}; "
162
- f"expected one of {', '.join(ROLES)}")
163
- roles = _read_raw()
164
- roles[role] = {"provider_name": provider_name, "model": model}
165
- return _write(roles, "save")
166
-
167
-
168
- def forget(role: str) -> str:
169
- """Drop `role`'s entry. "removed", "absent" or "failed".
170
-
171
- Three outcomes rather than a bool, following model_windows: the shell
172
- says a different sentence for each, and a failed write reported as
173
- "nothing was set" would be a lie about a file the user can go and
174
- read. Note that "removed" does not mean the role is unset -- config.py
175
- may still answer, and the shell says so.
176
- """
177
- if role not in ROLES:
178
- raise ValueError(f"unknown pipeline model role {role!r}; "
179
- f"expected one of {', '.join(ROLES)}")
180
- roles = _read_raw()
181
- if roles.pop(role, None) is None:
182
- return "absent"
183
- return "removed" if _write(roles, "clear") else "failed"
184
-
185
-
186
- def all_roles() -> dict:
187
- """{role: {"provider_name", "model"}} for every role in force, from
188
- whichever tier answered. For a report."""
189
- return {role: pair for role in ROLES
190
- if (pair := resolve(role)) is not None}
1
+ """
2
+ core/pipeline_models.py
3
+
4
+ The model roles that are not the session model, remembered.
5
+
6
+ ROADMAP_v2 §45 (SQ7). A research run reaches for three models: the
7
+ generator (the session pair, `/model`), the CRITIC that grounds and
8
+ critiques its claims (§11), and — since §45 — the EMBEDDER that scores how
9
+ close a source is to the claim it was cited for. Only the first has ever
10
+ been reachable without editing installed source. `CRITIC_MODEL` has sat in
11
+ `config.py` since §11, which means the routing this project's own
12
+ methodology calls essential ("a model checking its own output for errors
13
+ shares that model's blind spots") was available only to whoever could edit
14
+ the checkout.
15
+
16
+ IN `core/`, NOT `tui/preferences.py`, AND THAT IS A LAYERING FACT. The
17
+ pipeline reads these and D12 makes the TUI a shell that core must never
18
+ import — WS6's argument for `core/model_windows.py`, unchanged, and §25's
19
+ lesson about a capability the pipeline could not reach. It is equally not
20
+ `core/session.py`, whose contract is that nothing there reaches disk.
21
+
22
+ EVERY ROLE IN ONE FILE, so every writer reads, modifies and writes. RM4's
23
+ shape and RM4's reason: a writer serialising only its own role would
24
+ silently drop the others', each correct in its own test. They are one file
25
+ rather than a module each because they are the same KIND of fact — which model plays
26
+ which part in a run — and `model_windows.py` is next door as the example
27
+ of when a second file is right instead (it holds a different kind of fact,
28
+ keyed on a pair rather than naming one).
29
+
30
+ PRECEDENCE: THE STORE OUTRANKS `config.py`. The opposite of
31
+ `model_windows`, and for the opposite reason — there, a configured value
32
+ could be confidently wrong about a deployment, so the person won. Here
33
+ `config.py` is the harness's own default and the store is a choice
34
+ someone made at a command prompt for this account, which is `/model`
35
+ outranking `config.MODEL_NAME` exactly.
36
+
37
+ WHY NOT `settings.json`. Choosing a provider is a grant (E2): a project's
38
+ settings.json outranks the user's, so a cloned repo could otherwise point
39
+ this harness's embedding calls — claim text and fetched page text — at a
40
+ provider of its choosing. `embedder_model` and `critic_model` are
41
+ therefore rejected there BY NAME, like `ensemble_models`, and this
42
+ user-tier store is the route instead.
43
+
44
+ A THIRD ROLE SINCE ROADMAP_v3 §57: `subagent`, set by `/submodel` in
45
+ either shell. It is the model a SPAWNED child runs on when its own file
46
+ pins neither half of a pair (SM6), at every depth and whatever its parent
47
+ runs on (SM7) -- so a cheap child no longer has to run on its parent's
48
+ expensive model. It is the same kind of fact as the other two, which part
49
+ a model plays, and so it shares their file and their read-modify-write.
50
+ It has NO `config.yaml` tier (SM5): `resolve` answers from this store or
51
+ not at all, which is why its `_FALLBACK_ATTR` entry is None rather than a
52
+ constant nobody sets. Nothing else reads it: the compactor, the pipeline
53
+ reviewer and the initializer keep the session model (SM8).
54
+ """
55
+
56
+ import logging
57
+ import os
58
+ from typing import Optional
59
+
60
+ import config
61
+ from json_store import read_versioned, write_json_atomic
62
+
63
+ logger = logging.getLogger(__name__)
64
+
65
+ # Bumped when the SHAPE changes. An unknown version reads as an empty
66
+ # store, which costs the remembered roles and falls back to config.py --
67
+ # there is nothing here that was consented to, so the MCP store's careful
68
+ # legacy handling has no counterpart.
69
+ STORE_VERSION = 1
70
+
71
+ # The roles this store knows. A role outside it is refused rather than
72
+ # stored: a typo'd `/embeder` writing a key nothing reads would look like
73
+ # it worked and change nothing, which is the failure mode this whole
74
+ # module exists to remove for CRITIC_MODEL.
75
+ ROLES = ("critic", "embedder", "subagent")
76
+
77
+ # Which config.py constant answers when the store is silent. None means
78
+ # nothing does: `subagent` is remembered or unset (§57, SM5).
79
+ _FALLBACK_ATTR = {"critic": "CRITIC_MODEL", "embedder": "EMBEDDER_MODEL",
80
+ "subagent": None}
81
+
82
+
83
+ def store_path() -> str:
84
+ # Call time, not import time: tests redirect it, and a moved config
85
+ # directory is picked up without a restart. Every sibling store
86
+ # resolves theirs the same way.
87
+ return os.path.expanduser("~/.config/venastine/pipeline_models.json")
88
+
89
+
90
+ def _read_raw() -> dict:
91
+ data = read_versioned(store_path(), STORE_VERSION,
92
+ "falling back to config.py for pipeline models.")
93
+ roles = data.get("roles")
94
+ return roles if isinstance(roles, dict) else {}
95
+
96
+
97
+ def _write(roles: dict, action: str) -> bool:
98
+ """Persist the whole map. True if it reached disk.
99
+
100
+ A failure WARNS and returns False rather than raising, matching
101
+ model_windows: the TUI routes WARNING+ into the transcript, so someone
102
+ whose choice could not be saved is told at the moment they make it
103
+ rather than discovering it at the next launch.
104
+ """
105
+ path = store_path()
106
+ try:
107
+ write_json_atomic(path, {"version": STORE_VERSION, "roles": roles},
108
+ sort_keys=True)
109
+ except OSError as exc:
110
+ logger.warning("Could not %s the pipeline model in %s (%s).",
111
+ action, path, exc)
112
+ return False
113
+ return True
114
+
115
+
116
+ def _valid(entry) -> bool:
117
+ """A whole pair or nothing.
118
+
119
+ tui/preferences.py's rule, for its reason: a model name means nothing
120
+ against the wrong provider, so half a record is no record. A
121
+ hand-edited file with only one of the two is ignored rather than
122
+ half-applied.
123
+ """
124
+ return (isinstance(entry, dict)
125
+ and isinstance(entry.get("provider_name"), str)
126
+ and isinstance(entry.get("model"), str)
127
+ and bool(entry["provider_name"]) and bool(entry["model"]))
128
+
129
+
130
+ def remembered(role: str) -> Optional[dict]:
131
+ """What the user chose for `role`, or None. Ignores config.py."""
132
+ entry = _read_raw().get(role)
133
+ if not _valid(entry):
134
+ return None
135
+ return {"provider_name": entry["provider_name"], "model": entry["model"]}
136
+
137
+
138
+ def resolve(role: str) -> Optional[dict]:
139
+ """The pair actually in force for `role`: the store, else config.py,
140
+ else None.
141
+
142
+ THE ONE READER FOR THE PIPELINE. `orchestrator` and every shell ask
143
+ this rather than reading `config.CRITIC_MODEL` directly, so a
144
+ remembered choice reaches the CLI, the TUI and a spawned run alike --
145
+ and so there is one precedence rule rather than one per caller.
146
+ """
147
+ if role not in ROLES:
148
+ raise ValueError(f"unknown pipeline model role {role!r}; "
149
+ f"expected one of {', '.join(ROLES)}")
150
+ chosen = remembered(role)
151
+ if chosen is not None:
152
+ return chosen
153
+ attr = _FALLBACK_ATTR[role]
154
+ fallback = getattr(config, attr, None) if attr else None
155
+ return fallback if _valid(fallback) else None
156
+
157
+
158
+ def remember(role: str, provider_name: str, model: str) -> bool:
159
+ """Record a pair for `role`. True if it reached disk."""
160
+ if role not in ROLES:
161
+ raise ValueError(f"unknown pipeline model role {role!r}; "
162
+ f"expected one of {', '.join(ROLES)}")
163
+ roles = _read_raw()
164
+ roles[role] = {"provider_name": provider_name, "model": model}
165
+ return _write(roles, "save")
166
+
167
+
168
+ def forget(role: str) -> str:
169
+ """Drop `role`'s entry. "removed", "absent" or "failed".
170
+
171
+ Three outcomes rather than a bool, following model_windows: the shell
172
+ says a different sentence for each, and a failed write reported as
173
+ "nothing was set" would be a lie about a file the user can go and
174
+ read. Note that "removed" does not mean the role is unset -- config.py
175
+ may still answer, and the shell says so.
176
+ """
177
+ if role not in ROLES:
178
+ raise ValueError(f"unknown pipeline model role {role!r}; "
179
+ f"expected one of {', '.join(ROLES)}")
180
+ roles = _read_raw()
181
+ if roles.pop(role, None) is None:
182
+ return "absent"
183
+ return "removed" if _write(roles, "clear") else "failed"
184
+
185
+
186
+ def all_roles() -> dict:
187
+ """{role: {"provider_name", "model"}} for every role in force, from
188
+ whichever tier answered. For a report."""
189
+ return {role: pair for role in ROLES
190
+ if (pair := resolve(role)) is not None}