@simonfestl/husky-cli 1.22.0 ā 1.24.0
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/commands/brain.js +124 -0
- package/dist/commands/chat.js +18 -6
- package/package.json +1 -1
package/dist/commands/brain.js
CHANGED
|
@@ -539,6 +539,130 @@ brainCommand
|
|
|
539
539
|
}
|
|
540
540
|
});
|
|
541
541
|
// ============================================================================
|
|
542
|
+
// Auto-Brain: Hook Integration Commands
|
|
543
|
+
// ============================================================================
|
|
544
|
+
brainCommand
|
|
545
|
+
.command("auto-recall <prompt>")
|
|
546
|
+
.description("Automatically search brain for relevant memories based on user prompt (for hook integration)")
|
|
547
|
+
.option("-a, --agent <id>", "Agent ID", DEFAULT_AGENT)
|
|
548
|
+
.option("-l, --limit <num>", "Max results", "3")
|
|
549
|
+
.option("-m, --min-score <score>", "Minimum similarity score (0-1)", "0.6")
|
|
550
|
+
.option("--agent-type <type>", `Agent type for database selection (${AGENT_TYPES.join(", ")})`)
|
|
551
|
+
.option("--format <format>", "Output format (hint, json, markdown)", "hint")
|
|
552
|
+
.option("--quiet", "Suppress output if no results found")
|
|
553
|
+
.action(async (prompt, options) => {
|
|
554
|
+
try {
|
|
555
|
+
if (prompt.length < 10) {
|
|
556
|
+
if (!options.quiet) {
|
|
557
|
+
console.log("");
|
|
558
|
+
}
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
const validFormats = ["hint", "json", "markdown"];
|
|
562
|
+
if (!validFormats.includes(options.format)) {
|
|
563
|
+
if (options.format === "json") {
|
|
564
|
+
console.log(JSON.stringify({ success: false, error: `Invalid format. Use: ${validFormats.join(", ")}` }));
|
|
565
|
+
}
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
const limit = parseInt(options.limit, 10);
|
|
569
|
+
const minScore = parseFloat(options.minScore);
|
|
570
|
+
if (isNaN(limit) || limit < 1) {
|
|
571
|
+
if (options.format === "json") {
|
|
572
|
+
console.log(JSON.stringify({ success: false, error: "Invalid limit value" }));
|
|
573
|
+
}
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (isNaN(minScore) || minScore < 0 || minScore > 1) {
|
|
577
|
+
if (options.format === "json") {
|
|
578
|
+
console.log(JSON.stringify({ success: false, error: "min-score must be 0-1" }));
|
|
579
|
+
}
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
const brain = createBrain(options.agent, options.agentType);
|
|
583
|
+
const results = await brain.recall(prompt, limit, minScore);
|
|
584
|
+
if (results.length === 0) {
|
|
585
|
+
if (!options.quiet) {
|
|
586
|
+
console.log("");
|
|
587
|
+
}
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
if (options.format === "json") {
|
|
591
|
+
console.log(JSON.stringify({ success: true, results }));
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const truncate = (text, maxLen) => {
|
|
595
|
+
return text.length > maxLen ? `${text.slice(0, maxLen)}...` : text;
|
|
596
|
+
};
|
|
597
|
+
if (options.format === "markdown") {
|
|
598
|
+
console.log("\n## š§ Brain Recall - Relevante Erinnerungen\n");
|
|
599
|
+
for (const r of results) {
|
|
600
|
+
const tags = r.memory.tags.length > 0 ? ` (Tags: ${r.memory.tags.join(", ")})` : "";
|
|
601
|
+
console.log(`- **[${(r.score * 100).toFixed(0)}%]** ${truncate(r.memory.content, 150)}${tags}`);
|
|
602
|
+
}
|
|
603
|
+
console.log("");
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
console.log("\nš§ BRAIN RECALL - Relevante Erinnerungen:");
|
|
607
|
+
console.log("ā".repeat(50));
|
|
608
|
+
for (const r of results) {
|
|
609
|
+
const tags = r.memory.tags.length > 0 ? ` [${r.memory.tags.join(", ")}]` : "";
|
|
610
|
+
console.log(` [${(r.score * 100).toFixed(0)}%] ${truncate(r.memory.content, 120)}${tags}`);
|
|
611
|
+
}
|
|
612
|
+
console.log("ā".repeat(50));
|
|
613
|
+
console.log("");
|
|
614
|
+
}
|
|
615
|
+
catch {
|
|
616
|
+
if (options.format === "json") {
|
|
617
|
+
console.log(JSON.stringify({ success: false, error: "recall failed" }));
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
brainCommand
|
|
622
|
+
.command("auto-remember <content>")
|
|
623
|
+
.description("Automatically store a learning/insight (for hook integration after task completion)")
|
|
624
|
+
.option("-a, --agent <id>", "Agent ID", DEFAULT_AGENT)
|
|
625
|
+
.option("--agent-type <type>", `Agent type for database selection (${AGENT_TYPES.join(", ")})`)
|
|
626
|
+
.option("--task-id <id>", "Associated task ID")
|
|
627
|
+
.option("-t, --tags <tags>", "Comma-separated tags", "auto-learning")
|
|
628
|
+
.option("--source <source>", "Source of learning (task, conversation, tool)", "task")
|
|
629
|
+
.option("--json", "Output as JSON")
|
|
630
|
+
.action(async (content, options) => {
|
|
631
|
+
try {
|
|
632
|
+
if (content.length < 20) {
|
|
633
|
+
if (options.json) {
|
|
634
|
+
console.log(JSON.stringify({ success: false, error: "Content too short" }));
|
|
635
|
+
}
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
const brain = createBrain(options.agent, options.agentType);
|
|
639
|
+
const tags = options.tags.split(",").map((t) => t.trim());
|
|
640
|
+
if (options.source && !tags.includes(options.source)) {
|
|
641
|
+
tags.push(options.source);
|
|
642
|
+
}
|
|
643
|
+
if (options.taskId) {
|
|
644
|
+
tags.push(`task:${options.taskId}`);
|
|
645
|
+
}
|
|
646
|
+
const id = await brain.remember(content, tags, {
|
|
647
|
+
source: options.source,
|
|
648
|
+
taskId: options.taskId,
|
|
649
|
+
autoGenerated: true,
|
|
650
|
+
timestamp: new Date().toISOString(),
|
|
651
|
+
}, 'private', false);
|
|
652
|
+
if (options.json) {
|
|
653
|
+
console.log(JSON.stringify({ success: true, id, tags }));
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
console.log(` ā Auto-Remember: ${id.slice(0, 8)}... [${tags.join(", ")}]`);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch {
|
|
660
|
+
if (options.json) {
|
|
661
|
+
console.log(JSON.stringify({ success: false, error: "remember failed" }));
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
// ============================================================================
|
|
542
666
|
// Knowledge Base Commands
|
|
543
667
|
// ============================================================================
|
|
544
668
|
brainCommand
|
package/dist/commands/chat.js
CHANGED
|
@@ -100,6 +100,8 @@ chatCommand
|
|
|
100
100
|
.command("send <message>")
|
|
101
101
|
.description("Send a message as supervisor")
|
|
102
102
|
.option("--task-id <id>", "Link to a specific task")
|
|
103
|
+
.option("--dm <user>", "Send as direct message to user")
|
|
104
|
+
.option("--space <name>", "Target Google Chat space (e.g., spaces/ABC123)")
|
|
103
105
|
.action(async (message, options) => {
|
|
104
106
|
const config = getConfig();
|
|
105
107
|
if (!config.apiUrl) {
|
|
@@ -107,21 +109,31 @@ chatCommand
|
|
|
107
109
|
process.exit(1);
|
|
108
110
|
}
|
|
109
111
|
try {
|
|
110
|
-
|
|
112
|
+
let endpoint = `${config.apiUrl}/api/chat/supervisor`;
|
|
113
|
+
let payload = {
|
|
114
|
+
content: message,
|
|
115
|
+
...(options.taskId && { taskId: options.taskId }),
|
|
116
|
+
};
|
|
117
|
+
// If --space is provided, use Google Chat API instead
|
|
118
|
+
if (options.space) {
|
|
119
|
+
endpoint = `${config.apiUrl}/api/google-chat/send`;
|
|
120
|
+
payload = {
|
|
121
|
+
text: message,
|
|
122
|
+
spaceName: options.space,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const res = await fetch(endpoint, {
|
|
111
126
|
method: "POST",
|
|
112
127
|
headers: {
|
|
113
128
|
"Content-Type": "application/json",
|
|
114
129
|
...(config.apiKey ? { "x-api-key": config.apiKey } : {}),
|
|
115
130
|
},
|
|
116
|
-
body: JSON.stringify(
|
|
117
|
-
content: message,
|
|
118
|
-
taskId: options.taskId,
|
|
119
|
-
}),
|
|
131
|
+
body: JSON.stringify(payload),
|
|
120
132
|
});
|
|
121
133
|
if (!res.ok) {
|
|
122
134
|
throw new Error(`API error: ${res.status}`);
|
|
123
135
|
}
|
|
124
|
-
console.log("Message sent.");
|
|
136
|
+
console.log(options.space ? "ā
Message sent to Google Chat." : "Message sent.");
|
|
125
137
|
}
|
|
126
138
|
catch (error) {
|
|
127
139
|
console.error("Error sending message:", error);
|