UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

4 lines • 3.68 kB
import{r as captureOpenClawStateWorkerContext}from"./openclaw-state-worker-context-Dx8YjqO2.mjs";import{a as withProjectCheckoutLifecycle,t as ProjectCheckoutBusyError}from"./project-checkout-DRqVKlFG.mjs";import{t as note}from"./note-e4DtVgg2.mjs";import{t as listProjectRegistry}from"./project-registry-CrFzyaNY.mjs";import{c as unshallowProjectCheckout,t as ProjectCloneError}from"./project-clone-runtime-COnxATMu.mjs";import path from"node:path";import fs from"node:fs/promises"; //!src/commands/doctor-project-clone-shape.ts const CHECK_ID=`core/doctor/project-clone-shape`;async function collectProjectCloneShapeHealthFindings(e,t={}){const n=t.env??process.env;const r=[];const report=e=>r.push({checkId:CHECK_ID,category:`recommended`,docsUrl:`https://docs.openclaw.ai/cli/doctor/checks`,...e});let i;try{i=(await listProjectRegistry(e,{env:n})).filter(e=>e.source===`cloned`)}catch{report({severity:`warning`,category:`fix-now`,message:`Skipped project clone inspection: the project registry is unreadable.`,fixHint:`Restore access to the project registry and rerun openclaw doctor.`});return r}for(const e of i){const r=`Project clone ${e.displayName} (${e.id})`;let i=false;try{const inspect=async t=>{const a=path.join(e.repoRoot,`.git`);if(!(await fs.readdir(a)).includes(`shallow`))return;const o=(await fs.readdir(path.join(a,`objects`,`pack`))).filter(e=>e.endsWith(`.pack`)).length;const s=o>=1e3?` ${o} packs: ask the operator to run a separate bounded repack under the project checkout lifecycle lease; Doctor does not repack.`:``;if(t){if(!e.originUrl){report({severity:`warning`,path:e.repoRoot,message:`${r}: repair skipped; the registry has no recorded repository URL. Restore the project registration before retrying.`});return}i=true;await unshallowProjectCheckout({target:e.repoRoot,url:e.originUrl},{env:n,timeoutMs:18e5,signal:t.signal,assertCurrent:()=>t.assertCurrent(),startRun:async e=>{await t.assertOwned();t.assertCurrent();return await e()}});const o=(await fs.readdir(a)).includes(`shallow`);report({severity:o?`warning`:`info`,path:e.repoRoot,message:o?`${r}: still shallow; origin may not have complete history. Restore access to a full-history origin and rerun openclaw doctor --fix.${s}`:`${r}: unshallowed; blob filtering and existing objects retained.${s}`})}else report({severity:`warning`,path:e.repoRoot,message:`${r}: shallow history can cause repeated downloads in partial clones.${s}`,fixHint:`Run openclaw doctor --fix to fetch full history while retaining blob:none.`})};if(t.repair)await withProjectCheckoutLifecycle(e.repoRoot,{context:captureOpenClawStateWorkerContext({env:n}),waitMs:0},inspect);else await inspect()}catch(t){report({severity:`warning`,category:`fix-now`,path:e.repoRoot,message:t instanceof ProjectCheckoutBusyError?`${r}: busy; skipped. Rerun openclaw doctor --fix when checkout work finishes.`:i&&t instanceof ProjectCloneError&&t.failure===`auth_required`?`${r}: unshallow requires repository authentication. Doctor has no admitted Control UI/Gateway credential and does not prompt or use checkout credential helpers. Ask the operator to run an approved authenticated unshallow under the project checkout lifecycle lease.`:i?`${r}: unshallow failed or timed out. Check origin access, network, and disk space, then rerun openclaw doctor --fix.`:`${r}: skipped; repository is missing or unreadable. Check the clone path and permissions.`})}}return r}async function noteProjectCloneShape(e,t={}){for(const n of await collectProjectCloneShapeHealthFindings(e,t))note([n.message,n.path,n.fixHint].filter(Boolean).join(` `),`Project clones`)}export{collectProjectCloneShapeHealthFindings,noteProjectCloneShape};