pantheon-opencode 2.1.2 → 2.1.3

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.
@@ -3,7 +3,21 @@ name: mnemosyne
3
3
  description: "Memory curation specialist — owns the durable pantheon-memory stores (memory_store/recall/search) and curates .pantheon/memory-bank/ + ADRs on request. Use when memory needs saving, curating or recovering."
4
4
  mode: all
5
5
  reasoning_effort: low
6
-
6
+ permission:
7
+ shell: deny
8
+ bash: deny
9
+ read: allow
10
+ grep: allow
11
+ write:
12
+ "*": deny
13
+ ".pantheon/memory-bank/**": allow
14
+ ".pantheon/deepwork/**": allow
15
+ edit:
16
+ "*": deny
17
+ ".pantheon/memory-bank/**": allow
18
+ ".pantheon/deepwork/**": allow
19
+ task:
20
+ "*": deny
7
21
  mcp_tools:
8
22
  pantheon-resources: all
9
23
  pantheon-memory:
@@ -23,24 +37,6 @@ skills:
23
37
  - session-goal
24
38
  - simplify
25
39
  - worktrees
26
- permission:
27
- shell: deny
28
- bash: deny
29
- read: allow
30
- grep: allow
31
- # Scoped write/edit: mnemosyne may create and modify files ONLY inside the
32
- # memory-bank and deepwork directories. Everything else stays denied, keeping
33
- # the SCOPE BOUNDARY below enforceable at the permission layer (issue #111).
34
- write:
35
- "*": deny
36
- ".pantheon/memory-bank/**": allow
37
- ".pantheon/deepwork/**": allow
38
- edit:
39
- "*": deny
40
- ".pantheon/memory-bank/**": allow
41
- ".pantheon/deepwork/**": allow
42
- task:
43
- "*": deny
44
40
  ---
45
41
 
46
42
  ## MCP governance (identical ladder, grant-aware)
package/src/agents/nyx.md CHANGED
@@ -3,6 +3,7 @@ name: nyx
3
3
  description: "Observability & cost analytics specialist — OpenTelemetry tracing, per-agent cost dashboards, anomaly detection; also chaos and adversarial testing (fuzzing, hostile inputs, boundaries). Analysis-only: never fixes, routes through Zeus."
4
4
  mode: all
5
5
  reasoning_effort: low
6
+ temperature: 0.1
6
7
  permission:
7
8
  read: allow
8
9
  grep: allow
@@ -13,7 +14,10 @@ permission:
13
14
  hashline_edit: deny
14
15
  task:
15
16
  "*": deny
16
- temperature: 0.1
17
+ mcp_tools:
18
+ pantheon-resources: all
19
+ pantheon-memory: [memory_search]
20
+ pantheon-code-mode: [execute_code_script]
17
21
  skills:
18
22
  - auto-continue
19
23
  - loop-engineering
@@ -21,10 +25,6 @@ skills:
21
25
  - security-hardening
22
26
  - simplify
23
27
  - worktrees
24
- mcp_tools:
25
- pantheon-resources: all
26
- pantheon-memory: [memory_search]
27
- pantheon-code-mode: [execute_code_script]
28
28
  ---
29
29
 
30
30
  ## MCP governance (identical ladder, grant-aware)
@@ -3,6 +3,7 @@ name: prometheus
3
3
  description: "Infrastructure + model provider specialist — Docker, CI/CD, multi-model routing, cost optimization, provider abstraction"
4
4
  mode: all
5
5
  reasoning_effort: medium
6
+ temperature: 0.2
6
7
  permission:
7
8
  read: allow
8
9
  grep: allow
@@ -13,7 +14,10 @@ permission:
13
14
  webfetch: allow
14
15
  task:
15
16
  "*": deny
16
- temperature: 0.2
17
+ mcp_tools:
18
+ pantheon-resources: all
19
+ pantheon-memory: [memory_search]
20
+ pantheon-code-mode: [execute_code_script]
17
21
  skills:
18
22
  - git-workflow-and-versioning
19
23
  - incremental-implementation
@@ -21,10 +25,6 @@ skills:
21
25
  - reflect
