agentrinse 0.0.0 → 0.1.0

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.
Files changed (125) hide show
  1. package/README.md +128 -83
  2. package/dist/cli.js +2 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/apply.d.ts +6 -0
  5. package/dist/commands/apply.d.ts.map +1 -1
  6. package/dist/commands/apply.js +37 -13
  7. package/dist/commands/apply.js.map +1 -1
  8. package/dist/commands/audit.d.ts +7 -1
  9. package/dist/commands/audit.d.ts.map +1 -1
  10. package/dist/commands/audit.js +103 -12
  11. package/dist/commands/audit.js.map +1 -1
  12. package/dist/commands/completion.d.ts +4 -0
  13. package/dist/commands/completion.d.ts.map +1 -0
  14. package/dist/commands/completion.js +94 -0
  15. package/dist/commands/completion.js.map +1 -0
  16. package/dist/commands/config.d.ts +17 -0
  17. package/dist/commands/config.d.ts.map +1 -0
  18. package/dist/commands/config.js +41 -0
  19. package/dist/commands/config.js.map +1 -0
  20. package/dist/commands/doctor.d.ts +28 -0
  21. package/dist/commands/doctor.d.ts.map +1 -0
  22. package/dist/commands/doctor.js +582 -0
  23. package/dist/commands/doctor.js.map +1 -0
  24. package/dist/commands/history.d.ts +15 -0
  25. package/dist/commands/history.d.ts.map +1 -0
  26. package/dist/commands/history.js +30 -0
  27. package/dist/commands/history.js.map +1 -0
  28. package/dist/commands/lock.d.ts +21 -0
  29. package/dist/commands/lock.d.ts.map +1 -0
  30. package/dist/commands/lock.js +43 -0
  31. package/dist/commands/lock.js.map +1 -0
  32. package/dist/commands/plan.d.ts +2 -0
  33. package/dist/commands/plan.d.ts.map +1 -1
  34. package/dist/commands/plan.js +9 -2
  35. package/dist/commands/plan.js.map +1 -1
  36. package/dist/commands/show.d.ts +20 -0
  37. package/dist/commands/show.d.ts.map +1 -0
  38. package/dist/commands/show.js +54 -0
  39. package/dist/commands/show.js.map +1 -0
  40. package/dist/config/load.d.ts +6 -0
  41. package/dist/config/load.d.ts.map +1 -1
  42. package/dist/config/load.js +25 -0
  43. package/dist/config/load.js.map +1 -1
  44. package/dist/config/path.d.ts +5 -0
  45. package/dist/config/path.d.ts.map +1 -0
  46. package/dist/config/path.js +13 -0
  47. package/dist/config/path.js.map +1 -0
  48. package/dist/contracts/doctor.d.ts +35 -0
  49. package/dist/contracts/doctor.d.ts.map +1 -0
  50. package/dist/contracts/doctor.js +15 -0
  51. package/dist/contracts/doctor.js.map +1 -0
  52. package/dist/contracts/output.d.ts +50 -0
  53. package/dist/contracts/output.d.ts.map +1 -0
  54. package/dist/contracts/output.js +23 -0
  55. package/dist/contracts/output.js.map +1 -0
  56. package/dist/contracts/run.d.ts +2 -0
  57. package/dist/contracts/run.d.ts.map +1 -1
  58. package/dist/contracts/run.js +1 -1
  59. package/dist/contracts/run.js.map +1 -1
  60. package/dist/core/apply.d.ts +1 -0
  61. package/dist/core/apply.d.ts.map +1 -1
  62. package/dist/core/apply.js +46 -3
  63. package/dist/core/apply.js.map +1 -1
  64. package/dist/core/audit.d.ts +21 -0
  65. package/dist/core/audit.d.ts.map +1 -1
  66. package/dist/core/audit.js +31 -1
  67. package/dist/core/audit.js.map +1 -1
  68. package/dist/core/duration.d.ts +2 -0
  69. package/dist/core/duration.d.ts.map +1 -0
  70. package/dist/core/duration.js +21 -0
  71. package/dist/core/duration.js.map +1 -0
  72. package/dist/core/interruption.d.ts +5 -0
  73. package/dist/core/interruption.d.ts.map +1 -0
  74. package/dist/core/interruption.js +5 -0
  75. package/dist/core/interruption.js.map +1 -0
  76. package/dist/core/process-identity.d.ts +24 -0
  77. package/dist/core/process-identity.d.ts.map +1 -0
  78. package/dist/core/process-identity.js +104 -0
  79. package/dist/core/process-identity.js.map +1 -0
  80. package/dist/core/redaction.d.ts +4 -0
  81. package/dist/core/redaction.d.ts.map +1 -0
  82. package/dist/core/redaction.js +91 -0
  83. package/dist/core/redaction.js.map +1 -0
  84. package/dist/core/safety.d.ts +8 -0
  85. package/dist/core/safety.d.ts.map +1 -1
  86. package/dist/core/safety.js +29 -1
  87. package/dist/core/safety.js.map +1 -1
  88. package/dist/index.d.ts +3 -1
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +2 -0
  91. package/dist/index.js.map +1 -1
  92. package/dist/machine-output.d.ts +21 -0
  93. package/dist/machine-output.d.ts.map +1 -0
  94. package/dist/machine-output.js +32 -0
  95. package/dist/machine-output.js.map +1 -0
  96. package/dist/main.d.ts.map +1 -1
  97. package/dist/main.js +194 -7
  98. package/dist/main.js.map +1 -1
  99. package/dist/state/json-file.d.ts +6 -1
  100. package/dist/state/json-file.d.ts.map +1 -1
  101. package/dist/state/json-file.js +34 -3
  102. package/dist/state/json-file.js.map +1 -1
  103. package/dist/state/layout.d.ts +2 -0
  104. package/dist/state/layout.d.ts.map +1 -1
  105. package/dist/state/layout.js +2 -0
  106. package/dist/state/layout.js.map +1 -1
  107. package/dist/state/lock.d.ts +54 -1
  108. package/dist/state/lock.d.ts.map +1 -1
  109. package/dist/state/lock.js +237 -33
  110. package/dist/state/lock.js.map +1 -1
  111. package/dist/state/records.d.ts +5 -0
  112. package/dist/state/records.d.ts.map +1 -0
  113. package/dist/state/records.js +35 -0
  114. package/dist/state/records.js.map +1 -0
  115. package/dist/state/run-journal.d.ts +3 -1
  116. package/dist/state/run-journal.d.ts.map +1 -1
  117. package/dist/state/run-journal.js +15 -4
  118. package/dist/state/run-journal.js.map +1 -1
  119. package/dist/version.d.ts +1 -1
  120. package/dist/version.js +1 -1
  121. package/package.json +3 -2
  122. package/schemas/command-envelope.schema.json +78 -0
  123. package/schemas/command-event.schema.json +36 -0
  124. package/schemas/doctor.schema.json +51 -0
  125. package/schemas/run.schema.json +1 -1
