@cleocode/core 2026.6.15 → 2026.6.18
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/dist/docs/export-document.js +41 -0
- package/dist/docs/export-document.js.map +1 -1
- package/dist/gc/janitor.d.ts +149 -0
- package/dist/gc/janitor.d.ts.map +1 -0
- package/dist/gc/janitor.js +760 -0
- package/dist/gc/janitor.js.map +1 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +3 -0
- package/dist/internal.js.map +1 -1
- package/dist/llm/cli-ops.d.ts +15 -4
- package/dist/llm/cli-ops.d.ts.map +1 -1
- package/dist/llm/cli-ops.js +78 -21
- package/dist/llm/cli-ops.js.map +1 -1
- package/dist/llm/credential-pool.d.ts +62 -0
- package/dist/llm/credential-pool.d.ts.map +1 -1
- package/dist/llm/credential-pool.js +161 -0
- package/dist/llm/credential-pool.js.map +1 -1
- package/dist/llm/cross-provider-selector.d.ts +8 -3
- package/dist/llm/cross-provider-selector.d.ts.map +1 -1
- package/dist/llm/cross-provider-selector.js +71 -8
- package/dist/llm/cross-provider-selector.js.map +1 -1
- package/dist/llm/plugin-facade.js +122 -1
- package/dist/llm/plugin-facade.js.map +1 -1
- package/dist/selfimprove/fix-gen-context.d.ts +172 -0
- package/dist/selfimprove/fix-gen-context.d.ts.map +1 -0
- package/dist/selfimprove/fix-gen-context.js +218 -0
- package/dist/selfimprove/fix-gen-context.js.map +1 -0
- package/dist/selfimprove/fix-gen.d.ts +60 -4
- package/dist/selfimprove/fix-gen.d.ts.map +1 -1
- package/dist/selfimprove/fix-gen.js +76631 -256
- package/dist/selfimprove/fix-gen.js.map +6 -1
- package/dist/selfimprove/op-source-map.d.ts +92 -0
- package/dist/selfimprove/op-source-map.d.ts.map +1 -0
- package/dist/selfimprove/op-source-map.js +187 -0
- package/dist/selfimprove/op-source-map.js.map +1 -0
- package/dist/selfimprove/probe-helper.d.ts +61 -0
- package/dist/selfimprove/probe-helper.d.ts.map +1 -0
- package/dist/selfimprove/probe-helper.js +64 -0
- package/dist/selfimprove/probe-helper.js.map +1 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/golden.json +18 -0
- package/dist/selfimprove/scenarios/seeded-code-regression/scenario.json +12 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.d.ts.map +1 -1
- package/dist/setup/index.js +1 -0
- package/dist/setup/index.js.map +1 -1
- package/dist/setup/sections/models-roles.d.ts +32 -1
- package/dist/setup/sections/models-roles.d.ts.map +1 -1
- package/dist/setup/sections/models-roles.js +118 -19
- package/dist/setup/sections/models-roles.js.map +1 -1
- package/dist/setup/whoami-summary.d.ts +34 -0
- package/dist/setup/whoami-summary.d.ts.map +1 -0
- package/dist/setup/whoami-summary.js +106 -0
- package/dist/setup/whoami-summary.js.map +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLEO Janitor — orphan process reaper + stale scope/lock/debris sweep.
|
|
3
|
+
*
|
|
4
|
+
* Composable engine that the GC subsystem and the `cleo janitor run` CLI verb
|
|
5
|
+
* call. Every action is:
|
|
6
|
+
* - Silent: no console output; one JSONL line per action appended to
|
|
7
|
+
* `.cleo/audit/janitor.jsonl`, plus counts in the returned result.
|
|
8
|
+
* - Idempotent: a fully-converged state produces zero actions on re-run.
|
|
9
|
+
* - Dry-run capable: `dryRun: true` reports planned actions without mutating
|
|
10
|
+
* anything.
|
|
11
|
+
*
|
|
12
|
+
* ## Categories
|
|
13
|
+
*
|
|
14
|
+
* | # | Category | Description |
|
|
15
|
+
* |---|--------------------------|------------------------------------------------------|
|
|
16
|
+
* | 1 | `reaped` | Leaked MCP/agent helpers (registration-primary) |
|
|
17
|
+
* | 2 | `scopesStopped` | Cleo-owned systemd transient scopes that exited |
|
|
18
|
+
* | 3 | `locksReclaimed` | Sentient/GC lock files held by dead PIDs |
|
|
19
|
+
* | 4 | `semaphoreSlotsCleared` | Tool-semaphore slot dirs held past staleMs |
|
|
20
|
+
* | 5 | `worktreesPruned` | Orphan worktree directories |
|
|
21
|
+
* | 6 | `worktreesQuarantined` | Dirty/unpushed worktrees quarantined |
|
|
22
|
+
* | 7 | `tmpRemoved` | Stale CLEO temp directories |
|
|
23
|
+
* | 8 | `attachmentsRepaired` | Attachment rows/files repaired |
|
|
24
|
+
* | 9 | `configsRepaired` | Corrupt config files restored |
|
|
25
|
+
*
|
|
26
|
+
* ## Amendment compliance
|
|
27
|
+
*
|
|
28
|
+
* - **Amendment 1 (registration-primary)**: orphan detection uses cleo-owned
|
|
29
|
+
* scope/pgid as PRIMARY discriminator; signature+age only for UNREGISTERED
|
|
30
|
+
* processes when all stdio pipe peers are dead.
|
|
31
|
+
* - **Amendment 2 (regression)**: reparented double-fork of a LIVE session is
|
|
32
|
+
* preserved; same of a DEAD session is reaped.
|
|
33
|
+
* - **Amendment 3 (scope reaping)**: restricted to units starting with
|
|
34
|
+
* `cleo-` prefix inside `cleo.slice`. Never touches `run-*.scope`.
|
|
35
|
+
* - **Amendment 4 (idempotency)**: TERM→KILL escalation spanning runs is
|
|
36
|
+
* legitimate; a fully-converged state produces zero actions on second run.
|
|
37
|
+
* - **Amendment 5 (liveness probe)**: stale locks reclaimed only after
|
|
38
|
+
* verifying the holder PID is dead — never on mtime alone.
|
|
39
|
+
* - **Amendment 6 (silence)**: every action → `.cleo/audit/janitor.jsonl`;
|
|
40
|
+
* zero desktop notifications; zero console noise in non-verbose mode.
|
|
41
|
+
* - **Amendment 7 (tmp debris)**: reuses `gc/cleanup.ts` patterns directly.
|
|
42
|
+
*
|
|
43
|
+
* @module @cleocode/core/gc/janitor
|
|
44
|
+
* @task T11995
|
|
45
|
+
* @epic T11992
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Default minimum age (ms) of an unregistered process before reap eligibility.
|
|
49
|
+
* 10 minutes gives a freshly-spawned MCP server time to register.
|
|
50
|
+
*/
|
|
51
|
+
export declare const DEFAULT_GRACE_MS: number;
|
|
52
|
+
/**
|
|
53
|
+
* Default SIGTERM→SIGKILL grace period (ms).
|
|
54
|
+
* Matches suite-reaper.ts value for consistency.
|
|
55
|
+
*/
|
|
56
|
+
export declare const SIGTERM_GRACE_MS = 3000;
|
|
57
|
+
/**
|
|
58
|
+
* Default stale-ms for tool-semaphore slot lock directories.
|
|
59
|
+
* Matches tool-semaphore.ts default.
|
|
60
|
+
*/
|
|
61
|
+
export declare const DEFAULT_SEMAPHORE_STALE_MS = 600000;
|
|
62
|
+
/** Per-category result counts returned by {@link runJanitor}. */
|
|
63
|
+
export interface JanitorResult {
|
|
64
|
+
/** Orphan agent/MCP processes sent SIGTERM or SIGKILL. */
|
|
65
|
+
readonly reaped: number;
|
|
66
|
+
/** Cleo-owned transient scopes stopped + reset-failed. */
|
|
67
|
+
readonly scopesStopped: number;
|
|
68
|
+
/** Stale PID lock files reclaimed (sentient, gc). */
|
|
69
|
+
readonly locksReclaimed: number;
|
|
70
|
+
/** Stale tool-semaphore slot directories cleared. */
|
|
71
|
+
readonly semaphoreSlotsCleared: number;
|
|
72
|
+
/** Orphan worktree directories removed. */
|
|
73
|
+
readonly worktreesPruned: number;
|
|
74
|
+
/** Dirty/unpushed worktrees quarantined (not deleted). */
|
|
75
|
+
readonly worktreesQuarantined: number;
|
|
76
|
+
/** Stale CLEO tmp dirs removed. */
|
|
77
|
+
readonly tmpRemoved: number;
|
|
78
|
+
/** Attachment orphans marked or deleted. */
|
|
79
|
+
readonly attachmentsRepaired: number;
|
|
80
|
+
/** Corrupt config files restored from backup. */
|
|
81
|
+
readonly configsRepaired: number;
|
|
82
|
+
/** Total non-fatal errors encountered. */
|
|
83
|
+
readonly errors: number;
|
|
84
|
+
/** True when `dryRun: true` was set — no mutations were performed. */
|
|
85
|
+
readonly dryRun: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Options for {@link runJanitor}. */
|
|
88
|
+
export interface JanitorOptions {
|
|
89
|
+
/**
|
|
90
|
+
* When true, report planned actions without performing any mutations.
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
dryRun?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Minimum age (ms) of an unregistered process before reap eligibility.
|
|
96
|
+
* @default DEFAULT_GRACE_MS (10 min)
|
|
97
|
+
*/
|
|
98
|
+
gracePeriodMs?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Absolute path to the project-level `.cleo/` directory.
|
|
101
|
+
* Defaults to `resolveCleoDir()` using the current working directory.
|
|
102
|
+
*/
|
|
103
|
+
cleoDir?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Root of the CLEO worktrees hierarchy.
|
|
106
|
+
* Defaults to `~/.local/share/cleo/worktrees/`.
|
|
107
|
+
*/
|
|
108
|
+
worktreesRoot?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Set of active (non-terminal) task IDs for the worktree prune guard.
|
|
111
|
+
* When `undefined`, worktree pruning is skipped entirely.
|
|
112
|
+
*/
|
|
113
|
+
activeTaskIds?: Set<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Selectively skip categories. Omit or set `false` to run all.
|
|
116
|
+
*/
|
|
117
|
+
skip?: {
|
|
118
|
+
processes?: boolean;
|
|
119
|
+
scopes?: boolean;
|
|
120
|
+
locks?: boolean;
|
|
121
|
+
semaphores?: boolean;
|
|
122
|
+
worktrees?: boolean;
|
|
123
|
+
tmp?: boolean;
|
|
124
|
+
attachments?: boolean;
|
|
125
|
+
config?: boolean;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check whether a PID is alive via `kill(pid, 0)`.
|
|
130
|
+
* Returns `false` for ESRCH or any other error.
|
|
131
|
+
*/
|
|
132
|
+
export declare function isPidAlive(pid: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Run the CLEO janitor sweep.
|
|
135
|
+
*
|
|
136
|
+
* Runs all enabled categories and returns a structured result with per-category
|
|
137
|
+
* counts. Designed to be called from:
|
|
138
|
+
* - `cleo janitor run [--dry-run]` (manual verb)
|
|
139
|
+
* - GC subsystem sentient tick (daemon mode)
|
|
140
|
+
* - Session start/end (daemon-off lazy mode)
|
|
141
|
+
*
|
|
142
|
+
* @param opts - Janitor options.
|
|
143
|
+
* @returns Structured result.
|
|
144
|
+
*
|
|
145
|
+
* @task T11995
|
|
146
|
+
* @epic T11992
|
|
147
|
+
*/
|
|
148
|
+
export declare function runJanitor(opts?: JanitorOptions): Promise<JanitorResult>;
|
|
149
|
+
//# sourceMappingURL=janitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"janitor.d.ts","sourceRoot":"","sources":["../../src/gc/janitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAwBH;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAiB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,OAAQ,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAsClD,iEAAiE;AACjE,MAAM,WAAW,aAAa;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,qDAAqD;IACrD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,2CAA2C;IAC3C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,mCAAmC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4CAA4C;IAC5C,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,iDAAiD;IACjD,QAAQ,CAAC,eAAe,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