pantheon-opencode 1.6.0-beta.14 → 1.6.0-beta.17

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 (50) hide show
  1. package/AGENTS.global.md +8 -10
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +62 -3
  4. package/README.md +155 -24
  5. package/README.pt-BR.md +14 -14
  6. package/package.json +3 -3
  7. package/plugin.json +1 -1
  8. package/pyproject.toml +1 -1
  9. package/scripts/_pantheon_paths.py +24 -0
  10. package/scripts/doctor.mjs +7 -2
  11. package/scripts/install-mcp.mjs +1 -1
  12. package/scripts/mcp_persistence.py +1260 -1017
  13. package/scripts/memory_mcp.py +12 -843
  14. package/scripts/test-opencode-v2-sandbox.sh +2 -115
  15. package/skills-lock.json +3 -3
  16. package/src/agents/aphrodite.md +11 -10
  17. package/src/agents/apollo.md +1 -2
  18. package/src/agents/athena.md +13 -13
  19. package/src/agents/demeter.md +10 -7
  20. package/src/agents/gaia.md +0 -1
  21. package/src/agents/hephaestus.md +4 -3
  22. package/src/agents/hermes.md +10 -9
  23. package/src/agents/iris.md +0 -1
  24. package/src/agents/mnemosyne.md +3 -2
  25. package/src/agents/nyx.md +4 -4
  26. package/src/agents/prometheus.md +12 -11
  27. package/src/agents/zeus.md +27 -2
  28. package/src/instructions/agent-return-format.instructions.md +7 -9
  29. package/src/instructions/zeus-council-synthesis.instructions.md +2 -2
  30. package/src/instructions/zeus-memory-operations.instructions.md +9 -1
  31. package/src/instructions/zeus-timeout-retry.instructions.md +8 -1
  32. package/src/mcp/_pantheon_paths.py +24 -0
  33. package/src/mcp/mcp_codemap_module.py +86 -18
  34. package/src/mcp/mcp_persistence.py +1260 -1017
  35. package/src/mcp/memory_mcp.py +101 -57
  36. package/src/pantheon/goal-loop.ts +11 -8
  37. package/src/pantheon/task-result-guard.ts +50 -14
  38. package/src/pantheon/v2-execute-after.ts +135 -24
  39. package/src/pantheon/v2-tools.ts +10 -1
  40. package/src/plugin-v2.ts +6 -4
  41. package/src/plugin.ts +3 -2
  42. package/src/plugins/tui/dist/tui-v2.js +2 -2
  43. package/src/plugins/tui/dist/tui.js +1 -1
  44. package/src/plugins/tui/package-lock.json +2 -2
  45. package/src/plugins/tui/package.json +1 -1
  46. package/src/routing.yml +4 -4
  47. package/src/skills/codemap/SKILL.md +1 -1
  48. package/src/skills/memory-bank/SKILL.md +17 -13
  49. package/src/skills/session-goal/SKILL.md +12 -22
  50. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -1,263 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from 'node:child_process'