22
26
  - simplify
23
27
  - worktrees
24
- mcp_tools:
25
- pantheon-resources: all
26
- pantheon-memory: [memory_search]
27
- pantheon-code-mode: [execute_code_script]
28
28
  ---
29
29
 
30
30
  ## MCP governance (identical ladder, grant-aware)
@@ -3,6 +3,7 @@ name: talos
3
3
  description: "Hotfix express lane — direct fixes for small bugs, CSS, typos, minor logic. No TDD ceremony, no orchestration overhead. Standalone, no subagents. Escalates complex issues to zeus."
4
4
  mode: all
5
5
  reasoning_effort: low
6
+ temperature: 0.3
6
7
  permission:
7
8
  read: allow
8
9
  edit: allow
@@ -12,7 +13,10 @@ permission:
12
13
  grep: allow
13
14
  task:
14
15
  "*": deny
15
- temperature: 0.3
16
+ mcp_tools:
17
+ pantheon-resources: all
18
+ pantheon-memory: [memory_recall]
19
+ pantheon-code-mode: [execute_code_script]
16
20
  skills:
17
21
  - fast-path-execution
18
22
  - incremental-implementation
@@ -21,12 +25,12 @@ skills:
21
25
  - simplify
22
26
  - test-slicing
23
27
  - worktrees
24
- mcp_tools:
25
- pantheon-resources: all
26
- pantheon-memory: [memory_recall]
27
- pantheon-code-mode: [execute_code_script]
28
28
  ---
29
29
 
30
+ ## Test Slicing
31
+
32
+ - Validate hotfixes using a single focused check (<5s). NEVER run full repo test suites.
33
+
30
34
  ## MCP governance (identical ladder, grant-aware)
31
35
 
32
36
  - Escalation order: session context first; the local selector answers free;
@@ -3,6 +3,7 @@ name: themis
3
3
  description: "Quality & security gate — Ruff/Biome linting, dead/legacy code detection, OWASP Top 10, applicable coverage requirements, correctness, deprecation audit. Called for material/sensitive changes; escalates blockers to zeus."
4
4
  mode: all
5
5
  reasoning_effort: medium
6
+ temperature: 0.1
6
7
  permission:
7
8
  read: allow
8
9
  grep: allow
@@ -13,7 +14,9 @@ permission:
13
14
  pantheon_deepwork: allow
14
15
  task:
15
16
  "*": deny
16
- temperature: 0.1
17
+ mcp_tools:
18
+ pantheon-resources: all
19
+ pantheon-memory: [memory_search]
17
20
  skills:
18
21
  - code-review-checklist
19
22
  - loop-engineering
@@ -23,11 +26,13 @@ skills:
23
26
  - tdd-with-agents
24
27
  - test-slicing
25
28
  - worktrees
26
- mcp_tools:
27
- pantheon-resources: all
28
- pantheon-memory: [memory_search]
29
29
  ---
30
30
 
31
+ ## Strict Test Slicing Review Guard
32
+
33
+ - **NEVER RUN GLOBAL TEST SUITES:** Running `npm test` or unconstrained suites during reviews is STRICTLY PROHIBITED.
34
+ - **Run Slices Only:** Validate reviews using targeted single-file test slices (<10s).
35
+
31
36
  ## MCP governance (identical ladder, grant-aware)
32
37
 
33
38
  - Escalation order: session context first; the local selector answers free;
@@ -1,7 +1,9 @@
1
1
  ---
2
+ name: zeus
2
3
  description: "Central orchestrator — NEVER implements. Routes to specialists. General agent is forbidden."
3
4
  mode: primary
4
5
  reasoning_effort: medium
6
+ temperature: 0.2
5
7
  permission:
6
8
  read: allow
7
9
  edit: deny
@@ -13,9 +15,10 @@ permission:
13
15
  pantheon_skill_search: allow
14
16
  pantheon_deepwork: allow
15
17
  question: allow
18
+ todowrite: allow
19
+ todoread: allow
16
20
  task:
17
21
  "*": allow
18
- temperature: 0.2
19
22
  mcp_tools:
