pi-agents-switch 0.2.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/types.ts ADDED
@@ -0,0 +1,151 @@
1
+ /** Key identifier string for keybindings like "f9" or "ctrl+shift+a" */
2
+ export type KeyId = string;
3
+
4
+ export type ThinkingLevel =
5
+ | "off"
6
+ | "minimal"
7
+ | "low"
8
+ | "medium"
9
+ | "high"
10
+ | "xhigh";
11
+
12
+ // ─── YAML Frontmatter (parsed from AGENTS.md) ─────────────
13
+
14
+ /**
15
+ * Metadata parsed from the YAML frontmatter block in an agent's AGENTS.md.
16
+ * The body of the markdown (after the closing `---`) is the system prompt.
17
+ */
18
+ export interface AgentFrontmatter {
19
+ /** Display name (e.g. "📋 Plan", "🐛 Debug") */
20
+ name?: string;
21
+ /** Short description shown in picker */
22
+ description?: string;
23
+ /** Provider name (e.g. "anthropic", "openai") */
24
+ provider?: string;
25
+ /** Model ID (e.g. "claude-sonnet-4-5") */
26
+ model?: string;
27
+ /** Thinking level for this agent */
28
+ thinkingLevel?: ThinkingLevel;
29
+
30
+ // ── Inference parameters ──
31
+ /** Temperature (0-2). Controls randomness. Lower = more deterministic. */
32
+ temperature?: number;
33
+ /** Top-p sampling (0-1). Nucleus sampling threshold. */
34
+ topP?: number;
35
+
36
+ // ── Tool lists ──
37
+ /**
38
+ * Tools to ADD (after inheritance from PI).
39
+ * Last-write-wins: if `tools` and `excluded_tools` both declare
40
+ * the same tool, the key that appears later in the YAML wins.
41
+ * `"*"` wildcard in `excluded_tools` matches all tools.
42
+ */
43
+ tools?: string[];
44
+ /**
45
+ * Tools to REMOVE (from PI's inherited set). Supports `"*"` wildcard.
46
+ */
47
+ excluded_tools?: string[];
48
+
49
+ // ── Extension lists ──
50
+ /** Extensions to ADD. */
51
+ extensions?: string[];
52
+ /**
53
+ * Extensions to REMOVE (from PI's inherited set). Supports `"*"` wildcard.
54
+ * Preferred over deprecated `noextensions`.
55
+ */
56
+ excluded_extensions?: string[];
57
+ /** @deprecated Use `excluded_extensions` instead. Still recognized for backward compat. */
58
+ noextensions?: string[];
59
+
60
+ // ── Skill lists ──
61
+ /** Skills to ADD. */
62
+ skills?: string[];
63
+ /**
64
+ * Skills to REMOVE (from PI's inherited set). Supports `"*"` wildcard.
65
+ * Preferred over deprecated `noskills`.
66
+ */
67
+ excluded_skills?: string[];
68
+ /** @deprecated Use `excluded_skills` instead. Still recognized for backward compat. */
69
+ noskills?: string[];
70
+ }
71
+
72
+ // ─── Frontmatter parse result ──────────────────────────────
73
+
74
+ export interface FrontmatterResult {
75
+ frontmatter: AgentFrontmatter;
76
+ body: string;
77
+ /**
78
+ * Ordered list of top-level YAML keys as they appear in the file.
79
+ * Used for last-write-wins conflict resolution between `tools`/`excluded_tools`,
80
+ * `extensions`/`excluded_extensions`/`noextensions`, etc.
81
+ */
82
+ keyOrder: string[];
83
+ }
84
+
85
+ // ─── Resolved Agent Config (after inheritance + fallback) ─
86
+
87
+ /**
88
+ * Fully resolved agent configuration after applying the fallback chain
89
+ * (agent → project → pi default) and inheritance rules.
90
+ */
91
+ export interface ResolvedAgentConfig {
92
+ /** Agent name (directory name) */
93
+ name: string;
94
+ /** Display name */
95
+ label: string;
96
+ /** Short description */
97
+ description: string;
98
+ /** Provider/model string (e.g. "anthropic/claude-sonnet-4-5") or undefined */
99
+ model?: string;
100
+ /** Thinking level */
101
+ thinkingLevel?: ThinkingLevel;
102
+ /** Temperature for inference */
103
+ temperature?: number;
104
+ /** Top-p sampling */
105
+ topP?: number;
106
+ /** The system prompt (AGENTS.md body) */
107
+ systemPrompt: string;
108
+ /** Resolved tools for this agent */
109
+ tools: string[];
110
+ /** Resolved extensions for this agent (from agent-specific folder) */
111
+ extensionPaths: string[];
112
+ /** Resolved skills for this agent (from agent-specific folder) */
113
+ skillPaths: string[];
114
+ /** Source of this agent (path to AGENTS.md used) */
115
+ sourcePath: string;
116
+ /** Whether this agent exists on disk */
117
+ exists: boolean;
118
+ }
119
+
120
+ // ─── Simplified Global Config ──────────────────────────────
121
+
122
+ /**
123
+ * Global config stored in ~/.pi/agent/agents-switch.json.
124
+ * Only tracks hotkey and which agent is active.
125
+ * Agent definitions are discovered from the filesystem.
126
+ */
127
+ export interface AgentsConfig {
128
+ version: 1;
129
+ /** Key string like "f9" or "ctrl+shift+a" */
130
+ hotkey?: KeyId;
131
+ /** Which agent is currently active ("PI" or a custom agent name) */
132
+ active?: string;
133
+ }
134
+
135
+ // ─── Disk Profile ──────────────────────────────────────────
136
+
137
+ /** Info about an agent profile directory discovered on disk. */
138
+ export interface AgentDiskProfile {
139
+ /** Agent name (directory name) */
140
+ name: string;
141
+ /** Absolute path to the agent directory */
142
+ path: string;
143
+ /** Has an AGENTS.md file */
144
+ hasAgentsMd: boolean;
145
+ /** Has an extensions/ subdirectory */
146
+ hasExtensions: boolean;
147
+ /** Has a skills/ subdirectory */
148
+ hasSkills: boolean;
149
+ /** Agent source scope */
150
+ source: "user" | "project";
151
+ }