mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
feat: deliver v1.8.0 harness reliability and parity updates
This commit is contained in:
74
scripts/lib/hook-flags.js
Normal file
74
scripts/lib/hook-flags.js
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Shared hook enable/disable controls.
|
||||
*
|
||||
* Controls:
|
||||
* - ECC_HOOK_PROFILE=minimal|standard|strict (default: standard)
|
||||
* - ECC_DISABLED_HOOKS=comma,separated,hook,ids
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const VALID_PROFILES = new Set(['minimal', 'standard', 'strict']);
|
||||
|
||||
function normalizeId(value) {
|
||||
return String(value || '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function getHookProfile() {
|
||||
const raw = String(process.env.ECC_HOOK_PROFILE || 'standard').trim().toLowerCase();
|
||||
return VALID_PROFILES.has(raw) ? raw : 'standard';
|
||||
}
|
||||
|
||||
function getDisabledHookIds() {
|
||||
const raw = String(process.env.ECC_DISABLED_HOOKS || '');
|
||||
if (!raw.trim()) return new Set();
|
||||
|
||||
return new Set(
|
||||
raw
|
||||
.split(',')
|
||||
.map(v => normalizeId(v))
|
||||
.filter(Boolean)
|
||||
);
|
||||
}
|
||||
|
||||
function parseProfiles(rawProfiles, fallback = ['standard', 'strict']) {
|
||||
if (!rawProfiles) return [...fallback];
|
||||
|
||||
if (Array.isArray(rawProfiles)) {
|
||||
const parsed = rawProfiles
|
||||
.map(v => String(v || '').trim().toLowerCase())
|
||||
.filter(v => VALID_PROFILES.has(v));
|
||||
return parsed.length > 0 ? parsed : [...fallback];
|
||||
}
|
||||
|
||||
const parsed = String(rawProfiles)
|
||||
.split(',')
|
||||
.map(v => v.trim().toLowerCase())
|
||||
.filter(v => VALID_PROFILES.has(v));
|
||||
|
||||
return parsed.length > 0 ? parsed : [...fallback];
|
||||
}
|
||||
|
||||
function isHookEnabled(hookId, options = {}) {
|
||||
const id = normalizeId(hookId);
|
||||
if (!id) return true;
|
||||
|
||||
const disabled = getDisabledHookIds();
|
||||
if (disabled.has(id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const profile = getHookProfile();
|
||||
const allowedProfiles = parseProfiles(options.profiles);
|
||||
return allowedProfiles.includes(profile);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
VALID_PROFILES,
|
||||
normalizeId,
|
||||
getHookProfile,
|
||||
getDisabledHookIds,
|
||||
parseProfiles,
|
||||
isHookEnabled,
|
||||
};
|
||||
@@ -16,10 +16,12 @@ const {
|
||||
log
|
||||
} = require('./utils');
|
||||
|
||||
// Session filename pattern: YYYY-MM-DD-[short-id]-session.tmp
|
||||
// The short-id is optional (old format) and can be 8+ alphanumeric characters
|
||||
// Matches: "2026-02-01-session.tmp" or "2026-02-01-a1b2c3d4-session.tmp"
|
||||
const SESSION_FILENAME_REGEX = /^(\d{4}-\d{2}-\d{2})(?:-([a-z0-9]{8,}))?-session\.tmp$/;
|
||||
// Session filename pattern: YYYY-MM-DD-[session-id]-session.tmp
|
||||
// The session-id is optional (old format) and can include lowercase
|
||||
// alphanumeric characters and hyphens, with a minimum length of 8.
|
||||
// Matches: "2026-02-01-session.tmp", "2026-02-01-a1b2c3d4-session.tmp",
|
||||
// and "2026-02-01-frontend-worktree-1-session.tmp"
|
||||
const SESSION_FILENAME_REGEX = /^(\d{4}-\d{2}-\d{2})(?:-([a-z0-9-]{8,}))?-session\.tmp$/;
|
||||
|
||||
/**
|
||||
* Parse session filename to extract metadata
|
||||
|
||||
Reference in New Issue
Block a user