@lucascouts/claude-agent-tui 0.11.0 → 0.11.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/dist/tools.js +87 -9
- package/package.json +1 -1
package/dist/tools.js
CHANGED
|
@@ -878,6 +878,90 @@ export function parseTaskCreateOutput(content) {
|
|
|
878
878
|
return undefined;
|
|
879
879
|
}
|
|
880
880
|
const TASK_STATUSES = new Set(["pending", "in_progress", "completed"]);
|
|
881
|
+
/**
|
|
882
|
+
* One line of a textual TaskList listing — `#<id> [<status>] <subject>`, optionally followed by
|
|
883
|
+
* ` (<owner>)` and ` [blocked by #a, #b]` — or `undefined` when the line is not one.
|
|
884
|
+
*
|
|
885
|
+
* A LINEAR SCANNER, deliberately, and not the regex upstream uses. That regex nests a quantifier
|
|
886
|
+
* inside a quantified group (`(?:#[^,\]]+(?:, )?)+`) and CodeQL flagged it twice on this repo:
|
|
887
|
+
* `js/redos` (exponential) and `js/polynomial-redos`. It reproduces — on `#! [pending] a [blocked
|
|
888
|
+
* by #` followed by N repetitions of `+#`, the match time QUADRUPLES for every 2 characters added
|
|
889
|
+
* (n=20 → 4.9 ms, n=22 → 20 ms, n=24 → 79 ms), so a ~100-character line hangs the process for
|
|
890
|
+
* hours. The input is the model-facing text of a tool_result read from the transcript, so it is
|
|
891
|
+
* not trusted the way a literal in this file would be.
|
|
892
|
+
*
|
|
893
|
+
* This follows the precedent story 051 set for the command-marker stripper: replace the regex with
|
|
894
|
+
* a scanner that makes exactly one pass and never backtracks. Same grammar, same results — the
|
|
895
|
+
* equivalence is pinned by tests — in O(n).
|
|
896
|
+
*
|
|
897
|
+
* The two optional suffixes are anchored at the END of the line, so they are peeled right-to-left
|
|
898
|
+
* with `lastIndexOf`. That reproduces the lazy `(.+?)` subject of the original: the regex, unable
|
|
899
|
+
* to put parentheses inside `[^()]*`, ends up matching the LAST parenthesised group as the owner,
|
|
900
|
+
* which is exactly what `lastIndexOf` finds.
|
|
901
|
+
*/
|
|
902
|
+
function parseTaskListLine(line) {
|
|
903
|
+
if (!line.startsWith("#"))
|
|
904
|
+
return undefined;
|
|
905
|
+
const idEnd = line.indexOf(" ");
|
|
906
|
+
// `#` alone is not an id, and `\S+` cannot be empty.
|
|
907
|
+
if (idEnd < 2)
|
|
908
|
+
return undefined;
|
|
909
|
+
const id = line.slice(1, idEnd);
|
|
910
|
+
const afterId = line.slice(idEnd + 1);
|
|
911
|
+
if (!afterId.startsWith("["))
|
|
912
|
+
return undefined;
|
|
913
|
+
const statusEnd = afterId.indexOf("]");
|
|
914
|
+
if (statusEnd < 0)
|
|
915
|
+
return undefined;
|
|
916
|
+
const status = afterId.slice(1, statusEnd);
|
|
917
|
+
if (!TASK_STATUSES.has(status))
|
|
918
|
+
return undefined;
|
|
919
|
+
let tail = afterId.slice(statusEnd + 1);
|
|
920
|
+
if (!tail.startsWith(" "))
|
|
921
|
+
return undefined;
|
|
922
|
+
tail = tail.slice(1);
|
|
923
|
+
let blockedBy = [];
|
|
924
|
+
const BLOCKED_BY = " [blocked by ";
|
|
925
|
+
if (tail.endsWith("]")) {
|
|
926
|
+
const at = tail.lastIndexOf(BLOCKED_BY);
|
|
927
|
+
// `at > 0` also enforces the original's non-empty subject: at 0 there is nothing before it.
|
|
928
|
+
if (at > 0) {
|
|
929
|
+
const entries = tail.slice(at + BLOCKED_BY.length, -1).split(", ");
|
|
930
|
+
// Every entry is `#<id>` with an id that carries no comma and no bracket — the character
|
|
931
|
+
// class the original spelled as `[^,\]]+`.
|
|
932
|
+
if (entries.length > 0 &&
|
|
933
|
+
entries.every((entry) => entry.startsWith("#") &&
|
|
934
|
+
entry.length > 1 &&
|
|
935
|
+
!entry.includes(",") &&
|
|
936
|
+
!entry.includes("]"))) {
|
|
937
|
+
blockedBy = entries.map((entry) => entry.slice(1));
|
|
938
|
+
tail = tail.slice(0, at);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
let owner;
|
|
943
|
+
if (tail.endsWith(")")) {
|
|
944
|
+
const at = tail.lastIndexOf(" (");
|
|
945
|
+
if (at > 0) {
|
|
946
|
+
const inner = tail.slice(at + 2, -1);
|
|
947
|
+
// `[^()]*` — the owner group cannot itself contain parentheses.
|
|
948
|
+
if (!inner.includes("(") && !inner.includes(")")) {
|
|
949
|
+
owner = inner;
|
|
950
|
+
tail = tail.slice(0, at);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
// `(.+?)` needs at least one character of subject.
|
|
955
|
+
if (tail.length === 0)
|
|
956
|
+
return undefined;
|
|
957
|
+
return {
|
|
958
|
+
id,
|
|
959
|
+
subject: tail,
|
|
960
|
+
status: status,
|
|
961
|
+
...(owner ? { owner } : {}),
|
|
962
|
+
blockedBy,
|
|
963
|
+
};
|
|
964
|
+
}
|
|
881
965
|
/**
|
|
882
966
|
* Best-effort parse of a TaskList result — the SDK's AUTHORITATIVE snapshot of the task list.
|
|
883
967
|
* Upstream #974 (v0.67.0).
|
|
@@ -903,20 +987,14 @@ export function parseTaskListOutput(content) {
|
|
|
903
987
|
const tasks = [];
|
|
904
988
|
let clean = true;
|
|
905
989
|
for (const line of text.trim().split("\n")) {
|
|
906
|
-
const
|
|
990
|
+
const task = parseTaskListLine(line);
|
|
907
991
|
// A single unparseable line means this text is not a task listing at all — take none of it
|
|
908
992
|
// rather than a truncated plan that reads as complete.
|
|
909
|
-
if (!
|
|
993
|
+
if (!task) {
|
|
910
994
|
clean = false;
|
|
911
995
|
break;
|
|
912
996
|
}
|
|
913
|
-
tasks.push(
|
|
914
|
-
id: match[1],
|
|
915
|
-
subject: match[3],
|
|
916
|
-
status: match[2],
|
|
917
|
-
...(match[4] ? { owner: match[4] } : {}),
|
|
918
|
-
blockedBy: match[5] ? match[5].split(", ").map((id) => id.slice(1)) : [],
|
|
919
|
-
});
|
|
997
|
+
tasks.push(task);
|
|
920
998
|
}
|
|
921
999
|
if (clean && tasks.length > 0)
|
|
922
1000
|
return { tasks };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.11.
|
|
6
|
+
"version": "0.11.1",
|
|
7
7
|
"description": "Run the official Claude Code TUI in Zed's agent panel on your Claude Pro/Max subscription — an ACP-over-PTY bridge created for Anthropic's billing split (paused June 15; see README).",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|