3
- /**
4
- * Offline/ambiental probe for context_rehydrate and context_session_summary.
5
- *
6
- * The Python child imports the installed persistence server and exercises the
7
- * real FastMCP tools against a temporary SQLite database. No OpenCode command,
8
- * network call, LLM, or user database is involved. Missing package/runtime is
9
- * NOT_TESTED/AMBIENTAL rather than a false PASS.
10
- */
11
- import { existsSync, mkdtempSync, rmSync } from 'node:fs'
12
- import { tmpdir } from 'node:os'
13
- import { join } from 'node:path'
14
- import { fileURLToPath } from 'node:url'
15
-
16
- const requestedVersion = valueFor('--version')
17
- const jsonOutput = process.argv.includes('--json')
18
- const runtime = fileURLToPath(new URL('./mcp_persistence.py', import.meta.url))
19
-
20
- function valueFor(name) {
21
- const index = process.argv.indexOf(name)
22
- return index >= 0 ? process.argv[index + 1] : undefined
23
- }
24
-
25
- function emit(status, detail, checks = []) {
26
- const result = { status, version: requestedVersion, detail, checks }
27
- if (jsonOutput) process.stdout.write(JSON.stringify(result))
28
- else process.stdout.write(`${status}: ${detail}\n`)
29
- if (status === 'FAIL') process.exitCode = 1
30
- }
31
-
32
- function unavailable(detail) {
33
- emit('NOT_TESTED', detail)
34
- }
35
-
36
- function pythonCandidates() {
37
- const venvPython = process.env.HOME
38
- ? join(process.env.HOME, '.config', 'opencode', '.venv', 'bin', 'python')
39
- : undefined
40
- return [process.env.PANTHEON_PYTHON, venvPython, 'python3'].filter(Boolean)
41
- }
42
-
43
- const PYTHON_HARNESS = `
44
- import asyncio
45
- import importlib.util
46
- import json
47
- import os
48
- import sys
49
- from pathlib import Path
50
-
51
- runtime_path = Path(sys.argv[1]).resolve()
52
- db_root = Path(sys.argv[2]).resolve()
53
- sys.path.insert(0, str(runtime_path.parent))
54
- sys.argv = [str(runtime_path), "--global-db", str(db_root / "global.db"),
55
- "--project-db", str(db_root / "project.db")]
56
-
57
- spec = importlib.util.spec_from_file_location("probe_mcp_persistence", runtime_path)
58
- if spec is None or spec.loader is None:
59
- raise RuntimeError("could not load persistence runtime")
60
- module = importlib.util.module_from_spec(spec)
61
- spec.loader.exec_module(module)
62
-
63
-
64
- async def call(name, arguments):
65
- result = await module.mcp.call_tool(name, arguments)
66
- structured = getattr(result, "structured_content", None)
67
- if structured is not None:
68
- metadata = getattr(result, "meta", None) or {}
69
- if metadata.get("fastmcp", {}).get("wrap_result"):
70
- return structured.get("result") if isinstance(structured, dict) else structured
71
- return structured
72
- if isinstance(result, tuple):
73
- structured = result[1]
74
- if structured is not None:
75
- if isinstance(structured, dict) and "result" in structured:
76
- return structured["result"]
77
- return structured
78
- result = result[0]
79
- if isinstance(result, dict):
80
- return result
81
- if not result:
82
- return None
83
- text = getattr(result[0], "text", str(result[0]))
84
- try:
85
- return json.loads(text)
86
- except (TypeError, ValueError, json.JSONDecodeError):
87
- return text
88
-
89
-
90
- async def main():
91
- checks = []
92
- slug = "context-rehydrate-probe"
93
- session_id = "synthetic-session"
94
- checkpoint = {
95
- "version": 1,
96
- "goal": {"id": "probe-goal", "objective": "verify context recovery",
97
- "status": "in_progress"},
98
- "phase": {"current": 2, "total": 3, "name": "offline validation"},
99
- "delegations": {"in_flight": [{"alias": "apo-probe", "agent": "apollo",
100
- "task_id": "probe-task"}]},
101
- }
102
- tail = ["phase 1 complete", "phase 2 payload validated"]
103
-
104
- # context_save creates the real session-qualified latest pointer. Keeping
105
- # tail under its own key also tests the runtime's latest/tail fallback.
106
- await call("context_save", {"slug": slug, "key": "tail",
107
- "content": json.dumps(tail),
108
- "session_id": session_id})
109
- await call("context_save", {"slug": slug, "key": "phase:2",
110
- "content": json.dumps(checkpoint),
111
- "session_id": session_id})
112
- latest = await call("context_get", {"slug": slug, "key": "latest",
113
- "session_id": session_id})
114
- stored_tail = await call("context_get", {"slug": slug, "key": "tail",
115
- "session_id": session_id})
116
- if latest is None or stored_tail is None:
117
- raise AssertionError("synthetic latest/tail checkpoint payload is null")
118
- checks.append("synthetic latest/tail/goal/phase/delegation checkpoint: PASS")
119
-
120
- os.environ.pop("PANTHEON_COMPACTION", None)
121
- os.environ.pop("PANTHEON_SESSION_END_SUMMARY", None)
122
- blocks = await call("context_rehydrate", {"slug": slug,
123
- "session_id": session_id})
124
- summary = await call("context_session_summary", {"slug": slug,
125
- "session_id": session_id})
126
- if not isinstance(blocks, list) or not blocks:
127
- raise AssertionError("context_rehydrate returned a null/empty payload")
128
- if not isinstance(summary, str) or not summary:
129
- raise AssertionError("context_session_summary returned a null/empty payload")
130
- for fragment in ("verify context recovery", "phase 2/3", "apo-probe",
131
- "phase 2 payload validated"):
132
- if not any(fragment in block for block in blocks) and fragment not in summary:
133
- raise AssertionError(f"payload is missing {fragment!r}")
134
- checks.append("context_rehydrate non-null payload: PASS")
135
- checks.append("context_session_summary non-null payload: PASS")
136
-
137
- missing_blocks = await call("context_rehydrate", {"slug": "probe-absent",
138
- "session_id": session_id})
139
- missing_summary = await call("context_session_summary", {"slug": "probe-absent",
140
- "session_id": session_id})
141
- if missing_blocks is not None or missing_summary is not None:
142
- raise AssertionError("absent checkpoint must return null payloads")
143
- checks.append("absence returns null: PASS")
144
-
145
- expired_slug = "context-expired-probe"
146
- await call("context_save", {"slug": expired_slug, "key": "phase:1",
147
- "content": json.dumps(checkpoint), "ttl": 1,
148
- "session_id": session_id})
149
- # Use the public TTL contract (positive seconds) and let the entry expire;
150
- # negative TTLs are rejected by validation and must not be special-cased.
151
- await asyncio.sleep(1.2)
152
- expired_blocks = await call("context_rehydrate", {"slug": expired_slug,
153
- "session_id": session_id})
154
- expired_summary = await call("context_session_summary", {"slug": expired_slug,
155
- "session_id": session_id})
156
- if expired_blocks is not None or expired_summary is not None:
157
- raise AssertionError("expired checkpoint must return null payloads")
158
- checks.append("expiration returns null: PASS")
159
-
160
- invalid_slug = "context-invalid-probe"
161
- await call("context_save", {"slug": invalid_slug, "key": "phase:1",
162
- "content": "not-json", "session_id": session_id})
163
- invalid_blocks = await call("context_rehydrate", {"slug": invalid_slug,
164
- "session_id": session_id})
165
- invalid_summary = await call("context_session_summary", {"slug": invalid_slug,
166
- "session_id": session_id})
167
- if invalid_blocks is not None or invalid_summary is not None:
168
- raise AssertionError("invalid checkpoint must return null payloads")
169
- checks.append("invalid payload returns null: PASS")
170
-
171
- os.environ["PANTHEON_COMPACTION"] = "off"
172
- switched_blocks = await call("context_rehydrate", {"slug": slug,
173
- "session_id": session_id})
174
- if switched_blocks is not None:
175
- raise AssertionError("PANTHEON_COMPACTION=off must return null")
176
- os.environ.pop("PANTHEON_COMPACTION", None)
177
- os.environ["PANTHEON_SESSION_END_SUMMARY"] = "off"
178
- switched_summary = await call("context_session_summary", {"slug": slug,
179
- "session_id": session_id})
180
- if switched_summary is not None:
181
- raise AssertionError("PANTHEON_SESSION_END_SUMMARY=off must return null")
182
- checks.append("kill-switches return null: PASS")
183
- print(json.dumps({"checks": checks}))
184
-
185
-
186
- asyncio.run(main())
187
- `
188
-
189
- async function main() {
190
- if (requestedVersion !== 'v1' && requestedVersion !== 'v2') {
191
- emit('FAIL', 'usage: --version v1|v2 [--json]')
192
- return
193
- }
194
- if (!existsSync(runtime)) {
195
- unavailable('installed package does not include mcp_persistence.py')
196
- return
197
- }
198
-
199
- const root = mkdtempSync(join(tmpdir(), 'pantheon-context-probe-'))
200
- const dbRoot = join(root, 'db')
201
- const python = pythonCandidates().find((candidate) =>
202
- candidate.includes('/') ? existsSync(candidate) : true,
203
- )
204
- if (!python) {
205
- rmSync(root, { recursive: true, force: true })
206
- unavailable('Python persistence runtime is not available')
207
- return
208
- }
209
-
210
- try {
211
- const child = spawnSync(python, ['-c', PYTHON_HARNESS, runtime, dbRoot], {
212
- encoding: 'utf8',
213
- timeout: 30000,
214
- env: process.env,
215
- })
216
- if (child.error) {
217
- const detail = child.error instanceof Error ? child.error.message : String(child.error)
218
- if (/EACCES|permission denied|not found/i.test(detail)) {
219
- emit('AMBIENTAL', `persistence runtime unavailable: ${detail}`)
220
- } else {
221
- unavailable(`persistence runtime unavailable: ${detail}`)
222
- }
223
- return
224
- }
225
- if (child.signal === 'SIGTERM') {
226
- emit('AMBIENTAL', 'persistence probe timed out after 30s')
227
- return
228
- }
229
- if (/IncompleteFieldDefinitionWarning|pydantic_settings/i.test(child.stderr)) {
230
- emit('FAIL', 'persistence probe emitted an incomplete pydantic_settings field warning')
231
- return
232
- }
233
- if (child.status !== 0) {
234
- const detail = `${child.stderr || child.stdout || 'persistence probe failed'}`.trim()
235
- if (
236
- /No module named|ModuleNotFoundError|can't open file|No such file|importerror/i.test(detail)
237
- ) {
238
- unavailable(`persistence runtime unavailable: ${detail.slice(0, 320)}`)
239
- } else {
240
- emit('FAIL', `offline persistence checks failed: ${detail.slice(0, 320)}`)
241
- }
242
- return
243
- }
244
-
245
- const lines = child.stdout.trim().split('\n').filter(Boolean)
246
- const payload = JSON.parse(lines.at(-1) || '')
247
- if (!Array.isArray(payload.checks) || payload.checks.length < 6) {
248
- emit('FAIL', 'offline persistence probe returned incomplete checks')
249
- return
250
- }
251
- emit(
252
- 'PASS',
253
- 'offline synthetic persistence checks passed; no LLM or user DB was used',
254
- payload.checks,
255
- )
256
- } catch (error) {
257
- emit('FAIL', error instanceof Error ? error.message : String(error))
258
- } finally {
259
- rmSync(root, { recursive: true, force: true })
260
- }
261
- }
262
-
263
- await main()