pi-task-tracker 0.2.5 → 0.2.6
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/index.ts +16 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -290,7 +290,7 @@ const GUARD_ASK_PROMPT = "pi-task-tracker external-write guard";
|
|
|
290
290
|
async function guardExternalWriteHit(
|
|
291
291
|
event: { toolName: string; input?: unknown },
|
|
292
292
|
sessionCwd: string,
|
|
293
|
-
mode: "block" | "ask",
|
|
293
|
+
mode: "block" | "ask" | "warn",
|
|
294
294
|
ctx?: { hasUI?: boolean; ui?: { confirm: (t: string, m: string) => Promise<boolean>; notify: (m: string, kind?: string) => void } }
|
|
295
295
|
): Promise<string | null> {
|
|
296
296
|
if (!sessionCwd) return null;
|
|
@@ -313,6 +313,12 @@ async function guardExternalWriteHit(
|
|
|
313
313
|
}
|
|
314
314
|
if (hit.block) {
|
|
315
315
|
const why = "External changes cannot be tracked or rolled back by pi-task-tracker.";
|
|
316
|
+
if (mode === "warn") {
|
|
317
|
+
if (ctx?.hasUI && ctx.ui) {
|
|
318
|
+
ctx.ui.notify(`pi-task-tracker: command writes to '${hit.block}' outside the session directory. ${why}`, "warning");
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
316
322
|
if (mode === "ask") {
|
|
317
323
|
if (!ctx?.hasUI || !ctx.ui) return `pi-task-tracker scope guard: '${hit.block}' is outside the session directory and no UI is available. ${why}`;
|
|
318
324
|
const ok = await ctx.ui.confirm(
|
|
@@ -335,6 +341,12 @@ async function guardExternalWriteHit(
|
|
|
335
341
|
if (!isWriteish && (GUARD_READ_TOOLS.has(toolName) || coveredByGuardHeuristics(toolName))) return null;
|
|
336
342
|
if (!isExternalAbs2(sessionCwd, p)) return null;
|
|
337
343
|
const why = "External changes cannot be tracked or rolled back by pi-task-tracker.";
|
|
344
|
+
if (mode === "warn") {
|
|
345
|
+
if (ctx?.hasUI && ctx.ui) {
|
|
346
|
+
ctx.ui.notify(`pi-task-tracker: '${toolName}' targets '${p}' outside the session directory. ${why}`, "warning");
|
|
347
|
+
}
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
338
350
|
if (mode === "ask") {
|
|
339
351
|
if (!ctx?.hasUI || !ctx.ui) return `pi-task-tracker scope guard: '${p}' is outside the session directory and no UI is available to approve external writes. ${why}`;
|
|
340
352
|
const ok = await ctx.ui.confirm(
|
|
@@ -599,8 +611,8 @@ interface TrackerConfig {
|
|
|
599
611
|
/** master switch for the built-in permission layer (external-write guard,
|
|
600
612
|
* git-ask inheritance, cd disable). false = defer entirely to other extensions */
|
|
601
613
|
guard: boolean;
|
|
602
|
-
/** Writes outside the session directory: "
|
|
603
|
-
externalWrite: "block" | "ask" | "off";
|
|
614
|
+
/** Writes outside the session directory: "ask" (default) | "warn" (allow + yellow notice) | "block" | "off" */
|
|
615
|
+
externalWrite: "block" | "ask" | "warn" | "off";
|
|
604
616
|
}
|
|
605
617
|
|
|
606
618
|
function readConfig(): TrackerConfig {
|
|
@@ -615,7 +627,7 @@ function readConfig(): TrackerConfig {
|
|
|
615
627
|
readme: t.readme !== false,
|
|
616
628
|
autoCommit: t.autoCommit !== false,
|
|
617
629
|
guard: t.guard !== false,
|
|
618
|
-
externalWrite: t.externalWrite === "block" || t.externalWrite === "off" ? t.externalWrite : "ask",
|
|
630
|
+
externalWrite: t.externalWrite === "block" || t.externalWrite === "off" || t.externalWrite === "warn" ? t.externalWrite : "ask",
|
|
619
631
|
};
|
|
620
632
|
} catch {
|
|
621
633
|
return fallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-task-tracker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Task workflow tracking for the pi coding agent: TODO/README maintenance, per-task git auto-commits as checkpoints, and an interactive /rollback. Hashline-aware, nested-repo aware, subagent-artifact-safe.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|