20
23
  pantheon-resources: all
21
24
  pantheon-memory: [memory_search]
@@ -60,6 +63,16 @@ skills:
60
63
  - When a request mixes refactor/fix/redesign without clear acceptance criteria, extract internal lean brief (Target, Slices, Constraints, Verification, Defaults).
61
64
  - If ambiguity blocks safe execution or presents critical trade-offs, **always invoke the native `question` tool** with concrete options (recommended option first) rather than making blind assumptions or writing plain-text questions.
62
65
 
66
+
67
+ ## Strict Test Slicing & Anti-Fatigue Mandate (Issue #437)
68
+
69
+ - **Repo Selector First:** Prefer the repository's own focused selector (e.g. `npm run test:quick`, `node scripts/test-slice.mjs`, `pytest -k`) over path guessing.
70
+ - **Mandatory Sliced Checks (<10s):** When dispatching implementation specialists (@hermes, @aphrodite, @talos, @demeter, @prometheus), ALWAYS provide the exact, narrow test slice command for the changed file (e.g. `node --test tests/<slice>.test.mjs`, `pytest tests/test_<slice>.py -k <func>`).
71
+ - **Global Suites Forbidden in Dev Loops:** STRICTLY FORBID specialists from running global repository-wide test suites (`npm test`, `npm run test:all`, unconstrained `pytest`). Full suites cause massive timeouts, context bloating, and token waste. Full suites are reserved exclusively for the final release/PR gate.
72
+ - **Failure/Fix Loop (No Redundant Passes):** When fixing a failed test, specialists MUST rerun ONLY the failed test (`-k <func>` or `--test-name-pattern`). DO NOT repeat passing tests if code was unchanged.
73
+ - **Mapping Gaps & Scope Justification:** If no direct test file exists, report the mapping gap and run static lint/typecheck fallback (`npx biome check <file>` or `ruff check <file>`) plus nearest slice; never escalate silently to full suites. Any broader-than-slice run requires visible scope justification.
74
+ - **Observable Summary Receipt:** Require the specialist to return the structured receipt: `**tests:** [PASS|WARN|FAIL] <cmd> (targets: N, duration: <X>s, selection: <reason>)`.
75
+
63
76
  ## Fast-Path Direct Implementation (Default Coding Workflow)
64
77
 
65
78
  - **Direct coding requests (features, bug fixes, refactoring, tests, hotfixes)**:
@@ -72,11 +85,19 @@ skills:
72
85
  - **Planning via @athena is strictly gated**:
73
86
  - ONLY invoke Athena when the user explicitly runs `/pantheon-deepwork` or explicitly requests a plan in the prompt ("plan this first", "create a plan", "planeje").
74
87
 
88
+ ## Session Task Checklist & TUI Todo Panel (`todowrite`)
89
+
90
+ - **Live TUI Progress:** Whenever coordinating a workflow with two or more steps, or executing an architecture/deepwork plan:
91
+ - **Initialize:** Call `todowrite` immediately with the sequential task checklist (all items marked `pending`).
92
+ - **Transition:** As each phase or specialist delegation starts, update the active item to `in_progress` via `todowrite`.
93
+ - **Complete:** Upon verification or specialist return, mark the item `completed` (or `cancelled` if discarded) via `todowrite`.
94
+ - This ensures the active session's task status is visible in real-time in the Pantheon TUI Todo block.
95
+
75
96
  ## Golden Rule & Boundaries
76
97
 
77
98
  **Coordinator and router.** Zeus never edits or implements code (delegates to @hermes, @aphrodite, @talos, etc.), but may perform bounded reads (≤50 lines) for fast routing without unnecessary subagent dispatches. Broad investigations or exploratory research go to @apollo. Routing and inspecting files across the `.pantheon/` directory (`.pantheon/**`, including plans, memory-bank, reports, configs) and active worktrees (`.pantheon-worktrees/**`) is fully permitted without restriction. Avoid broad recursive scans across `.git/**` or `node_modules/**`.
78
99
 
