pantheon-opencode 1.6.1 → 1.6.2-beta.2

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 (115) hide show
  1. package/AGENTS.global.md +11 -11
  2. package/AGENTS.md +2 -2
  3. package/CHANGELOG.md +29 -0
  4. package/README.md +100 -19
  5. package/README.pt-BR.md +27 -11
  6. package/bin/pantheon-init.mjs +106 -19
  7. package/package.json +3 -2
  8. package/plugin.json +1 -1
  9. package/pyproject.toml +1 -1
  10. package/scripts/build-agents-md.mjs +1 -1
  11. package/scripts/doctor.mjs +213 -45
  12. package/scripts/install/agents-md.mjs +2 -1
  13. package/scripts/install/config-migration.mjs +344 -393
  14. package/scripts/install/config-paths.mjs +15 -0
  15. package/scripts/install/mcp-permissions.mjs +164 -0
  16. package/scripts/install/opencode-version.mjs +31 -13
  17. package/scripts/install/opencode-wildcard.mjs +106 -0
  18. package/scripts/install/opencode.mjs +240 -69
  19. package/scripts/install/plan-artifact.mjs +12 -1
  20. package/scripts/install/plugin.mjs +17 -1
  21. package/scripts/install/v2-capabilities.mjs +5 -6
  22. package/scripts/package-evidence.mjs +1 -0
  23. package/scripts/sandbox-env.sh +174 -0
  24. package/scripts/setup-v2-config.mjs +1703 -0
  25. package/scripts/setup.mjs +415 -0
  26. package/scripts/sync-tui.mjs +9 -1
  27. package/scripts/test-opencode-v2-sandbox.sh +438 -151
  28. package/scripts/update-skills-lock.mjs +30 -0
  29. package/skills-lock.json +10 -10
  30. package/src/agents/aphrodite.md +5 -2
  31. package/src/agents/apollo.md +5 -0
  32. package/src/agents/athena.md +6 -1
  33. package/src/agents/demeter.md +5 -1
  34. package/src/agents/gaia.md +4 -0
  35. package/src/agents/hephaestus.md +6 -1
  36. package/src/agents/hermes.md +6 -3
  37. package/src/agents/iris.md +5 -1
  38. package/src/agents/mnemosyne.md +20 -50
  39. package/src/agents/nyx.md +5 -1
  40. package/src/agents/prometheus.md +4 -0
  41. package/src/agents/talos.md +4 -0
  42. package/src/agents/themis.md +4 -0
  43. package/src/agents/zeus.md +9 -3
  44. package/src/instructions/agent-return-format.instructions.md +1 -1
  45. package/src/instructions/memory-protocol.instructions.md +3 -3
  46. package/src/instructions/test-economy.instructions.md +6 -6
  47. package/src/mcp/pantheon_vision.py +37 -36
  48. package/src/pantheon/cost-command.ts +30 -133
  49. package/src/pantheon/model-pricing.ts +1 -536
  50. package/src/pantheon/v2-vision.ts +34 -29
  51. package/src/pantheon/vision.ts +43 -10
  52. package/src/plugin-v2.ts +30 -53
  53. package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
  54. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +749 -0
  55. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +1 -0
  56. package/src/plugins/tui/dist/quota-adapters.d.ts +89 -0
  57. package/src/plugins/tui/dist/quota-adapters.d.ts.map +1 -0
  58. package/src/plugins/tui/dist/quota-adapters.js +1142 -0
  59. package/src/plugins/tui/dist/quota-adapters.js.map +1 -0
  60. package/src/plugins/tui/dist/quota-cli.d.ts +17 -0
  61. package/src/plugins/tui/dist/quota-cli.d.ts.map +1 -0
  62. package/src/plugins/tui/dist/quota-cli.js +184 -0
  63. package/src/plugins/tui/dist/quota-cli.js.map +1 -0
  64. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +684 -0
  65. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +1 -0
  66. package/src/plugins/tui/dist/server-v2.d.ts +14 -0
  67. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -0
  68. package/src/plugins/tui/dist/server-v2.js +796 -0
  69. package/src/plugins/tui/dist/server-v2.js.map +1 -0
  70. package/src/plugins/tui/dist/tui-v2.d.ts +375 -53
  71. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  72. package/src/plugins/tui/dist/tui-v2.js +5876 -530
  73. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  74. package/src/plugins/tui/dist/tui.js +1 -1
  75. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +118 -0
  76. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +1 -0
  77. package/src/plugins/tui/dist/usage-history-worker.js +25 -0
  78. package/src/plugins/tui/dist/usage-history-worker.js.map +1 -0
  79. package/src/plugins/tui/index-v2.ts +3 -6
  80. package/src/plugins/tui/package-lock.json +17 -2
  81. package/src/plugins/tui/package.json +6 -3
  82. package/src/plugins/tui/src/context-gauge.ts +59 -0
  83. package/src/plugins/tui/src/cost-data.ts +607 -0
  84. package/src/plugins/tui/src/go-key-diagnostic-ui.ts +100 -0
  85. package/src/plugins/tui/src/go-key-diagnostic.ts +125 -0
  86. package/src/plugins/tui/src/index-v2.tsx +231 -240
  87. package/src/plugins/tui/src/model-pricing.ts +536 -0
  88. package/src/plugins/tui/src/model-usage-limits.ts +4 -0
  89. package/src/plugins/tui/src/quota-adapters.ts +1598 -0
  90. package/src/plugins/tui/src/quota-cli.ts +237 -0
  91. package/src/plugins/tui/src/quota-rpc.ts +373 -0
  92. package/src/plugins/tui/src/quota-v2-model.ts +1032 -0
  93. package/src/plugins/tui/src/quota-v2.tsx +1238 -0
  94. package/src/plugins/tui/src/server-v2.ts +985 -0
  95. package/src/plugins/tui/src/sidebar-width.ts +129 -0
  96. package/src/plugins/tui/src/usage-history-contract.ts +217 -0
  97. package/src/plugins/tui/src/usage-history-validation.ts +104 -0
  98. package/src/plugins/tui/src/usage-history-view.tsx +236 -0
  99. package/src/plugins/tui/src/usage-history-worker.ts +25 -0
  100. package/src/plugins/tui/src/usage-view-model.ts +272 -0
  101. package/src/plugins/tui/tsconfig.typecheck.json +6 -1
  102. package/src/plugins/tui/tsdown.config.ts +44 -5
  103. package/src/routing.yml +72 -13
  104. package/src/skills/README.md +4 -0
  105. package/src/skills/agent-coordination/SKILL.md +0 -3
  106. package/src/skills/artifact-management/SKILL.md +0 -3
  107. package/src/skills/auto-continue/SKILL.md +0 -3
  108. package/src/skills/code-review-checklist/SKILL.md +0 -3
  109. package/src/skills/context-compression/SKILL.md +0 -3
  110. package/src/skills/memory-bank/SKILL.md +6 -28
  111. package/src/skills/session-goal/SKILL.md +0 -3
  112. package/src/skills/simplify/SKILL.md +5 -4
  113. package/src/skills/tdd-with-agents/SKILL.md +0 -3
  114. package/src/skills/visual-review-pipeline/SKILL.md +0 -1
  115. package/src/pantheon/memory-context.ts +0 -1017
