agentrinse 0.4.0 → 0.5.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 (134) hide show
  1. package/README.md +57 -48
  2. package/dist/adapters/claude-cache.d.ts +3 -0
  3. package/dist/adapters/claude-cache.d.ts.map +1 -0
  4. package/dist/adapters/claude-cache.js +67 -0
  5. package/dist/adapters/claude-cache.js.map +1 -0
  6. package/dist/adapters/claude-debug.d.ts +3 -0
  7. package/dist/adapters/claude-debug.d.ts.map +1 -0
  8. package/dist/adapters/claude-debug.js +100 -0
  9. package/dist/adapters/claude-debug.js.map +1 -0
  10. package/dist/adapters/claude-retention.d.ts +36 -0
  11. package/dist/adapters/claude-retention.d.ts.map +1 -0
  12. package/dist/adapters/claude-retention.js +176 -0
  13. package/dist/adapters/claude-retention.js.map +1 -0
  14. package/dist/adapters/copilot-maintenance.d.ts +23 -0
  15. package/dist/adapters/copilot-maintenance.d.ts.map +1 -0
  16. package/dist/adapters/copilot-maintenance.js +53 -0
  17. package/dist/adapters/copilot-maintenance.js.map +1 -0
  18. package/dist/adapters/provider-adapter.d.ts +1 -0
  19. package/dist/adapters/provider-adapter.d.ts.map +1 -1
  20. package/dist/adapters/provider-adapter.js +209 -4
  21. package/dist/adapters/provider-adapter.js.map +1 -1
  22. package/dist/adapters/provider-root.d.ts +8 -0
  23. package/dist/adapters/provider-root.d.ts.map +1 -0
  24. package/dist/adapters/provider-root.js +27 -0
  25. package/dist/adapters/provider-root.js.map +1 -0
  26. package/dist/adapters/provider-specs.d.ts.map +1 -1
  27. package/dist/adapters/provider-specs.js +10 -0
  28. package/dist/adapters/provider-specs.js.map +1 -1
  29. package/dist/adapters/registry.d.ts.map +1 -1
  30. package/dist/adapters/registry.js +1 -0
  31. package/dist/adapters/registry.js.map +1 -1
  32. package/dist/commands/doctor.d.ts.map +1 -1
  33. package/dist/commands/doctor.js +2 -0
  34. package/dist/commands/doctor.js.map +1 -1
  35. package/dist/commands/purge.d.ts +7 -1
  36. package/dist/commands/purge.d.ts.map +1 -1
  37. package/dist/commands/purge.js +23 -0
  38. package/dist/commands/purge.js.map +1 -1
  39. package/dist/commands/show.d.ts.map +1 -1
  40. package/dist/commands/show.js +3 -0
  41. package/dist/commands/show.js.map +1 -1
  42. package/dist/commands/undo.d.ts +4 -1
  43. package/dist/commands/undo.d.ts.map +1 -1
  44. package/dist/commands/undo.js +18 -1
  45. package/dist/commands/undo.js.map +1 -1
  46. package/dist/contracts/action.d.ts +335 -2
  47. package/dist/contracts/action.d.ts.map +1 -1
  48. package/dist/contracts/action.js +52 -1
  49. package/dist/contracts/action.js.map +1 -1
  50. package/dist/contracts/finding.d.ts +153 -2
  51. package/dist/contracts/finding.d.ts.map +1 -1
  52. package/dist/contracts/plan.d.ts +152 -2
  53. package/dist/contracts/plan.d.ts.map +1 -1
  54. package/dist/contracts/plan.js +1 -1
  55. package/dist/contracts/plan.js.map +1 -1
  56. package/dist/contracts/provider-file-quarantine.d.ts +221 -0
  57. package/dist/contracts/provider-file-quarantine.d.ts.map +1 -0
  58. package/dist/contracts/provider-file-quarantine.js +61 -0
  59. package/dist/contracts/provider-file-quarantine.js.map +1 -0
  60. package/dist/contracts/report.d.ts +153 -2
  61. package/dist/contracts/report.d.ts.map +1 -1
  62. package/dist/contracts/resource.d.ts +3 -0
  63. package/dist/contracts/resource.d.ts.map +1 -1
  64. package/dist/contracts/resource.js +1 -0
  65. package/dist/contracts/resource.js.map +1 -1
  66. package/dist/contracts/run.d.ts +94 -0
  67. package/dist/contracts/run.d.ts.map +1 -1
  68. package/dist/contracts/run.js +7 -0
  69. package/dist/contracts/run.js.map +1 -1
  70. package/dist/core/apply.d.ts +5 -1
  71. package/dist/core/apply.d.ts.map +1 -1
  72. package/dist/core/apply.js +74 -3
  73. package/dist/core/apply.js.map +1 -1
  74. package/dist/core/no-clobber-rename.d.ts +1 -0
  75. package/dist/core/no-clobber-rename.d.ts.map +1 -1
  76. package/dist/core/no-clobber-rename.js +44 -0
  77. package/dist/core/no-clobber-rename.js.map +1 -1
  78. package/dist/core/pinned-file.d.ts +37 -0
  79. package/dist/core/pinned-file.d.ts.map +1 -0
  80. package/dist/core/pinned-file.js +228 -0
  81. package/dist/core/pinned-file.js.map +1 -0
  82. package/dist/core/plan.d.ts.map +1 -1
  83. package/dist/core/plan.js +4 -1
  84. package/dist/core/plan.js.map +1 -1
  85. package/dist/core/process-ownership.d.ts +1 -0
  86. package/dist/core/process-ownership.d.ts.map +1 -1
  87. package/dist/core/process-ownership.js +17 -3
  88. package/dist/core/process-ownership.js.map +1 -1
  89. package/dist/core/provider-file-executor.d.ts +40 -0
  90. package/dist/core/provider-file-executor.d.ts.map +1 -0
  91. package/dist/core/provider-file-executor.js +259 -0
  92. package/dist/core/provider-file-executor.js.map +1 -0
  93. package/dist/core/provider-file-identity.d.ts +8 -0
  94. package/dist/core/provider-file-identity.d.ts.map +1 -0
  95. package/dist/core/provider-file-identity.js +113 -0
  96. package/dist/core/provider-file-identity.js.map +1 -0
  97. package/dist/core/provider-file-policy.d.ts +19 -0
  98. package/dist/core/provider-file-policy.d.ts.map +1 -0
  99. package/dist/core/provider-file-policy.js +72 -0
  100. package/dist/core/provider-file-policy.js.map +1 -0
  101. package/dist/core/provider-file-recovery.d.ts +25 -0
  102. package/dist/core/provider-file-recovery.d.ts.map +1 -0
  103. package/dist/core/provider-file-recovery.js +393 -0
  104. package/dist/core/provider-file-recovery.js.map +1 -0
  105. package/dist/core/provider-file-revalidation.d.ts +20 -0
  106. package/dist/core/provider-file-revalidation.d.ts.map +1 -0
  107. package/dist/core/provider-file-revalidation.js +60 -0
  108. package/dist/core/provider-file-revalidation.js.map +1 -0
  109. package/dist/core/provider-processes.d.ts +18 -0
  110. package/dist/core/provider-processes.d.ts.map +1 -0
  111. package/dist/core/provider-processes.js +90 -0
  112. package/dist/core/provider-processes.js.map +1 -0
  113. package/dist/index.d.ts +3 -2
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +3 -2
  116. package/dist/index.js.map +1 -1
  117. package/dist/state/json-file.d.ts +2 -1
  118. package/dist/state/json-file.d.ts.map +1 -1
  119. package/dist/state/json-file.js +59 -2
  120. package/dist/state/json-file.js.map +1 -1
  121. package/dist/state/layout.d.ts +1 -0
  122. package/dist/state/layout.d.ts.map +1 -1
  123. package/dist/state/layout.js +1 -0
  124. package/dist/state/layout.js.map +1 -1
  125. package/dist/state/run-journal.d.ts.map +1 -1
  126. package/dist/state/run-journal.js +8 -2
  127. package/dist/state/run-journal.js.map +1 -1
  128. package/dist/version.d.ts +1 -1
  129. package/dist/version.js +1 -1
  130. package/package.json +1 -1
  131. package/schemas/audit.schema.json +786 -1
  132. package/schemas/plan.schema.json +785 -1
  133. package/schemas/provider-file-quarantine.schema.json +741 -0
  134. package/schemas/run.schema.json +85 -0
