@yahyahammad/venastine 0.3.8 → 0.3.9

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 (128) hide show
  1. package/.env.example +19 -19
  2. package/CONFIG_ARCHITECTURE.md +2030 -2002
  3. package/LICENSE +201 -201
  4. package/README.md +1034 -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 +528 -528
  14. package/bin/venastine.py +71 -71
  15. package/cli_commands.py +838 -835
  16. package/config.yaml +13 -0
  17. package/config_edit.py +1301 -1301
  18. package/config_schema.py +971 -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 +2715 -2715
  28. package/core/commands.py +460 -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 +234 -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 +458 -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 +108 -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 +733 -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 +295 -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 +267 -267
  102. package/tools/builtin/arxiv.py +681 -681
  103. package/tools/builtin/fetch_url.py +371 -371
  104. package/tools/builtin/file_ops.py +720 -720
  105. package/tools/builtin/geometry.py +184 -184
  106. package/tools/builtin/load_skill.py +76 -76
  107. package/tools/builtin/pin.py +227 -227
  108. package/tools/builtin/probability_stats.py +224 -224
  109. package/tools/builtin/project_docs.py +464 -464
  110. package/tools/builtin/remember.py +175 -175
  111. package/tools/builtin/shell.py +980 -980
  112. package/tools/builtin/todo.py +149 -149
  113. package/tools/builtin/web_search.py +328 -328
  114. package/tools/context.py +159 -159
  115. package/tools/isolation.py +387 -387
  116. package/tools/registry.py +1242 -1242
  117. package/tui/app.py +8318 -8307
  118. package/tui/app.tcss +747 -739
  119. package/tui/commands.py +26 -26
  120. package/tui/diffs.py +286 -286
  121. package/tui/history.py +128 -128
  122. package/tui/hosted_driver.py +102 -102
  123. package/tui/markdown.py +1329 -1329
  124. package/tui/meters.py +364 -364
  125. package/tui/ravens.py +146 -146
  126. package/tui/screens.py +1255 -1197
  127. package/tui/themes.py +599 -599
  128. package/tui/widgets.py +3813 -3796