79
- Zeus NEVER edits files (`edit: deny`, `hashline_edit: deny`). Zero shell access (`bash: deny`, `shell: deny`).
100
+ Zeus NEVER edits files (`edit: deny`, `hashline_edit: deny`). Zero terminal access (`bash: deny`, `shell: deny`). OpenCode's native terminal tool is `bash` (aliased to `shell`). Zeus has NO terminal access.
80
101
  NEVER ask the user to type terminal commands — dispatch the specialist with bash permitted (@prometheus, @hermes, @talos).
81
102
 
82
103
  ## MCP call timing (when each integration fires)
@@ -11,7 +11,7 @@ All agents check each result against the request and evidence; remove unrelated
11
11
  ## subtask_summary
12
12
  **files_changed:** [list of file paths, one per line]
13
13
  **summary:** What was done, in 2-3 sentences
14
- **tests:** [PASS] All passing / [WARN] X failing / [FAIL] Not run (reason)
14
+ **tests:** [PASS | WARN | FAIL] `<command>` (targets: N, duration: <X>s, selection: <reason>)
15
15
  **coverage:** X% (if applicable)
16
16
  **tokens:** ~N input / ~M output (estimated)
17
17
  **status:** complete | partial (reason) | escalated (reason)
@@ -1,13 +1,13 @@
1
1
  ---
2
- description: "Test economy — write smaller, focused suites; heavy install/E2E suites are opt-in, never per-phase."
2
+ description: "Test economy — sub-10s test slicing; heavy suites are opt-in."
3
3
  name: "Test Economy"
4
4
  ---
5
5
 
6
6
  Write one focused test per behavior; do not duplicate coverage.
7
7
 
8
- - Prefer unit/integration checks; use E2E, install, or network tests only when a change affects that path.
9
- - Avoid assertions on copy/formatting or tests that merely restate the implementation.
10
- - Default to focused tests; run the full suite only for scope, risk, or CI/release gates. Bug fixes need one regression test unless existing coverage catches them.
11
- - Test slicing: In dev loops, run ONLY the test slice for the changed file (`node --test tests/foo.test.mjs`, `pytest -k <func>`); avoid full suites.
12
- - Keep slow install/E2E suites opt-in, never per edit or phase; reserve them for release gates.
8
+ - **Test Slicing**: In dev loops, run ONLY the narrowest slice (<10s) for changed code (`node --test <slice>`, `pytest -k`); avoid unconstrained suites.
9
+ - **Repo Selector & Receipt**: Prefer repo selectors (`test:quick`, `test:slice`); record command, targets, duration, and selection reason in `subtask_summary`.
10
+ - **Failure/Fix Loops**: Rerun ONLY failed checks; never rerun passing tests without code changes.
11
+ - **Mapping Gaps**: If a file lacks tests, run static check fallback plus nearest slice.
12
+ - Slow install/E2E suites are opt-in, never per edit; reserve for release gates.
13
13
  - Test economy does NOT weaken stronger gates: auth, security, data-integrity, and required coverage.
