@noppu-labs/opencode-permission-reviewer 3.3.0 → 3.3.2
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/CHANGELOG.md +45 -0
- package/dist/index.js +62 -29
- package/dist/tui/modules/status/services/ui-text-elide.ts +72 -31
- package/dist/tui/ui/action-fit.ts +9 -10
- package/dist/tui/ui/east-asian-wide.ts +44 -0
- package/dist/tui/ui/fit-parts.ts +39 -10
- package/dist/tui/ui/text-columns.ts +42 -0
- package/dist/tui/utils/text-units.ts +18 -0
- package/docs/SECURITY.md +5 -0
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.3.2] - 2026-10-30
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bumped the runtime dependency `@opencode/client` to 2.2.2.
|
|
15
|
+
- Bumped the dev dependencies `@opencode/plugin` to 2.2.2, `get-east-asian-width` to 1.7.0 and
|
|
16
|
+
`string-width` to 8.3.0, with `bun.lock` synchronized. The `@opentui/*` pins stay at 0.7.0
|
|
17
|
+
because `@opencode/plugin` 2.2.2 still pins them, so the `seroval` residual exposure tracked in
|
|
18
|
+
[#112](https://github.com/noppu-labs/opencode-permission-reviewer/issues/112) is unchanged.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- The TUI's East Asian Wide table is regenerated from `get-east-asian-width` 1.7.0, so characters
|
|
23
|
+
added as wide in Unicode 18 take two terminal columns when long commands are fitted.
|
|
24
|
+
|
|
25
|
+
## [3.3.1] - 2026-10-30
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Releases are tagged automatically: every push to `main` reads the `package.json` version and, if
|
|
30
|
+
it is not tagged yet, runs the release checks, then tags the commit `vX.Y.Z` and publishes from
|
|
31
|
+
that tag ([Releasing](docs/DEVELOPMENT.md#releasing)).
|
|
32
|
+
- New npm package description that more accurately represents what the plugin does.
|
|
33
|
+
- Bumped the dev dependencies `@opencode-ai/plugin` and `@opencode-ai/sdk` to 1.19.5, with
|
|
34
|
+
`bun.lock` synchronized (dependency bumps only; no behavior change). The `@opencode-ai/plugin`
|
|
35
|
+
peer range is unchanged.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- The TUI fits long commands by terminal columns, so CJK text and emoji no longer overflow the row
|
|
40
|
+
or lose the end of the command, combining accents no longer cut it short, and a cut never splits
|
|
41
|
+
a flag, an emoji or an accented letter ([#45](https://github.com/noppu-labs/opencode-permission-reviewer/issues/45)).
|
|
42
|
+
|
|
43
|
+
### Security
|
|
44
|
+
|
|
45
|
+
- GHSA-97r2-qh9m-474h, GHSA-wp97-x4hv-qvhp, GHSA-7rv5-mrxv-xcr9 and GHSA-9wx9-5pv9-3349 in
|
|
46
|
+
`seroval` are documented as residual exposure, alongside GHSA-p6vx-979v-rg4c and
|
|
47
|
+
GHSA-jp82-f5mq-hwhp. `seroval` arrives through `solid-js` 1.9.12, which `@opentui/solid` 0.7.0
|
|
48
|
+
pins exactly. Only the SSR renderer `solid-js/web` imports it, and neither this plugin nor
|
|
49
|
+
OpenTUI loads that renderer, so the vulnerable code is unreachable at runtime
|
|
50
|
+
([Supply chain](docs/SUPPLY-CHAIN.md#known-residual-exposure)). The upgrade is tracked in
|
|
51
|
+
[#112](https://github.com/noppu-labs/opencode-permission-reviewer/issues/112).
|
|
52
|
+
- The audit no longer ignores GHSA-ch52-4w7c-c8xp (`http-cache-semantics`), which GitHub
|
|
53
|
+
withdrew.
|
|
54
|
+
|
|
10
55
|
## [3.3.0] - 2026-10-28
|
|
11
56
|
|
|
12
57
|
### Added
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function invariant(condition, message) {
|
|
|
108
108
|
if (!condition) throw new Error(message);
|
|
109
109
|
}
|
|
110
110
|
// package.json
|
|
111
|
-
var version = "3.3.
|
|
111
|
+
var version = "3.3.2";
|
|
112
112
|
// src/utils/redact.ts
|
|
113
113
|
const REDACT = (type) => `[REDACTED:${type}]`;
|
|
114
114
|
const OPENCODE_SESSION_KEY = /^(?:session[_-]?id|session|sid)$/i;
|
|
@@ -12677,6 +12677,15 @@ function parseUiStatus(value) {
|
|
|
12677
12677
|
if (!(isRecord(value) && fieldsPass(value, STATUS_CHECKS))) return;
|
|
12678
12678
|
return value;
|
|
12679
12679
|
}
|
|
12680
|
+
// src/utils/text-units.ts
|
|
12681
|
+
/** One unit per code point, one column each. */
|
|
12682
|
+
const codePointUnits = (text) => Array.from(text, (character) => ({
|
|
12683
|
+
text: character,
|
|
12684
|
+
columns: 1
|
|
12685
|
+
}));
|
|
12686
|
+
function unitsColumns(units) {
|
|
12687
|
+
return units.reduce((total, unit) => total + unit.columns, 0);
|
|
12688
|
+
}
|
|
12680
12689
|
// src/modules/status/services/ui-text-elide.ts
|
|
12681
12690
|
const ELISION = " ⋯ ";
|
|
12682
12691
|
const ELISION_COLUMNS = Array.from(ELISION).length;
|
|
@@ -12693,40 +12702,64 @@ function escapeChar(char) {
|
|
|
12693
12702
|
function renderActionText(value) {
|
|
12694
12703
|
return value.replace(ESCAPED, escapeChar).replace(/\\\n/g, `\\⏎`).replace(/\n/g, ` ⏎ `).replace(/[ \t]+/g, " ").trim();
|
|
12695
12704
|
}
|
|
12696
|
-
/** Whether whole words of `kept`
|
|
12705
|
+
/** Whether whole words of `kept` columns use at least half of `max`, so
|
|
12697
12706
|
* the cut may fall between words rather than inside one. */
|
|
12698
12707
|
const wordCut = (kept, max) => kept > 0 && kept * 2 >= max;
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
*
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12708
|
+
const joinUnits = (units) => units.map((unit) => unit.text).join("");
|
|
12709
|
+
/** The longest prefix of `text` made of whole words within `max` columns as
|
|
12710
|
+
* `split` measures them (code points by default); a hard cut at `max` when
|
|
12711
|
+
* those words would use less than half of it. Always a prefix of `text`
|
|
12712
|
+
* (trailing spaces trimmed). */
|
|
12713
|
+
function keepHead(text, max, split = codePointUnits) {
|
|
12714
|
+
const units = split(text);
|
|
12715
|
+
if (unitsColumns(units) <= max) return text;
|
|
12716
|
+
let fit = 0;
|
|
12717
|
+
let used = 0;
|
|
12718
|
+
for (const unit of units) {
|
|
12719
|
+
if (used + unit.columns > max) break;
|
|
12720
|
+
used += unit.columns;
|
|
12721
|
+
fit += 1;
|
|
12722
|
+
}
|
|
12723
|
+
let end = fit;
|
|
12724
|
+
while (end > 0 && units[end]?.text !== " ") {
|
|
12725
|
+
end -= 1;
|
|
12726
|
+
used -= units[end]?.columns ?? 0;
|
|
12727
|
+
}
|
|
12728
|
+
return joinUnits(units.slice(0, wordCut(used, max) ? end : fit)).trimEnd();
|
|
12729
|
+
}
|
|
12730
|
+
/** The longest suffix of `text` made of whole words within `max` columns as
|
|
12731
|
+
* `split` measures them (code points by default); a hard cut at `max` when
|
|
12732
|
+
* those words would use less than half of it. Always a suffix of `text`
|
|
12733
|
+
* (leading spaces trimmed). */
|
|
12734
|
+
function keepTail(text, max, split = codePointUnits) {
|
|
12713
12735
|
if (max <= 0) return "";
|
|
12714
|
-
const
|
|
12715
|
-
if (
|
|
12716
|
-
let
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12724
|
-
|
|
12736
|
+
const units = split(text);
|
|
12737
|
+
if (unitsColumns(units) <= max) return text;
|
|
12738
|
+
let fitStart = units.length;
|
|
12739
|
+
let used = 0;
|
|
12740
|
+
while (fitStart > 0) {
|
|
12741
|
+
const columns = units[fitStart - 1]?.columns ?? 0;
|
|
12742
|
+
if (used + columns > max) break;
|
|
12743
|
+
used += columns;
|
|
12744
|
+
fitStart -= 1;
|
|
12745
|
+
}
|
|
12746
|
+
let start = fitStart;
|
|
12747
|
+
while (start < units.length && units[start - 1]?.text !== " ") {
|
|
12748
|
+
used -= units[start]?.columns ?? 0;
|
|
12749
|
+
start += 1;
|
|
12750
|
+
}
|
|
12751
|
+
return joinUnits(units.slice(wordCut(used, max) ? start : fitStart)).trimStart();
|
|
12752
|
+
}
|
|
12753
|
+
/** `text` split into a head and a tail that fit `max` columns as `split`
|
|
12754
|
+
* measures them (code points by default) together with " ⋯ " between them,
|
|
12755
|
+
* the head taking at most half; undefined when `text` already fits. */
|
|
12756
|
+
function elideMiddle(text, max, split = codePointUnits) {
|
|
12757
|
+
if (unitsColumns(split(text)) <= max) return void 0;
|
|
12725
12758
|
const budget = Math.max(0, max - ELISION_COLUMNS);
|
|
12726
|
-
const head = keepHead(text, Math.ceil(budget / 2));
|
|
12759
|
+
const head = keepHead(text, Math.ceil(budget / 2), split);
|
|
12727
12760
|
return {
|
|
12728
12761
|
head,
|
|
12729
|
-
tail: keepTail(text, budget -
|
|
12762
|
+
tail: keepTail(text, budget - unitsColumns(split(head)), split)
|
|
12730
12763
|
};
|
|
12731
12764
|
}
|
|
12732
12765
|
/** `value` on one line with escapes and line-break markers applied and at most
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// Ships to the TUI (the action fit) and runs on the server (the bounded action
|
|
2
2
|
// and segment texts), so it must not import a server-only module.
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
codePointUnits,
|
|
6
|
+
type TextUnit,
|
|
7
|
+
type UnitSplitter,
|
|
8
|
+
unitsColumns,
|
|
9
|
+
} from "../../../utils/text-units.ts";
|
|
10
|
+
|
|
4
11
|
export const ELISION: string = " ⋯ ";
|
|
5
12
|
export const LINE_BREAK: string = "⏎";
|
|
6
13
|
const ELISION_COLUMNS: number = Array.from(ELISION).length;
|
|
@@ -31,51 +38,85 @@ export function renderActionText(value: string): string {
|
|
|
31
38
|
.trim();
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
/** Whether whole words of `kept`
|
|
41
|
+
/** Whether whole words of `kept` columns use at least half of `max`, so
|
|
35
42
|
* the cut may fall between words rather than inside one. */
|
|
36
43
|
const wordCut = (kept: number, max: number): boolean =>
|
|
37
44
|
kept > 0 && kept * 2 >= max;
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const joinUnits = (units: readonly TextUnit[]): string =>
|
|
47
|
+
units.map((unit) => unit.text).join("");
|
|
48
|
+
|
|
49
|
+
/** The longest prefix of `text` made of whole words within `max` columns as
|
|
50
|
+
* `split` measures them (code points by default); a hard cut at `max` when
|
|
51
|
+
* those words would use less than half of it. Always a prefix of `text`
|
|
52
|
+
* (trailing spaces trimmed). */
|
|
53
|
+
export function keepHead(
|
|
54
|
+
text: string,
|
|
55
|
+
max: number,
|
|
56
|
+
split: UnitSplitter = codePointUnits,
|
|
57
|
+
): string {
|
|
58
|
+
const units = split(text);
|
|
59
|
+
if (unitsColumns(units) <= max) return text;
|
|
60
|
+
let fit = 0;
|
|
61
|
+
let used = 0;
|
|
62
|
+
for (const unit of units) {
|
|
63
|
+
if (used + unit.columns > max) break;
|
|
64
|
+
used += unit.columns;
|
|
65
|
+
fit += 1;
|
|
66
|
+
}
|
|
67
|
+
let end = fit;
|
|
68
|
+
while (end > 0 && units[end]?.text !== " ") {
|
|
69
|
+
end -= 1;
|
|
70
|
+
used -= units[end]?.columns ?? 0;
|
|
71
|
+
}
|
|
72
|
+
return joinUnits(units.slice(0, wordCut(used, max) ? end : fit)).trimEnd();
|
|
51
73
|
}
|
|
52
74
|
|
|
53
|
-
/** The longest suffix of `text` made of whole words within `max`
|
|
54
|
-
* points; a hard cut at `max` when
|
|
55
|
-
* it. Always a suffix of `text`
|
|
56
|
-
|
|
75
|
+
/** The longest suffix of `text` made of whole words within `max` columns as
|
|
76
|
+
* `split` measures them (code points by default); a hard cut at `max` when
|
|
77
|
+
* those words would use less than half of it. Always a suffix of `text`
|
|
78
|
+
* (leading spaces trimmed). */
|
|
79
|
+
export function keepTail(
|
|
80
|
+
text: string,
|
|
81
|
+
max: number,
|
|
82
|
+
split: UnitSplitter = codePointUnits,
|
|
83
|
+
): string {
|
|
57
84
|
if (max <= 0) return "";
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
85
|
+
const units = split(text);
|
|
86
|
+
if (unitsColumns(units) <= max) return text;
|
|
87
|
+
let fitStart = units.length;
|
|
88
|
+
let used = 0;
|
|
89
|
+
while (fitStart > 0) {
|
|
90
|
+
const columns = units[fitStart - 1]?.columns ?? 0;
|
|
91
|
+
if (used + columns > max) break;
|
|
92
|
+
used += columns;
|
|
93
|
+
fitStart -= 1;
|
|
94
|
+
}
|
|
95
|
+
let start = fitStart;
|
|
96
|
+
while (start < units.length && units[start - 1]?.text !== " ") {
|
|
97
|
+
used -= units[start]?.columns ?? 0;
|
|
98
|
+
start += 1;
|
|
99
|
+
}
|
|
100
|
+
return joinUnits(
|
|
101
|
+
units.slice(wordCut(used, max) ? start : fitStart),
|
|
102
|
+
).trimStart();
|
|
66
103
|
}
|
|
67
104
|
|
|
68
|
-
/** `text` split into a head and a tail that fit `max`
|
|
69
|
-
* with " ⋯ " between them,
|
|
70
|
-
* `text` already fits. */
|
|
105
|
+
/** `text` split into a head and a tail that fit `max` columns as `split`
|
|
106
|
+
* measures them (code points by default) together with " ⋯ " between them,
|
|
107
|
+
* the head taking at most half; undefined when `text` already fits. */
|
|
71
108
|
export function elideMiddle(
|
|
72
109
|
text: string,
|
|
73
110
|
max: number,
|
|
111
|
+
split: UnitSplitter = codePointUnits,
|
|
74
112
|
): { head: string; tail: string } | undefined {
|
|
75
|
-
if (
|
|
113
|
+
if (unitsColumns(split(text)) <= max) return undefined;
|
|
76
114
|
const budget = Math.max(0, max - ELISION_COLUMNS);
|
|
77
|
-
const head = keepHead(text, Math.ceil(budget / 2));
|
|
78
|
-
return {
|
|
115
|
+
const head = keepHead(text, Math.ceil(budget / 2), split);
|
|
116
|
+
return {
|
|
117
|
+
head,
|
|
118
|
+
tail: keepTail(text, budget - unitsColumns(split(head)), split),
|
|
119
|
+
};
|
|
79
120
|
}
|
|
80
121
|
|
|
81
122
|
/** `value` on one line with escapes and line-break markers applied and at most
|
|
@@ -4,14 +4,12 @@ import type {
|
|
|
4
4
|
ActionSegment,
|
|
5
5
|
ReviewUiStatus,
|
|
6
6
|
} from "../modules/status/models/ui-protocol.ts";
|
|
7
|
-
import {
|
|
8
|
-
ELISION,
|
|
9
|
-
elideMiddle,
|
|
10
|
-
keepHead,
|
|
11
|
-
keepTail,
|
|
12
|
-
} from "../modules/status/services/ui-text-elide.ts";
|
|
7
|
+
import { ELISION } from "../modules/status/services/ui-text-elide.ts";
|
|
13
8
|
import {
|
|
14
9
|
type FitPart,
|
|
10
|
+
fitHead,
|
|
11
|
+
fitMiddle,
|
|
12
|
+
fitTail,
|
|
15
13
|
merged,
|
|
16
14
|
partsColumns,
|
|
17
15
|
shown,
|
|
@@ -25,7 +23,8 @@ export interface ActionFitPart {
|
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
const ELLIPSIS = "⋯";
|
|
28
|
-
/** Narrowest width that
|
|
26
|
+
/** Narrowest width that can show a narrow character on each side of " ⋯ ";
|
|
27
|
+
* wide characters need 7, and below that the tail is kept. */
|
|
29
28
|
const MIN_ELIDED_COLUMNS = 5;
|
|
30
29
|
|
|
31
30
|
/** Collapses line breaks and tabs so a value renders on one row. */
|
|
@@ -94,11 +93,11 @@ function cutMarker(hidden: number, columns: number): string {
|
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
const headOf = (parts: readonly FitPart[], max: number): FitPart[] =>
|
|
97
|
-
sliceParts(parts, 0, textColumns(
|
|
96
|
+
sliceParts(parts, 0, textColumns(fitHead(shown(parts), max)));
|
|
98
97
|
|
|
99
98
|
function tailOf(parts: readonly FitPart[], max: number): FitPart[] {
|
|
100
99
|
const columns = partsColumns(parts);
|
|
101
|
-
const tail =
|
|
100
|
+
const tail = fitTail(shown(parts), max);
|
|
102
101
|
return sliceParts(parts, columns - textColumns(tail), columns);
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -132,7 +131,7 @@ function firstAndLast(
|
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
function headAndTail(action: string, columns: number): ActionFitPart[] {
|
|
135
|
-
const parts =
|
|
134
|
+
const parts = fitMiddle(singleLine(action), columns);
|
|
136
135
|
if (parts === undefined)
|
|
137
136
|
return merged([{ text: singleLine(action), muted: false }]);
|
|
138
137
|
return merged([
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Generated by `bun scripts/generate-east-asian-wide.ts` from
|
|
2
|
+
// get-east-asian-width 1.7.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-18cda 18cff-18d20 18d80-18df2",
|
|
14
|
+
"18e00-19191 191a0-191d2 1aff0-1aff3 1aff5-1affb 1affd-1affe 1b000-1b128 1b132-1b132 1b150-1b152",
|
|
15
|
+
"1b155-1b155 1b164-1b168 1b170-1b2fb 1d300-1d356 1d360-1d376 1f004-1f004 1f0cf-1f0cf 1f18e-1f18e",
|
|
16
|
+
"1f191-1f19a 1f1ae-1f1ae 1f200-1f202 1f210-1f23b 1f240-1f248 1f250-1f251 1f260-1f265 1f300-1f320",
|
|
17
|
+
"1f32d-1f335 1f337-1f37c 1f37e-1f393 1f3a0-1f3ca 1f3cf-1f3d3 1f3e0-1f3f0 1f3f4-1f3f4 1f3f8-1f43e",
|
|
18
|
+
"1f440-1f440 1f442-1f4fc 1f4ff-1f53d 1f54b-1f54e 1f550-1f567 1f57a-1f57a 1f595-1f596 1f5a4-1f5a4",
|
|
19
|
+
"1f5fb-1f64f 1f680-1f6c5 1f6cc-1f6cc 1f6d0-1f6d2 1f6d5-1f6d9 1f6dc-1f6df 1f6eb-1f6ec 1f6f4-1f6fc",
|
|
20
|
+
"1f7da-1f7da 1f7e0-1f7eb 1f7f0-1f7f0 1f90c-1f93a 1f93c-1f945 1f947-1f9ff 1fa70-1fa7c 1fa80-1fac6",
|
|
21
|
+
"1fac8-1fac8 1facc-1fadd 1fadf-1faeb 1faef-1fafa 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
|
+
}
|
package/dist/tui/ui/fit-parts.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// Measuring, slicing and merging fitted action parts.
|
|
2
2
|
|
|
3
|
-
import {
|
|
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
|
-
/**
|
|
21
|
+
/** Terminal columns `text` takes. */
|
|
14
22
|
export function textColumns(text: string): number {
|
|
15
|
-
return
|
|
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
|
|
57
|
-
*
|
|
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
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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 });
|
|
@@ -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.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.3.2",
|
|
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",
|
|
@@ -102,13 +102,15 @@
|
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@biomejs/biome": "2.6.3",
|
|
105
|
-
"@opencode-ai/plugin": "1.19.
|
|
106
|
-
"@opencode-ai/sdk": "1.19.
|
|
107
|
-
"@opencode/plugin": "2.2.
|
|
105
|
+
"@opencode-ai/plugin": "1.19.5",
|
|
106
|
+
"@opencode-ai/sdk": "1.19.5",
|
|
107
|
+
"@opencode/plugin": "2.2.2",
|
|
108
108
|
"@types/bun": "^1.3.0",
|
|
109
109
|
"@types/semver": "7.8.0",
|
|
110
110
|
"fta-cli": "3.1.0",
|
|
111
|
+
"get-east-asian-width": "1.7.0",
|
|
111
112
|
"knip": "6.43.0",
|
|
113
|
+
"string-width": "8.3.0",
|
|
112
114
|
"tsdown": "0.23.3",
|
|
113
115
|
"typescript": "7.0.2"
|
|
114
116
|
},
|
|
@@ -125,7 +127,7 @@
|
|
|
125
127
|
"typecheck": "tsc --noEmit",
|
|
126
128
|
"fta": "fta .",
|
|
127
129
|
"knip": "knip",
|
|
128
|
-
"audit": "bun audit --ignore GHSA-
|
|
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",
|
|
129
131
|
"build": "rm -rf dist && tsdown && bun scripts/copy-tui.ts",
|
|
130
132
|
"test": "bun test",
|
|
131
133
|
"test:stress": "bun test tests/stress.test.ts --timeout 30000",
|
|
@@ -136,7 +138,7 @@
|
|
|
136
138
|
},
|
|
137
139
|
"dependencies": {
|
|
138
140
|
"@typesafe-ai/sdk": "0.6.0",
|
|
139
|
-
"@opencode/client": "2.2.
|
|
141
|
+
"@opencode/client": "2.2.2",
|
|
140
142
|
"jsonc-parser": "3.3.1",
|
|
141
143
|
"semver": "7.8.5",
|
|
142
144
|
"@opentui/core": "0.7.0",
|