pi-jev-guard 0.1.2 → 0.1.4
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/package.json +1 -1
- package/src/commands.ts +44 -1
package/package.json
CHANGED
package/src/commands.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync, existsSync, statSync, realpathSync, writeFileSync, mkdirSync, chmodSync } from "node:fs";
|
|
2
2
|
import { resolve, dirname } from "node:path";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
3
4
|
import type { ExtensionAPI, ModelRegistry } from "@earendil-works/pi-coding-agent";
|
|
4
5
|
import type { JevConfig } from "./config.ts";
|
|
5
6
|
import { defaultConfigPath, expandHome, parseUpstreamRef, resolveBackend, saveConfig } from "./config.ts";
|
|
@@ -125,6 +126,37 @@ export function registerJevCommand(pi: ExtensionAPI, deps: JevCommandDeps) {
|
|
|
125
126
|
guardedAuth = "sconosciuto";
|
|
126
127
|
}
|
|
127
128
|
}
|
|
129
|
+
// Registrato? Visibile nel picker? Selezionato? — le tre domande
|
|
130
|
+
// che spiegano ogni "non lo vedo nella lista" dopo un reload.
|
|
131
|
+
let twinScope = "—";
|
|
132
|
+
if (gate.active && gate.twin) {
|
|
133
|
+
try {
|
|
134
|
+
const scoped = ctx.scopedModels ?? [];
|
|
135
|
+
if (scoped.length === 0) {
|
|
136
|
+
twinScope = "visibile (nessun filtro modelli)";
|
|
137
|
+
} else {
|
|
138
|
+
const inScope = scoped.some(
|
|
139
|
+
(s) => `${s.model.provider}/${s.model.id}` === gate.twin,
|
|
140
|
+
);
|
|
141
|
+
twinScope = inScope
|
|
142
|
+
? "visibile nel picker"
|
|
143
|
+
: "FILTRATO FUORI — abilitalo con /scoped-models";
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
twinScope = "sconosciuto";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
let currentModel = "—";
|
|
150
|
+
try {
|
|
151
|
+
const m = ctx.model as { provider?: string; id?: string } | undefined;
|
|
152
|
+
if (m?.provider && m?.id) {
|
|
153
|
+
const ref = `${m.provider}/${m.id}`;
|
|
154
|
+
currentModel =
|
|
155
|
+
gate.active && ref === gate.twin ? `${ref} (twin: enforcement attivo)` : ref;
|
|
156
|
+
}
|
|
157
|
+
} catch {
|
|
158
|
+
currentModel = "sconosciuto";
|
|
159
|
+
}
|
|
128
160
|
ctx.ui.notify(
|
|
129
161
|
[
|
|
130
162
|
`Modalità: ${cfg.mode}`,
|
|
@@ -134,6 +166,8 @@ export function registerJevCommand(pi: ExtensionAPI, deps: JevCommandDeps) {
|
|
|
134
166
|
`Policy: ${cfg.policy.revision} pass<=${cfg.policy.passMaxFlawProbability} block>=${cfg.policy.blockMinFlawProbability}`,
|
|
135
167
|
`Chiave presente: ${resolved.apiKeyPresent ? "sì" : "no"} (${resolved.keySource})`,
|
|
136
168
|
`Gate: ${gate.active ? `attivo (twin ${gate.twin}, stessa auth di ${authProvider})` : `non attivo (${gate.reason})`}`,
|
|
169
|
+
`Twin nel picker: ${twinScope}`,
|
|
170
|
+
`Modello corrente: ${currentModel}`,
|
|
137
171
|
`Ultimo upstream salvato: ${cfg.automatic.upstreamProvider}/${cfg.automatic.upstreamModel}`,
|
|
138
172
|
`Auth guarded: ${guardedAuth}`,
|
|
139
173
|
`Tool policy: ${cfg.toolsPolicy.enabled ? "attiva in automatic (bash/powershell/write/edit)" : "disattiva (config)"}`,
|
|
@@ -312,9 +346,18 @@ export function registerJevCommand(pi: ExtensionAPI, deps: JevCommandDeps) {
|
|
|
312
346
|
|
|
313
347
|
if (sub === "save-key") {
|
|
314
348
|
const cfg = deps.config();
|
|
315
|
-
|
|
349
|
+
let target = cfg.jev.apiKeyFile?.trim()
|
|
316
350
|
? expandHome(cfg.jev.apiKeyFile.trim())
|
|
317
351
|
: resolve(dirname(defaultConfigPath()), "jev-api-key.txt");
|
|
352
|
+
// Mai chiavi in tmp: dir effimera (pulizia automatica = chiave persa).
|
|
353
|
+
// Può capitare con config stantie caricate in memoria prima di un fix.
|
|
354
|
+
if (target === tmpdir() || target.startsWith(tmpdir() + "/")) {
|
|
355
|
+
ctx.ui.notify(
|
|
356
|
+
`Jev: percorso chiave sotto tmp ignorato (${target}); uso quello canonico.`,
|
|
357
|
+
"warning",
|
|
358
|
+
);
|
|
359
|
+
target = resolve(dirname(defaultConfigPath()), "jev-api-key.txt");
|
|
360
|
+
}
|
|
318
361
|
let key: string | undefined;
|
|
319
362
|
try {
|
|
320
363
|
key = await ctx.ui.input(
|