Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
- run: yarn run typecheck
- run: yarn run lint
- run: yarn run build
- run: yarn run test
# Sanity-check `npm pack` only once (Linux + Node 24) to avoid
# 6-way artifact-name collisions; lint/build coverage is what
# the cross-OS matrix is actually for.
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ export default [
},
},
{
ignores: ["dist/**", "node_modules/**"],
ignores: ["dist/**", "node_modules/**", "tests/**"],
},
];
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gui-chat-plugin/set-image-style",
"version": "1.1.0",
"version": "1.1.1",
"description": "Set image style modifier plugin for GUIChat",
"type": "module",
"main": "./dist/index.cjs",
Expand Down Expand Up @@ -31,7 +31,8 @@
"dev": "vite",
"build": "vite build && vue-tsc -p tsconfig.build.json --emitDeclarationOnly",
"typecheck": "vue-tsc --noEmit",
"lint": "eslint src demo"
"lint": "eslint src demo",
"test": "tsx --test tests/*.test.ts"
},
"peerDependencies": {
"gui-chat-protocol": "^1.2.0",
Expand All @@ -48,6 +49,7 @@
"globals": "^17.8.0",
"gui-chat-protocol": "^1.2.0",
"tailwindcss": "^4.3.3",
"tsx": "^4.23.4",
"typescript": "~6.0.3",
"vite": "^8.1.5",
"vue": "^3.5.40",
Expand Down
7 changes: 5 additions & 2 deletions src/core/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
* Execute the setImageStyle function
* Updates the image generation config to include a style modifier
*/
// context is nullable on purpose: hosts that run the plugin without client-side
// state (MulmoClaude's server bridge) pass an empty or missing context, and
// reading through it unguarded threw a TypeError instead of returning a result.
export const executeSetImageStyle = async (
context: ToolContext,
context: ToolContext | null | undefined,
args: SetImageStyleArgs,
): Promise<ToolResult<SetImageStyleData, SetImageStyleJsonData>> => {
const { styleModifier } = args;

// Check if app context provides image config functions
const app = context.app as {
const app = context?.app as {

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (22.x, macos-latest)

Do not use any type assertions

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (22.x, windows-latest)

Do not use any type assertions

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (24.x, macos-latest)

Do not use any type assertions

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (24.x, ubuntu-latest)

Do not use any type assertions

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (24.x, windows-latest)

Do not use any type assertions

Check warning on line 31 in src/core/plugin.ts

View workflow job for this annotation

GitHub Actions / lint_test (22.x, ubuntu-latest)

Do not use any type assertions
getImageConfig?: () => ImageGenerationConfig;
setConfig?: (key: string, value: ImageGenerationConfig) => void;
};
Expand Down
36 changes: 36 additions & 0 deletions tests/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Regression test for receptron/mulmoclaude#2709.
*
* Hosts that run a plugin without any client-side state (MulmoClaude's server
* bridge) pass a missing or empty context. Reading through it unguarded threw
* `Cannot read properties of null` and surfaced as an HTTP 500 for every call.
*
* Run with: yarn test
*/

import { test, describe } from "node:test";
import assert from "node:assert";
import { pluginCore } from "../src/core/plugin.js";

const ARGS = { styleModifier: "watercolor" };

const CONTEXTS: [string, unknown][] = [
["null", null],
["undefined", undefined],
["an empty object", {}],
];

describe("GUIChatPluginSetImageStyle - host provides no context", () => {
CONTEXTS.forEach(([label, context]) => {
test(`returns a result instead of throwing when context is ${label}`, async () => {
const result = await pluginCore.execute(
context as never,
ARGS as never,
);
assert.ok(
result && typeof result === "object",
"execute must resolve to a ToolResult rather than throw",
);
});
});
});
171 changes: 171 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,136 @@
dependencies:
tslib "^2.4.0"

"@esbuild/aix-ppc64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz#7a01a8d2ec2fbb2dac78adad09b0fa781e4082be"
integrity sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==

"@esbuild/android-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz#b540a27d14e4afd058496a4dbec4d3f414db110a"
integrity sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==

"@esbuild/android-arm@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.28.1.tgz#704bd297de6d762de54eabbeafbf55f6756abe2f"
integrity sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==

"@esbuild/android-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.28.1.tgz#d1cb166d34b0fbf0fe8ab460a5594f24a378701e"
integrity sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==

"@esbuild/darwin-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz#1034b26457fc886368fe61bbd09f653f6afa8e54"
integrity sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==

"@esbuild/darwin-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz#65556a432a1e4d72032d8218c1932fcca1a49772"
integrity sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==

"@esbuild/freebsd-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz#2e61e0592f9030d7e3dae18ee25ebc535918aef6"
integrity sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==

"@esbuild/freebsd-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz#c95ec289959ef8079c4dca817a1e2c4be66b9bd3"
integrity sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==

"@esbuild/linux-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz#40b22175dda06182f3ee8141186c5ff304c4a717"
integrity sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==

"@esbuild/linux-arm@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz#c09a0f67917592ac0de892a9be4d3814debd2a6c"
integrity sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==

"@esbuild/linux-ia32@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz#a580f9c676797833891e519fc7a1337c8afd8db3"
integrity sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==

"@esbuild/linux-loong64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz#46452cf321dc7f9e91c2fa780a56bb56e79cd68b"
integrity sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==

"@esbuild/linux-mips64el@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz#4211b3184dd6608f53dcb22e39f5d34ee08852c8"
integrity sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==

"@esbuild/linux-ppc64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz#697857c2a61cb9b0b6bb6652e40c1dc5e1ca8e5d"
integrity sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==

"@esbuild/linux-riscv64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz#d192943eb146a40ac4c6497d0cf7be35b986bf08"
integrity sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==

"@esbuild/linux-s390x@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz#acea0356da0e0ebc08f97cf7b9c2e401e1e648dc"
integrity sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==

"@esbuild/linux-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz#6f0c3ce0cb64c534b70c4c45ecb2c16d34e35dfd"
integrity sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==

"@esbuild/netbsd-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz#8bcd77077a0dce3378b574fedb26d2a253b73d36"
integrity sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==

"@esbuild/netbsd-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz#e7fb2a01e99c830c94e6623cd9fefb4c8fb58347"
integrity sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==

"@esbuild/openbsd-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz#c52909372db8b86e2c55e05a8940033b5660a3b2"
integrity sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==

"@esbuild/openbsd-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz#c427b9be5a64c262ff9a7eb70b5fbbaadf446c6c"
integrity sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==

"@esbuild/openharmony-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz#dc9b147baca2e6c4b3c85571741ef4860a489097"
integrity sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==

"@esbuild/sunos-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz#ce866d12df13c15e4c99f073a3d466f6e0649b3a"
integrity sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==

"@esbuild/win32-arm64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz#7468e3692d01d629d5941e5d83817bb80f9e39b4"
integrity sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==

"@esbuild/win32-ia32@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz#a5bc0063fb2bcab6d0ed63f2a1537958bc269ec6"
integrity sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==

"@esbuild/win32-x64@0.28.1":
version "0.28.1"
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz#10064ee44f4347b90c9a02b446bbf80a91632b12"
integrity sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==

"@eslint-community/eslint-utils@^4.8.0", "@eslint-community/eslint-utils@^4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz#4e90af67bc51ddee6cdef5284edf572ec376b595"
Expand Down Expand Up @@ -708,6 +838,38 @@ entities@^7.0.1:
resolved "https://registry.yarnpkg.com/entities/-/entities-7.0.1.tgz#26e8a88889db63417dcb9a1e79a3f1bc92b5976b"
integrity sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==

esbuild@~0.28.0:
version "0.28.1"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.28.1.tgz#ef45b4634c9c9d97a296aea4114a5f9840f95578"
integrity sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==
optionalDependencies:
"@esbuild/aix-ppc64" "0.28.1"
"@esbuild/android-arm" "0.28.1"
"@esbuild/android-arm64" "0.28.1"
"@esbuild/android-x64" "0.28.1"
"@esbuild/darwin-arm64" "0.28.1"
"@esbuild/darwin-x64" "0.28.1"
"@esbuild/freebsd-arm64" "0.28.1"
"@esbuild/freebsd-x64" "0.28.1"
"@esbuild/linux-arm" "0.28.1"
"@esbuild/linux-arm64" "0.28.1"
"@esbuild/linux-ia32" "0.28.1"
"@esbuild/linux-loong64" "0.28.1"
"@esbuild/linux-mips64el" "0.28.1"
"@esbuild/linux-ppc64" "0.28.1"
"@esbuild/linux-riscv64" "0.28.1"
"@esbuild/linux-s390x" "0.28.1"
"@esbuild/linux-x64" "0.28.1"
"@esbuild/netbsd-arm64" "0.28.1"
"@esbuild/netbsd-x64" "0.28.1"
"@esbuild/openbsd-arm64" "0.28.1"
"@esbuild/openbsd-x64" "0.28.1"
"@esbuild/openharmony-arm64" "0.28.1"
"@esbuild/sunos-x64" "0.28.1"
"@esbuild/win32-arm64" "0.28.1"
"@esbuild/win32-ia32" "0.28.1"
"@esbuild/win32-x64" "0.28.1"

escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
Expand Down Expand Up @@ -1235,6 +1397,15 @@ tslib@^2.4.0, tslib@^2.8.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f"
integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==

tsx@^4.23.4:
version "4.23.4"
resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.23.4.tgz#7e0b074f7f8105c19d389a54bac47eb1db02cf03"
integrity sha512-ZiUQ8oT/KzN51mJUWPqARYqwFLFJZtGZipRkw1ynHMr9vy3eU77m5yfF3Gzm6meEg/beW+lUu3fHYgskTN2oVQ==
dependencies:
esbuild "~0.28.0"
optionalDependencies:
fsevents "~2.3.3"

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
Expand Down
Loading