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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sa-assistant",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "description": "OpenCode plugin for AWS Solutions Architect assistant with multi-agent Guru system",
@@ -23,17 +23,12 @@ export function detectWaddKeyword(content: string): boolean {
23
23
  return WADD_PATTERN.test(content);
24
24
  }
25
25
 
26
- /**
27
- * Activates SA mode by modifying message properties
28
- * @param message - Message object to modify
29
- */
30
- export function activateSAMode(message: any): void {
31
- // Set variant to "max" for best model
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
- if (detectWaddKeyword(input.message.content)) {
45
- activateSAMode(output.message);
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
- // Check if SA mode is active by scanning message history
64
- const hasWadd = input.messages?.some((m: any) =>
65
- m.content && detectWaddKeyword(m.content)
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}`;