@@ -2126,6 +2126,16 @@ function syntheticHistoryPart(message: VisionHistoryMessage, text: string): Text
2126
2126
  }
2127
2127
  }
2128
2128
 
2129
+ /**
2130
+ * Result of a recursive sanitize pass: the (possibly rebuilt) value plus
2131
+ * whether anything at or below it actually changed. Unchanged subtrees keep
2132
+ * the ORIGINAL value by reference so host-owned instances (objects carrying
2133
+ * methods like `.inline()`, class instances, etc.) are never replaced by
2134
+ * plain-object copies — deep-copying them strips prototypes and crashes the
2135
+ * host when it later calls methods on what should still be its own objects.
2136
+ */
2137
+ type SanitizeResult = { value: unknown; changed: boolean }
2138
+
2129
2139
  /**
2130
2140
  * Remove image-bearing parts before a provider serializer can turn them into
2131
2141
  * image_url content. This hook is deliberately synchronous in spirit: it only
@@ -2144,9 +2154,20 @@ export function sanitizeVisionHistory(
2144
2154
  const sessionID = historyMessage.info?.sessionID ?? historyMessage.sessionID ?? ''
2145
2155
  if (nativeVisionSessions.has(sessionID)) continue
2146
2156
  const descriptions = sessionVisionText.get(sessionID)
2147
- const sanitize = (value: unknown, inParts: boolean): unknown => {
2148
- if (Array.isArray(value)) return value.map((item) => sanitize(item, inParts))
2149
- if (!value || typeof value !== 'object') return value
2157
+ const sanitize = (value: unknown, inParts: boolean): SanitizeResult => {
2158
+ // Lazily-copied array: the original array is returned by reference
2159
+ // until the first changed child forces a rebuild.
2160
+ if (Array.isArray(value)) {
2161
+ let items: unknown[] | null = null
2162
+ for (let i = 0; i < value.length; i++) {
2163
+ const result = sanitize(value[i], inParts)
2164
+ if (!result.changed && !items) continue
2165
+ items ??= value.slice(0, i)
2166
+ items.push(result.value)
2167
+ }
2168
+ return items ? { value: items, changed: true } : { value, changed: false }
2169
+ }
2170
+ if (!value || typeof value !== 'object') return { value, changed: false }
2150
2171
 
2151
2172
  const raw = value as { type?: unknown; id?: unknown; mime?: unknown }
2152
2173
  const isImageUrl = raw.type === 'image_url'
@@ -2164,18 +2185,30 @@ export function sanitizeVisionHistory(
2164
2185
  const text =
2165
2186
  descriptions?.get(partID) ??
2166
2187
  'Imagem removida do histórico antes do envio ao provedor textual.'
2167
- return inParts ? syntheticHistoryPart(historyMessage, text) : { type: 'text', text }
2188
+ return {
2189
+ value: inParts ? syntheticHistoryPart(historyMessage, text) : { type: 'text', text },
2190
+ changed: true,
2191
+ }
2168
2192
  }
2169
2193
 
2170
- const copy: Record<string, unknown> = {}
2171
- for (const [key, child] of Object.entries(value)) {
2172
- copy[key] = sanitize(child, key === 'parts')
2194
+ // Lazily-copied object: untouched subtrees keep their original value —
2195
+ // including host class instances and objects with methods — so nothing
2196
+ // loses its prototype unless a nested image part must be replaced.
2197
+ const entries = Object.entries(value)
2198
+ let copy: Record<string, unknown> | null = null
2199
+ for (let i = 0; i < entries.length; i++) {
2200
+ const [key, child] = entries[i] as [string, unknown]
2201
+ const result = sanitize(child, key === 'parts')
2202
+ if (!result.changed && !copy) continue
2203
+ copy ??= Object.fromEntries(entries.slice(0, i))
2204
+ copy[key] = result.value
2173
2205
  }
2174
- return copy
2206
+ return copy ? { value: copy, changed: true } : { value, changed: false }
2175
2207
  }
2176
2208
 
2177
- const sanitized = sanitize(historyMessage, false) as VisionHistoryMessage
2178
- for (const [key, value] of Object.entries(sanitized)) {
2209
+ const sanitized = sanitize(historyMessage, false)
2210
+ if (!sanitized.changed) continue
2211
+ for (const [key, value] of Object.entries(sanitized.value as VisionHistoryMessage)) {
2179
2212
  historyMessage[key] = value
2180
2213
  }
2181
2214
  }
package/src/plugin-v2.ts CHANGED
@@ -108,12 +108,6 @@ import {
108
108
  } from './pantheon/delegation-enforce.ts'
109
109
  import { GOAL_LOOP_DEFAULTS, GoalStore } from './pantheon/goal-loop.ts'
110
110
  import { createGuardPathResolver } from './pantheon/guard-path.ts'
111
- import {
112
- applyMemoryInjection,
113
- MemoryInjectionCache,
114
- resolveMemoryInjectionConfig,
115
- warnInvalidMemoryInjectionConfig,
116
- } from './pantheon/memory-context.ts'
117
111
  import { getSharedBoard } from './pantheon/shared-board.ts'
118
112
  import {
119
113
  TODO_ENFORCER_DEFAULTS,
@@ -895,7 +889,6 @@ async function onSessionDeleted(event: V2SessionEvent): Promise<void> {
895
889
  return
896
890
  }
897
891
  readOnlyRegistry.unregister(sessionID)
898
- memoryInjectionCache.delete(sessionID)
899
892
  }
900
893
 
901
894
  /**
@@ -918,17 +911,35 @@ async function onSessionCompacted(_event: V2SessionEvent): Promise<void> {}
918
911
 
919
912
  // ─── V2 Session Hooks ───────────────────────────────────────────────────
920
913
 
921
- /**
922
- * One-line prune stats entry through the existing hooks.log channel only when
923
- * a pass actually rewrote something. Silent no-ops (below threshold, protected
924
- * window, already-pruned) stay silent so a compaction does not add noise for
925
- * every request.
926
- */
927
- function logContextPrune(stats: PruneStats): void {
928
- if (!stats.changed) return
914
+ /** One entry per no-op reason and session/site; successful passes retain each saving. */
915
+ const pruneSkipSessions = new Set<string>()
916
+ const PRUNE_SKIP_SESSIONS_MAX = 256
917
+
918
+ function logContextPrune(stats: PruneStats, sessionID: unknown): void {
919
+ if (stats.changed) {
920
+ appendV2HookLog(
921
+ `[context-pruner] site=${stats.site} messages=${stats.messagesTouched} ` +
922
+ `parts=${stats.partsPruned} est_tokens_saved=${stats.estimatedTokensSaved}`,
923
+ )
924
+ return
925
+ }
926
+ if (
927
+ stats.skipReason === null ||
928
+ stats.skipReason === 'not-array' ||
929
+ stats.skipReason === 'malformed'
930
+ ) {
931
+ return
932
+ }
933
+
934
+ const session = typeof sessionID === 'string' && sessionID !== '' ? sessionID : 'unknown'
935
+ const key = `${stats.site}:${session}:${stats.skipReason}`
936
+ if (pruneSkipSessions.has(key)) return
937
+ if (pruneSkipSessions.size >= PRUNE_SKIP_SESSIONS_MAX) pruneSkipSessions.clear()
938
+ pruneSkipSessions.add(key)
929
939
  appendV2HookLog(
930
- `[context-pruner] site=${stats.site} messages=${stats.messagesTouched} ` +
931
- `parts=${stats.partsPruned} est_tokens_saved=${stats.estimatedTokensSaved}`,
940
+ `[context-pruner] site=${stats.site} skip=${stats.skipReason} ` +
941
+ `messages=${stats.messagesTouched} parts=${stats.partsPruned} ` +
942
+ `est_tokens_saved=${stats.estimatedTokensSaved}`,
932
943
  )
933
944
  }
934
945
 
@@ -989,17 +1000,6 @@ function warnContextPrunerConfigOnce(options: unknown): void {
989
1000
  }
990
1001
  }
