am-i-done 0.3.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "am-i-done",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A definition of done for agentic projects: one command that says whether the work is finished.",
5
5
  "license": "MIT",
6
6
  "author": "theshadow27 (https://github.com/theshadow27)",
package/src/spawn.ts CHANGED
@@ -103,7 +103,7 @@ export const liveGroups = (): number[] => [...live];
103
103
  * SIGTERM each group, wait for it to go, SIGKILL what is left, and wait again. Returns the groups
104
104
  * still alive after all that, which should never happen and must be reported if it does.
105
105
  */
106
- async function endGroups(pids: number[], graceMs: number = TERM_GRACE_MS): Promise<number[]> {
106
+ export async function endGroups(pids: number[], graceMs: number = TERM_GRACE_MS): Promise<number[]> {
107
107
  for (const pid of pids) signal(pid, "SIGTERM");
108
108
  await until(() => !pids.some(groupAlive), graceMs);
109
109
  const stubborn = pids.filter(groupAlive);
package/src/tmp.ts CHANGED
@@ -21,9 +21,9 @@ export const ROOT_PREFIX = "amid-";
21
21
  const ROOT_NAME = new RegExp(`^${ROOT_PREFIX}(\\d+)(?:n(\\d+))?-`);
22
22
 
23
23
  /** This process's pid namespace (Linux), or `undefined` where there is no `/proc`. */
24
- export function pidNamespace(): string | undefined {
24
+ export function pidNamespace(link = "/proc/self/ns/pid"): string | undefined {
25
25
  try {
26
- return /\[(\d+)\]/.exec(readlinkSync("/proc/self/ns/pid"))?.[1];
26
+ return /\[(\d+)\]/.exec(readlinkSync(link))?.[1];
27
27
  } catch {
28
28
  return undefined;
29
29
  }
@@ -50,14 +50,13 @@ export const tmpBase = (): string => realpathSync(process.env["TMPDIR"] || tmpdi
50
50
  */
51
51
  export function sweepDeadTmpRoots(
52
52
  base: string = tmpBase(),
53
- {
54
- alive = pidAlive,
55
- self = process.pid,
56
- namespace = NAMESPACE,
57
- }: { alive?: (pid: number) => boolean; self?: number; namespace?: string | undefined } = {},
53
+ options: { alive?: (pid: number) => boolean; self?: number; namespace?: string | undefined } = {},
58
54
  ): string[] {
55
+ const { alive = pidAlive, self = process.pid } = options;
56
+ // Not a destructuring default: that would replace an explicit `undefined` (no namespace) with this one.
57
+ const namespace = "namespace" in options ? options.namespace : NAMESPACE;
59
58
  const removed: string[] = [];
60
- const names = existsSync(base) ? readdirSync(base) : [];
59
+ const names = existsSync(base) ? readdirSync(base).sort() : [];
61
60
  for (const name of names) {
62
61
  const match = ROOT_NAME.exec(name);
63
62
  const pid = Number(match?.[1]);