pantheon-opencode 1.6.2-beta.4 → 1.6.2-beta.5

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 (54) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +174 -3
  3. package/bin/pantheon-init.mjs +6 -1
  4. package/package.json +1 -1
  5. package/plugin.json +1 -1
  6. package/pyproject.toml +1 -1
  7. package/scripts/decision-router-budget.mjs +3 -3
  8. package/scripts/decision-router-v2-budget.mjs +218 -0
  9. package/scripts/decision-router-v2-egress.mjs +272 -0
  10. package/scripts/decision-router.mjs +268 -46
  11. package/scripts/docs-check-changelog.mjs +5 -3
  12. package/scripts/install/decision-layer-preview.mjs +376 -0
  13. package/scripts/install/decision-router-config.mjs +158 -11
  14. package/scripts/mcp_resources.py +11 -9
  15. package/scripts/release-notes.mjs +30 -7
  16. package/scripts/versioning.mjs +41 -5
  17. package/src/mcp/eval_store.py +11 -4
  18. package/src/mcp/mcp_resources.py +11 -9
  19. package/src/mcp/memory_mcp.py +293 -150
  20. package/src/pantheon/local-decision-prompt.ts +181 -36
  21. package/src/pantheon/local-decision-skills.ts +115 -5
  22. package/src/pantheon/local-decision-tool.ts +35 -1
  23. package/src/pantheon/v2-decision-budget.ts +456 -0
  24. package/src/pantheon/v2-decision-contracts.ts +300 -0
  25. package/src/pantheon/v2-decision-egress.ts +203 -0
  26. package/src/pantheon/v2-decision-events.ts +180 -0
  27. package/src/pantheon/v2-decision-heuristic.ts +121 -0
  28. package/src/pantheon/v2-decision-points/p1-agent.ts +91 -0
  29. package/src/pantheon/v2-decision-points/p10-claims.ts +243 -0
  30. package/src/pantheon/v2-decision-points/p11-catalog.ts +220 -0
  31. package/src/pantheon/v2-decision-points/p2-skill.ts +83 -0
  32. package/src/pantheon/v2-decision-points/p3-complexity.ts +108 -0
  33. package/src/pantheon/v2-decision-points/p4-memory.ts +137 -0
  34. package/src/pantheon/v2-decision-points/p5-themis-verify.ts +190 -0
  35. package/src/pantheon/v2-decision-points/p6-council.ts +161 -0
  36. package/src/pantheon/v2-decision-points/p7-loop.ts +263 -0
  37. package/src/pantheon/v2-decision-points/p8-guardrail.ts +366 -0
  38. package/src/pantheon/v2-decision-points/p9-memory-compaction.ts +304 -0
  39. package/src/pantheon/v2-decision-points.ts +242 -0
  40. package/src/pantheon/v2-decision-policy.ts +166 -0
  41. package/src/pantheon/v2-decision-premises.ts +146 -0
  42. package/src/pantheon/v2-decision-prompt-surface.ts +115 -0
  43. package/src/pantheon/v2-decision-rank.ts +91 -0
  44. package/src/pantheon/v2-decision-registry.ts +391 -0
  45. package/src/pantheon/v2-decision-resource-ids.ts +127 -0
  46. package/src/pantheon/v2-decision-shadow.ts +123 -0
  47. package/src/pantheon/v2-decision-telemetry.ts +214 -0
  48. package/src/pantheon/v2-decision-verify.ts +51 -0
  49. package/src/pantheon/v2-tools.ts +21 -2
  50. package/src/plugin-v2.ts +305 -3
  51. package/src/plugins/tui/dist/tui-v2.js +3 -3
  52. package/src/plugins/tui/dist/tui.js +1 -1
  53. package/src/plugins/tui/package-lock.json +2 -2
  54. package/src/plugins/tui/package.json +1 -1
@@ -19,8 +19,8 @@
19
19
  * bullet `- #N - <subject>` per referenced issue
20
20
  * (deduped); the group is OMITTED when no refs exist
