Skip to content

Commit 0be57cc

Browse files
committed
feat(claude-code): simplify prompt, configure dynamic granularity, warn about cwd
- Set dynamicBankId=true and dynamicBankGranularity=["agent", "project"] in plugin config (or fail if user has conflicting config) - Simplify the prompt to just "/hindsight-memory:create-agent <name> from <path>" (the skill knows how to handle the SDA layout) - Warn user that the agent's memory is scoped to cwd at session start
1 parent ac57fb9 commit 0be57cc

12 files changed

Lines changed: 4341 additions & 14 deletions

File tree

src/cli.ts

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -985,16 +985,45 @@ async function main() {
985985
const claudeConfig = await promptClaudeConfig(agentId);
986986
ccConfig.hindsightApiUrl = claudeConfig.apiUrl;
987987
ccConfig.hindsightApiToken = claudeConfig.apiToken;
988-
ccConfig.enableKnowledgeTools = true;
989-
mkdirSync(ccConfigDir, { recursive: true });
990-
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
991-
p.log.success(`Hindsight connection saved to ${color.dim(ccConfigPath)}`);
992-
} else if (!ccConfig.enableKnowledgeTools) {
993-
ccConfig.enableKnowledgeTools = true;
994-
mkdirSync(ccConfigDir, { recursive: true });
995-
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
996988
}
997989

990+
// Verify/set bank granularity. SDA agents need per-project isolation —
991+
// bank derived as agentName::projectBasename. If the user has a conflicting
992+
// config (dynamicBankId: false with a static bankId), bail with instructions.
993+
if (ccConfig.dynamicBankId === false && ccConfig.bankId) {
994+
p.cancel(
995+
`Conflicting plugin config in ${ccConfigPath}:\n` +
996+
` Found: dynamicBankId=false, bankId="${ccConfig.bankId}"\n` +
997+
` Self-driving agents need dynamicBankId=true with granularity ["agent", "project"].\n` +
998+
` Remove "dynamicBankId" and "bankId" from the config, or set them to:\n` +
999+
` "dynamicBankId": true,\n` +
1000+
` "dynamicBankGranularity": ["agent", "project"]`
1001+
);
1002+
process.exit(1);
1003+
}
1004+
1005+
const expectedGranularity = ["agent", "project"];
1006+
const currentGranularity = ccConfig.dynamicBankGranularity;
1007+
if (
1008+
currentGranularity &&
1009+
JSON.stringify(currentGranularity) !== JSON.stringify(expectedGranularity)
1010+
) {
1011+
p.cancel(
1012+
`Conflicting plugin config in ${ccConfigPath}:\n` +
1013+
` Found: dynamicBankGranularity=${JSON.stringify(currentGranularity)}\n` +
1014+
` Self-driving agents require: ${JSON.stringify(expectedGranularity)}\n` +
1015+
` Update the config to match, or remove the field to let the installer set it.`
1016+
);
1017+
process.exit(1);
1018+
}
1019+
1020+
ccConfig.dynamicBankId = true;
1021+
ccConfig.dynamicBankGranularity = expectedGranularity;
1022+
ccConfig.enableKnowledgeTools = true;
1023+
mkdirSync(ccConfigDir, { recursive: true });
1024+
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
1025+
p.log.success(`Plugin config: ${color.dim(ccConfigPath)}`);
1026+
9981027
// Step 4: Save content locally for the agent
9991028
const contentDir = join(homedir(), ".self-driving-agents", "claude-code", agentId);
10001029
mkdirSync(contentDir, { recursive: true });
@@ -1042,15 +1071,16 @@ async function main() {
10421071
p.log.success("Auto-approved hindsight tools in Claude Code");
10431072
}
10441073

1045-
const hasBankTemplate = existsSync(join(contentDir, "bank-template.json"));
1046-
const prompt = hasBankTemplate
1047-
? `Use /hindsight-memory:create-agent to create a "${agentId}" agent. Then ingest all files from ${contentDir}/ (skip bank-template.json). Read ${contentDir}/bank-template.json and create the exact mental models (knowledge pages) defined in its "mental_models" array using agent_knowledge_create_page for each one.`
1048-
: `Use /hindsight-memory:create-agent to create a "${agentId}" agent. Then ingest all files from ${contentDir}/ and create 3 knowledge pages that make sense based on the content.`;
1074+
const prompt = `/hindsight-memory:create-agent ${agentId} from ${contentDir}`;
10491075

10501076
p.note(
10511077
[
1052-
`${color.dim("1.")} Start Claude Code`,
1053-
`${color.dim("2.")} Say: ${color.cyan(prompt)}`,
1078+
`${color.yellow("⚠")} ${color.bold(`Important:`)} the agent's memory is scoped to the directory where you start ${color.cyan("claude")}.`,
1079+
` Always start your Claude Code sessions from the same project directory.`,
1080+
``,
1081+
`${color.dim("1.")} ${color.cyan("cd")} into your project directory`,
1082+
`${color.dim("2.")} Run: ${color.cyan("claude")}`,
1083+
`${color.dim("3.")} Say: ${color.cyan(prompt)}`,
10541084
].join("\n"),
10551085
"Next steps"
10561086
);

website/next.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
14
/** @type {import('next').NextConfig} */
25

36
// Static export so the site can deploy to GitHub Pages, S3, Vercel, anywhere.
47
// basePath is empty by default for `npm run dev` and Vercel; set
58
// SITE_BASE=/self-driving-agents in CI for GitHub Pages.
69
const SITE_BASE = process.env.SITE_BASE || '';
710

11+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
12+
813
const nextConfig = {
914
output: 'export',
1015
basePath: SITE_BASE || undefined,
@@ -15,6 +20,8 @@ const nextConfig = {
1520
env: {
1621
NEXT_PUBLIC_BASE_PATH: SITE_BASE,
1722
},
23+
// Pin the workspace root so Next doesn't get confused by ancestor lockfiles.
24+
outputFileTracingRoot: __dirname,
1825
};
1926

2027
export default nextConfig;

0 commit comments

Comments
 (0)