@wrongstack/plugins 1.0.6 → 1.0.7

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.
@@ -97,30 +97,42 @@ async function getChangedFiles(cwd) {
97
97
  }
98
98
  async function getStagedFiles(cwd) {
99
99
  const output = await runGit(["diff", "--cached", "--name-only"], cwd);
100
- return output ? output.split("\n").filter(Boolean) : [];
100
+ return output ? output.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
101
101
  }
102
102
  async function getScopedStagedFiles(paths, cwd) {
103
103
  const output = await runGit(["diff", "--cached", "--name-only", "--", ...paths], cwd);
104
- return output ? output.split("\n").filter(Boolean) : [];
104
+ return output ? output.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
105
105
  }
106
106
  async function stageFiles(files, cwd) {
107
- if (!files || !Array.isArray(files) || files.length === 0) return;
107
+ if (!files || !Array.isArray(files) || files.length === 0) return [];
108
108
  const hasPattern = files.some((f) => /[*?[\]]/.test(f));
109
109
  if (!hasPattern) {
110
- const existing = files.filter((f) => {
110
+ const onDisk = files.filter((f) => {
111
111
  try {
112
112
  return existsSync(cwd ? resolve(cwd, f) : f);
113
113
  } catch {
114
114
  return false;
115
115
  }
116
116
  });
117
+ let existing = onDisk;
118
+ if (onDisk.length < files.length) {
119
+ let tracked = [];
120
+ try {
121
+ const out = await runGit(["ls-files", "--", ...files], cwd);
122
+ tracked = out ? out.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
123
+ } catch {
124
+ tracked = [];
125
+ }
126
+ existing = [.../* @__PURE__ */ new Set([...onDisk, ...tracked])];
127
+ }
117
128
  if (existing.length === 0) {
118
129
  throw new Error("Failed to stage files: none of the specified files exist on disk");
119
130
  }
120
131
  await runGit(["add", "--", ...existing], cwd);
121
- return;
132
+ return existing;
122
133
  }
123
134
  await runGit(["add", "--", ...files], cwd);
135
+ return files;
124
136
  }
125
137
  async function commitWithMessage(message, cwd, paths) {
126
138
  const scoped = paths && paths.length > 0 ? ["--only", "--", ...paths] : [];
@@ -191,6 +203,9 @@ async function externalChangesSinceStage(cwd) {
191
203
  const out = await runGit(["status", "--porcelain"], cwd);
192
204
  if (!out) return null;
193
205
  const unstaged = out.split("\n").filter((l) => l.trim()).filter((l) => {
206
+ const twoColumn = /^[MADRCUTX?! ]{2} /.test(l);
207
+ const oneColumnTrimmed = !twoColumn && /^[MADRCUTX?!] /.test(l);
208
+ if (oneColumnTrimmed) return true;
194
209
  const idx = l[0] ?? " ";
195
210
  return idx === " " || idx === "?";
196
211
  }).map((l) => parsePorcelainLine(l)).filter((p) => p !== null && p.length > 0);
@@ -426,14 +441,13 @@ var plugin = {
426
441
  }
427
442
  } else if (files && files.length > 0) {
428
443
  try {
429
- await stageFiles(files);
444
+ commitScope = await stageFiles(files);
430
445
  } catch (err) {
431
446
  return {
432
447
  ok: false,
433
448
  error: `Failed to stage files: ${err instanceof Error ? err.message : String(err)}`
434
449
  };
435
450
  }
436
- commitScope = files;
437
451
  try {
438
452
  staged = await getStagedFiles();
439
453
  } catch {
package/dist/index.js CHANGED
@@ -8972,30 +8972,42 @@ async function getChangedFiles(cwd) {
8972
8972
  }
8973
8973
  async function getStagedFiles(cwd) {
8974
8974
  const output = await runGit3(["diff", "--cached", "--name-only"], cwd);
8975
- return output ? output.split("\n").filter(Boolean) : [];
8975
+ return output ? output.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
8976
8976
  }
8977
8977
  async function getScopedStagedFiles(paths, cwd) {
8978
8978
  const output = await runGit3(["diff", "--cached", "--name-only", "--", ...paths], cwd);
8979
- return output ? output.split("\n").filter(Boolean) : [];
8979
+ return output ? output.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
8980
8980
  }
8981
8981
  async function stageFiles(files, cwd) {
8982
- if (!files || !Array.isArray(files) || files.length === 0) return;
8982
+ if (!files || !Array.isArray(files) || files.length === 0) return [];
8983
8983
  const hasPattern = files.some((f) => /[*?[\]]/.test(f));
8984
8984
  if (!hasPattern) {
8985
- const existing = files.filter((f) => {
8985
+ const onDisk = files.filter((f) => {
8986
8986
  try {
8987
8987
  return existsSync3(cwd ? resolve11(cwd, f) : f);
8988
8988
  } catch {
8989
8989
  return false;
8990
8990
  }
8991
8991
  });
8992
+ let existing = onDisk;
8993
+ if (onDisk.length < files.length) {
8994
+ let tracked = [];
8995
+ try {
8996
+ const out = await runGit3(["ls-files", "--", ...files], cwd);
8997
+ tracked = out ? out.split("\n").filter(Boolean).map(unquotePorcelainPath) : [];
8998
+ } catch {
8999
+ tracked = [];
9000
+ }
9001
+ existing = [.../* @__PURE__ */ new Set([...onDisk, ...tracked])];
9002
+ }
8992
9003
  if (existing.length === 0) {
8993
9004
  throw new Error("Failed to stage files: none of the specified files exist on disk");
8994
9005
  }
8995
9006
  await runGit3(["add", "--", ...existing], cwd);
8996
- return;
9007
+ return existing;
8997
9008
  }
8998
9009
  await runGit3(["add", "--", ...files], cwd);
9010
+ return files;
8999
9011
  }
9000
9012
  async function commitWithMessage(message, cwd, paths) {
9001
9013
  const scoped = paths && paths.length > 0 ? ["--only", "--", ...paths] : [];
@@ -9066,6 +9078,9 @@ async function externalChangesSinceStage(cwd) {
9066
9078
  const out = await runGit3(["status", "--porcelain"], cwd);
9067
9079
  if (!out) return null;
9068
9080
  const unstaged = out.split("\n").filter((l) => l.trim()).filter((l) => {
9081
+ const twoColumn = /^[MADRCUTX?! ]{2} /.test(l);
9082
+ const oneColumnTrimmed = !twoColumn && /^[MADRCUTX?!] /.test(l);
9083
+ if (oneColumnTrimmed) return true;
9069
9084
  const idx = l[0] ?? " ";
9070
9085
  return idx === " " || idx === "?";
9071
9086
  }).map((l) => parsePorcelainLine(l)).filter((p) => p !== null && p.length > 0);
@@ -9301,14 +9316,13 @@ var plugin26 = {
9301
9316
  }
9302
9317
  } else if (files && files.length > 0) {
9303
9318
  try {
9304
- await stageFiles(files);
9319
+ commitScope = await stageFiles(files);
9305
9320
  } catch (err) {
9306
9321
  return {
9307
9322
  ok: false,
9308
9323
  error: `Failed to stage files: ${err instanceof Error ? err.message : String(err)}`
9309
9324
  };
9310
9325
  }
9311
- commitScope = files;
9312
9326
  try {
9313
9327
  staged = await getStagedFiles();
9314
9328
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/plugins",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Official WrongStack collection of focused plugins for code quality, security, observability, planning, and agent coordination",
5
5
  "license": "MIT",
6
6
  "author": "ECOSTACK TECHNOLOGY OÜ",
@@ -303,10 +303,10 @@
303
303
  "vitest": "^4.1.11"
304
304
  },
305
305
  "dependencies": {
306
- "@wrongstack/core": "1.0.6",
307
- "@wrongstack/primitives": "1.0.6",
308
- "@wrongstack/plugin-sdk": "1.0.6",
309
- "@wrongstack/tools": "1.0.6"
306
+ "@wrongstack/core": "1.0.7",
307
+ "@wrongstack/primitives": "1.0.7",
308
+ "@wrongstack/plugin-sdk": "1.0.7",
309
+ "@wrongstack/tools": "1.0.7"
310
310
  },
311
311
  "scripts": {
312
312
  "build": "node ../../scripts/build-package.mjs",