mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 21:42:11 +00:00
Add config-health monitor and install wiring
- Add the config-health skill: a read-only monitor for hook wiring, rule references, and rule staleness; every mode exits 0. - Ship its own SessionStart hook asset so installing the module registers the monitor; keep PreToolUse opt-in. - Keep one install-state record per hook source, so hooks-runtime and config-health can share settings.json and uninstall removes both. - Split the monitor into a CLI entry plus constants, paths, and scan modules; split scan_command and the hook contract suite. All files are under 800 lines and no function body reaches 50 lines.
This commit is contained in:
20 files changed
+1752
-1249
No files matched your search
@@ -611,9 +611,14 @@ function findPreviousManagedHooks(previousState, plan, operation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Settings files collect hooks from more than one module, so the recorded
|
||||
// operation is identified by its source as well; matching on the destination
|
||||
// alone hands one module the other module's managed hooks.
|
||||
const previousOperation = (previousState.operations || []).find(candidate => (
|
||||
candidate.kind === operation.kind
|
||||
&& comparablePath(candidate.destinationPath) === comparablePath(operation.destinationPath)
|
||||
&& (operation.kind !== 'update-claude-settings'
|
||||
|| (candidate.sourceRelativePath || '') === (operation.sourceRelativePath || ''))
|
||||
));
|
||||
if (!previousOperation || !previousOperation.managedHooks) {
|
||||
return null;
|
||||
|
||||
@@ -135,9 +135,18 @@ function isManagedOperation(operation) {
|
||||
function uniqueOperations(operations) {
|
||||
const byDestination = new Map();
|
||||
for (const operation of operations) {
|
||||
// A target path has one current owner. Later operations come from the
|
||||
// newest plan and replace stale metadata for the same destination.
|
||||
byDestination.set(comparablePath(operation.destinationPath), operation);
|
||||
// A target path has one current owner — except a settings file, which
|
||||
// takes contributions from every module that ships hooks. Keyed by the
|
||||
// destination alone, the last settings operation would replace the
|
||||
// earlier records, and uninstall would leave their managed hooks behind.
|
||||
const isSettingsOperation = operation.kind === 'update-claude-settings'
|
||||
|| operation.kind === 'remove-claude-settings-hooks';
|
||||
const key = isSettingsOperation
|
||||
? `${operation.kind}\0${comparablePath(operation.destinationPath)}\0${operation.sourceRelativePath || ''}`
|
||||
: comparablePath(operation.destinationPath);
|
||||
// Later operations come from the newest plan and replace stale metadata
|
||||
// for the same destination and source.
|
||||
byDestination.set(key, operation);
|
||||
}
|
||||
return [...byDestination.values()];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user