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.
- package/AGENTS.global.md +7 -7
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +27 -0
- package/package.json +7 -4
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/build-plugin.mjs +35 -9
- package/scripts/build-roster.mjs +139 -0
- package/scripts/test-slice.mjs +352 -0
- package/skills-lock.json +1 -1
- package/src/agents/aphrodite.md +6 -6
- package/src/agents/apollo.md +7 -7
- package/src/agents/athena.md +20 -18
- package/src/agents/demeter.md +5 -5
- package/src/agents/gaia.md +5 -8
- package/src/agents/hephaestus.md +5 -5
- package/src/agents/hermes.md +18 -16
- package/src/agents/iris.md +8 -8
- package/src/agents/mnemosyne.md +15 -19
- package/src/agents/nyx.md +5 -5
- package/src/agents/prometheus.md +5 -5
- package/src/agents/talos.md +9 -5
- package/src/agents/themis.md +9 -4
- package/src/agents/zeus.md +23 -2
- package/src/instructions/agent-return-format.instructions.md +1 -1
- package/src/instructions/test-economy.instructions.md +6 -6
- package/src/pantheon/auto-permissions.ts +303 -0
- package/src/pantheon/deepwork/deepwork-tool.ts +14 -0
- package/src/pantheon/delegation-enforce.ts +32 -10
- package/src/pantheon/tools.ts +102 -3
- package/src/plugin/index.js +271 -6
- package/src/plugin.ts +7 -0
- package/src/plugins/tui/dist/tui.js +5 -5
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/skills/test-slicing/SKILL.md +44 -15
package/src/pantheon/tools.ts
CHANGED
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
* @module pantheon/tools
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
import { exec } from 'node:child_process'
|
|
50
|
+
import { promisify } from 'node:util'
|
|
49
51
|
import { createCostCommand } from './cost-command.ts'
|
|
50
52
|
import type { ShadowSink } from './decision-shadow.ts'
|
|
51
53
|
import { createDeepworkTool } from './deepwork/deepwork-tool.ts'
|
|
@@ -476,6 +478,16 @@ const TODOWRITE_INPUT = {
|
|
|
476
478
|
},
|
|
477
479
|
} as const
|
|
478
480
|
|
|
481
|
+
let latestSessionTodos: unknown[] = []
|
|
482
|
+
|
|
483
|
+
export function getLatestSessionTodos(): unknown[] {
|
|
484
|
+
return latestSessionTodos
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export function setLatestSessionTodos(todos: unknown[]): void {
|
|
488
|
+
latestSessionTodos = todos
|
|
489
|
+
}
|
|
490
|
+
|
|
479
491
|
/** A V2 pass-through `todowrite`: the host stores the tool part in the
|
|
480
492
|
* transcript, and the TUI todo panel renders the newest completed write. The
|
|
481
493
|
* tool itself is stateless — the transcript IS the store. */
|
|
@@ -487,13 +499,98 @@ const todowriteTool: V2ToolDef = {
|
|
|
487
499
|
input: TODOWRITE_INPUT,
|
|
488
500
|
output: {},
|
|
489
501
|
execute: async (input) => {
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
502
|
+
const rawTodos = (input as Record<string, unknown>).todos
|
|
503
|
+
const todos: unknown[] = Array.isArray(rawTodos) ? (rawTodos as unknown[]) : []
|
|
504
|
+
latestSessionTodos = todos
|
|
493
505
|
return { ok: true, todos, output: JSON.stringify({ todos }) }
|
|
494
506
|
},
|
|
495
507
|
}
|
|
496
508
|
|
|
509
|
+
const TODOREAD_INPUT = {
|
|
510
|
+
type: 'object',
|
|
511
|
+
additionalProperties: false,
|
|
512
|
+
properties: {
|
|
513
|
+
status: {
|
|
514
|
+
type: 'string',
|
|
515
|
+
description: 'Optional filter by task status (pending, in_progress, completed, cancelled)',
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
} as const
|
|
519
|
+
|
|
520
|
+
/** A V2 `todoread`: returns the newest task list written via `todowrite`. */
|
|
521
|
+
const todoreadTool: V2ToolDef = {
|
|
522
|
+
name: 'todoread',
|
|
523
|
+
description:
|
|
524
|
+
'Read the active session task checklist. Returns the newest list of tasks written via todowrite.',
|
|
525
|
+
input: TODOREAD_INPUT,
|
|
526
|
+
output: {},
|
|
527
|
+
execute: async (input) => {
|
|
528
|
+
const statusFilter = (input as Record<string, unknown>)?.status
|
|
529
|
+
let todos = latestSessionTodos
|
|
530
|
+
if (typeof statusFilter === 'string' && statusFilter.trim() !== '') {
|
|
531
|
+
todos = todos.filter(
|
|
532
|
+
(t) =>
|
|
533
|
+
typeof t === 'object' &&
|
|
534
|
+
t !== null &&
|
|
535
|
+
(t as Record<string, unknown>).status === statusFilter,
|
|
536
|
+
)
|
|
537
|
+
}
|
|
538
|
+
return {
|
|
539
|
+
ok: true,
|
|
540
|
+
todos,
|
|
541
|
+
output: JSON.stringify({ todos }),
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const execAsync = promisify(exec)
|
|
547
|
+
|
|
548
|
+
const SHELL_INPUT = {
|
|
549
|
+
type: 'object',
|
|
550
|
+
required: ['command'],
|
|
551
|
+
properties: {
|
|
552
|
+
command: {
|
|
553
|
+
type: 'string',
|
|
554
|
+
description: 'The shell command to execute in the workspace directory',
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
} as const
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* A V2 fallback shell tool alias. OpenCode registers `bash`, but models frequently
|
|
561
|
+
* attempt to invoke `shell` because of agent permission YAML conventions.
|
|
562
|
+
* This alias ensures terminal commands execute seamlessly without tool-not-found errors.
|
|
563
|
+
*/
|
|
564
|
+
const shellTool: V2ToolDef = {
|
|
565
|
+
name: 'shell',
|
|
566
|
+
description: 'Execute a shell command in the workspace directory. Alias for bash execution.',
|
|
567
|
+
input: SHELL_INPUT,
|
|
568
|
+
output: {},
|
|
569
|
+
execute: async (input, context) => {
|
|
570
|
+
const command = String((input as Record<string, unknown>).command ?? '')
|
|
571
|
+
if (!command.trim()) {
|
|
572
|
+
return { output: '', ok: false, error: 'Command cannot be empty' }
|
|
573
|
+
}
|
|
574
|
+
const toolCtx = toolContext(context)
|
|
575
|
+
const cwd = toolCtx.directory || process.cwd()
|
|
576
|
+
try {
|
|
577
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
578
|
+
cwd,
|
|
579
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
580
|
+
shell: '/bin/bash',
|
|
581
|
+
})
|
|
582
|
+
const output = [stdout, stderr].filter(Boolean).join('\n')
|
|
583
|
+
return { output, ok: true }
|
|
584
|
+
} catch (err: unknown) {
|
|
585
|
+
const execError = err as { stdout?: string; stderr?: string; message?: string }
|
|
586
|
+
const output = [execError.stdout, execError.stderr, execError.message]
|
|
587
|
+
.filter(Boolean)
|
|
588
|
+
.join('\n')
|
|
589
|
+
return { output, ok: false, error: output }
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
}
|
|
593
|
+
|
|
497
594
|
export function createV2ToolDefinitions(
|
|
498
595
|
visionRuntime?: V2VisionRuntime,
|
|
499
596
|
shadow: V2ToolShadowOptions = {},
|
|
@@ -545,6 +642,8 @@ export function createV2ToolDefinitions(
|
|
|
545
642
|
}),
|
|
546
643
|
)
|
|
547
644
|
definitions.push(todowriteTool)
|
|
645
|
+
definitions.push(todoreadTool)
|
|
646
|
+
definitions.push(shellTool)
|
|
548
647
|
definitions.push(createV2SkillSearchDefinition())
|
|
549
648
|
definitions.push(createDeepworkTool())
|
|
550
649
|
if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime))
|
package/src/plugin/index.js
CHANGED
|
@@ -12,6 +12,168 @@ import path4 from "node:path";
|
|
|
12
12
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
13
13
|
import { define } from "@opencode-ai/plugin/v2/promise";
|
|
14
14
|
|
|
15
|
+
// src/pantheon/auto-permissions.ts
|
|
16
|
+
var READ_ONLY_AGENTS = /* @__PURE__ */ new Set(["zeus", "athena", "apollo", "gaia"]);
|
|
17
|
+
var SAFE_DEV_BINARIES = /* @__PURE__ */ new Set([
|
|
18
|
+
"git",
|
|
19
|
+
"npm",
|
|
20
|
+
"npx",
|
|
21
|
+
"node",
|
|
22
|
+
"python",
|
|
23
|
+
"python3",
|
|
24
|
+
"pytest",
|
|
25
|
+
"ruff",
|
|
26
|
+
"cat",
|
|
27
|
+
"ls",
|
|
28
|
+
"mkdir",
|
|
29
|
+
"cp",
|
|
30
|
+
"mv",
|
|
31
|
+
"touch",
|
|
32
|
+
"grep",
|
|
33
|
+
"find",
|
|
34
|
+
"head",
|
|
35
|
+
"tail",
|
|
36
|
+
"diff",
|
|
37
|
+
"echo",
|
|
38
|
+
"which",
|
|
39
|
+
"tar",
|
|
40
|
+
"zip",
|
|
41
|
+
"unzip",
|
|
42
|
+
"curl",
|
|
43
|
+
"jq",
|
|
44
|
+
"sed",
|
|
45
|
+
"awk",
|
|
46
|
+
"biome",
|
|
47
|
+
"tsc",
|
|
48
|
+
"pnpm",
|
|
49
|
+
"yarn",
|
|
50
|
+
"bun",
|
|
51
|
+
"cargo",
|
|
52
|
+
"go",
|
|
53
|
+
"sh",
|
|
54
|
+
"bash"
|
|
55
|
+
]);
|
|
56
|
+
function autoPermissionsEnabled(env = process.env) {
|
|
57
|
+
const val = (env.PANTHEON_AUTO_PERMISSIONS ?? "").trim().toLowerCase();
|
|
58
|
+
return val !== "off" && val !== "0" && val !== "false";
|
|
59
|
+
}
|
|
60
|
+
function isDangerousCommand(command) {
|
|
61
|
+
const trimmed = command.trim();
|
|
62
|
+
if (!trimmed) return false;
|
|
63
|
+
if (/\bsudo\b/.test(trimmed)) return true;
|
|
64
|
+
if (/\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(
|
|
65
|
+
trimmed
|
|
66
|
+
))
|
|
67
|
+
return true;
|
|
68
|
+
if (/(curl|wget)\b.*\|\s*(ba)?sh\b/.test(trimmed)) return true;
|
|
69
|
+
if (/\bmkfs(\.[a-z0-9]+)?\b/.test(trimmed)) return true;
|
|
70
|
+
if (/\bdd\s+if=/.test(trimmed)) return true;
|
|
71
|
+
if (/\bchmod\s+(-[a-zA-Z]*R[a-zA-Z]*\s+)?777\s+\//.test(trimmed)) return true;
|
|
72
|
+
if (/\b(>\s*|\bcp\b.*|\bmv\b.*)\s+\/(etc|boot|sys|proc|root|usr)(\/|$)/.test(trimmed)) return true;
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
function isSafeDevCommand(command) {
|
|
76
|
+
const trimmed = command.trim();
|
|
77
|
+
if (!trimmed) return false;
|
|
78
|
+
if (isDangerousCommand(trimmed)) return false;
|
|
79
|
+
const segments = trimmed.split(/[|&;]/);
|
|
80
|
+
for (const rawSeg of segments) {
|
|
81
|
+
const seg = rawSeg.trim();
|
|
82
|
+
if (!seg) continue;
|
|
83
|
+
const tokens = seg.split(/\s+/).filter(Boolean);
|
|
84
|
+
let binary = tokens[0] ?? "";
|
|
85
|
+
let tokenIdx = 0;
|
|
86
|
+
while (binary.includes("=") && tokenIdx < tokens.length - 1) {
|
|
87
|
+
tokenIdx += 1;
|
|
88
|
+
binary = tokens[tokenIdx] ?? "";
|
|
89
|
+
}
|
|
90
|
+
const cleanBinary = binary.replace(/^.*\//, "");
|
|
91
|
+
if (!SAFE_DEV_BINARIES.has(cleanBinary)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
function isUnconstrainedTestSuite(command) {
|
|
98
|
+
const trimmed = command.trim();
|
|
99
|
+
if (!trimmed) return false;
|
|
100
|
+
if (/^(npm|pnpm|yarn|bun)\s+(run\s+)?(test|test:all)(\s+--)?\s*$/.test(trimmed)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (/^(python3?\s+-m\s+)?pytest\s*$/.test(trimmed)) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (/^(npx\s+)?(vitest|jest)(\s+run)?\s*$/.test(trimmed)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (/^cargo\s+test\s*$/.test(trimmed)) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
function evaluateAutoPermission(event, options = {}) {
|
|
115
|
+
const env = options.env ?? process.env;
|
|
116
|
+
if (!autoPermissionsEnabled(env)) {
|
|
117
|
+
return { decision: "disabled" };
|
|
118
|
+
}
|
|
119
|
+
if (event.effect === "deny") {
|
|
120
|
+
return { decision: "preserve-deny" };
|
|
121
|
+
}
|
|
122
|
+
if (event.effect === "allow") {
|
|
123
|
+
return { decision: "preserve-allow" };
|
|
124
|
+
}
|
|
125
|
+
const action = String(event.action ?? "").toLowerCase().trim();
|
|
126
|
+
const agent = String(event.agent ?? "").toLowerCase().trim();
|
|
127
|
+
if (action === "todowrite" || action === "todoread" || action === "pantheon_deepwork" || action.startsWith("pantheon_")) {
|
|
128
|
+
event.effect = "allow";
|
|
129
|
+
return { decision: "allow", reason: "pantheon-native-tool" };
|
|
130
|
+
}
|
|
131
|
+
if (READ_ONLY_AGENTS.has(agent)) {
|
|
132
|
+
if (["edit", "write", "hashline_edit", "bash", "shell"].includes(action)) {
|
|
133
|
+
event.effect = "deny";
|
|
134
|
+
event.message = `Pantheon auto-permissions denied: read-only agent '${agent}' cannot execute mutating action '${action}'`;
|
|
135
|
+
return { decision: "deny", reason: "read-only-role-violation" };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (["read", "glob", "grep", "webfetch", "question"].includes(action)) {
|
|
139
|
+
const firstResource = Array.isArray(event.resources) && typeof event.resources[0] === "string" ? event.resources[0] : "";
|
|
140
|
+
if (firstResource.startsWith("http://") || firstResource.startsWith("https://")) {
|
|
141
|
+
return { decision: "passthrough" };
|
|
142
|
+
}
|
|
143
|
+
event.effect = "allow";
|
|
144
|
+
return { decision: "allow", reason: "safe-read-action" };
|
|
145
|
+
}
|
|
146
|
+
if (action === "bash" || action === "shell") {
|
|
147
|
+
const rawCmd = Array.isArray(event.resources) && typeof event.resources[0] === "string" ? event.resources[0] : "";
|
|
148
|
+
if (rawCmd) {
|
|
149
|
+
if (isDangerousCommand(rawCmd)) {
|
|
150
|
+
event.effect = "deny";
|
|
151
|
+
event.message = "Pantheon auto-permissions denied: destructive or privilege-escalating command";
|
|
152
|
+
return { decision: "deny", reason: "dangerous-command" };
|
|
153
|
+
}
|
|
154
|
+
if (isUnconstrainedTestSuite(rawCmd)) {
|
|
155
|
+
event.effect = "ask";
|
|
156
|
+
event.message = "Pantheon test-economy: unconstrained test suite detected in dev loop. Use a focused test slice (sub-10s) or provide scope justification.";
|
|
157
|
+
return {
|
|
158
|
+
decision: "unconstrained-suite",
|
|
159
|
+
reason: "unconstrained-test-suite-forbidden-in-dev-loop"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (isSafeDevCommand(rawCmd)) {
|
|
163
|
+
event.effect = "allow";
|
|
164
|
+
return { decision: "allow", reason: "safe-dev-command" };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (["edit", "write", "hashline_edit"].includes(action)) {
|
|
169
|
+
if (!READ_ONLY_AGENTS.has(agent)) {
|
|
170
|
+
event.effect = "allow";
|
|
171
|
+
return { decision: "allow", reason: "implementer-workspace-edit" };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { decision: "passthrough" };
|
|
175
|
+
}
|
|
176
|
+
|
|
15
177
|
// src/pantheon/behavior-overrides.ts
|
|
16
178
|
var OVERRIDE_CONTENT_MAX = 8e3;
|
|
17
179
|
var OVERRIDE_REASON_MAX = 200;
|
|
@@ -3693,6 +3855,7 @@ var DEFAULT_BLOCKED_TOOLS = /* @__PURE__ */ new Set([
|
|
|
3693
3855
|
"edit",
|
|
3694
3856
|
"write",
|
|
3695
3857
|
"bash",
|
|
3858
|
+
"shell",
|
|
3696
3859
|
"task",
|
|
3697
3860
|
"hashline_edit",
|
|
3698
3861
|
// `pantheon_model` writes active-preset.json in BOTH the project and the
|
|
@@ -3734,8 +3897,19 @@ function isDeniedReadPath(candidate, target) {
|
|
|
3734
3897
|
}
|
|
3735
3898
|
return false;
|
|
3736
3899
|
}
|
|
3737
|
-
|
|
3738
|
-
|
|
3900
|
+
var CODE_FILE_EXTENSIONS = /\.(ts|tsx|js|jsx|mjs|cjs|py|go|rs|c|cpp|h|hpp|java|kt|rb|php|swift|cs|scala|vue|svelte)$/i;
|
|
3901
|
+
function isDeniedGlobPattern(pattern) {
|
|
3902
|
+
const normalized = normalizeGuardPath(pattern);
|
|
3903
|
+
if (normalized.startsWith("../") || normalized === ".." || normalized.includes("/../")) {
|
|
3904
|
+
return true;
|
|
3905
|
+
}
|
|
3906
|
+
if (isDeniedReadPath(normalized, true)) {
|
|
3907
|
+
return true;
|
|
3908
|
+
}
|
|
3909
|
+
if (CODE_FILE_EXTENSIONS.test(normalized)) {
|
|
3910
|
+
return true;
|
|
3911
|
+
}
|
|
3912
|
+
return false;
|
|
3739
3913
|
}
|
|
3740
3914
|
function zeusReadGuard(tool2, args, agent, resolvePath) {
|
|
3741
3915
|
if (agent !== "zeus") return;
|
|
@@ -3770,7 +3944,7 @@ function zeusReadGuard(tool2, args, agent, resolvePath) {
|
|
|
3770
3944
|
if (tool2 === "grep" && candidate.target) deny();
|
|
3771
3945
|
continue;
|
|
3772
3946
|
}
|
|
3773
|
-
if (tool2 === "glob" && candidate.target &&
|
|
3947
|
+
if (tool2 === "glob" && candidate.target && isDeniedGlobPattern(effectivePath)) deny();
|
|
3774
3948
|
if (isDeniedReadPath(effectivePath, candidate.target)) deny();
|
|
3775
3949
|
}
|
|
3776
3950
|
}
|
|
@@ -3804,8 +3978,8 @@ var ReadOnlySessionRegistry = class {
|
|
|
3804
3978
|
}
|
|
3805
3979
|
};
|
|
3806
3980
|
var readOnlyRegistry = new ReadOnlySessionRegistry();
|
|
3807
|
-
var
|
|
3808
|
-
function syncReadOnlySession(registry, sessionID, agent, readOnlyAgents =
|
|
3981
|
+
var READ_ONLY_AGENTS2 = /* @__PURE__ */ new Set(["apollo", "gaia"]);
|
|
3982
|
+
function syncReadOnlySession(registry, sessionID, agent, readOnlyAgents = READ_ONLY_AGENTS2) {
|
|
3809
3983
|
const normalized = normalizeDelegationAgent(agent);
|
|
3810
3984
|
if (normalized === void 0 || !readOnlyAgents.has(normalized)) {
|
|
3811
3985
|
registry.unregister(sessionID);
|
|
@@ -10558,6 +10732,10 @@ var TodoEnforcer = class {
|
|
|
10558
10732
|
}
|
|
10559
10733
|
};
|
|
10560
10734
|
|
|
10735
|
+
// src/pantheon/tools.ts
|
|
10736
|
+
import { exec } from "node:child_process";
|
|
10737
|
+
import { promisify } from "node:util";
|
|
10738
|
+
|
|
10561
10739
|
// src/pantheon/cost-command.ts
|
|
10562
10740
|
import { execFile } from "node:child_process";
|
|
10563
10741
|
import { accessSync, constants as constants3, existsSync as existsSync5, statSync as statSync3 } from "node:fs";
|
|
@@ -12425,6 +12603,12 @@ function createDeepworkTool(cwd = process.cwd()) {
|
|
|
12425
12603
|
});
|
|
12426
12604
|
const projection = generateChatProjection(initialPlan, effectiveCwd);
|
|
12427
12605
|
const approvalQ = buildApprovalQuestion(initialPlan);
|
|
12606
|
+
const todoPayload = {
|
|
12607
|
+
todos: tasks.map((t) => ({
|
|
12608
|
+
content: `[${t.id}] ${t.title}`,
|
|
12609
|
+
status: t.state === "done" ? "completed" : t.state === "in_progress" ? "in_progress" : "pending"
|
|
12610
|
+
}))
|
|
12611
|
+
};
|
|
12428
12612
|
return {
|
|
12429
12613
|
output: [
|
|
12430
12614
|
`\u2705 Plano de Deepwork '${title}' inicializado com sucesso em \`.pantheon/deepwork/${slug}/\`!`,
|
|
@@ -12432,6 +12616,11 @@ function createDeepworkTool(cwd = process.cwd()) {
|
|
|
12432
12616
|
`- \u{1F517} **Deeplink plan.json:** [Abrir plan.json](file://${deepworkPlanJsonPath(effectiveCwd, slug)})`,
|
|
12433
12617
|
"",
|
|
12434
12618
|
projection,
|
|
12619
|
+
"",
|
|
12620
|
+
"**TUI Todo Sync:** Espelhe as tarefas chamando `todowrite` com:",
|
|
12621
|
+
`\`\`\`json
|
|
12622
|
+
${JSON.stringify(todoPayload, null, 2)}
|
|
12623
|
+
\`\`\``,
|
|
12435
12624
|
"",
|
|
12436
12625
|
"**Pergunta de Aprova\xE7\xE3o Nativa (Gate 1):**",
|
|
12437
12626
|
`\`${JSON.stringify(approvalQ)}\``
|
|
@@ -14142,16 +14331,87 @@ var TODOWRITE_INPUT = {
|
|
|
14142
14331
|
}
|
|
14143
14332
|
}
|
|
14144
14333
|
};
|
|
14334
|
+
var latestSessionTodos = [];
|
|
14145
14335
|
var todowriteTool = {
|
|
14146
14336
|
name: "todowrite",
|
|
14147
14337
|
description: "Write the session task checklist (full replace). The TUI todo panel renders the newest list; mark each item in_progress/completed as soon as its state changes.",
|
|
14148
14338
|
input: TODOWRITE_INPUT,
|
|
14149
14339
|
output: {},
|
|
14150
14340
|
execute: async (input) => {
|
|
14151
|
-
const
|
|
14341
|
+
const rawTodos = input.todos;
|
|
14342
|
+
const todos = Array.isArray(rawTodos) ? rawTodos : [];
|
|
14343
|
+
latestSessionTodos = todos;
|
|
14152
14344
|
return { ok: true, todos, output: JSON.stringify({ todos }) };
|
|
14153
14345
|
}
|
|
14154
14346
|
};
|
|
14347
|
+
var TODOREAD_INPUT = {
|
|
14348
|
+
type: "object",
|
|
14349
|
+
additionalProperties: false,
|
|
14350
|
+
properties: {
|
|
14351
|
+
status: {
|
|
14352
|
+
type: "string",
|
|
14353
|
+
description: "Optional filter by task status (pending, in_progress, completed, cancelled)"
|
|
14354
|
+
}
|
|
14355
|
+
}
|
|
14356
|
+
};
|
|
14357
|
+
var todoreadTool = {
|
|
14358
|
+
name: "todoread",
|
|
14359
|
+
description: "Read the active session task checklist. Returns the newest list of tasks written via todowrite.",
|
|
14360
|
+
input: TODOREAD_INPUT,
|
|
14361
|
+
output: {},
|
|
14362
|
+
execute: async (input) => {
|
|
14363
|
+
const statusFilter = input?.status;
|
|
14364
|
+
let todos = latestSessionTodos;
|
|
14365
|
+
if (typeof statusFilter === "string" && statusFilter.trim() !== "") {
|
|
14366
|
+
todos = todos.filter(
|
|
14367
|
+
(t) => typeof t === "object" && t !== null && t.status === statusFilter
|
|
14368
|
+
);
|
|
14369
|
+
}
|
|
14370
|
+
return {
|
|
14371
|
+
ok: true,
|
|
14372
|
+
todos,
|
|
14373
|
+
output: JSON.stringify({ todos })
|
|
14374
|
+
};
|
|
14375
|
+
}
|
|
14376
|
+
};
|
|
14377
|
+
var execAsync = promisify(exec);
|
|
14378
|
+
var SHELL_INPUT = {
|
|
14379
|
+
type: "object",
|
|
14380
|
+
required: ["command"],
|
|
14381
|
+
properties: {
|
|
14382
|
+
command: {
|
|
14383
|
+
type: "string",
|
|
14384
|
+
description: "The shell command to execute in the workspace directory"
|
|
14385
|
+
}
|
|
14386
|
+
}
|
|
14387
|
+
};
|
|
14388
|
+
var shellTool = {
|
|
14389
|
+
name: "shell",
|
|
14390
|
+
description: "Execute a shell command in the workspace directory. Alias for bash execution.",
|
|
14391
|
+
input: SHELL_INPUT,
|
|
14392
|
+
output: {},
|
|
14393
|
+
execute: async (input, context) => {
|
|
14394
|
+
const command = String(input.command ?? "");
|
|
14395
|
+
if (!command.trim()) {
|
|
14396
|
+
return { output: "", ok: false, error: "Command cannot be empty" };
|
|
14397
|
+
}
|
|
14398
|
+
const toolCtx = toolContext(context);
|
|
14399
|
+
const cwd = toolCtx.directory || process.cwd();
|
|
14400
|
+
try {
|
|
14401
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
14402
|
+
cwd,
|
|
14403
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
14404
|
+
shell: "/bin/bash"
|
|
14405
|
+
});
|
|
14406
|
+
const output = [stdout, stderr].filter(Boolean).join("\n");
|
|
14407
|
+
return { output, ok: true };
|
|
14408
|
+
} catch (err) {
|
|
14409
|
+
const execError = err;
|
|
14410
|
+
const output = [execError.stdout, execError.stderr, execError.message].filter(Boolean).join("\n");
|
|
14411
|
+
return { output, ok: false, error: output };
|
|
14412
|
+
}
|
|
14413
|
+
}
|
|
14414
|
+
};
|
|
14155
14415
|
function createV2ToolDefinitions(visionRuntime, shadow = {}, jevRuntime) {
|
|
14156
14416
|
const definitions = [
|
|
14157
14417
|
{
|
|
@@ -14182,6 +14442,8 @@ function createV2ToolDefinitions(visionRuntime, shadow = {}, jevRuntime) {
|
|
|
14182
14442
|
})
|
|
14183
14443
|
);
|
|
14184
14444
|
definitions.push(todowriteTool);
|
|
14445
|
+
definitions.push(todoreadTool);
|
|
14446
|
+
definitions.push(shellTool);
|
|
14185
14447
|
definitions.push(createV2SkillSearchDefinition());
|
|
14186
14448
|
definitions.push(createDeepworkTool());
|
|
14187
14449
|
if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime));
|
|
@@ -15260,6 +15522,9 @@ async function registerV2PermissionHook(context, subagentOrigins) {
|
|
|
15260
15522
|
deny("caller or target is not allowed by delegation policy");
|
|
15261
15523
|
return;
|
|
15262
15524
|
}
|
|
15525
|
+
if (event.effect !== "deny") {
|
|
15526
|
+
evaluateAutoPermission(event, { cwd: domains.location?.directory || process.cwd() });
|
|
15527
|
+
}
|
|
15263
15528
|
writeProof();
|
|
15264
15529
|
recordP8(p8Result, event);
|
|
15265
15530
|
});
|
package/src/plugin.ts
CHANGED
|
@@ -95,6 +95,7 @@ import type {
|
|
|
95
95
|
ReferenceDraft,
|
|
96
96
|
} from '@opencode-ai/plugin/v2/promise'
|
|
97
97
|
import { define } from '@opencode-ai/plugin/v2/promise'
|
|
98
|
+
import { evaluateAutoPermission } from './pantheon/auto-permissions.ts'
|
|
98
99
|
import { type EffectiveOverrides, mergeOverrides } from './pantheon/behavior-overrides.ts'
|
|
99
100
|
import {
|
|
100
101
|
BOUNDED_READ_TOOL,
|
|
@@ -2516,6 +2517,12 @@ async function registerV2PermissionHook(
|
|
|
2516
2517
|
deny('caller or target is not allowed by delegation policy')
|
|
2517
2518
|
return
|
|
2518
2519
|
}
|
|
2520
|
+
|
|
2521
|
+
// Auto-Permissions: Evaluate safe workspace actions if the event is not denied
|
|
2522
|
+
if (event.effect !== 'deny') {
|
|
2523
|
+
evaluateAutoPermission(event, { cwd: domains.location?.directory || process.cwd() })
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2519
2526
|
writeProof()
|
|
2520
2527
|
recordP8(p8Result, event)
|
|
2521
2528
|
})
|
|
@@ -2062,7 +2062,7 @@ async function readChangelogForBundle(bundleUrl) {
|
|
|
2062
2062
|
}
|
|
2063
2063
|
/** The ambient build-time version, or null outside a tsdown build. */
|
|
2064
2064
|
function embeddedVersion() {
|
|
2065
|
-
return "2.1.
|
|
2065
|
+
return "2.1.3";
|
|
2066
2066
|
}
|
|
2067
2067
|
/**
|
|
2068
2068
|
* Resolve the running Pantheon version for the what's-new window: the plugin
|
|
@@ -2287,7 +2287,7 @@ function persistUpdateCheckState(previous, latest) {
|
|
|
2287
2287
|
} catch {}
|
|
2288
2288
|
}
|
|
2289
2289
|
function resolveRunningVersion() {
|
|
2290
|
-
return "2.1.
|
|
2290
|
+
return "2.1.3";
|
|
2291
2291
|
}
|
|
2292
2292
|
const VALUE_WIDTH = 24;
|
|
2293
2293
|
function SettingsWindow(props) {
|
|
@@ -6513,7 +6513,7 @@ async function checkForPantheonUpdate(context) {
|
|
|
6513
6513
|
const latest = String((await response.json())?.version ?? "");
|
|
6514
6514
|
if (!latest) return;
|
|
6515
6515
|
const notice = pickUpdateNotice({
|
|
6516
|
-
currentVersion: "2.1.
|
|
6516
|
+
currentVersion: "2.1.3",
|
|
6517
6517
|
latestVersion: latest,
|
|
6518
6518
|
state: readState(),
|
|
6519
6519
|
nowMs: Date.now()
|
|
@@ -7325,7 +7325,7 @@ function Sidebar(props) {
|
|
|
7325
7325
|
get children() {
|
|
7326
7326
|
var _el$13 = createElement("text");
|
|
7327
7327
|
setProp(_el$13, "attributes", 1);
|
|
7328
|
-
insert(_el$13, `Pantheon v2.1.
|
|
7328
|
+
insert(_el$13, `Pantheon v2.1.3`);
|
|
7329
7329
|
effect((_$p) => setProp(_el$13, "fg", text(), _$p));
|
|
7330
7330
|
return _el$13;
|
|
7331
7331
|
}
|
|
@@ -8097,7 +8097,7 @@ function HomeStatus(props) {
|
|
|
8097
8097
|
},
|
|
8098
8098
|
get children() {
|
|
8099
8099
|
var _el$73 = createElement("text");
|
|
8100
|
-
insert(_el$73, () => `Pantheon v2.1.
|
|
8100
|
+
insert(_el$73, () => `Pantheon v2.1.3${preset().name ? ` ▸ ${preset().name}` : ""}`);
|
|
8101
8101
|
effect((_$p) => setProp(_el$73, "fg", muted(), _$p));
|
|
8102
8102
|
return _el$73;
|
|
8103
8103
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "2.1.
|
|
9
|
+
"version": "2.1.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@opencode/plugin": "2.0.26",
|
|
@@ -3,20 +3,51 @@ name: test-slicing
|
|
|
3
3
|
description: "Targeted test execution — map changed files directly to their narrow test slice instead of running full suites."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Test Slicing
|
|
6
|
+
# Test Slicing (Observable & Enforceable)
|
|
7
7
|
|
|
8
|
-
> **Never run
|
|
8
|
+
> **Never run unconstrained repository-wide test suites for isolated edits. Map modified files directly to their narrow, sub-10s test slice to eliminate test fatigue, conserve tokens, and maintain high developer velocity.**
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Core Rules & Protocol (Issue #437)
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
### 1. Repository-First Selector Discovery
|
|
15
|
+
Always prefer the repository's own focused selector or diff-aware command over guessing paths:
|
|
16
|
+
1. Inspect `package.json` / `pyproject.toml` / `Makefile` for focused slice runners:
|
|
17
|
+
- Node/TypeScript: `npm run test:quick`, `npm run test:slice`, `npm run test:fast`, `node scripts/test-slice.mjs`
|
|
18
|
+
- Python: `pytest -k <selector>`, `pytest tests/test_<slice>.py`
|
|
19
|
+
2. If a project-defined focused selector exists, execute it directly.
|
|
20
|
+
3. If absent, map the modified file directly to its corresponding test file.
|
|
21
|
+
|
|
22
|
+
### 2. Scope Escalation & Mapping Gap Protocol
|
|
23
|
+
- **No Silent Escalation:** NEVER silently broaden a test run from a modified file to an entire package or global suite.
|
|
24
|
+
- **Explicit Justification:** If an expansion beyond the narrow slice is genuinely warranted (e.g. cross-cutting auth change, schema migration affecting multiple handlers), state visibly before running:
|
|
25
|
+
`[Test Scope Expansion] Scope: <files> | Selected: <tests> | Reason: <concrete risk/integration rationale>`
|
|
26
|
+
- **Mapping Gap Handling:** If a modified file has no direct test counterpart:
|
|
27
|
+
1. Report the mapping gap explicitly: `[Test Mapping Gap] No direct test file for <file>.`
|
|
28
|
+
2. Execute a bounded risk-appropriate fallback (static lint/typecheck gate e.g. `npx biome check <file>` or `ruff check <file>` plus the closest integration slice).
|
|
29
|
+
3. DO NOT escalate to running the entire repository test suite.
|
|
30
|
+
|
|
31
|
+
### 3. Failure/Fix Loop (Rerun Only Failed Tests)
|
|
32
|
+
- After an initial edit, run only the selected slice.
|
|
33
|
+
- When an assertion or test fails:
|
|
34
|
+
1. Diagnose and apply the fix to the target file.
|
|
35
|
+
2. **Rerun ONLY the failed test** (e.g. `pytest tests/test_foo.py -k <failing_func>` or `node --test tests/foo.test.mjs --test-name-pattern="<failing_test>"`).
|
|
36
|
+
3. **DO NOT rerun checks that already passed** when their covered code did not change.
|
|
37
|
+
4. Once the targeted test passes, rerun the single slice file once to confirm no regressions within the file.
|
|
38
|
+
|
|
39
|
+
### 4. Observable Task Receipt Summary
|
|
40
|
+
Every implementation specialist MUST include the detailed test receipt in the `subtask_summary`:
|
|
41
|
+
```markdown
|
|
42
|
+
**tests:** [PASS | WARN | FAIL] `<command>` (targets: N, duration: <X>s, selection: <reason or repo selector>)
|
|
43
|
+
**test_scope_justification:** <required ONLY if broader than a focused slice>
|
|
44
|
+
```
|
|
45
|
+
*Example:*
|
|
46
|
+
`**tests:** [PASS] npx tsx tests/pantheon/auto-permissions.test.ts (targets: 10, duration: 0.12s, selection: direct file slice for auto-permissions.ts)`
|
|
47
|
+
|
|
48
|
+
### 5. Preserving CI and Release Gates
|
|
49
|
+
- Full-suite checks (`npm test`, unconstrained `pytest`, full CI pipelines) remain required and intact for release gates and PR validations.
|
|
50
|
+
- Developer loops run narrow slices exclusively.
|
|
20
51
|
|
|
21
52
|
---
|
|
22
53
|
|
|
@@ -25,6 +56,7 @@ description: "Targeted test execution — map changed files directly to their na
|
|
|
25
56
|
| Runtime / Framework | Changed Source File | Sliced Test Command |
|
|
26
57
|
|---|---|---|
|
|
27
58
|
| **Node.js (Built-in test runner)** | `src/foo.ts` / `src/foo.js` | `node --test tests/foo.test.mjs` (or `npm test -- tests/foo.test.mjs`) |
|
|
59
|
+
| **Pantheon Engine** | `src/pantheon/<module>.ts` | `npx tsx tests/pantheon/<module>.test.ts` or `npm run test:quick` |
|
|
28
60
|
| **Vitest** | `src/components/Button.tsx` | `npx vitest run src/components/Button.test.tsx` |
|
|
29
61
|
| **Jest** | `src/utils/calc.ts` | `npx jest src/utils/calc.test.ts` |
|
|
30
62
|
| **Pytest** | `src/service/auth.py` | `pytest tests/test_auth.py -k <test_func>` |
|
|
@@ -34,21 +66,18 @@ description: "Targeted test execution — map changed files directly to their na
|
|
|
34
66
|
|
|
35
67
|
## Lint-First Fast Gate (< 50ms)
|
|
36
68
|
|
|
37
|
-
Before launching the test runner
|
|
69
|
+
Before launching the test runner, run a static syntax/linter check on the modified file:
|
|
38
70
|
- **Python:** `ruff check <file>` (~20ms)
|
|
39
71
|
- **TypeScript / JavaScript:** `npx biome check <file>` (~30ms) or `tsc --noEmit`
|
|
40
72
|
|
|
41
|
-
Catching syntax errors, missing imports, and broken brackets at the lint gate saves
|
|
73
|
+
Catching syntax errors, missing imports, and broken brackets at the lint gate saves test loop latency and avoids test runner crashes.
|
|
42
74
|
|
|
43
75
|
---
|
|
44
76
|
|
|
45
77
|
## Execution Guardrails
|
|
46
78
|
|
|
47
79
|
1. **Timeout Budget:** A sliced check must complete in < 10 seconds. If a test hangs or takes > 30s, abort immediately and check background task/locks.
|
|
48
|
-
2. **Failure Isolation:**
|
|
49
|
-
- Read the exact assertion failure and stack trace.
|
|
50
|
-
- Do NOT run unrelated test suites hoping for clues.
|
|
51
|
-
- Fix the targeted failure and re-run only the failing slice.
|
|
80
|
+
2. **Failure Isolation:** Read the exact assertion failure and stack trace. Do NOT run unrelated test suites hoping for clues.
|
|
52
81
|
3. **No Flaky Re-runs:** Do not blindly re-run the same failing test in a loop without inspecting code or diffs.
|
|
53
82
|
4. **Token Economy:** Pass flags that suppress noise:
|
|
54
83
|
- Node: `node --test tests/foo.test.mjs` (clean output).
|