@asterxsk/kiln 0.2.0 → 0.4.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/LICENSE +21 -21
- package/README.md +4 -19
- package/agent/extensions/AGENTS.md +68 -68
- package/agent/extensions/ask-user/install.ps1 +4 -0
- package/agent/extensions/ask-user/install.sh +3 -0
- package/agent/extensions/background-terminals/install.ps1 +4 -0
- package/agent/extensions/background-terminals/install.sh +3 -0
- package/agent/extensions/destructive/install.ps1 +4 -0
- package/agent/extensions/destructive/install.sh +3 -0
- package/agent/extensions/file-search/install.ps1 +4 -0
- package/agent/extensions/file-search/install.sh +3 -0
- package/agent/extensions/goal/install.ps1 +4 -0
- package/agent/extensions/goal/install.sh +3 -0
- package/agent/extensions/herdr-agent-state.ts +257 -0
- package/agent/extensions/kiln-update/README.md +25 -0
- package/agent/extensions/kiln-update/index.ts +99 -0
- package/agent/extensions/kiln-update/install.ps1 +27 -0
- package/agent/extensions/kiln-update/install.sh +24 -0
- package/agent/extensions/modelconf/install.ps1 +4 -0
- package/agent/extensions/modelconf/install.sh +3 -0
- package/agent/extensions/shared/install.ps1 +4 -0
- package/agent/extensions/shared/install.sh +3 -0
- package/agent/extensions/skillsconf/install.ps1 +4 -0
- package/agent/extensions/skillsconf/install.sh +3 -0
- package/agent/extensions/statusline/install.ps1 +4 -0
- package/agent/extensions/statusline/install.sh +3 -0
- package/agent/extensions/subagents/install.ps1 +4 -0
- package/agent/extensions/subagents/install.sh +3 -0
- package/agent/extensions/taste/index.ts +443 -0
- package/agent/extensions/taste/install.ps1 +27 -0
- package/agent/extensions/taste/install.sh +24 -0
- package/agent/extensions/todo/install.ps1 +4 -0
- package/agent/extensions/todo/install.sh +3 -0
- package/agent/extensions/trim-context/install.ps1 +4 -0
- package/agent/extensions/trim-context/install.sh +3 -0
- package/agent/version.txt +1 -0
- package/bin/kiln.js +590 -471
- package/package.json +27 -27
- package/agent/install.ps1 +0 -637
- package/agent/install.sh +0 -620
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pi-taste — local "taste" learning, no npx / no network.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors Command Code's Taste but entirely on-disk:
|
|
5
|
+
* - Learns preferences from each completed request via the active local model.
|
|
6
|
+
* - Stores them as markdown at two scopes:
|
|
7
|
+
* Global : ~/.pi/agent/extensions/taste/taste.md (applies to ALL projects)
|
|
8
|
+
* Project: <cwd>/.pi/taste/taste.md (this codebase only)
|
|
9
|
+
* - Feeds high-confidence learnings back into the system prompt each turn.
|
|
10
|
+
*
|
|
11
|
+
* Confidence system: new learning = newConfidence (0.40); a repeat (same
|
|
12
|
+
* category + normalized text) raises confidence by repeatIncrement (0.10),
|
|
13
|
+
* capped at 0.95. Only learnings >= applyThreshold (0.60) are injected.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
17
|
+
import { CONFIG_DIR_NAME } from "@earendil-works/pi-coding-agent";
|
|
18
|
+
import { uuidv7 } from "@earendil-works/pi-ai";
|
|
19
|
+
import * as fs from "node:fs";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
import * as os from "node:os";
|
|
22
|
+
|
|
23
|
+
// ---- Paths -------------------------------------------------------------
|
|
24
|
+
// Global taste lives INSIDE this extension's folder (per user request).
|
|
25
|
+
const EXT_DIR = path.join(os.homedir(), ".pi", "agent", "extensions", "taste");
|
|
26
|
+
const GLOBAL_TASTE = path.join(EXT_DIR, "taste.md");
|
|
27
|
+
const GLOBAL_SETTINGS = path.join(EXT_DIR, "settings.json");
|
|
28
|
+
|
|
29
|
+
const projectTasteFile = (cwd: string) =>
|
|
30
|
+
path.join(cwd, CONFIG_DIR_NAME, "taste", "taste.md");
|
|
31
|
+
const projectSettingsFile = (cwd: string) =>
|
|
32
|
+
path.join(cwd, CONFIG_DIR_NAME, "taste", "settings.json");
|
|
33
|
+
|
|
34
|
+
// ---- Settings ----------------------------------------------------------
|
|
35
|
+
interface Settings {
|
|
36
|
+
learning: boolean;
|
|
37
|
+
applyThreshold: number;
|
|
38
|
+
newConfidence: number;
|
|
39
|
+
repeatIncrement: number;
|
|
40
|
+
minPromptLength: number;
|
|
41
|
+
minIntervalMs: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const DEFAULTS: Settings = {
|
|
45
|
+
learning: true,
|
|
46
|
+
applyThreshold: 0.6,
|
|
47
|
+
newConfidence: 0.4,
|
|
48
|
+
repeatIncrement: 0.1,
|
|
49
|
+
minPromptLength: 20,
|
|
50
|
+
minIntervalMs: 15000,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function loadSettings(file: string): Settings {
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(file)) {
|
|
56
|
+
return { ...DEFAULTS, ...JSON.parse(fs.readFileSync(file, "utf8")) };
|
|
57
|
+
}
|
|
58
|
+
} catch {
|
|
59
|
+
/* corrupt settings -> defaults */
|
|
60
|
+
}
|
|
61
|
+
return { ...DEFAULTS };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ---- Taste data model --------------------------------------------------
|
|
65
|
+
interface Item {
|
|
66
|
+
text: string;
|
|
67
|
+
confidence: number;
|
|
68
|
+
}
|
|
69
|
+
type Taste = Map<string, Item[]>;
|
|
70
|
+
|
|
71
|
+
const normalize = (s: string) =>
|
|
72
|
+
s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
73
|
+
|
|
74
|
+
function parseTaste(text: string): Taste {
|
|
75
|
+
const taste: Taste = new Map();
|
|
76
|
+
let category = "Other";
|
|
77
|
+
for (const line of text.split(/\r?\n/)) {
|
|
78
|
+
const h = line.match(/^#\s+(.+?)\s*$/);
|
|
79
|
+
if (h) {
|
|
80
|
+
category = h[1].trim() || "Other";
|
|
81
|
+
if (!taste.has(category)) taste.set(category, []);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const b = line.match(
|
|
85
|
+
/^-\s+(.*?)\s*\.\s*Confidence:\s*([0-9]+(?:\.[0-9]+)?)\s*$/i,
|
|
86
|
+
);
|
|
87
|
+
if (b) {
|
|
88
|
+
const items = taste.get(category) ?? [];
|
|
89
|
+
items.push({ text: b[1].trim(), confidence: parseFloat(b[2]) });
|
|
90
|
+
taste.set(category, items);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return taste;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function serializeTaste(taste: Taste): string {
|
|
97
|
+
const lines: string[] = [];
|
|
98
|
+
for (const [category, items] of taste) {
|
|
99
|
+
if (items.length === 0) continue;
|
|
100
|
+
lines.push(`# ${category}`);
|
|
101
|
+
for (const it of [...items].sort((a, b) => b.confidence - a.confidence)) {
|
|
102
|
+
lines.push(`- ${it.text}. Confidence: ${it.confidence.toFixed(2)}`);
|
|
103
|
+
}
|
|
104
|
+
lines.push("");
|
|
105
|
+
}
|
|
106
|
+
return lines.join("\n").trimEnd() + "\n";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Merge one learning; returns true if the file should be rewritten. */
|
|
110
|
+
function mergeLearning(
|
|
111
|
+
taste: Taste,
|
|
112
|
+
category: string,
|
|
113
|
+
preference: string,
|
|
114
|
+
s: Settings,
|
|
115
|
+
): boolean {
|
|
116
|
+
const cat = category.trim() || "Other";
|
|
117
|
+
const norm = normalize(preference);
|
|
118
|
+
if (!norm) return false;
|
|
119
|
+
|
|
120
|
+
const items = taste.get(cat) ?? [];
|
|
121
|
+
const existing = items.find((i) => normalize(i.text) === norm);
|
|
122
|
+
if (existing) {
|
|
123
|
+
const before = existing.confidence;
|
|
124
|
+
existing.confidence = Math.min(
|
|
125
|
+
0.95,
|
|
126
|
+
+(existing.confidence + s.repeatIncrement).toFixed(2),
|
|
127
|
+
);
|
|
128
|
+
return existing.confidence !== before;
|
|
129
|
+
}
|
|
130
|
+
items.push({ text: preference.trim(), confidence: s.newConfidence });
|
|
131
|
+
taste.set(cat, items);
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function readTaste(file: string): Taste {
|
|
136
|
+
try {
|
|
137
|
+
if (fs.existsSync(file)) return parseTaste(fs.readFileSync(file, "utf8"));
|
|
138
|
+
} catch {
|
|
139
|
+
/* unreadable -> empty */
|
|
140
|
+
}
|
|
141
|
+
return new Map();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function writeTaste(file: string, taste: Taste): void {
|
|
145
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
146
|
+
fs.writeFileSync(file, serializeTaste(taste), "utf8");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function safeDelete(file: string): void {
|
|
150
|
+
try {
|
|
151
|
+
if (fs.existsSync(file)) fs.unlinkSync(file);
|
|
152
|
+
} catch {
|
|
153
|
+
/* ignore */
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ---- Apply: build the system-prompt section ----------------------------
|
|
158
|
+
function tasteToLines(taste: Taste, threshold: number): string[] {
|
|
159
|
+
const out: string[] = [];
|
|
160
|
+
for (const [cat, items] of taste) {
|
|
161
|
+
const applied = items.filter((i) => i.confidence >= threshold);
|
|
162
|
+
if (applied.length === 0) continue;
|
|
163
|
+
out.push(`**${cat}**`);
|
|
164
|
+
for (const it of [...applied].sort((a, b) => b.confidence - a.confidence)) {
|
|
165
|
+
out.push(`- ${it.text}. (conf ${it.confidence.toFixed(2)})`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function buildTasteSection(
|
|
172
|
+
gTaste: Taste,
|
|
173
|
+
pTaste: Taste,
|
|
174
|
+
gThresh: number,
|
|
175
|
+
pThresh: number,
|
|
176
|
+
): string {
|
|
177
|
+
const gLines = tasteToLines(gTaste, gThresh);
|
|
178
|
+
const pLines = tasteToLines(pTaste, pThresh);
|
|
179
|
+
if (gLines.length === 0 && pLines.length === 0) return "";
|
|
180
|
+
|
|
181
|
+
const parts = [
|
|
182
|
+
"## Your learned taste (pi-taste)",
|
|
183
|
+
"",
|
|
184
|
+
"Preferences learned from your past requests. Follow them unless the current request clearly overrides.",
|
|
185
|
+
"",
|
|
186
|
+
];
|
|
187
|
+
if (gLines.length) {
|
|
188
|
+
parts.push("### Global preferences (all projects)");
|
|
189
|
+
parts.push(...gLines, "");
|
|
190
|
+
}
|
|
191
|
+
if (pLines.length) {
|
|
192
|
+
parts.push("### This project");
|
|
193
|
+
parts.push(...pLines, "");
|
|
194
|
+
}
|
|
195
|
+
return parts.join("\n").trimEnd();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ---- Learn: extract preferences via the active local model ------------
|
|
199
|
+
interface RawLearning {
|
|
200
|
+
category?: string;
|
|
201
|
+
preference?: string;
|
|
202
|
+
scope?: "global" | "project";
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const EXTRACT_PROMPT = `You are a coding-preference extractor. Given a user's coding request and the assistant's outcome, extract DURABLE preferences about how this user likes to work.
|
|
206
|
+
|
|
207
|
+
Rules:
|
|
208
|
+
- Extract only preferences clearly evidenced by the request or the resulting choices: tooling, libraries, language style, architecture, testing, git/commit style, documentation, or communication/format.
|
|
209
|
+
- Do NOT extract task-specific facts (file names, bug locations, one-off decisions).
|
|
210
|
+
- For each, set scope:
|
|
211
|
+
- "global" if it applies to ANY software project regardless of language/stack (e.g. "prefer pnpm", "write concise commit messages").
|
|
212
|
+
- "project" if it is specific to THIS codebase (its languages, frameworks, conventions, file layout).
|
|
213
|
+
- Choose a short category from: CLI, TypeScript, JavaScript, Python, Rust, Go, Architecture, Testing, Git, Documentation, Style, Tooling, Communication, Other.
|
|
214
|
+
|
|
215
|
+
Return ONLY minified JSON: an array of {"category":string,"preference":string,"scope":"global"|"project"}. No markdown fences, no commentary. If nothing durable, return [].`;
|
|
216
|
+
|
|
217
|
+
function parseLearnings(text: string): RawLearning[] {
|
|
218
|
+
let t = text.trim();
|
|
219
|
+
const fence = t.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
220
|
+
if (fence) t = fence[1].trim();
|
|
221
|
+
try {
|
|
222
|
+
const parsed = JSON.parse(t);
|
|
223
|
+
if (!Array.isArray(parsed)) return [];
|
|
224
|
+
return parsed
|
|
225
|
+
.filter(
|
|
226
|
+
(x) =>
|
|
227
|
+
x &&
|
|
228
|
+
typeof x.preference === "string" &&
|
|
229
|
+
x.preference.trim().length > 0,
|
|
230
|
+
)
|
|
231
|
+
.map((x) => ({
|
|
232
|
+
category: typeof x.category === "string" ? x.category : "Other",
|
|
233
|
+
preference: x.preference,
|
|
234
|
+
scope: x.scope === "global" ? "global" : "project",
|
|
235
|
+
}));
|
|
236
|
+
} catch {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function lastAssistantText(ctx: ExtensionContext): string {
|
|
242
|
+
const entries = ctx.sessionManager.getEntries();
|
|
243
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
244
|
+
const e = entries[i];
|
|
245
|
+
if (e.type === "message" && e.message?.role === "assistant") {
|
|
246
|
+
const c = e.message.content;
|
|
247
|
+
if (typeof c === "string") return c;
|
|
248
|
+
if (Array.isArray(c)) {
|
|
249
|
+
return c
|
|
250
|
+
.filter((p: any) => p?.type === "text")
|
|
251
|
+
.map((p: any) => p.text)
|
|
252
|
+
.join("\n");
|
|
253
|
+
}
|
|
254
|
+
return "";
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return "";
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function extractLearnings(
|
|
261
|
+
ctx: ExtensionContext,
|
|
262
|
+
userPrompt: string,
|
|
263
|
+
assistantText: string,
|
|
264
|
+
): Promise<RawLearning[]> {
|
|
265
|
+
if (!ctx.model) return [];
|
|
266
|
+
if (!ctx.modelRegistry.hasConfiguredAuth(ctx.model)) return [];
|
|
267
|
+
|
|
268
|
+
const context = {
|
|
269
|
+
messages: [
|
|
270
|
+
{
|
|
271
|
+
role: "user" as const,
|
|
272
|
+
content: [
|
|
273
|
+
{
|
|
274
|
+
type: "text" as const,
|
|
275
|
+
text:
|
|
276
|
+
EXTRACT_PROMPT +
|
|
277
|
+
`\n\nUSER REQUEST:\n${userPrompt}\n\nASSISTANT OUTCOME:\n${assistantText}`,
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
timestamp: Date.now(),
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
} as any;
|
|
284
|
+
|
|
285
|
+
const res = await ctx.modelRegistry.complete(ctx.model, context, {
|
|
286
|
+
reasoningEffort: "low",
|
|
287
|
+
cacheRetention: "none",
|
|
288
|
+
sessionId: uuidv7(),
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const text = res.content
|
|
292
|
+
.filter((c: any) => c.type === "text")
|
|
293
|
+
.map((c: any) => c.text)
|
|
294
|
+
.join("");
|
|
295
|
+
return parseLearnings(text);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ---- Wiring ------------------------------------------------------------
|
|
299
|
+
export default function (pi: ExtensionAPI) {
|
|
300
|
+
let lastUserPrompt = "";
|
|
301
|
+
let lastLearnAt = 0;
|
|
302
|
+
let pendingLearn: Promise<void> | null = null;
|
|
303
|
+
// True only between a genuine user `input` and that turn's `agent_settled`.
|
|
304
|
+
// Synthetic re-runs (auto-compaction, retries) emit no `input`, so this
|
|
305
|
+
// stays false and we never learn preferences from a system-generated prompt.
|
|
306
|
+
let freshInput = false;
|
|
307
|
+
|
|
308
|
+
// A genuine user submission arms learning. Extension-injected messages
|
|
309
|
+
// (source "extension") are excluded so we don't learn the taste of our own
|
|
310
|
+
// meta-prompts (e.g. review-subagent instructions).
|
|
311
|
+
pi.on("input", (event) => {
|
|
312
|
+
if (event.source !== "extension") freshInput = true;
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Apply: inject learned taste before each agent run.
|
|
316
|
+
pi.on("before_agent_start", (event, ctx) => {
|
|
317
|
+
if (freshInput) lastUserPrompt = event.prompt ?? "";
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
const gSettings = loadSettings(GLOBAL_SETTINGS);
|
|
321
|
+
const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
|
|
322
|
+
const gTaste = readTaste(GLOBAL_TASTE);
|
|
323
|
+
const pTaste = readTaste(projectTasteFile(ctx.cwd));
|
|
324
|
+
|
|
325
|
+
const section = buildTasteSection(
|
|
326
|
+
gTaste,
|
|
327
|
+
pTaste,
|
|
328
|
+
gSettings.applyThreshold,
|
|
329
|
+
pSettings.applyThreshold,
|
|
330
|
+
);
|
|
331
|
+
if (!section) return;
|
|
332
|
+
return { systemPrompt: event.systemPrompt + "\n\n" + section };
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
// Learn: after a request fully settles (no retry/compact/follow-up left).
|
|
336
|
+
pi.on("agent_settled", async (_event, ctx) => {
|
|
337
|
+
const gSettings = loadSettings(GLOBAL_SETTINGS);
|
|
338
|
+
const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
|
|
339
|
+
if (!gSettings.learning && !pSettings.learning) return;
|
|
340
|
+
if (!freshInput) return; // synthetic re-run (e.g. auto-compaction) — skip
|
|
341
|
+
freshInput = false; // this genuine turn is now being consumed
|
|
342
|
+
|
|
343
|
+
const prompt = lastUserPrompt.trim();
|
|
344
|
+
if (!prompt || prompt.length < gSettings.minPromptLength) return;
|
|
345
|
+
if (prompt.startsWith("/taste")) return; // don't learn from our own command
|
|
346
|
+
|
|
347
|
+
// Rate-limit window follows whichever scope is actually learning.
|
|
348
|
+
const interval = gSettings.learning
|
|
349
|
+
? gSettings.minIntervalMs
|
|
350
|
+
: pSettings.minIntervalMs;
|
|
351
|
+
if (Date.now() - lastLearnAt < interval) return;
|
|
352
|
+
|
|
353
|
+
const assistantText = lastAssistantText(ctx);
|
|
354
|
+
if (!assistantText) return;
|
|
355
|
+
|
|
356
|
+
const learnings = await extractLearnings(ctx, prompt, assistantText);
|
|
357
|
+
if (learnings.length === 0) return;
|
|
358
|
+
|
|
359
|
+
// Only consume the cooldown once we actually learned something.
|
|
360
|
+
lastLearnAt = Date.now();
|
|
361
|
+
|
|
362
|
+
const task = (async () => {
|
|
363
|
+
let wrote = false;
|
|
364
|
+
for (const l of learnings) {
|
|
365
|
+
const isGlobal = l.scope === "global";
|
|
366
|
+
const settings = isGlobal ? gSettings : pSettings;
|
|
367
|
+
if (!settings.learning) continue;
|
|
368
|
+
const file = isGlobal ? GLOBAL_TASTE : projectTasteFile(ctx.cwd);
|
|
369
|
+
const taste = readTaste(file);
|
|
370
|
+
if (mergeLearning(taste, l.category ?? "Other", l.preference ?? "", settings)) {
|
|
371
|
+
writeTaste(file, taste);
|
|
372
|
+
wrote = true;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (wrote && ctx.hasUI) {
|
|
376
|
+
ctx.ui.notify(
|
|
377
|
+
`TASTE learned ${learnings.length} preference(s)`,
|
|
378
|
+
"info",
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
})();
|
|
382
|
+
pendingLearn = task;
|
|
383
|
+
await task;
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// Flush any in-flight learning so it isn't lost on exit.
|
|
387
|
+
pi.on("session_shutdown", async () => {
|
|
388
|
+
if (pendingLearn) {
|
|
389
|
+
try {
|
|
390
|
+
await pendingLearn;
|
|
391
|
+
} catch {
|
|
392
|
+
/* ignore */
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// /taste — view or reset learnings.
|
|
398
|
+
pi.registerCommand("taste", {
|
|
399
|
+
description:
|
|
400
|
+
"Show or reset learned taste. Usage: /taste [reset [global|project]]",
|
|
401
|
+
handler: async (args, ctx) => {
|
|
402
|
+
const parts = args.trim().split(/\s+/).filter(Boolean);
|
|
403
|
+
if (parts[0] === "reset") {
|
|
404
|
+
const scope = parts[1];
|
|
405
|
+
if (scope === "global") {
|
|
406
|
+
safeDelete(GLOBAL_TASTE);
|
|
407
|
+
ctx.ui.notify("Cleared global taste.", "info");
|
|
408
|
+
} else if (scope === "project") {
|
|
409
|
+
safeDelete(projectTasteFile(ctx.cwd));
|
|
410
|
+
ctx.ui.notify("Cleared project taste.", "info");
|
|
411
|
+
} else if (!scope) {
|
|
412
|
+
safeDelete(GLOBAL_TASTE);
|
|
413
|
+
safeDelete(projectTasteFile(ctx.cwd));
|
|
414
|
+
ctx.ui.notify("Cleared global + project taste.", "info");
|
|
415
|
+
} else {
|
|
416
|
+
ctx.ui.notify(
|
|
417
|
+
`Unknown scope '${scope}'. Use 'global' or 'project'.`,
|
|
418
|
+
"warning",
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
const g = readTaste(GLOBAL_TASTE);
|
|
425
|
+
const p = readTaste(projectTasteFile(ctx.cwd));
|
|
426
|
+
const gSettings = loadSettings(GLOBAL_SETTINGS);
|
|
427
|
+
const pSettings = loadSettings(projectSettingsFile(ctx.cwd));
|
|
428
|
+
const count = (t: Taste) =>
|
|
429
|
+
[...t.values()].reduce((n, a) => n + a.length, 0);
|
|
430
|
+
const applied = (t: Taste, th: number) =>
|
|
431
|
+
[...t.values()].flat().filter((i) => i.confidence >= th).length;
|
|
432
|
+
|
|
433
|
+
ctx.ui.notify(
|
|
434
|
+
[
|
|
435
|
+
`TASTE — global : ${count(g)} prefs (${applied(g, gSettings.applyThreshold)} applied) → ${GLOBAL_TASTE}`,
|
|
436
|
+
`TASTE — project: ${count(p)} prefs (${applied(p, pSettings.applyThreshold)} applied) → ${projectTasteFile(ctx.cwd)}`,
|
|
437
|
+
`Run '/taste reset [global|project]' to clear.`,
|
|
438
|
+
].join("\n"),
|
|
439
|
+
"info",
|
|
440
|
+
);
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env pwsh
|
|
2
|
+
# Per-extension installer — Windows / PowerShell
|
|
3
|
+
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
|
+
$ErrorActionPreference = "Stop"
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
Remove-Item Env:\npm_config_allow_scripts -ErrorAction SilentlyContinue
|
|
8
|
+
Remove-Item Env:\NPM_CONFIG_ALLOW_SCRIPTS -ErrorAction SilentlyContinue
|
|
9
|
+
$extDir = $PSScriptRoot
|
|
10
|
+
if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
|
|
11
|
+
if (-not (Test-Path "$extDir/package.json")) {
|
|
12
|
+
Write-Host " - no package.json — skipping" -ForegroundColor DarkGray
|
|
13
|
+
exit 0
|
|
14
|
+
}
|
|
15
|
+
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
|
|
16
|
+
Write-Host " x npm not found — install Node.js 22+" -ForegroundColor Red
|
|
17
|
+
exit 1
|
|
18
|
+
}
|
|
19
|
+
if (Test-Path "$extDir/package-lock.json") {
|
|
20
|
+
Write-Host " - npm ci" -ForegroundColor DarkGray
|
|
21
|
+
npm --prefix $extDir ci --no-audit --no-fund
|
|
22
|
+
} else {
|
|
23
|
+
Write-Host " - npm install" -ForegroundColor DarkGray
|
|
24
|
+
npm --prefix $extDir install --no-audit --no-fund
|
|
25
|
+
}
|
|
26
|
+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
27
|
+
Write-Host " + done" -ForegroundColor Green
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Per-extension installer — macOS / Linux
|
|
3
|
+
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
|
+
set -eu
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
unset npm_config_allow_scripts NPM_CONFIG_ALLOW_SCRIPTS 2>/dev/null || true
|
|
8
|
+
EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
9
|
+
if [ ! -f "$EXT_DIR/package.json" ]; then
|
|
10
|
+
echo " · no package.json — skipping"
|
|
11
|
+
exit 0
|
|
12
|
+
fi
|
|
13
|
+
if ! command -v npm >/dev/null 2>&1; then
|
|
14
|
+
echo " ✖ npm not found — install Node.js 22+" >&2
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
if [ -f "$EXT_DIR/package-lock.json" ]; then
|
|
18
|
+
echo " · npm ci"
|
|
19
|
+
npm --prefix "$EXT_DIR" ci --no-audit --no-fund
|
|
20
|
+
else
|
|
21
|
+
echo " · npm install"
|
|
22
|
+
npm --prefix "$EXT_DIR" install --no-audit --no-fund
|
|
23
|
+
fi
|
|
24
|
+
echo " ✓ done"
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Per-extension installer — Windows / PowerShell
|
|
3
3
|
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
4
|
$ErrorActionPreference = "Stop"
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
Remove-Item Env:\npm_config_allow_scripts -ErrorAction SilentlyContinue
|
|
8
|
+
Remove-Item Env:\NPM_CONFIG_ALLOW_SCRIPTS -ErrorAction SilentlyContinue
|
|
5
9
|
$extDir = $PSScriptRoot
|
|
6
10
|
if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
|
|
7
11
|
if (-not (Test-Path "$extDir/package.json")) {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Per-extension installer — macOS / Linux
|
|
3
3
|
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
4
|
set -eu
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
unset npm_config_allow_scripts NPM_CONFIG_ALLOW_SCRIPTS 2>/dev/null || true
|
|
5
8
|
EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
9
|
if [ ! -f "$EXT_DIR/package.json" ]; then
|
|
7
10
|
echo " · no package.json — skipping"
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Per-extension installer — Windows / PowerShell
|
|
3
3
|
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
4
|
$ErrorActionPreference = "Stop"
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
Remove-Item Env:\npm_config_allow_scripts -ErrorAction SilentlyContinue
|
|
8
|
+
Remove-Item Env:\NPM_CONFIG_ALLOW_SCRIPTS -ErrorAction SilentlyContinue
|
|
5
9
|
$extDir = $PSScriptRoot
|
|
6
10
|
if (-not $extDir) { $extDir = Split-Path -Parent $MyInvocation.MyCommand.Path }
|
|
7
11
|
if (-not (Test-Path "$extDir/package.json")) {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Per-extension installer — macOS / Linux
|
|
3
3
|
# Installs npm dependencies for this extension. No-op if no package.json.
|
|
4
4
|
set -eu
|
|
5
|
+
# Drop npm_config_allow_scripts inherited from a parent npm/npx process:
|
|
6
|
+
# npm >=11 rejects it for project installs (EALLOWSCRIPTS). File config still applies.
|
|
7
|
+
unset npm_config_allow_scripts NPM_CONFIG_ALLOW_SCRIPTS 2>/dev/null || true
|
|
5
8
|
EXT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
9
|
if [ ! -f "$EXT_DIR/package.json" ]; then
|
|
7
10
|
echo " · no package.json — skipping"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.4.0
|