991
1002
 
992
- // ─── Ambient memory injection (opt-in, V2 context hook) ─────────────────
993
-
994
- /**
995
- * One payload per session, computed on the session's first request. Bounded by
996
- * `MEMORY_CACHE_MAX_SESSIONS` inside the cache (FIFO), so a long-lived host
997
- * cannot grow it without limit. The payload is built, rendered and logged by
998
- * `memory-context.ts`; this module only supplies the hook wiring and the
999
- * `hooks.log` channel.
1000
- */
1001
- const memoryInjectionCache = new MemoryInjectionCache()
1002
-
1003
1003
  /**
1004
1004
  * Empty description cache for {@link sanitizeVisionHistory}.
1005
1005
  *
@@ -1024,7 +1024,6 @@ async function registerV2SessionHooks(context: PluginContext): Promise<boolean>
1024
1024
  // Config validity is independent of hook availability; warn before the early
1025
1025
  // return so a typo is visible even on a host that registers no session hook.
1026
1026
  warnContextPrunerConfigOnce(context.options)
1027
- warnInvalidMemoryInjectionConfig(context.options, appendV2HookLog)
1028
1027
  const sessionCtx = hostDomains(context).session
1029
1028
 
1030
1029
  if (!sessionCtx?.hook) {
@@ -1037,11 +1036,6 @@ async function registerV2SessionHooks(context: PluginContext): Promise<boolean>
1037
1036
  // applies the rules unconditionally.
1038
1037
  const prunerConfig = resolveContextPrunerConfig(context.options)
1039
1038
 
1040
- // Ambient memory injection is opt-in and default OFF: with `enabled: false`
1041
- // this hook adds nothing, so `system` stays byte-identical to the policy-only
1042
- // output. Resolved here (not per request) for the same reason as the pruner.
1043
- const memoryConfig = resolveMemoryInjectionConfig(context.options)
1044
-
1045
1039
  let registered = false
1046
1040
 
1047
1041
  try {
@@ -1078,23 +1072,6 @@ async function registerV2SessionHooks(context: PluginContext): Promise<boolean>
1078
1072
  normalized.push({ type: 'text', text: POLICY } satisfies SystemPart)
1079
1073
  }
1080
1074
  }
1081
- // Opt-in ambient memory injection: the top-K memories relevant to the
1082
- // session's first user message, computed once per session and re-added
1083
- // verbatim on later requests. Deliberately OUTSIDE the block above: with
1084
- // `enabled: true` and no usable `system` there is nowhere to push, and
1085
- // the module reports `skip=no-system` once per session instead of the
1086
- // feature going silently inert. Off by default, so this is the only
1087
- // thing `enabled: false` skips.
1088
- if (memoryConfig.enabled) {
1089
- applyMemoryInjection(
1090
- normalized ?? ctx.system,
1091
- ctx.messages,
1092
- ctx.sessionID,
1093
- memoryConfig,
1094
- memoryInjectionCache,
1095
- appendV2HookLog,
1096
- )
1097
- }
1098
1075
  // Vision history sanitization (V1
1099
1076
  // `experimental.chat.messages.transform` parity, #266). Image parts are
1100
1077
  // replaced with their cached description, or with the same placeholder
@@ -1120,7 +1097,7 @@ async function registerV2SessionHooks(context: PluginContext): Promise<boolean>
1120
1097
  if (prunerConfig.enabled) {
1121
1098
  try {
1122
1099
  const stats = pruneMessages(ctx.messages, prunerConfig, 'context')
1123
- logContextPrune(stats)
1100
+ logContextPrune(stats, ctx.sessionID)
1124
1101
  logPruneShapeIssue(stats, ctx.sessionID, 'context')
1125
1102
  } catch (error) {
1126
1103
  logPruneFailureOnce(ctx.sessionID, 'context', error)
@@ -2227,7 +2204,7 @@ export const plugin = define({
2227
2204
  : undefined
2228
2205
  const prunerConfig = resolveContextPrunerConfig(context.options)
2229
2206
  const stats = pruneMessages(payload?.messages, prunerConfig, 'compaction')
2230
- logContextPrune(stats)
2207
+ logContextPrune(stats, sessionID)
2231
2208
  logPruneShapeIssue(stats, sessionID, 'compaction')
2232
2209
 
2233
2210
  // Compaction context (V1 `experimental.session.compacting`
@@ -0,0 +1,24 @@
1
+ # Third-party notices
2
+
3
+ The `dist/tui-v2.js` bundle includes tree-shaken code and the OpenIcon glyph
4
+ table from `@profullstack/hqtui` 0.11.1, licensed under the MIT License.
5
+
6
+ Copyright (c) 2026 HQTUI contributors
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.