@iinm/plain-agent 1.11.4 → 1.11.5
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 +1 -1
- package/package.json +1 -1
- package/src/cli/formatter.mjs +26 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://deepwiki.com/iinm/plain-agent)
|
|
4
4
|
[](https://www.npmjs.com/package/@iinm/plain-agent)
|
|
5
5
|
[](https://packagephobia.com/result?p=@iinm/plain-agent)
|
|
6
|
-
[](https://socket.dev/npm/package/@iinm/plain-agent)
|
|
7
7
|
[](https://github.com/iinm/plain-agent/actions/workflows/github-code-scanning/codeql)
|
|
8
8
|
|
|
9
9
|
A lightweight terminal-based coding agent focused on safety and low token cost
|
package/package.json
CHANGED
package/src/cli/formatter.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const ARG_BLOCK_LENGTH_THRESHOLD = 60;
|
|
|
27
27
|
* @param {unknown} args
|
|
28
28
|
* @returns {string}
|
|
29
29
|
*/
|
|
30
|
-
export function
|
|
30
|
+
export function formatCommandArgs(args) {
|
|
31
31
|
if (!Array.isArray(args) || args.length === 0) {
|
|
32
32
|
return `args: ${JSON.stringify(args ?? [])}`;
|
|
33
33
|
}
|
|
@@ -38,7 +38,7 @@ export function formatArgs(args) {
|
|
|
38
38
|
(a.includes("\n") || a.length > ARG_BLOCK_LENGTH_THRESHOLD),
|
|
39
39
|
);
|
|
40
40
|
if (!needsBlock) {
|
|
41
|
-
return `args: ${JSON.stringify(args)}`;
|
|
41
|
+
return `args: ${highlightCommandArgs(JSON.stringify(args))}`;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const lines = ["args:"];
|
|
@@ -49,15 +49,35 @@ export function formatArgs(args) {
|
|
|
49
49
|
) {
|
|
50
50
|
lines.push(" - |");
|
|
51
51
|
for (const line of arg.split("\n")) {
|
|
52
|
-
lines.push(` ${line}`);
|
|
52
|
+
lines.push(` ${highlightCommandArgs(line)}`);
|
|
53
53
|
}
|
|
54
54
|
} else {
|
|
55
|
-
lines.push(` - ${JSON.stringify(arg)}`);
|
|
55
|
+
lines.push(` - ${highlightCommandArgs(JSON.stringify(arg))}`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return lines.join("\n");
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} args
|
|
63
|
+
* @returns {string}
|
|
64
|
+
*/
|
|
65
|
+
function highlightCommandArgs(args) {
|
|
66
|
+
return (
|
|
67
|
+
args
|
|
68
|
+
// --foo
|
|
69
|
+
.replace(
|
|
70
|
+
/(^|\s|")(--[a-zA-Z0-9-]+)(\s|"|$)/gm,
|
|
71
|
+
(_, p1, p2, p3) => p1 + styleText("cyan", p2) + p3,
|
|
72
|
+
)
|
|
73
|
+
// -f
|
|
74
|
+
.replace(
|
|
75
|
+
/(^|\s|")(-[a-zA-Z]+)(\s|"|$)/gm,
|
|
76
|
+
(_, p1, p2, p3) => p1 + styleText("cyan", p2) + p3,
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
/**
|
|
62
82
|
* Format tool use for display.
|
|
63
83
|
* @param {MessageContentToolUse} toolUse
|
|
@@ -72,7 +92,7 @@ export async function formatToolUse(toolUse) {
|
|
|
72
92
|
return [
|
|
73
93
|
`${toolName}`,
|
|
74
94
|
`command: ${JSON.stringify(execCommandInput.command)}`,
|
|
75
|
-
|
|
95
|
+
formatCommandArgs(execCommandInput.args),
|
|
76
96
|
].join("\n");
|
|
77
97
|
}
|
|
78
98
|
|
|
@@ -117,7 +137,7 @@ export async function formatToolUse(toolUse) {
|
|
|
117
137
|
return [
|
|
118
138
|
`${toolName}`,
|
|
119
139
|
`command: ${tmuxCommandInput.command}`,
|
|
120
|
-
|
|
140
|
+
formatCommandArgs(tmuxCommandInput.args),
|
|
121
141
|
].join("\n");
|
|
122
142
|
}
|
|
123
143
|
|