@@ -0,0 +1,303 @@
1
+ /**
2
+ * Auto-Permissions Engine — Intelligent Scope Governance.
3
+ *
4
+ * Intercepts OpenCode V2 permission evaluation events. When an action lands in
5
+ * `ask` status (permission prompt fatigue), it evaluates whether the requested
6
+ * tool or shell command is a safe, routine development action within the
7
+ * workspace.
8
+ *
9
+ * Rules:
10
+ * 1. Hard deny preservation: explicit host `deny` is NEVER overridden.
11
+ * 2. Catastrophic command rejection: dangerous operations (`rm -rf /`, `sudo`,
12
+ * arbitrary remote execution `curl | sh`, system path alteration) are strictly denied.
13
+ * 3. Read-only role isolation: read-only agents (`zeus`, `athena`, `apollo`, `gaia`)
14
+ * are never permitted to execute mutating tools or arbitrary shell commands.
15
+ * 4. Safe dev tool grant: routine developer commands (`node`, `python3`, `npm`,
16
+ * `git`, `mkdir`, `cat`, `ls`, local test scripts, etc.) and Pantheon native
17
+ * tools (`todowrite`, `pantheon_*`) are auto-approved without prompting.
18
+ * 5. Kill-switch: `PANTHEON_AUTO_PERMISSIONS=off` leaves `ask` untouched.
19
+ *
20
+ * @module auto-permissions
21
+ */
22
+
23
+ export interface AutoPermissionEvent {
24
+ action?: unknown
25
+ resources?: unknown
26
+ agent?: unknown
27
+ sessionID?: unknown
28
+ effect?: unknown
29
+ message?: unknown
30
+ }
31
+
32
+ export interface AutoPermissionOptions {
33
+ cwd?: string
34
+ env?: Record<string, string | undefined>
35
+ }
36
+
37
+ export interface AutoPermissionResult {
38
+ decision:
39
+ | 'allow'
40
+ | 'deny'
41
+ | 'preserve-deny'
42
+ | 'preserve-allow'
43
+ | 'passthrough'
44
+ | 'disabled'
45
+ | 'unconstrained-suite'
46
+ reason?: string
47
+ }
48
+
49
+ /** Agents strictly forbidden from mutating workspace files or executing arbitrary shell commands. */
50
+ const READ_ONLY_AGENTS: ReadonlySet<string> = new Set(['zeus', 'athena', 'apollo', 'gaia'])
51
+
52
+ /** Allowed binary names for routine workspace development. */
53
+ const SAFE_DEV_BINARIES: ReadonlySet<string> = new Set([
54
+ 'git',
55
+ 'npm',
56
+ 'npx',
57
+ 'node',
58
+ 'python',
59
+ 'python3',
60
+ 'pytest',
61
+ 'ruff',
62
+ 'cat',
63
+ 'ls',
64
+ 'mkdir',
65
+ 'cp',
66
+ 'mv',
67
+ 'touch',
68
+ 'grep',
69
+ 'find',
70
+ 'head',
71
+ 'tail',
72
+ 'diff',
73
+ 'echo',
74
+ 'which',
75
+ 'tar',
76
+ 'zip',
77
+ 'unzip',
78
+ 'curl',
79
+ 'jq',
80
+ 'sed',
81
+ 'awk',
82
+ 'biome',
83
+ 'tsc',
84
+ 'pnpm',
85
+ 'yarn',
86
+ 'bun',
87
+ 'cargo',
88
+ 'go',
89
+ 'sh',
90
+ 'bash',
91
+ ])
92
+
93
+ /** Check if auto-permissions engine is enabled in environment. */
94
+ export function autoPermissionsEnabled(
95
+ env: Record<string, string | undefined> = process.env,
96
+ ): boolean {
97
+ const val = (env.PANTHEON_AUTO_PERMISSIONS ?? '').trim().toLowerCase()
98
+ return val !== 'off' && val !== '0' && val !== 'false'
99
+ }
100
+
101
+ /** Check if a command matches high-risk destructive or privilege escalation patterns. */
102
+ export function isDangerousCommand(command: string): boolean {
103
+ const trimmed = command.trim()
104
+ if (!trimmed) return false
105
+
106
+ // Privilege escalation
107
+ if (/\bsudo\b/.test(trimmed)) return true
108
+
109
+ // Destructive recursive deletion targeting root, all root items, or user home
110
+ if (
111
+ /\brm\s+(-[a-zA-Z]*r[a-zA-Z]*f|-[a-zA-Z]*f[a-zA-Z]*r|--force)\s+(\/\s*$|\/\*\s*$|~\/?\s*$|\$HOME)/.test(
112
+ trimmed,
113
+ )
114
+ )
115
+ return true
116
+
117
+ // Remote execution via piping to shell
118
+ if (/(curl|wget)\b.*\|\s*(ba)?sh\b/.test(trimmed)) return true
119
+
120
+ // Raw disk formatting or writing
121
+ if (/\bmkfs(\.[a-z0-9]+)?\b/.test(trimmed)) return true
122
+ if (/\bdd\s+if=/.test(trimmed)) return true
123
+
124
+ // Global permissions tampering
125
+ if (/\bchmod\s+(-[a-zA-Z]*R[a-zA-Z]*\s+)?777\s+\//.test(trimmed)) return true
126
+
127
+ // Sensitive system directory writes
128
+ if (/\b(>\s*|\bcp\b.*|\bmv\b.*)\s+\/(etc|boot|sys|proc|root|usr)(\/|$)/.test(trimmed)) return true
129
+
130
+ return false
131
+ }
132
+
133
+ /** Check if a command is a standard dev command within workspace. */
134
+ export function isSafeDevCommand(command: string): boolean {
135
+ const trimmed = command.trim()
136
+ if (!trimmed) return false
137
+ if (isDangerousCommand(trimmed)) return false
138
+
139
+ // Extract the primary command tokens (before flags/arguments, handling simple env prefixes)
140
+ const segments = trimmed.split(/[|&;]/)
141
+ for (const rawSeg of segments) {
142
+ const seg = rawSeg.trim()
143
+ if (!seg) continue
144
+
145
+ const tokens = seg.split(/\s+/).filter(Boolean)
146
+ let binary = tokens[0] ?? ''
147
+
148
+ // Skip environment assignments like FOO=bar node ...
149
+ let tokenIdx = 0
150
+ while (binary.includes('=') && tokenIdx < tokens.length - 1) {
151
+ tokenIdx += 1
152
+ binary = tokens[tokenIdx] ?? ''
153
+ }
154
+
155
+ const cleanBinary = binary.replace(/^.*\//, '')
156
+ if (!SAFE_DEV_BINARIES.has(cleanBinary)) {
157
+ return false
158
+ }
159
+ }
160
+
161
+ return true
162
+ }
163
+
164
+ /**
165
+ * Detect unconstrained repository-wide test suite invocations.
166
+ *
167
+ * During active dev/fix/implementation loops, unconstrained test suites cause
168
+ * massive latency, timeouts, and token waste (Issue #437). Auto-permissions
169
+ * holds these in 'ask' so agents cannot silently burn minutes running hundreds
170
+ * of unrelated tests without explicit user intent or visible scope justification.
171
+ */
172
+ export function isUnconstrainedTestSuite(command: string): boolean {
173
+ const trimmed = command.trim()
174
+ if (!trimmed) return false
175
+
176
+ // Unconstrained npm test (without arguments or slice flags)
177
+ // Matches: npm test, npm run test, npm run test:all, pnpm test, yarn test, bun test
178
+ if (/^(npm|pnpm|yarn|bun)\s+(run\s+)?(test|test:all)(\s+--)?\s*$/.test(trimmed)) {
179
+ return true
180
+ }
181
+
182
+ // Unconstrained pytest (without -k, -m, or specific test path)
183
+ if (/^(python3?\s+-m\s+)?pytest\s*$/.test(trimmed)) {
184
+ return true
185
+ }
186
+
187
+ // Unconstrained vitest or jest (without file path or filter)
188
+ if (/^(npx\s+)?(vitest|jest)(\s+run)?\s*$/.test(trimmed)) {
189
+ return true
190
+ }
191
+
192
+ // Unconstrained cargo test
193
+ if (/^cargo\s+test\s*$/.test(trimmed)) {
194
+ return true
195
+ }
196
+
197
+ return false
198
+ }
199
+
200
+ /**
201
+ * Evaluate an OpenCode V2 permission evaluation event.
202
+ * If safe to auto-allow, sets `event.effect = 'allow'`.
203
+ */
204
+ export function evaluateAutoPermission(
205
+ event: AutoPermissionEvent,
206
+ options: AutoPermissionOptions = {},
207
+ ): AutoPermissionResult {
208
+ const env = options.env ?? process.env
209
+ if (!autoPermissionsEnabled(env)) {
210
+ return { decision: 'disabled' }
211
+ }
212
+
213
+ if (event.effect === 'deny') {
214
+ return { decision: 'preserve-deny' }
215
+ }
216
+
217
+ if (event.effect === 'allow') {
218
+ return { decision: 'preserve-allow' }
219
+ }
220
+
221
+ const action = String(event.action ?? '')
222
+ .toLowerCase()
223
+ .trim()
224
+ const agent = String(event.agent ?? '')
225
+ .toLowerCase()
226
+ .trim()
227
+
228
+ // 1. Native Pantheon tools and Todo tools are always auto-allowed
229
+ if (
230
+ action === 'todowrite' ||
231
+ action === 'todoread' ||
232
+ action === 'pantheon_deepwork' ||
233
+ action.startsWith('pantheon_')
234
+ ) {
235
+ event.effect = 'allow'
236
+ return { decision: 'allow', reason: 'pantheon-native-tool' }
237
+ }
238
+
239
+ // 2. Read-only agents are strictly prohibited from mutating tools or shell
240
+ if (READ_ONLY_AGENTS.has(agent)) {
241
+ if (['edit', 'write', 'hashline_edit', 'bash', 'shell'].includes(action)) {
242
+ event.effect = 'deny'
243
+ event.message = `Pantheon auto-permissions denied: read-only agent '${agent}' cannot execute mutating action '${action}'`
244
+ return { decision: 'deny', reason: 'read-only-role-violation' }
245
+ }
246
+ }
247
+
248
+ // 3. Read-only inspection tools are safe within workspace (excluding network/external URLs)
249
+ if (['read', 'glob', 'grep', 'webfetch', 'question'].includes(action)) {
250
+ const firstResource =
251
+ Array.isArray(event.resources) && typeof event.resources[0] === 'string'
252
+ ? event.resources[0]
253
+ : ''
254
+ if (firstResource.startsWith('http://') || firstResource.startsWith('https://')) {
255
+ return { decision: 'passthrough' }
256
+ }
257
+ event.effect = 'allow'
258
+ return { decision: 'allow', reason: 'safe-read-action' }
259
+ }
260
+
261
+ // 4. Shell commands
262
+ if (action === 'bash' || action === 'shell') {
263
+ const rawCmd =
264
+ Array.isArray(event.resources) && typeof event.resources[0] === 'string'
265
+ ? event.resources[0]
266
+ : ''
267
+
268
+ if (rawCmd) {
269
+ if (isDangerousCommand(rawCmd)) {
270
+ event.effect = 'deny'
271
+ event.message =
272
+ 'Pantheon auto-permissions denied: destructive or privilege-escalating command'
273
+ return { decision: 'deny', reason: 'dangerous-command' }
274
+ }
275
+
276
+ if (isUnconstrainedTestSuite(rawCmd)) {
277
+ event.effect = 'ask'
278
+ event.message =
279
+ 'Pantheon test-economy: unconstrained test suite detected in dev loop. ' +
280
+ 'Use a focused test slice (sub-10s) or provide scope justification.'
281
+ return {
282
+ decision: 'unconstrained-suite',
283
+ reason: 'unconstrained-test-suite-forbidden-in-dev-loop',
284
+ }
285
+ }
286
+
287
+ if (isSafeDevCommand(rawCmd)) {
288
+ event.effect = 'allow'
289
+ return { decision: 'allow', reason: 'safe-dev-command' }
290
+ }
291
+ }
292
+ }
293
+
294
+ // 5. File mutations for implementation agents
295
+ if (['edit', 'write', 'hashline_edit'].includes(action)) {
296
+ if (!READ_ONLY_AGENTS.has(agent)) {
297
+ event.effect = 'allow'
298
+ return { decision: 'allow', reason: 'implementer-workspace-edit' }
299
+ }
300
+ }
301
+
302
+ return { decision: 'passthrough' }
303
+ }
@@ -248,6 +248,17 @@ export function createDeepworkTool(cwd = process.cwd()): V2ToolDef {
248
248
 
249
249
  const projection = generateChatProjection(initialPlan, effectiveCwd)
250
250
  const approvalQ = buildApprovalQuestion(initialPlan)
251
+ const todoPayload = {
252
+ todos: tasks.map((t) => ({
253
+ content: `[${t.id}] ${t.title}`,
254
+ status:
255
+ t.state === 'done'
256
+ ? 'completed'
257
+ : t.state === 'in_progress'
258
+ ? 'in_progress'
259
+ : 'pending',
260
+ })),
261
+ }
251
262
 
252
263
  return {
253
264
  output: [
@@ -257,6 +268,9 @@ export function createDeepworkTool(cwd = process.cwd()): V2ToolDef {
257
268
  '',
258
269
  projection,
259
270
  '',
271
+ '**TUI Todo Sync:** Espelhe as tarefas chamando `todowrite` com:',
272
+ `\`\`\`json\n${JSON.stringify(todoPayload, null, 2)}\n\`\`\``,
273
+ '',
260
274
  '**Pergunta de Aprovação Nativa (Gate 1):**',
261
275
  `\`${JSON.stringify(approvalQ)}\``,
262
276
  ].join('\n'),
@@ -183,6 +183,7 @@ export const DEFAULT_BLOCKED_TOOLS: ReadonlySet<string> = new Set([
183
183
  'edit',
184
184
  'write',
185
185
  'bash',
186
+ 'shell',
186
187
  'task',
187
188
  'hashline_edit',
188
189
  // `pantheon_model` writes active-preset.json in BOTH the project and the
@@ -278,13 +279,34 @@ function isDeniedReadPath(candidate: string, target: boolean): boolean {
278
279
  export type GuardPathResolver = (rawPath: string) => GuardPathResolution
279
280
 
280
281
  /**
281
- * Glob expansion is controlled by the host and its symlink-follow behavior is
282
- * not part of this guard's contract. Only exact, non-glob paths are safe to
283
- * preflight; fail closed on glob metacharacters rather than infer the host's
284
- * expansion semantics.
282
+ * File extensions that identify source code or test files. Zeus must delegate
283
+ * source code exploration and search to @apollo.
285
284
  */
286
- function hasGlobMeta(value: string): boolean {
287
- return ['*', '?', '[', ']', '{', '}', '(', ')'].some((meta) => value.includes(meta))
285
+ const CODE_FILE_EXTENSIONS =
286
+ /\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|c|cpp|h|hpp|java|kt|rb|php|swift|cs|scala|vue|svelte)$/i
287
+
288
+ // Glob patterns that Zeus is denied from evaluating.
289
+ // Zeus is the orchestrator and must NOT read source code, tests, or scripts.
290
+ //
291
+ // Denied:
292
+ // - Direct targets into denied code roots (src/, tests/, scripts/)
293
+ // - Path traversal (../, ..)
294
+ // - Source code extensions (.ts, .py, etc.)
295
+ //
296
+ // Allowed:
297
+ // - Project-level metadata and non-code patterns: *, *.json, *.md, **/package.json, docs/**, .pantheon/**, memories/**
298
+ export function isDeniedGlobPattern(pattern: string): boolean {
299
+ const normalized = normalizeGuardPath(pattern)
300
+ if (normalized.startsWith('../') || normalized === '..' || normalized.includes('/../')) {
301
+ return true
302
+ }
303
+ if (isDeniedReadPath(normalized, true)) {
304
+ return true
305
+ }
306
+ if (CODE_FILE_EXTENSIONS.test(normalized)) {
307
+ return true
308
+ }
309
+ return false
288
310
  }
289
311
 
290
312
  /**
@@ -372,10 +394,10 @@ export function zeusReadGuard(
372
394
  if (tool === 'grep' && candidate.target) deny()
373
395
  continue
374
396
  }
375
- // Resolve every direct grep/glob path before any policy decision. Wildcard
376
- // expansion itself cannot be safely preflighted using the host's unknown
377
- // symlink semantics, so Zeus may glob exact paths only.
378
- if (tool === 'glob' && candidate.target && hasGlobMeta(effectivePath)) deny()
397
+ // Resolve every direct grep/glob path before any policy decision.
398
+ // Zeus is allowed to glob project-level metadata and non-code files (*, **/package.json),
399
+ // but denied from globbing code roots (src/, tests/, scripts/) or source code files.
400
+ if (tool === 'glob' && candidate.target && isDeniedGlobPattern(effectivePath)) deny()
379
401
  if (isDeniedReadPath(effectivePath, candidate.target)) deny()
380
402
  }
381
403
  }