@@ -10,6 +10,15 @@ import { createCommandWorkspaceHarness } from "./commands-filesystem.test-suppor
1010import { handlePluginsCommand } from "./commands-plugins.js" ;
1111import { buildPluginsCommandParams } from "./commands.test-harness.js" ;
1212
13+ // Default-selector assertions describe a stable build; beta cases set their own identity.
14+ const coreVersion = vi . hoisted ( ( ) => ( { value : "2026.8.1" } ) ) ;
15+ vi . mock ( "../../version.js" , async ( importOriginal ) => ( {
16+ ...( await importOriginal < typeof import ( "../../version.js" ) > ( ) ) ,
17+ get VERSION ( ) {
18+ return coreVersion . value ;
19+ } ,
20+ } ) ) ;
21+
1322const {
1423 installPluginFromNpmPackArchiveMock,
1524 installPluginFromNpmSpecMock,
@@ -62,6 +71,18 @@ vi.mock("../../plugins/install-persistence.js", async (importOriginal) => ({
6271
6372const workspaceHarness = createCommandWorkspaceHarness ( "openclaw-command-plugins-install-" ) ;
6473
74+ function mockNpmPluginInstall ( pluginId : string , packageName : string , version = "1.0.0" ) : void {
75+ installPluginFromNpmSpecMock . mockResolvedValue ( {
76+ ok : true ,
77+ pluginId,
78+ targetDir : `/tmp/${ pluginId } ` ,
79+ version,
80+ extensions : [ "index.js" ] ,
81+ npmResolution : { name : packageName , version, resolvedSpec : `${ packageName } @${ version } ` } ,
82+ } ) ;
83+ persistPluginInstallMock . mockResolvedValue ( { } ) ;
84+ }
85+
6586function buildPluginsParams (
6687 commandBodyNormalized : string ,
6788 workspaceDir : string ,
@@ -126,6 +147,7 @@ function expectNonClawHubChatInstallRejected(
126147
127148describe ( "handleCommands /plugins install" , ( ) => {
128149 afterEach ( async ( ) => {
150+ coreVersion . value = "2026.8.1" ;
129151 installPluginFromNpmPackArchiveMock . mockReset ( ) ;
130152 installPluginFromNpmSpecMock . mockReset ( ) ;
131153 installPluginFromPathMock . mockReset ( ) ;
@@ -167,19 +189,7 @@ describe("handleCommands /plugins install", () => {
167189 } ,
168190 } ,
169191 } ;
170- installPluginFromNpmSpecMock . mockResolvedValue ( {
171- ok : true ,
172- pluginId : "policy-plugin" ,
173- targetDir : "/tmp/policy-plugin" ,
174- version : "1.0.0" ,
175- extensions : [ "index.js" ] ,
176- npmResolution : {
177- name : "@acme/policy-plugin" ,
178- version : "1.0.0" ,
179- resolvedSpec :
"@acme/[email protected] " , 180- } ,
181- } ) ;
182- persistPluginInstallMock . mockResolvedValue ( { } ) ;
192+ mockNpmPluginInstall ( "policy-plugin" , "@acme/policy-plugin" ) ;
183193
184194 await withTempHome ( "openclaw-command-plugins-home-" , async ( home ) => {
185195 await fs . writeFile (
@@ -222,7 +232,11 @@ describe("handleCommands /plugins install", () => {
222232 } ) ;
223233 } ) ;
224234
225- it ( "allows npm packages matched by the official catalog" , async ( ) => {
235+ it . each ( [
236+ { version : "2026.8.1" , installSpec : "@openclaw/brave-plugin" } ,
237+ { version : "2026.8.1-beta.4" , installSpec : "@openclaw/brave-plugin@beta" } ,
238+ ] ) ( "allows official catalog npm installs on core $version" , async ( { version, installSpec } ) => {
239+ coreVersion . value = version ;
226240 const policyConfig : OpenClawConfig = {
227241 commands : { text : true , plugins : true } ,
228242 plugins : { enabled : true } ,
@@ -237,19 +251,7 @@ describe("handleCommands /plugins install", () => {
237251 } ,
238252 } ,
239253 } ;
240- installPluginFromNpmSpecMock . mockResolvedValue ( {
241- ok : true ,
242- pluginId : "brave" ,
243- targetDir : "/tmp/brave" ,
244- version : "1.0.0" ,
245- extensions : [ "index.js" ] ,
246- npmResolution : {
247- name : "@openclaw/brave-plugin" ,
248- version : "1.0.0" ,
249- resolvedSpec :
"@openclaw/[email protected] " , 250- } ,
251- } ) ;
252- persistPluginInstallMock . mockResolvedValue ( { } ) ;
254+ mockNpmPluginInstall ( "brave" , "@openclaw/brave-plugin" ) ;
253255
254256 await withTempHome ( "openclaw-command-plugins-home-" , async ( home ) => {
255257 await fs . writeFile (
@@ -267,7 +269,7 @@ describe("handleCommands /plugins install", () => {
267269
268270 expect ( result ?. reply ?. text ) . toContain ( 'Installed plugin "brave"' ) ;
269271 expectObjectFields ( mockFirstObjectArg ( installPluginFromNpmSpecMock ) , {
270- spec : "@openclaw/brave-plugin" ,
272+ spec : installSpec ,
271273 config : {
272274 ...policyConfig ,
273275 agents : { entries : { main : { } } } ,
@@ -284,20 +286,12 @@ describe("handleCommands /plugins install", () => {
284286 } ) ;
285287 } ) ;
286288
287- it ( "allows npm packages matched by a bundled plugin manifest" , async ( ) => {
288- installPluginFromNpmSpecMock . mockResolvedValue ( {
289- ok : true ,
290- pluginId : "discord" ,
291- targetDir : "/tmp/discord" ,
292- version : "1.0.0" ,
293- extensions : [ "index.js" ] ,
294- npmResolution : {
295- name : "@openclaw/discord" ,
296- version : "1.0.0" ,
297- resolvedSpec :
"@openclaw/[email protected] " , 298- } ,
299- } ) ;
300- persistPluginInstallMock . mockResolvedValue ( { } ) ;
289+ it . each ( [
290+ { version : "2026.8.1" , installSpec : "@openclaw/discord" } ,
291+ { version : "2026.8.1-beta.4" , installSpec : "@openclaw/discord@beta" } ,
292+ ] ) ( "allows bundled-manifest npm installs on core $version" , async ( { version, installSpec } ) => {
293+ coreVersion . value = version ;
294+ mockNpmPluginInstall ( "discord" , "@openclaw/discord" ) ;
301295
302296 await withTempHome ( "openclaw-command-plugins-home-" , async ( ) => {
303297 const workspaceDir = await workspaceHarness . createWorkspace ( ) ;
@@ -310,7 +304,7 @@ describe("handleCommands /plugins install", () => {
310304
311305 expect ( result ?. reply ?. text ) . toContain ( 'Installed plugin "discord"' ) ;
312306 expectObjectFields ( mockFirstObjectArg ( installPluginFromNpmSpecMock ) , {
313- spec : "@openclaw/discord" ,
307+ spec : installSpec ,
314308 expectedPluginId : "discord" ,
315309 trustedSourceLinkedOfficialInstall : true ,
316310 } ) ;
@@ -346,19 +340,7 @@ describe("handleCommands /plugins install", () => {
346340 } ) ;
347341
348342 it ( "allows plugin ids matched by the official catalog" , async ( ) => {
349- installPluginFromNpmSpecMock . mockResolvedValue ( {
350- ok : true ,
351- pluginId : "wecom-openclaw-plugin" ,
352- targetDir : "/tmp/wecom-openclaw-plugin" ,
353- version : "2026.7.2" ,
354- extensions : [ "index.js" ] ,
355- npmResolution : {
356- name : "@wecom/wecom-openclaw-plugin" ,
357- version : "2026.7.2" ,
358- resolvedSpec :
"@wecom/[email protected] " , 359- } ,
360- } ) ;
361- persistPluginInstallMock . mockResolvedValue ( { } ) ;
343+ mockNpmPluginInstall ( "wecom-openclaw-plugin" , "@wecom/wecom-openclaw-plugin" , "2026.7.2" ) ;
362344
363345 await withTempHome ( "openclaw-command-plugins-home-" , async ( ) => {
364346 const workspaceDir = await workspaceHarness . createWorkspace ( ) ;
@@ -1043,46 +1025,41 @@ describe("handleCommands /plugins install", () => {
10431025 } ) ;
10441026 } ) ;
10451027
1046- it ( "allows catalog npm package chat installs with alternate selectors" , async ( ) => {
1047- installPluginFromNpmSpecMock . mockResolvedValue ( {
1048- ok : true ,
1049- pluginId : "wecom-openclaw-plugin" ,
1050- targetDir : "/tmp/wecom-openclaw-plugin" ,
1051- version : "2026.7.2" ,
1052- extensions : [ "index.js" ] ,
1053- npmResolution : {
1054- name : "@wecom/wecom-openclaw-plugin" ,
1055- version : "2026.7.2" ,
1056- resolvedSpec :
"@wecom/[email protected] " , 1057- } ,
1058- } ) ;
1059- persistPluginInstallMock . mockResolvedValue ( { } ) ;
1028+ it . each ( [
1029+ { version : "2026.8.1" , installSpec : "@wecom/wecom-openclaw-plugin@latest" } ,
1030+ { version : "2026.8.1-beta.4" , installSpec : "@wecom/wecom-openclaw-plugin@beta" } ,
1031+ ] ) (
1032+ "allows catalog npm @latest chat installs on core $version" ,
1033+ async ( { version, installSpec } ) => {
1034+ coreVersion . value = version ;
1035+ mockNpmPluginInstall ( "wecom-openclaw-plugin" , "@wecom/wecom-openclaw-plugin" , "2026.7.2" ) ;
10601036
1061- await withTempHome ( "openclaw-command-plugins-home-" , async ( ) => {
1062- const workspaceDir = await workspaceHarness . createWorkspace ( ) ;
1063- const params = buildPluginsParams (
1064- "/plugins install @wecom/wecom-openclaw-plugin@latest --accept-capabilities" ,
1065- workspaceDir ,
1066- ) ;
1067- const result = await handlePluginsCommand ( params , true ) ;
1068- if ( result === null ) {
1069- throw new Error ( "expected plugin install result" ) ;
1070- }
1071- expect ( result . reply ?. text ) . toContain ( 'Installed plugin "wecom-openclaw-plugin"' ) ;
1072- expectObjectFields ( mockFirstObjectArg ( installPluginFromNpmSpecMock ) , {
1073- spec : "@wecom/wecom-openclaw-plugin@latest" ,
1074- expectedPluginId : "wecom-openclaw-plugin" ,
1075- expectedIntegrity : undefined ,
1076- trustedSourceLinkedOfficialInstall : true ,
1077- } ) ;
1078- expectPersistedInstall ( "wecom-openclaw-plugin" , {
1079- source : "npm" ,
1080- spec : "@wecom/wecom-openclaw-plugin@latest" ,
1081- installPath : "/tmp/wecom-openclaw-plugin" ,
1082- version : "2026.7.2" ,
1083- resolvedName : "@wecom/wecom-openclaw-plugin" ,
1084- resolvedVersion : "2026.7.2" ,
1037+ await withTempHome ( "openclaw-command-plugins-home-" , async ( ) => {
1038+ const workspaceDir = await workspaceHarness . createWorkspace ( ) ;
1039+ const params = buildPluginsParams (
1040+ "/plugins install @wecom/wecom-openclaw-plugin@latest --accept-capabilities" ,
1041+ workspaceDir ,
1042+ ) ;
1043+ const result = await handlePluginsCommand ( params , true ) ;
1044+ if ( result === null ) {
1045+ throw new Error ( "expected plugin install result" ) ;
1046+ }
1047+ expect ( result . reply ?. text ) . toContain ( 'Installed plugin "wecom-openclaw-plugin"' ) ;
1048+ expectObjectFields ( mockFirstObjectArg ( installPluginFromNpmSpecMock ) , {
1049+ spec : installSpec ,
1050+ expectedPluginId : "wecom-openclaw-plugin" ,
1051+ expectedIntegrity : undefined ,
1052+ trustedSourceLinkedOfficialInstall : true ,
1053+ } ) ;
1054+ expectPersistedInstall ( "wecom-openclaw-plugin" , {
1055+ source : "npm" ,
1056+ spec : "@wecom/wecom-openclaw-plugin@latest" ,
1057+ installPath : "/tmp/wecom-openclaw-plugin" ,
1058+ version : "2026.7.2" ,
1059+ resolvedName : "@wecom/wecom-openclaw-plugin" ,
1060+ resolvedVersion : "2026.7.2" ,
1061+ } ) ;
10851062 } ) ;
1086- } ) ;
1087- } ) ;
1063+ } ,
1064+ ) ;
10881065} ) ;
0 commit comments