pi-task-tracker 0.2.1 → 0.2.3
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/README.md +2 -1
- package/index.ts +20 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,7 +75,8 @@ Optional `taskTracker` key in `~/.pi/agent/settings.json` (all default to `true`
|
|
|
75
75
|
- `todo` — maintain `TODO.md`
|
|
76
76
|
- `readme` — maintain the `README.md` project-structure section
|
|
77
77
|
- `autoCommit` — per-task commits; these are the `/rollback` checkpoints, so disabling this also disables rollback targets
|
|
78
|
-
- `
|
|
78
|
+
- `guard` — master switch for the built-in permission layer (default `true`). Set `false` to defer permission decisions entirely to another extension (e.g. `pi-permission-system`): no external-write checks, no git-ask prompts, no cd sandbox.
|
|
79
|
+
- `externalWrite` — policy for tool calls that would create/modify files OUTSIDE the session directory: `"block"` (default, hard deny — external changes cannot be tracked or rolled back), `"ask"` (per-attempt confirmation), `"off"` (no enforcement; `pi-permission-system` rules still apply). Reads stay free. Copying files FROM outside INTO the session is allowed (`cp` checks only its destination); moving/deleting external paths is blocked. Everything INSIDE the session directory passes by default — the only sandbox-internal intervention is the `cd` disable. Git history protection is **inherited**: history-rewriting git (rebase/reset/amend/force-push/clean/...) prompts for confirmation right here, so `pi-permission-system` can be uninstalled without losing that layer; routine git passes untouched, an external `git init`/`clone` is allowed with a heads-up that the new repo is not tracked. Shell commands are analyzed statically (redirects, `rm/mv/cp/touch/...`, `cd` tracking, PowerShell equivalents); git protection is inherited from `pi-permission-system` — routine git passes untouched and history-rewriting git still prompts there; only redirect targets and `-C` destinations on git segments are checked. **`cd` is free inside the session directory; a `cd` that would move the working directory outside it is blocked** (that is the one operation that changes pi's effective scope). No cd-tracking is performed — resolution baseline stays the session root, so a deep in-session `cd` followed by enough `../` levels to escape may over-block, which is the fail-safe direction.
|
|
79
80
|
|
|
80
81
|
## Requirements
|
|
81
82
|
|
package/index.ts
CHANGED
|
@@ -184,8 +184,20 @@ function guardShellExternalWrite(cmd: string, sessionCwd: string): { block?: str
|
|
|
184
184
|
const out: { block?: string; ask?: string; notify?: string } = {};
|
|
185
185
|
for (const seg of segments) {
|
|
186
186
|
if (/^(cd|sl|set-location)\s/i.test(seg)) {
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// only a cd that would move the working directory OUTSIDE the session
|
|
188
|
+
// is stopped; in-session cd is free. Resolution baseline stays
|
|
189
|
+
// sessionCwd (no cd tracking) - documented limitation: a deep in-session
|
|
190
|
+
// cd followed by enough ../ levels to escape the session may over-block,
|
|
191
|
+
// which is the fail-safe direction.
|
|
192
|
+
const arg = seg.replace(/^(cd|sl|set-location)\s+/i, "").trim();
|
|
193
|
+
if (arg) {
|
|
194
|
+
const r = guardResolve(sessionCwd, arg);
|
|
195
|
+
if (r.external) {
|
|
196
|
+
out.block = r.abs;
|
|
197
|
+
return out;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
continue;
|
|
189
201
|
}
|
|
190
202
|
// 2. redirects: > >> 2> 2>> &> &>> >| (not heredocs, not fd dups like 2>&1)
|
|
191
203
|
for (const m of seg.matchAll(/(?:^|[^<>&=(])(?:\d?>{1,2}|&>>?|>\|)\s*([^\s;&|]+)/g)) {
|
|
@@ -569,12 +581,15 @@ interface TrackerConfig {
|
|
|
569
581
|
todo: boolean;
|
|
570
582
|
readme: boolean;
|
|
571
583
|
autoCommit: boolean;
|
|
584
|
+
/** master switch for the built-in permission layer (external-write guard,
|
|
585
|
+
* git-ask inheritance, cd disable). false = defer entirely to other extensions */
|
|
586
|
+
guard: boolean;
|
|
572
587
|
/** Writes outside the session directory: "block" (default) | "ask" | "off" */
|
|
573
588
|
externalWrite: "block" | "ask" | "off";
|
|
574
589
|
}
|
|
575
590
|
|
|
576
591
|
function readConfig(): TrackerConfig {
|
|
577
|
-
const fallback: TrackerConfig = { todo: true, readme: true, autoCommit: true, externalWrite: "block" };
|
|
592
|
+
const fallback: TrackerConfig = { todo: true, readme: true, autoCommit: true, externalWrite: "block", guard: true };
|
|
578
593
|
try {
|
|
579
594
|
const dir = process.env.PI_CODING_AGENT_DIR || path.join(os.homedir(), ".pi", "agent");
|
|
580
595
|
const file = process.env.PI_TRACKER_SETTINGS || path.join(dir, "settings.json");
|
|
@@ -584,6 +599,7 @@ function readConfig(): TrackerConfig {
|
|
|
584
599
|
todo: t.todo !== false,
|
|
585
600
|
readme: t.readme !== false,
|
|
586
601
|
autoCommit: t.autoCommit !== false,
|
|
602
|
+
guard: t.guard !== false,
|
|
587
603
|
externalWrite: t.externalWrite === "ask" || t.externalWrite === "off" ? t.externalWrite : "block",
|
|
588
604
|
};
|
|
589
605
|
} catch {
|
|
@@ -671,7 +687,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
671
687
|
pi.on("tool_call", async (event, ctx) => {
|
|
672
688
|
// External-write guard: keep the writable scope equal to the trackable
|
|
673
689
|
// scope. See the "External-write guard" block above for the policy.
|
|
674
|
-
if (config.externalWrite !== "off") {
|
|
690
|
+
if (config.guard && config.externalWrite !== "off") {
|
|
675
691
|
const hit = await guardExternalWriteHit(event, cwd, config.externalWrite === "off" ? "block" : config.externalWrite, ctx);
|
|
676
692
|
if (hit) {
|
|
677
693
|
if (hit === "__ask__") return; // ask mode: user approved in guardExternalWriteHit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-task-tracker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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",
|