pantheon-opencode 2.0.2 → 2.0.4
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/AGENTS.global.md +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +50 -0
- package/README.md +5 -1
- package/README.pt-BR.md +4 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +27 -6
- package/scripts/decision-router.mjs +76 -34
- package/scripts/doctor.mjs +74 -0
- package/scripts/install/decision-router-config.mjs +32 -7
- package/skills-lock.json +1 -1
- package/src/agents/apollo.md +6 -53
- package/src/agents/athena.md +31 -23
- package/src/agents/talos.md +10 -40
- package/src/agents/themis.md +8 -0
- package/src/agents/zeus.md +11 -6
- package/src/pantheon/background-job-board.ts +33 -0
- package/src/pantheon/bus.ts +190 -0
- package/src/pantheon/execution-receipt.ts +113 -0
- package/src/pantheon/jev-decision-tool.ts +8 -2
- package/src/pantheon/local-decision-budget.ts +36 -6
- package/src/pantheon/model-command.ts +2 -4
- package/src/pantheon/prompt-cache-order.ts +89 -0
- package/src/pantheon/themis-reflex.ts +164 -0
- package/src/plugin/index.js +60 -21
- package/src/plugins/tui/dist/tui.js +19 -19
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/autonomy-state.ts +6 -8
- package/src/plugins/tui/src/decision-router-state.ts +5 -5
- package/src/plugins/tui/src/j1-gate-status.ts +4 -6
- package/src/skills/prompt-refinery/SKILL.md +4 -4
package/AGENTS.global.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- pantheon:generated:begin — Pantheon-managed region; regenerated on install/upgrade, never edit inside -->
|
|
2
2
|
<!-- Generated by scripts/build-agents-md.mjs — do not edit directly. -->
|
|
3
3
|
<!-- Source of truth: src/instructions/*.instructions.md + the static sections in this script. -->
|
|
4
|
-
<!-- pantheon:agents-md v2 artifact=global generated-at=2026-11-
|
|
4
|
+
<!-- pantheon:agents-md v2 artifact=global generated-at=2026-11-11T22:52:04-03:00 sha=ec8bbf8 -->
|
|
5
5
|
|
|
6
6
|
# Pantheon Agent System — OpenCode
|
|
7
7
|
|
package/AGENTS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- pantheon:generated:begin — Pantheon-managed region; regenerated on install/upgrade, never edit inside -->
|
|
2
2
|
<!-- Generated by scripts/build-agents-md.mjs — do not edit directly. -->
|
|
3
3
|
<!-- Source of truth: project sections in scripts/build-agents-md.mjs. -->
|
|
4
|
-
<!-- pantheon:agents-md v2 artifact=project generated-at=2026-11-
|
|
4
|
+
<!-- pantheon:agents-md v2 artifact=project generated-at=2026-11-11T22:52:04-03:00 sha=ec8bbf8 -->
|
|
5
5
|
|
|
6
6
|
# Pantheon — Repository Setup
|
|
7
7
|
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
## [v2.0.4] - 2026-11-12
|
|
9
|
+
|
|
10
|
+
### 🆕 What's New
|
|
11
|
+
|
|
12
|
+
- **Container & JupyterHub Support**: Auto-detect environments and relax directory trust checks via `PANTHEON_ALLOW_GROUP_WRITABLE=1`.
|
|
13
|
+
- **Decision Router Diagnostics**: New Section L in `doctor` validating router configuration and fault-tolerant CLI diagnostics.
|
|
14
|
+
- **Reactive Event Bus**: Zero-latency in-memory event bus replacing disk file polling for background job status updates.
|
|
15
|
+
- **Themis Local Reflex**: Self-healing loop enabling implementers to remediate lint and test slice issues without coordinator.
|
|
16
|
+
- **Execution Proof Receipts**: Cryptographic verification receipts with SHA-256 fingerprinting for completed agent subtasks.
|
|
17
|
+
- **Prefix Cache & Prompt Diet**: Deterministic prompt layering and distilled instructions maximizing KV-cache hit rate.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **routing** — add `PANTHEON_ALLOW_GROUP_WRITABLE` environment variable and auto-detection for container environments (JupyterHub, Docker, Kubernetes).
|
|
22
|
+
- **doctor** — add Section L to `scripts/doctor.mjs` checking Decision Router configuration trust and budget ledger accessibility.
|
|
23
|
+
- **orchestration** — in-memory `PantheonBus` event dispatcher with zero-latency reactive notifications for background job lifecycles.
|
|
24
|
+
- **orchestration** — `ThemisReflexController` bounding inline implementer self-healing to 2 retries before escalating to Zeus.
|
|
25
|
+
- **orchestration** — `createExecutionReceipt` and `verifyExecutionReceipt` with SHA-256 content hashes and verifiable test slices.
|
|
26
|
+
- **orchestration** — `buildPrefixCachedPrompt` aligning agent prompts with provider KV-cache prefix retention specifications.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **agents** — distilled system prompts for Talos and Apollo stripping generic MCP governance to maximize fast-path throughput.
|
|
31
|
+
|
|
32
|
+
### Removed
|
|
33
|
+
|
|
34
|
+
- **cli** — remove obsolete V1 legacy wizard documentation and comments in `model-command.ts`.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **routing** — relax `assertTrustedDirectoryChain` and `validateDirectoryTrust` to accept root/sticky ownership and permitted group-writable ancestors.
|
|
39
|
+
- **cli** — wrap `readUserDecisionRouterConfig` in `status` and `doctor` commands to report clean errors instead of crashing.
|
|
40
|
+
- **jev** — surface specific failure details for `CONFIG_UNAVAILABLE` in `runGatedNativeJevCall`.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## [v2.0.3] - 2026-11-11
|
|
44
|
+
|
|
45
|
+
### 🆕 What's New
|
|
46
|
+
|
|
47
|
+
- **Simplified TUI Architecture**: Plain-language labels for Jev Assistant, Operation Mode, Cloud API Access, and Safety Gate.
|
|
48
|
+
- **Two-Tier Architecture Planning**: Concise 1-page visual summary in chat with full technical blueprint saved to disk.
|
|
49
|
+
- **Interactive Question Prompts**: Native question tool integration for prompt refinery disambiguation and plan approval gates.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- **tui** — align row labels and group titles across Decision, Autonomy, and J1 Safety in PT-BR and EN.
|
|
54
|
+
- **planning** — decouple Athena plan into chat-friendly Executive Decision Contract and disk-based deep technical blueprint.
|
|
55
|
+
- **agents** — grant native question tool to Zeus and Athena for interactive UI choices and confirmation dialogs.
|
|
56
|
+
|
|
57
|
+
|
|
8
58
|
## [v2.0.2] - 2026-11-11
|
|
9
59
|
|
|
10
60
|
### 🆕 What's New
|
package/README.md
CHANGED
|
@@ -57,6 +57,10 @@ flowchart LR
|
|
|
57
57
|
|
|
58
58
|
- **Fast-Track execution:** Bounded micro-edits (<= 2 files, <= 50 lines) bypass all heavy ceremony and verify in < 10 seconds.
|
|
59
59
|
- **Mandatory test slicing:** Sub-second targeted test execution instead of running sluggish repository-wide test suites during dev loops.
|
|
60
|
+
- **Execution proof receipts:** Cryptographic SHA-256 fingerprinting on modified files and test slice exit codes prevents false-positive task reports.
|
|
61
|
+
- **KV-cache prefix optimization:** Strict invariant-first prompt layering maximizes LLM cache hits (up to 90% cost and latency savings).
|
|
62
|
+
- **Reactive event bus & zero polling:** Process-wide in-memory event bus delivers instant updates across jobs and agents without disk polling.
|
|
63
|
+
- **Themis local reflex loops:** Specialist self-healing resolves isolated lint and test slice discrepancies before escalating to Zeus.
|
|
60
64
|
- **Assertive council (`/pantheon`):** Parallel specialist consultations resolved decisively via domain authority and JEV multi-criteria decisions without endless debate turns.
|
|
61
65
|
- **You stay in charge:** Pantheon supports your judgment; it never silently alters permissions or runs unapproved destructive actions.
|
|
62
66
|
- **Non-destructive upgrades:** Updating Pantheon (`pantheon-opencode update`) refreshes skills, MCPs, and instructions while strictly preserving all user models, presets, permissions, and custom configs.
|
|
@@ -84,7 +88,7 @@ pantheon-opencode init --yes
|
|
|
84
88
|
```bash
|
|
85
89
|
pantheon-opencode doctor
|
|
86
90
|
```
|
|
87
|
-
Runs a
|
|
91
|
+
Runs a diagnostic checking Decision Router & budget ledger accessibility, MCP initialization, Python virtual environments, Node version, permissions, and config integrity. In containerized or JupyterHub environments with group-writable homes, set `PANTHEON_ALLOW_GROUP_WRITABLE=1` if needed.
|
|
88
92
|
|
|
89
93
|
### 3. Updating Pantheon Without Overwriting Settings
|
|
90
94
|
When a new version is released:
|
package/README.pt-BR.md
CHANGED
|
@@ -53,6 +53,10 @@ flowchart LR
|
|
|
53
53
|
|
|
54
54
|
- **Execução Fast-Track:** Micro-edições delimitadas (<= 2 arquivos, <= 50 linhas) pulam cerimônias pesadas e validam em < 10 segundos.
|
|
55
55
|
- **Fatiamento mandatório de testes (test slicing):** Execução direcionada em submissegundos em vez de rodar suites lentas do repositório inteiro durante loops de desenvolvimento.
|
|
56
|
+
- **Recibos de execução comprováveis:** Assinatura criptográfica SHA-256 sobre arquivos modificados e fatias de teste elimina relatórios falsos-positivos de conclusão.
|
|
57
|
+
- **Otimização de prefixo de cache KV:** Estruturação estrita de prompts invariantes maximiza reaproveitamento de cache em modelos modernos.
|
|
58
|
+
- **Barramento reativo de eventos sem polling:** Event bus em memória distribui atualizações de jobs e agentes em tempo real com latência zero.
|
|
59
|
+
- **Loops de reflexo local Themis:** Auto-remediação direta de falhas isoladas de lint ou fatias de teste antes de escalar para o Zeus.
|
|
56
60
|
- **Conselho assertivo (`/pantheon`):** Consultas paralelas entre especialistas resolvidas decisivamente via autoridade de domínio e decisões multi-critério JEV sem loops infinitos de debate.
|
|
57
61
|
- **Você no comando:** O Pantheon apoia seu julgamento; ele nunca altera permissões silenciosamente nem executa ações destrutivas sem aprovação.
|
|
58
62
|
- **Atualizações não-destrutivas:** Atualizar o Pantheon (`pantheon-opencode update`) renova skills, MCPs e instruções preservando rigorosamente todos os modelos do usuário, presets ativos, permissões e regras customizadas no `AGENTS.md`.
|
package/package.json
CHANGED
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon",
|
|
3
3
|
"publisher": "ils15",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.4",
|
|
5
5
|
"displayName": "Pantheon",
|
|
6
6
|
"description": "Conductor-Delegate orchestration platform with 14 specialized agents, 25 skills, and OpenCode support.",
|
|
7
7
|
"agents": "./src/agents",
|
package/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pantheon"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.4"
|
|
8
8
|
description = "Multi-agent orchestration framework"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
# Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
|
|
@@ -4,7 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
// src/pantheon/local-decision-budget.ts
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
chmodSync,
|
|
9
|
+
closeSync,
|
|
10
|
+
existsSync,
|
|
11
|
+
lstatSync,
|
|
12
|
+
mkdirSync,
|
|
13
|
+
openSync
|
|
14
|
+
} from "node:fs";
|
|
8
15
|
import { homedir } from "node:os";
|
|
9
16
|
import { basename, dirname, isAbsolute, join, parse, resolve, sep } from "node:path";
|
|
10
17
|
import { performance } from "node:perf_hooks";
|
|
@@ -858,20 +865,34 @@ function ensureTrustedDirectoryChain(directoryPath) {
|
|
|
858
865
|
}
|
|
859
866
|
}
|
|
860
867
|
}
|
|
868
|
+
function isPermittedGroupWritable(env = process.env) {
|
|
869
|
+
if (env.PANTHEON_ALLOW_GROUP_WRITABLE === "1" || env.PANTHEON_ALLOW_GROUP_WRITABLE === "true") {
|
|
870
|
+
return true;
|
|
871
|
+
}
|
|
872
|
+
if (env.JUPYTERHUB_USER || env.JUPYTER_IMAGE || env.JUPYTER_SERVER_ROOT || env.KUBERNETES_SERVICE_HOST || env.container || existsSync("/.dockerenv")) {
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
861
877
|
function validateDirectoryTrust(stat, uid, isFinalDirectory) {
|
|
862
878
|
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
863
879
|
throw new Error("Budget ledger path contains a non-directory or symlink ancestor");
|
|
864
880
|
}
|
|
865
|
-
|
|
881
|
+
const mode = stat.mode & 4095;
|
|
882
|
+
const isSticky = (mode & 512) !== 0;
|
|
883
|
+
const isSystemOrUser = stat.uid === uid || stat.uid === 0 || isSticky && stat.uid === 65534;
|
|
884
|
+
if (!isSystemOrUser) {
|
|
866
885
|
throw new Error("Budget ledger path contains an untrusted owner");
|
|
867
886
|
}
|
|
868
887
|
if (isFinalDirectory && stat.uid !== uid) {
|
|
869
888
|
throw new Error("Budget ledger directory must be owned by the current user");
|
|
870
889
|
}
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
890
|
+
const worldWritable = (mode & 2) !== 0;
|
|
891
|
+
const groupWritable = (mode & 16) !== 0;
|
|
892
|
+
if (worldWritable && !isSticky) {
|
|
893
|
+
throw new Error("Budget ledger path contains a group/other-writable directory");
|
|
894
|
+
}
|
|
895
|
+
if (groupWritable && !isSticky && !isFinalDirectory && !isPermittedGroupWritable()) {
|
|
875
896
|
throw new Error("Budget ledger path contains a group/other-writable directory");
|
|
876
897
|
}
|
|
877
898
|
}
|
|
@@ -111,27 +111,50 @@ export async function runDecisionRouterCommand(
|
|
|
111
111
|
|
|
112
112
|
if (command === 'status') {
|
|
113
113
|
const options = parseNamedFlags(rest, ['--target'])
|
|
114
|
-
|
|
114
|
+
let config = null
|
|
115
|
+
let configError = null
|
|
116
|
+
try {
|
|
117
|
+
config = readUserDecisionRouterConfig({ env })
|
|
118
|
+
} catch (err) {
|
|
119
|
+
configError = err
|
|
120
|
+
}
|
|
115
121
|
const dbPath = resolveLocalDecisionBudgetDbPath(env)
|
|
116
|
-
|
|
122
|
+
let inspection = null
|
|
123
|
+
let ledgerError = null
|
|
124
|
+
try {
|
|
125
|
+
inspection = inspectDecisionBudget(dbPath)
|
|
126
|
+
} catch (err) {
|
|
127
|
+
ledgerError = err
|
|
128
|
+
}
|
|
117
129
|
const wallPeriod = utcPeriodOf(Date.now())
|
|
118
|
-
const egress = describeEgress(config, inspection, wallPeriod)
|
|
130
|
+
const egress = config && inspection ? describeEgress(config, inspection, wallPeriod) : null
|
|
119
131
|
|
|
120
132
|
stdout(`Config: ${resolveUserDecisionRouterConfigPath(env)}`)
|
|
121
133
|
stdout(
|
|
122
134
|
`Config file: ${existsSync(resolveUserDecisionRouterConfigPath(env)) ? 'present' : 'absent'}`,
|
|
123
135
|
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
`Enabled
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
if (configError) {
|
|
137
|
+
stdout(`Config status: ERROR (${configError.message})`)
|
|
138
|
+
stdout('Enabled: unknown (blocked by security or configuration error)')
|
|
139
|
+
} else {
|
|
140
|
+
stdout(`Enabled: ${config.enabled ? 'yes' : 'no'}`)
|
|
141
|
+
stdout(`Selection: ${formatSelection(config.selection)}`)
|
|
142
|
+
stdout(`Egress consent: ${config.egress_consent ? 'yes' : 'no'}`)
|
|
143
|
+
stdout(
|
|
144
|
+
`Enabled candidates: ${config.enabled_candidates.length ? config.enabled_candidates.map(formatCandidate).join(', ') : 'none'}`,
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
if (egress) {
|
|
148
|
+
stdout(describeEgressLine(egress))
|
|
149
|
+
}
|
|
150
|
+
if (ledgerError) {
|
|
151
|
+
stdout(`Ledger: ERROR (${ledgerError.message})`)
|
|
152
|
+
} else if (inspection) {
|
|
153
|
+
stdout(`Ledger: ${formatLedger(inspection, dbPath)}`)
|
|
154
|
+
stdout(`Budget period: ${formatPeriod(inspection)}`)
|
|
155
|
+
stdout(`Caps: ${formatCaps(inspection)}`)
|
|
156
|
+
}
|
|
157
|
+
if (config && options['--target'] !== undefined) {
|
|
135
158
|
stdout(`Install-state: ${formatInstallState(config, options['--target'])}`)
|
|
136
159
|
}
|
|
137
160
|
stdout('Mode: read-only — status and help never create, migrate or write anything.')
|
|
@@ -480,50 +503,69 @@ export async function runDecisionRouterCommand(
|
|
|
480
503
|
if (command === 'doctor' && rest.length === 0) {
|
|
481
504
|
// Read-only diagnosis. The host-catalog probe runs `opencode models` with a
|
|
482
505
|
// timeout; a missing/unavailable binary is a warning, not a failure.
|
|
483
|
-
const config = readUserDecisionRouterConfig({ env })
|
|
484
|
-
const dbPath = resolveLocalDecisionBudgetDbPath(env)
|
|
485
|
-
const inspection = inspectDecisionBudget(dbPath)
|
|
486
|
-
const wallPeriod = utcPeriodOf(Date.now())
|
|
487
|
-
const egress = describeEgress(config, inspection, wallPeriod)
|
|
488
506
|
const rows = []
|
|
489
507
|
const fail = (name, detail, fix) => rows.push({ name, state: 'FAIL', detail, fix })
|
|
490
508
|
const warn = (name, detail, fix) => rows.push({ name, state: 'WARN', detail, fix })
|
|
491
509
|
const pass = (name, detail) => rows.push({ name, state: 'PASS', detail })
|
|
492
510
|
|
|
511
|
+
let config = null
|
|
512
|
+
try {
|
|
513
|
+
config = readUserDecisionRouterConfig({ env })
|
|
514
|
+
} catch (err) {
|
|
515
|
+
fail(
|
|
516
|
+
'config',
|
|
517
|
+
`configuration path unreadable: ${err.message}`,
|
|
518
|
+
'check permissions or set PANTHEON_ALLOW_GROUP_WRITABLE=1',
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
const dbPath = resolveLocalDecisionBudgetDbPath(env)
|
|
522
|
+
let inspection = null
|
|
523
|
+
try {
|
|
524
|
+
inspection = inspectDecisionBudget(dbPath)
|
|
525
|
+
} catch (err) {
|
|
526
|
+
fail(
|
|
527
|
+
'ledger',
|
|
528
|
+
`budget ledger unreadable: ${err.message}`,
|
|
529
|
+
'check permissions or set PANTHEON_ALLOW_GROUP_WRITABLE=1',
|
|
530
|
+
)
|
|
531
|
+
}
|
|
532
|
+
const wallPeriod = utcPeriodOf(Date.now())
|
|
533
|
+
const egress = config && inspection ? describeEgress(config, inspection, wallPeriod) : null
|
|
534
|
+
|
|
493
535
|
if (!existsSync(resolveUserDecisionRouterConfigPath(env))) {
|
|
494
536
|
fail(
|
|
495
537
|
'config',
|
|
496
538
|
'no user-level config yet',
|
|
497
539
|
'decision-router setup-model <provider>/<model> --monthly-usd N --per-decision-usd N',
|
|
498
540
|
)
|
|
499
|
-
} else if (!config.enabled) {
|
|
541
|
+
} else if (config && !config.enabled) {
|
|
500
542
|
fail('config', 'turn selection is disabled', 'decision-router enable')
|
|
501
|
-
} else {
|
|
543
|
+
} else if (config) {
|
|
502
544
|
pass('config', 'enabled')
|
|
503
545
|
}
|
|
504
|
-
if (config
|
|
546
|
+
if (config?.enabled && !config.egress_consent) {
|
|
505
547
|
fail(
|
|
506
548
|
'consent',
|
|
507
549
|
'egress consent missing',
|
|
508
550
|
'decision-router consent yes (or rerun setup-model without --no-consent)',
|
|
509
551
|
)
|
|
510
|
-
} else if (config
|
|
552
|
+
} else if (config?.enabled) {
|
|
511
553
|
pass('consent', 'recorded')
|
|
512
554
|
}
|
|
513
555
|
|
|
514
|
-
const selection = config
|
|
515
|
-
if (config
|
|
556
|
+
const selection = config?.selection
|
|
557
|
+
if (config?.enabled && selection?.mode === 'local') {
|
|
516
558
|
fail('selection', 'selection is local', 'decision-router select <provider>/<model>')
|
|
517
|
-
} else if (config
|
|
518
|
-
if (egress.mode === 'opt-in')
|
|
559
|
+
} else if (config?.enabled && selection?.mode === 'auto') {
|
|
560
|
+
if (egress && egress.mode === 'opt-in')
|
|
519
561
|
pass('selection', `auto resolved ${egress.provider}/${egress.candidate.model}`)
|
|
520
562
|
else
|
|
521
563
|
fail(
|
|
522
564
|
'selection',
|
|
523
|
-
`auto did not resolve (${egress.reason})`,
|
|
565
|
+
`auto did not resolve (${egress ? egress.reason : 'config or ledger unreadable'})`,
|
|
524
566
|
'enable exactly one cap-valid candidate, or select explicitly',
|
|
525
567
|
)
|
|
526
|
-
} else if (config
|
|
568
|
+
} else if (config?.enabled && selection?.mode === 'explicit') {
|
|
527
569
|
const enabled = config.enabled_candidates.some(
|
|
528
570
|
(candidate) =>
|
|
529
571
|
candidate.provider === selection.provider && candidate.model === selection.model,
|
|
@@ -539,16 +581,16 @@ export async function runDecisionRouterCommand(
|
|
|
539
581
|
}
|
|
540
582
|
}
|
|
541
583
|
|
|
542
|
-
if (config
|
|
584
|
+
if (config?.enabled && egress && egress.mode !== 'opt-in' && config.egress_consent) {
|
|
543
585
|
fail(
|
|
544
586
|
'budget',
|
|
545
587
|
`no cap- and period-eligible candidate (${egress.reason})`,
|
|
546
588
|
'decision-router caps user|provider|model ... and decision-router period confirm',
|
|
547
589
|
)
|
|
548
|
-
} else if (config
|
|
590
|
+
} else if (config?.enabled && egress && egress.mode === 'opt-in') {
|
|
549
591
|
pass('budget', `admission open for ${egress.provider}/${egress.candidate.model}`)
|
|
550
592
|
}
|
|
551
|
-
if (inspection
|
|
593
|
+
if (inspection?.ledger.present && inspection.ledger.readable && inspection.ledger.holds > 0) {
|
|
552
594
|
warn(
|
|
553
595
|
'holds',
|
|
554
596
|
`${inspection.ledger.holds} unresolved hold(s) hold budget until reconciled`,
|
|
@@ -557,9 +599,9 @@ export async function runDecisionRouterCommand(
|
|
|
557
599
|
}
|
|
558
600
|
|
|
559
601
|
const target =
|
|
560
|
-
config
|
|
602
|
+
config?.enabled && selection?.mode === 'explicit'
|
|
561
603
|
? selection
|
|
562
|
-
: egress
|
|
604
|
+
: egress?.mode === 'opt-in'
|
|
563
605
|
? { provider: egress.provider, model: egress.candidate.model }
|
|
564
606
|
: null
|
|
565
607
|
if (target !== null) {
|
package/scripts/doctor.mjs
CHANGED
|
@@ -30,8 +30,14 @@ import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
|
|
|
30
30
|
import { fileURLToPath } from 'node:url'
|
|
31
31
|
import { load } from 'js-yaml'
|
|
32
32
|
import { listV2UnsupportedFeatures } from '../src/pantheon/unsupported.mjs'
|
|
33
|
+
import { resolveLocalDecisionBudgetDbPath } from './decision-router-budget.mjs'
|
|
34
|
+
import { inspectDecisionBudget } from './decision-router-budget-gates.mjs'
|
|
33
35
|
import { classifyOverrideFiles } from './install/behavior-overrides.bundle.mjs'
|
|
34
36
|
import { describePluginOptionsReachability } from './install/capabilities.mjs'
|
|
37
|
+
import {
|
|
38
|
+
readUserDecisionRouterConfig,
|
|
39
|
+
resolveUserDecisionRouterConfigPath,
|
|
40
|
+
} from './install/decision-router-config.mjs'
|
|
35
41
|
import { classifyFileInventory } from './install/file-inventory.mjs'
|
|
36
42
|
import { staleTuiRefs } from './install/plugin.mjs'
|
|
37
43
|
import { readState } from './install/state.mjs'
|
|
@@ -2902,6 +2908,73 @@ function checkBehaviorOverrides(args) {
|
|
|
2902
2908
|
}
|
|
2903
2909
|
}
|
|
2904
2910
|
|
|
2911
|
+
export function checkDecisionRouter(_args = {}) {
|
|
2912
|
+
section('L. Decision Router & JEV Runtime')
|
|
2913
|
+
const env = process.env
|
|
2914
|
+
const configPath = resolveUserDecisionRouterConfigPath(env)
|
|
2915
|
+
if (!existsSync(configPath)) {
|
|
2916
|
+
pass('decision-router.json is not configured (optional JEV routing inactive)', {
|
|
2917
|
+
code: 'decision_router_absent',
|
|
2918
|
+
classification: 'config',
|
|
2919
|
+
})
|
|
2920
|
+
return
|
|
2921
|
+
}
|
|
2922
|
+
|
|
2923
|
+
let config = null
|
|
2924
|
+
try {
|
|
2925
|
+
config = readUserDecisionRouterConfig({ env })
|
|
2926
|
+
pass('decision-router.json is trusted and private', {
|
|
2927
|
+
code: 'decision_router_config_trusted',
|
|
2928
|
+
classification: 'config',
|
|
2929
|
+
})
|
|
2930
|
+
} catch (error) {
|
|
2931
|
+
warn(`decision-router.json directory trust check failed: ${error.message}`, {
|
|
2932
|
+
code: 'decision_router_trust_failed',
|
|
2933
|
+
classification: 'config',
|
|
2934
|
+
})
|
|
2935
|
+
info(
|
|
2936
|
+
'Hint: in container/JupyterHub environments, export PANTHEON_ALLOW_GROUP_WRITABLE=1 or run: chmod +t <path>',
|
|
2937
|
+
)
|
|
2938
|
+
return
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
if (config.enabled) {
|
|
2942
|
+
if (!config.egress_consent) {
|
|
2943
|
+
warn('decision-router is enabled but egress consent is missing', {
|
|
2944
|
+
code: 'decision_router_consent_missing',
|
|
2945
|
+
classification: 'config',
|
|
2946
|
+
})
|
|
2947
|
+
} else {
|
|
2948
|
+
pass(`decision-router is enabled with selection: ${JSON.stringify(config.selection)}`, {
|
|
2949
|
+
code: 'decision_router_enabled',
|
|
2950
|
+
classification: 'config',
|
|
2951
|
+
})
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
const dbPath = resolveLocalDecisionBudgetDbPath(env)
|
|
2955
|
+
try {
|
|
2956
|
+
const inspection = inspectDecisionBudget(dbPath)
|
|
2957
|
+
if (inspection.ledger.readable) {
|
|
2958
|
+
pass(`decision budget ledger is accessible (${dbPath})`, {
|
|
2959
|
+
code: 'decision_budget_ledger_accessible',
|
|
2960
|
+
classification: 'budget',
|
|
2961
|
+
})
|
|
2962
|
+
} else {
|
|
2963
|
+
warn(`decision budget ledger is not initialized yet (${dbPath})`, {
|
|
2964
|
+
code: 'decision_budget_ledger_uninitialized',
|
|
2965
|
+
classification: 'budget',
|
|
2966
|
+
})
|
|
2967
|
+
}
|
|
2968
|
+
} catch (error) {
|
|
2969
|
+
warn(`decision budget ledger path error: ${error.message}`, {
|
|
2970
|
+
code: 'decision_budget_ledger_error',
|
|
2971
|
+
classification: 'budget',
|
|
2972
|
+
})
|
|
2973
|
+
info('Hint: export PANTHEON_ALLOW_GROUP_WRITABLE=1 or run setup-model')
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2905
2978
|
async function main() {
|
|
2906
2979
|
const args = parseArgs(process.argv)
|
|
2907
2980
|
jsonMode = args.json
|
|
@@ -2998,6 +3071,7 @@ async function main() {
|
|
|
2998
3071
|
checkSubagentDepthPlacement(args)
|
|
2999
3072
|
checkPermissionTaskPresence(args)
|
|
3000
3073
|
checkUnsupportedFeatures(args)
|
|
3074
|
+
checkDecisionRouter(args)
|
|
3001
3075
|
|
|
3002
3076
|
printSummary(args.target)
|
|
3003
3077
|
if (jsonMode) writeDoctorJson(createDoctorJsonReport(args), exitCode)
|
|
@@ -334,7 +334,7 @@ export function readUserDecisionRouterConfig({ env = process.env } = {}) {
|
|
|
334
334
|
const filePath = resolveUserDecisionRouterConfigPath(env)
|
|
335
335
|
try {
|
|
336
336
|
assertNoSymlinkAncestors(filePath)
|
|
337
|
-
assertTrustedDirectoryChain(dirname(filePath))
|
|
337
|
+
assertTrustedDirectoryChain(dirname(filePath), { env })
|
|
338
338
|
const stat = lstatSync(filePath)
|
|
339
339
|
assertPrivatePath(stat, true)
|
|
340
340
|
const parsed = JSON.parse(readFileSync(filePath, 'utf8'))
|
|
@@ -356,7 +356,7 @@ export function writeUserDecisionRouterConfig(config, { env = process.env } = {}
|
|
|
356
356
|
assertNoSymlinkAncestors(directory, { includeLeaf: false })
|
|
357
357
|
mkdirSync(directory, { recursive: true, mode: 0o700 })
|
|
358
358
|
assertNoSymlinkAncestors(directory)
|
|
359
|
-
assertTrustedDirectoryChain(directory)
|
|
359
|
+
assertTrustedDirectoryChain(directory, { env })
|
|
360
360
|
assertPrivateDirectory(directory)
|
|
361
361
|
try {
|
|
362
362
|
const existing = lstatSync(filePath)
|
|
@@ -535,7 +535,24 @@ function assertPrivateDirectory(directory) {
|
|
|
535
535
|
assertPrivatePath(stat, false)
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
function
|
|
538
|
+
function isPermittedGroupWritable(_current, env = process.env) {
|
|
539
|
+
if (env.PANTHEON_ALLOW_GROUP_WRITABLE === '1' || env.PANTHEON_ALLOW_GROUP_WRITABLE === 'true') {
|
|
540
|
+
return true
|
|
541
|
+
}
|
|
542
|
+
if (
|
|
543
|
+
env.JUPYTERHUB_USER ||
|
|
544
|
+
env.JUPYTER_IMAGE ||
|
|
545
|
+
env.JUPYTER_SERVER_ROOT ||
|
|
546
|
+
env.KUBERNETES_SERVICE_HOST ||
|
|
547
|
+
env.container ||
|
|
548
|
+
existsSync('/.dockerenv')
|
|
549
|
+
) {
|
|
550
|
+
return true
|
|
551
|
+
}
|
|
552
|
+
return false
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function assertTrustedDirectoryChain(directory, { env = process.env } = {}) {
|
|
539
556
|
const absolute = resolve(directory)
|
|
540
557
|
const root = parse(absolute).root
|
|
541
558
|
const parts = absolute.slice(root.length).split(sep).filter(Boolean)
|
|
@@ -555,14 +572,22 @@ function assertTrustedDirectoryChain(directory) {
|
|
|
555
572
|
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
556
573
|
throw new Error('Decision-router configuration path contains a non-directory component')
|
|
557
574
|
}
|
|
558
|
-
|
|
575
|
+
const mode = stat.mode & 0o7777
|
|
576
|
+
const isSticky = (mode & 0o1000) !== 0
|
|
577
|
+
const isSystemOrUser = stat.uid === uid || stat.uid === 0 || (isSticky && stat.uid === 65534)
|
|
578
|
+
if (!isSystemOrUser) {
|
|
559
579
|
throw new Error('Decision-router configuration path has an untrusted owner')
|
|
560
580
|
}
|
|
561
|
-
const
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
581
|
+
const worldWritable = (mode & 0o002) !== 0
|
|
582
|
+
const groupWritable = (mode & 0o020) !== 0
|
|
583
|
+
if (worldWritable && !isSticky) {
|
|
564
584
|
throw new Error('Decision-router configuration path is writable by other users')
|
|
565
585
|
}
|
|
586
|
+
if (groupWritable && !isSticky && !isPermittedGroupWritable(current, env)) {
|
|
587
|
+
throw new Error(
|
|
588
|
+
`Decision-router configuration path "${current}" is group-writable (mode ${(mode & 0o777).toString(8)}). In containers or JupyterHub, set PANTHEON_ALLOW_GROUP_WRITABLE=1 to permit group-writable ancestors, or run: chmod +t "${current}"`,
|
|
589
|
+
)
|
|
590
|
+
}
|
|
566
591
|
}
|
|
567
592
|
}
|
|
568
593
|
|
package/skills-lock.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"src/skills/memory-bank/references/storage-model.md": "728a9e5f2055ce0f74c759405072a6fe57f65587bdb7b9e5e7fa90b60528b085",
|
|
24
24
|
"src/skills/memory-bank/references/structure-and-frequency.md": "09caedf905870c688401a2e58b2776a9c6187fe724c576019c58c3b80fe1b98f",
|
|
25
25
|
"src/skills/memory-bank/SKILL.md": "047b3049c27e908b1d79afb14f79336e32f775385ba23956771166d445944f2f",
|
|
26
|
-
"src/skills/prompt-refinery/SKILL.md": "
|
|
26
|
+
"src/skills/prompt-refinery/SKILL.md": "4ffbcddefb4f8937537358386f364ecca1303f928a1b07ff0bbd7e65d6fe7982",
|
|
27
27
|
"src/skills/reflect/SKILL.md": "297c374f1fbc8e15d3848f51e811e0614d4a008c7d0e1daf88bbb240d605b8a8",
|
|
28
28
|
"src/skills/security-hardening/SKILL.md": "6d637e122421f7bc3b751f04854ad343a5a5d35249458bc8939233138fd3f20d",
|
|
29
29
|
"src/skills/session-goal/references/goal-format.md": "071f6f8f12cfbc26d4703cd5f34f839f91e586a3b969bf5f81a74b961c254a83",
|
package/src/agents/apollo.md
CHANGED
|
@@ -59,57 +59,10 @@ mcp_tools:
|
|
|
59
59
|
- **Code-mode / infrastructure reads** — cheap and on demand; never for
|
|
60
60
|
decisions the ladder already answers.
|
|
61
61
|
|
|
62
|
-
##
|
|
62
|
+
## Discovery Rules & Boundaries
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
### 2. External Research
|
|
71
|
-
- Web search through whatever web-search MCP the USER has configured — Pantheon
|
|
72
|
-
bundles none and does not assume one. If no search tool is available, skip
|
|
73
|
-
external search and say so; never present an unverified recollection as a
|
|
74
|
-
citation.
|
|
75
|
-
- Context7 for library documentation
|
|
76
|
-
- Read URLs with webfetch for known resource URLs
|
|
77
|
-
|
|
78
|
-
### 3. Codemap Generation
|
|
79
|
-
- Map project structure: top-level directories, entry points, key modules
|
|
80
|
-
- Identify architecture patterns and tech debt signals
|
|
81
|
-
- Return hierarchical summaries (60-70% token savings vs raw file reads)
|
|
82
|
-
|
|
83
|
-
## TOOLS NOT AVAILABLE
|
|
84
|
-
- bash - forbidden (cannot run commands)
|
|
85
|
-
- edit - forbidden (read-only agent)
|
|
86
|
-
- Web search by default - no search MCP is bundled or pre-configured. Use one
|
|
87
|
-
ONLY if the user's own config exposes it; otherwise state that external search
|
|
88
|
-
was unavailable instead of improvising.
|
|
89
|
-
|
|
90
|
-
## Pragmatism and Non-Destructive Inspection
|
|
91
|
-
- Diagnostic operations (reading files, targeted webfetch for documentation/status, symbol search) are inherently safe and non-destructive.
|
|
92
|
-
- Do not debate hypothetical side-effects (e.g. click counting, redirect chains) or invent reasons to avoid inspecting what was requested.
|
|
93
|
-
- Focus on returning objective findings directly, without paralysis over capabilities.
|
|
94
|
-
|
|
95
|
-
## MCP Security
|
|
96
|
-
- Never embed credentials in URLs (grep for token=, key=, secret=)
|
|
97
|
-
- Use environment variables for auth
|
|
98
|
-
- Scrub URLs before logging
|
|
99
|
-
- URL allowlist: official docs, public RFCs, package registries, public GitHub
|
|
100
|
-
- Response content never stored to disk
|
|
101
|
-
|
|
102
|
-
## Output Format
|
|
103
|
-
Return structured findings with:
|
|
104
|
-
- **files_changed:** [paths]
|
|
105
|
-
- **summary:** What was found
|
|
106
|
-
- **confidence:** high | medium | low
|
|
107
|
-
|
|
108
|
-
## Auto-Continue (Embedded: Discovery)
|
|
109
|
-
|
|
110
|
-
- Continue through independent discovery queries when more evidence is needed; use only the breadth justified by the request
|
|
111
|
-
- Partial results OK on timeout — return whatever is found
|
|
112
|
-
- No checkpoint needed (read-only, idempotent operations)
|
|
113
|
-
- If timeout occurs, return partial findings with confidence score
|
|
114
|
-
- Do NOT loop back for more searches — return what you have
|
|
115
|
-
- Never auto-continue past 3 search rounds without fresh context
|
|
64
|
+
- **Strictly read-only scout**: search with grep/glob/read and `pantheon-memory` (`memory_search`, `code_query`). Never modify files, never run shell commands.
|
|
65
|
+
- **Search order**: session context first, direct targeted searches second. Batch independent queries only when discovery scope benefits from parallel search.
|
|
66
|
+
- **Boundaries**: NEVER search or read inside `.pantheon/**`, `.pantheon/deepwork/**`, `.git/**`, `node_modules/**`, or `.pantheon-worktrees/**`.
|
|
67
|
+
- **External research**: Use configured web search MCP or `webfetch` for documentation URLs. Never invent citations.
|
|
68
|
+
- **Output format**: Return hierarchical structured findings (`files_changed`, `summary`, `confidence`). No raw dumps.
|