@@ -79,6 +79,8 @@ vi.mock("../../state/claw-package-adoption.js", () => ({
7979 markClawPackageIndependentlyOwned : markClawPackageIndependentlyOwnedMock ,
8080} ) ) ;
8181
82+ const { ClawHubRequestError } = await import ( "../../infra/clawhub-client.js" ) ;
83+
8284const {
8385 installSkillFromClawHub,
8486 preflightSkillFromClawHub,
@@ -354,6 +356,53 @@ describe("skills-clawhub", () => {
354356 } ) ;
355357 } ) ;
356358
359+ it . each ( [
360+ {
361+ name : "maps missing install resolutions to the skills-info recovery message" ,
362+ lookup : "install" ,
363+ status : 404 ,
364+ path : "/api/v1/skills/missing-skill/install" ,
365+ body : "remote not-found detail" ,
366+ expected :
367+ 'Skill "missing-skill" not found. Run `openclaw skills list` to see available skills.' ,
368+ } ,
369+ {
370+ name : "maps missing versioned skills to the skills-info recovery message" ,
371+ lookup : "detail" ,
372+ status : 404 ,
373+ path : "/custom-clawhub/api/v1/skills/missing-skill" ,
374+ body : "remote versioned not-found detail" ,
375+ expected :
376+ 'Skill "missing-skill" not found. Run `openclaw skills list` to see available skills.' ,
377+ } ,
378+ {
379+ name : "keeps server failures distinct from missing skills" ,
380+ lookup : "install" ,
381+ status : 500 ,
382+ path : "/api/v1/skills/missing-skill/install" ,
383+ body : "remote-controlled server failure" ,
384+ expected :
385+ 'ClawHub is temporarily unavailable while installing skill "missing-skill". Try again later.' ,
386+ } ,
387+ ] as const ) ( "$name" , async ( { lookup, status, path : requestPath , body, expected } ) => {
388+ const requestError = new ClawHubRequestError ( { path : requestPath , status, body } ) ;
389+ if ( lookup === "detail" ) {
390+ fetchClawHubSkillDetailMock . mockRejectedValueOnce ( requestError ) ;
391+ } else {
392+ fetchClawHubSkillInstallResolutionMock . mockRejectedValueOnce ( requestError ) ;
393+ }
394+
395+ const result = await installSkillFromClawHub ( {
396+ workspaceDir : "/tmp/workspace" ,
397+ slug : "missing-skill" ,
398+ ...( lookup === "detail" ? { version : "1.2.3" } : { } ) ,
399+ } ) ;
400+
401+ expect ( result ) . toEqual ( { ok : false , error : expected } ) ;
402+ expect ( result . ok ? "" : result . error ) . not . toContain ( "/api/v1/" ) ;
403+ expect ( result . ok ? "" : result . error ) . not . toContain ( body ) ;
404+ } ) ;
405+
357406 it ( "installs skills-sh references via a ClawHub-approved pinned GitHub commit" , async ( ) => {
358407 const commit = "a" . repeat ( 40 ) ;
359408 const reference = "skills-sh:openclaw/skills/weather" ;
@@ -1887,6 +1936,37 @@ describe("skills-clawhub", () => {
18871936 } ) ;
18881937 } ) ;
18891938
1939+ it ( "reports a tracked skill removed from ClawHub with the same recovery message" , async ( ) => {
1940+ const workspaceDir = await tempDirs . make ( "openclaw-missing-update-" ) ;
1941+ await writeClawHubOriginFixture ( {
1942+ workspaceDir,
1943+ slug : "missing-skill" ,
1944+ installedVersion : "0.9.0" ,
1945+ } ) ;
1946+ const body = "remote update not-found detail" ;
1947+ fetchClawHubSkillInstallResolutionMock . mockRejectedValueOnce (
1948+ new ClawHubRequestError ( {
1949+ path : "/clawhub/api/v1/skills/missing-skill/install" ,
1950+ status : 404 ,
1951+ body,
1952+ } ) ,
1953+ ) ;
1954+
1955+ const results = await updateSkillsFromClawHub ( {
1956+ workspaceDir,
1957+ slug : "missing-skill" ,
1958+ } ) ;
1959+
1960+ expect ( results ) . toEqual ( [
1961+ {
1962+ ok : false ,
1963+ error :
1964+ 'Skill "missing-skill" not found. Run `openclaw skills list` to see available skills.' ,
1965+ } ,
1966+ ] ) ;
1967+ expect ( results [ 0 ] ?. ok ? "" : results [ 0 ] ?. error ) . not . toContain ( body ) ;
1968+ } ) ;
1969+
18901970 it ( "updates official publisher ClawHub skills without fetching security verdicts" , async ( ) => {
18911971 const workspaceDir = await tempDirs . make ( "openclaw-official-owner-update-" ) ;
18921972 await writeClawHubOriginFixture ( {
0 commit comments