@jwilger/pi-development-system 0.3.3 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jwilger/pi-development-system",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "A pi extension package representing a seasoned approach to software development using a full AI SDLC.",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -5,16 +5,15 @@ export type WeakeningSignals = { addsSkip: boolean; emptied: boolean; commentedO
5
5
 
6
6
  const SKIP_MARKERS: readonly RegExp[] = [
7
7
  /\b(?:it|test|describe|context)\.(?:skip|only)\b/,
8
- /\.skip\(/,
8
+ /\b(?:this|t|self|ctx)\.skip\(/,
9
9
  /\bskip:\s*true\b/,
10
10
  /\bskipTest\(/,
11
- /\bf(?:it|describe)\(/,
12
- /\bx(?:it|describe|test)\(/,
11
+ /(?<![.\w])f(?:it|describe)\(/,
12
+ /(?<![.\w])x(?:it|describe|test)\(/,
13
13
  /#\[ignore\b/,
14
14
  /@pytest\.mark\.(?:skip|skipif|xfail)|@unittest\.skip|\bpytest\.skip\(/,
15
15
  /\bt\.Skip(?:Now|f)?\(/,
16
16
  /@Disabled\b|@Ignore\b/,
17
- /\bprocess\.exit\(/,
18
17
  ];
19
18
 
20
19
  const countSkips = (text: string): number =>
@@ -39,11 +38,9 @@ function codeLineCount(text: string): number {
39
38
  inBlock = true;
40
39
  line = line.slice(2);
41
40
  } else {
41
+ // A `/*` after code is more likely inside a string than a comment opener.
42
42
  code = true;
43
- const start = line.indexOf("/*");
44
- if (start < 0) break;
45
- inBlock = true;
46
- line = line.slice(start + 2);
43
+ break;
47
44
  }
48
45
  }
49
46
  if (code) count++;
@@ -234,11 +231,18 @@ function findTargets(args: readonly string[]): string[] {
234
231
  ? [args[i + 1] ?? ""]
235
232
  : [],
236
233
  );
237
- return [...starts, ...patterns];
234
+ // With name patterns the start directory is only where to look, not what is deleted.
235
+ return patterns.length > 0 ? patterns : starts;
238
236
  }
239
237
 
240
238
  const removers = (args: readonly string[]): string[] => operands(args);
241
239
 
240
+ /** `mv src… dir/`: the trailing-slash destination is a directory receiving files, not a removal. */
241
+ const moveSources = (args: readonly string[]): string[] => {
242
+ const ops = operands(args);
243
+ return ops.length > 1 && ops.at(-1)?.endsWith("/") ? ops.slice(0, -1) : ops;
244
+ };
245
+
242
246
  export type MutationKind = "remove" | "overwrite";
243
247
  export type Mutation = { readonly path: string; readonly kind: MutationKind };
244
248
 
@@ -273,7 +277,7 @@ const TARGETS: Readonly<Record<string, (args: readonly string[]) => string[]>> =
273
277
  unlink: removers,
274
278
  trash: removers,
275
279
  rmdir: removers,
276
- mv: removers,
280
+ mv: moveSources,
277
281
  tee: removers,
278
282
  truncate: truncateTargets,
279
283
  find: findTargets,
@@ -320,12 +324,11 @@ function collect(command: string, startCwd: string, depth: number): Mutation[] {
320
324
  if (script !== undefined) found.push(...collect(script, cwd, depth + 1));
321
325
  continue;
322
326
  }
327
+ const redirectKind: MutationKind = PRODUCES_NOTHING.has(head) ? "remove" : "overwrite";
323
328
  found.push(...commandTargets(words).map((m) => ({ ...m, path: joinCwd(cwd, m.path) })));
324
329
  found.push(
325
330
  ...seg.truncates.flatMap((p): Mutation[] =>
326
- p === "/dev/null"
327
- ? []
328
- : [{ path: joinCwd(cwd, p), kind: PRODUCES_NOTHING.has(head) ? "remove" : "overwrite" }],
331
+ p === "/dev/null" ? [] : [{ path: joinCwd(cwd, p), kind: redirectKind }],
329
332
  ),
330
333
  );
331
334
  }