@geminixiang/pi-simplify 0.1.2 → 0.1.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/CHANGELOG.md +7 -0
- package/package.json +2 -10
- package/src/code-smell/workflow.ts +7 -1
- package/src/repository-path.ts +19 -0
- package/src/simplify/workflow.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.3] - 2026-09-07
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Move repository-relative path validation from tool-schema regex lookaheads to runtime checks for better provider compatibility in `/simplify` and `/code-smell`.
|
|
14
|
+
- Reject absolute paths and parent-directory traversal using either forward slashes or backslashes.
|
|
15
|
+
|
|
9
16
|
## [0.1.2] - 2026-07-26
|
|
10
17
|
|
|
11
18
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geminixiang/pi-simplify",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Simplify: Review changed code for reuse, quality, and efficiency",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -13,19 +13,11 @@
|
|
|
13
13
|
"directory": "packages/pi-simplify"
|
|
14
14
|
},
|
|
15
15
|
"main": "index.ts",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"lint": "oxlint",
|
|
18
|
-
"lint:fix": "oxlint --fix",
|
|
19
|
-
"fmt": "oxfmt",
|
|
20
|
-
"fmt:check": "oxfmt --check"
|
|
21
|
-
},
|
|
22
16
|
"devDependencies": {
|
|
23
17
|
"@earendil-works/pi-coding-agent": "^0.82.1",
|
|
24
18
|
"@earendil-works/pi-tui": "^0.82.1",
|
|
25
|
-
"oxfmt": "^0.45.0",
|
|
26
|
-
"oxlint": "^1.60.0",
|
|
27
19
|
"typebox": "^1.1.38",
|
|
28
|
-
"typescript": "
|
|
20
|
+
"typescript": "7.0.2"
|
|
29
21
|
},
|
|
30
22
|
"peerDependencies": {
|
|
31
23
|
"@earendil-works/pi-coding-agent": "*",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import { Container, SelectList, Text, type SelectItem } from "@earendil-works/pi-tui";
|
|
10
10
|
import { Type } from "typebox";
|
|
11
11
|
|
|
12
|
+
import { assertRepositoryRelativePaths } from "../repository-path.js";
|
|
12
13
|
import { runProgrammaticChecks } from "./checks.js";
|
|
13
14
|
import { CODE_SMELL_PROMPT } from "./prompt.js";
|
|
14
15
|
import { showFindingSelector } from "./selector.js";
|
|
@@ -164,7 +165,10 @@ function registerFindingsTool(
|
|
|
164
165
|
category: categorySchema,
|
|
165
166
|
severity: severitySchema,
|
|
166
167
|
confidence: confidenceSchema,
|
|
167
|
-
file: Type.String({
|
|
168
|
+
file: Type.String({
|
|
169
|
+
description: "Repository-relative path without '..' segments",
|
|
170
|
+
minLength: 1,
|
|
171
|
+
}),
|
|
168
172
|
lines: Type.String(),
|
|
169
173
|
smell: Type.String({ minLength: 1 }),
|
|
170
174
|
evidence: Type.String({ minLength: 1 }),
|
|
@@ -176,6 +180,8 @@ function registerFindingsTool(
|
|
|
176
180
|
}),
|
|
177
181
|
async execute(_toolCallId, params) {
|
|
178
182
|
const findings: CodeSmellFinding[] = params.findings;
|
|
183
|
+
assertRepositoryRelativePaths(findings.map((finding) => finding.file));
|
|
184
|
+
|
|
179
185
|
const resolve = state.getResolver();
|
|
180
186
|
if (!resolve) {
|
|
181
187
|
return {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function isRepositoryRelativePath(file: string): boolean {
|
|
2
|
+
const normalized = file.replaceAll("\\", "/");
|
|
3
|
+
|
|
4
|
+
return (
|
|
5
|
+
file.length > 0 &&
|
|
6
|
+
!normalized.startsWith("/") &&
|
|
7
|
+
!/^[A-Za-z]:\//.test(normalized) &&
|
|
8
|
+
!normalized.split("/").includes("..")
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function assertRepositoryRelativePaths(files: string[]): void {
|
|
13
|
+
const invalidFiles = files.filter((file) => !isRepositoryRelativePath(file));
|
|
14
|
+
if (invalidFiles.length === 0) return;
|
|
15
|
+
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Expected repository-relative file paths without '..' segments; received: ${invalidFiles.join(", ")}`,
|
|
18
|
+
);
|
|
19
|
+
}
|
package/src/simplify/workflow.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { Container, SelectList, Text, type SelectItem } from "@earendil-works/pi-tui";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
10
|
|
|
11
|
+
import { assertRepositoryRelativePaths } from "../repository-path.js";
|
|
11
12
|
import { SIMPLIFY_PROMPT } from "./prompt.js";
|
|
12
13
|
import { showCandidateSelector } from "./selector.js";
|
|
13
14
|
import type { SimplifyResult } from "./types.js";
|
|
@@ -124,9 +125,8 @@ function registerSimplifyCandidatesTool(
|
|
|
124
125
|
category: categorySchema,
|
|
125
126
|
risk: riskSchema,
|
|
126
127
|
file: Type.String({
|
|
127
|
-
description: "Repository-relative path",
|
|
128
|
+
description: "Repository-relative path without '..' segments",
|
|
128
129
|
minLength: 1,
|
|
129
|
-
pattern: "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+$",
|
|
130
130
|
}),
|
|
131
131
|
lines: Type.String({ description: "Line number or range, or empty string if unknown" }),
|
|
132
132
|
rootIssue: Type.String({
|
|
@@ -162,6 +162,8 @@ function registerSimplifyCandidatesTool(
|
|
|
162
162
|
parameters,
|
|
163
163
|
async execute(_toolCallId, params) {
|
|
164
164
|
const candidates: SimplifyResult[] = params.candidates;
|
|
165
|
+
assertRepositoryRelativePaths(candidates.map((candidate) => candidate.file));
|
|
166
|
+
|
|
165
167
|
const resolve = state.getResolver();
|
|
166
168
|
if (!resolve) {
|
|
167
169
|
return {
|