@noppu-labs/opencode-permission-reviewer 3.2.3 → 3.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.
@@ -0,0 +1,44 @@
1
+ // Generated by `bun scripts/generate-east-asian-wide.ts` from
2
+ // get-east-asian-width 1.6.0. Do not edit by hand.
3
+ // Packed as hex "from-to" pairs because a literal array of tuples exceeds the FTA cap.
4
+
5
+ const PACKED: string = [
6
+ "1100-115f 231a-231b 2329-232a 23e9-23ec 23f0-23f0 23f3-23f3 25fd-25fe 2614-2615",
7
+ "2630-2637 2648-2653 267f-267f 268a-268f 2693-2693 26a1-26a1 26aa-26ab 26bd-26be",
8
+ "26c4-26c5 26ce-26ce 26d4-26d4 26ea-26ea 26f2-26f3 26f5-26f5 26fa-26fa 26fd-26fd",
9
+ "2705-2705 270a-270b 2728-2728 274c-274c 274e-274e 2753-2755 2757-2757 2795-2797",
10
+ "27b0-27b0 27bf-27bf 2b1b-2b1c 2b50-2b50 2b55-2b55 2e80-2e99 2e9b-2ef3 2f00-2fd5",
11
+ "2ff0-303e 3041-3096 3099-30ff 3105-312f 3131-318e 3190-31e5 31ef-321e 3220-3247",
12
+ "3250-a48c a490-a4c6 a960-a97c ac00-d7a3 f900-faff fe10-fe19 fe30-fe52 fe54-fe66",
13
+ "fe68-fe6b ff01-ff60 ffe0-ffe6 16fe0-16fe4 16ff0-16ff6 17000-18cd5 18cff-18d1e 18d80-18df2",
14
+ "1aff0-1aff3 1aff5-1affb 1affd-1affe 1b000-1b122 1b132-1b132 1b150-1b152 1b155-1b155 1b164-1b167",
15
+ "1b170-1b2fb 1d300-1d356 1d360-1d376 1f004-1f004 1f0cf-1f0cf 1f18e-1f18e 1f191-1f19a 1f200-1f202",
16
+ "1f210-1f23b 1f240-1f248 1f250-1f251 1f260-1f265 1f300-1f320 1f32d-1f335 1f337-1f37c 1f37e-1f393",
17
+ "1f3a0-1f3ca 1f3cf-1f3d3 1f3e0-1f3f0 1f3f4-1f3f4 1f3f8-1f43e 1f440-1f440 1f442-1f4fc 1f4ff-1f53d",
18
+ "1f54b-1f54e 1f550-1f567 1f57a-1f57a 1f595-1f596 1f5a4-1f5a4 1f5fb-1f64f 1f680-1f6c5 1f6cc-1f6cc",
19
+ "1f6d0-1f6d2 1f6d5-1f6d8 1f6dc-1f6df 1f6eb-1f6ec 1f6f4-1f6fc 1f7e0-1f7eb 1f7f0-1f7f0 1f90c-1f93a",
20
+ "1f93c-1f945 1f947-1f9ff 1fa70-1fa7c 1fa80-1fa8a 1fa8e-1fac6 1fac8-1fac8 1facd-1fadc 1fadf-1faea",
21
+ "1faef-1faf8 20000-2fffd 30000-3fffd",
22
+ ].join(" ");
23
+
24
+ /** Inclusive code point ranges with East Asian Width Wide or Fullwidth. */
25
+ export const EAST_ASIAN_WIDE: readonly (readonly [number, number])[] =
26
+ PACKED.split(" ").map((pair): readonly [number, number] => {
27
+ const [from = "", to = ""] = pair.split("-");
28
+ return [Number.parseInt(from, 16), Number.parseInt(to, 16)];
29
+ });
30
+
31
+ /** True when the terminal draws `code` in two columns. */
32
+ export function isEastAsianWide(code: number): boolean {
33
+ let low = 0;
34
+ let high = EAST_ASIAN_WIDE.length - 1;
35
+ while (low <= high) {
36
+ const middle = (low + high) >> 1;
37
+ const range = EAST_ASIAN_WIDE[middle];
38
+ if (range === undefined) return false;
39
+ if (code < range[0]) high = middle - 1;
40
+ else if (code > range[1]) low = middle + 1;
41
+ else return true;
42
+ }
43
+ return false;
44
+ }
@@ -1,7 +1,15 @@
1
1
  // Measuring, slicing and merging fitted action parts.