@@ -1,146 +1,238 @@
1
- """
2
- agents/tui_commands.py
3
-
4
- ROADMAP_v2 §18, D6 user-initiated half: /agent, /goal and /grill-me
5
- register into §16's slash registry. The shell hosts the commands; this
6
- section owns them -- the same mechanism-vs-policy split tools/registry.py
7
- uses for tools. TUI-only for now (CLI stays unchanged per the §18 scope
8
- decision); the model-initiated half lives in subagent_tool.py and works
9
- in every shell.
10
-
11
- Handlers receive the app object from tui.commands.dispatch(); this module
12
- deliberately does NOT import tui.app, so app.py can import it without a
13
- cycle.
14
- """
15
-
16
- from agents.manager import GRILL_ME_TASK, manager
17
- from tui.commands import bind
18
- from tui.commands import registry as commands
19
-
20
-
21
- def _cmd_agent(app, args: str) -> None:
22
- """Session-scoped active agent: subsequent turns run under the
23
- agent's body, model/provider/max_steps overrides, and ToolContext,
24
- until /agent default or another switch."""
25
- if not args:
26
- current = app.active_agent.name if app.active_agent else "default"
27
- app._transcript.write_system(
28
- f"Active agent: {current}. "
29
- f"Available: {', '.join(manager.names()) or 'none'}. "
30
- "/agent <name> to switch, /agent default to clear."
31
- )
32
- return
33
- if args == "default":
34
- app.active_agent = None
35
- app._transcript.write_system("Active agent cleared — default harness.")
36
- _note_skills_under_new_context(app)
37
- _refresh_agent_panel(app)
38
- return
39
- agent = manager.get(args)
40
- if agent is None:
41
- app._transcript.write_error(
42
- f"Unknown agent {args!r}. "
43
- f"Available: {', '.join(manager.names()) or 'none'}."
44
- )
45
- return
46
- app.active_agent = agent
47
- app._transcript.write_system(
48
- f"Active agent: {agent.name} — {agent.description}")
49
- _note_skills_under_new_context(app)
50
- _refresh_agent_panel(app)
51
-
52
-
53
- def _refresh_agent_panel(app) -> None:
54
- """Batch 59: the panel's root row IS the active agent, so a
55
- switch has to repaint it.
56
-
57
- getattr rather than a direct call because this module is driven
58
- against stub apps in tests/test_agents.py that carry a transcript
59
- and nothing else -- and /agent must not start depending on a
60
- sidebar widget to do its actual job."""
61
- refresh = getattr(app, "refresh_agent_panel", None)
62
- if refresh is not None:
63
- refresh()
64
-
65
-
66
- def _note_skills_under_new_context(app) -> None:
67
- """K2's activation note is computed against the context active at
68
- activation time; an /agent switch changes the context for every
69
- subsequent turn, so re-check active skills and say what is now
70
- denied (review §19-20 f21). Advisory only -- enforcement still
71
- happens per call via is_tool_allowed."""
72
- from skills.manager import manager as skill_manager
73
-
74
- context = (manager.active_context(app.active_agent)
75
- if app.active_agent is not None else None)
76
- label = app.active_agent.name if app.active_agent is not None else "default"
77
- for name in app.active_skills:
78
- skill = skill_manager.get(name)
79
- if skill is None:
80
- continue
81
- missing = skill_manager.missing_tools(skill, context)
82
- if missing:
83
- app._transcript.write_system(
84
- f"Note: {name} expects {', '.join(missing)}, which are "
85
- f"not available under agent {label}.")
86
-
87
-
88
- def _cmd_goal(app, args: str) -> None:
89
- """Persistent per-thread objective (extra_data). Injected into every
90
- turn's system prompt in ANY shell; the banner mirrors it here.
91
-
92
- #113: the read and clear paths go through `app._memory`, NOT
93
- `app.memory` -- same rule refresh_goal_banner's comment states.
94
- Constructing a ConversationMemory persists a thread row, so answering
95
- "there is no goal" (or clearing one on a session that has none) must
96
- not be what creates the thread. Only SETTING a goal touches
97
- app.memory: the user is putting state on a thread, so a thread is
98
- warranted."""
99
- if args == "clear":
100
- if app._memory is None:
101
- app._transcript.write_system("No goal set.")
102
- else:
103
- app.memory.set_extra("goal", None)
104
- app._transcript.write_system("Goal cleared.")
105
- elif args:
106
- app.memory.set_extra("goal", args)
107
- app._transcript.write_system(f"Goal set: {args}")
108
- else:
109
- goal = app._memory.extra.get("goal") if app._memory else None
110
- if goal:
111
- app._transcript.write_system(f"Current goal: {goal}")
112
- else:
113
- app._transcript.write_system(
114
- "No goal set. /goal <text> to set one, /goal clear to remove.")
115
- app.refresh_goal_banner()
116
-
117
-
118
- def _cmd_grill(app, args: str) -> None:
119
- """One turn in the CURRENT thread under the grill-me agent's system
120
- prompt -- it reads the live history directly (no digest loss)."""
121
- if app._busy:
122
- app._transcript.write_error(
123
- "Still working — wait for this turn to finish.")
124
- return
125
- agent = manager.get("grill-me")
126
- if agent is None:
127
- app._transcript.write_error("grill-me agent not found.")
128
- return
129
- app._transcript.write_user("/grill-me")
130
- # run_one_shot owns the WHOLE assembly (#170): the channel, the
131
- # catalog facts and the run must come from one answer, so nothing is
132
- # decided here. (Review f19's "no context, deliberately" answered a
133
- # question §25 R15 replaced -- what matters now is not which policy
134
- # governs but whether anything can answer, and only the run knows.)
135
- app.run_one_shot(agent, GRILL_ME_TASK)
136
-
137
-
138
- def register_agent_commands() -> None:
139
- """Idempotent — registering by name overwrites, matching §16's
140
- register_builtin_commands()."""
141
- for command in (
142
- bind("agent", _cmd_agent),
143
- bind("goal", _cmd_goal),
144
- bind("grill-me", _cmd_grill),
145
- ):
146
- commands.register(command)
1
+ """
2
+ agents/tui_commands.py
3
+
4
+ ROADMAP_v2 §18, D6 user-initiated half: /agent, /goal and /grill-me
5
+ register into §16's slash registry. The shell hosts the commands; this
6
+ section owns them -- the same mechanism-vs-policy split tools/registry.py
7
+ uses for tools. TUI-only for now (CLI stays unchanged per the §18 scope
8
+ decision); the model-initiated half lives in subagent_tool.py and works
9
+ in every shell.
10
+
11
+ Handlers receive the app object from tui.commands.dispatch(); this module
12
+ deliberately does NOT import tui.app, so app.py can import it without a
13
+ cycle.
14
+ """
15
+
16
+ from agents.manager import GRILL_ME_TASK, manager
17
+ from tui.commands import bind
18
+ from tui.commands import registry as commands
19
+
20
+
21
+ def _cmd_agent(app, args: str) -> None:
22
+ """Session-scoped active agent: subsequent turns run under the
23
+ agent's body, model/provider/max_steps overrides, and ToolContext,
24
+ until /agent default or another switch."""
25
+ if not args:
26
+ current = app.active_agent.name if app.active_agent else "default"
27
+ stops, _ = cycle_stops()
28
+ cycle = (" shift+tab in the prompt steps through "
29
+ f"{' → '.join(_stop_name(stop) for stop in stops)}."
30
+ if len(stops) > 1 else "")
31
+ app._transcript.write_system(
32
+ f"Active agent: {current}. "
33
+ f"Available: {', '.join(manager.names()) or 'none'}. "
34
+ f"/agent <name> to switch, /agent default to clear.{cycle}"
35
+ )
36
+ return
37
+ if args == "default":
38
+ _switch_to(app, None)
39
+ return
40
+ agent = manager.get(args)
41
+ if agent is None:
42
+ app._transcript.write_error(
43
+ f"Unknown agent {args!r}. "
44
+ f"Available: {', '.join(manager.names()) or 'none'}."
45
+ )
46
+ return
47
+ _switch_to(app, agent)
48
+
49
+
50
+ def _switch_to(app, agent) -> None:
51
+ """Make `agent` the active one, or clear it with None.
52
+
53
+ ONE path for /agent and for shift+tab (ROADMAP_v3 §59), so the two
54
+ cannot differ in what a switch says, re-checks or repaints. A turn
55
+ already running keeps the agent it started with: `agent_turn` reads
56
+ `app.active_agent` once, when the turn begins.
57
+ """
58
+ app.active_agent = agent
59
+ if agent is None:
60
+ app._transcript.write_system("Active agent cleared — default harness.")
61
+ else:
62
+ app._transcript.write_system(
63
+ f"Active agent: {agent.name} — {agent.description}")
64
+ _note_skills_under_new_context(app)
65
+ _refresh_agent_panel(app)
66
+
67
+
68
+ # ---------------------------------------------------------------------------
69
+ # ---- shift+tab: the agent cycle (ROADMAP_v3 §59, UI2 / UI3) ----------------
70
+ # ---------------------------------------------------------------------------
71
+
72
+ DEFAULT_STOP = "default"
73
+
74
+
75
+ def _stop_name(stop) -> str:
76
+ return DEFAULT_STOP if stop is None else stop.name
77
+
78
+
79
+ def cycle_stops() -> tuple[list, list]:
80
+ """The stops shift+tab walks, and the configured names it had to skip.
81
+
82
+ The first stop is ALWAYS None, the plain harness (UI6), and the rest
83
+ are `config.AGENT_CYCLE` in its own order. A "default" entry and a
84
+ repeated name add nothing. A name no tier provides is skipped, because
85
+ the user and project tiers are only known at runtime; the caller says
86
+ so. Read at call time, so a test or a /config edit is seen at once.
87
+ """
88
+ import config
89
+
90
+ stops, missing, seen = [None], [], {DEFAULT_STOP}
91
+ for name in config.AGENT_CYCLE:
92
+ if name in seen:
93
+ continue
94
+ seen.add(name)
95
+ agent = manager.get(name)
96
+ if agent is None:
97
+ missing.append(name)
98
+ else:
99
+ stops.append(agent)
100
+ return stops, missing
101
+
102
+
103
+ def can_cycle() -> bool:
104
+ """Whether shift+tab means "next agent" right now: at least one agent
105
+ beside the default. When it does not, the prompt declines the key and
106
+ Textual's reverse focus gets it, as before §59."""
107
+ stops, _ = cycle_stops()
108
+ return len(stops) > 1
109
+
110
+
111
+ def cycle_agent(app) -> None:
112
+ """shift+tab in the prompt: switch to the next stop.
113
+
114
+ From an agent the roster does not list (one picked with /agent), the
115
+ next stop is the first one, the default. A cycle has one start, and
116
+ that is the stop a user can always find again.
117
+ """
118
+ stops, missing = cycle_stops()
119
+ _note_missing(app, missing)
120
+ if len(stops) < 2:
121
+ return
122
+ names = [_stop_name(stop) for stop in stops]
123
+ current = _stop_name(app.active_agent)
124
+ following = (names.index(current) + 1) % len(stops) \
125
+ if current in names else 0
126
+ _switch_to(app, stops[following])
127
+
128
+
129
+ def _note_missing(app, missing: list) -> None:
130
+ """Name each skipped roster entry once per session, not once per press.
131
+ Kept on the app, so a new session starts with a clean slate."""
132
+ noted = getattr(app, "_agent_cycle_noted", None)
133
+ if noted is None:
134
+ noted = set()
135
+ app._agent_cycle_noted = noted
136
+ for name in missing:
137
+ if name in noted:
138
+ continue
139
+ noted.add(name)
140
+ app._transcript.write_system(
141
+ f"agent_cycle in config.yaml names {name!r}, which no agent tier "
142
+ "provides here, so shift+tab skips it.")
143
+
144
+
145
+ def _refresh_agent_panel(app) -> None:
146
+ """Batch 59: the panel's root row IS the active agent, so a
147
+ switch has to repaint it.
148
+
149
+ getattr rather than a direct call because this module is driven
150
+ against stub apps in tests/test_agents.py that carry a transcript
151
+ and nothing else -- and /agent must not start depending on a
152
+ sidebar widget to do its actual job."""
153
+ refresh = getattr(app, "refresh_agent_panel", None)
154
+ if refresh is not None:
155
+ refresh()
156
+
157
+
158
+ def _note_skills_under_new_context(app) -> None:
159
+ """K2's activation note is computed against the context active at
160
+ activation time; an /agent switch changes the context for every
161
+ subsequent turn, so re-check active skills and say what is now
162
+ denied (review §19-20 f21). Advisory only -- enforcement still
163
+ happens per call via is_tool_allowed."""
164
+ from skills.manager import manager as skill_manager
165
+
166
+ context = (manager.active_context(app.active_agent)
167
+ if app.active_agent is not None else None)
168
+ label = app.active_agent.name if app.active_agent is not None else "default"
169
+ for name in app.active_skills:
170
+ skill = skill_manager.get(name)
171
+ if skill is None:
172
+ continue
173
+ missing = skill_manager.missing_tools(skill, context)
174
+ if missing:
175
+ app._transcript.write_system(
176
+ f"Note: {name} expects {', '.join(missing)}, which are "
177
+ f"not available under agent {label}.")
178
+
179
+
180
+ def _cmd_goal(app, args: str) -> None:
181
+ """Persistent per-thread objective (extra_data). Injected into every
182
+ turn's system prompt in ANY shell; the banner mirrors it here.
183
+
184
+ #113: the read and clear paths go through `app._memory`, NOT
185
+ `app.memory` -- same rule refresh_goal_banner's comment states.
186
+ Constructing a ConversationMemory persists a thread row, so answering
187
+ "there is no goal" (or clearing one on a session that has none) must
188
+ not be what creates the thread. Only SETTING a goal touches
189
+ app.memory: the user is putting state on a thread, so a thread is
190
+ warranted."""
191
+ if args == "clear":
192
+ if app._memory is None:
193
+ app._transcript.write_system("No goal set.")
194
+ else:
195
+ app.memory.set_extra("goal", None)
196
+ app._transcript.write_system("Goal cleared.")
197
+ elif args:
198
+ app.memory.set_extra("goal", args)
199
+ app._transcript.write_system(f"Goal set: {args}")
200
+ else:
201
+ goal = app._memory.extra.get("goal") if app._memory else None
202
+ if goal:
203
+ app._transcript.write_system(f"Current goal: {goal}")
204
+ else:
205
+ app._transcript.write_system(
206
+ "No goal set. /goal <text> to set one, /goal clear to remove.")
207
+ app.refresh_goal_banner()
208
+
209
+
210
+ def _cmd_grill(app, args: str) -> None:
211
+ """One turn in the CURRENT thread under the grill-me agent's system
212
+ prompt -- it reads the live history directly (no digest loss)."""
213
+ if app._busy:
214
+ app._transcript.write_error(
215
+ "Still working — wait for this turn to finish.")
216
+ return
217
+ agent = manager.get("grill-me")
218
+ if agent is None:
219
+ app._transcript.write_error("grill-me agent not found.")
220
+ return
221
+ app._transcript.write_user("/grill-me")
222
+ # run_one_shot owns the WHOLE assembly (#170): the channel, the
223
+ # catalog facts and the run must come from one answer, so nothing is
224
+ # decided here. (Review f19's "no context, deliberately" answered a
225
+ # question §25 R15 replaced -- what matters now is not which policy
226
+ # governs but whether anything can answer, and only the run knows.)
227
+ app.run_one_shot(agent, GRILL_ME_TASK)
228
+
229
+
230
+ def register_agent_commands() -> None:
231
+ """Idempotent — registering by name overwrites, matching §16's
232
+ register_builtin_commands()."""
233
+ for command in (
234
+ bind("agent", _cmd_agent),
235
+ bind("goal", _cmd_goal),
236
+ bind("grill-me", _cmd_grill),
237
+ ):
238
+ commands.register(command)