Skip to content

Commit 8faec8b

Browse files
committed
refactor(pi): drop isSubmitPathAllowed alias
isSubmitPathAllowed was a pure pass-through to isPlanWritePathAllowed with no plausible reason to diverge. Use the write-gate helper directly from submit_plan and drop the alias. For provenance purposes, this commit was AI assisted.
1 parent acbe8d3 commit 8faec8b

3 files changed

Lines changed: 2 additions & 24 deletions

File tree

apps/pi-extension/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import {
5252
import {
5353
getToolsForPhase,
5454
isPlanWritePathAllowed,
55-
isSubmitPathAllowed,
5655
PLAN_SUBMIT_TOOL,
5756
type Phase,
5857
stripPlanningOnlyTools,
@@ -552,7 +551,7 @@ export default function plannotator(pi: ExtensionAPI): void {
552551
};
553552
}
554553

555-
if (!isSubmitPathAllowed(inputPath, ctx.cwd)) {
554+
if (!isPlanWritePathAllowed(inputPath, ctx.cwd)) {
556555
return {
557556
content: [
558557
{

apps/pi-extension/tool-scope.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { describe, expect, test } from "bun:test";
22
import {
33
getToolsForPhase,
44
isPlanWritePathAllowed,
5-
isSubmitPathAllowed,
65
PLAN_SUBMIT_TOOL,
76
stripPlanningOnlyTools,
87
} from "./tool-scope";
@@ -87,18 +86,3 @@ describe("plan write path gate", () => {
8786
expect(isPlanWritePathAllowed("notes.MdX", cwd)).toBe(true);
8887
});
8988
});
90-
91-
describe("submit path gate", () => {
92-
const cwd = "/r";
93-
94-
test("accepts markdown paths inside cwd", () => {
95-
expect(isSubmitPathAllowed("PLAN.md", cwd)).toBe(true);
96-
expect(isSubmitPathAllowed("plans/auth.md", cwd)).toBe(true);
97-
});
98-
99-
test("rejects traversal and non-markdown", () => {
100-
expect(isSubmitPathAllowed("../escape.md", cwd)).toBe(false);
101-
expect(isSubmitPathAllowed("plan.txt", cwd)).toBe(false);
102-
expect(isSubmitPathAllowed("plans/", cwd)).toBe(false);
103-
});
104-
});

apps/pi-extension/tool-scope.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function getToolsForPhase(
2626
];
2727
}
2828

29-
// During planning, agents may write/edit any markdown file inside cwd.
29+
// Used by both the planning-phase write gate and plannotator_submit_plan.
3030
// Path must resolve inside cwd (no traversal, no absolute escape) and end
3131
// in a permitted markdown extension.
3232
export function isPlanWritePathAllowed(inputPath: string, cwd: string): boolean {
@@ -37,8 +37,3 @@ export function isPlanWritePathAllowed(inputPath: string, cwd: string): boolean
3737
const ext = extname(targetAbs).toLowerCase();
3838
return ALLOWED_PLAN_EXTENSIONS.has(ext);
3939
}
40-
41-
// Validates an agent-supplied submit_plan path. Same rules as the write gate.
42-
export function isSubmitPathAllowed(inputPath: string, cwd: string): boolean {
43-
return isPlanWritePathAllowed(inputPath, cwd);
44-
}

0 commit comments

Comments
 (0)