@preapexis/pi-kit 1.0.0 → 1.0.7
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/.github/workflows/publish.yml +30 -30
- package/LICENSE +15 -15
- package/README.md +373 -370
- package/extensions/brand-ui.ts +107 -107
- package/extensions/sound-cues.ts +88 -88
- package/extensions/update.ts +245 -245
- package/extensions/usage-tracker.ts +154 -154
- package/package.json +6 -2
- package/prompts/init.md +98 -98
- package/settings.json +4 -4
- package/skills/component-implementation/SKILL.md +80 -80
- package/skills/frontend-onboarding/SKILL.md +76 -76
- package/skills/frontend-quality/SKILL.md +85 -85
- package/skills/safe-coding/SKILL.md +48 -48
- package/themes/latte-review.json +77 -77
- package/themes/neon-guardian.json +77 -77
- package/themes/safe-dark.json +75 -75
- package/themes/tokyo-midnight.json +77 -77
package/extensions/update.ts
CHANGED
|
@@ -1,245 +1,245 @@
|
|
|
1
|
-
// cSpell:words Varun Gaikwad preapexis npm PowerShell
|
|
2
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
|
|
4
|
-
type EventContext = Parameters<Parameters<ExtensionAPI["on"]>[1]>[1];
|
|
5
|
-
|
|
6
|
-
type UpdateOption = {
|
|
7
|
-
id: string;
|
|
8
|
-
label: string;
|
|
9
|
-
shell: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ShellCommand = {
|
|
13
|
-
command: string;
|
|
14
|
-
args: string[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const RUN_CHOICE = "▶ Run selected updates";
|
|
18
|
-
const CANCEL_CHOICE = "✕ Cancel";
|
|
19
|
-
|
|
20
|
-
export default function (pi: ExtensionAPI): void {
|
|
21
|
-
const options: UpdateOption[] = [
|
|
22
|
-
{
|
|
23
|
-
id: "pi",
|
|
24
|
-
label: "Update Pi CLI globally",
|
|
25
|
-
shell:
|
|
26
|
-
"npm install -g --ignore-scripts @earendil-works/pi-coding-agent@latest"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: "kit-local",
|
|
30
|
-
label: "Re-link this local PreApeXis kit",
|
|
31
|
-
shell: "pi install -l ."
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: "kit-github",
|
|
35
|
-
label: "Update PreApeXis Pi Kit from GitHub",
|
|
36
|
-
shell: "pi install git:github.com/VarunGaikwad/preapexis-pi-kit@master"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: "kit-npm",
|
|
40
|
-
label: "Update PreApeXis Pi Kit from npm",
|
|
41
|
-
shell: "pi install npm:preapexis-pi-kit"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "project-npm",
|
|
45
|
-
label: "Update current project npm packages",
|
|
46
|
-
shell: "npm update"
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
function shellCommand(command: string): ShellCommand {
|
|
51
|
-
if (process.platform === "win32") {
|
|
52
|
-
return {
|
|
53
|
-
command: "cmd",
|
|
54
|
-
args: ["/d", "/s", "/c", command]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
command: "sh",
|
|
60
|
-
args: ["-lc", command]
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function optionLabel(
|
|
65
|
-
option: UpdateOption,
|
|
66
|
-
selected: Map<string, UpdateOption>
|
|
67
|
-
): string {
|
|
68
|
-
const marker = selected.has(option.id) ? "✓" : "×";
|
|
69
|
-
return `${marker} ${option.label}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function selectedSummary(selected: UpdateOption[]): string {
|
|
73
|
-
if (selected.length === 0) {
|
|
74
|
-
return "Selected: none";
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return ["Selected:", ...selected.map((option) => `- ${option.label}`)].join(
|
|
78
|
-
"\n"
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function buildMenu(selected: Map<string, UpdateOption>): {
|
|
83
|
-
items: string[];
|
|
84
|
-
optionByMenuItem: Map<string, UpdateOption>;
|
|
85
|
-
} {
|
|
86
|
-
const optionByMenuItem = new Map<string, UpdateOption>();
|
|
87
|
-
|
|
88
|
-
const optionItems = options.map((option) => {
|
|
89
|
-
const label = optionLabel(option, selected);
|
|
90
|
-
optionByMenuItem.set(label, option);
|
|
91
|
-
return label;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
items: [...optionItems, RUN_CHOICE, CANCEL_CHOICE],
|
|
96
|
-
optionByMenuItem
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function chooseUpdates(ctx: EventContext): Promise<UpdateOption[]> {
|
|
101
|
-
const selected = new Map<string, UpdateOption>();
|
|
102
|
-
|
|
103
|
-
while (true) {
|
|
104
|
-
const { items, optionByMenuItem } = buildMenu(selected);
|
|
105
|
-
|
|
106
|
-
const choice = await ctx.ui.select(
|
|
107
|
-
[
|
|
108
|
-
"What do you want to update?",
|
|
109
|
-
"",
|
|
110
|
-
"Pick an item to toggle it.",
|
|
111
|
-
"✓ = selected, × = not selected",
|
|
112
|
-
"",
|
|
113
|
-
selectedSummary([...selected.values()])
|
|
114
|
-
].join("\n"),
|
|
115
|
-
items
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
if (!choice || choice === CANCEL_CHOICE) {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (choice === RUN_CHOICE) {
|
|
123
|
-
if (selected.size === 0) {
|
|
124
|
-
ctx.ui.notify("Select at least one update first.", "warning");
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return [...selected.values()];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const option = optionByMenuItem.get(choice);
|
|
132
|
-
|
|
133
|
-
if (!option) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (selected.has(option.id)) {
|
|
138
|
-
selected.delete(option.id);
|
|
139
|
-
ctx.ui.notify(`Removed: ${option.label}`, "info");
|
|
140
|
-
} else {
|
|
141
|
-
selected.set(option.id, option);
|
|
142
|
-
ctx.ui.notify(`Added: ${option.label}`, "info");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
async function runUpdate(
|
|
148
|
-
option: UpdateOption,
|
|
149
|
-
ctx: EventContext
|
|
150
|
-
): Promise<boolean> {
|
|
151
|
-
ctx.ui.notify(`Running update:\n\n${option.shell}`, "info");
|
|
152
|
-
|
|
153
|
-
const shell = shellCommand(option.shell);
|
|
154
|
-
|
|
155
|
-
const result = await pi.exec(shell.command, shell.args, {
|
|
156
|
-
cwd: ctx.cwd
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const stdout = result.stdout?.trim() ?? "";
|
|
160
|
-
const stderr = result.stderr?.trim() ?? "";
|
|
161
|
-
const output = [stdout, stderr].filter(Boolean).join("\n\n");
|
|
162
|
-
|
|
163
|
-
if (result.code === 0) {
|
|
164
|
-
ctx.ui.notify(
|
|
165
|
-
[`Update completed: ${option.label}`, "", output || "No output."].join(
|
|
166
|
-
"\n"
|
|
167
|
-
),
|
|
168
|
-
"info"
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
ctx.ui.notify(
|
|
175
|
-
[
|
|
176
|
-
`Update failed: ${option.label}`,
|
|
177
|
-
"",
|
|
178
|
-
`Command: ${option.shell}`,
|
|
179
|
-
`Exit code: ${result.code}`,
|
|
180
|
-
"",
|
|
181
|
-
output ||
|
|
182
|
-
"No output captured. Try running this command manually in PowerShell."
|
|
183
|
-
].join("\n"),
|
|
184
|
-
"error"
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
pi.registerCommand("update", {
|
|
191
|
-
description: "Update Pi, this Pi kit, or project packages",
|
|
192
|
-
handler: async (_args, ctx) => {
|
|
193
|
-
if (!ctx.hasUI) {
|
|
194
|
-
console.log("The /update command requires the Pi UI.");
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const selected = await chooseUpdates(ctx);
|
|
199
|
-
|
|
200
|
-
if (selected.length === 0) {
|
|
201
|
-
ctx.ui.notify("Update cancelled.", "info");
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const summary = selected
|
|
206
|
-
.map((option) => `- ${option.label}\n ${option.shell}`)
|
|
207
|
-
.join("\n");
|
|
208
|
-
|
|
209
|
-
const ok = await ctx.ui.confirm(
|
|
210
|
-
"Confirm updates",
|
|
211
|
-
`The following updates will run:\n\n${summary}\n\nContinue?`
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
if (!ok) {
|
|
215
|
-
ctx.ui.notify("Update cancelled.", "info");
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
let passed = 0;
|
|
220
|
-
let failed = 0;
|
|
221
|
-
|
|
222
|
-
for (const option of selected) {
|
|
223
|
-
const updateOk = await runUpdate(option, ctx);
|
|
224
|
-
|
|
225
|
-
if (updateOk) {
|
|
226
|
-
passed += 1;
|
|
227
|
-
} else {
|
|
228
|
-
failed += 1;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
ctx.ui.notify(
|
|
233
|
-
[
|
|
234
|
-
"Update finished.",
|
|
235
|
-
"",
|
|
236
|
-
`Passed: ${passed}`,
|
|
237
|
-
`Failed: ${failed}`,
|
|
238
|
-
"",
|
|
239
|
-
"Run /reload or restart Pi if needed."
|
|
240
|
-
].join("\n"),
|
|
241
|
-
failed > 0 ? "warning" : "info"
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
1
|
+
// cSpell:words Varun Gaikwad preapexis npm PowerShell
|
|
2
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
type EventContext = Parameters<Parameters<ExtensionAPI["on"]>[1]>[1];
|
|
5
|
+
|
|
6
|
+
type UpdateOption = {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
shell: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type ShellCommand = {
|
|
13
|
+
command: string;
|
|
14
|
+
args: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const RUN_CHOICE = "▶ Run selected updates";
|
|
18
|
+
const CANCEL_CHOICE = "✕ Cancel";
|
|
19
|
+
|
|
20
|
+
export default function (pi: ExtensionAPI): void {
|
|
21
|
+
const options: UpdateOption[] = [
|
|
22
|
+
{
|
|
23
|
+
id: "pi",
|
|
24
|
+
label: "Update Pi CLI globally",
|
|
25
|
+
shell:
|
|
26
|
+
"npm install -g --ignore-scripts @earendil-works/pi-coding-agent@latest"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "kit-local",
|
|
30
|
+
label: "Re-link this local PreApeXis kit",
|
|
31
|
+
shell: "pi install -l ."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "kit-github",
|
|
35
|
+
label: "Update PreApeXis Pi Kit from GitHub",
|
|
36
|
+
shell: "pi install git:github.com/VarunGaikwad/preapexis-pi-kit@master"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "kit-npm",
|
|
40
|
+
label: "Update PreApeXis Pi Kit from npm",
|
|
41
|
+
shell: "pi install npm:preapexis-pi-kit"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "project-npm",
|
|
45
|
+
label: "Update current project npm packages",
|
|
46
|
+
shell: "npm update"
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
function shellCommand(command: string): ShellCommand {
|
|
51
|
+
if (process.platform === "win32") {
|
|
52
|
+
return {
|
|
53
|
+
command: "cmd",
|
|
54
|
+
args: ["/d", "/s", "/c", command]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
command: "sh",
|
|
60
|
+
args: ["-lc", command]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function optionLabel(
|
|
65
|
+
option: UpdateOption,
|
|
66
|
+
selected: Map<string, UpdateOption>
|
|
67
|
+
): string {
|
|
68
|
+
const marker = selected.has(option.id) ? "✓" : "×";
|
|
69
|
+
return `${marker} ${option.label}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function selectedSummary(selected: UpdateOption[]): string {
|
|
73
|
+
if (selected.length === 0) {
|
|
74
|
+
return "Selected: none";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return ["Selected:", ...selected.map((option) => `- ${option.label}`)].join(
|
|
78
|
+
"\n"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function buildMenu(selected: Map<string, UpdateOption>): {
|
|
83
|
+
items: string[];
|
|
84
|
+
optionByMenuItem: Map<string, UpdateOption>;
|
|
85
|
+
} {
|
|
86
|
+
const optionByMenuItem = new Map<string, UpdateOption>();
|
|
87
|
+
|
|
88
|
+
const optionItems = options.map((option) => {
|
|
89
|
+
const label = optionLabel(option, selected);
|
|
90
|
+
optionByMenuItem.set(label, option);
|
|
91
|
+
return label;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
items: [...optionItems, RUN_CHOICE, CANCEL_CHOICE],
|
|
96
|
+
optionByMenuItem
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function chooseUpdates(ctx: EventContext): Promise<UpdateOption[]> {
|
|
101
|
+
const selected = new Map<string, UpdateOption>();
|
|
102
|
+
|
|
103
|
+
while (true) {
|
|
104
|
+
const { items, optionByMenuItem } = buildMenu(selected);
|
|
105
|
+
|
|
106
|
+
const choice = await ctx.ui.select(
|
|
107
|
+
[
|
|
108
|
+
"What do you want to update?",
|
|
109
|
+
"",
|
|
110
|
+
"Pick an item to toggle it.",
|
|
111
|
+
"✓ = selected, × = not selected",
|
|
112
|
+
"",
|
|
113
|
+
selectedSummary([...selected.values()])
|
|
114
|
+
].join("\n"),
|
|
115
|
+
items
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (!choice || choice === CANCEL_CHOICE) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (choice === RUN_CHOICE) {
|
|
123
|
+
if (selected.size === 0) {
|
|
124
|
+
ctx.ui.notify("Select at least one update first.", "warning");
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return [...selected.values()];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const option = optionByMenuItem.get(choice);
|
|
132
|
+
|
|
133
|
+
if (!option) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (selected.has(option.id)) {
|
|
138
|
+
selected.delete(option.id);
|
|
139
|
+
ctx.ui.notify(`Removed: ${option.label}`, "info");
|
|
140
|
+
} else {
|
|
141
|
+
selected.set(option.id, option);
|
|
142
|
+
ctx.ui.notify(`Added: ${option.label}`, "info");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function runUpdate(
|
|
148
|
+
option: UpdateOption,
|
|
149
|
+
ctx: EventContext
|
|
150
|
+
): Promise<boolean> {
|
|
151
|
+
ctx.ui.notify(`Running update:\n\n${option.shell}`, "info");
|
|
152
|
+
|
|
153
|
+
const shell = shellCommand(option.shell);
|
|
154
|
+
|
|
155
|
+
const result = await pi.exec(shell.command, shell.args, {
|
|
156
|
+
cwd: ctx.cwd
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const stdout = result.stdout?.trim() ?? "";
|
|
160
|
+
const stderr = result.stderr?.trim() ?? "";
|
|
161
|
+
const output = [stdout, stderr].filter(Boolean).join("\n\n");
|
|
162
|
+
|
|
163
|
+
if (result.code === 0) {
|
|
164
|
+
ctx.ui.notify(
|
|
165
|
+
[`Update completed: ${option.label}`, "", output || "No output."].join(
|
|
166
|
+
"\n"
|
|
167
|
+
),
|
|
168
|
+
"info"
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
ctx.ui.notify(
|
|
175
|
+
[
|
|
176
|
+
`Update failed: ${option.label}`,
|
|
177
|
+
"",
|
|
178
|
+
`Command: ${option.shell}`,
|
|
179
|
+
`Exit code: ${result.code}`,
|
|
180
|
+
"",
|
|
181
|
+
output ||
|
|
182
|
+
"No output captured. Try running this command manually in PowerShell."
|
|
183
|
+
].join("\n"),
|
|
184
|
+
"error"
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
pi.registerCommand("update", {
|
|
191
|
+
description: "Update Pi, this Pi kit, or project packages",
|
|
192
|
+
handler: async (_args, ctx) => {
|
|
193
|
+
if (!ctx.hasUI) {
|
|
194
|
+
console.log("The /update command requires the Pi UI.");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const selected = await chooseUpdates(ctx);
|
|
199
|
+
|
|
200
|
+
if (selected.length === 0) {
|
|
201
|
+
ctx.ui.notify("Update cancelled.", "info");
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const summary = selected
|
|
206
|
+
.map((option) => `- ${option.label}\n ${option.shell}`)
|
|
207
|
+
.join("\n");
|
|
208
|
+
|
|
209
|
+
const ok = await ctx.ui.confirm(
|
|
210
|
+
"Confirm updates",
|
|
211
|
+
`The following updates will run:\n\n${summary}\n\nContinue?`
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
if (!ok) {
|
|
215
|
+
ctx.ui.notify("Update cancelled.", "info");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let passed = 0;
|
|
220
|
+
let failed = 0;
|
|
221
|
+
|
|
222
|
+
for (const option of selected) {
|
|
223
|
+
const updateOk = await runUpdate(option, ctx);
|
|
224
|
+
|
|
225
|
+
if (updateOk) {
|
|
226
|
+
passed += 1;
|
|
227
|
+
} else {
|
|
228
|
+
failed += 1;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
ctx.ui.notify(
|
|
233
|
+
[
|
|
234
|
+
"Update finished.",
|
|
235
|
+
"",
|
|
236
|
+
`Passed: ${passed}`,
|
|
237
|
+
`Failed: ${failed}`,
|
|
238
|
+
"",
|
|
239
|
+
"Run /reload or restart Pi if needed."
|
|
240
|
+
].join("\n"),
|
|
241
|
+
failed > 0 ? "warning" : "info"
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|