opencode-sa-assistant 0.2.0 → 0.2.2
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/package.json +1 -1
- package/src/hooks/wadd-mode.ts +23 -18
package/package.json
CHANGED
package/src/hooks/wadd-mode.ts
CHANGED
|
@@ -23,17 +23,12 @@ export function detectWaddKeyword(content: string): boolean {
|
|
|
23
23
|
return WADD_PATTERN.test(content);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
message.variant = "max";
|
|
33
|
-
|
|
34
|
-
// Prepend SA mode activation marker
|
|
35
|
-
// (Full orchestrator prompt will be added in Task 5)
|
|
36
|
-
message.content = `[SA MODE ACTIVATED]\n\n${message.content}`;
|
|
26
|
+
function extractPromptText(parts: any[]): string {
|
|
27
|
+
if (!parts || !Array.isArray(parts)) return "";
|
|
28
|
+
return parts
|
|
29
|
+
.filter((p: any) => p.type === "text")
|
|
30
|
+
.map((p: any) => p.text || "")
|
|
31
|
+
.join("");
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
/**
|
|
@@ -41,10 +36,12 @@ export function activateSAMode(message: any): void {
|
|
|
41
36
|
* Intercepts user messages to detect WADD keyword and activate SA mode
|
|
42
37
|
*/
|
|
43
38
|
export const chatMessageHook = async (input: any, output: any) => {
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const content = extractPromptText(output?.parts);
|
|
40
|
+
if (!content) return;
|
|
41
|
+
|
|
42
|
+
if (detectWaddKeyword(content)) {
|
|
43
|
+
output.variant = "max";
|
|
46
44
|
|
|
47
|
-
// Show toast notification if API available
|
|
48
45
|
if (output.toasts) {
|
|
49
46
|
output.toasts.push({
|
|
50
47
|
type: "info",
|
|
@@ -60,10 +57,18 @@ export const chatMessageHook = async (input: any, output: any) => {
|
|
|
60
57
|
* Injects SA orchestrator system prompt when SA mode is active
|
|
61
58
|
*/
|
|
62
59
|
export const systemTransformHook = async (input: any, output: any) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
m.
|
|
66
|
-
|
|
60
|
+
const hasWadd = input.messages?.some((m: any) => {
|
|
61
|
+
if (m.role !== "user") return false;
|
|
62
|
+
const parts = m.parts || m.content;
|
|
63
|
+
if (Array.isArray(parts)) {
|
|
64
|
+
const text = parts
|
|
65
|
+
.filter((p: any) => p.type === "text")
|
|
66
|
+
.map((p: any) => p.text || "")
|
|
67
|
+
.join("");
|
|
68
|
+
return detectWaddKeyword(text);
|
|
69
|
+
}
|
|
70
|
+
return typeof parts === "string" && detectWaddKeyword(parts);
|
|
71
|
+
});
|
|
67
72
|
|
|
68
73
|
if (hasWadd) {
|
|
69
74
|
output.system = `${output.system || ""}\n\n${SA_ORCHESTRATOR_PROMPT}`;
|