fix: doctor memory hint

This commit is contained in:
Peter Steinberger
2026-01-06 06:01:11 +00:00
parent f29efb9862
commit 7d896b5f67
6 changed files with 93 additions and 18 deletions

View File

@@ -289,9 +289,16 @@ export function buildProgram() {
program
.command("doctor")
.description("Health checks + quick fixes for the gateway and providers")
.action(async () => {
.option(
"--no-workspace-suggestions",
"Disable workspace memory system suggestions",
false,
)
.action(async (opts) => {
try {
await doctorCommand(defaultRuntime);
await doctorCommand(defaultRuntime, {
workspaceSuggestions: opts.workspaceSuggestions,
});
} catch (err) {
defaultRuntime.error(String(err));
defaultRuntime.exit(1);

View File

@@ -9,6 +9,7 @@ import {
DEFAULT_SANDBOX_COMMON_IMAGE,
DEFAULT_SANDBOX_IMAGE,
} from "../agents/sandbox.js";
import { DEFAULT_AGENTS_FILENAME } from "../agents/workspace.js";
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
import type { ClawdbotConfig } from "../config/config.js";
import {
@@ -128,6 +129,45 @@ async function runSandboxScript(
return true;
}
type DoctorOptions = {
workspaceSuggestions?: boolean;
};
const MEMORY_SYSTEM_PROMPT = [
"Memory system not found in workspace.",
"Paste this into your agent:",
"",
"Install the memory system by applying:",
"https://github.com/clawdbot/clawdbot/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e",
"https://github.com/clawdbot/clawdbot/commit/7d1fee70e76f2f634f1b41fca927ee663914183a",
].join("\n");
async function shouldSuggestMemorySystem(workspaceDir: string): Promise<boolean> {
const memoryPaths = [
path.join(workspaceDir, "MEMORY.md"),
path.join(workspaceDir, "memory.md"),
];
for (const memoryPath of memoryPaths) {
try {
await fs.promises.access(memoryPath);
return false;
} catch {
// keep scanning
}
}
const agentsPath = path.join(workspaceDir, DEFAULT_AGENTS_FILENAME);
try {
const content = await fs.promises.readFile(agentsPath, "utf-8");
if (/memory\.md/i.test(content)) return false;
} catch {
// no AGENTS.md or unreadable; treat as missing memory guidance
}
return true;
}
async function isDockerAvailable(): Promise<boolean> {
try {
await runExec("docker", ["version", "--format", "{{.Server.Version}}"], {
@@ -546,7 +586,10 @@ async function maybeMigrateLegacyGatewayService(
});
}
export async function doctorCommand(runtime: RuntimeEnv = defaultRuntime) {
export async function doctorCommand(
runtime: RuntimeEnv = defaultRuntime,
options: DoctorOptions = {},
) {
printWizardHeader(runtime);
intro("Clawdbot doctor");
@@ -694,5 +737,14 @@ export async function doctorCommand(runtime: RuntimeEnv = defaultRuntime) {
await writeConfigFile(cfg);
runtime.log(`Updated ${CONFIG_PATH_CLAWDBOT}`);
if (options.workspaceSuggestions !== false) {
const workspaceDir = resolveUserPath(
cfg.agent?.workspace ?? DEFAULT_WORKSPACE,
);
if (await shouldSuggestMemorySystem(workspaceDir)) {
note(MEMORY_SYSTEM_PROMPT, "Workspace");
}
}
outro("Doctor complete.");
}

View File

@@ -394,5 +394,4 @@ export type {
CronRunParams,
CronRunsParams,
CronRunLogEntry,
PollParams,
};

29
src/types/proper-lockfile.d.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
declare module "proper-lockfile" {
export type RetryOptions = {
retries?: number;
factor?: number;
minTimeout?: number;
maxTimeout?: number;
randomize?: boolean;
};
export type LockOptions = {
retries?: number | RetryOptions;
stale?: number;
update?: number;
realpath?: boolean;
};
export type ReleaseFn = () => Promise<void>;
export function lock(
path: string,
options?: LockOptions,
): Promise<ReleaseFn>;
const lockfile: {
lock: typeof lock;
};
export default lockfile;
}

View File

@@ -386,20 +386,6 @@ export async function runOnboardingWizard(
});
return String(code);
},
onManualCodeInput: isRemote
? () => {
if (!manualCodePromise) {
manualCodePromise = prompter
.text({
message: "Paste the redirect URL (or authorization code)",
validate: (value) =>
value?.trim() ? undefined : "Required",
})
.then((value) => String(value));
}
return manualCodePromise;
}
: undefined,
onProgress: (msg) => spin.update(msg),
});
spin.stop("OpenAI OAuth complete");