pantheon-opencode 2.1.2 → 2.1.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.
Files changed (42) hide show
  1. package/AGENTS.global.md +7 -7
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +77 -0
  4. package/README.md +10 -0
  5. package/package.json +7 -4
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/build-plugin.mjs +35 -9
  9. package/scripts/build-roster.mjs +139 -0
  10. package/scripts/doctor.mjs +111 -2
  11. package/scripts/install/opencode.mjs +16 -0
  12. package/scripts/sync-tui.mjs +2 -0
  13. package/scripts/test-slice.mjs +352 -0
  14. package/skills-lock.json +1 -1
  15. package/src/agents/aphrodite.md +8 -6
  16. package/src/agents/apollo.md +9 -7
  17. package/src/agents/athena.md +21 -18
  18. package/src/agents/demeter.md +7 -5
  19. package/src/agents/gaia.md +7 -8
  20. package/src/agents/hephaestus.md +7 -5
  21. package/src/agents/hermes.md +20 -16
  22. package/src/agents/iris.md +10 -8
  23. package/src/agents/mnemosyne.md +17 -19
  24. package/src/agents/nyx.md +7 -5
  25. package/src/agents/prometheus.md +7 -5
  26. package/src/agents/talos.md +11 -5
  27. package/src/agents/themis.md +11 -4
  28. package/src/agents/zeus.md +23 -2
  29. package/src/instructions/agent-return-format.instructions.md +1 -1
  30. package/src/instructions/test-economy.instructions.md +6 -6
  31. package/src/mcp/pantheon_vision.py +24 -0
  32. package/src/pantheon/auto-permissions.ts +328 -0
  33. package/src/pantheon/deepwork/deepwork-tool.ts +14 -0
  34. package/src/pantheon/delegation-enforce.ts +43 -12
  35. package/src/pantheon/native-vision.ts +54 -2
  36. package/src/pantheon/tools.ts +102 -3
  37. package/src/plugin/index.js +342 -16
  38. package/src/plugin.ts +7 -0
  39. package/src/plugins/tui/dist/tui.js +5 -5
  40. package/src/plugins/tui/package-lock.json +2 -2
  41. package/src/plugins/tui/package.json +1 -1
  42. package/src/skills/test-slicing/SKILL.md +44 -15