package/README.md CHANGED
@@ -15,11 +15,13 @@ protected or eligible, creates a content-addressed plan, and revalidates the
15
15
  same facts immediately before mutation.
16
16
 
17
17
  agentrinse is not audit-only. audit establishes the evidence; apply performs
18
- the approved filesystem, Git metadata, and offline database changes. `0.4.0`
19
- removes exact configured rebuildable artifacts, quarantines proven inactive linked
20
- worktrees, repairs and locks their Git registrations, restores quarantined
21
- worktrees, permanently purges explicitly selected quarantine entries, and
22
- compacts supported Codex SQLite state with a retained rollback copy.
18
+ the approved filesystem, Git metadata, and offline database changes. `0.5.0`
19
+ removes exact configured rebuildable artifacts, quarantines proven inactive
20
+ linked worktrees, repairs and locks their Git registrations, restores
21
+ quarantined worktrees, permanently purges explicitly selected quarantine
22
+ entries, and compacts supported Codex SQLite state with a retained rollback
23
+ copy. It also quarantines exact stale Claude debug logs and changelog cache
24
+ files with a seven-day undo window.
23
25
 
24
26
  the point is confidence: make real cleanup changes without deleting the
25
27
  session, branch, worktree, database content, or cache that another agent still
@@ -33,20 +35,24 @@ optional external handoff for broader macOS and project debris.
33
35
 
34
36
  ## cleanup actions
35
37
 
