@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.
- package/.env.example +19 -19
- package/CONFIG_ARCHITECTURE.md +2139 -2002
- package/LICENSE +201 -201
- package/README.md +1043 -1034
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -106
- package/agents/builtin/review.md +74 -74
- package/agents/manager.py +261 -261
- package/agents/subagent_tool.py +472 -472
- package/agents/tui_commands.py +238 -146
- package/bin/venastine.mjs +584 -528
- package/bin/venastine.py +73 -71
- package/cli_commands.py +848 -835
- package/config.yaml +64 -0
- package/config_edit.py +1301 -1301
- package/config_schema.py +987 -966
- package/config_update.py +749 -749
- package/core/agent_activity.py +256 -256
- package/core/ansi.py +452 -452
- package/core/approval.py +137 -137
- package/core/call_view.py +364 -364
- package/core/cancel.py +121 -121
- package/core/chatgpt_auth.py +747 -747
- package/core/claims_view.py +107 -107
- package/core/client.py +2756 -2715
- package/core/commands.py +464 -454
- package/core/compaction.py +1735 -1735
- package/core/config_loader.py +1982 -1982
- package/core/connect.py +686 -686
- package/core/events.py +123 -123
- package/core/file_mentions.py +280 -280
- package/core/interaction.py +411 -411
- package/core/loop.py +2566 -2566
- package/core/memory.py +482 -482
- package/core/pipeline_models.py +190 -190
- package/core/provider_errors.py +274 -234
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -484
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/orchestrator.py +1561 -1561
- package/core/reasoning/output_writer.py +345 -345
- package/core/reasoning/payload_validation.py +524 -524
- package/core/reasoning/pipeline_storage.py +427 -427
- package/core/reasoning/scholar.py +467 -458
- package/core/reasoning/source_corpus.py +433 -433
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -315
- package/core/shell_sessions.py +1553 -1553
- package/credentials.py +307 -307
- package/database.py +333 -333
- package/docs/PRIVACY.md +78 -78
- package/docs/SECURITY.md +114 -108
- package/docs/THIRD_PARTY_NOTICES.md +148 -148
- package/env_secrets.py +118 -118
- package/json_store.py +343 -343
- package/logging_setup.py +295 -295
- package/main.py +3433 -3433
- package/mcp_client/client.py +780 -733
- package/mcp_client/config.py +484 -484
- package/mcp_client/registration.py +343 -343
- package/memories/manager.py +147 -147
- package/memories/tui_commands.py +319 -239
- package/package.json +303 -303
- package/project_init/config_files.py +282 -282
- package/project_init/generator.py +728 -728
- package/project_init/manifest.py +418 -418
- package/project_init/tui_commands.py +147 -147
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +17 -17
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -316
- package/providers.json.example +94 -94
- package/pyproject.toml +149 -149
- package/requirements.txt +314 -295
- package/safety/policy_enforcement.py +1082 -1082
- package/security/askpass.py +419 -419
- package/security/capability.py +207 -207
- package/security/confine.py +484 -484
- package/security/hosted.py +182 -182
- package/security/permissions.py +237 -237
- package/security/protected_paths.py +501 -501
- package/security/sandbox.py +4108 -4108
- package/skills/builtin/math/formal-specification.md +67 -67
- package/skills/builtin/math/numerical-methods.md +66 -66
- package/skills/builtin/research/experiment-design.md +62 -62
- package/skills/builtin/research/reproducibility.md +55 -55
- package/skills/builtin/research/source-evaluation.md +70 -70
- package/skills/builtin/research/statistical-inference.md +63 -63
- package/skills/builtin/research/technical-writing.md +59 -59
- package/skills/builtin/software/code-review.md +61 -61
- package/skills/builtin/software/debugging.md +61 -61
- package/skills/builtin/software/test-design.md +67 -67
- package/skills/tui_commands.py +110 -110
- package/storage.py +1338 -1338
- package/tools/base.py +465 -465
- package/tools/builtin/_math_common.py +667 -667
- package/tools/builtin/_net_common.py +1145 -267
- package/tools/builtin/_page_text.py +490 -0
- package/tools/builtin/_pdf_text.py +113 -0
- package/tools/builtin/arxiv.py +685 -681
- package/tools/builtin/fetch_url.py +639 -371
- package/tools/builtin/file_ops.py +720 -720
- package/tools/builtin/geometry.py +184 -184
- package/tools/builtin/load_skill.py +76 -76
- package/tools/builtin/pin.py +227 -227
- package/tools/builtin/probability_stats.py +224 -224
- package/tools/builtin/project_docs.py +464 -464
- package/tools/builtin/remember.py +175 -175
- package/tools/builtin/shell.py +980 -980
- package/tools/builtin/todo.py +149 -149
- package/tools/builtin/web_search.py +402 -328
- package/tools/context.py +159 -159
- package/tools/isolation.py +387 -387
- package/tools/registry.py +1252 -1242
- package/tui/app.py +8372 -8307
- package/tui/app.tcss +754 -739
- package/tui/commands.py +26 -26
- package/tui/diffs.py +286 -286
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -102
- package/tui/markdown.py +1329 -1329
- package/tui/meters.py +364 -364
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -1197
- package/tui/themes.py +599 -599
- package/tui/widgets.py +3861 -3796
package/memories/manager.py
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
"""
|
|
2
|
-
memories/manager.py
|
|
3
|
-
|
|
4
|
-
ROADMAP_v2 §21b. Durable memory: what is in scope for this session, how
|
|
5
|
-
much of it reaches a prompt, and the one place that text is assembled.
|
|
6
|
-
|
|
7
|
-
Mirrors skills/manager.py deliberately -- a manager over rows the loader
|
|
8
|
-
does not own, holding no session state, plus a single prompt_fragment().
|
|
9
|
-
A package rather than a module under core/ because `core/memory.py`
|
|
10
|
-
already means the in-run conversation state, and two names that close
|
|
11
|
-
together is a trap rather than a convention.
|
|
12
|
-
|
|
13
|
-
WHAT THIS OWNS
|
|
14
|
-
scope resolution -- which rows this session may see (D25/M12)
|
|
15
|
-
the injection cap -- how many of them reach a prompt (M14)
|
|
16
|
-
prompt_fragment() -- the text, assembled once
|
|
17
|
-
|
|
18
|
-
WHAT IT DOES NOT OWN
|
|
19
|
-
Persistence (storage.py), the decision to write one (the `remember`
|
|
20
|
-
tool plus D26's approval gate), and WHERE the fragment is appended --
|
|
21
|
-
which is agents/manager.py for an agent run and the shells for a plain
|
|
22
|
-
chat turn.
|
|
23
|
-
|
|
24
|
-
THE FRAGMENT MUST BE APPENDED OUTSIDE with_catalogs() (M13). That function
|
|
25
|
-
feeds prompts.system_prompts.pass_prompt(), so injecting there would put
|
|
26
|
-
every durable memory into all ten research passes -- a run the user
|
|
27
|
-
started separately, from a shell that wrote none of them. This is the same
|
|
28
|
-
trap §19 recorded as K6 for skill bodies, and this is its second instance.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
import logging
|
|
32
|
-
from typing import Optional
|
|
33
|
-
|
|
34
|
-
import config
|
|
35
|
-
from core import config_loader
|
|
36
|
-
|
|
37
|
-
logger = logging.getLogger(__name__)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
class MemoryManager:
|
|
41
|
-
"""Scope resolution and prompt assembly over storage's UserMemory rows."""
|
|
42
|
-
|
|
43
|
-
@staticmethod
|
|
44
|
-
def scope_path() -> Optional[str]:
|
|
45
|
-
"""The project path memories are scoped to this session, or None.
|
|
46
|
-
|
|
47
|
-
One resolution point, over config_loader's already-resolved value,
|
|
48
|
-
so "which project" cannot mean one thing to the trust store and
|
|
49
|
-
another to memory (D25).
|
|
50
|
-
"""
|
|
51
|
-
return config_loader.get_project_path()
|
|
52
|
-
|
|
53
|
-
def visible(self, scope: Optional[str] = None) -> list:
|
|
54
|
-
"""Every memory this session may see, newest first.
|
|
55
|
-
|
|
56
|
-
Global rows plus the project rows recorded against exactly this
|
|
57
|
-
path (§21 AC6).
|
|
58
|
-
|
|
59
|
-
NO RESOLVED PROJECT MEANS NO MEMORIES AT ALL, not global-only.
|
|
60
|
-
scope_path() is None exactly when config_loader.initialize() has
|
|
61
|
-
not run, and main.py runs it at startup -- so this is "there is no
|
|
62
|
-
session", not "this session happens to be outside a project". It
|
|
63
|
-
follows the convention get_agents()/get_skills() already set:
|
|
64
|
-
uninitialized is materially the same state as initialized-and-empty
|
|
65
|
-
for every consumer, and answering with rows would mean reading a
|
|
66
|
-
database on behalf of a session that does not exist.
|
|
67
|
-
"""
|
|
68
|
-
from storage import list_memories
|
|
69
|
-
|
|
70
|
-
path = self.scope_path()
|
|
71
|
-
if path is None:
|
|
72
|
-
return []
|
|
73
|
-
return list_memories(project_path=path, scope=scope)
|
|
74
|
-
|
|
75
|
-
def wants_memories(self, agent) -> bool:
|
|
76
|
-
"""Does this run get memories injected?
|
|
77
|
-
|
|
78
|
-
M13: `agent=None` -- a plain chat turn with no active agent -- counts
|
|
79
|
-
as opted IN. The frontmatter parser already defaults `use_memory` to
|
|
80
|
-
True, so an agent that says nothing gets them, and treating "no agent
|
|
81
|
-
at all" differently would make the whole feature invisible in the
|
|
82
|
-
default shell until someone happened to run /agent. That is the §25
|
|
83
|
-
shape: a capability a whole shell cannot reach.
|
|
84
|
-
|
|
85
|
-
`use_memory: false` still opts out, which is how the compactor and
|
|
86
|
-
the pipeline reviewer stay out of it.
|
|
87
|
-
"""
|
|
88
|
-
return agent is None or bool(getattr(agent, "use_memory", True))
|
|
89
|
-
|
|
90
|
-
def prompt_fragment(self, agent=None) -> str:
|
|
91
|
-
"""The `## Remembered` block for this session, or "".
|
|
92
|
-
|
|
93
|
-
ONE assembly point, mirroring skills.manager.prompt_fragment and
|
|
94
|
-
core.loop.with_goal, so every shell that injects memories produces
|
|
95
|
-
the same text.
|
|
96
|
-
|
|
97
|
-
CAPPED, AND THE CAP IS STATED IN THE TEXT (M14). Every in-scope
|
|
98
|
-
memory would otherwise enter every turn forever, which is the
|
|
99
|
-
unbounded context growth §21 exists to fight. Newest first, because
|
|
100
|
-
recency is the only staleness signal available without asking a
|
|
101
|
-
model. The count is reported to the MODEL and not only to a log:
|
|
102
|
-
the model is the consumer, and one that can see it is looking at a
|
|
103
|
-
truncated list can say so, while a log line reaches nobody
|
|
104
|
-
mid-conversation. Same "no silent caps" rule as §20's
|
|
105
|
-
MAX_REVIEW_FINDINGS.
|
|
106
|
-
|
|
107
|
-
A CAP OF 0 MEANS OFF, IN THIS HALF TOO (batch 154). config.yaml
|
|
108
|
-
says so where the value is set, and `remember`'s available_check
|
|
109
|
-
already honours it by hiding the tool. This half did not: `rows[:0]`
|
|
110
|
-
is empty, `total > 0` fires the truncation branch, and every turn
|
|
111
|
-
got a "## Remembered" header announcing "the 0 most recent of 2"
|
|
112
|
-
with a WARNING behind it -- telling the model that remembered
|
|
113
|
-
content exists and is being withheld, while the tool that could
|
|
114
|
-
have earned it is not on the menu.
|
|
115
|
-
"""
|
|
116
|
-
if not self.wants_memories(agent):
|
|
117
|
-
return ""
|
|
118
|
-
rows = self.visible()
|
|
119
|
-
if not rows:
|
|
120
|
-
return ""
|
|
121
|
-
|
|
122
|
-
cap = config.MAX_INJECTED_MEMORIES
|
|
123
|
-
if cap <= 0:
|
|
124
|
-
# `<= 0` because the sentence is "a non-positive cap is off".
|
|
125
|
-
# Only 0 is reachable -- config_schema types this key
|
|
126
|
-
# NonNegativeInt -- so the other half of the comparison is the
|
|
127
|
-
# schema's job and not this line's.
|
|
128
|
-
return ""
|
|
129
|
-
shown, total = rows[:cap], len(rows)
|
|
130
|
-
header = "## Remembered"
|
|
131
|
-
if total > cap:
|
|
132
|
-
logger.warning(
|
|
133
|
-
"Injecting %s of %s memories; the oldest %s are not in this "
|
|
134
|
-
"prompt. Raise config.MAX_INJECTED_MEMORIES or prune with "
|
|
135
|
-
"/forget.", cap, total, total - cap)
|
|
136
|
-
header = (f"{header}\n\nShowing the {cap} most recent of {total}. "
|
|
137
|
-
f"Older ones exist and are not listed here.")
|
|
138
|
-
|
|
139
|
-
lines = [header, ""]
|
|
140
|
-
for row in shown:
|
|
141
|
-
marker = "global" if row["scope"] == "global" else "this project"
|
|
142
|
-
category = f" [{row['category']}]" if row.get("category") else ""
|
|
143
|
-
lines.append(f"- ({marker}){category} {row['content']}")
|
|
144
|
-
return "\n".join(lines)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
manager = MemoryManager()
|
|
1
|
+
"""
|
|
2
|
+
memories/manager.py
|
|
3
|
+
|
|
4
|
+
ROADMAP_v2 §21b. Durable memory: what is in scope for this session, how
|
|
5
|
+
much of it reaches a prompt, and the one place that text is assembled.
|
|
6
|
+
|
|
7
|
+
Mirrors skills/manager.py deliberately -- a manager over rows the loader
|
|
8
|
+
does not own, holding no session state, plus a single prompt_fragment().
|
|
9
|
+
A package rather than a module under core/ because `core/memory.py`
|
|
10
|
+
already means the in-run conversation state, and two names that close
|
|
11
|
+
together is a trap rather than a convention.
|
|
12
|
+
|
|
13
|
+
WHAT THIS OWNS
|
|
14
|
+
scope resolution -- which rows this session may see (D25/M12)
|
|
15
|
+
the injection cap -- how many of them reach a prompt (M14)
|
|
16
|
+
prompt_fragment() -- the text, assembled once
|
|
17
|
+
|
|
18
|
+
WHAT IT DOES NOT OWN
|
|
19
|
+
Persistence (storage.py), the decision to write one (the `remember`
|
|
20
|
+
tool plus D26's approval gate), and WHERE the fragment is appended --
|
|
21
|
+
which is agents/manager.py for an agent run and the shells for a plain
|
|
22
|
+
chat turn.
|
|
23
|
+
|
|
24
|
+
THE FRAGMENT MUST BE APPENDED OUTSIDE with_catalogs() (M13). That function
|
|
25
|
+
feeds prompts.system_prompts.pass_prompt(), so injecting there would put
|
|
26
|
+
every durable memory into all ten research passes -- a run the user
|
|
27
|
+
started separately, from a shell that wrote none of them. This is the same
|
|
28
|
+
trap §19 recorded as K6 for skill bodies, and this is its second instance.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
import logging
|
|
32
|
+
from typing import Optional
|
|
33
|
+
|
|
34
|
+
import config
|
|
35
|
+
from core import config_loader
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger(__name__)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class MemoryManager:
|
|
41
|
+
"""Scope resolution and prompt assembly over storage's UserMemory rows."""
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def scope_path() -> Optional[str]:
|
|
45
|
+
"""The project path memories are scoped to this session, or None.
|
|
46
|
+
|
|
47
|
+
One resolution point, over config_loader's already-resolved value,
|
|
48
|
+
so "which project" cannot mean one thing to the trust store and
|
|
49
|
+
another to memory (D25).
|
|
50
|
+
"""
|
|
51
|
+
return config_loader.get_project_path()
|
|
52
|
+
|
|
53
|
+
def visible(self, scope: Optional[str] = None) -> list:
|
|
54
|
+
"""Every memory this session may see, newest first.
|
|
55
|
+
|
|
56
|
+
Global rows plus the project rows recorded against exactly this
|
|
57
|
+
path (§21 AC6).
|
|
58
|
+
|
|
59
|
+
NO RESOLVED PROJECT MEANS NO MEMORIES AT ALL, not global-only.
|
|
60
|
+
scope_path() is None exactly when config_loader.initialize() has
|
|
61
|
+
not run, and main.py runs it at startup -- so this is "there is no
|
|
62
|
+
session", not "this session happens to be outside a project". It
|
|
63
|
+
follows the convention get_agents()/get_skills() already set:
|
|
64
|
+
uninitialized is materially the same state as initialized-and-empty
|
|
65
|
+
for every consumer, and answering with rows would mean reading a
|
|
66
|
+
database on behalf of a session that does not exist.
|
|
67
|
+
"""
|
|
68
|
+
from storage import list_memories
|
|
69
|
+
|
|
70
|
+
path = self.scope_path()
|
|
71
|
+
if path is None:
|
|
72
|
+
return []
|
|
73
|
+
return list_memories(project_path=path, scope=scope)
|
|
74
|
+
|
|
75
|
+
def wants_memories(self, agent) -> bool:
|
|
76
|
+
"""Does this run get memories injected?
|
|
77
|
+
|
|
78
|
+
M13: `agent=None` -- a plain chat turn with no active agent -- counts
|
|
79
|
+
as opted IN. The frontmatter parser already defaults `use_memory` to
|
|
80
|
+
True, so an agent that says nothing gets them, and treating "no agent
|
|
81
|
+
at all" differently would make the whole feature invisible in the
|
|
82
|
+
default shell until someone happened to run /agent. That is the §25
|
|
83
|
+
shape: a capability a whole shell cannot reach.
|
|
84
|
+
|
|
85
|
+
`use_memory: false` still opts out, which is how the compactor and
|
|
86
|
+
the pipeline reviewer stay out of it.
|
|
87
|
+
"""
|
|
88
|
+
return agent is None or bool(getattr(agent, "use_memory", True))
|
|
89
|
+
|
|
90
|
+
def prompt_fragment(self, agent=None) -> str:
|
|
91
|
+
"""The `## Remembered` block for this session, or "".
|
|
92
|
+
|
|
93
|
+
ONE assembly point, mirroring skills.manager.prompt_fragment and
|
|
94
|
+
core.loop.with_goal, so every shell that injects memories produces
|
|
95
|
+
the same text.
|
|
96
|
+
|
|
97
|
+
CAPPED, AND THE CAP IS STATED IN THE TEXT (M14). Every in-scope
|
|
98
|
+
memory would otherwise enter every turn forever, which is the
|
|
99
|
+
unbounded context growth §21 exists to fight. Newest first, because
|
|
100
|
+
recency is the only staleness signal available without asking a
|
|
101
|
+
model. The count is reported to the MODEL and not only to a log:
|
|
102
|
+
the model is the consumer, and one that can see it is looking at a
|
|
103
|
+
truncated list can say so, while a log line reaches nobody
|
|
104
|
+
mid-conversation. Same "no silent caps" rule as §20's
|
|
105
|
+
MAX_REVIEW_FINDINGS.
|
|
106
|
+
|
|
107
|
+
A CAP OF 0 MEANS OFF, IN THIS HALF TOO (batch 154). config.yaml
|
|
108
|
+
says so where the value is set, and `remember`'s available_check
|
|
109
|
+
already honours it by hiding the tool. This half did not: `rows[:0]`
|
|
110
|
+
is empty, `total > 0` fires the truncation branch, and every turn
|
|
111
|
+
got a "## Remembered" header announcing "the 0 most recent of 2"
|
|
112
|
+
with a WARNING behind it -- telling the model that remembered
|
|
113
|
+
content exists and is being withheld, while the tool that could
|
|
114
|
+
have earned it is not on the menu.
|
|
115
|
+
"""
|
|
116
|
+
if not self.wants_memories(agent):
|
|
117
|
+
return ""
|
|
118
|
+
rows = self.visible()
|
|
119
|
+
if not rows:
|
|
120
|
+
return ""
|
|
121
|
+
|
|
122
|
+
cap = config.MAX_INJECTED_MEMORIES
|
|
123
|
+
if cap <= 0:
|
|
124
|
+
# `<= 0` because the sentence is "a non-positive cap is off".
|
|
125
|
+
# Only 0 is reachable -- config_schema types this key
|
|
126
|
+
# NonNegativeInt -- so the other half of the comparison is the
|
|
127
|
+
# schema's job and not this line's.
|
|
128
|
+
return ""
|
|
129
|
+
shown, total = rows[:cap], len(rows)
|
|
130
|
+
header = "## Remembered"
|
|
131
|
+
if total > cap:
|
|
132
|
+
logger.warning(
|
|
133
|
+
"Injecting %s of %s memories; the oldest %s are not in this "
|
|
134
|
+
"prompt. Raise config.MAX_INJECTED_MEMORIES or prune with "
|
|
135
|
+
"/forget.", cap, total, total - cap)
|
|
136
|
+
header = (f"{header}\n\nShowing the {cap} most recent of {total}. "
|
|
137
|
+
f"Older ones exist and are not listed here.")
|
|
138
|
+
|
|
139
|
+
lines = [header, ""]
|
|
140
|
+
for row in shown:
|
|
141
|
+
marker = "global" if row["scope"] == "global" else "this project"
|
|
142
|
+
category = f" [{row['category']}]" if row.get("category") else ""
|
|
143
|
+
lines.append(f"- ({marker}){category} {row['content']}")
|
|
144
|
+
return "\n".join(lines)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
manager = MemoryManager()
|