@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,184 +1,184 @@
1
- """
2
- tools/builtin/geometry.py
3
-
4
- Classical 2D/3D geometry: distances, midpoints, lines, circles, polygons,
5
- and triangles. Matrix/vector/tensor work lives in linear_algebra.py --
6
- this tool is specifically for geometric objects and their properties.
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- from typing import Literal, Optional
12
-
13
- from pydantic import BaseModel, Field
14
- from sympy.geometry import Circle, Line, Point, Polygon, Triangle
15
-
16
- from tools.builtin._math_common import (
17
- MathParseError,
18
- _split_warnings,
19
- parse_params,
20
- safe_parse,
21
- serialize,
22
- )
23
-
24
- _OPERATIONS = Literal[
25
- "distance", "midpoint", "is_collinear", "line_intersection",
26
- "circle_area", "circle_circumference",
27
- "polygon_area", "polygon_perimeter", "triangle_properties",
28
- ]
29
-
30
-
31
- class GeometryParams(BaseModel):
32
- operation: _OPERATIONS = Field(..., description="Which operation to perform")
33
- points: Optional[list[list[str]]] = Field(
34
- None, description="List of points, each as [x, y] coordinate strings (numbers or symbolic expressions)"
35
- )
36
- radius: Optional[str] = Field(None, description="Radius, for circle operations (required for circle_area/circle_circumference)")
37
- center: Optional[list[str]] = Field(None, description="Center point [x, y] for circle operations - optional, defaults to [0, 0] (origin) when omitted")
38
- evaluate: bool = Field(False, description="If true, return numeric approximation (e.g. 12.566... instead of 4*pi). Default false keeps exact symbolic form.")
39
- precision: int = Field(15, ge=1, le=50, description="Significant digits when evaluate is true")
40
- symbols: Optional[list[str]] = Field(
41
- None,
42
- description=(
43
- "Multi-character symbol names used in the coordinates or radius, "
44
- "e.g. ['mass', 'width']. Declare them or they are read as "
45
- "products of single letters: 'mass' becomes a*m*s**2. Single "
46
- "letters and names containing an underscore are safe without this."
47
- ),
48
- )
49
-
50
-
51
- TOOL_SCHEMA = {
52
- "name": "geometry",
53
- "description": (
54
- "Classical geometry operations: distance and midpoint between "
55
- "points, collinearity check, line intersection, circle area and "
56
- "circumference, polygon area and perimeter, and triangle "
57
- "properties (area, perimeter, right/equilateral/isosceles checks). "
58
- "Circle operations default the center to the origin when not supplied; results are exact symbolic "
59
- "expressions (e.g. 4*pi, sqrt(2)) unless 'evaluate' is true, which returns a numeric approximation with 'precision' digits."
60
- ),
61
- "input_schema": GeometryParams.model_json_schema(),
62
- }
63
-
64
-
65
- def _to_point(coords: list[str], symbols=None, rewritten=None) -> Point:
66
- return Point(*[safe_parse(c, symbols=symbols, rewritten=rewritten)
67
- for c in coords])
68
-
69
-
70
- def run(params: dict) -> dict:
71
- try:
72
- parsed = parse_params(GeometryParams, params)
73
- except MathParseError as e:
74
- return {"error": str(e)}
75
- # One `rewritten` set across every coordinate and the radius: this tool
76
- # could not reach `symbols=` at all, so a multi-character coordinate was
77
- # rewritten into a product of single letters (batch 131).
78
- rewritten: set = set()
79
- syms = parsed.symbols or None
80
-
81
- def to_point(coords):
82
- return _to_point(coords, syms, rewritten)
83
-
84
- try:
85
- op = parsed.operation
86
- pts = [to_point(p) for p in parsed.points] if parsed.points else []
87
-
88
- if op == "distance":
89
- if len(pts) < 2:
90
- return {"error": "distance requires 2 points (each [x, y])."}
91
- result = pts[0].distance(pts[1])
92
- elif op == "midpoint":
93
- if len(pts) < 2:
94
- return {"error": "midpoint requires 2 points (each [x, y])."}
95
- result = pts[0].midpoint(pts[1])
96
- elif op == "is_collinear":
97
- if len(pts) < 2:
98
- return {"error": "is_collinear requires at least 2 points."}
99
- result = Point.is_collinear(*pts)
100
- elif op == "line_intersection":
101
- if len(pts) < 4:
102
- return {"error": "line_intersection requires 4 points (two per line: [p0,p1] and [p2,p3])."}
103
- if pts[0] == pts[1]:
104
- return {"error": "line_intersection: the first two points must be distinct (first line is degenerate)."}
105
- if pts[2] == pts[3]:
106
- return {"error": "line_intersection: the last two points must be distinct (second line is degenerate)."}
107
- line_a = Line(pts[0], pts[1])
108
- line_b = Line(pts[2], pts[3])
109
- result = line_a.intersection(line_b)
110
- elif op == "circle_area":
111
- if parsed.radius is None:
112
- return {"error": "circle_area requires 'radius'."}
113
- center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
114
- result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).area
115
- elif op == "circle_circumference":
116
- if parsed.radius is None:
117
- return {"error": "circle_circumference requires 'radius'."}
118
- center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
119
- result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).circumference
120
- elif op == "polygon_area":
121
- if len(pts) < 3:
122
- return {"error": f"polygon_area requires at least 3 points (got {len(pts)})."}
123
- # Pre-check collinear/degenerate that would surface as Segment2D
124
- if len(pts) == 3 and Point.is_collinear(*pts):
125
- return {"error": "polygon_area: degenerate polygon (collinear points) - at least 3 non-collinear points required."}
126
- result = Polygon(*pts).area
127
- elif op == "polygon_perimeter":
128
- if len(pts) < 3:
129
- return {"error": f"polygon_perimeter requires at least 3 points (got {len(pts)})."}
130
- if len(pts) == 3 and Point.is_collinear(*pts):
131
- return {"error": "polygon_perimeter: degenerate polygon (collinear points) - at least 3 non-collinear points required."}
132
- result = Polygon(*pts).perimeter
133
- elif op == "triangle_properties":
134
- if len(pts) != 3:
135
- return {"error": f"triangle_properties requires exactly 3 points (got {len(pts)})."}
136
- if Point.is_collinear(*pts):
137
- return {"error": "triangle_properties: degenerate triangle (collinear points) - Segment2D has no triangle properties."}
138
- tri = Triangle(*pts)
139
- if parsed.evaluate:
140
- result = {
141
- "area": str(tri.area.evalf(parsed.precision)),
142
- "perimeter": str(tri.perimeter.evalf(parsed.precision)),
143
- "is_right": tri.is_right(),
144
- "is_equilateral": tri.is_equilateral(),
145
- "is_isosceles": tri.is_isosceles(),
146
- }
147
- else:
148
- result = {
149
- "area": str(tri.area),
150
- "perimeter": str(tri.perimeter),
151
- "is_right": tri.is_right(),
152
- "is_equilateral": tri.is_equilateral(),
153
- "is_isosceles": tri.is_isosceles(),
154
- }
155
- else:
156
- return {"error": f"Unknown operation: {op}"}
157
-
158
- except MathParseError as e:
159
- return {"error": str(e)}
160
- except (IndexError, TypeError) as e:
161
- return {"error": f"Missing or malformed points/parameters for '{op}': {e}"}
162
- except Exception as e:
163
- return {"error": f"Computation failed: {e}"}
164
-
165
- # Numeric-evaluate path: keep exact by default, evaluate only when asked.
166
- if parsed.evaluate and not isinstance(result, (bool, dict)):
167
- try:
168
- if isinstance(result, list):
169
- result = [r.evalf(parsed.precision) if hasattr(r, "evalf") else r for r in result]
170
- elif hasattr(result, "evalf"):
171
- result = result.evalf(parsed.precision)
172
- except Exception:
173
- pass # no numeric form; the exact result is still a correct answer
174
-
175
- # H6, one batch late (batch 143). The evaluate block above stays where it is: a tail
176
- # handler contains the one call that can fail without restructuring the
177
- # function around it, which is `discrete_math`'s shape.
178
- try:
179
- out: dict = {"result": serialize(result, what=op), "operation": op}
180
- except MathParseError as e:
181
- return {"error": str(e)}
182
- if rewritten:
183
- out["warnings"] = _split_warnings(rewritten)
184
- return out
1
+ """
2
+ tools/builtin/geometry.py
3
+
4
+ Classical 2D/3D geometry: distances, midpoints, lines, circles, polygons,
5
+ and triangles. Matrix/vector/tensor work lives in linear_algebra.py --
6
+ this tool is specifically for geometric objects and their properties.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Literal, Optional
12
+
13
+ from pydantic import BaseModel, Field
14
+ from sympy.geometry import Circle, Line, Point, Polygon, Triangle
15
+
16
+ from tools.builtin._math_common import (
17
+ MathParseError,
18
+ _split_warnings,
19
+ parse_params,
20
+ safe_parse,
21
+ serialize,
22
+ )
23
+
24
+ _OPERATIONS = Literal[
25
+ "distance", "midpoint", "is_collinear", "line_intersection",
26
+ "circle_area", "circle_circumference",
27
+ "polygon_area", "polygon_perimeter", "triangle_properties",
28
+ ]
29
+
30
+
31
+ class GeometryParams(BaseModel):
32
+ operation: _OPERATIONS = Field(..., description="Which operation to perform")
33
+ points: Optional[list[list[str]]] = Field(
34
+ None, description="List of points, each as [x, y] coordinate strings (numbers or symbolic expressions)"
35
+ )
36
+ radius: Optional[str] = Field(None, description="Radius, for circle operations (required for circle_area/circle_circumference)")
37
+ center: Optional[list[str]] = Field(None, description="Center point [x, y] for circle operations - optional, defaults to [0, 0] (origin) when omitted")
38
+ evaluate: bool = Field(False, description="If true, return numeric approximation (e.g. 12.566... instead of 4*pi). Default false keeps exact symbolic form.")
39
+ precision: int = Field(15, ge=1, le=50, description="Significant digits when evaluate is true")
40
+ symbols: Optional[list[str]] = Field(
41
+ None,
42
+ description=(
43
+ "Multi-character symbol names used in the coordinates or radius, "
44
+ "e.g. ['mass', 'width']. Declare them or they are read as "
45
+ "products of single letters: 'mass' becomes a*m*s**2. Single "
46
+ "letters and names containing an underscore are safe without this."
47
+ ),
48
+ )
49
+
50
+
51
+ TOOL_SCHEMA = {
52
+ "name": "geometry",
53
+ "description": (
54
+ "Classical geometry operations: distance and midpoint between "
55
+ "points, collinearity check, line intersection, circle area and "
56
+ "circumference, polygon area and perimeter, and triangle "
57
+ "properties (area, perimeter, right/equilateral/isosceles checks). "
58
+ "Circle operations default the center to the origin when not supplied; results are exact symbolic "
59
+ "expressions (e.g. 4*pi, sqrt(2)) unless 'evaluate' is true, which returns a numeric approximation with 'precision' digits."
60
+ ),
61
+ "input_schema": GeometryParams.model_json_schema(),
62
+ }
63
+
64
+
65
+ def _to_point(coords: list[str], symbols=None, rewritten=None) -> Point:
66
+ return Point(*[safe_parse(c, symbols=symbols, rewritten=rewritten)
67
+ for c in coords])
68
+
69
+
70
+ def run(params: dict) -> dict:
71
+ try:
72
+ parsed = parse_params(GeometryParams, params)
73
+ except MathParseError as e:
74
+ return {"error": str(e)}
75
+ # One `rewritten` set across every coordinate and the radius: this tool
76
+ # could not reach `symbols=` at all, so a multi-character coordinate was
77
+ # rewritten into a product of single letters (batch 131).
78
+ rewritten: set = set()
79
+ syms = parsed.symbols or None
80
+
81
+ def to_point(coords):
82
+ return _to_point(coords, syms, rewritten)
83
+
84
+ try:
85
+ op = parsed.operation
86
+ pts = [to_point(p) for p in parsed.points] if parsed.points else []
87
+
88
+ if op == "distance":
89
+ if len(pts) < 2:
90
+ return {"error": "distance requires 2 points (each [x, y])."}
91
+ result = pts[0].distance(pts[1])
92
+ elif op == "midpoint":
93
+ if len(pts) < 2:
94
+ return {"error": "midpoint requires 2 points (each [x, y])."}
95
+ result = pts[0].midpoint(pts[1])
96
+ elif op == "is_collinear":
97
+ if len(pts) < 2:
98
+ return {"error": "is_collinear requires at least 2 points."}
99
+ result = Point.is_collinear(*pts)
100
+ elif op == "line_intersection":
101
+ if len(pts) < 4:
102
+ return {"error": "line_intersection requires 4 points (two per line: [p0,p1] and [p2,p3])."}
103
+ if pts[0] == pts[1]:
104
+ return {"error": "line_intersection: the first two points must be distinct (first line is degenerate)."}
105
+ if pts[2] == pts[3]:
106
+ return {"error": "line_intersection: the last two points must be distinct (second line is degenerate)."}
107
+ line_a = Line(pts[0], pts[1])
108
+ line_b = Line(pts[2], pts[3])
109
+ result = line_a.intersection(line_b)
110
+ elif op == "circle_area":
111
+ if parsed.radius is None:
112
+ return {"error": "circle_area requires 'radius'."}
113
+ center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
114
+ result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).area
115
+ elif op == "circle_circumference":
116
+ if parsed.radius is None:
117
+ return {"error": "circle_circumference requires 'radius'."}
118
+ center = to_point(parsed.center) if parsed.center is not None else Point(0, 0)
119
+ result = Circle(center, safe_parse(parsed.radius, symbols=syms, rewritten=rewritten)).circumference
120
+ elif op == "polygon_area":
121
+ if len(pts) < 3:
122
+ return {"error": f"polygon_area requires at least 3 points (got {len(pts)})."}
123
+ # Pre-check collinear/degenerate that would surface as Segment2D
124
+ if len(pts) == 3 and Point.is_collinear(*pts):
125
+ return {"error": "polygon_area: degenerate polygon (collinear points) - at least 3 non-collinear points required."}
126
+ result = Polygon(*pts).area
127
+ elif op == "polygon_perimeter":
128
+ if len(pts) < 3:
129
+ return {"error": f"polygon_perimeter requires at least 3 points (got {len(pts)})."}
130
+ if len(pts) == 3 and Point.is_collinear(*pts):
131
+ return {"error": "polygon_perimeter: degenerate polygon (collinear points) - at least 3 non-collinear points required."}
132
+ result = Polygon(*pts).perimeter
133
+ elif op == "triangle_properties":
134
+ if len(pts) != 3:
135
+ return {"error": f"triangle_properties requires exactly 3 points (got {len(pts)})."}
136
+ if Point.is_collinear(*pts):
137
+ return {"error": "triangle_properties: degenerate triangle (collinear points) - Segment2D has no triangle properties."}
138
+ tri = Triangle(*pts)
139
+ if parsed.evaluate:
140
+ result = {
141
+ "area": str(tri.area.evalf(parsed.precision)),
142
+ "perimeter": str(tri.perimeter.evalf(parsed.precision)),
143
+ "is_right": tri.is_right(),
144
+ "is_equilateral": tri.is_equilateral(),
145
+ "is_isosceles": tri.is_isosceles(),
146
+ }
147
+ else:
148
+ result = {
149
+ "area": str(tri.area),
150
+ "perimeter": str(tri.perimeter),
151
+ "is_right": tri.is_right(),
152
+ "is_equilateral": tri.is_equilateral(),
153
+ "is_isosceles": tri.is_isosceles(),
154
+ }
155
+ else:
156
+ return {"error": f"Unknown operation: {op}"}
157
+
158
+ except MathParseError as e:
159
+ return {"error": str(e)}
160
+ except (IndexError, TypeError) as e:
161
+ return {"error": f"Missing or malformed points/parameters for '{op}': {e}"}
162
+ except Exception as e:
163
+ return {"error": f"Computation failed: {e}"}
164
+
165
+ # Numeric-evaluate path: keep exact by default, evaluate only when asked.
166
+ if parsed.evaluate and not isinstance(result, (bool, dict)):
167
+ try:
168
+ if isinstance(result, list):
169
+ result = [r.evalf(parsed.precision) if hasattr(r, "evalf") else r for r in result]
170
+ elif hasattr(result, "evalf"):
171
+ result = result.evalf(parsed.precision)
172
+ except Exception:
173
+ pass # no numeric form; the exact result is still a correct answer
174
+
175
+ # H6, one batch late (batch 143). The evaluate block above stays where it is: a tail
176
+ # handler contains the one call that can fail without restructuring the
177
+ # function around it, which is `discrete_math`'s shape.
178
+ try:
179
+ out: dict = {"result": serialize(result, what=op), "operation": op}
180
+ except MathParseError as e:
181
+ return {"error": str(e)}
182
+ if rewritten:
183
+ out["warnings"] = _split_warnings(rewritten)
184
+ return out
@@ -1,76 +1,76 @@
1
- """
2
- tools/builtin/load_skill.py
3
-
4
- Skill progressive disclosure (ROADMAP_v2 §14): the model's system prompt
5
- lists available skills as name + one-line description only; this tool
6
- returns a skill's full body on request. View-only -- activation
7
- semantics (additional_tools, slash commands) belong to §19's
8
- SkillManager, not here.
9
- """
10
-
11
- from core import config_loader
12
-
13
- TOOL_SCHEMA = {
14
- "name": "load_skill",
15
- "description": "View the full instructions of an available skill. "
16
- "The system prompt lists available skills by name and "
17
- "one-line summary; call this with a skill name to load "
18
- "its complete methodology before following it.",
19
- "input_schema": {
20
- "type": "object",
21
- "properties": {
22
- "name": {
23
- "type": "string",
24
- "description": "Skill name exactly as listed in the "
25
- "Available skills catalog.",
26
- },
27
- },
28
- "required": ["name"],
29
- },
30
- }
31
-
32
-
33
- def has_skills() -> bool:
34
- """ToolSpec.available_check (ROADMAP_v2 §15, review finding F5).
35
-
36
- With no skills discovered -- or before config_loader.initialize() has
37
- run at all -- the system prompt carries no catalog, so this tool's
38
- only possible answer is "Unknown skill". Advertising it anyway is the
39
- same defect shape as the fetch_url one §15 exists to fix: a schema the
40
- model can see, choose, and never get value from. Returning False here
41
- keeps it out of registry.schemas() until there is something to load.
42
-
43
- Reads the SAME function prompt assembly uses (skill_catalog_text, via
44
- prompts/system_prompts.with_skill_catalog) rather than a parallel
45
- check, so "advertised" and "catalogued" cannot drift apart.
46
- """
47
- return bool(config_loader.skill_catalog_text())
48
-
49
-
50
- def run(params: dict) -> dict:
51
- # params.get, not params[]. NO provider validates tool inputs against
52
- # the schema, so a call with the key missing or misspelled raised a
53
- # bare KeyError -- and _run() catches only ToolCallDenied, so it
54
- # aborted the whole turn, skipped any remaining batched tool calls,
55
- # and persisted no tool_result for the tool_use id. An error dict
56
- # lets the model see what it got wrong and correct itself, which is
57
- # what the unknown-name branch two lines down already does.
58
- #
59
- # THE ONE OF THESE WRITTEN IN THE PAST TENSE, and therefore the one
60
- # that stayed true: four siblings said the same thing in the PRESENT
61
- # tense, and dispatch() has contained a handler's exception since
62
- # well before they were written. The last two clauses are the
63
- # precise ones -- the parallel path converts a raise into THIS call's
64
- # error result so the siblings' finished work and the tool_use id's
65
- # reply both survive. tools/base.py carries the one copy of all of it
66
- # now, including the half none of these mentioned: a GATE's raise is
67
- # not contained (batch 146).
68
- name = params.get("name")
69
- if not name:
70
- return {"error": "load_skill requires a 'name' -- the skill's name "
71
- "exactly as listed in the available skills catalog."}
72
- skill = config_loader.get_skill(name)
73
- if skill is None:
74
- return {"error": f"Unknown skill: {name!r} is not in "
75
- f"the available skills catalog."}
76
- return {"result": skill.body}
1
+ """
2
+ tools/builtin/load_skill.py
3
+
4
+ Skill progressive disclosure (ROADMAP_v2 §14): the model's system prompt
5
+ lists available skills as name + one-line description only; this tool
6
+ returns a skill's full body on request. View-only -- activation
7
+ semantics (additional_tools, slash commands) belong to §19's
8
+ SkillManager, not here.
9
+ """
10
+
11
+ from core import config_loader
12
+
13
+ TOOL_SCHEMA = {
14
+ "name": "load_skill",
15
+ "description": "View the full instructions of an available skill. "
16
+ "The system prompt lists available skills by name and "
17
+ "one-line summary; call this with a skill name to load "
18
+ "its complete methodology before following it.",
19
+ "input_schema": {
20
+ "type": "object",
21
+ "properties": {
22
+ "name": {
23
+ "type": "string",
24
+ "description": "Skill name exactly as listed in the "
25
+ "Available skills catalog.",
26
+ },
27
+ },
28
+ "required": ["name"],
29
+ },
30
+ }
31
+
32
+
33
+ def has_skills() -> bool:
34
+ """ToolSpec.available_check (ROADMAP_v2 §15, review finding F5).
35
+
36
+ With no skills discovered -- or before config_loader.initialize() has
37
+ run at all -- the system prompt carries no catalog, so this tool's
38
+ only possible answer is "Unknown skill". Advertising it anyway is the
39
+ same defect shape as the fetch_url one §15 exists to fix: a schema the
40
+ model can see, choose, and never get value from. Returning False here
41
+ keeps it out of registry.schemas() until there is something to load.
42
+
43
+ Reads the SAME function prompt assembly uses (skill_catalog_text, via
44
+ prompts/system_prompts.with_skill_catalog) rather than a parallel
45
+ check, so "advertised" and "catalogued" cannot drift apart.
46
+ """
47
+ return bool(config_loader.skill_catalog_text())
48
+
49
+
50
+ def run(params: dict) -> dict:
51
+ # params.get, not params[]. NO provider validates tool inputs against
52
+ # the schema, so a call with the key missing or misspelled raised a
53
+ # bare KeyError -- and _run() catches only ToolCallDenied, so it
54
+ # aborted the whole turn, skipped any remaining batched tool calls,
55
+ # and persisted no tool_result for the tool_use id. An error dict
56
+ # lets the model see what it got wrong and correct itself, which is
57
+ # what the unknown-name branch two lines down already does.
58
+ #
59
+ # THE ONE OF THESE WRITTEN IN THE PAST TENSE, and therefore the one
60
+ # that stayed true: four siblings said the same thing in the PRESENT
61
+ # tense, and dispatch() has contained a handler's exception since
62
+ # well before they were written. The last two clauses are the
63
+ # precise ones -- the parallel path converts a raise into THIS call's
64
+ # error result so the siblings' finished work and the tool_use id's
65
+ # reply both survive. tools/base.py carries the one copy of all of it
66
+ # now, including the half none of these mentioned: a GATE's raise is
67
+ # not contained (batch 146).
68
+ name = params.get("name")
69
+ if not name:
70
+ return {"error": "load_skill requires a 'name' -- the skill's name "
71
+ "exactly as listed in the available skills catalog."}
72
+ skill = config_loader.get_skill(name)
73
+ if skill is None:
74
+ return {"error": f"Unknown skill: {name!r} is not in "
75
+ f"the available skills catalog."}
76
+ return {"result": skill.body}