package/README.md CHANGED
@@ -2,53 +2,39 @@
2
2
 
3
3
  Safe, local-first cleanup for agentic development.
4
4
 
5
- AgentRinse inventories agent state and developer residue, explains why
6
- resources are protected, produces content-addressed cleanup plans, and applies
7
- only actions that still pass every safety check.
8
-
9
- > [!IMPORTANT]
10
- > `0.0.0` is a package-reservation release. It is not supported for cleanup
11
- > against real developer state. The first supported release will be `0.1.0`.
12
-
13
- ## Reservation Release
14
-
15
- The implemented mutation boundary under development is intentionally narrow:
16
-
17
- - removes only exact rebuildable artifact directories declared in config
18
- - supports `node_modules`, `dist`, `dist-runtime`, `build`, `.next`, `.turbo`,
19
- `.cache`, `coverage`, `target`, and `.venv`
20
- - revalidates path, realpath, inode, device, recursive metadata fingerprint,
21
- newest descendant mtime, measured bytes, configured scope, current working
22
- directory, and process ownership after acquiring the apply lock
23
- - rejects artifact roots and descendants that cross filesystem mount
24
- boundaries
25
- - rejects sockets, pipes, devices, and other non-regular filesystem entries
26
- - rechecks size, age, and plan expiration immediately before each mutation
27
- - atomically renames an artifact to a same-parent tombstone before recursive
28
- removal, repeats fingerprint and process checks on the isolated tree, and
29
- performs a final synchronous inode check at the deletion boundary
30
- - journals every transition and records the recovery path for partial actions
31
-
32
- Codex, Claude Code, Cursor, GitHub Copilot CLI, Zed, OpenCode, Grok Build, Git,
33
- and Docker are report-only. Provider state, worktrees, images, containers,
34
- volumes, branches, stashes, credentials, configuration, plugins, skills, and
35
- memories are not cleanup targets.
5
+ AgentRinse inventories agent state and developer residue, explains why each
6
+ resource is protected or eligible, creates content-addressed cleanup plans,
7
+ and applies only actions that still pass every safety check.
8
+
9
+ Version `0.1.0` supports one mutating action: removing exact rebuildable
10
+ artifact directories declared under explicit project roots. Provider state,
11
+ Git worktrees, and Docker resources remain report-only.
36
12
 
