claudecode-omc 5.6.8 → 5.11.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.
- package/.local/settings/settings.json +8 -0
- package/.local/skills/prompt-optimizer/SKILL.md +262 -19
- package/.omc-curation/ecc-selection.json +80 -0
- package/.omc-curation/governance.json +116 -0
- package/.omc-curation/sources.lock.json +30 -0
- package/README.md +78 -4
- package/bundled/manifest.json +6 -5
- package/bundled/upstream/anthropic-skills/.omc-source/bundle.json +18 -0
- package/bundled/upstream/anthropic-skills/.omc-source/provenance.json +399 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/SKILL.md +18 -17
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/examples.md +9 -9
- package/bundled/upstream/anthropic-skills/skills/claude-api/curl/managed-agents.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/go/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/claude-api.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/java/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/claude-api.md +10 -10
- package/bundled/upstream/anthropic-skills/skills/claude-api/php/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/README.md +16 -16
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/batches.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/files-api.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/streaming.md +7 -7
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/claude-api/tool-use.md +19 -19
- package/bundled/upstream/anthropic-skills/skills/claude-api/python/managed-agents/README.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/claude-api.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/ruby/managed-agents/README.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/error-codes.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/live-sources.md +3 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-api-reference.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-core.md +19 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-environments.md +6 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-multiagent.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-onboarding.md +3 -3
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-overview.md +3 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +173 -0
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/managed-agents-tools.md +10 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/model-migration.md +113 -13
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/models.md +14 -11
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/prompt-caching.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/shared/tool-use-concepts.md +4 -4
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/README.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/batches.md +2 -2
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/files-api.md +1 -1
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/streaming.md +5 -5
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/claude-api/tool-use.md +15 -15
- package/bundled/upstream/anthropic-skills/skills/claude-api/typescript/managed-agents/README.md +3 -3
- package/bundled/upstream/ecc/.omc-source/bundle.json +2 -1
- package/bundled/upstream/ecc/.omc-source/last-plan-apply.json +108 -24
- package/bundled/upstream/ecc/.omc-source/manifests/.claude-plugin/marketplace.json +3 -3
- package/bundled/upstream/ecc/.omc-source/provenance.json +563 -0
- package/bundled/upstream/ecc/agents/marketing-agent.md +159 -0
- package/bundled/upstream/ecc/agents/react-build-resolver.md +215 -0
- package/bundled/upstream/ecc/agents/react-reviewer.md +167 -0
- package/bundled/upstream/ecc/agents/typescript-reviewer.md +3 -0
- package/bundled/upstream/ecc/commands/harness-audit.md +17 -10
- package/bundled/upstream/ecc/commands/marketing-campaign.md +129 -0
- package/bundled/upstream/ecc/commands/react-build.md +187 -0
- package/bundled/upstream/ecc/commands/react-review.md +170 -0
- package/bundled/upstream/ecc/commands/react-test.md +265 -0
- package/bundled/upstream/ecc/skills/benchmark-optimization-loop/SKILL.md +69 -0
- package/bundled/upstream/ecc/skills/blender-motion-state-inspection/SKILL.md +164 -0
- package/bundled/upstream/ecc/skills/canary-watch/SKILL.md +9 -1
- package/bundled/upstream/ecc/skills/continuous-learning-v2/hooks/observe.sh +31 -9
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/detect-project.sh +38 -4
- package/bundled/upstream/ecc/skills/continuous-learning-v2/scripts/instinct-cli.py +319 -12
- package/bundled/upstream/ecc/skills/data-throughput-accelerator/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/dynamic-workflow-mode/SKILL.md +123 -0
- package/bundled/upstream/ecc/skills/frontend-a11y/SKILL.md +446 -0
- package/bundled/upstream/ecc/skills/ito-basket-compare/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-data-atlas-agent/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/ito-market-intelligence/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/ito-trade-planner/SKILL.md +67 -0
- package/bundled/upstream/ecc/skills/latency-critical-systems/SKILL.md +73 -0
- package/bundled/upstream/ecc/skills/marketing-campaign/SKILL.md +113 -0
- package/bundled/upstream/ecc/skills/nextjs-turbopack/SKILL.md +13 -0
- package/bundled/upstream/ecc/skills/parallel-execution-optimizer/SKILL.md +72 -0
- package/bundled/upstream/ecc/skills/prediction-market-oracle-research/SKILL.md +63 -0
- package/bundled/upstream/ecc/skills/prediction-market-risk-review/SKILL.md +60 -0
- package/bundled/upstream/ecc/skills/react-patterns/SKILL.md +341 -0
- package/bundled/upstream/ecc/skills/react-performance/SKILL.md +574 -0
- package/bundled/upstream/ecc/skills/react-testing/SKILL.md +423 -0
- package/bundled/upstream/ecc/skills/recsys-pipeline-architect/SKILL.md +114 -0
- package/bundled/upstream/ecc/skills/recursive-decision-ledger/SKILL.md +79 -0
- package/bundled/upstream/ecc/skills/social-publisher/SKILL.md +115 -0
- package/bundled/upstream/ecc/skills/team-agent-orchestration/SKILL.md +110 -0
- package/bundled/upstream/ecc/skills/uncloud/SKILL.md +343 -0
- package/bundled/upstream/ecc/skills/windows-desktop-e2e/SKILL.md +99 -0
- package/bundled/upstream/impeccable/.omc-source/bundle.json +20 -0
- package/bundled/upstream/impeccable/.omc-source/provenance.json +105 -0
- package/bundled/upstream/impeccable/agents/impeccable-manual-edit-applier.md +97 -0
- package/bundled/upstream/impeccable/skills/impeccable/SKILL.md +168 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/adapt.md +311 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/animate.md +201 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/audit.md +133 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/bolder.md +113 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/brand.md +108 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/clarify.md +288 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/codex.md +105 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/colorize.md +257 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/craft.md +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/critique.md +767 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/delight.md +302 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/distill.md +111 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/document.md +429 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/extract.md +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/harden.md +347 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/hooks.md +88 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/init.md +172 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/interaction-design.md +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/layout.md +161 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/live.md +718 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/onboard.md +234 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/optimize.md +258 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/overdrive.md +130 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/polish.md +241 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/product.md +60 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/quieter.md +99 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/shape.md +165 -0
- package/bundled/upstream/impeccable/skills/impeccable/reference/typeset.md +279 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/command-metadata.json +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context-signals.mjs +225 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/context.mjs +280 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detect.mjs +21 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/browser/injected/index.mjs +1735 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/cli/main.mjs +244 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +4907 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/detect-antipatterns.mjs +43 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/browser/detect-url.mjs +252 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +552 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1013 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/static-html/detect-html.mjs +208 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/findings.mjs +12 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/node/file-system.mjs +198 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/profile/profiler.mjs +166 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/registry/antipatterns.mjs +419 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/rules/checks.mjs +2671 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/color.mjs +124 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/constants.mjs +101 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/detector/shared/page.mjs +7 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-admin.mjs +574 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-before-edit.mjs +473 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook-lib.mjs +1286 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/hook.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/design-parser.mjs +835 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/impeccable-paths.mjs +126 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/lib/is-generated.mjs +69 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/browser-script-parts.mjs +49 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/completion.mjs +19 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/event-validation.mjs +137 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/insert-ui.mjs +458 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-apply.mjs +939 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edit-routes.mjs +357 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/session-store.mjs +289 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/svelte-component.mjs +826 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/sveltekit-adapter.mjs +274 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/ui-core.mjs +180 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live/vocabulary.mjs +36 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-accept.mjs +812 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-dom.js +146 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-browser.js +11086 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-commit-manual-edits.mjs +1241 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-copy-edit-agent.mjs +683 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-discard-manual-edits.mjs +51 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-inject.mjs +583 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-insert.mjs +272 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-manual-edit-evidence.mjs +363 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-poll.mjs +379 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-resume.mjs +94 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-server.mjs +1134 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-status.mjs +61 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live-wrap.mjs +894 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/live.mjs +246 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/palette.mjs +633 -0
- package/bundled/upstream/impeccable/skills/impeccable/scripts/pin.mjs +214 -0
- package/bundled/upstream/oh-my-claudecode/.omc-source/bundle.json +2 -1
- package/bundled/upstream/oh-my-claudecode/.omc-source/provenance.json +116 -0
- package/bundled/upstream/oh-my-claudecode/skills/autopilot/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/cancel/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/deep-interview/SKILL.md +39 -5
- package/bundled/upstream/oh-my-claudecode/skills/hud/SKILL.md +1 -0
- package/bundled/upstream/oh-my-claudecode/skills/local-build-reminder/SKILL.md +78 -0
- package/bundled/upstream/oh-my-claudecode/skills/omc-doctor/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/SKILL.md +26 -10
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/01-install-claude-md.md +3 -3
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/02-configure.md +6 -4
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/03-integrations.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/omc-setup/phases/04-welcome.md +2 -2
- package/bundled/upstream/oh-my-claudecode/skills/omc-teams/SKILL.md +6 -6
- package/bundled/upstream/oh-my-claudecode/skills/plan/SKILL.md +44 -32
- package/bundled/upstream/oh-my-claudecode/skills/ralph/SKILL.md +45 -21
- package/bundled/upstream/oh-my-claudecode/skills/ralplan/SKILL.md +1 -1
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/SKILL.md +7 -0
- package/bundled/upstream/oh-my-claudecode/skills/self-improve/scripts/resolve-paths.mjs +39 -15
- package/bundled/upstream/oh-my-claudecode/skills/team/SKILL.md +132 -90
- package/bundled/upstream/oh-my-claudecode/skills/ultragoal/SKILL.md +93 -0
- package/bundled/upstream/oh-my-claudecode/skills/ultraqa/SKILL.md +28 -13
- package/bundled/upstream/oh-my-claudecode/skills/ultrawork/SKILL.md +7 -0
- package/bundled/upstream/superpowers/.omc-source/bundle.json +2 -1
- package/bundled/upstream/superpowers/.omc-source/provenance.json +63 -0
- package/package.json +2 -1
- package/src/catalog/source-catalog.js +10 -4
- package/src/cli/index.js +4 -0
- package/src/cli/plan.js +14 -2
- package/src/cli/setup.js +52 -13
- package/src/cli/skill.js +1 -1
- package/src/cli/source.js +271 -14
- package/src/config/sources.js +82 -1
- package/src/merge/content-patch.js +88 -0
- package/templates/merge-config.json +1 -8
- package/bundled/upstream/ecc/skills/strategic-compact/suggest-compact.sh +0 -54
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `/impeccable hooks <on|off|status|reset>` — manage the design hook
|
|
4
|
+
* via the `hook` key of .impeccable/config.json and .impeccable/config.local.json
|
|
5
|
+
* in the current project.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* node hook-admin.mjs status # print current state
|
|
9
|
+
* node hook-admin.mjs on # set enabled: true
|
|
10
|
+
* node hook-admin.mjs off # set enabled: false
|
|
11
|
+
* node hook-admin.mjs ignore-rule <rule-id> # append to ignoreRules
|
|
12
|
+
* node hook-admin.mjs ignore-rule overused-font --all-values
|
|
13
|
+
* node hook-admin.mjs ignore-file <glob> # append to ignoreFiles
|
|
14
|
+
* node hook-admin.mjs ignore-value <rule> <value> # append to shared ignoreValues
|
|
15
|
+
* node hook-admin.mjs ignore-value <rule> <value> --local
|
|
16
|
+
* node hook-admin.mjs reset # remove all config + cache
|
|
17
|
+
*
|
|
18
|
+
* Designed to be invoked by the LLM from the reference/hooks.md flow.
|
|
19
|
+
* Output is human-readable; the harness will pass it back to the user.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
getConfigPath,
|
|
27
|
+
getLocalConfigPath,
|
|
28
|
+
getCachePath,
|
|
29
|
+
getPendingPath,
|
|
30
|
+
readConfig,
|
|
31
|
+
DEFAULT_CONFIG,
|
|
32
|
+
ensureHookGitExcludes,
|
|
33
|
+
normalizeIgnoreValue,
|
|
34
|
+
normalizeIgnoreValueEntries,
|
|
35
|
+
} from './hook-lib.mjs';
|
|
36
|
+
|
|
37
|
+
const ACTIONS = new Set(['status', 'on', 'off', 'ignore-rule', 'ignore-file', 'ignore-value', 'reset']);
|
|
38
|
+
const IMPECCABLE_HOOK_COMMAND_MARKERS = [
|
|
39
|
+
'skills/impeccable/scripts/hook-probe.mjs',
|
|
40
|
+
'skills/impeccable/scripts/hook.mjs',
|
|
41
|
+
'skills/impeccable/scripts/hook-before-edit.mjs',
|
|
42
|
+
'skills/impeccable/scripts/hook-after-edit.mjs',
|
|
43
|
+
'skills/impeccable/scripts/hook-stop.mjs',
|
|
44
|
+
];
|
|
45
|
+
const TIMEOUT_SECONDS = 5;
|
|
46
|
+
const STATUS_MESSAGE = 'Checking UI changes';
|
|
47
|
+
|
|
48
|
+
const HOOK_MANIFEST_TARGETS = [
|
|
49
|
+
{
|
|
50
|
+
provider: '.claude',
|
|
51
|
+
skillRel: '.claude/skills/impeccable',
|
|
52
|
+
destRel: '.claude/settings.local.json',
|
|
53
|
+
sharedDestRel: '.claude/settings.json',
|
|
54
|
+
manifest: () => ({
|
|
55
|
+
description: 'Impeccable design detector: runs after Edit/Write/MultiEdit on UI files and surfaces findings as system reminders.',
|
|
56
|
+
hooks: {
|
|
57
|
+
PostToolUse: [
|
|
58
|
+
{
|
|
59
|
+
matcher: 'Edit|Write|MultiEdit',
|
|
60
|
+
hooks: [
|
|
61
|
+
{
|
|
62
|
+
type: 'command',
|
|
63
|
+
command: 'node "${CLAUDE_PROJECT_DIR}/.claude/skills/impeccable/scripts/hook.mjs"',
|
|
64
|
+
timeout: TIMEOUT_SECONDS,
|
|
65
|
+
statusMessage: STATUS_MESSAGE,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
provider: '.agents',
|
|
75
|
+
skillRel: '.agents/skills/impeccable',
|
|
76
|
+
destRel: '.codex/hooks.json',
|
|
77
|
+
manifest: () => ({
|
|
78
|
+
description: 'Impeccable design detector: runs after Edit/Write/apply_patch on UI files and surfaces findings as system reminders.',
|
|
79
|
+
hooks: {
|
|
80
|
+
PostToolUse: [
|
|
81
|
+
{
|
|
82
|
+
matcher: 'Edit|Write|apply_patch',
|
|
83
|
+
hooks: [
|
|
84
|
+
{
|
|
85
|
+
type: 'command',
|
|
86
|
+
command: 'node "$(git rev-parse --show-toplevel)/.agents/skills/impeccable/scripts/hook.mjs"',
|
|
87
|
+
timeout: TIMEOUT_SECONDS,
|
|
88
|
+
statusMessage: STATUS_MESSAGE,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
provider: '.cursor',
|
|
98
|
+
skillRel: '.cursor/skills/impeccable',
|
|
99
|
+
destRel: '.cursor/hooks.json',
|
|
100
|
+
manifest: () => ({
|
|
101
|
+
version: 1,
|
|
102
|
+
hooks: {
|
|
103
|
+
preToolUse: [
|
|
104
|
+
{
|
|
105
|
+
command: 'node ".cursor/skills/impeccable/scripts/hook-before-edit.mjs"',
|
|
106
|
+
timeout: TIMEOUT_SECONDS,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
function readRawConfigFile(filePath) {
|
|
115
|
+
if (!fs.existsSync(filePath)) return { exists: false, malformed: false, raw: null };
|
|
116
|
+
try {
|
|
117
|
+
return { exists: true, malformed: false, raw: JSON.parse(fs.readFileSync(filePath, 'utf-8')) };
|
|
118
|
+
} catch {
|
|
119
|
+
return { exists: true, malformed: true, raw: null };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// The hook settings to edit: the unified file's `hook` subtree.
|
|
124
|
+
function readRawConfig(cwd, opts = {}) {
|
|
125
|
+
const unified = readRawConfigFile(opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd)).raw;
|
|
126
|
+
if (unified && typeof unified === 'object' && unified.hook && typeof unified.hook === 'object') {
|
|
127
|
+
return unified.hook;
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Write the hook config back under the `hook` key of the unified file, leaving
|
|
133
|
+
// any sibling keys (e.g. updateCheck) untouched.
|
|
134
|
+
function writeConfig(cwd, hookConfig, opts = {}) {
|
|
135
|
+
const filePath = opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd);
|
|
136
|
+
if (opts.local) ensureHookGitExcludes(cwd);
|
|
137
|
+
const existingRaw = readRawConfigFile(filePath).raw;
|
|
138
|
+
const existing = existingRaw && typeof existingRaw === 'object' && !Array.isArray(existingRaw) ? existingRaw : {};
|
|
139
|
+
const existingHook = existing.hook && typeof existing.hook === 'object' && !Array.isArray(existing.hook) ? existing.hook : {};
|
|
140
|
+
// Merge over the existing hook object so fields the merge helpers don't manage
|
|
141
|
+
// (consent, quiet, auditLog) survive a `/impeccable hooks` edit.
|
|
142
|
+
const next = { ...existing, hook: { ...existingHook, ...hookConfig } };
|
|
143
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
144
|
+
fs.writeFileSync(filePath, JSON.stringify(next, null, 2) + '\n');
|
|
145
|
+
return filePath;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function mergeConfig(existing) {
|
|
149
|
+
// Persist the full shape so /impeccable hooks edits leave a complete file
|
|
150
|
+
// for the user to see, not an unhelpful `{"enabled":false}`.
|
|
151
|
+
const base = existing && typeof existing === 'object' ? existing : {};
|
|
152
|
+
return {
|
|
153
|
+
enabled: base.enabled === false ? false : true,
|
|
154
|
+
ignoreRules: Array.isArray(base.ignoreRules) ? Array.from(new Set(base.ignoreRules.map(String))) : [],
|
|
155
|
+
ignoreFiles: Array.isArray(base.ignoreFiles) ? Array.from(new Set(base.ignoreFiles.map(String))) : [],
|
|
156
|
+
ignoreValues: normalizeIgnoreValueEntries(base.ignoreValues || []),
|
|
157
|
+
limits: {
|
|
158
|
+
maxFindings: Number.isFinite(base?.limits?.maxFindings) ? base.limits.maxFindings : DEFAULT_CONFIG.limits.maxFindings,
|
|
159
|
+
maxChars: Number.isFinite(base?.limits?.maxChars) ? base.limits.maxChars : DEFAULT_CONFIG.limits.maxChars,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function mergeLocalConfig(existing) {
|
|
165
|
+
const base = existing && typeof existing === 'object' ? existing : {};
|
|
166
|
+
const out = {};
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(base, 'enabled')) {
|
|
168
|
+
out.enabled = base.enabled === false ? false : true;
|
|
169
|
+
}
|
|
170
|
+
if (Array.isArray(base.ignoreRules)) {
|
|
171
|
+
out.ignoreRules = Array.from(new Set(base.ignoreRules.map(String)));
|
|
172
|
+
}
|
|
173
|
+
if (Array.isArray(base.ignoreFiles)) {
|
|
174
|
+
out.ignoreFiles = Array.from(new Set(base.ignoreFiles.map(String)));
|
|
175
|
+
}
|
|
176
|
+
out.ignoreValues = normalizeIgnoreValueEntries(base.ignoreValues || []);
|
|
177
|
+
if (base.limits && typeof base.limits === 'object') {
|
|
178
|
+
const limits = {};
|
|
179
|
+
if (Number.isFinite(base.limits.maxFindings)) limits.maxFindings = base.limits.maxFindings;
|
|
180
|
+
if (Number.isFinite(base.limits.maxChars)) limits.maxChars = base.limits.maxChars;
|
|
181
|
+
if (Object.keys(limits).length) out.limits = limits;
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function statusReport(cwd) {
|
|
187
|
+
const shared = readRawConfigFile(getConfigPath(cwd));
|
|
188
|
+
const local = readRawConfigFile(getLocalConfigPath(cwd));
|
|
189
|
+
const cfg = readConfig(cwd);
|
|
190
|
+
const envKill = process.env.IMPECCABLE_HOOK_DISABLED;
|
|
191
|
+
const envState = envKill ? `IMPECCABLE_HOOK_DISABLED=${envKill}` : 'unset';
|
|
192
|
+
const cfgPath = path.relative(cwd, getConfigPath(cwd)) || '.impeccable/config.json';
|
|
193
|
+
const localPath = path.relative(cwd, getLocalConfigPath(cwd)) || '.impeccable/config.local.json';
|
|
194
|
+
const cachePath = path.relative(cwd, getCachePath(cwd)) || '.impeccable/hook.cache.json';
|
|
195
|
+
const fileState = (info, relPath, absent) => {
|
|
196
|
+
if (info.malformed) return `${relPath} (malformed; ignored)`;
|
|
197
|
+
if (info.exists) return relPath;
|
|
198
|
+
return `${relPath} (${absent})`;
|
|
199
|
+
};
|
|
200
|
+
const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
|
|
201
|
+
|
|
202
|
+
const lines = [
|
|
203
|
+
`Impeccable design hook`,
|
|
204
|
+
` state: ${cfg.enabled ? 'enabled' : 'disabled'}`,
|
|
205
|
+
` shared file: ${fileState(shared, cfgPath, 'using defaults; file not present')}`,
|
|
206
|
+
` local file: ${fileState(local, localPath, 'not present')}`,
|
|
207
|
+
` ignoreRules: ${cfg.ignoreRules.length ? cfg.ignoreRules.join(', ') : '(none)'}`,
|
|
208
|
+
` ignoreFiles: ${cfg.ignoreFiles.length ? cfg.ignoreFiles.join(', ') : '(none)'}`,
|
|
209
|
+
` ignoreValues: ${ignoreValues.length ? ignoreValues.join(', ') : '(none)'}`,
|
|
210
|
+
` maxFindings: ${cfg.limits.maxFindings}`,
|
|
211
|
+
` maxChars: ${cfg.limits.maxChars}`,
|
|
212
|
+
` env override: ${envState}`,
|
|
213
|
+
` cache file: ${fs.existsSync(getCachePath(cwd)) ? cachePath : `${cachePath} (not present)`}`,
|
|
214
|
+
];
|
|
215
|
+
return lines.join('\n');
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function setEnabled(cwd, value) {
|
|
219
|
+
const config = mergeConfig(readRawConfig(cwd));
|
|
220
|
+
config.enabled = value;
|
|
221
|
+
const target = writeConfig(cwd, config);
|
|
222
|
+
if (!value) {
|
|
223
|
+
return `Design hook disabled for this project (wrote ${path.relative(cwd, target) || target}).`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const localTarget = writeConfig(cwd, { consent: 'accepted' }, { local: true });
|
|
227
|
+
const repaired = repairHookManifests(cwd);
|
|
228
|
+
const parts = [
|
|
229
|
+
`Design hook enabled for this project (wrote ${path.relative(cwd, target) || target}).`,
|
|
230
|
+
`Recorded local hook consent in ${path.relative(cwd, localTarget) || localTarget}.`,
|
|
231
|
+
];
|
|
232
|
+
if (repaired.written.length > 0) {
|
|
233
|
+
parts.push(`Installed or repaired hook manifests for: ${repaired.written.join(', ')}.`);
|
|
234
|
+
} else if (repaired.already.length > 0) {
|
|
235
|
+
parts.push(`Hook manifests already installed for: ${repaired.already.join(', ')}.`);
|
|
236
|
+
} else {
|
|
237
|
+
parts.push('No installed provider skill folders found to repair.');
|
|
238
|
+
}
|
|
239
|
+
if (repaired.backups.length > 0) {
|
|
240
|
+
parts.push(`Backed up malformed manifest(s): ${repaired.backups.map((filePath) => path.relative(cwd, filePath) || filePath).join(', ')}.`);
|
|
241
|
+
}
|
|
242
|
+
return parts.join(' ');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function repairHookManifests(cwd) {
|
|
246
|
+
const result = { written: [], already: [], backups: [] };
|
|
247
|
+
for (const target of HOOK_MANIFEST_TARGETS) {
|
|
248
|
+
if (!fs.existsSync(path.join(cwd, target.skillRel))) continue;
|
|
249
|
+
const dest = path.join(cwd, target.destRel);
|
|
250
|
+
const sharedDest = target.sharedDestRel ? path.join(cwd, target.sharedDestRel) : null;
|
|
251
|
+
|
|
252
|
+
if (sharedDest && fileHasImpeccableHookMarker(sharedDest)) {
|
|
253
|
+
pruneImpeccableHookFromManifest(dest);
|
|
254
|
+
result.already.push(target.provider);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const fresh = target.manifest();
|
|
259
|
+
let next = fresh;
|
|
260
|
+
if (fs.existsSync(dest)) {
|
|
261
|
+
try {
|
|
262
|
+
next = mergeHookManifests(JSON.parse(fs.readFileSync(dest, 'utf-8')), fresh);
|
|
263
|
+
} catch {
|
|
264
|
+
const backup = `${dest}.bak`;
|
|
265
|
+
fs.copyFileSync(dest, backup);
|
|
266
|
+
result.backups.push(backup);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const serialized = `${JSON.stringify(next, null, 2)}\n`;
|
|
271
|
+
const current = fs.existsSync(dest) ? safeReadText(dest) : null;
|
|
272
|
+
if (current === serialized) {
|
|
273
|
+
result.already.push(target.provider);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
277
|
+
fs.writeFileSync(dest, serialized);
|
|
278
|
+
result.written.push(target.provider);
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function safeReadText(filePath) {
|
|
284
|
+
try {
|
|
285
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
286
|
+
} catch {
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function mergeHookManifests(existing, fresh) {
|
|
292
|
+
const existingObject = existing && typeof existing === 'object' && !Array.isArray(existing) ? existing : {};
|
|
293
|
+
const freshObject = fresh && typeof fresh === 'object' && !Array.isArray(fresh) ? fresh : {};
|
|
294
|
+
const existingHooks = existingObject.hooks && typeof existingObject.hooks === 'object' && !Array.isArray(existingObject.hooks)
|
|
295
|
+
? existingObject.hooks
|
|
296
|
+
: {};
|
|
297
|
+
const freshHooks = freshObject.hooks && typeof freshObject.hooks === 'object' && !Array.isArray(freshObject.hooks)
|
|
298
|
+
? freshObject.hooks
|
|
299
|
+
: {};
|
|
300
|
+
|
|
301
|
+
const merged = { ...existingObject, hooks: {} };
|
|
302
|
+
if (freshObject.version !== undefined) merged.version = freshObject.version;
|
|
303
|
+
if (freshObject.description !== undefined) merged.description = freshObject.description;
|
|
304
|
+
|
|
305
|
+
const hookEvents = new Set([...Object.keys(existingHooks), ...Object.keys(freshHooks)]);
|
|
306
|
+
for (const event of hookEvents) {
|
|
307
|
+
const preserved = stripImpeccableHookEntries(existingHooks[event]);
|
|
308
|
+
const added = Array.isArray(freshHooks[event]) ? freshHooks[event] : [];
|
|
309
|
+
const mergedEntries = [...preserved, ...added];
|
|
310
|
+
if (mergedEntries.length > 0) merged.hooks[event] = mergedEntries;
|
|
311
|
+
}
|
|
312
|
+
return merged;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function fileHasImpeccableHookMarker(filePath) {
|
|
316
|
+
if (!fs.existsSync(filePath)) return false;
|
|
317
|
+
let parsed;
|
|
318
|
+
try {
|
|
319
|
+
parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
320
|
+
} catch {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return false;
|
|
324
|
+
if (!parsed.hooks || typeof parsed.hooks !== 'object') return false;
|
|
325
|
+
return valueHasImpeccableHookMarker(parsed.hooks);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function valueHasImpeccableHookMarker(value) {
|
|
329
|
+
if (typeof value === 'string') {
|
|
330
|
+
return IMPECCABLE_HOOK_COMMAND_MARKERS.some((marker) => value.includes(marker));
|
|
331
|
+
}
|
|
332
|
+
if (Array.isArray(value)) return value.some(valueHasImpeccableHookMarker);
|
|
333
|
+
if (value && typeof value === 'object') return Object.values(value).some(valueHasImpeccableHookMarker);
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function stripImpeccableHookEntry(entry) {
|
|
338
|
+
if (!entry || typeof entry !== 'object') return entry;
|
|
339
|
+
if (valueHasImpeccableHookMarker(entry.command) || valueHasImpeccableHookMarker(entry.args)) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
if (!Array.isArray(entry.hooks)) return entry;
|
|
343
|
+
|
|
344
|
+
const strippedHooks = entry.hooks
|
|
345
|
+
.map(stripImpeccableHookEntry)
|
|
346
|
+
.filter(Boolean);
|
|
347
|
+
|
|
348
|
+
if (strippedHooks.length === 0 && entry.hooks.some(valueHasImpeccableHookMarker)) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
return { ...entry, hooks: strippedHooks };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function stripImpeccableHookEntries(entries) {
|
|
355
|
+
if (!Array.isArray(entries)) return [];
|
|
356
|
+
return entries
|
|
357
|
+
.map(stripImpeccableHookEntry)
|
|
358
|
+
.filter(Boolean);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function pruneImpeccableHookFromManifest(manifestPath) {
|
|
362
|
+
if (!fileHasImpeccableHookMarker(manifestPath)) return false;
|
|
363
|
+
let parsed;
|
|
364
|
+
try {
|
|
365
|
+
parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
366
|
+
} catch {
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const existingHooks = parsed.hooks && typeof parsed.hooks === 'object' && !Array.isArray(parsed.hooks)
|
|
371
|
+
? parsed.hooks
|
|
372
|
+
: {};
|
|
373
|
+
const cleanedHooks = {};
|
|
374
|
+
for (const [event, entries] of Object.entries(existingHooks)) {
|
|
375
|
+
const kept = stripImpeccableHookEntries(entries);
|
|
376
|
+
if (kept.length > 0) cleanedHooks[event] = kept;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const next = { ...parsed };
|
|
380
|
+
if (Object.keys(cleanedHooks).length > 0) {
|
|
381
|
+
next.hooks = cleanedHooks;
|
|
382
|
+
} else {
|
|
383
|
+
delete next.hooks;
|
|
384
|
+
delete next.description;
|
|
385
|
+
delete next.version;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (Object.keys(next).length === 0) {
|
|
389
|
+
fs.rmSync(manifestPath, { force: true });
|
|
390
|
+
} else {
|
|
391
|
+
fs.writeFileSync(manifestPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function normalizeRuleId(rule) {
|
|
397
|
+
return String(rule || '').trim().toLowerCase();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function parseIgnoreRuleArgs(args) {
|
|
401
|
+
const positionals = [];
|
|
402
|
+
let allValues = false;
|
|
403
|
+
|
|
404
|
+
for (let i = 0; i < args.length; i++) {
|
|
405
|
+
const arg = String(args[i] || '');
|
|
406
|
+
if (arg === '--all-values') {
|
|
407
|
+
allValues = true;
|
|
408
|
+
} else if (arg === '--reason') {
|
|
409
|
+
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) i++;
|
|
410
|
+
} else if (arg.startsWith('--reason=')) {
|
|
411
|
+
// Accepted for command symmetry; ignoreRules stores rule ids only.
|
|
412
|
+
} else if (arg.startsWith('--')) {
|
|
413
|
+
throw new Error(`Unknown ignore-rule flag: ${arg}`);
|
|
414
|
+
} else {
|
|
415
|
+
positionals.push(arg);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
return {
|
|
420
|
+
rule: normalizeRuleId(positionals[0]),
|
|
421
|
+
allValues,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function addIgnoreRule(cwd, args) {
|
|
426
|
+
const parsed = parseIgnoreRuleArgs(args);
|
|
427
|
+
const rule = parsed.rule;
|
|
428
|
+
if (!rule) throw new Error('Pass a rule id, e.g. /impeccable hooks ignore-rule side-tab');
|
|
429
|
+
if (rule === 'overused-font' && !parsed.allValues) {
|
|
430
|
+
throw new Error('overused-font is value-specific by default. Use /impeccable hooks ignore-value overused-font <font> for a confirmed font, or /impeccable hooks ignore-rule overused-font --all-values only when the user asked to ignore overused fonts generally.');
|
|
431
|
+
}
|
|
432
|
+
const config = mergeConfig(readRawConfig(cwd));
|
|
433
|
+
if (!config.ignoreRules.includes(rule)) config.ignoreRules.push(rule);
|
|
434
|
+
writeConfig(cwd, config);
|
|
435
|
+
return `Added "${rule}" to ignoreRules. Current: ${config.ignoreRules.join(', ')}`;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function addIgnoreFile(cwd, glob) {
|
|
439
|
+
if (!glob) throw new Error('Pass a glob, e.g. /impeccable hooks ignore-file "src/legacy/**"');
|
|
440
|
+
const config = mergeConfig(readRawConfig(cwd));
|
|
441
|
+
if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);
|
|
442
|
+
writeConfig(cwd, config);
|
|
443
|
+
return `Added "${glob}" to ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function parseIgnoreValueArgs(args) {
|
|
447
|
+
const positionals = [];
|
|
448
|
+
let shared = false;
|
|
449
|
+
let local = false;
|
|
450
|
+
let reason = '';
|
|
451
|
+
|
|
452
|
+
for (let i = 0; i < args.length; i++) {
|
|
453
|
+
const arg = args[i];
|
|
454
|
+
if (arg === '--shared') {
|
|
455
|
+
shared = true;
|
|
456
|
+
} else if (arg === '--local') {
|
|
457
|
+
local = true;
|
|
458
|
+
} else if (arg === '--reason') {
|
|
459
|
+
const chunks = [];
|
|
460
|
+
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) {
|
|
461
|
+
chunks.push(args[++i]);
|
|
462
|
+
}
|
|
463
|
+
reason = chunks.join(' ').trim();
|
|
464
|
+
} else if (String(arg).startsWith('--reason=')) {
|
|
465
|
+
reason = String(arg).slice('--reason='.length).trim();
|
|
466
|
+
} else {
|
|
467
|
+
positionals.push(arg);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const [rule, ...valueParts] = positionals;
|
|
472
|
+
return {
|
|
473
|
+
rule: String(rule || '').trim().toLowerCase(),
|
|
474
|
+
value: normalizeIgnoreValue(valueParts.join(' ')),
|
|
475
|
+
shared,
|
|
476
|
+
local,
|
|
477
|
+
reason,
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function addIgnoreValue(cwd, args) {
|
|
482
|
+
const parsed = parseIgnoreValueArgs(args);
|
|
483
|
+
if (!parsed.rule || !parsed.value) {
|
|
484
|
+
throw new Error('Pass a rule id and value, e.g. /impeccable hooks ignore-value overused-font Inter');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (parsed.shared && parsed.local) {
|
|
488
|
+
throw new Error('Pass only one scope flag: --shared or --local');
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const local = parsed.local;
|
|
492
|
+
const config = local
|
|
493
|
+
? mergeLocalConfig(readRawConfig(cwd, { local: true }))
|
|
494
|
+
: mergeConfig(readRawConfig(cwd, { local: false }));
|
|
495
|
+
const key = `${parsed.rule}\0${parsed.value}`;
|
|
496
|
+
const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
|
|
497
|
+
|
|
498
|
+
if (existing) {
|
|
499
|
+
if (parsed.reason) existing.reason = parsed.reason;
|
|
500
|
+
} else {
|
|
501
|
+
const entry = {
|
|
502
|
+
rule: parsed.rule,
|
|
503
|
+
value: parsed.value,
|
|
504
|
+
createdAt: new Date().toISOString(),
|
|
505
|
+
};
|
|
506
|
+
if (parsed.reason) entry.reason = parsed.reason;
|
|
507
|
+
config.ignoreValues.push(entry);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const target = writeConfig(cwd, config, { local });
|
|
511
|
+
const scope = local ? 'local ignoreValues' : 'shared ignoreValues';
|
|
512
|
+
return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function reset(cwd) {
|
|
516
|
+
const removed = [];
|
|
517
|
+
// Unified files may hold non-hook keys (e.g. updateCheck); strip only the
|
|
518
|
+
// hook subtree and keep the rest, deleting the file only if nothing remains.
|
|
519
|
+
for (const filePath of [getConfigPath(cwd), getLocalConfigPath(cwd)]) {
|
|
520
|
+
try {
|
|
521
|
+
const raw = readRawConfigFile(filePath).raw;
|
|
522
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || !('hook' in raw)) continue;
|
|
523
|
+
const { hook, ...rest } = raw;
|
|
524
|
+
if (Object.keys(rest).length === 0) {
|
|
525
|
+
fs.unlinkSync(filePath);
|
|
526
|
+
} else {
|
|
527
|
+
fs.writeFileSync(filePath, JSON.stringify(rest, null, 2) + '\n');
|
|
528
|
+
}
|
|
529
|
+
removed.push(path.relative(cwd, filePath) || filePath);
|
|
530
|
+
} catch { /* ignore */ }
|
|
531
|
+
}
|
|
532
|
+
// State files are wholly ours; delete outright.
|
|
533
|
+
for (const filePath of [getCachePath(cwd), getPendingPath(cwd)]) {
|
|
534
|
+
try {
|
|
535
|
+
if (fs.existsSync(filePath)) {
|
|
536
|
+
fs.unlinkSync(filePath);
|
|
537
|
+
removed.push(path.relative(cwd, filePath) || filePath);
|
|
538
|
+
}
|
|
539
|
+
} catch { /* ignore */ }
|
|
540
|
+
}
|
|
541
|
+
return removed.length
|
|
542
|
+
? `Reset design hook config and cache (removed: ${removed.join(', ')}).`
|
|
543
|
+
: 'No hook config or cache to remove. Already at defaults.';
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function main() {
|
|
547
|
+
const [, , actionArg, ...rest] = process.argv;
|
|
548
|
+
const action = (actionArg || 'status').toLowerCase();
|
|
549
|
+
const cwd = process.cwd();
|
|
550
|
+
|
|
551
|
+
if (!ACTIONS.has(action)) {
|
|
552
|
+
process.stderr.write(`Unknown action: ${action}\nValid: ${Array.from(ACTIONS).join(', ')}\n`);
|
|
553
|
+
process.exit(1);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
try {
|
|
557
|
+
let out = '';
|
|
558
|
+
switch (action) {
|
|
559
|
+
case 'status': out = statusReport(cwd); break;
|
|
560
|
+
case 'on': out = setEnabled(cwd, true); break;
|
|
561
|
+
case 'off': out = setEnabled(cwd, false); break;
|
|
562
|
+
case 'ignore-rule': out = addIgnoreRule(cwd, rest); break;
|
|
563
|
+
case 'ignore-file': out = addIgnoreFile(cwd, rest[0]); break;
|
|
564
|
+
case 'ignore-value': out = addIgnoreValue(cwd, rest); break;
|
|
565
|
+
case 'reset': out = reset(cwd); break;
|
|
566
|
+
}
|
|
567
|
+
process.stdout.write(out + '\n');
|
|
568
|
+
} catch (err) {
|
|
569
|
+
process.stderr.write(`Error: ${err.message || err}\n`);
|
|
570
|
+
process.exit(1);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
main();
|