opencode-agent-plus 0.2.0 → 0.3.0

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/README.md CHANGED
@@ -12,7 +12,7 @@ with `shell: ask` in your permissions you get no prompt window for them — ever
12
12
  OpenCode v2 drops request settings such as `temperature` for OpenAI-compatible providers, and has no per-agent
13
13
  reminder. agent-plus reads extra keys from the agent's `.md` file and applies them to every model request.
14
14
 
15
- Tested with OpenCode 2.0.28 and llama.cpp behind LiteLLM.
15
+ Tested with OpenCode 2.2.0 and llama.cpp behind LiteLLM.
16
16
 
17
17
  ![agent-plus settings in the OpenCode sidebar](screenshot.png)
18
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-plus",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "OpenCode plugin: safe-command auto-allow (no prompt for read-only calls), per-agent chat_template_kwargs (enable_thinking), sampling settings and system reminders from agent frontmatter. For llama.cpp, LiteLLM and OpenAI-compatible providers.",
5
5
  "license": "MIT",
6
6
  "author": "Anoosh Ahmadi",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "files": ["src"],
24
24
  "peerDependencies": {
25
- "@opentui/core": ">=0.5.8",
26
- "@opentui/solid": ">=0.5.8",
25
+ "@opentui/core": ">=0.7.0",
26
+ "@opentui/solid": ">=0.7.0",
27
27
  "solid-js": ">=1.9.0"
28
28
  }
29
29
  }
@@ -13,7 +13,24 @@ export const BODY = [
13
13
  "top_k",
14
14
  "min_p",
15
15
  "presence_penalty",
16
+ "frequency_penalty",
17
+ "repetition_penalty",
16
18
  "repeat_penalty",
19
+ "repeat_last_n",
20
+ "penalty_last_n",
21
+ "dry_multiplier",
22
+ "dry_allowed_length",
23
+ "dry_penalty_last_n",
24
+ "dry_base",
25
+ "mirostat",
26
+ "mirostat_tau",
27
+ "mirostat_eta",
28
+ "typical_p",
29
+ "xtc_threshold",
30
+ "xtc_probability",
31
+ "min_keep",
32
+ "ignore_eos",
33
+ "seed",
17
34
  "max_completion_tokens",
18
35
  "reasoning_budget_tokens",
19
36
  "reasoning_effort",
package/src/index.ts CHANGED
@@ -60,9 +60,23 @@ export default {
60
60
  // Safe-command auto-allow is on for every agent; an agent turns it off with `safe_commands: none`.
61
61
  // It skips the ask window for read-only tool calls and safe shell commands.
62
62
  // Configured `deny` rules are final and never reach this hook; anything unsafe passes through unchanged.
63
+ // `max_same_tool: n` additionally denies a tool after n calls in one session.
64
+ const toolCalls = new Map<string, number>()
63
65
  await ctx.permission.hook("evaluate", async (event: any) => {
64
- if (event.effect !== "ask" || !event.agent) return
66
+ if (!event.agent) return
65
67
  const { keys } = await settings(event.agent)
68
+ const max = Number(keys.max_same_tool)
69
+ if (Number.isInteger(max) && max >= 1 && event.action !== "task") {
70
+ const id = `${event.sessionID}/${event.action}`
71
+ const count = (toolCalls.get(id) ?? 0) + 1
72
+ toolCalls.set(id, count)
73
+ if (count > max) {
74
+ event.effect = "deny"
75
+ event.message = `You already used '${event.action}' more than the maximum allowed ${max} times. You are probably stuck in a doom loop. Try something else or report the issue to user.`
76
+ return
77
+ }
78
+ }
79
+ if (event.effect !== "ask") return
66
80
  if (keys.safe_commands === "none") return
67
81
  if (isSafe(event.action, event.resources ?? [])) event.effect = "allow"
68
82
  })