@@ -12,6 +12,188 @@ 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 isExcludedReadPath(rawPath) {
57
+ const trimmed = rawPath.trim();
58
+ if (!trimmed) return false;
59
+ const normalized = trimmed.replace(/\\/g, "/");
60
+ if (normalized.startsWith("../") || normalized === ".." || normalized.includes("/../")) {
61
+ return true;
62
+ }
63
+ if (/^\/(etc|boot|sys|proc|root)(\/|$)/.test(normalized)) {
64
+ return true;
65
+ }
66
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ function autoPermissionsEnabled(env = process.env) {
72
+ const val = (env.PANTHEON_AUTO_PERMISSIONS ?? "").trim().toLowerCase();
73
+ return val !== "off" && val !== "0" && val !== "false";
74
+ }
75
+ function isDangerousCommand(command) {
76
+ const trimmed = command.trim();
77
+ if (!trimmed) return false;
78
+ if (/\bsudo\b/.test(trimmed)) return true;
79
+ 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(
80
+ trimmed
81
+ ))
82
+ return true;
83
+ if (/(curl|wget)\b.*\|\s*(ba)?sh\b/.test(trimmed)) return true;
84
+ if (/\bmkfs(\.[a-z0-9]+)?\b/.test(trimmed)) return true;
85
+ if (/\bdd\s+if=/.test(trimmed)) return true;
86
+ if (/\bchmod\s+(-[a-zA-Z]*R[a-zA-Z]*\s+)?777\s+\//.test(trimmed)) return true;
87
+ if (/\b(>\s*|\bcp\b.*|\bmv\b.*)\s+\/(etc|boot|sys|proc|root|usr)(\/|$)/.test(trimmed)) return true;
88
+ return false;
89
+ }
90
+ function isSafeDevCommand(command) {
91
+ const trimmed = command.trim();
92
+ if (!trimmed) return false;
93
+ if (isDangerousCommand(trimmed)) return false;
94
+ const segments = trimmed.split(/[|&;]/);
95
+ for (const rawSeg of segments) {
96
+ const seg = rawSeg.trim();
97
+ if (!seg) continue;
98
+ const tokens = seg.split(/\s+/).filter(Boolean);
99
+ let binary = tokens[0] ?? "";
100
+ let tokenIdx = 0;
101
+ while (binary.includes("=") && tokenIdx < tokens.length - 1) {
102
+ tokenIdx += 1;
103
+ binary = tokens[tokenIdx] ?? "";
104
+ }
105
+ const cleanBinary = binary.replace(/^.*\//, "");
106
+ if (!SAFE_DEV_BINARIES.has(cleanBinary)) {
107
+ return false;
108
+ }
109
+ }
110
+ return true;
111
+ }
112
+ function isUnconstrainedTestSuite(command) {
113
+ const trimmed = command.trim();
114
+ if (!trimmed) return false;
115
+ if (/^(npm|pnpm|yarn|bun)\s+(run\s+)?(test|test:all)(\s+--)?\s*$/.test(trimmed)) {
116
+ return true;
117
+ }
118
+ if (/^(python3?\s+-m\s+)?pytest\s*$/.test(trimmed)) {
119
+ return true;
120
+ }
121
+ if (/^(npx\s+)?(vitest|jest)(\s+run)?\s*$/.test(trimmed)) {
122
+ return true;
123
+ }
124
+ if (/^cargo\s+test\s*$/.test(trimmed)) {
125
+ return true;
126
+ }
127
+ return false;
128
+ }
129
+ function evaluateAutoPermission(event, options = {}) {
130
+ const env = options.env ?? process.env;
131
+ if (!autoPermissionsEnabled(env)) {
132
+ return { decision: "disabled" };
133
+ }
134
+ if (event.effect === "deny") {
135
+ return { decision: "preserve-deny" };
136
+ }
137
+ if (event.effect === "allow") {
138
+ return { decision: "preserve-allow" };
139
+ }
140
+ const action = String(event.action ?? "").toLowerCase().trim();
141
+ const agent = String(event.agent ?? "").toLowerCase().trim();
142
+ if (action === "todowrite" || action === "todoread" || action === "pantheon_deepwork" || action.startsWith("pantheon_")) {
143
+ event.effect = "allow";
144
+ return { decision: "allow", reason: "pantheon-native-tool" };
145
+ }
146
+ if (READ_ONLY_AGENTS.has(agent)) {
147
+ if (["edit", "write", "hashline_edit", "bash", "shell"].includes(action)) {
148
+ event.effect = "deny";
149
+ event.message = `Pantheon auto-permissions denied: read-only agent '${agent}' cannot execute mutating action '${action}'`;
150
+ return { decision: "deny", reason: "read-only-role-violation" };
151
+ }
152
+ }
153
+ if (["read", "glob", "grep", "webfetch", "question"].includes(action)) {
154
+ const firstResource = Array.isArray(event.resources) && typeof event.resources[0] === "string" ? event.resources[0] : "";
155
+ if (firstResource.startsWith("http://") || firstResource.startsWith("https://")) {
156
+ return { decision: "passthrough" };
157
+ }
158
+ if (firstResource && isExcludedReadPath(firstResource)) {
159
+ event.effect = "deny";
160
+ event.message = `Pantheon auto-permissions denied: reading '${firstResource}' is prohibited (.git and node_modules are excluded)`;
161
+ return { decision: "deny", reason: "excluded-path" };
162
+ }
163
+ event.effect = "allow";
164
+ return { decision: "allow", reason: "safe-read-action" };
165
+ }
166
+ if (action === "bash" || action === "shell") {
167
+ const rawCmd = Array.isArray(event.resources) && typeof event.resources[0] === "string" ? event.resources[0] : "";
168
+ if (rawCmd) {
169
+ if (isDangerousCommand(rawCmd)) {
170
+ event.effect = "deny";
171
+ event.message = "Pantheon auto-permissions denied: destructive or privilege-escalating command";
172
+ return { decision: "deny", reason: "dangerous-command" };
173
+ }
174
+ if (isUnconstrainedTestSuite(rawCmd)) {
175
+ event.effect = "ask";
176
+ event.message = "Pantheon test-economy: unconstrained test suite detected in dev loop. Use a focused test slice (sub-10s) or provide scope justification.";
177
+ return {
178
+ decision: "unconstrained-suite",
179
+ reason: "unconstrained-test-suite-forbidden-in-dev-loop"
180
+ };
181
+ }
182
+ if (isSafeDevCommand(rawCmd)) {
183
+ event.effect = "allow";
184
+ return { decision: "allow", reason: "safe-dev-command" };
185
+ }
186
+ }
187
+ }
188
+ if (["edit", "write", "hashline_edit"].includes(action)) {
189
+ if (!READ_ONLY_AGENTS.has(agent)) {
190
+ event.effect = "allow";
191
+ return { decision: "allow", reason: "implementer-workspace-edit" };
192
+ }
193
+ }
194
+ return { decision: "passthrough" };
195
+ }
196
+
15
197
  // src/pantheon/behavior-overrides.ts
16
198
  var OVERRIDE_CONTENT_MAX = 8e3;
17
199
  var OVERRIDE_REASON_MAX = 200;
@@ -3693,6 +3875,7 @@ var DEFAULT_BLOCKED_TOOLS = /* @__PURE__ */ new Set([
3693
3875
  "edit",
3694
3876
  "write",
3695
3877
  "bash",
3878
+ "shell",
3696
3879
  "task",
3697
3880
  "hashline_edit",
3698
3881
  // `pantheon_model` writes active-preset.json in BOTH the project and the
@@ -3703,7 +3886,13 @@ var DEFAULT_BLOCKED_TOOLS = /* @__PURE__ */ new Set([
3703
3886
  // opencode.db.
3704
3887
  "pantheon_model"
3705
3888
  ]);
3706
- var ZEUS_READ_DENY_PATTERNS = [/^src\//, /^tests?\//, /^scripts?\//];
3889
+ var ZEUS_READ_DENY_PATTERNS = [
3890
+ /^src\//,
3891
+ /^tests?\//,
3892
+ /^scripts?\//,
3893
+ /(^|\/)\.git(\/|$)/,
3894
+ /(^|\/)node_modules(\/|$)/
3895
+ ];
3707
3896
  function normalizeGuardPath(value) {
3708
3897
  let normalized = value.replace(/\\/g, "/");
3709
3898
  while (normalized.startsWith("./")) normalized = normalized.slice(2);
@@ -3734,8 +3923,22 @@ function isDeniedReadPath(candidate, target) {
3734
3923
  }
3735
3924
  return false;
3736
3925
  }
3737
- function hasGlobMeta(value) {
3738
- return ["*", "?", "[", "]", "{", "}", "(", ")"].some((meta) => value.includes(meta));
3926
+ 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;
3927
+ function isDeniedGlobPattern(pattern) {
3928
+ const normalized = normalizeGuardPath(pattern);
3929
+ if (normalized.startsWith("../") || normalized === ".." || normalized.includes("/../")) {
3930
+ return true;
3931
+ }
3932
+ if (/(^|\/)(\.git|node_modules)(\/|$)/.test(normalized)) {
3933
+ return true;
3934
+ }
3935
+ if (isDeniedReadPath(normalized, true)) {
3936
+ return true;
3937
+ }
3938
+ if (CODE_FILE_EXTENSIONS.test(normalized)) {
3939
+ return true;
3940
+ }
3941
+ return false;
3739
3942
  }
3740
3943
  function zeusReadGuard(tool2, args, agent, resolvePath) {
3741
3944
  if (agent !== "zeus") return;
@@ -3770,7 +3973,7 @@ function zeusReadGuard(tool2, args, agent, resolvePath) {
3770
3973
  if (tool2 === "grep" && candidate.target) deny();
3771
3974
  continue;
3772
3975
  }
3773
- if (tool2 === "glob" && candidate.target && hasGlobMeta(effectivePath)) deny();
3976
+ if (tool2 === "glob" && candidate.target && isDeniedGlobPattern(effectivePath)) deny();
3774
3977
  if (isDeniedReadPath(effectivePath, candidate.target)) deny();
3775
3978
  }
3776
3979
  }
@@ -3804,8 +4007,8 @@ var ReadOnlySessionRegistry = class {
3804
4007
  }
3805
4008
  };
3806
4009
  var readOnlyRegistry = new ReadOnlySessionRegistry();
3807
- var READ_ONLY_AGENTS = /* @__PURE__ */ new Set(["apollo", "gaia"]);
3808
- function syncReadOnlySession(registry, sessionID, agent, readOnlyAgents = READ_ONLY_AGENTS) {
4010
+ var READ_ONLY_AGENTS2 = /* @__PURE__ */ new Set(["apollo", "gaia"]);
4011
+ function syncReadOnlySession(registry, sessionID, agent, readOnlyAgents = READ_ONLY_AGENTS2) {
3809
4012
  const normalized = normalizeDelegationAgent(agent);
3810
4013
  if (normalized === void 0 || !readOnlyAgents.has(normalized)) {
3811
4014
  registry.unregister(sessionID);
@@ -8063,6 +8266,7 @@ function createJ3EscalationObserver(options) {
8063
8266
 
8064
8267
  // src/pantheon/native-vision.ts
8065
8268
  import { lookup as dnsLookup } from "node:dns/promises";
8269
+ import { existsSync as existsSync4 } from "node:fs";
8066
8270
  import { readFile as readFile4 } from "node:fs/promises";
8067
8271
  import { request as httpRequest } from "node:http";
8068
8272
  import { request as httpsRequest } from "node:https";
@@ -9033,6 +9237,33 @@ async function imageAttachment(value, directory, signal) {
9033
9237
  }
9034
9238
  return toImageAttachment(bytes, localPath.split(/[\\/]/).at(-1) || "image");
9035
9239
  }
9240
+ function discoverActiveSessionId(directory) {
9241
+ for (const envVar of ["OPENCODE_SESSION_ID", "SESSION_ID"]) {
9242
+ const val = (process.env[envVar] ?? "").trim();
9243
+ if (isValidSessionId(val)) return val;
9244
+ }
9245
+ try {
9246
+ const dataHome = process.env.XDG_DATA_HOME || join10(homedir4(), ".local", "share");
9247
+ const dbPath = process.env.OPENCODE_DB || join10(dataHome, "opencode", "opencode.db");
9248
+ if (!existsSync4(dbPath)) return void 0;
9249
+ const sqlite = __require("node:sqlite");
9250
+ const db = new sqlite.DatabaseSync(dbPath, { readOnly: true });
9251
+ try {
9252
+ if (directory) {
9253
+ const row = db.prepare(
9254
+ "SELECT id FROM session_v2 WHERE directory = ? ORDER BY time_created DESC LIMIT 1"
9255
+ ).get(directory);
9256
+ if (row && isValidSessionId(row.id)) return String(row.id);
9257
+ }
9258
+ const fallbackRow = db.prepare("SELECT id FROM session_v2 ORDER BY time_created DESC LIMIT 1").get();
9259
+ if (fallbackRow && isValidSessionId(fallbackRow.id)) return String(fallbackRow.id);
9260
+ } finally {
9261
+ db.close();
9262
+ }
9263
+ } catch {
9264
+ }
9265
+ return void 0;
9266
+ }
9036
9267
  function createV2VisionTool(runtime) {
9037
9268
  return {
9038
9269
  name: "vision_describe",
@@ -9055,7 +9286,11 @@ function createV2VisionTool(runtime) {
9055
9286
  let stage = "validate OpenCode session";
9056
9287
  try {
9057
9288
  const call = asRecord2(rawContext) ?? {};
9058
- if (!isValidSessionId(call.sessionID)) {
9289
+ let sessionID = isValidSessionId(call.sessionID) ? call.sessionID : void 0;
9290
+ if (!sessionID) {
9291
+ sessionID = discoverActiveSessionId(call.directory || process.cwd());
9292
+ }
9293
+ if (!sessionID) {
9059
9294
  throw new Error(
9060
9295
  "a valid OpenCode session id is required; retry this tool from an active OpenCode session"
9061
9296
  );
@@ -9094,7 +9329,7 @@ function createV2VisionTool(runtime) {
9094
9329
  stage = "send image to the selected multimodal model";
9095
9330
  const requestTarget = {
9096
9331
  ...target,
9097
- sessionID: call.sessionID
9332
+ sessionID
9098
9333
  };
9099
9334
  let failure;
9100
9335
  const output = await describeImagesNative(
@@ -10558,9 +10793,13 @@ var TodoEnforcer = class {
10558
10793
  }
10559
10794
  };
10560
10795
 
10796
+ // src/pantheon/tools.ts
10797
+ import { exec } from "node:child_process";
10798
+ import { promisify } from "node:util";
10799
+
10561
10800
  // src/pantheon/cost-command.ts
10562
10801
  import { execFile } from "node:child_process";
10563
- import { accessSync, constants as constants3, existsSync as existsSync5, statSync as statSync3 } from "node:fs";
10802
+ import { accessSync, constants as constants3, existsSync as existsSync6, statSync as statSync3 } from "node:fs";
10564
10803
  import { delimiter, dirname as dirname8, join as join14 } from "node:path";
10565
10804
  import { fileURLToPath as fileURLToPath4 } from "node:url";
10566
10805
  import { z } from "zod";
@@ -10570,7 +10809,7 @@ import { homedir as homedir6 } from "node:os";
10570
10809
  import { join as join13 } from "node:path";
10571
10810
 
10572
10811
  // src/plugins/tui/src/model-pricing.ts
10573
- import { existsSync as existsSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
10812
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, writeFileSync as writeFileSync4 } from "node:fs";
10574
10813
  import { homedir as homedir5 } from "node:os";
10575
10814
  import { dirname as dirname7, join as join12 } from "node:path";
10576
10815
  var MODELS_DEV_URL = "https://models.dev/api.json";
@@ -10716,7 +10955,7 @@ function parseCachedCatalog(raw) {
10716
10955
  }
10717
10956
  function readPricingCache(cachePath) {
10718
10957
  try {
10719
- if (!existsSync4(cachePath)) return void 0;
10958
+ if (!existsSync5(cachePath)) return void 0;
10720
10959
  return parseCachedCatalog(JSON.parse(readFileSync6(cachePath, "utf8")));
10721
10960
  } catch {
10722
10961
  return void 0;
@@ -10947,7 +11186,7 @@ var costArgs = {
10947
11186
  };
10948
11187
  function findExistingDb(override) {
10949
11188
  const candidate = override === void 0 ? resolveCostDbPath() : resolveCostDbPath({ dbPath: override });
10950
- return existsSync5(candidate) ? candidate : void 0;
11189
+ return existsSync6(candidate) ? candidate : void 0;
10951
11190
  }
10952
11191
  var COST_AGGREGATE_SQL = {
10953
11192
  message: (sessionId) => `
@@ -11656,7 +11895,7 @@ async function queryWithCliFallback(dbPath, days, deps) {
11656
11895
  const execFileAsync = deps?.execFile ?? defaultExecFile;
11657
11896
  const isExecutable = deps?.isExecutable ?? defaultIsExecutable;
11658
11897
  const costScript = join14(__dirname, "..", "..", "scripts", "cost.mjs");
11659
- if (!existsSync5(costScript)) {
11898
+ if (!existsSync6(costScript)) {
11660
11899
  throw new Error(`CLI fallback script not found: ${costScript}`);
11661
11900
  }
11662
11901
  const node = resolveNodeExecutable(env, isExecutable);
@@ -11982,7 +12221,7 @@ function buildApprovalQuestion(plan) {
11982
12221
  }
11983
12222
 
11984
12223
  // src/pantheon/deepwork/plan-tracker.ts
11985
- import { existsSync as existsSync6 } from "node:fs";
12224
+ import { existsSync as existsSync7 } from "node:fs";
11986
12225
  import { appendFile as appendFile3, mkdir as mkdir6, readdir, readFile as readFile6, rename as rename5, writeFile as writeFile3 } from "node:fs/promises";
11987
12226
  import { join as join16 } from "node:path";
11988
12227
 
@@ -12215,7 +12454,7 @@ async function resolvePlanDecision(cwd = process.cwd(), slug, decisionId, chosen
12215
12454
  }
12216
12455
  async function listPlans(cwd = process.cwd()) {
12217
12456
  const root = deepworkRootDir(cwd);
12218
- if (!existsSync6(root)) return [];
12457
+ if (!existsSync7(root)) return [];
12219
12458
  const entries = await readdir(root, { withFileTypes: true });
12220
12459
  const result = [];
12221
12460
  for (const entry of entries) {
@@ -12425,6 +12664,12 @@ function createDeepworkTool(cwd = process.cwd()) {
12425
12664
  });
12426
12665
  const projection = generateChatProjection(initialPlan, effectiveCwd);
12427
12666
  const approvalQ = buildApprovalQuestion(initialPlan);
12667
+ const todoPayload = {
12668
+ todos: tasks.map((t) => ({
12669
+ content: `[${t.id}] ${t.title}`,
12670
+ status: t.state === "done" ? "completed" : t.state === "in_progress" ? "in_progress" : "pending"
12671
+ }))
12672
+ };
12428
12673
  return {
12429
12674
  output: [
12430
12675
  `\u2705 Plano de Deepwork '${title}' inicializado com sucesso em \`.pantheon/deepwork/${slug}/\`!`,
@@ -12432,6 +12677,11 @@ function createDeepworkTool(cwd = process.cwd()) {
12432
12677
  `- \u{1F517} **Deeplink plan.json:** [Abrir plan.json](file://${deepworkPlanJsonPath(effectiveCwd, slug)})`,
12433
12678
  "",
12434
12679
  projection,
12680
+ "",
12681
+ "**TUI Todo Sync:** Espelhe as tarefas chamando `todowrite` com:",
12682
+ `\`\`\`json
12683
+ ${JSON.stringify(todoPayload, null, 2)}
12684
+ \`\`\``,
12435
12685
  "",
12436
12686
  "**Pergunta de Aprova\xE7\xE3o Nativa (Gate 1):**",
12437
12687
  `\`${JSON.stringify(approvalQ)}\``
@@ -14142,16 +14392,87 @@ var TODOWRITE_INPUT = {
14142
14392
  }
14143
14393
  }
14144
14394
  };
14395
+ var latestSessionTodos = [];
14145
14396
  var todowriteTool = {
14146
14397
  name: "todowrite",
14147
14398
  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
14399
  input: TODOWRITE_INPUT,
14149
14400
  output: {},
14150
14401
  execute: async (input) => {
14151
- const todos = Array.isArray(input.todos) ? input.todos : [];
14402
+ const rawTodos = input.todos;
14403
+ const todos = Array.isArray(rawTodos) ? rawTodos : [];
14404
+ latestSessionTodos = todos;
14152
14405
  return { ok: true, todos, output: JSON.stringify({ todos }) };
14153
14406
  }
14154
14407
  };
14408
+ var TODOREAD_INPUT = {
14409
+ type: "object",
14410
+ additionalProperties: false,
14411
+ properties: {
14412
+ status: {
14413
+ type: "string",
14414
+ description: "Optional filter by task status (pending, in_progress, completed, cancelled)"
14415
+ }
14416
+ }
14417
+ };
14418
+ var todoreadTool = {
14419
+ name: "todoread",
14420
+ description: "Read the active session task checklist. Returns the newest list of tasks written via todowrite.",
14421
+ input: TODOREAD_INPUT,
14422
+ output: {},
14423
+ execute: async (input) => {
14424
+ const statusFilter = input?.status;
14425
+ let todos = latestSessionTodos;
14426
+ if (typeof statusFilter === "string" && statusFilter.trim() !== "") {
14427
+ todos = todos.filter(
14428
+ (t) => typeof t === "object" && t !== null && t.status === statusFilter
14429
+ );
14430
+ }
14431
+ return {
14432
+ ok: true,
14433
+ todos,
14434
+ output: JSON.stringify({ todos })
14435
+ };
14436
+ }
14437
+ };
14438
+ var execAsync = promisify(exec);
14439
+ var SHELL_INPUT = {
14440
+ type: "object",
14441
+ required: ["command"],
14442
+ properties: {
14443
+ command: {
14444
+ type: "string",
14445
+ description: "The shell command to execute in the workspace directory"
14446
+ }
14447
+ }
14448
+ };
14449
+ var shellTool = {
14450
+ name: "shell",
14451
+ description: "Execute a shell command in the workspace directory. Alias for bash execution.",
14452
+ input: SHELL_INPUT,
14453
+ output: {},
14454
+ execute: async (input, context) => {
14455
+ const command = String(input.command ?? "");
14456
+ if (!command.trim()) {
14457
+ return { output: "", ok: false, error: "Command cannot be empty" };
14458
+ }
14459
+ const toolCtx = toolContext(context);
14460
+ const cwd = toolCtx.directory || process.cwd();
14461
+ try {
14462
+ const { stdout, stderr } = await execAsync(command, {
14463
+ cwd,
14464
+ maxBuffer: 10 * 1024 * 1024,
14465
+ shell: "/bin/bash"
14466
+ });
14467
+ const output = [stdout, stderr].filter(Boolean).join("\n");
14468
+ return { output, ok: true };
14469
+ } catch (err) {
14470
+ const execError = err;
14471
+ const output = [execError.stdout, execError.stderr, execError.message].filter(Boolean).join("\n");
14472
+ return { output, ok: false, error: output };
14473
+ }
14474
+ }
14475
+ };
14155
14476
  function createV2ToolDefinitions(visionRuntime, shadow = {}, jevRuntime) {
14156
14477
  const definitions = [
14157
14478
  {
@@ -14182,6 +14503,8 @@ function createV2ToolDefinitions(visionRuntime, shadow = {}, jevRuntime) {
14182
14503
  })
14183
14504
  );
14184
14505
  definitions.push(todowriteTool);
14506
+ definitions.push(todoreadTool);
14507
+ definitions.push(shellTool);
14185
14508
  definitions.push(createV2SkillSearchDefinition());
14186
14509
  definitions.push(createDeepworkTool());
14187
14510
  if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime));
@@ -15260,6 +15583,9 @@ async function registerV2PermissionHook(context, subagentOrigins) {
15260
15583
  deny("caller or target is not allowed by delegation policy");
15261
15584
  return;
15262
15585
  }
15586
+ if (event.effect !== "deny") {
15587
+ evaluateAutoPermission(event, { cwd: domains.location?.directory || process.cwd() });
15588
+ }
15263
15589
  writeProof();
15264
15590
  recordP8(p8Result, event);
15265
15591
  });
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.2";
2065
+ return "2.1.4";
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.2";
2290
+ return "2.1.4";
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.2",
6516
+ currentVersion: "2.1.4",
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.2`);
7328
+ insert(_el$13, `Pantheon v2.1.4`);
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.2${preset().name ? ` ▸ ${preset().name}` : ""}`);
8100
+ insert(_el$73, () => `Pantheon v2.1.4${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.2",
3
+ "version": "2.1.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pantheon-tui",
9
- "version": "2.1.2",
9
+ "version": "2.1.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@opencode/plugin": "2.0.26",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
3
  "type": "module",
4
- "version": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "description": "Pantheon TUI plugin \u2014 V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
6
6
  "license": "MIT",
7
7
  "engines": {