@sage-protocol/pi-adapter 0.3.4 → 0.3.5
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/extensions/index.ts +16 -5
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -98,15 +98,26 @@ class SageWidgetState {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
/** Extract skill keys from Sage suggestion output.
|
|
101
|
+
/** Extract skill keys from Sage suggestion output.
|
|
102
|
+
*
|
|
103
|
+
* Handles two output formats:
|
|
104
|
+
* 1. Codex (-prefixed): "- code-audit" or "- code-audit (code-audit)"
|
|
105
|
+
* 2. Content (headers): "# Skill: code-audit (from zenith)"
|
|
106
|
+
*/
|
|
102
107
|
function parseSuggestionKeys(text: string): string[] {
|
|
103
108
|
const keys: string[] = [];
|
|
104
109
|
for (const line of text.split('\n')) {
|
|
105
110
|
const trimmed = line.trim();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
// Codex format: "- key" or "- key (key)" or "- key - desc"
|
|
112
|
+
if (trimmed.startsWith('-')) {
|
|
113
|
+
const m = trimmed.match(/^-\s+(\S+?)(?:\s+\(|$|\s+-)/);
|
|
114
|
+
if (m) { keys.push(m[1]); continue; }
|
|
115
|
+
}
|
|
116
|
+
// Content format: "# Skill: name (from library)" or "# Prompt: name (from ...)"
|
|
117
|
+
if (trimmed.startsWith('#') && /\b(?:Skill|Prompt|Behavior):/i.test(trimmed)) {
|
|
118
|
+
const m = trimmed.match(/^#\s+(?:Skill|Prompt|Behavior):\s+(\S+?)(?:\s+\(from|$)/i);
|
|
119
|
+
if (m) keys.push(m[1]);
|
|
120
|
+
}
|
|
110
121
|
}
|
|
111
122
|
return keys;
|
|
112
123
|
}
|