@arnilo/prism-coding-agent 0.3.0 → 0.3.1
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 +5 -0
- package/dist/coding-checkpoint.js +51 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -16,7 +16,35 @@ export const CODING_STATE_KEY = "coding";
|
|
|
16
16
|
const SHA256_HEX = /^[a-f0-9]{64}$/;
|
|
17
17
|
const TASK_ID = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;
|
|
18
18
|
const BRANCH = /^[^\s]{1,255}$/;
|
|
19
|
-
|
|
19
|
+
// Linear todo-line scanner replaces `/^\s*[-*]\s+\[([ xX])\]\s+(.+?)\s*$/` (CodeQL js/polynomial-redos, alert 4)
|
|
20
|
+
function parseTodoLine(line) {
|
|
21
|
+
let i = 0;
|
|
22
|
+
while (i < line.length && /\s/.test(line[i]))
|
|
23
|
+
i += 1;
|
|
24
|
+
if (line[i] !== "-" && line[i] !== "*")
|
|
25
|
+
return undefined;
|
|
26
|
+
i += 1;
|
|
27
|
+
while (i < line.length && /\s/.test(line[i]))
|
|
28
|
+
i += 1;
|
|
29
|
+
if (line[i] !== "[")
|
|
30
|
+
return undefined;
|
|
31
|
+
i += 1;
|
|
32
|
+
const doneChar = line[i];
|
|
33
|
+
if (doneChar !== "x" && doneChar !== "X" && doneChar !== " ")
|
|
34
|
+
return undefined;
|
|
35
|
+
i += 1;
|
|
36
|
+
if (line[i] !== "]")
|
|
37
|
+
return undefined;
|
|
38
|
+
i += 1;
|
|
39
|
+
while (i < line.length && /\s/.test(line[i]))
|
|
40
|
+
i += 1;
|
|
41
|
+
let end = line.length;
|
|
42
|
+
while (end > i && /\s/.test(line[end - 1]))
|
|
43
|
+
end -= 1;
|
|
44
|
+
if (end <= i)
|
|
45
|
+
return undefined;
|
|
46
|
+
return { done: doneChar.toLowerCase() === "x", raw: line.slice(i, end) };
|
|
47
|
+
}
|
|
20
48
|
const FORBIDDEN_METADATA_KEYS = new Set([
|
|
21
49
|
"credentials",
|
|
22
50
|
"credential",
|
|
@@ -123,17 +151,32 @@ export function parseCodingPlanTodos(markdown, limits) {
|
|
|
123
151
|
assertByteLimit("plan", markdown, resolved.maxPlanBytes);
|
|
124
152
|
const todos = [];
|
|
125
153
|
for (const line of markdown.split(/\r?\n/)) {
|
|
126
|
-
const match =
|
|
154
|
+
const match = parseTodoLine(line);
|
|
127
155
|
if (!match)
|
|
128
156
|
continue;
|
|
129
|
-
const done = match
|
|
130
|
-
const raw = match
|
|
157
|
+
const done = match.done;
|
|
158
|
+
const raw = match.raw;
|
|
131
159
|
assertTodoText(raw, resolved.maxTodoTextBytes);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
// Linear id-prefix parse replaces `/^\[([A-Za-z0-9._-]{1,64})\]\s+(.+)$/` (CodeQL js/polynomial-redos, alert 5)
|
|
161
|
+
let id;
|
|
162
|
+
let text = raw;
|
|
163
|
+
if (raw.startsWith("[")) {
|
|
164
|
+
const close = raw.indexOf("]", 1);
|
|
165
|
+
if (close !== -1) {
|
|
166
|
+
const candidate = raw.slice(1, close);
|
|
167
|
+
const after = raw.slice(close + 1);
|
|
168
|
+
if (candidate.length >= 1 &&
|
|
169
|
+
candidate.length <= 64 &&
|
|
170
|
+
/^[A-Za-z0-9._-]+$/u.test(candidate) &&
|
|
171
|
+
/^\s/u.test(after) &&
|
|
172
|
+
after.trim().length > 0) {
|
|
173
|
+
id = candidate;
|
|
174
|
+
text = after.trim();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
135
178
|
assertTodoText(text, resolved.maxTodoTextBytes);
|
|
136
|
-
todos.push({ id
|
|
179
|
+
todos.push({ id: id ?? `todo-${todos.length + 1}`, text, done });
|
|
137
180
|
if (todos.length > resolved.maxTodos) {
|
|
138
181
|
throw new CodingCheckpointError(`Plan exceeds ${resolved.maxTodos} todo limit`);
|
|
139
182
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism-coding-agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Optional coding-agent tools (shell, read, write, edit, repo_list, repo_search, glob, delete, move, opt-in Git/check/ask-user-decision, and durable plan/checkpoint helpers) package for Prism.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"diff": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@arnilo/prism": "^0.3.
|
|
31
|
+
"@arnilo/prism": "^0.3.1",
|
|
32
32
|
"@arnilo/prism-workflows": "^0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|