loop-task 2.1.2 → 2.1.4

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.
@@ -4,10 +4,15 @@ import { formatDuration } from "../duration.js";
4
4
  import { t } from "../i18n/index.js";
5
5
  import { MAX_CONTEXT_STDOUT_BYTES } from "../config/constants.js";
6
6
  function quoteArg(arg) {
7
- return /[\s"]/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;
7
+ if (arg.length === 0)
8
+ return "''";
9
+ if (/^[A-Za-z0-9_\-=:./,@]+$/.test(arg))
10
+ return arg;
11
+ const cleaned = arg.replace(/[\n\r]/g, " ");
12
+ return "'" + cleaned.replace(/'/g, "'\\''") + "'";
8
13
  }
9
14
  function formatCommandLine(command, commandArgs) {
10
- return [command, ...commandArgs.map((a) => quoteArg(a.replace(/[\n\r]/g, " ")))].join(" ").trim();
15
+ return [command, ...commandArgs.map(quoteArg)].join(" ").trim();
11
16
  }
12
17
  export function extractExitCode(error) {
13
18
  return error && typeof error === "object" && "exitCode" in error
@@ -1,3 +1,20 @@
1
+ function shellEscape(value) {
2
+ if (value.length === 0)
3
+ return '""';
4
+ // If the value is purely safe characters, pass it through unmodified
5
+ if (/^[A-Za-z0-9_\-=:./,@]+$/.test(value))
6
+ return value;
7
+ // Escape characters that are dangerous inside double quotes, then wrap
8
+ // the whole value in single quotes — the strongest shell quoting.
9
+ // Single quotes preserve everything literally (newlines, backticks,
10
+ // $, ", \, parens) except single quotes themselves.
11
+ return "'" + value.replace(/'/g, "'\\''") + "'";
12
+ }
1
13
  export function interpolate(input, context) {
2
- return input.replace(/{{(\w+)}}/g, (_, key) => String(context[key] ?? ""));
14
+ return input.replace(/{{(\w+)}}/g, (_, key) => {
15
+ const raw = context[key];
16
+ if (raw === undefined || raw === null)
17
+ return "";
18
+ return shellEscape(String(raw));
19
+ });
3
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loop-task",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Loop engineering toolkit. Run any command on a cadence, in the background, managed from a terminal board. Schedule tests, builds, syncs, or agent prompts.",
5
5
  "type": "module",
6
6
  "bin": {