@cleocode/core 2026.10.2 → 2026.10.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/dist/build-provenance.json +2 -2
- package/dist/cloud/http.d.ts +2 -0
- package/dist/cloud/http.d.ts.map +1 -1
- package/dist/cloud/http.js +3 -0
- package/dist/cloud/http.js.map +1 -1
- package/dist/cloud/manifest-check.d.ts.map +1 -1
- package/dist/cloud/manifest-check.js +13 -0
- package/dist/cloud/manifest-check.js.map +1 -1
- package/dist/cloud/nexus-enrol.d.ts +9 -0
- package/dist/cloud/nexus-enrol.d.ts.map +1 -1
- package/dist/cloud/nexus-enrol.js +45 -2
- package/dist/cloud/nexus-enrol.js.map +1 -1
- package/dist/cloud/nexus-first-run.d.ts +142 -0
- package/dist/cloud/nexus-first-run.d.ts.map +1 -0
- package/dist/cloud/nexus-first-run.js +352 -0
- package/dist/cloud/nexus-first-run.js.map +1 -0
- package/dist/cloud/nexus-project-names.d.ts +173 -0
- package/dist/cloud/nexus-project-names.d.ts.map +1 -0
- package/dist/cloud/nexus-project-names.js +314 -0
- package/dist/cloud/nexus-project-names.js.map +1 -0
- package/dist/cloud/nexus-vault-keys.d.ts +35 -3
- package/dist/cloud/nexus-vault-keys.d.ts.map +1 -1
- package/dist/cloud/nexus-vault-keys.js +212 -22
- package/dist/cloud/nexus-vault-keys.js.map +1 -1
- package/dist/cloud/nexus-vault.d.ts.map +1 -1
- package/dist/cloud/nexus-vault.js +14 -2
- package/dist/cloud/nexus-vault.js.map +1 -1
- package/dist/dispatch/contracts/derive-output-contract.d.ts +1 -1
- package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -1
- package/dist/dispatch/contracts/derive-output-contract.js +2 -1
- package/dist/dispatch/contracts/derive-output-contract.js.map +1 -1
- package/dist/dispatch/contracts/output-contracts.d.ts +2 -1
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/output-contracts.js +1 -1
- package/dist/dispatch/contracts/output-contracts.js.map +1 -1
- package/dist/dispatch/mvi-projection.d.ts +1 -1
- package/dist/dispatch/mvi-projection.d.ts.map +1 -1
- package/dist/dispatch/mvi-projection.js +1 -1
- package/dist/dispatch/mvi-projection.js.map +1 -1
- package/dist/docs/export-document.js +24462 -24572
- package/dist/docs/export-document.js.map +3 -3
- package/dist/doctor/db-substrate.d.ts +6 -9
- package/dist/doctor/db-substrate.d.ts.map +1 -1
- package/dist/doctor/db-substrate.js +10 -14
- package/dist/doctor/db-substrate.js.map +1 -1
- package/dist/doctor/migrations.d.ts +18 -0
- package/dist/doctor/migrations.d.ts.map +1 -1
- package/dist/doctor/migrations.js +54 -2
- package/dist/doctor/migrations.js.map +1 -1
- package/dist/error-catalog.js +1 -1
- package/dist/error-catalog.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +21 -5
- package/dist/init.js.map +1 -1
- package/dist/llm/conversation.d.ts.map +1 -1
- package/dist/llm/conversation.js +15 -4
- package/dist/llm/conversation.js.map +1 -1
- package/dist/llm/plugin-facade.js +277 -376
- package/dist/llm/plugin-facade.js.map +3 -3
- package/dist/llm/transports/bedrock.d.ts +1 -0
- package/dist/llm/transports/bedrock.d.ts.map +1 -1
- package/dist/llm/transports/bedrock.js +30 -12
- package/dist/llm/transports/bedrock.js.map +1 -1
- package/dist/memory/decision-contradiction.d.ts.map +1 -1
- package/dist/memory/decision-contradiction.js +10 -5
- package/dist/memory/decision-contradiction.js.map +1 -1
- package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
- package/dist/memory/dialectic-evaluator.js +4 -1
- package/dist/memory/dialectic-evaluator.js.map +1 -1
- package/dist/memory/transcript-extractor.d.ts.map +1 -1
- package/dist/memory/transcript-extractor.js +3 -2
- package/dist/memory/transcript-extractor.js.map +1 -1
- package/dist/metrics/token-service.d.ts +16 -0
- package/dist/metrics/token-service.d.ts.map +1 -1
- package/dist/metrics/token-service.js +18 -0
- package/dist/metrics/token-service.js.map +1 -1
- package/dist/nexus/api-contracts.d.ts.map +1 -1
- package/dist/nexus/api-contracts.js +27 -11
- package/dist/nexus/api-contracts.js.map +1 -1
- package/dist/nexus/api-extractors/http-extractor.d.ts +2 -2
- package/dist/nexus/api-extractors/http-extractor.d.ts.map +1 -1
- package/dist/nexus/api-extractors/http-extractor.js +3 -3
- package/dist/nexus/api-extractors/http-extractor.js.map +1 -1
- package/dist/nexus/clusters.js +1 -1
- package/dist/nexus/clusters.js.map +1 -1
- package/dist/nexus/diff.d.ts +1 -1
- package/dist/nexus/diff.d.ts.map +1 -1
- package/dist/nexus/diff.js +3 -2
- package/dist/nexus/diff.js.map +1 -1
- package/dist/nexus/flows.js +1 -1
- package/dist/nexus/flows.js.map +1 -1
- package/dist/nexus/identity.d.ts +8 -0
- package/dist/nexus/identity.d.ts.map +1 -1
- package/dist/nexus/identity.js +17 -1
- package/dist/nexus/identity.js.map +1 -1
- package/dist/nexus/index.d.ts +1 -1
- package/dist/nexus/index.d.ts.map +1 -1
- package/dist/nexus/index.js +2 -2
- package/dist/nexus/index.js.map +1 -1
- package/dist/nexus/nexus-bridge.d.ts.map +1 -1
- package/dist/nexus/nexus-bridge.js +5 -5
- package/dist/nexus/nexus-bridge.js.map +1 -1
- package/dist/nexus/registry.d.ts +22 -0
- package/dist/nexus/registry.d.ts.map +1 -1
- package/dist/nexus/registry.js +76 -1
- package/dist/nexus/registry.js.map +1 -1
- package/dist/paths.js +1 -1
- package/dist/paths.js.map +1 -1
- package/dist/project-scope.js +1 -1
- package/dist/project-scope.js.map +1 -1
- package/dist/project-tombstone.js +1 -1
- package/dist/project-tombstone.js.map +1 -1
- package/dist/release/open.d.ts +3 -6
- package/dist/release/open.d.ts.map +1 -1
- package/dist/release/open.js +59 -23
- package/dist/release/open.js.map +1 -1
- package/dist/release/preflight-skip.d.ts +69 -10
- package/dist/release/preflight-skip.d.ts.map +1 -1
- package/dist/release/preflight-skip.js +195 -47
- package/dist/release/preflight-skip.js.map +1 -1
- package/dist/render/colors.js +1 -19
- package/dist/render/colors.js.map +1 -1
- package/dist/render/tasks/colors.js +1 -1
- package/dist/render/tasks/colors.js.map +1 -1
- package/dist/resources/governor.d.ts +12 -0
- package/dist/resources/governor.d.ts.map +1 -1
- package/dist/resources/governor.js +5 -1
- package/dist/resources/governor.js.map +1 -1
- package/dist/resources/heavy-command-hook-delivery.d.ts +144 -0
- package/dist/resources/heavy-command-hook-delivery.d.ts.map +1 -0
- package/dist/resources/heavy-command-hook-delivery.js +204 -0
- package/dist/resources/heavy-command-hook-delivery.js.map +1 -0
- package/dist/resources/heavy-command.d.ts +69 -0
- package/dist/resources/heavy-command.d.ts.map +1 -1
- package/dist/resources/heavy-command.js +479 -7
- package/dist/resources/heavy-command.js.map +1 -1
- package/dist/resources/run-class.d.ts.map +1 -1
- package/dist/resources/run-class.js +1 -0
- package/dist/resources/run-class.js.map +1 -1
- package/dist/routing/build-command-groups.d.ts +1 -1
- package/dist/routing/build-command-groups.d.ts.map +1 -1
- package/dist/routing/build-command-groups.js +4 -1
- package/dist/routing/build-command-groups.js.map +1 -1
- package/dist/scaffold/ensure-skills.d.ts.map +1 -1
- package/dist/scaffold/ensure-skills.js +58 -2
- package/dist/scaffold/ensure-skills.js.map +1 -1
- package/dist/selfimprove/fix-gen.js +277 -376
- package/dist/selfimprove/fix-gen.js.map +3 -3
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/briefing.js +11 -0
- package/dist/sessions/briefing.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +6 -1
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/portable-bundle-scan.d.ts +22 -0
- package/dist/store/portable-bundle-scan.d.ts.map +1 -1
- package/dist/store/portable-bundle-scan.js +97 -25
- package/dist/store/portable-bundle-scan.js.map +1 -1
- package/dist/store/portable-bundle.d.ts +7 -0
- package/dist/store/portable-bundle.d.ts.map +1 -1
- package/dist/store/portable-bundle.js +10 -1
- package/dist/store/portable-bundle.js.map +1 -1
- package/dist/store/table-classification.d.ts +27 -0
- package/dist/store/table-classification.d.ts.map +1 -1
- package/dist/store/table-classification.js +32 -0
- package/dist/store/table-classification.js.map +1 -1
- package/dist/store/vault-manifest.d.ts +5 -1
- package/dist/store/vault-manifest.d.ts.map +1 -1
- package/dist/store/vault-manifest.js +9 -2
- package/dist/store/vault-manifest.js.map +1 -1
- package/dist/system/health.d.ts +13 -0
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +96 -1
- package/dist/system/health.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts +20 -7
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +39 -13
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/affected-template.d.ts +93 -0
- package/dist/tasks/affected-template.d.ts.map +1 -0
- package/dist/tasks/affected-template.js +198 -0
- package/dist/tasks/affected-template.js.map +1 -0
- package/dist/tasks/command-line.d.ts +4 -1
- package/dist/tasks/command-line.d.ts.map +1 -1
- package/dist/tasks/command-line.js +7 -2
- package/dist/tasks/command-line.js.map +1 -1
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +12 -2
- package/dist/tasks/done-plan.js.map +1 -1
- package/dist/tasks/duplicate-detector.d.ts.map +1 -1
- package/dist/tasks/duplicate-detector.js +11 -5
- package/dist/tasks/duplicate-detector.js.map +1 -1
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +185 -11
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/heavy-tool-env.d.ts +385 -18
- package/dist/tasks/heavy-tool-env.d.ts.map +1 -1
- package/dist/tasks/heavy-tool-env.js +719 -40
- package/dist/tasks/heavy-tool-env.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/tasks/index.d.ts.map +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/tasks/index.js.map +1 -1
- package/dist/tasks/tool-cache-env.d.ts +20 -13
- package/dist/tasks/tool-cache-env.d.ts.map +1 -1
- package/dist/tasks/tool-cache-env.js +27 -48
- package/dist/tasks/tool-cache-env.js.map +1 -1
- package/dist/tasks/tool-cache.d.ts +8 -0
- package/dist/tasks/tool-cache.d.ts.map +1 -1
- package/dist/tasks/tool-cache.js +19 -6
- package/dist/tasks/tool-cache.js.map +1 -1
- package/dist/tasks/tool-semaphore.d.ts +66 -23
- package/dist/tasks/tool-semaphore.d.ts.map +1 -1
- package/dist/tasks/tool-semaphore.js +96 -34
- package/dist/tasks/tool-semaphore.js.map +1 -1
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +37 -4
- package/dist/upgrade.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +17 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +83 -0
- package/dist/validation/doctor/checks.js.map +1 -1
- package/package.json +13 -13
- package/schemas/project-context.schema.json +5 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heavy-command hook delivery for `cleo init`, `cleo upgrade`, `cleo doctor`
|
|
3
|
+
* and the session briefing (T13124).
|
|
4
|
+
*
|
|
5
|
+
* The hook (`cleo hook heavy-command`, T12983) routes agent-run tests, builds
|
|
6
|
+
* and typechecks through `cleo run`, the machine-wide ResourceGovernor. It only
|
|
7
|
+
* helps where it is installed. init/upgrade used to install it through
|
|
8
|
+
* `AdapterManager`, whose discovery finds no adapter in any project, and a
|
|
9
|
+
* try/catch swallowed every failure, so on 2026-10-03 it was installed nowhere.
|
|
10
|
+
* Delivery is now its own step, with one outcome per provider in the report,
|
|
11
|
+
* and `cleo doctor` plus the briefing say when a provider in use lacks it.
|
|
12
|
+
*
|
|
13
|
+
* The per-provider installers live in `@cleocode/adapters` (provider delivery).
|
|
14
|
+
* That package builds on this one, so it is loaded at run time through its
|
|
15
|
+
* light `@cleocode/adapters/heavy-command-hook` entry point and validated
|
|
16
|
+
* against the {@link HeavyHookDeliveryApi} contract.
|
|
17
|
+
*
|
|
18
|
+
* @module resources/heavy-command-hook-delivery
|
|
19
|
+
* @task T13124
|
|
20
|
+
* @epic T13121
|
|
21
|
+
*/
|
|
22
|
+
import type { HeavyCommandHookMode, HeavyHookCliProbe, HeavyHookDeliveryApi, HeavyHookDeliveryOptions, HeavyHookDeliveryOutcome, HeavyHookInspection } from '@cleocode/contracts';
|
|
23
|
+
/** The adapters entry point that carries the delivery functions. */
|
|
24
|
+
export declare const HEAVY_HOOK_DELIVERY_MODULE = "@cleocode/adapters/heavy-command-hook";
|
|
25
|
+
/** The command that installs or refreshes only this hook. */
|
|
26
|
+
export declare const HEAVY_HOOK_FIX = "cleo doctor heavy-command-hook --fix";
|
|
27
|
+
/**
|
|
28
|
+
* Load the delivery functions from `@cleocode/adapters`. The specifier is held
|
|
29
|
+
* in a variable so TypeScript does not resolve it at build time (adapters
|
|
30
|
+
* references core, so a static import would be a build cycle).
|
|
31
|
+
*
|
|
32
|
+
* @returns the delivery API.
|
|
33
|
+
* @throws when the module is missing or does not export the API.
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadHeavyHookDelivery(): Promise<HeavyHookDeliveryApi>;
|
|
36
|
+
/**
|
|
37
|
+
* The hook mode init/upgrade install from: `resources.heavyCommandHook`
|
|
38
|
+
* (default `rewrite`). The `CLEO_HEAVY_COMMAND_HOOK` environment variable
|
|
39
|
+
* switches the hook at run time only and does not change what is installed.
|
|
40
|
+
*
|
|
41
|
+
* @param projectRoot - the project whose config to read.
|
|
42
|
+
*/
|
|
43
|
+
export declare function installedHeavyHookMode(projectRoot: string): Promise<HeavyCommandHookMode>;
|
|
44
|
+
/** What {@link deliverHeavyCommandHooks} did. */
|
|
45
|
+
export interface HeavyHookDeliveryReport {
|
|
46
|
+
/** The mode installed from. */
|
|
47
|
+
readonly mode: HeavyCommandHookMode;
|
|
48
|
+
/** One outcome per provider. */
|
|
49
|
+
readonly outcomes: readonly HeavyHookDeliveryOutcome[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Install, refresh or remove the hook for every provider in use in the project.
|
|
53
|
+
*
|
|
54
|
+
* @param projectRoot - the project root.
|
|
55
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
56
|
+
* run-time loaded adapters module.
|
|
57
|
+
* @returns the mode and each provider's outcome.
|
|
58
|
+
* @throws only when the adapters module cannot be loaded.
|
|
59
|
+
*/
|
|
60
|
+
export declare function deliverHeavyCommandHooks(projectRoot: string, options?: HeavyHookDeliveryOptions & {
|
|
61
|
+
readonly api?: HeavyHookDeliveryApi;
|
|
62
|
+
}): Promise<HeavyHookDeliveryReport>;
|
|
63
|
+
/** What {@link inspectHeavyCommandHooks} found. */
|
|
64
|
+
export interface HeavyHookInspectionReport {
|
|
65
|
+
/** The configured mode. */
|
|
66
|
+
readonly mode: HeavyCommandHookMode;
|
|
67
|
+
/** One inspection per provider. */
|
|
68
|
+
readonly inspections: readonly HeavyHookInspection[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read-only: the hook's state for every provider in the project.
|
|
72
|
+
*
|
|
73
|
+
* @param projectRoot - the project root.
|
|
74
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
75
|
+
* run-time loaded adapters module.
|
|
76
|
+
* @returns the mode and each provider's state.
|
|
77
|
+
* @throws only when the adapters module cannot be loaded.
|
|
78
|
+
*/
|
|
79
|
+
export declare function inspectHeavyCommandHooks(projectRoot: string, options?: HeavyHookDeliveryOptions & {
|
|
80
|
+
readonly api?: HeavyHookDeliveryApi;
|
|
81
|
+
}): Promise<HeavyHookInspectionReport>;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the `cleo` on PATH, as the hook resolves it from the project, can
|
|
84
|
+
* answer the hook (an installed hook in front of an older CLEO governs
|
|
85
|
+
* nothing). Starts that `cleo` once.
|
|
86
|
+
*
|
|
87
|
+
* @param projectRoot - the project root.
|
|
88
|
+
* @param options - environment (tests); `api` replaces the run-time loaded
|
|
89
|
+
* adapters module.
|
|
90
|
+
* @throws only when the adapters module cannot be loaded.
|
|
91
|
+
*/
|
|
92
|
+
export declare function probeHeavyHookCliFor(projectRoot: string, options?: HeavyHookDeliveryOptions & {
|
|
93
|
+
readonly api?: HeavyHookDeliveryApi;
|
|
94
|
+
}): Promise<HeavyHookCliProbe>;
|
|
95
|
+
/**
|
|
96
|
+
* Whether any provider has CLEO's hook in place (installed or outdated), so
|
|
97
|
+
* the `cleo` it calls matters.
|
|
98
|
+
*
|
|
99
|
+
* @param inspections - the providers' states.
|
|
100
|
+
*/
|
|
101
|
+
export declare function heavyHookPresent(inspections: readonly HeavyHookInspection[]): boolean;
|
|
102
|
+
/** One line of an init/upgrade report about the hook. */
|
|
103
|
+
export interface HeavyHookReportLine {
|
|
104
|
+
/** `applied`: something was written; `skipped`: the hook is not (fully) in place. */
|
|
105
|
+
readonly status: 'applied' | 'skipped';
|
|
106
|
+
/** What happened, naming the provider and file. */
|
|
107
|
+
readonly details: string;
|
|
108
|
+
/** Why the hook is not in place (`skipped` only). */
|
|
109
|
+
readonly reason?: string;
|
|
110
|
+
/** The exact remedy (`skipped` only). */
|
|
111
|
+
readonly fix?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The report lines for a delivery: every write, and every provider in use
|
|
115
|
+
* whose hook could not be put in place (blocked, unsupported or failed).
|
|
116
|
+
* Unchanged hooks and providers not in use add nothing.
|
|
117
|
+
*
|
|
118
|
+
* @param outcomes - the delivery outcomes.
|
|
119
|
+
* @returns the lines, in provider order.
|
|
120
|
+
*/
|
|
121
|
+
export declare function heavyHookReportLines(outcomes: readonly HeavyHookDeliveryOutcome[]): readonly HeavyHookReportLine[];
|
|
122
|
+
/**
|
|
123
|
+
* Whether an inspection is a problem the user should fix: the hook is
|
|
124
|
+
* missing, outdated, blocked or unreadable for a provider in use (or present
|
|
125
|
+
* while the mode is off).
|
|
126
|
+
*
|
|
127
|
+
* @param inspection - one provider's state.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isHeavyHookProblem(inspection: HeavyHookInspection): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* The one-line briefing warning when a provider in use has no working hook,
|
|
132
|
+
* or `null` when every provider in use is covered (or the check itself
|
|
133
|
+
* fails; doctor reports that). Kimi's permanent `unsupported` state and a
|
|
134
|
+
* team's `needs-consent` are left to `cleo doctor`, so the briefing does not
|
|
135
|
+
* repeat them every session. It makes no git spawns (`gitChecks: false`).
|
|
136
|
+
*
|
|
137
|
+
* @param projectRoot - the project root.
|
|
138
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
139
|
+
* run-time loaded adapters module.
|
|
140
|
+
*/
|
|
141
|
+
export declare function heavyHookBriefingWarning(projectRoot: string, options?: HeavyHookDeliveryOptions & {
|
|
142
|
+
readonly api?: HeavyHookDeliveryApi;
|
|
143
|
+
}): Promise<string | null>;
|
|
144
|
+
//# sourceMappingURL=heavy-command-hook-delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heavy-command-hook-delivery.d.ts","sourceRoot":"","sources":["../../src/resources/heavy-command-hook-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAG7B,oEAAoE;AACpE,eAAO,MAAM,0BAA0B,0CAA0C,CAAC;AAElF,6DAA6D;AAC7D,eAAO,MAAM,cAAc,yCAAyC,CAAC;AAgBrE;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAS3E;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,WAAW,EAAE,MA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AAO,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,SAAS,mBAAmB,EAAE,CA4BhC;AAWD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAE3E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,wBAAwB,GAAG;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,oBAAoB,CAAA;CAAO,GAC/E,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmBxB"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heavy-command hook delivery for `cleo init`, `cleo upgrade`, `cleo doctor`
|
|
3
|
+
* and the session briefing (T13124).
|
|
4
|
+
*
|
|
5
|
+
* The hook (`cleo hook heavy-command`, T12983) routes agent-run tests, builds
|
|
6
|
+
* and typechecks through `cleo run`, the machine-wide ResourceGovernor. It only
|
|
7
|
+
* helps where it is installed. init/upgrade used to install it through
|
|
8
|
+
* `AdapterManager`, whose discovery finds no adapter in any project, and a
|
|
9
|
+
* try/catch swallowed every failure, so on 2026-10-03 it was installed nowhere.
|
|
10
|
+
* Delivery is now its own step, with one outcome per provider in the report,
|
|
11
|
+
* and `cleo doctor` plus the briefing say when a provider in use lacks it.
|
|
12
|
+
*
|
|
13
|
+
* The per-provider installers live in `@cleocode/adapters` (provider delivery).
|
|
14
|
+
* That package builds on this one, so it is loaded at run time through its
|
|
15
|
+
* light `@cleocode/adapters/heavy-command-hook` entry point and validated
|
|
16
|
+
* against the {@link HeavyHookDeliveryApi} contract.
|
|
17
|
+
*
|
|
18
|
+
* @module resources/heavy-command-hook-delivery
|
|
19
|
+
* @task T13124
|
|
20
|
+
* @epic T13121
|
|
21
|
+
*/
|
|
22
|
+
import { configuredHeavyHookMode, resolveHeavyHookMode } from './heavy-command.js';
|
|
23
|
+
/** The adapters entry point that carries the delivery functions. */
|
|
24
|
+
export const HEAVY_HOOK_DELIVERY_MODULE = '@cleocode/adapters/heavy-command-hook';
|
|
25
|
+
/** The command that installs or refreshes only this hook. */
|
|
26
|
+
export const HEAVY_HOOK_FIX = 'cleo doctor heavy-command-hook --fix';
|
|
27
|
+
function isRecord(value) {
|
|
28
|
+
return typeof value === 'object' && value !== null;
|
|
29
|
+
}
|
|
30
|
+
/** Whether a loaded module export implements {@link HeavyHookDeliveryApi}. */
|
|
31
|
+
function isDeliveryApi(value) {
|
|
32
|
+
return (isRecord(value) &&
|
|
33
|
+
typeof value.syncProjectHeavyCommandHooks === 'function' &&
|
|
34
|
+
typeof value.inspectProjectHeavyCommandHooks === 'function' &&
|
|
35
|
+
typeof value.probeHeavyHookCli === 'function');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load the delivery functions from `@cleocode/adapters`. The specifier is held
|
|
39
|
+
* in a variable so TypeScript does not resolve it at build time (adapters
|
|
40
|
+
* references core, so a static import would be a build cycle).
|
|
41
|
+
*
|
|
42
|
+
* @returns the delivery API.
|
|
43
|
+
* @throws when the module is missing or does not export the API.
|
|
44
|
+
*/
|
|
45
|
+
export async function loadHeavyHookDelivery() {
|
|
46
|
+
const specifier = HEAVY_HOOK_DELIVERY_MODULE;
|
|
47
|
+
const mod = await import(specifier);
|
|
48
|
+
const api = isRecord(mod) ? mod.heavyHookDeliveryApi : undefined;
|
|
49
|
+
if (!isDeliveryApi(api)) {
|
|
50
|
+
// @sync-invariant none:local-only a broken install of the adapters package; writes project config files, never a synced row
|
|
51
|
+
throw new Error(`${specifier} does not export heavyHookDeliveryApi`);
|
|
52
|
+
}
|
|
53
|
+
return api;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The hook mode init/upgrade install from: `resources.heavyCommandHook`
|
|
57
|
+
* (default `rewrite`). The `CLEO_HEAVY_COMMAND_HOOK` environment variable
|
|
58
|
+
* switches the hook at run time only and does not change what is installed.
|
|
59
|
+
*
|
|
60
|
+
* @param projectRoot - the project whose config to read.
|
|
61
|
+
*/
|
|
62
|
+
export async function installedHeavyHookMode(projectRoot) {
|
|
63
|
+
return resolveHeavyHookMode(undefined, await configuredHeavyHookMode(projectRoot));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Install, refresh or remove the hook for every provider in use in the project.
|
|
67
|
+
*
|
|
68
|
+
* @param projectRoot - the project root.
|
|
69
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
70
|
+
* run-time loaded adapters module.
|
|
71
|
+
* @returns the mode and each provider's outcome.
|
|
72
|
+
* @throws only when the adapters module cannot be loaded.
|
|
73
|
+
*/
|
|
74
|
+
export async function deliverHeavyCommandHooks(projectRoot, options = {}) {
|
|
75
|
+
const { api: injected, ...delivery } = options;
|
|
76
|
+
const api = injected ?? (await loadHeavyHookDelivery());
|
|
77
|
+
const mode = await installedHeavyHookMode(projectRoot);
|
|
78
|
+
const outcomes = await api.syncProjectHeavyCommandHooks(projectRoot, mode, delivery);
|
|
79
|
+
return { mode, outcomes };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Read-only: the hook's state for every provider in the project.
|
|
83
|
+
*
|
|
84
|
+
* @param projectRoot - the project root.
|
|
85
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
86
|
+
* run-time loaded adapters module.
|
|
87
|
+
* @returns the mode and each provider's state.
|
|
88
|
+
* @throws only when the adapters module cannot be loaded.
|
|
89
|
+
*/
|
|
90
|
+
export async function inspectHeavyCommandHooks(projectRoot, options = {}) {
|
|
91
|
+
const { api: injected, ...delivery } = options;
|
|
92
|
+
const api = injected ?? (await loadHeavyHookDelivery());
|
|
93
|
+
const mode = await installedHeavyHookMode(projectRoot);
|
|
94
|
+
return { mode, inspections: api.inspectProjectHeavyCommandHooks(projectRoot, mode, delivery) };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether the `cleo` on PATH, as the hook resolves it from the project, can
|
|
98
|
+
* answer the hook (an installed hook in front of an older CLEO governs
|
|
99
|
+
* nothing). Starts that `cleo` once.
|
|
100
|
+
*
|
|
101
|
+
* @param projectRoot - the project root.
|
|
102
|
+
* @param options - environment (tests); `api` replaces the run-time loaded
|
|
103
|
+
* adapters module.
|
|
104
|
+
* @throws only when the adapters module cannot be loaded.
|
|
105
|
+
*/
|
|
106
|
+
export async function probeHeavyHookCliFor(projectRoot, options = {}) {
|
|
107
|
+
const { api: injected, ...delivery } = options;
|
|
108
|
+
const api = injected ?? (await loadHeavyHookDelivery());
|
|
109
|
+
return api.probeHeavyHookCli(projectRoot, delivery);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether any provider has CLEO's hook in place (installed or outdated), so
|
|
113
|
+
* the `cleo` it calls matters.
|
|
114
|
+
*
|
|
115
|
+
* @param inspections - the providers' states.
|
|
116
|
+
*/
|
|
117
|
+
export function heavyHookPresent(inspections) {
|
|
118
|
+
return inspections.some((i) => i.state === 'installed' || i.state === 'outdated');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The report lines for a delivery: every write, and every provider in use
|
|
122
|
+
* whose hook could not be put in place (blocked, unsupported or failed).
|
|
123
|
+
* Unchanged hooks and providers not in use add nothing.
|
|
124
|
+
*
|
|
125
|
+
* @param outcomes - the delivery outcomes.
|
|
126
|
+
* @returns the lines, in provider order.
|
|
127
|
+
*/
|
|
128
|
+
export function heavyHookReportLines(outcomes) {
|
|
129
|
+
const lines = [];
|
|
130
|
+
for (const o of outcomes) {
|
|
131
|
+
switch (o.status) {
|
|
132
|
+
case 'installed':
|
|
133
|
+
case 'updated':
|
|
134
|
+
case 'removed':
|
|
135
|
+
lines.push({
|
|
136
|
+
status: 'applied',
|
|
137
|
+
details: `heavy-command hook (${o.provider}): ${o.status} ${o.target}`,
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case 'blocked':
|
|
141
|
+
case 'unsupported':
|
|
142
|
+
case 'needs-consent':
|
|
143
|
+
case 'failed':
|
|
144
|
+
lines.push({
|
|
145
|
+
status: 'skipped',
|
|
146
|
+
details: `heavy-command hook (${o.provider}): ${o.status}, ${o.target}`,
|
|
147
|
+
reason: `${o.provider} ${o.status}: ${o.reason ?? 'no reason given'}`,
|
|
148
|
+
...(o.remedy === undefined ? {} : { fix: o.remedy }),
|
|
149
|
+
});
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return lines;
|
|
156
|
+
}
|
|
157
|
+
/** States that need the user's attention (the provider is in use). */
|
|
158
|
+
const PROBLEM_STATES = new Set([
|
|
159
|
+
'missing',
|
|
160
|
+
'outdated',
|
|
161
|
+
'blocked',
|
|
162
|
+
'unreadable',
|
|
163
|
+
'needs-consent',
|
|
164
|
+
]);
|
|
165
|
+
/**
|
|
166
|
+
* Whether an inspection is a problem the user should fix: the hook is
|
|
167
|
+
* missing, outdated, blocked or unreadable for a provider in use (or present
|
|
168
|
+
* while the mode is off).
|
|
169
|
+
*
|
|
170
|
+
* @param inspection - one provider's state.
|
|
171
|
+
*/
|
|
172
|
+
export function isHeavyHookProblem(inspection) {
|
|
173
|
+
return PROBLEM_STATES.has(inspection.state);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The one-line briefing warning when a provider in use has no working hook,
|
|
177
|
+
* or `null` when every provider in use is covered (or the check itself
|
|
178
|
+
* fails; doctor reports that). Kimi's permanent `unsupported` state and a
|
|
179
|
+
* team's `needs-consent` are left to `cleo doctor`, so the briefing does not
|
|
180
|
+
* repeat them every session. It makes no git spawns (`gitChecks: false`).
|
|
181
|
+
*
|
|
182
|
+
* @param projectRoot - the project root.
|
|
183
|
+
* @param options - environment and provider list (tests); `api` replaces the
|
|
184
|
+
* run-time loaded adapters module.
|
|
185
|
+
*/
|
|
186
|
+
export async function heavyHookBriefingWarning(projectRoot, options = {}) {
|
|
187
|
+
let report;
|
|
188
|
+
try {
|
|
189
|
+
// No git spawns on the briefing path (review LOW-5); `cleo doctor` runs them.
|
|
190
|
+
report = await inspectHeavyCommandHooks(projectRoot, { gitChecks: false, ...options });
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
// `needs-consent` is a team's standing decision about its own config: doctor
|
|
196
|
+
// reports it, the briefing does not repeat it every session.
|
|
197
|
+
const problems = report.inspections.filter((i) => isHeavyHookProblem(i) && i.state !== 'needs-consent');
|
|
198
|
+
if (problems.length === 0)
|
|
199
|
+
return null;
|
|
200
|
+
const list = problems.map((p) => `${p.provider} (${p.state})`).join(', ');
|
|
201
|
+
return (`Heavy-command hook not in place for ${list}: agent-run tests, builds and typechecks ` +
|
|
202
|
+
`bypass the machine-wide resource budget. Remedy: ${HEAVY_HOOK_FIX}`);
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=heavy-command-hook-delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heavy-command-hook-delivery.js","sourceRoot":"","sources":["../../src/resources/heavy-command-hook-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,oEAAoE;AACpE,MAAM,CAAC,MAAM,0BAA0B,GAAG,uCAAuC,CAAC;AAElF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAErE,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,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mB,EACnB,UAA8E,EAAE;IAEhF,IAAI,MAAiC,CAAC;IACtC,IAAI,CAAC;QACH,8EAA8E;QAC9E,MAAM,GAAG,MAAM,wBAAwB,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,6EAA6E;IAC7E,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,eAAe,CAC5D,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,OAAO,CACL,uCAAuC,IAAI,2CAA2C;QACtF,oDAAoD,cAAc,EAAE,CACrE,CAAC;AACJ,CAAC"}
|
|
@@ -77,6 +77,75 @@ export interface HeavyCommandPlanOptions {
|
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
export declare function planHeavyCommand(command: string, opts: HeavyCommandPlanOptions): HeavyCommandPlan;
|
|
80
|
+
/**
|
|
81
|
+
* Whether a Claude Code Bash rule pattern (the text inside `Bash(…)`) matches
|
|
82
|
+
* one subcommand's text, as the permissions reference specifies: `*` stands for
|
|
83
|
+
* any text including spaces, a trailing `:*` equals a trailing ` *`, a trailing
|
|
84
|
+
* ` *` that is the rule's only wildcard also matches the bare command, and a
|
|
85
|
+
* rule without `*` matches one exact command. The bare `Bash` rule is `*`.
|
|
86
|
+
*
|
|
87
|
+
* @param pattern - the rule pattern, e.g. `pnpm test *` or `npm run test:*`.
|
|
88
|
+
* @param text - one subcommand as written.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* claudeBashRuleMatches('pnpm test *', 'pnpm test'); // true
|
|
93
|
+
* claudeBashRuleMatches('pnpm test:*', 'pnpm test --run'); // true
|
|
94
|
+
* claudeBashRuleMatches('ls *', 'lsof'); // false
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function claudeBashRuleMatches(pattern: string, text: string): boolean;
|
|
98
|
+
/** Options for {@link claudePreApproval}. */
|
|
99
|
+
export interface ClaudePreApprovalOptions {
|
|
100
|
+
/** The directory the command line starts in. */
|
|
101
|
+
readonly cwd: string;
|
|
102
|
+
/**
|
|
103
|
+
* Claude Code's primary working directory (`CLAUDE_PROJECT_DIR`). A `cd`
|
|
104
|
+
* and the read-only commands are accepted only inside it.
|
|
105
|
+
*/
|
|
106
|
+
readonly workingDir: string;
|
|
107
|
+
}
|
|
108
|
+
/** Whether Claude Code would run a command line without a prompt. */
|
|
109
|
+
export type ClaudePreApproval = {
|
|
110
|
+
readonly approved: true;
|
|
111
|
+
} | {
|
|
112
|
+
readonly approved: false;
|
|
113
|
+
readonly reason: string;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Whether Claude Code would run `command` WITHOUT a prompt because the user's
|
|
117
|
+
* Bash allow rules approve it: every subcommand (split at `&&`, `||`, `;`,
|
|
118
|
+
* `|`, `|&` and newlines, as Claude Code splits) matches an allow rule, or is
|
|
119
|
+
* a narrow read-only form Claude Code runs unprompted (`cd` into the working
|
|
120
|
+
* directory, `tail -50`, `grep -v x`, …).
|
|
121
|
+
*
|
|
122
|
+
* The heavy-command hook uses this to rewrite a command in Claude Code's
|
|
123
|
+
* default, acceptEdits, dontAsk and auto modes with `permissionDecision:
|
|
124
|
+
* "allow"`: the user already approved the command, and the rewrite only makes
|
|
125
|
+
* it queue for the machine-wide budget. So this check must never approve more
|
|
126
|
+
* than Claude Code would. It is deliberately narrower: no wrapper stripping
|
|
127
|
+
* (`timeout`, `nice`), no leading assignments, no expansions, no
|
|
128
|
+
* substitutions, subshells, compound commands or background jobs, no
|
|
129
|
+
* redirection except to `/dev/null` or a file descriptor, and both the stage
|
|
130
|
+
* as written and its words alone must match the same rule. Anything else is
|
|
131
|
+
* "not pre-approved" and the hook falls back to a warning. Deny and ask rules
|
|
132
|
+
* are not checked here (the hook checks them, and Claude Code enforces them
|
|
133
|
+
* on the rewritten command regardless).
|
|
134
|
+
*
|
|
135
|
+
* @param command - the command line as the agent wrote it.
|
|
136
|
+
* @param allowPatterns - the patterns of the user's `Bash(…)` allow rules (`*` for a bare `Bash`).
|
|
137
|
+
* @param opts - where the line starts, and Claude Code's working directory.
|
|
138
|
+
* @returns approved, or the first reason it is not.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* claudePreApproval('pnpm test 2>&1 | tail -50', ['pnpm test *'], { cwd: '/repo', workingDir: '/repo' });
|
|
143
|
+
* // { approved: true }
|
|
144
|
+
* claudePreApproval('pnpm test && rm -rf dist', ['pnpm test *'], { cwd: '/repo', workingDir: '/repo' });
|
|
145
|
+
* // { approved: false, reason: '`rm` is not approved by an allow rule' }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function claudePreApproval(command: string, allowPatterns: readonly string[], opts: ClaudePreApprovalOptions): ClaudePreApproval;
|
|
80
149
|
/**
|
|
81
150
|
* Whether `value` (trimmed, any case) names a hook mode. The hook reads the
|
|
82
151
|
* config only when the environment variable does not.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heavy-command.d.ts","sourceRoot":"","sources":["../../src/resources/heavy-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAGjB,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