Skip to content

Commit a76299f

Browse files
author
dmmop
committed
fix(tooling): lint nested staged files
1 parent c57bef8 commit a76299f

7 files changed

Lines changed: 61 additions & 40 deletions

File tree

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
}
8484
},
8585
{
86-
"includes": ["src/tui.tsx"],
86+
"includes": ["src/tui.tsx", "src/tui-v2.tsx"],
8787
"linter": {
8888
"rules": {
8989
"a11y": {

lefthook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pre-commit:
22
commands:
33
biome:
4-
glob: "*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}"
4+
glob: "**/*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}"
55
run: pnpm exec biome check --write --no-errors-on-unmatched {staged_files}
66
stage_fixed: true
77

scripts/verify-typescript-version.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import { fileURLToPath } from "node:url";
55
import { parse } from "yaml";
66

77
const EXPECTED_TYPESCRIPT_VERSION = "7.0.2";
8-
const EXPECTED_PLUGIN_VERSION = "1.18.11";
9-
const EXPECTED_OPENTUI_VERSION = "0.4.5";
8+
const EXPECTED_PLUGIN_VERSION = "1.18.1";
9+
const EXPECTED_OPENTUI_SPECIFIER = "^0.5.3";
10+
const EXPECTED_OPENTUI_VERSION = "0.5.4";
1011
const EXPECTED_OPENTUI_PACKAGES = ["@opentui/core", "@opentui/solid"];
11-
const BUN_FFI_STRUCTS_VERSION = "0.2.4";
12+
const BUN_FFI_STRUCTS_VERSION = "0.3.1";
1213
const BUN_FFI_TYPESCRIPT_PEER = "^5";
1314

1415
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
@@ -66,9 +67,9 @@ if (configuredPlugin !== EXPECTED_PLUGIN_VERSION) {
6667
}
6768
for (const name of EXPECTED_OPENTUI_PACKAGES) {
6869
const configuredVersion = packageJson.dependencies?.[name];
69-
if (configuredVersion !== EXPECTED_OPENTUI_VERSION) {
70+
if (configuredVersion !== EXPECTED_OPENTUI_SPECIFIER) {
7071
fail(
71-
`${name} must be pinned exactly to ${EXPECTED_OPENTUI_VERSION} for @opencode-ai/plugin ${EXPECTED_PLUGIN_VERSION} compatibility; package.json has ${String(configuredVersion)}.`,
72+
`${name} must be pinned to ${EXPECTED_OPENTUI_SPECIFIER}; package.json has ${String(configuredVersion)}.`,
7273
);
7374
}
7475
}
@@ -111,7 +112,7 @@ verifyImporterDependency("typescript", EXPECTED_TYPESCRIPT_VERSION);
111112
for (const name of EXPECTED_OPENTUI_PACKAGES) {
112113
const dependency = rootImporter.dependencies?.[name];
113114
if (
114-
dependency?.specifier !== EXPECTED_OPENTUI_VERSION ||
115+
dependency?.specifier !== EXPECTED_OPENTUI_SPECIFIER ||
115116
(dependency?.version !== EXPECTED_OPENTUI_VERSION &&
116117
!dependency?.version?.startsWith(`${EXPECTED_OPENTUI_VERSION}(`))
117118
) {

src/tui-v2.tsx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/** @jsxImportSource @opentui/solid */
2-
import type { JSX } from "@opentui/solid";
2+
33
import { RGBA } from "@opentui/core";
4-
import { Show, createSignal, onCleanup } from "solid-js";
4+
import type { JSX } from "@opentui/solid";
5+
import { createSignal, onCleanup, Show } from "solid-js";
56

67
import { sanitizeDisplayText } from "./lib/display-sanitize.js";
78
import { formatQuotaRows } from "./lib/format.js";
@@ -10,13 +11,13 @@ import {
1011
QUOTA_DIALOG_COMMANDS,
1112
type QuotaDialogCommandId,
1213
} from "./lib/quota-dialog-commands.js";
14+
import { resolveQuotaFormatStyle } from "./lib/quota-format-style.js";
1315
import { collectQuotaRenderData } from "./lib/quota-render-data.js";
1416
import {
1517
createQuotaRuntimeRequestContext,
16-
resolveQuotaRuntimeContext,
1718
type QuotaSessionModelContext,
19+
resolveQuotaRuntimeContext,
1820
} from "./lib/quota-runtime-context.js";
19-
import { resolveQuotaFormatStyle } from "./lib/quota-format-style.js";
2021
import { buildSidebarQuotaPanelLines } from "./lib/tui-sidebar-format.js";
2122

2223
const terminalForeground = RGBA.defaultForeground();
@@ -32,22 +33,25 @@ type TuiContext = {
3233
client: unknown;
3334
data: { on: (event: string, handler: (event: TuiEvent) => void) => () => void };
3435
keymap: {
35-
layer: (build: () => {
36-
mode: "global";
37-
commands: Array<{
38-
id: string;
39-
title: string;
40-
group: string;
41-
palette: true;
42-
slash: { name: string };
43-
run: (input?: unknown) => void;
44-
}>;
45-
}) => void;
36+
layer: (
37+
build: () => {
38+
mode: "global";
39+
commands: Array<{
40+
id: string;
41+
title: string;
42+
group: string;
43+
palette: true;
44+
slash: { name: string };
45+
run: (input?: unknown) => void;
46+
}>;
47+
},
48+
) => void;
4649
};
4750
ui: {
48-
slot: (claim:
49-
| { append: "app"; render: () => null }
50-
| { append: "sidebar.content"; render: (props: { sessionID: string }) => JSX.Element }
51+
slot: (
52+
claim:
53+
| { append: "app"; render: () => null }
54+
| { append: "sidebar.content"; render: (props: { sessionID: string }) => JSX.Element },
5155
) => () => void;
5256
toast: { show: (toast: Toast) => void };
5357
dialog: {
@@ -244,7 +248,11 @@ function SidebarQuotaView(props: {
244248

245249
return (
246250
<box flexDirection="column">
247-
<box flexDirection="row" gap={1} onMouseDown={() => expandable() && setOpen((value) => !value)}>
251+
<box
252+
flexDirection="row"
253+
gap={1}
254+
onMouseDown={() => expandable() && setOpen((value) => !value)}
255+
>
248256
<Show when={expandable()}>
249257
<text fg={terminalForeground}>{open() ? "▼" : "▶"}</text>
250258
</Show>
@@ -295,7 +303,9 @@ const plugin = {
295303
})
296304
.catch(reportFailure);
297305
};
298-
const onStepEnded = context.data.on("session.step.ended", (event) => trigger(event, "idle"));
306+
const onStepEnded = context.data.on("session.step.ended", (event) =>
307+
trigger(event, "idle"),
308+
);
299309
const onCompacted = context.data.on("session.compaction.ended", (event) =>
300310
trigger(event, "compacted"),
301311
);

tests/package-manifest.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ describe("package manifest compatibility", () => {
153153

154154
it("keeps the public plugin peer broad and reference-compatible development targets exact", () => {
155155
expect(pkg.peerDependencies?.["@opencode-ai/plugin"]).toBe("^1.4.3");
156-
expect(pkg.devDependencies?.["@opencode-ai/plugin"]).toBe("1.18.11");
157-
expect(pkg.dependencies?.["@opentui/core"]).toBe("0.4.5");
158-
expect(pkg.dependencies?.["@opentui/solid"]).toBe("0.4.5");
156+
expect(pkg.devDependencies?.["@opencode-ai/plugin"]).toBe("1.18.1");
157+
expect(pkg.dependencies?.["@opentui/core"]).toBe("^0.5.3");
158+
expect(pkg.dependencies?.["@opentui/solid"]).toBe("^0.5.3");
159159
expect(readme).toContain("Node.js `>= 22` is required.");
160160
expect(readme).not.toContain("OpenCode `>= 1.4.3`");
161161
expect(pkg.engines).not.toHaveProperty("opencode");
@@ -164,8 +164,10 @@ describe("package manifest compatibility", () => {
164164
it("keeps the TypeScript 7 toolchain explicit without suppressing the known peer mismatch", () => {
165165
expect(tsconfig.compilerOptions?.types).toEqual(["node"]);
166166
expect(typescriptValidator).toContain('const EXPECTED_TYPESCRIPT_VERSION = "7.0.2";');
167-
expect(typescriptValidator).toContain('const EXPECTED_PLUGIN_VERSION = "1.18.11";');
168-
expect(typescriptValidator).toContain('const EXPECTED_OPENTUI_VERSION = "0.4.5";');
167+
expect(typescriptValidator).toContain('const EXPECTED_PLUGIN_VERSION = "1.18.1";');
168+
expect(typescriptValidator).toContain('const EXPECTED_OPENTUI_SPECIFIER = "^0.5.3";');
169+
expect(typescriptValidator).toContain('const EXPECTED_OPENTUI_VERSION = "0.5.4";');
170+
expect(typescriptValidator).toContain('const BUN_FFI_STRUCTS_VERSION = "0.3.1";');
169171
expect(typescriptValidator).toContain('const BUN_FFI_TYPESCRIPT_PEER = "^5";');
170172
expect(typescriptValidator).toContain("Known unmet peer:");
171173
expect(typescriptValidator).not.toMatch(/TypeScript v4 freeze|\^5\.9/);
@@ -215,7 +217,7 @@ describe("package manifest compatibility", () => {
215217

216218
expect(lefthookConfig["pre-commit"]?.commands).toEqual({
217219
biome: {
218-
glob: "*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}",
220+
glob: "**/*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}",
219221
run: "pnpm exec biome check --write --no-errors-on-unmatched {staged_files}",
220222
stage_fixed: true,
221223
},

tests/release-gates.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe("v4 release gates", () => {
115115
const typescript = run(typescriptScript);
116116
expect(typescript.status).toBe(0);
117117
expect(typescript.stdout).toContain(
118-
"TypeScript 7.0.2 and @opencode-ai/plugin 1.18.11 lock entries verified",
118+
"TypeScript 7.0.2 and @opencode-ai/plugin 1.18.1 lock entries verified",
119119
);
120120

121121
const history = run(historyScript);
@@ -147,7 +147,7 @@ describe("v4 release gates", () => {
147147
"references/local/opencode-1.18.2/package.json",
148148
"references/branches/private-plan.md",
149149
"prompt-exports/session.md",
150-
"opencode-quota/auth.json",
150+
"opencode-quota/opencode.db",
151151
"images/private-smoke.png",
152152
"opencode.json",
153153
"tui.json",
@@ -210,7 +210,7 @@ describe("v4 release gates", () => {
210210
"references/local/v4.0.0-consolidated-plan.md",
211211
"references/upstream-plugins/README.md",
212212
"prompt-exports/review.md",
213-
"opencode-quota/auth.json",
213+
"opencode-quota/opencode.db",
214214
"tests/package-manifest.test.ts",
215215
"scripts/verify-release-version.mjs",
216216
"opencode-quota-logo-dark.svg",

tests/tui-v2-commands.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import plugin from "../src/tui-v2.tsx";
44

55
describe("V2 quota TUI commands", () => {
66
it("registers every quota command as a local slash command", () => {
7-
let layer: { commands: Array<{ slash: { name: string }; palette: boolean; run: () => void }> } | undefined;
7+
let layer:
8+
| { commands: Array<{ slash: { name: string }; palette: boolean; run: () => void }> }
9+
| undefined;
810
const context = {
911
client: {},
1012
data: { on: vi.fn(() => vi.fn()) },
11-
keymap: { layer: vi.fn((build) => (layer = build())) },
13+
keymap: {
14+
layer: vi.fn((build) => {
15+
layer = build();
16+
}),
17+
},
1218
ui: {
1319
slot: vi.fn((claim) => {
1420
if (claim.append === "app") claim.render();
@@ -37,7 +43,9 @@ describe("V2 quota TUI commands", () => {
3743
]);
3844
expect(layer?.commands.every((command) => command.palette)).toBe(true);
3945
expect(context.ui.slot).toHaveBeenCalledWith(expect.objectContaining({ append: "app" }));
40-
expect(context.ui.slot).toHaveBeenCalledWith(expect.objectContaining({ append: "sidebar.content" }));
46+
expect(context.ui.slot).toHaveBeenCalledWith(
47+
expect.objectContaining({ append: "sidebar.content" }),
48+
);
4149
expect(context.data.on.mock.calls.map(([event]) => event)).toEqual([
4250
"session.step.ended",
4351
"session.compaction.ended",

0 commit comments

Comments
 (0)