@@ -10,7 +10,7 @@ import {
1010 shouldSkipLegacyUpdateDoctorConfigWrite ,
1111} from "./doctor-health-contributions.js" ;
1212import { runDoctorLintChecks } from "./doctor-lint-flow.js" ;
13- import type { HealthCheck } from "./health-checks.js" ;
13+ import type { HealthCheck , HealthFinding } from "./health-checks.js" ;
1414
1515const mocks = vi . hoisted ( ( ) => ( {
1616 maybeRunConfiguredPluginInstallReleaseStep : vi . fn ( ) ,
@@ -83,6 +83,7 @@ const mocks = vi.hoisted(() => ({
8383 gatherDaemonStatus : vi . fn ( ) ,
8484 noteWorkspaceStatus : vi . fn ( ) ,
8585 collectWorkspaceStatusHealthFindings : vi . fn ( ) . mockResolvedValue ( [ ] ) ,
86+ collectDiskSpaceHealthFindings : vi . fn ( ( ) : readonly HealthFinding [ ] => [ ] ) ,
8687 collectDevicePairingHealthFindings : vi . fn ( async ( ) => [ ] ) ,
8788 scanConfiguredChannelPluginBlockers : vi . fn (
8889 ( ) : Array < { channelId : string ; pluginId : string ; reason : string } > => [ ] ,
@@ -297,6 +298,11 @@ vi.mock("../commands/doctor-workspace-status.js", () => ({
297298 collectWorkspaceStatusHealthFindings : mocks . collectWorkspaceStatusHealthFindings ,
298299} ) ) ;
299300
301+ vi . mock ( "../commands/doctor-disk-space.js" , ( ) => ( {
302+ noteDiskSpace : vi . fn ( ) ,
303+ collectDiskSpaceHealthFindings : mocks . collectDiskSpaceHealthFindings ,
304+ } ) ) ;
305+
300306vi . mock ( "../commands/doctor-device-pairing.js" , ( ) => ( {
301307 collectDevicePairingHealthFindings : mocks . collectDevicePairingHealthFindings ,
302308 noteDevicePairingHealth : vi . fn ( ) . mockResolvedValue ( undefined ) ,
@@ -490,6 +496,8 @@ describe("doctor health contributions", () => {
490496 mocks . noteWorkspaceStatus . mockReset ( ) ;
491497 mocks . collectWorkspaceStatusHealthFindings . mockReset ( ) ;
492498 mocks . collectWorkspaceStatusHealthFindings . mockResolvedValue ( [ ] ) ;
499+ mocks . collectDiskSpaceHealthFindings . mockReset ( ) ;
500+ mocks . collectDiskSpaceHealthFindings . mockReturnValue ( [ ] ) ;
493501 mocks . collectDevicePairingHealthFindings . mockReset ( ) ;
494502 mocks . collectDevicePairingHealthFindings . mockResolvedValue ( [ ] ) ;
495503 mocks . scanConfiguredChannelPluginBlockers . mockReset ( ) ;
@@ -1211,6 +1219,7 @@ describe("doctor health contributions", () => {
12111219 expect ( contributionIds ) . toContain ( "core/doctor/session-snapshots" ) ;
12121220 expect ( contributionIds ) . toContain ( "core/doctor/plugin-registry" ) ;
12131221 expect ( contributionIds ) . toContain ( "core/doctor/configured-plugin-installs" ) ;
1222+ expect ( contributionIds ) . toContain ( "core/doctor/disk-space" ) ;
12141223 expect ( contributionIds ) . toContain ( "core/doctor/device-pairing" ) ;
12151224 expect ( contributionIds ) . toContain ( "core/doctor/channel-plugin-blockers" ) ;
12161225 expect ( contributionIds ) . toContain ( "core/doctor/tool-result-cap" ) ;
@@ -1403,6 +1412,47 @@ describe("doctor health contributions", () => {
14031412 expect ( findings ) . toEqual ( [ ] ) ;
14041413 } ) ;
14051414
1415+ it ( "keeps disk space opt-in for default lint selection" , async ( ) => {
1416+ const contributionChecks = await resolveDoctorContributionHealthChecks ( ) ;
1417+ const diskSpaceCheck = contributionChecks . find (
1418+ ( check ) => check . id === "core/doctor/disk-space" ,
1419+ ) ;
1420+ expect ( diskSpaceCheck ) . toMatchObject ( { defaultEnabled : false } ) ;
1421+ expect ( diskSpaceCheck ) . toBeDefined ( ) ;
1422+
1423+ const ctx = {
1424+ cfg : { } ,
1425+ mode : "lint" ,
1426+ runtime : { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ,
1427+ } as const ;
1428+ const checks = [ diskSpaceCheck ! ] ;
1429+
1430+ await expect ( runDoctorLintChecks ( ctx , { checks } ) ) . resolves . toMatchObject ( {
1431+ checksRun : 0 ,
1432+ checksSkipped : 1 ,
1433+ } ) ;
1434+ expect ( mocks . collectDiskSpaceHealthFindings ) . not . toHaveBeenCalled ( ) ;
1435+
1436+ mocks . collectDiskSpaceHealthFindings . mockReturnValueOnce ( [
1437+ {
1438+ checkId : "core/doctor/disk-space" ,
1439+ severity : "warning" ,
1440+ message : "Low disk space: 300 MB free on the partition containing ~/.openclaw." ,
1441+ path : "/home/test/.openclaw" ,
1442+ requirement : "low-free-space" ,
1443+ } ,
1444+ ] ) ;
1445+
1446+ await expect (
1447+ runDoctorLintChecks ( ctx , { checks, onlyIds : [ "core/doctor/disk-space" ] } ) ,
1448+ ) . resolves . toMatchObject ( {
1449+ checksRun : 1 ,
1450+ checksSkipped : 0 ,
1451+ findings : [ expect . objectContaining ( { checkId : "core/doctor/disk-space" } ) ] ,
1452+ } ) ;
1453+ expect ( mocks . collectDiskSpaceHealthFindings ) . toHaveBeenCalledWith ( ctx . cfg ) ;
1454+ } ) ;
1455+
14061456 it ( "keeps device pairing opt-in for default lint selection" , async ( ) => {
14071457 const contributionChecks = await resolveDoctorContributionHealthChecks ( ) ;
14081458 const devicePairingCheck = contributionChecks . find (
0 commit comments