@vectorize-io/self-driving-agents 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +83 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -809,7 +809,89 @@ async function main() {
|
|
|
809
809
|
apiToken = claudeConfig.apiToken;
|
|
810
810
|
}
|
|
811
811
|
else if (harness === "claude-code") {
|
|
812
|
-
//
|
|
812
|
+
// Step 1: Ensure Claude Code CLI is available
|
|
813
|
+
try {
|
|
814
|
+
execSync("which claude", { stdio: "pipe" });
|
|
815
|
+
}
|
|
816
|
+
catch {
|
|
817
|
+
p.cancel("Claude Code CLI not found. Install it:\n npm install -g @anthropic-ai/claude-code");
|
|
818
|
+
process.exit(1);
|
|
819
|
+
}
|
|
820
|
+
// Step 2: Ensure marketplace + plugin installed
|
|
821
|
+
const MARKETPLACE_REPO = "vectorize-io/hindsight";
|
|
822
|
+
const MARKETPLACE_NAME = "vectorize-io-hindsight";
|
|
823
|
+
const PLUGIN_NAME = "hindsight-memory";
|
|
824
|
+
let hasMarketplace = false;
|
|
825
|
+
try {
|
|
826
|
+
const out = execSync("claude plugin marketplace list", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
827
|
+
hasMarketplace = out.includes(MARKETPLACE_NAME) || out.includes(MARKETPLACE_REPO);
|
|
828
|
+
}
|
|
829
|
+
catch { /* ignore */ }
|
|
830
|
+
if (!hasMarketplace) {
|
|
831
|
+
p.log.info("Adding Hindsight marketplace...");
|
|
832
|
+
try {
|
|
833
|
+
execSync(`claude plugin marketplace add ${MARKETPLACE_REPO}`, { stdio: "inherit" });
|
|
834
|
+
p.log.success("Marketplace added");
|
|
835
|
+
}
|
|
836
|
+
catch (err) {
|
|
837
|
+
const msg = err?.stderr?.toString?.()?.trim() || err?.message || String(err);
|
|
838
|
+
if (!msg.includes("already")) {
|
|
839
|
+
p.log.warn(`Failed to add marketplace: ${msg}`);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
let pluginInstalled = false;
|
|
844
|
+
try {
|
|
845
|
+
const out = execSync("claude plugin list", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
846
|
+
pluginInstalled = out.includes(PLUGIN_NAME);
|
|
847
|
+
}
|
|
848
|
+
catch { /* ignore */ }
|
|
849
|
+
if (!pluginInstalled) {
|
|
850
|
+
p.log.info("Installing hindsight-memory plugin...");
|
|
851
|
+
try {
|
|
852
|
+
execSync(`claude plugin install ${PLUGIN_NAME}@${MARKETPLACE_NAME}`, { stdio: "inherit" });
|
|
853
|
+
p.log.success("Plugin installed");
|
|
854
|
+
}
|
|
855
|
+
catch (err) {
|
|
856
|
+
const msg = err?.stderr?.toString?.()?.trim() || err?.message || String(err);
|
|
857
|
+
p.log.warn(`Failed to install plugin: ${msg}`);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
else {
|
|
861
|
+
// Update to latest
|
|
862
|
+
p.log.info("Updating hindsight-memory plugin...");
|
|
863
|
+
try {
|
|
864
|
+
execSync(`claude plugin update ${PLUGIN_NAME}@${MARKETPLACE_NAME}`, { stdio: "pipe" });
|
|
865
|
+
p.log.success("Plugin up to date");
|
|
866
|
+
}
|
|
867
|
+
catch { /* ignore */ }
|
|
868
|
+
}
|
|
869
|
+
// Step 3: Configure Hindsight connection in ~/.hindsight/claude-code.json
|
|
870
|
+
const ccConfigDir = join(homedir(), ".hindsight");
|
|
871
|
+
const ccConfigPath = join(ccConfigDir, "claude-code.json");
|
|
872
|
+
let ccConfig = {};
|
|
873
|
+
if (existsSync(ccConfigPath)) {
|
|
874
|
+
try {
|
|
875
|
+
ccConfig = JSON.parse(readFileSync(ccConfigPath, "utf-8"));
|
|
876
|
+
}
|
|
877
|
+
catch { /* ignore */ }
|
|
878
|
+
}
|
|
879
|
+
const hasConnection = ccConfig.hindsightApiUrl || ccConfig.llmProvider;
|
|
880
|
+
if (!hasConnection && process.stdin.isTTY) {
|
|
881
|
+
const claudeConfig = await promptClaudeConfig(agentId);
|
|
882
|
+
ccConfig.hindsightApiUrl = claudeConfig.apiUrl;
|
|
883
|
+
ccConfig.hindsightApiToken = claudeConfig.apiToken;
|
|
884
|
+
ccConfig.enableKnowledgeTools = true;
|
|
885
|
+
mkdirSync(ccConfigDir, { recursive: true });
|
|
886
|
+
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
|
|
887
|
+
p.log.success(`Hindsight connection saved to ${color.dim(ccConfigPath)}`);
|
|
888
|
+
}
|
|
889
|
+
else if (!ccConfig.enableKnowledgeTools) {
|
|
890
|
+
ccConfig.enableKnowledgeTools = true;
|
|
891
|
+
mkdirSync(ccConfigDir, { recursive: true });
|
|
892
|
+
writeFileSync(ccConfigPath, JSON.stringify(ccConfig, null, 2) + "\n");
|
|
893
|
+
}
|
|
894
|
+
// Step 4: Save content locally for the agent
|
|
813
895
|
const contentDir = join(homedir(), ".self-driving-agents", "claude-code", agentId);
|
|
814
896
|
mkdirSync(contentDir, { recursive: true });
|
|
815
897
|
// Copy content files to the local dir
|