@@ -8,6 +8,11 @@ import type { PluginManifestRecord } from "./manifest-registry.js";
88
99const mocks = vi . hoisted ( ( ) => ( {
1010 plugins : [ ] as PluginManifestRecord [ ] ,
11+ warn : vi . fn ( ) ,
12+ } ) ) ;
13+
14+ vi . mock ( "../logging/subsystem.js" , ( ) => ( {
15+ createSubsystemLogger : ( ) => ( { warn : mocks . warn } ) ,
1116} ) ) ;
1217
1318vi . mock ( "./manifest-registry.js" , ( ) => ( {
@@ -36,6 +41,7 @@ const tempDirs: string[] = [];
3641
3742afterEach ( async ( ) => {
3843 mocks . plugins = [ ] ;
44+ mocks . warn . mockReset ( ) ;
3945 await Promise . all ( tempDirs . splice ( 0 ) . map ( ( dir ) => fs . rm ( dir , { recursive : true , force : true } ) ) ) ;
4046} ) ;
4147
@@ -225,11 +231,10 @@ describe("loadEnabledClaudeBundleCommands", () => {
225231 ) ;
226232 } ) ;
227233
228- it ( "skips oversized bundle command markdown files exceeding 1 MB and continues loading siblings" , async ( ) => {
234+ it ( "warns and skips oversized bundle commands without dropping siblings" , async ( ) => {
229235 const homeDir = await createTempDir ( "openclaw-bundle-commands-oversized-" ) ;
230236 const workspaceDir = await createTempDir ( "openclaw-bundle-commands-oversized-ws-" ) ;
231237
232- // Write a normal command file alongside an oversized one
233238 await writeClaudeBundleCommandFixture ( {
234239 homeDir,
235240 pluginId : "oversized-test" ,
@@ -246,38 +251,25 @@ describe("loadEnabledClaudeBundleCommands", () => {
246251 ] ,
247252 } ) ;
248253
249- // Create the oversized command file (> 1 MB) alongside the normal one
250254 const pluginRoot = resolveBundlePluginRoot ( homeDir , "oversized-test" ) ;
251255 const oversizedFilePath = path . join ( pluginRoot , "commands" , "oversized.md" ) ;
252256 await fs . mkdir ( path . dirname ( oversizedFilePath ) , { recursive : true } ) ;
253257 const oversizedContent = Buffer . alloc ( 1 * 1024 * 1024 + 1 , "x" ) ;
254258 await fs . writeFile ( oversizedFilePath , oversizedContent ) ;
255259
256- // Suppress console.warn for this test
257- const warnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
258-
259- try {
260- const commands = loadEnabledClaudeBundleCommands ( {
261- workspaceDir,
262- cfg : {
263- plugins : {
264- entries : { "oversized-test" : { enabled : true } } ,
265- } ,
260+ const commands = loadEnabledClaudeBundleCommands ( {
261+ workspaceDir,
262+ cfg : {
263+ plugins : {
264+ entries : { "oversized-test" : { enabled : true } } ,
266265 } ,
267- } ) ;
268-
269- // Normal command still loads
270- const names = commands . map ( ( entry ) => entry . rawName ) ;
271- expect ( names ) . toContain ( "normal" ) ;
272- expect ( names ) . not . toContain ( "oversized" ) ;
266+ } ,
267+ } ) ;
273268
274- // console.warn was called with the oversized file path
275- expect ( warnSpy ) . toHaveBeenCalledWith (
276- expect . stringContaining ( "[bundle-commands]" ) ,
277- expect . any ( String ) ,
278- ) ;
279- } finally {
280- warnSpy . mockRestore ( ) ;
281- }
269+ expect ( commands . map ( ( entry ) => entry . rawName ) ) . toEqual ( [ "normal" ] ) ;
270+ expect ( mocks . warn ) . toHaveBeenCalledOnce ( ) ;
271+ const warning = String ( mocks . warn . mock . calls [ 0 ] ?. [ 0 ] ) ;
272+ expect ( warning ) . toContain ( oversizedFilePath ) ;
273+ expect ( warning ) . toContain ( "1048576" ) ;
282274 } ) ;
283275} ) ;
0 commit comments