2
2
 
3
- import { LINE_BREAK } from "../modules/status/services/ui-text-elide.ts";
3
+ import {
4
+ ELISION,
5
+ elideMiddle,
6
+ keepHead,
7
+ keepTail,
8
+ LINE_BREAK,
9
+ } from "../modules/status/services/ui-text-elide.ts";
10
+ import { unitsColumns } from "../utils/text-units.ts";
4
11
  import type { ActionFitPart } from "./action-fit.ts";
12
+ import { columnUnits } from "./text-columns.ts";
5
13
 
6
14
  /** A part as the fit builds it; `whole` marks one a cut may not split. */
7
15
  export interface FitPart extends ActionFitPart {
@@ -10,9 +18,28 @@ export interface FitPart extends ActionFitPart {
10
18
 
11
19
  const STANDALONE_BREAK = new RegExp(`(?<!\\\\)${LINE_BREAK}`);
12
20
 
13
- /** Columns `text` takes, one per code point. */
21
+ /** Terminal columns `text` takes. */
14
22
  export function textColumns(text: string): number {
15
- return Array.from(text).length;
23
+ return unitsColumns(columnUnits(text));
24
+ }
25
+
26
+ export const fitHead = (text: string, max: number): string =>
27
+ keepHead(text, max, columnUnits);
28
+
29
+ export const fitTail = (text: string, max: number): string =>
30
+ keepTail(text, max, columnUnits);
31
+
32
+ /** `elideMiddle` by columns. When a wide character leaves no room for the
33
+ * tail, the tail is kept and the head gives way. */
34
+ export function fitMiddle(
35
+ text: string,
36
+ max: number,
37
+ ): ReturnType<typeof elideMiddle> {
38
+ const parts = elideMiddle(text, max, columnUnits);
39
+ if (parts === undefined || parts.tail !== "") return parts;
40
+ const budget = max - textColumns(ELISION);
41
+ const tail = fitTail(text, budget);
42
+ return { head: fitHead(text, budget - textColumns(tail)), tail };
16
43
  }
17
44
 
18
45
  export function partsColumns(parts: readonly FitPart[]): number {
@@ -53,8 +80,9 @@ export function merged(parts: readonly FitPart[]): ActionFitPart[] {
53
80
  return out;
54
81
  }
55
82
 
56
- /** The code points `start` to `end` of `parts`. A muted or `whole` part (a
57
- * heredoc marker or a separator) is kept whole or dropped, never cut. */
83
+ /** The columns `start` to `end` of `parts`; a wide character crossing either
84
+ * edge is dropped. A muted or `whole` part (a heredoc marker or a separator)
85
+ * is kept whole or dropped, never cut. */
58
86
  export function sliceParts(
59
87
  parts: readonly FitPart[],
60
88
  start: number,
@@ -63,11 +91,12 @@ export function sliceParts(
63
91
  const out: FitPart[] = [];
64
92
  let offset = 0;
65
93
  for (const part of parts) {
66
- const chars = Array.from(part.text);
67
- const from = Math.max(start - offset, 0);
68
- const to = Math.max(0, Math.min(end - offset, chars.length));
69
- offset += chars.length;
70
- const text = chars.slice(from, to).join("");
94
+ let text = "";
95
+ for (const unit of columnUnits(part.text)) {
96
+ const unitStart = offset;
97
+ offset += unit.columns;
98
+ if (unitStart >= start && offset <= end) text += unit.text;
99
+ }
71
100
  const cut = text.trim() !== part.text.trim();
72
101
  if (text === "" || ((part.muted || part.whole === true) && cut)) continue;
73
102
  out.push({ ...part, text });
@@ -54,14 +54,14 @@ function noTimeLeft(
54
54
  const parts = reason === undefined ? null : BUDGET_REASON.exec(reason);
55
55
  if (handoff !== undefined)
56
56
  return withReason(
57
- `${NO_TIME_LEAD} ${shortModelName(handoff.to) || GENERIC_REVIEWER} after Jev (${handoffCause(handoff)}).`,
57
+ `${NO_TIME_LEAD} ${shortModelName(handoff.to) || GENERIC_REVIEWER} after System One (${handoffCause(handoff)}).`,
58
58
  parts === null ? reason : parts[2],
59
59
  );
60
60
  if (reason === undefined)
61
- return `${NO_TIME_LEAD} ${GENERIC_REVIEWER} after Jev.`;
61
+ return `${NO_TIME_LEAD} ${GENERIC_REVIEWER} after System One.`;
62
62
  if (parts === null) return reason;
63
63
  const name = shortModelName(reviewer ?? "") || GENERIC_REVIEWER;
64
- return `${NO_TIME_LEAD} ${name} after Jev (${parts[1]}). ${parts[2]}`;
64
+ return `${NO_TIME_LEAD} ${name} after System One (${parts[1]}). ${parts[2]}`;
65
65
  }
66
66
 
67
67
  /** `fallback` stands in for a missing reason on a `reasoning-escalated` or
@@ -75,7 +75,7 @@ export function manualToast(
75
75
  switch (status.resolution) {
76
76
  case "reasoning-escalated":
77
77
  return warning(
78
- `${reasoningModel(status)} reviewed this after Jev; it needs your approval: ${status.reason ?? fallback}`,
78
+ `${reasoningModel(status)} reviewed this after System One; it needs your approval: ${status.reason ?? fallback}`,
79
79
  );
80
80
  case "reasoning-unavailable":
81
81
  return unavailable(status);
@@ -0,0 +1,42 @@
1
+ import type { TextUnit, UnitSplitter } from "../utils/text-units.ts";
2
+ import { isEastAsianWide } from "./east-asian-wide.ts";
3
+
4
+ const SEGMENTER = new Intl.Segmenter(undefined, { granularity: "grapheme" });
5
+ const ZERO_WIDTH = /^[\p{Mn}\p{Me}\p{Cf}]+$/u;
6
+ const EMOJI_PRESENTATION = /\p{Emoji_Presentation}/u;
7
+ const EMOJI_VARIATION = /\p{Extended_Pictographic}\uFE0F/u;
8
+ const KEYCAP = /^[#*0-9]\uFE0F?\u20E3$/u;
9
+ /** Text whose every code point is its own one-column grapheme: printable
10
+ * ASCII and the fit's own ⋯ and ⏎ markers. */
11
+ const ONE_COLUMN_EACH = /^[\x20-\x7e\u22ef\u23ce]*$/;
12
+
13
+ function clusterColumns(cluster: string): number {
14
+ if (ZERO_WIDTH.test(cluster)) return 0;
15
+ const first = cluster.codePointAt(0) ?? 0;
16
+ if (
17
+ isEastAsianWide(first) ||
18
+ EMOJI_PRESENTATION.test(cluster) ||
19
+ EMOJI_VARIATION.test(cluster) ||
20
+ KEYCAP.test(cluster)
21
+ ) {
22
+ return 2;
23
+ }
24
+ return 1;
25
+ }
26
+
27
+ /** One unit per grapheme cluster, measured in the terminal columns OpenTUI renders. */
28
+ export const columnUnits: UnitSplitter = (text: string): TextUnit[] => {
29
+ if (ONE_COLUMN_EACH.test(text))
30
+ return Array.from(
31
+ text,
32
+ (char: string): TextUnit => ({
33
+ text: char,
34
+ columns: 1,
35
+ }),
36
+ );
37
+ const units: TextUnit[] = [];
38
+ for (const { segment } of SEGMENTER.segment(text)) {
39
+ units.push({ text: segment, columns: clusterColumns(segment) });
40
+ }
41
+ return units;
42
+ };
@@ -0,0 +1,18 @@
1
+ /** One measured piece of text. */
2
+ export interface TextUnit {
3
+ readonly text: string;
4
+ readonly columns: number;
5
+ }
6
+
7
+ export type UnitSplitter = (text: string) => TextUnit[];
8
+
9
+ /** One unit per code point, one column each. */
10
+ export const codePointUnits: UnitSplitter = (text: string): TextUnit[] =>
11
+ Array.from(
12
+ text,
13
+ (character: string): TextUnit => ({ text: character, columns: 1 }),
14
+ );
15
+
16
+ export function unitsColumns(units: readonly TextUnit[]): number {
17
+ return units.reduce((total, unit) => total + unit.columns, 0);
18
+ }
package/docs/SECURITY.md CHANGED
@@ -46,5 +46,10 @@ or `npm ci` (npm 8.15.0 or later), run this in the installing project:
46
46
  npm audit signatures
47
47
  ```
48
48
 
49
+ The provenance of a release made by this workflow at the tag (automatic, a pushed tag, or a retry
50
+ dispatched with `--ref vX.Y.Z`) records the `vX.Y.Z` tag ref (`refs/tags/vX.Y.Z`) and the
51
+ `release.yml` workflow, so a verifier that pins the source ref should pin the tag. A dispatch from
52
+ another ref records that ref instead.
53
+
49
54
  [docs/SUPPLY-CHAIN.md](SUPPLY-CHAIN.md) describes what the package ships and the known
50
55
  residual exposure in its dependency tree.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@noppu-labs/opencode-permission-reviewer",
3
- "version": "3.2.3",
4
- "description": "Policy-aware AI permission reviewer for OpenCode V1 and V2: auto-approves routine agent tool calls, denies risky ones with feedback, and escalates the rest to you",
3
+ "version": "3.3.1",
4
+ "description": "Let OpenCode run unattended, securely: a System One or LLM reviewer answers permission prompts and asks you only when it should.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -85,7 +85,7 @@
85
85
  "bun"
86
86
  ],
87
87
  "engines": {
88
- "bun": ">=1.3.0",
88
+ "bun": ">=1.3.14",
89
89
  "opencode": ">=1.18.29 <2 || >=2.0.22 <3"
90
90
  },
91
91
  "peerDependencies": {
@@ -101,21 +101,24 @@
101
101
  }
102
102
  },
103
103
  "devDependencies": {
104
- "@biomejs/biome": "2.5.15",
105
- "@opencode-ai/plugin": "1.19.4",
106
- "@opencode-ai/sdk": "1.19.4",
107
- "@opencode/plugin": "2.1.2",
104
+ "@biomejs/biome": "2.6.3",
105
+ "@opencode-ai/plugin": "1.19.5",
106
+ "@opencode-ai/sdk": "1.19.5",
107
+ "@opencode/plugin": "2.2.0",
108
108
  "@types/bun": "^1.3.0",
109
109
  "@types/semver": "7.8.0",
110
110
  "fta-cli": "3.1.0",
111
- "knip": "6.41.0",
112
- "tsdown": "0.23.1",
111
+ "get-east-asian-width": "1.6.0",
112
+ "knip": "6.43.0",
113
+ "string-width": "7.2.0",
114
+ "tsdown": "0.23.3",
113
115
  "typescript": "7.0.2"
114
116
  },
115
117
  "overrides": {
116
118
  "@babel/core": "7.29.7",
117
119
  "ip-address": "10.7.4",
118
- "toml": "5.0.1"
120
+ "toml": "5.0.1",
121
+ "zod": "4.6.7"
119
122
  },
120
123
  "scripts": {
121
124
  "lint": "biome check --error-on-warnings .",
@@ -124,7 +127,7 @@
124
127
  "typecheck": "tsc --noEmit",
125
128
  "fta": "fta .",
126
129
  "knip": "knip",
127
- "audit": "bun audit --ignore GHSA-ch52-4w7c-c8xp --ignore GHSA-p6vx-979v-rg4c --ignore GHSA-jp82-f5mq-hwhp",
130
+ "audit": "bun audit --ignore GHSA-p6vx-979v-rg4c --ignore GHSA-jp82-f5mq-hwhp --ignore GHSA-97r2-qh9m-474h --ignore GHSA-wp97-x4hv-qvhp --ignore GHSA-7rv5-mrxv-xcr9 --ignore GHSA-9wx9-5pv9-3349",
128
131
  "build": "rm -rf dist && tsdown && bun scripts/copy-tui.ts",
129
132
  "test": "bun test",
130
133
  "test:stress": "bun test tests/stress.test.ts --timeout 30000",
@@ -135,11 +138,11 @@
135
138
  },
136
139
  "dependencies": {
137
140
  "@typesafe-ai/sdk": "0.6.0",
138
- "@opencode/client": "2.1.2",
141
+ "@opencode/client": "2.2.0",
139
142
  "jsonc-parser": "3.3.1",
140
143
  "semver": "7.8.5",
141
- "@opentui/core": "0.5.11",
142
- "@opentui/solid": "0.5.11",
144
+ "@opentui/core": "0.7.0",
145
+ "@opentui/solid": "0.7.0",
143
146
  "solid-js": "1.9.12",
144
147
  "zod": "4.6.7"
145
148
  }