21
21
  *
22
- * Omitted (internal, never user-facing): chore | refactor | test | ci |
23
- * build | style | revert (unknown conventional types too).
22
+ * Omitted (internal, never user-facing): release scope and chore | refactor |
23
+ * test | ci | build | style | revert (unknown conventional types too).
24
24
  *
25
25
  * Breaking: `BREAKING CHANGE` footer or `type!:` / `type(scope)!:` — the
26
26
  * commit keeps its type bucket and the bullet is prefixed with 💥
@@ -126,6 +126,27 @@ function parseIssueRefs(body) {
126
126
  return [...body.matchAll(/\b(?:Closes|Fixes|Resolves)\s+#(\d+)\b/gi)].map((m) => Number(m[1]))
127
127
  }
128
128
 
129
+ /**
130
+ * Detect the documented BREAKING CHANGE trailer in the final body paragraph.
131
+ * The marker must be a trailer line, not a phrase embedded in body prose.
132
+ *
133
+ * @param {string} body
134
+ * @returns {boolean}
135
+ */
136
+ function hasBreakingFooter(body) {
137
+ const footerLines = body
138
+ .trimEnd()
139
+ .split(/\r?\n(?:[ \t]*\r?\n)+/)
140
+ .at(-1)
141
+ .split(/\r?\n/)
142
+ const isTrailerLine = /^[A-Za-z][A-Za-z-]*(?: [A-Za-z][A-Za-z-]*)*:[ \t]+\S/
143
+
144
+ return (
145
+ isTrailerLine.test(footerLines[0]) &&
146
+ footerLines.some((line) => /^BREAKING CHANGE:[ \t]+\S.*$/i.test(line))
147
+ )
148
+ }
149
+
129
150
  /**
130
151
  * Parse one "subject|body" record into a conventional-commit entry.
131
152
  * Returns null for records that must be skipped: merge commits ("Merge ..."),
@@ -151,7 +172,7 @@ export function parseCommitLine(line) {
151
172
  type: type.toLowerCase(),
152
173
  scope: scope || null,
153
174
  subject: cleanSubject,
154
- breaking: Boolean(bang) || /BREAKING CHANGE/i.test(body),
175
+ breaking: Boolean(bang) || hasBreakingFooter(body),
155
176
  refs: parseIssueRefs(body),
156
177
  }
157
178
  }
@@ -159,7 +180,8 @@ export function parseCommitLine(line) {
159
180
  /**
160
181
  * Conventional type → final release-note group. Types missing from this map
161
182
  * (chore, refactor, test, ci, build, style, revert, unknown) are internal
162
- * and omitted from the notes.
183
+ * and omitted from the notes. The maintainer-only `release` scope is also
184
+ * omitted, including its issue references.
163
185
  */
164
186
  const TYPE_GROUPS = {
165
187
  feat: 'whatsNew',
@@ -172,8 +194,9 @@ const TYPE_GROUPS = {
172
194
  /**
173
195
  * Group parsed commits into the final release-note sections. Breaking
174
196
  * commits keep their type bucket (the 💥 marker is applied at render time);
175
- * internal types are dropped; issue refs from ANY commit body feed
176
- * closedIssues (deduped, first occurrence wins). Entries keep git log order.
197
+ * internal types and the `release` scope are dropped; issue refs from remaining
198
+ * commit bodies feed closedIssues (deduped, first occurrence wins). Entries
199
+ * keep git log order.
177
200
  *
178
201
  * @param {Array<ReturnType<typeof parseCommitLine>>} entries
179
202
  * @param {{knownIssues?: string[]|string|null}} [options]
@@ -192,7 +215,7 @@ export function groupCommits(entries, options = {}) {
192
215
  }
193
216
  const seenRefs = new Set()
194
217
  for (const entry of entries) {
195
- if (!entry) continue
218
+ if (!entry || entry.scope === 'release') continue
196
219
  const bucket = TYPE_GROUPS[entry.type]
197
220
  if (bucket) groups[bucket].push(entry)
198
221
  for (const ref of entry.refs) {
@@ -61,6 +61,29 @@ function getLatestTag() {
61
61
  return tags.at(-1) || 'v0.0.0'
62
62
  }
63
63
 
64
+ function getLatestBetaTag() {
65
+ const tags = runGit(['tag', '-l', 'v*'])
66
+ .split('\n')
67
+ .filter((tag) => /^v\d+\.\d+\.\d+-beta\.\d+$/.test(tag))
68
+ tags.sort((left, right) => {
69
+ const a = left
70
+ .slice(1)
71
+ .match(/^(\d+)\.(\d+)\.(\d+)-beta\.(\d+)$/)
72
+ .slice(1)
73
+ .map(Number)
74
+ const b = right
75
+ .slice(1)
76
+ .match(/^(\d+)\.(\d+)\.(\d+)-beta\.(\d+)$/)
77
+ .slice(1)
78
+ .map(Number)
79
+ for (let index = 0; index < a.length; index += 1) {
80
+ if (a[index] !== b[index]) return a[index] - b[index]
81
+ }
82
+ return 0
83
+ })
84
+ return tags.at(-1) || null
85
+ }
86
+
64
87
  function getCurrentVersion() {
65
88
  return validateInventory(ROOT).sourceVersion
66
89
  }
@@ -400,9 +423,9 @@ switch (command) {
400
423
  const useBeta = command === 'beta' || args.includes('--beta')
401
424
 
402
425
  // Beta: advance the committed X.Y.Z-beta.N line and promote the
403
- // [Unreleased] CHANGELOG section into [vX.Y.Z-beta.N], exactly like the
404
- // stable path. The committed manifest is the single source of truth — no
405
- // npm lookup, no git lookup, and no runtime version computation.
426
+ // [Unreleased] CHANGELOG section into [vX.Y.Z-beta.N]. Optional --notes
427
+ // uses commits since the latest beta tag; without it, the manual
428
+ // [Unreleased] body is preserved.
406
429
  if (useBeta) {
407
430
  if (!contentHasUnreleased())
408
431
  throw new Error('CHANGELOG.md is missing the [Unreleased] section')
@@ -410,7 +433,18 @@ switch (command) {
410
433
  const newVersion = nextBetaVersion(current)
411
434
  const date = new Date().toISOString().slice(0, 10)
412
435
  console.log(`Bumping ${current} → ${newVersion} (beta)`)
413
- const changelogPlan = prepareUnreleased(newVersion, date)
436
+ let notesBody = null
437
+ if (useNotes) {
438
+ const since = getLatestBetaTag()
439
+ if (!since) throw new Error('cannot generate beta release notes: no prior beta tag found')
440
+ const raw = collectEntries({ since })
441
+ notesBody = renderChangelog(groupCommits(raw.map(parseCommitLine)))
442
+ if (!notesBody) {
443
+ throw new Error(`cannot generate beta release notes: no generated notes since ${since}`)
444
+ }
445
+ console.log(` --notes generated from ${raw.length} commits since ${since}`)
446
+ }
447
+ const changelogPlan = prepareUnreleased(newVersion, date, notesBody)
414
448
  const manifestPlan = prepareManifests(newVersion)
415
449
  commitPreparedRelease(
416
450
  { ...manifestPlan, version: newVersion },
@@ -508,9 +542,11 @@ Commands:
508
542
  apply [type] Bump manifests + move [Unreleased] → [vX.Y.Z]
509
543
  type: patch | minor | major | auto (default: auto)
510
544
  --notes: pre-fill the promoted entry with release
511
- notes generated from conventional commits
545
+ notes since the latest stable tag
512
546
  --beta: advance the committed X.Y.Z-beta.N line and
513
547
  promote [Unreleased] → [vX.Y.Z-beta.N] in CHANGELOG
548
+ --beta --notes: generate notes since the latest beta tag
549
+ (fails without a beta baseline or non-empty notes)
514
550
  beta Alias for 'apply --beta'
515
551
  changelog [version] Promote [Unreleased], or merge into an existing version section
516
552
 
@@ -67,10 +67,17 @@ def _connect() -> sqlite3.Connection:
67
67
  """Open (creating if needed) the memory DB with row access."""
68
68
  path = _db_path()
69
69
  path.parent.mkdir(parents=True, exist_ok=True)
70
- conn = sqlite3.connect(str(path))
71
- conn.row_factory = sqlite3.Row
72
- conn.execute("PRAGMA journal_mode=WAL")
73
- conn.executescript(_SCHEMA_SQL)
70
+ conn = sqlite3.connect(str(path), timeout=5.0)
71
+ try:
72
+ conn.row_factory = sqlite3.Row
73
+ # Keep the busy wait explicit so eval resource reads tolerate the
74
+ # memory MCP's short SQLite write transactions.
75
+ conn.execute("PRAGMA busy_timeout=5000")
76
+ conn.execute("PRAGMA journal_mode=WAL")
77
+ conn.executescript(_SCHEMA_SQL)
78
+ except BaseException:
79
+ conn.close()
80
+ raise
74
81
  return conn
75
82
 
76
83
 
@@ -23,7 +23,6 @@ from fastmcp import FastMCP
23
23
 
24
24
  # ── Path Resolution ──────────────────────────────────────────────────────────
25
25
  _PANTHEON_HOME: Path = pantheon_home()
26
- _PANTHEON_PROJECT: Path | None = pantheon_project()
27
26
 
28
27
 
29
28
  def _within(path: Path, parent: Path) -> bool:
@@ -68,12 +67,13 @@ def _resource_root(name: str) -> Path | None:
68
67
  preserves the global fallback while preventing symlink escapes.
69
68
  """
70
69
  candidates: list[tuple[Path, Path]] = []
71
- if _PANTHEON_PROJECT is not None:
70
+ project = pantheon_project()
71
+ if project is not None:
72
72
  if name in {"agents", "skills"}:
73
- local = _PANTHEON_PROJECT / ".opencode"
73
+ local = project / ".opencode"
74
74
  candidates.append((local / name, local))
75
75
  elif name in {"deepwork", "memory-bank"}:
76
- local = _PANTHEON_PROJECT / ".pantheon"
76
+ local = project / ".pantheon"
77
77
  candidates.append((local / name, local))
78
78
  candidates.append((_PANTHEON_HOME / name, _PANTHEON_HOME))
79
79
  for root, parent in candidates:
@@ -86,9 +86,10 @@ def _resource_root(name: str) -> Path | None:
86
86
  def _resource_roots(name: str) -> list[Path]:
87
87
  """Return safe resource roots in local-first precedence order."""
88
88
  roots: list[Path] = []
89
- if _PANTHEON_PROJECT is not None:
89
+ project = pantheon_project()
90
+ if project is not None:
90
91
  base_name = ".opencode" if name in {"agents", "skills"} else ".pantheon"
91
- base = _PANTHEON_PROJECT / base_name
92
+ base = project / base_name
92
93
  local = _safe_root(base / name, base)
93
94
  if local is not None:
94
95
  roots.append(local)
@@ -208,9 +209,10 @@ async def list_skills() -> str:
208
209
  async def get_routing() -> str:
209
210
  """Return the full content of routing.yml."""
210
211
  routing_file = _safe_child(_PANTHEON_HOME, "routing.yml")
211
- if routing_file is None and _PANTHEON_PROJECT:
212
- routing_file = _safe_child(_PANTHEON_PROJECT / "src", "routing.yml")
213
- if routing_file is None or not routing_file.exists():
212
+ project = pantheon_project()
213
+ if (routing_file is None or not routing_file.is_file()) and project:
214
+ routing_file = _safe_child(project / "src", "routing.yml")
215
+ if routing_file is None or not routing_file.is_file():
214
216
  return "routing.yml not found."
215
217
  return routing_file.read_text(encoding="utf-8")
216
218