36
- | Action | Risk | What changes | Recovery |
37
- | ---------------------- | ------------ | ----------------------------------------------------------------------------- | --------------------------------------- |
38
- | 🧹 artifact removal | safe | atomically isolates and removes an exact configured rebuildable directory | rebuild from the project |
39
- | 🌿 worktree quarantine | recoverable | moves a linked worktree, creates a recovery ref, and repairs Git registration | `agentrinse undo <run-id>` |
40
- | 🗜️ Codex DB vacuum | experimental | builds and verifies a compacted SQLite copy, then retains the original file | `agentrinse undo <run-id>` before reuse |
41
- | ↩️ worktree undo | recoverable | restores the worktree path and Git registration | original quarantine remains journaled |
42
- | 🗑️ recovery purge | destructive | permanently removes an explicitly selected worktree or DB rollback copy | none |
43
- | ⚙️ config init | operational | creates the default config without overwriting an existing file | edit or remove the generated config |
44
- | 🔒 lock recovery | operational | removes only a stale AgentRinse lock after proving its process is gone | rerun the interrupted command |
45
-
46
- Codex sessions and every other provider store remain report-only. `0.4.0`
47
- adds one narrow exception: explicit offline compaction for the exact current
48
- Codex `state_5`, `logs_2`, `goals_1`, and `memories_1` SQLite contracts.
49
- Docker remains audit-only.
38
+ | Action | Risk | What changes | Recovery |
39
+ | ---------------------- | ------------ | ------------------------------------------------------------------------------ | --------------------------------------- |
40
+ | 🧹 artifact removal | safe | atomically isolates and removes an exact configured rebuildable directory | rebuild from the project |
41
+ | 🌿 worktree quarantine | recoverable | moves a linked worktree, creates a recovery ref, and repairs Git registration | `agentrinse undo <run-id>` |
42
+ | 🧾 provider quarantine | recoverable | moves an exact provider-owned disposable file into private recovery storage | `agentrinse undo <run-id>` |
43
+ | 🗜️ Codex DB vacuum | experimental | builds and verifies a compacted SQLite copy, then retains the original file | `agentrinse undo <run-id>` before reuse |
44
+ | ↩️ recovery undo | recoverable | restores a quarantined worktree, provider file, or database original | recovery remains journaled |
45
+ | 🗑️ recovery purge | destructive | permanently removes an explicitly selected worktree, provider file, or DB copy | none |
46
+ | ⚙️ config init | operational | creates the default config without overwriting an existing file | edit or remove the generated config |
47
+ | 🔒 lock recovery | operational | removes only a stale AgentRinse lock after proving its process is gone | rerun the interrupted command |
48
+
49
+ provider sessions, transcripts, credentials, configuration, and logical
50
+ database records remain report-only. `0.5.0` supports explicit offline
51
+ compaction for the exact current Codex `state_5`, `logs_2`, `goals_1`, and
52
+ `memories_1` SQLite contracts. Claude cleanup is limited to exact old debug
53
+ text files and its rebuildable changelog cache. AgentRinse also reports
54
+ Claude's native retention policy and Copilot's native session and process-log
55
+ maintenance. Docker remains audit-only.
50
56
 
51
57
  ## agent integrations
52
58
 
@@ -54,26 +60,29 @@ provider state is report-only unless the table below says otherwise.
54
60
  agentrinse never erases transcripts, sessions, credentials, configuration, or
55
61
  logical memory records.
56
62
 
