pi-agents-switch 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/index.ts +27 -12
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -760,20 +760,35 @@ export default function agentsSwitch(pi: ExtensionAPI) {
760
760
  if (currentResolved && currentResolved.skillNames.length > 0) {
761
761
  const loadedSkills = (event.systemPromptOptions as { skills?: any[] })
762
762
  .skills;
763
- let selectedSkills: Array<{
764
- name: string;
765
- description: string;
766
- filePath: string;
767
- }>;
768
-
769
- if (loadedSkills && loadedSkills.length > 0) {
770
- selectedSkills = loadedSkills.filter((s) =>
771
- currentResolved!.skillNames.includes(s.name),
772
- );
773
- } else {
774
- selectedSkills = pm.getSkillObjects(currentResolved.skillNames);
763
+ const skillMap = new Map<
764
+ string,
765
+ { name: string; description: string; filePath: string }
766
+ >();
767
+
768
+ // Collect from Pi's loaded skills first (richest data)
769
+ if (loadedSkills) {
770
+ for (const s of loadedSkills) {
771
+ skillMap.set(s.name, {
772
+ name: s.name,
773
+ description: s.description ?? "",
774
+ filePath: s.filePath ?? "",
775
+ });
776
+ }
775
777
  }
776
778
 
779
+ // Fill gaps from disk (agent-specific skills not in Pi's loaded list)
780
+ for (const name of currentResolved.skillNames) {
781
+ if (!skillMap.has(name)) {
782
+ const found = pm.getSkillObjects([name]);
783
+ if (found.length > 0) skillMap.set(found[0].name, found[0]);
784
+ }
785
+ }
786
+
787
+ // Filter to only resolved names, preserving order
788
+ const selectedSkills = currentResolved.skillNames
789
+ .map((name) => skillMap.get(name))
790
+ .filter((s): s is NonNullable<typeof s> => s != null);
791
+
777
792
  if (selectedSkills.length > 0) {
778
793
  const skillsBlock = formatSkillsBlock(selectedSkills);
779
794
  const currentDateMarker = "\nCurrent date:";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agents-switch",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Tab to switch primary agents in Pi — like OpenCode's agent switching. Each agent gets an isolated profile with its own AGENTS.md, extensions, skills, and settings.",
5
5
  "type": "module",
6
6
  "pi": {