opencode-agent-plus 0.2.1 → 0.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-agent-plus",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
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",
@@ -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,24 @@ 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` denies a tool after n calls in a row without another tool in between.
64
+ // Varied work resets the count; only a streak trips it.
65
+ const streaks = new Map<string, { action: string; count: number }>()
63
66
  await ctx.permission.hook("evaluate", async (event: any) => {
64
- if (event.effect !== "ask" || !event.agent) return
67
+ if (!event.agent) return
65
68
  const { keys } = await settings(event.agent)
69
+ const max = Number(keys.max_same_tool)
70
+ if (Number.isInteger(max) && max >= 1 && event.action !== "task") {
71
+ const prev = streaks.get(event.sessionID)
72
+ const count = prev && prev.action === event.action ? prev.count + 1 : 1
73
+ streaks.set(event.sessionID, { action: event.action, count })
74
+ if (count > max) {
75
+ event.effect = "deny"
76
+ event.message = `You already used '${event.action}' more than the maximum allowed ${max} times in a row. You are probably stuck in a doom loop. Try something else or report the issue to user.`
77
+ return
78
+ }
79
+ }
80
+ if (event.effect !== "ask") return
66
81
  if (keys.safe_commands === "none") return
67
82
  if (isSafe(event.action, event.resources ?? [])) event.effect = "allow"
68
83
  })