57
- | Logo | Client | Mode | What it protects |
58
- | --------------------------------------------------------------------------- | ------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------- |
59
- | <img width="48px" src="docs/client-openai.jpg" alt="OpenAI Codex" /> | [OpenAI Codex](https://github.com/openai/codex) | audit + offline vacuum | sessions, workspace roots, reachability, and supported SQLite state |
60
- | <img width="48px" src="docs/client-claude.jpg" alt="Claude Code" /> | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | audit-only | sessions, workspace roots, and reachability |
61
- | <img width="48px" src="docs/client-cursor.jpg" alt="Cursor" /> | [Cursor](https://cursor.com/docs) | audit-only | local agent state and workspace references |
62
- | <img width="48px" src="docs/client-copilot.png" alt="GitHub Copilot CLI" /> | [GitHub Copilot CLI](https://github.com/github/copilot-cli) | audit-only | local session and configuration state |
63
- | <img width="48px" src="docs/client-zed.svg" alt="Zed" /> | [Zed](https://zed.dev/docs/ai/overview) | audit-only | local agent state |
64
- | <img width="48px" src="docs/client-opencode.png" alt="OpenCode" /> | [OpenCode](https://opencode.ai/) | audit-only | local agent state |
65
- | <img width="48px" src="docs/client-grok-build.svg" alt="Grok Build" /> | [Grok Build](https://docs.x.ai/build/overview) | audit-only | local agent state |
63
+ | Logo | Client | Mode | What it protects |
64
+ | --------------------------------------------------------------------------- | ----------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------- |
65
+ | <img width="48px" src="docs/client-openai.jpg" alt="OpenAI Codex" /> | [OpenAI Codex](https://github.com/openai/codex) | audit + offline vacuum | sessions, workspace roots, reachability, and supported SQLite state |
66
+ | <img width="48px" src="docs/client-claude.jpg" alt="Claude Code" /> | [Claude Code](https://code.claude.com/docs/en/overview) | retention + quarantine | sessions, caches, roots, native retention, and exact old files |
67
+ | <img width="48px" src="docs/client-cursor.jpg" alt="Cursor" /> | [Cursor](https://cursor.com/docs) | audit-only | local agent state and workspace references |
68
+ | <img width="48px" src="docs/client-copilot.png" alt="GitHub Copilot CLI" /> | [GitHub Copilot CLI](https://github.com/github/copilot-cli) | audit + native guidance | local sessions, process logs, and provider-owned maintenance |
69
+ | <img width="48px" src="docs/client-zed.svg" alt="Zed" /> | [Zed](https://zed.dev/docs/ai/overview) | audit-only | local agent state |
70
+ | <img width="48px" src="docs/client-opencode.png" alt="OpenCode" /> | [OpenCode](https://opencode.ai/) | audit-only | local agent state |
71
+ | <img width="48px" src="docs/client-grok-build.svg" alt="Grok Build" /> | [Grok Build](https://docs.x.ai/build/overview) | audit-only | local agent state |
66
72
 
67
73
  ## cleanup surfaces
68
74
 
69
- | Icon | Surface | Mode | What it understands |
70
- | -------------------------------------------------------------------- | ------------------------------------ | ------------------ | ----------------------------------------------------------------------- |
71
- | 🌿 | Git worktrees | audit + quarantine | linked worktrees, refs, dirtiness, locks, processes, and provider roots |
72
- | 🧹 | Build artifacts | safe-clean | exact configured rebuildable directories |
73
- | 🗜️ | Codex SQLite state | experimental | schema versions, free pages, sidecars, owner processes, and rollback |
74
- | | Agent runtimes | audit-only, opt-in | installed agent executables and versions |
75
- | <img width="48px" src="docs/client-docker-agent.svg" alt="Docker" /> | [Docker](https://docs.docker.com/) | audit-only, opt-in | images and containers |
76
- | 🕳️ | [Mole](https://github.com/tw93/Mole) | suggestions only | external dry-run cleanup opportunities on macOS |
75
+ | Icon | Surface | Mode | What it understands |
76
+ | --------------------------------------------------------------------------- | ------------------------------------ | ------------------ | ----------------------------------------------------------------------- |
77
+ | 🌿 | Git worktrees | audit + quarantine | linked worktrees, refs, dirtiness, locks, processes, and provider roots |
78
+ | 🧹 | Build artifacts | safe-clean | exact configured rebuildable directories |
79
+ | 🗜️ | Codex SQLite state | experimental | schema versions, free pages, sidecars, owner processes, and rollback |
80
+ | <img width="48px" src="docs/client-claude.jpg" alt="Claude Code" /> | Claude native retention | report-only | default or user retention, settings validity, and provider ownership |
81
+ | <img width="48px" src="docs/client-claude.jpg" alt="Claude Code" /> | Claude logs and changelog cache | recoverable | exact old files, provider liveness, seven-day undo, and explicit purge |
82
+ | <img width="48px" src="docs/client-copilot.png" alt="GitHub Copilot CLI" /> | Copilot native maintenance | report-only | local session pruning and versioned process-log retention |
83
+ | ⚡ | Agent runtimes | audit-only, opt-in | installed agent executables and versions |
84
+ | <img width="48px" src="docs/client-docker-agent.svg" alt="Docker" /> | [Docker](https://docs.docker.com/) | audit-only, opt-in | images and containers |
85
+ | 🕳️ | [Mole](https://github.com/tw93/Mole) | suggestions only | external dry-run cleanup opportunities on macOS |
77
86
 
78
87
  ## install
79
88
 
@@ -92,7 +101,7 @@ brew install vincentkoc/tap/agentrinse
92
101
  one-off use:
93
102
 
94
103
  ```bash
95
- npx agentrinse@0.4.0 doctor
104
+ npx agentrinse@0.5.0 doctor
96
105
  ```
97
106
 
98
107
  then:
@@ -212,7 +221,7 @@ agentrinse is built around refusal:
212
221
 
213
222
  there is no generic `--force` escape hatch.
214
223
 
215
- agentrinse `0.4.0` never removes:
224
+ agentrinse `0.5.0` never removes:
216
225
 
217
226
  - provider sessions, transcripts, logical database rows, credentials, or configuration
218
227
  - unsupported provider databases or Codex databases with unknown migrations
@@ -322,12 +331,12 @@ it can be verified before apply.
322
331
 
323
332
  ## platform support
324
333
 
325
- | Platform | `0.4.0` support |
326
- | -------------- | -------------------------------------------------------------- |
327
- | macOS | audit, artifact/worktree cleanup, Codex DB vacuum, undo, purge |
328
- | Linux | audit, artifact/worktree cleanup, Codex DB vacuum, undo, purge |
329
- | WSL | Linux contract inside the WSL filesystem |
330
- | native Windows | audit-only; mutation remains blocked before `1.0.0` |
334
+ | Platform | `0.5.0` support |
335
+ | -------------- | --------------------------------------------------------------- |
336
+ | macOS | audit, artifact/worktree/Claude cleanup, DB vacuum, undo, purge |
337
+ | Linux | audit, artifact/worktree/Claude cleanup, DB vacuum, undo, purge |
338
+ | WSL | Linux contract inside the WSL filesystem |
339
+ | native Windows | audit-only; mutation remains blocked before `1.0.0` |
331
340
 
332
341
  Git and `lsof` are required for the complete diagnostic and process-ownership
333
342
  contract. Codex DB maintenance additionally requires `sqlite3`. Docker is
@@ -362,9 +371,9 @@ unreleased build at real developer state.
362
371
 
363
372
  ## status
364
373
 
365
- `0.4.0` ships the complete audit → plan → revalidate → apply loop, safe
366
- configured artifact cleanup, recoverable Git worktree quarantine, and
367
- recoverable offline Codex database compaction. Docker and non-Codex provider
368
- state remain report-only.
374
+ `0.5.0` ships the complete audit → plan → revalidate → apply loop, safe
375
+ configured artifact cleanup, recoverable Git worktree and Claude file
376
+ quarantine, and recoverable offline Codex database compaction. Cursor, Zed,
377
+ OpenCode, Grok Build, and Docker remain report-only.
369
378
 
370
379
  MIT licensed. built by [Vincent Koc](https://github.com/vincentkoc).
@@ -0,0 +1,3 @@
1
+ import type { AuditContext, CollectionResult } from "../contracts/adapter.js";
2
+ export declare function collectClaudeChangelogCache(context: AuditContext, ownerRoot: string): Promise<CollectionResult>;
3
+ //# sourceMappingURL=claude-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-cache.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAc9E,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CA2D3B"}
@@ -0,0 +1,67 @@
1
+ import { lstat } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { sha256 } from "../core/digest.js";
4
+ import { inspectProviderFile } from "../core/provider-file-identity.js";
5
+ import { CLAUDE_CHANGELOG_CACHE_MIN_AGE_MINUTES, CLAUDE_CHANGELOG_CACHE_POLICY_ID, } from "../core/provider-file-policy.js";
6
+ function isMissing(error) {
7
+ return (error instanceof Error && "code" in error && error.code === "ENOENT");
8
+ }
9
+ export async function collectClaudeChangelogCache(context, ownerRoot) {
10
+ const cacheRoot = join(ownerRoot, "cache");
11
+ const path = join(cacheRoot, "changelog.md");
12
+ try {
13
+ const cacheStats = await lstat(cacheRoot);
14
+ if (cacheStats.isSymbolicLink() || !cacheStats.isDirectory()) {
15
+ return { resources: [], diagnostics: [] };
16
+ }
17
+ const stats = await lstat(path);
18
+ const cutoffMs = context.now.getTime() - CLAUDE_CHANGELOG_CACHE_MIN_AGE_MINUTES * 60_000;
19
+ if (!stats.isFile() || stats.isSymbolicLink() || stats.mtimeMs > cutoffMs) {
20
+ return { resources: [], diagnostics: [] };
21
+ }
22
+ const identity = await inspectProviderFile(path, ownerRoot, "claude");
23
+ const canonicalKey = `claude:changelog-cache:${identity.path}`;
24
+ return {
25
+ resources: [
26
+ {
27
+ resource: {
28
+ id: `claude:agent-cache:${sha256(canonicalKey)}`,
29
+ adapter: "claude",
30
+ kind: "agent-cache",
31
+ canonicalKey,
32
+ displayName: "Claude changelog cache",
33
+ path: identity.path,
34
+ },
35
+ observedAt: context.now.toISOString(),
36
+ exists: true,
37
+ measuredBytes: identity.measuredBytes,
38
+ facts: {
39
+ reportOnly: false,
40
+ maintenanceAction: "provider.file-quarantine",
41
+ policyId: CLAUDE_CHANGELOG_CACHE_POLICY_ID,
42
+ minAgeMinutes: CLAUDE_CHANGELOG_CACHE_MIN_AGE_MINUTES,
43
+ providerFileIdentity: identity,
44
+ },
45
+ },
46
+ ],
47
+ diagnostics: [],
48
+ };
49
+ }
50
+ catch (error) {
51
+ if (isMissing(error)) {
52
+ return { resources: [], diagnostics: [] };
53
+ }
54
+ return {
55
+ resources: [],
56
+ diagnostics: [
57
+ {
58
+ severity: "warning",
59
+ code: "CLAUDE_CHANGELOG_CACHE_INSPECTION_FAILED",
60
+ message: error instanceof Error ? error.message : String(error),
61
+ adapter: "claude",
62
+ },
63
+ ],
64
+ };
65
+ }
66
+ }
67
+ //# sourceMappingURL=claude-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-cache.js","sourceRoot":"","sources":["../../src/adapters/claude-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACL,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,iCAAiC,CAAC;AAEzC,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAChG,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAqB,EACrB,SAAiB;IAEjB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAE7C,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,UAAU,CAAC,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7D,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,KAAK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AE,CAAC;QAC5C,CAAC;QACD,OAAO;YACL,SAAS,EAAE,EAAE;YACb,WAAW,EAAE;gBACX;oBACE,QAAQ,EAAE,SAAS;oBACnB,IAAI,EAAE,0CAA0C;oBAChD,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC/D,OAAO,EAAE,QAAQ;iBAClB;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AuditContext, CollectionResult } from "../contracts/adapter.js";
2
+ export declare function collectClaudeDebugLogs(context: AuditContext, ownerRoot: string, maxEntries: number): Promise<CollectionResult>;
3
+ //# sourceMappingURL=claude-debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-debug.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-debug.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgB9E,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,CA6F3B"}
@@ -0,0 +1,100 @@
1
+ import { lstat, readdir } from "node:fs/promises";
2
+ import { basename, join } from "node:path";
3
+ import { sha256 } from "../core/digest.js";
4
+ import { inspectProviderFile } from "../core/provider-file-identity.js";
5
+ import { CLAUDE_DEBUG_LOG_MIN_AGE_MINUTES, CLAUDE_DEBUG_LOG_POLICY_ID, isClaudeDebugLogRelativePath, } from "../core/provider-file-policy.js";
6
+ function isMissing(error) {
7
+ return (error instanceof Error && "code" in error && error.code === "ENOENT");
8
+ }
9
+ export async function collectClaudeDebugLogs(context, ownerRoot, maxEntries) {
10
+ const debugRoot = join(ownerRoot, "debug");
11
+ const diagnostics = [];
12
+ let entries;
13
+ try {
14
+ const rootStats = await lstat(debugRoot);
15
+ if (rootStats.isSymbolicLink() || !rootStats.isDirectory()) {
16
+ return { resources: [], diagnostics };
17
+ }
18
+ entries = await readdir(debugRoot, { withFileTypes: true });
19
+ }
20
+ catch (error) {
21
+ if (isMissing(error)) {
22
+ return { resources: [], diagnostics };
23
+ }
24
+ return {
25
+ resources: [],
26
+ diagnostics: [
27
+ {
28
+ severity: "warning",
29
+ code: "CLAUDE_DEBUG_ENUMERATION_FAILED",
30
+ message: error instanceof Error ? error.message : String(error),
31
+ adapter: "claude",
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ if (entries.length > maxEntries) {
37
+ return {
38
+ resources: [],
39
+ diagnostics: [
40
+ {
41
+ severity: "warning",
42
+ code: "CLAUDE_DEBUG_ENUMERATION_TRUNCATED",
43
+ message: `Claude debug cleanup requires at most ${maxEntries} direct entries`,
44
+ adapter: "claude",
45
+ },
46
+ ],
47
+ };
48
+ }
49
+ const cutoffMs = context.now.getTime() - CLAUDE_DEBUG_LOG_MIN_AGE_MINUTES * 60_000;
50
+ const resources = [];
51
+ for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
52
+ context.signal?.throwIfAborted();
53
+ const path = join(debugRoot, entry.name);
54
+ const relativePath = join("debug", entry.name);
55
+ if (!isClaudeDebugLogRelativePath(relativePath)) {
56
+ continue;
57
+ }
58
+ try {
59
+ const stats = await lstat(path);
60
+ if (!stats.isFile() || stats.isSymbolicLink() || stats.mtimeMs > cutoffMs) {
61
+ continue;
62
+ }
63
+ const identity = await inspectProviderFile(path, ownerRoot, "claude");
64
+ const canonicalKey = `claude:debug-log:${identity.path}`;
65
+ resources.push({
66
+ resource: {
67
+ id: `claude:agent-log-store:${sha256(canonicalKey)}`,
68
+ adapter: "claude",
69
+ kind: "agent-log-store",
70
+ canonicalKey,
71
+ displayName: `Claude debug log ${basename(identity.path)}`,
72
+ path: identity.path,
73
+ },
74
+ observedAt: context.now.toISOString(),
75
+ exists: true,
76
+ measuredBytes: identity.measuredBytes,
77
+ facts: {
78
+ reportOnly: false,
79
+ maintenanceAction: "provider.file-quarantine",
80
+ policyId: CLAUDE_DEBUG_LOG_POLICY_ID,
81
+ minAgeMinutes: CLAUDE_DEBUG_LOG_MIN_AGE_MINUTES,
82
+ providerFileIdentity: identity,
83
+ },
84
+ });
85
+ }
86
+ catch (error) {
87
+ if (isMissing(error)) {
88
+ continue;
89
+ }
90
+ diagnostics.push({
91
+ severity: "warning",
92
+ code: "CLAUDE_DEBUG_FILE_INSPECTION_FAILED",
93
+ message: error instanceof Error ? error.message : String(error),
94
+ adapter: "claude",
95
+ });
96
+ }
97
+ }
98
+ return { resources, diagnostics };
99
+ }
100
+ //# sourceMappingURL=claude-debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-debug.js","sourceRoot":"","sources":["../../src/adapters/claude-debug.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAI3C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,iCAAiC,CAAC;AAEzC,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,CACL,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAChG,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,OAAqB,EACrB,SAAiB,EACjB,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAoC,EAAE,CAAC;IACxD,IAAI,OAAyB,CAAC;IAE9B,IAAI,CAAC;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0BAA0B;oBAC7C,QAAQ,EAAE,0BAA0B;oBACpC,aAAa,EAAE,gCAAgC;oBAC/C,oBAAoB,EAAE,QAAQ;iBAC/B;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;YACD,WAAW,CAAC,IAAI,CAAC;gBACf,QAAQ,EAAE,SAAS;gBACnB,IAAI,EAAE,qCAAqC;gBAC3C,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/D,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type Stats } from "node:fs";
2
+ import { type FileHandle } from "node:fs/promises";
3
+ import { z } from "zod";
4
+ import type { Diagnostic } from "../contracts/diagnostic.js";
5
+ export declare const CLAUDE_NATIVE_RETENTION_DEFAULT_DAYS = 30;
6
+ export declare const claudeNativeRetentionFactsSchema: z.ZodObject<{
7
+ mechanism: z.ZodLiteral<"cleanupPeriodDays">;
8
+ documentedDefaultDays: z.ZodLiteral<30>;
9
+ startupSweep: z.ZodLiteral<true>;
10
+ effectiveDaysKnown: z.ZodLiteral<false>;
11
+ userSettingsStatus: z.ZodEnum<{
12
+ changed: "changed";
13
+ invalid: "invalid";
14
+ missing: "missing";
15
+ "too-large": "too-large";
16
+ unreadable: "unreadable";
17
+ unsupported: "unsupported";
18
+ unverified: "unverified";
19
+ valid: "valid";
20
+ }>;
21
+ userConfiguredDays: z.ZodOptional<z.ZodNumber>;
22
+ }, z.core.$strip>;
23
+ export type ClaudeNativeRetentionFacts = z.infer<typeof claudeNativeRetentionFactsSchema>;
24
+ type SettingsFileHandle = Pick<FileHandle, "close" | "read" | "stat">;
25
+ export type ClaudeRetentionDependencies = {
26
+ lstat(path: string): Promise<Stats>;
27
+ open(path: string, flags: number): Promise<SettingsFileHandle>;
28
+ };
29
+ export type ClaudeRetentionInspection = {
30
+ facts: ClaudeNativeRetentionFacts;
31
+ diagnostics: Diagnostic[];
32
+ };
33
+ export declare function usesClaudeNativeRetention(relativePath: string): boolean;
34
+ export declare function inspectClaudeNativeRetention(ownerRoot: string, platform?: NodeJS.Platform, dependencies?: ClaudeRetentionDependencies): Promise<ClaudeRetentionInspection>;
35
+ export {};
36
+ //# sourceMappingURL=claude-retention.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-retention.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAI7D,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;iBAgB3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,KAAK,kBAAkB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,0BAA0B,CAAC;IAClC,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AA0EF,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED,wBAAsB,4BAA4B,CAChD,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,YAAY,GAAE,2BAAkD,GAC/D,OAAO,CAAC,yBAAyB,CAAC,CAyIpC"}
@@ -0,0 +1,176 @@
1
+ import { constants } from "node:fs";
2
+ import { lstat, open } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { z } from "zod";
5
+ const MAX_SETTINGS_BYTES = 1024 * 1024;
6
+ export const CLAUDE_NATIVE_RETENTION_DEFAULT_DAYS = 30;
7
+ export const claudeNativeRetentionFactsSchema = z.object({
8
+ mechanism: z.literal("cleanupPeriodDays"),
9
+ documentedDefaultDays: z.literal(CLAUDE_NATIVE_RETENTION_DEFAULT_DAYS),
10
+ startupSweep: z.literal(true),
11
+ effectiveDaysKnown: z.literal(false),
12
+ userSettingsStatus: z.enum([
13
+ "missing",
14
+ "valid",
15
+ "invalid",
16
+ "changed",
17
+ "unreadable",
18
+ "unsupported",
19
+ "too-large",
20
+ "unverified",
21
+ ]),
22
+ userConfiguredDays: z.number().int().min(1).optional(),
23
+ });
24
+ const DEFAULT_DEPENDENCIES = {
25
+ lstat,
26
+ open,
27
+ };
28
+ const NATIVE_RETENTION_PATHS = new Set(["projects", "debug", "paste-cache", "image-cache"]);
29
+ function isMissing(error) {
30
+ return (error instanceof Error && "code" in error && error.code === "ENOENT");
31
+ }
32
+ function stableStats(before, after) {
33
+ return (before.dev === after.dev &&
34
+ before.ino === after.ino &&
35
+ before.mode === after.mode &&
36
+ before.mtimeMs === after.mtimeMs &&
37
+ before.ctimeMs === after.ctimeMs &&
38
+ before.size === after.size);
39
+ }
40
+ async function readBoundedSettings(handle) {
41
+ const buffer = Buffer.allocUnsafe(MAX_SETTINGS_BYTES + 1);
42
+ let offset = 0;
43
+ while (offset < buffer.length) {
44
+ const result = await handle.read(buffer, offset, buffer.length - offset, offset);
45
+ if (result.bytesRead === 0) {
46
+ break;
47
+ }
48
+ offset += result.bytesRead;
49
+ }
50
+ if (offset > MAX_SETTINGS_BYTES) {
51
+ return { overflow: true };
52
+ }
53
+ return {
54
+ contents: buffer.subarray(0, offset).toString("utf8"),
55
+ overflow: false,
56
+ };
57
+ }
58
+ function inspection(userSettingsStatus, diagnostics = [], userConfiguredDays) {
59
+ return {
60
+ facts: {
61
+ mechanism: "cleanupPeriodDays",
62
+ documentedDefaultDays: CLAUDE_NATIVE_RETENTION_DEFAULT_DAYS,
63
+ startupSweep: true,
64
+ effectiveDaysKnown: false,
65
+ userSettingsStatus,
66
+ ...(userConfiguredDays === undefined ? {} : { userConfiguredDays }),
67
+ },
68
+ diagnostics,
69
+ };
70
+ }
71
+ function warning(code, message) {
72
+ return {
73
+ severity: "warning",
74
+ code,
75
+ message,
76
+ adapter: "claude",
77
+ };
78
+ }
79
+ export function usesClaudeNativeRetention(relativePath) {
80
+ return NATIVE_RETENTION_PATHS.has(relativePath);
81
+ }
82
+ export async function inspectClaudeNativeRetention(ownerRoot, platform = process.platform, dependencies = DEFAULT_DEPENDENCIES) {
83
+ const settingsPath = join(ownerRoot, "settings.json");
84
+ let entryStats;
85
+ try {
86
+ entryStats = await dependencies.lstat(settingsPath);
87
+ }
88
+ catch (error) {
89
+ if (isMissing(error)) {
90
+ return inspection("missing");
91
+ }
92
+ return inspection("unreadable", [
93
+ warning("CLAUDE_RETENTION_SETTINGS_UNREADABLE", "Claude user settings could not be inspected; native retention is uncertain."),
94
+ ]);
95
+ }
96
+ if (entryStats.isSymbolicLink() || !entryStats.isFile()) {
97
+ return inspection("unsupported", [
98
+ warning("CLAUDE_RETENTION_SETTINGS_UNSUPPORTED", "Claude user settings are not a direct regular file; native retention is uncertain."),
99
+ ]);
100
+ }
101
+ if (entryStats.size > MAX_SETTINGS_BYTES) {
102
+ return inspection("too-large", [
103
+ warning("CLAUDE_RETENTION_SETTINGS_TOO_LARGE", "Claude user settings exceed the inspection limit; native retention is uncertain."),
104
+ ]);
105
+ }
106
+ let handle;
107
+ try {
108
+ const flags = platform === "win32" ? constants.O_RDONLY : constants.O_RDONLY | constants.O_NOFOLLOW;
109
+ handle = await dependencies.open(settingsPath, flags);
110
+ }
111
+ catch {
112
+ return inspection("unreadable", [
113
+ warning("CLAUDE_RETENTION_SETTINGS_UNREADABLE", "Claude user settings could not be opened safely; native retention is uncertain."),
114
+ ]);
115
+ }
116
+ let contents;
117
+ try {
118
+ const before = await handle.stat();
119
+ if (!before.isFile() || !stableStats(entryStats, before) || before.size > MAX_SETTINGS_BYTES) {
120
+ return inspection("changed", [
121
+ warning("CLAUDE_RETENTION_SETTINGS_CHANGED", "Claude user settings changed during inspection; native retention is uncertain."),
122
+ ]);
123
+ }
124
+ const boundedRead = await readBoundedSettings(handle);
125
+ const after = await handle.stat();
126
+ if (!stableStats(before, after)) {
127
+ return inspection("changed", [
128
+ warning("CLAUDE_RETENTION_SETTINGS_CHANGED", "Claude user settings changed during inspection; native retention is uncertain."),
129
+ ]);
130
+ }
131
+ if (boundedRead.overflow || boundedRead.contents === undefined) {
132
+ return inspection("too-large", [
133
+ warning("CLAUDE_RETENTION_SETTINGS_TOO_LARGE", "Claude user settings exceed the inspection limit; native retention is uncertain."),
134
+ ]);
135
+ }
136
+ contents = boundedRead.contents;
137
+ }
138
+ catch {
139
+ return inspection("unreadable", [
140
+ warning("CLAUDE_RETENTION_SETTINGS_UNREADABLE", "Claude user settings could not be read safely; native retention is uncertain."),
141
+ ]);
142
+ }
143
+ finally {
144
+ await handle.close().catch(() => undefined);
145
+ }
146
+ let value;
147
+ try {
148
+ value = JSON.parse(contents.replace(/^\uFEFF/u, ""));
149
+ }
150
+ catch {
151
+ return inspection("invalid", [
152
+ warning("CLAUDE_RETENTION_SETTINGS_INVALID", "Claude user settings are not valid JSON; Claude may pause its native retention sweep."),
153
+ ]);
154
+ }
155
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
156
+ return inspection("invalid", [
157
+ warning("CLAUDE_RETENTION_SETTINGS_INVALID", "Claude user settings must be a JSON object; Claude may pause its native retention sweep."),
158
+ ]);
159
+ }
160
+ const settings = value;
161
+ const cleanupPeriodDays = settings.cleanupPeriodDays;
162
+ if (cleanupPeriodDays !== undefined &&
163
+ (!Number.isInteger(cleanupPeriodDays) || cleanupPeriodDays < 1)) {
164
+ return inspection("invalid", [
165
+ warning("CLAUDE_RETENTION_SETTINGS_INVALID", "Claude cleanupPeriodDays must be an integer of at least 1; native retention is uncertain."),
166
+ ]);
167
+ }
168
+ const userConfiguredDays = cleanupPeriodDays === undefined ? undefined : cleanupPeriodDays;
169
+ if (Object.keys(settings).some((key) => key !== "cleanupPeriodDays")) {
170
+ return inspection("unverified", [
171
+ warning("CLAUDE_RETENTION_SETTINGS_UNVERIFIED", "Claude user settings contain fields AgentRinse does not validate; native retention is uncertain."),
172
+ ], userConfiguredDays);
173
+ }
174
+ return inspection("valid", [], userConfiguredDays);
175
+ }
176
+ //# sourceMappingURL=claude-retention.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-retention.js","sourceRoot":"","sources":["../../src/adapters/claude-retention.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEvD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,m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BAAkB,CACnB,CAAC;IACJ,CAAC;IACD,OAAO,UAAU,CAAC,OAAO,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ export declare const copilotNativeMaintenanceFactsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ provider: z.ZodLiteral<"copilot">;
4
+ kind: z.ZodLiteral<"session-prune">;
5
+ command: z.ZodLiteral<"/session prune --older-than <days> [--dry-run] [--include-named]">;
6
+ localOnly: z.ZodLiteral<true>;
7
+ dryRunSupported: z.ZodLiteral<true>;
8
+ currentSessionExcluded: z.ZodLiteral<true>;
9
+ namedSessionsExcludedByDefault: z.ZodLiteral<true>;
10
+ installedSupportKnown: z.ZodLiteral<false>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ provider: z.ZodLiteral<"copilot">;
13
+ kind: z.ZodLiteral<"process-log-retention">;
14
+ introducedVersion: z.ZodLiteral<"1.0.52">;
15
+ filePattern: z.ZodLiteral<"process-*.log">;
16
+ maxAgeDays: z.ZodLiteral<7>;
17
+ maxFiles: z.ZodLiteral<50>;
18
+ extensionLogsExcluded: z.ZodLiteral<true>;
19
+ installedSupportKnown: z.ZodLiteral<false>;
20
+ }, z.core.$strip>], "kind">;
21
+ export type CopilotNativeMaintenanceFacts = z.infer<typeof copilotNativeMaintenanceFactsSchema>;
22
+ export declare function copilotNativeMaintenanceFor(relativePath: string): CopilotNativeMaintenanceFacts | undefined;
23
+ //# sourceMappingURL=copilot-maintenance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-maintenance.d.ts","sourceRoot":"","sources":["../../src/adapters/copilot-maintenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;2BAG9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,GACnB,6BAA6B,GAAG,SAAS,CA0B3C"}