37
13
  ## Install
38
14
 
39
- Do not install `0.0.0` for operational cleanup. Maintainers may verify the
40
- reservation package with:
15
+ Node.js 22 or newer is required.
41
16
 
42
17
  ```bash
43
18
  npm install --global agentrinse
44
19
  agentrinse --version
45
20
  ```
46
21
 
47
- The command must report `0.0.0`. Node.js 22 or newer is required.
22
+ One-off use also works:
23
+
24
+ ```bash
25
+ npx agentrinse@0.1.0 doctor
26
+ ```
27
+
28
+ ## Quickstart
48
29
 
49
- ## Configure
30
+ Create a default configuration without overwriting an existing file:
50
31
 
51
- Artifact cleanup is disabled until project roots are explicitly declared.
32
+ ```bash
33
+ agentrinse config init
34
+ agentrinse config path
35
+ ```
36
+
37
+ Edit the generated JSON and add explicit artifact roots:
52
38
 
53
39
  ```json
54
40
  {
@@ -71,69 +57,129 @@ Artifact cleanup is disabled until project roots are explicitly declared.
71
57
  }
72
58
  ```
73
59
 
74
- Project roots must be unique canonical absolute real directories inside the
75
- audited home; paths reached through symlinked ancestors are rejected. Artifact
76
- targets cannot overlap. AgentRinse never discovers arbitrary projects or
77
- expands wildcards.
60
+ Run diagnostics before the first audit:
78
61
 
79
- ## Use
62
+ ```bash
63
+ agentrinse config validate
64
+ agentrinse doctor
65
+ ```
80
66
 
81
- Audit and save immutable evidence:
67
+ Audit and save exact evidence:
82
68
 
83
69
  ```bash
84
- agentrinse audit \
85
- --home "$HOME" \
86
- --config agentrinse.json \
87
- --json \
88
- --output audit.json
70
+ agentrinse audit --home "$HOME" --output audit.json
89
71
  ```
90
72
 
91
- Create a bounded cleanup plan:
73
+ Create and review a bounded plan:
74
+
75
+ ```bash
76
+ agentrinse plan --audit audit.json --output plan.json
77
+ cat plan.json
78
+ ```
79
+
80
+ Apply only after reviewing the plan:
81
+
82
+ ```bash
83
+ agentrinse apply --plan plan.json
84
+ ```
85
+
86
+ Interactive apply asks for confirmation. Automation must pass `--yes`.
87
+
88
+ ## Mutation Boundary
89
+
90
+ AgentRinse can remove only these configured artifact names:
91
+
92
+ - `node_modules`
93
+ - `dist`
94
+ - `dist-runtime`
95
+ - `build`
96
+ - `.next`
97
+ - `.turbo`
98
+ - `.cache`
99
+ - `coverage`
100
+ - `target`
101
+ - `.venv`
102
+
103
+ Before removal it revalidates configured scope, canonical paths, device and
104
+ inode identity, recursive metadata fingerprint, measured bytes, newest
105
+ descendant age, mount boundaries, current working directory ownership,
106
+ same-user processes, and plan expiration. The exact target is atomically moved
107
+ to a same-parent tombstone and verified again before deletion.
108
+
109
+ AgentRinse never removes provider sessions, transcripts, databases,
110
+ credentials, configuration, plugins, skills, memories, Git branches, stashes,
111
+ worktrees, Docker images, containers, networks, volumes, or build cache in
112
+ `0.1.0`.
113
+
114
+ ## Operations
115
+
116
+ ```bash
117
+ agentrinse history
118
+ agentrinse show run <run-id>
119
+ agentrinse show plan <plan-id>
120
+ agentrinse show resource <resource-id>
121
+ agentrinse lock status
122
+ ```
123
+
124
+ A stale lock can be recovered only after AgentRinse proves the recorded local
125
+ process identity no longer exists:
126
+
127
+ ```bash
128
+ agentrinse lock status
129
+ agentrinse lock recover --yes
130
+ ```
131
+
132
+ Generate shell completion without modifying shell startup files:
133
+
134
+ ```bash
135
+ agentrinse completion bash
136
+ agentrinse completion zsh
137
+ agentrinse completion fish
138
+ ```
139
+
140
+ ## Machine Output
141
+
142
+ `agentrinse audit --json` emits a versioned command envelope. Long audits can
143
+ emit incremental event records:
92
144
 
