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

@@ -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.");
}