93
145
  ```bash
94
- agentrinse plan \
95
- --audit audit.json \
96
- --config agentrinse.json \
97
- --output plan.json
146
+ agentrinse audit --ndjson
98
147
  ```
99
148
 
100
- Review `plan.json`, then apply it:
149
+ Create a non-executable report for issue filing:
101
150
 
102
151
  ```bash
103
- agentrinse apply \
104
- --plan plan.json \
105
- --config agentrinse.json \
106
- --yes
152
+ agentrinse audit --json --redact > audit-redacted.json
107
153
  ```
108
154
 
109
- Without `--yes`, apply requires an interactive terminal confirmation. JSON
110
- output requires `--yes` so prompts can never corrupt stdout. A plan is rejected
111
- when it expires, changes, no longer matches the config, or contains inconsistent
112
- action totals. An action whose authorization expires during a run is recorded
113
- as `skipped-stale`, not deleted.
155
+ Redaction replaces paths, salts identifiers per report, removes host fields,
156
+ and strips candidate actions. Persisted state and `--output` evidence remain
157
+ exact so they can be used for planning.
114
158
 
115
- Run journals are stored under `$XDG_STATE_HOME/agentrinse/runs` or
116
- `$HOME/.local/state/agentrinse/runs`. Use `--state-dir` to select another
117
- location.
159
+ ## Platform Support
118
160
 
119
- ## Safety
161
+ | Platform | `0.1.0` support |
162
+ | -------------- | --------------------------------------------------- |
163
+ | macOS | audit and safe artifact apply |
164
+ | Linux | audit and safe artifact apply |
165
+ | WSL | Linux contract inside the WSL filesystem |
166
+ | native Windows | audit-only; mutation remains blocked before `1.0.0` |
120
167
 
121
- - discovery and planning never mutate
122
- - unknown state is protected
123
- - symlinks are not followed
124
- - no process is killed
125
- - no `sudo`
126
- - no Docker volume deletion
127
- - no generic `--force`
128
- - no wildcard deletion
129
- - one apply run holds the exclusive state lock
130
- - AgentRinse never removes its own working directory, lock, or journal
168
+ Git and `lsof` are required for the complete diagnostic and process-ownership
169
+ contract. Docker is optional. Doctor can detect the optional external Mole
170
+ tool on macOS.
131
171
 
132
- AgentRinse fails closed around ordinary concurrent developer tools. It does not
133
- claim isolation from a hostile process already running as the same OS user;
134
- that process can directly alter the user's files and AgentRinse state.
172
+ ## Documentation
135
173
 
136
- See `docs/safety.md` for the complete mutation contract.
174
+ - [Configuration](docs/configuration.md)
175
+ - [Automation](docs/automation.md)
176
+ - [Recovery](docs/recovery.md)
177
+ - [Platform support](docs/platforms.md)
178
+ - [Safety model](docs/safety.md)
179
+ - [Adapter matrix](docs/adapters.md)
180
+ - [Development](docs/development.md)
181
+ - [Releasing](docs/releasing.md)
182
+ - [Product specification](docs/product-spec.md)
137
183
 
138
184
  ## Development
139
185
 
@@ -144,9 +190,8 @@ pnpm smoke
144
190
  pnpm pack:check
145
191
  ```
146
192
 
147
- Development, tests, smoke runs, and destructive proof use temporary synthetic
148
- homes only. Never point `0.0.0` or an unreleased development build at a
149
- workstation home.
193
+ Tests and smoke runs use guarded temporary synthetic roots. Never point an
194
+ unreleased build at real developer state.
150
195
 
151
196
  ## License
152
197
 
package/dist/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { main } from "./main.js";
3
+ import { CommandInterruptedError } from "./core/interruption.js";
3
4
  main().catch((error) => {
4
5
  const message = error instanceof Error ? error.message : String(error);
5
6
  process.stderr.write(`agentrinse: ${message}\n`);
6
- process.exitCode = 1;
7
+ process.exitCode = error instanceof CommandInterruptedError ? error.exitCode : 1;
7
8
  });
8
9
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,OAAO,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,OAAO,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,QAAQ,GAAG,KAAK,YAAY,uBAAuB,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC,CAAC"}
@@ -5,11 +5,17 @@ export type ApplyCommandOptions = {
5
5
  stateDir?: string;
6
6
  yes: boolean;
7
7
  json: boolean;
8
+ signal?: AbortSignal;
8
9
  };
9
10
  export type ApplyCommandResult = {
10
11
  run: CleanupRun;
11
12
  journalPath: string;
12
13
  output: string;
13
14
  };
15
+ export type ConfirmApplyDependencies = {
16
+ isInteractive?: () => boolean;
17
+ question?: (prompt: string, signal?: AbortSignal) => Promise<string>;
18
+ };
19
+ export declare function confirmApply(actionCount: number, signal?: AbortSignal, dependencies?: ConfirmApplyDependencies): Promise<boolean>;
14
20
  export declare function executeApplyCommand(options: ApplyCommandOptions): Promise<ApplyCommandResult>;
15
21
  //# sourceMappingURL=apply.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,UAAU,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgCF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA4B7B"}
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,UAAU,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACtE,CAAC;AAyBF,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,WAAW,EACpB,YAAY,GAAE,wBAA6B,GAC1C,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAeD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAyB7B"}
@@ -1,27 +1,53 @@
1
1
  import { createInterface } from "node:readline/promises";
2
2
  import { resolve } from "node:path";
3
- import { loadConfig } from "../config/load.js";
3
+ import { loadConfigForHome } from "../config/load.js";
4
4
  import { cleanupPlanSchema } from "../contracts/plan.js";
5
5
  import { applyCleanupPlan } from "../core/apply.js";
6
+ import { CommandInterruptedError } from "../core/interruption.js";
6
7
  import { readJsonFile } from "../state/json-file.js";
7
8
  import { resolveStateRoot } from "../state/layout.js";
8
- import { VERSION } from "../version.js";
9
- async function confirmApply(actionCount) {
10
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
11
- throw new Error("apply requires --yes when stdin or stdout is not an interactive terminal");
12
- }
9
+ async function defaultQuestion(promptText, signal) {
13
10
  const prompt = createInterface({
14
11
  input: process.stdin,
15
12
  output: process.stdout,
16
13
  });
17
14
  try {
18
- const answer = await prompt.question(`Apply ${actionCount} safe cleanup action(s)? [y/N] `);
19
- return ["y", "yes"].includes(answer.trim().toLowerCase());
15
+ return signal === undefined
16
+ ? await prompt.question(promptText)
17
+ : await prompt.question(promptText, { signal });
20
18
  }
21
19
  finally {
22
20
  prompt.close();
23
21
  }
24
22
  }
23
+ function interruptionFrom(signal) {
24
+ if (signal?.aborted !== true) {
25
+ return undefined;
26
+ }
27
+ return signal.reason instanceof CommandInterruptedError
28
+ ? signal.reason
29
+ : new CommandInterruptedError("apply interrupted");
30
+ }
31
+ export async function confirmApply(actionCount, signal, dependencies = {}) {
32
+ const initialInterruption = interruptionFrom(signal);
33
+ if (initialInterruption !== undefined) {
34
+ throw initialInterruption;
35
+ }
36
+ if (!(dependencies.isInteractive ?? (() => process.stdin.isTTY && process.stdout.isTTY))()) {
37
+ throw new Error("apply requires --yes when stdin or stdout is not an interactive terminal");
38
+ }
39
+ try {
40
+ const answer = await (dependencies.question ?? defaultQuestion)(`Apply ${actionCount} safe cleanup action(s)? [y/N] `, signal);
41
+ return ["y", "yes"].includes(answer.trim().toLowerCase());
42
+ }
43
+ catch (error) {
44
+ const interruption = interruptionFrom(signal);
45
+ if (interruption !== undefined) {
46
+ throw interruption;
47
+ }
48
+ throw error;
49
+ }
50
+ }
25
51
  function renderRun(run, journalPath) {
26
52
  const applied = run.actions.filter((action) => action.status === "applied").length;
27
53
  const skipped = run.actions.filter((action) => action.status === "skipped-stale").length;
@@ -38,19 +64,17 @@ export async function executeApplyCommand(options) {
38
64
  if (options.json && !options.yes) {
39
65
  throw new Error("apply --json requires --yes");
40
66
  }
41
- if (VERSION === "0.0.0") {
42
- throw new Error("apply is unavailable in the unsupported 0.0.0 reservation release");
43
- }
44
67
  const input = await readJsonFile(resolve(options.plan));
45
68
  const plan = cleanupPlanSchema.parse(input);
46
- const config = await loadConfig(options.config);
47
- if (!options.yes && !(await confirmApply(plan.actions.length))) {
69
+ const { config } = await loadConfigForHome(plan.home, options.config);
70
+ if (!options.yes && !(await confirmApply(plan.actions.length, options.signal))) {
48
71
  throw new Error("apply cancelled");
49
72
  }
50
73
  const result = await applyCleanupPlan({
51
74
  input,
52
75
  config,
53
76
  stateRoot: resolveStateRoot(plan.home, options.stateDir),
77
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
54
78
  });
55
79
  return {
56
80
  run: result.run,
@@ -1 +1 @@
1
- {"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAgBxC,KAAK,UAAU,YAAY,CAAC,WAAmB;IAC7C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC;QAC7B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,WAAW,iCAAiC,CAAC,CAAC;QAC5F,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,CAA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AAC;IACjD,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC/E,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC;QACpC,KAAK;QACL,MAAM;QACN,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;QACxD,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;KACpE,CAAC,CAAC;IACH,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,EAAE,OAAO,CAAC,IAAI;YAClB,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI;YAC5C,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -2,11 +2,17 @@ import type { AuditReport } from "../contracts/report.js";
2
2
  export type AuditCommandOptions = {
3
3
  home: string;
4
4
  config?: string;
5
- json: boolean;
5
+ json?: boolean;
6
+ ndjson?: boolean;
7
+ redact?: boolean;
6
8
  output?: string;
9
+ stateDir?: string;
10
+ now?: () => Date;
11
+ emit?: (output: string) => void;
7
12
  };
8
13
  export type AuditCommandResult = {
9
14
  report: AuditReport;
15
+ statePath: string;
10
16
  output: string;
11
17
  };
12
18
  export declare function executeAuditCommand(options: AuditCommandOptions): Promise<AuditCommandResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAK1D,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAgB7B"}
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa1D,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAqH7B"}
@@ -1,22 +1,113 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { resolve } from "node:path";
2
3
  import { createAuditAdapters } from "../adapters/registry.js";
3
- import { loadConfig } from "../config/load.js";
4
+ import { loadConfigForHome } from "../config/load.js";
4
5
  import { runAudit } from "../core/audit.js";
6
+ import { redactAuditReport, redactAuditValue } from "../core/redaction.js";
7
+ import { createCommandEnvelope, createCommandEvent, jsonDocument, ndjsonRecord, } from "../machine-output.js";
5
8
  import { renderAudit } from "../output.js";
6
9
  import { writeJsonAtomic } from "../state/json-file.js";
10
+ import { resolveStateRoot, stateLayout } from "../state/layout.js";
7
11
  export async function executeAuditCommand(options) {
8
- const config = await loadConfig(options.config);
9
- const report = await runAudit({
10
- home: resolve(options.home),
11
- config,
12
- adapters: createAuditAdapters(config),
13
- });
14
- if (options.output !== undefined) {
15
- await writeJsonAtomic(resolve(options.output), report);
12
+ if (options.json === true && options.ndjson === true) {
13
+ throw new Error("audit accepts only one of --json or --ndjson");
16
14
  }
17
- return {
18
- report,
19
- output: options.json ? `${JSON.stringify(report, null, 2)}\n` : renderAudit(report),
15
+ if (options.redact === true && options.json !== true && options.ndjson !== true) {
16
+ throw new Error("audit --redact requires --json or --ndjson");
17
+ }
18
+ const clock = options.now ?? (() => new Date());
19
+ const commandId = randomUUID();
20
+ const salt = randomUUID();
21
+ const ndjson = [];
22
+ let sequence = 0;
23
+ const emitEvent = (event, timestamp, data) => {
24
+ const value = createCommandEvent({
25
+ event,
26
+ timestamp,
27
+ command: "audit",
28
+ commandId,
29
+ sequence: (sequence += 1),
30
+ ...(data === undefined ? {} : { data }),
31
+ });
32
+ const output = ndjsonRecord(value);
33
+ if (options.emit === undefined) {
34
+ ndjson.push(output);
35
+ }
36
+ else {
37
+ options.emit(output);
38
+ }
20
39
  };
40
+ const home = resolve(options.home);
41
+ const { config } = await loadConfigForHome(home, options.config);
42
+ const startedAt = clock().toISOString();
43
+ if (options.ndjson === true) {
44
+ emitEvent("command.started", startedAt, options.redact === true ? { home: "$HOME" } : { home });
45
+ }
46
+ try {
47
+ const report = await runAudit({
48
+ home,
49
+ config,
50
+ adapters: createAuditAdapters(config),
51
+ now: clock,
52
+ ...(options.ndjson === true
53
+ ? {
54
+ onEvent: (event) => {
55
+ emitEvent(event.type, event.timestamp, options.redact === true ? redactAuditValue(event.data, home, salt) : event.data);
56
+ },
57
+ }
58
+ : {}),
59
+ });
60
+ const layout = stateLayout(resolveStateRoot(home, options.stateDir));
61
+ const statePath = resolve(layout.audits, `${report.auditId}.json`);
62
+ await writeJsonAtomic(statePath, report, {
63
+ privateDirectories: [layout.root, layout.audits],
64
+ });
65
+ if (options.output !== undefined) {
66
+ await writeJsonAtomic(resolve(options.output), report);
67
+ }
68
+ const selectedReport = options.redact === true ? redactAuditReport(report, salt) : report;
69
+ if (options.ndjson === true) {
70
+ emitEvent("command.completed", report.completedAt, {
71
+ auditId: options.redact === true
72
+ ? redactAuditValue({ auditId: report.auditId }, home, salt).auditId
73
+ : report.auditId,
74
+ status: report.probes.some((probe) => probe.status === "degraded") ||
75
+ report.diagnostics.length > 0
76
+ ? "degraded"
77
+ : "ok",
78
+ probes: report.probes.length,
79
+ findings: report.findings.length,
80
+ });
81
+ }
82
+ const status = report.probes.some((probe) => probe.status === "degraded") || report.diagnostics.length > 0
83
+ ? "degraded"
84
+ : "ok";
85
+ return {
86
+ report,
87
+ statePath,
88
+ output: options.ndjson === true
89
+ ? ndjson.join("")
90
+ : options.json === true
91
+ ? jsonDocument(createCommandEnvelope({
92
+ command: "audit",
93
+ startedAt: report.startedAt,
94
+ completedAt: report.completedAt,
95
+ status,
96
+ data: selectedReport,
97
+ diagnostics: selectedReport.diagnostics,
98
+ }))
99
+ : renderAudit(report),
100
+ };
101
+ }
102
+ catch (error) {
103
+ if (options.ndjson === true) {
104
+ const data = {
105
+ status: "failed",
106
+ error: error instanceof Error ? error.message : String(error),
107
+ };
108
+ emitEvent("command.completed", clock().toISOString(), options.redact === true ? redactAuditValue(data, home, salt) : data);
109
+ }
110
+ throw error;
111
+ }
21
112
  }
22
113
  //# sourceMappingURL=audit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/commands/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAcxD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC;QAC5B,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;QAC3B,MAAM;QACN,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC;KACtC,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,MAAM,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,OAAO;QACL,MAAM;QACN,MAA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BAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;wBAC/B,MAAM;wBACN,IAAI,EAAE,cAAc;wBACpB,WAAW,EAAE,cAAc,CAAC,WAAW;qBACxC,CAAC,CACH;oBACH,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;SAC5B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG;gBACX,MAAM,EAAE,QAAQ;gBAChB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC;YACF,SAAS,CACP,mBAAmB,EACnB,KAAK,EAAE,CAAC,WAAW,EAAE,EACrB,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACpE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const completionShells: readonly ["bash", "zsh", "fish"];
2
+ export type CompletionShell = (typeof completionShells)[number];
3
+ export declare function renderCompletion(shell: string): string;
4
+ //# sourceMappingURL=completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAI,MAAM,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AA4FhE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWtD"}