@bastani/atomic 0.9.5-alpha.8 → 0.9.5
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/CHANGELOG.md +122 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +12 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/cursor/src/model-mapper.ts +6 -3
- package/dist/builtin/intercom/CHANGELOG.md +37 -0
- package/dist/builtin/intercom/README.md +4 -2
- package/dist/builtin/intercom/broker/broker.ts +6 -114
- package/dist/builtin/intercom/broker/client.ts +29 -54
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +44 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +142 -0
- package/dist/builtin/intercom/broker/send-handler.ts +106 -0
- package/dist/builtin/intercom/broker/send-signature.ts +37 -0
- package/dist/builtin/intercom/foreground-detach-handoff.ts +136 -0
- package/dist/builtin/intercom/index-heavy.ts +49 -53
- package/dist/builtin/intercom/index.ts +278 -262
- package/dist/builtin/intercom/lazy-heavy-proxy.ts +114 -0
- package/dist/builtin/intercom/lazy-subagent-ack.ts +20 -0
- package/dist/builtin/intercom/lazy-tool-execution.ts +39 -0
- package/dist/builtin/intercom/lifecycle-lease.ts +51 -0
- package/dist/builtin/intercom/lifecycle.ts +37 -20
- package/dist/builtin/intercom/package.json +3 -6
- package/dist/builtin/intercom/reply-routing.ts +17 -0
- package/dist/builtin/intercom/subagent-relay.ts +58 -12
- package/dist/builtin/intercom/types.ts +3 -3
- package/dist/builtin/mcp/CHANGELOG.md +38 -0
- package/dist/builtin/mcp/OAUTH.md +1 -0
- package/dist/builtin/mcp/README.md +10 -6
- package/dist/builtin/mcp/apps-cancellation.ts +32 -0
- package/dist/builtin/mcp/call-tool-result.ts +9 -0
- package/dist/builtin/mcp/caller-wait.ts +50 -0
- package/dist/builtin/mcp/command-registration.ts +82 -0
- package/dist/builtin/mcp/direct-tool-executor.ts +279 -0
- package/dist/builtin/mcp/direct-tools.ts +40 -255
- package/dist/builtin/mcp/host-html-template.ts +4 -2
- package/dist/builtin/mcp/index.ts +274 -239
- package/dist/builtin/mcp/init.ts +96 -126
- package/dist/builtin/mcp/mcp-auth-flow.ts +247 -237
- package/dist/builtin/mcp/mcp-callback-server.ts +89 -68
- package/dist/builtin/mcp/mcp-oauth-provider.ts +23 -1
- package/dist/builtin/mcp/metadata-hydration.ts +52 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +4 -4
- package/dist/builtin/mcp/proxy-call.ts +111 -40
- package/dist/builtin/mcp/proxy-connect.ts +35 -15
- package/dist/builtin/mcp/proxy-info-modes.ts +106 -23
- package/dist/builtin/mcp/proxy-modes.ts +3 -3
- package/dist/builtin/mcp/session-cleanup-barrier.ts +43 -0
- package/dist/builtin/mcp/startup-warmup.ts +98 -0
- package/dist/builtin/mcp/state-lease.ts +12 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -3
- package/dist/builtin/mcp/ui-server.ts +8 -8
- package/dist/builtin/mcp/ui-session.ts +9 -18
- package/dist/builtin/subagents/CHANGELOG.md +78 -0
- package/dist/builtin/subagents/README.md +30 -29
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +37 -36
- package/dist/builtin/subagents/src/extension/api-lifecycle.ts +64 -0
- package/dist/builtin/subagents/src/extension/fanout-child.ts +44 -51
- package/dist/builtin/subagents/src/extension/index.ts +289 -320
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +7 -10
- package/dist/builtin/subagents/src/extension/schemas.ts +22 -5
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +89 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +29 -0
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +13 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +106 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +26 -20
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +13 -2
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +3 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +189 -0
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +44 -7
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +34 -0
- package/dist/builtin/subagents/src/runs/background/notify.ts +72 -22
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +232 -0
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +151 -0
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +72 -0
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +48 -0
- package/dist/builtin/subagents/src/runs/background/result-status.ts +81 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +59 -0
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +177 -233
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +3 -2
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +73 -14
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +29 -15
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +1 -2
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +1 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +7 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +3 -13
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +2 -15
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +63 -46
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +48 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +39 -26
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +3 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +3 -51
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +6 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +11 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +5 -112
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +68 -118
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +79 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +55 -12
- package/dist/builtin/subagents/src/shared/artifacts.ts +22 -11
- package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +294 -0
- package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +44 -0
- package/dist/builtin/subagents/src/shared/jsonl-writer.ts +1 -0
- package/dist/builtin/subagents/src/shared/model-info.ts +2 -2
- package/dist/builtin/subagents/src/shared/settings.ts +20 -10
- package/dist/builtin/subagents/src/shared/types-async.ts +3 -1
- package/dist/builtin/subagents/src/shared/types-config.ts +2 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +3 -2
- package/dist/builtin/subagents/src/slash/slash-commands.ts +9 -12
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +63 -32
- package/dist/builtin/subagents/src/tui/render-result.ts +7 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -0
- package/dist/builtin/subagents/src/tui/render-widget.ts +157 -89
- package/dist/builtin/web-access/CHANGELOG.md +28 -0
- package/dist/builtin/web-access/README.md +4 -0
- package/dist/builtin/web-access/content-tools.ts +8 -3
- package/dist/builtin/web-access/index-heavy.ts +1 -1
- package/dist/builtin/web-access/index.ts +190 -46
- package/dist/builtin/web-access/lifecycle-lease.ts +38 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/result-renderers.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/web-access/web-search-activity.ts +1 -1
- package/dist/builtin/web-access/web-search-return.ts +7 -0
- package/dist/builtin/web-access/web-search-summary.ts +1 -1
- package/dist/builtin/web-access/web-search-tool.ts +4 -2
- package/dist/builtin/workflows/CHANGELOG.md +86 -0
- package/dist/builtin/workflows/README.md +5 -5
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +27 -4
- package/dist/builtin/workflows/builtin/goal-runner.ts +86 -27
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +10 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +9 -9
- package/dist/builtin/workflows/builtin/ralph-models.ts +71 -36
- package/dist/builtin/workflows/builtin/ralph-runner.ts +20 -31
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/SKILL.md +16 -13
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.md +1 -0
- package/dist/builtin/workflows/skills/impeccable/reference/adapt.native.md +58 -0
- package/dist/builtin/workflows/skills/impeccable/reference/android.md +40 -0
- package/dist/builtin/workflows/skills/impeccable/reference/animate.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.md +2 -0
- package/dist/builtin/workflows/skills/impeccable/reference/audit.native.md +139 -0
- package/dist/builtin/workflows/skills/impeccable/reference/bolder.md +69 -62
- package/dist/builtin/workflows/skills/impeccable/reference/critique.md +21 -7
- package/dist/builtin/workflows/skills/impeccable/reference/document.md +1 -1
- package/dist/builtin/workflows/skills/impeccable/reference/hooks.md +92 -0
- package/dist/builtin/workflows/skills/impeccable/reference/init.md +29 -7
- package/dist/builtin/workflows/skills/impeccable/reference/ios.md +45 -0
- package/dist/builtin/workflows/skills/impeccable/reference/layout.md +25 -1
- package/dist/builtin/workflows/skills/impeccable/reference/typeset.md +23 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context-signals.mjs +2 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/context.mjs +75 -14
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/browser/injected/index.mjs +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/cli/main.mjs +31 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/design-system.mjs +64 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +118 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +16 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/registry/antipatterns.mjs +66 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +42 -10
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/fonts.mjs +30 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +4 -6
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-admin.mjs +660 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-before-edit.mjs +516 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook-lib.mjs +1764 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/hook.mjs +61 -0
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/impeccable-config.mjs +4 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/lib/is-generated.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live/svelte-component.mjs +13 -16
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +17 -11
- package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +104 -37
- package/dist/builtin/workflows/skills/impeccable/scripts/live-wrap.mjs +9 -0
- package/dist/builtin/workflows/src/durable/backend.ts +12 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +17 -1
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +12 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +5 -2
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +2 -1
- package/dist/builtin/workflows/src/durable/types.ts +16 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +1 -2
- package/dist/builtin/workflows/src/engine/run-returned-status.ts +50 -16
- package/dist/builtin/workflows/src/engine/run.ts +20 -19
- package/dist/builtin/workflows/src/engine/runtime.ts +5 -0
- package/dist/builtin/workflows/src/extension/extension-factory.ts +3 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +9 -2
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +137 -27
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +22 -6
- package/dist/builtin/workflows/src/extension/public-types.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +13 -1
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +19 -4
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +9 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +17 -22
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +48 -23
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +15 -2
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +20 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +24 -8
- package/dist/builtin/workflows/src/runs/background/status.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +29 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +3 -2
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +155 -20
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +2 -2
- package/dist/builtin/workflows/src/shared/resume-continuation.ts +2 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +116 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +2 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +21 -3
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +3 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +1 -23
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +54 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +5 -2
- package/dist/builtin/workflows/src/tui/status-list.ts +22 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +4 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +23 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +129 -17
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +9 -1
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +1 -1
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -3
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +2 -2
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +1 -1
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +3 -2
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +4 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/anthropic-thinking-guard.d.ts +5 -5
- package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
- package/dist/core/anthropic-thinking-guard.js +42 -32
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +15 -15
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +14 -9
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +79 -46
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-assistant-turns.d.ts +42 -0
- package/dist/core/compaction/context-assistant-turns.d.ts.map +1 -0
- package/dist/core/compaction/context-assistant-turns.js +87 -0
- package/dist/core/compaction/context-assistant-turns.js.map +1 -0
- package/dist/core/compaction/context-compaction-critical.d.ts +1 -1
- package/dist/core/compaction/context-compaction-critical.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-critical.js +2 -2
- package/dist/core/compaction/context-compaction-critical.js.map +1 -1
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts +18 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js +186 -0
- package/dist/core/compaction/context-compaction-eviction-alternates.js.map +1 -0
- package/dist/core/compaction/context-compaction-eviction.d.ts +10 -2
- package/dist/core/compaction/context-compaction-eviction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-eviction.js +196 -146
- package/dist/core/compaction/context-compaction-eviction.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +1 -1
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-types.d.ts +2 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-types.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +5 -4
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +17 -15
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-store.js +1 -1
- package/dist/core/compaction/context-deletion-store.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -1
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +36 -31
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-helpers.js +116 -43
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts +1 -2
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +33 -37
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-model-synthesis.d.ts.map +1 -1
- package/dist/core/copilot-model-synthesis.js +3 -1
- package/dist/core/copilot-model-synthesis.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +8 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +2 -7
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +6 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +72 -29
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/messages.d.ts +9 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +100 -18
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +5 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
- package/dist/core/model-registry-custom-loader.js +49 -8
- package/dist/core/model-registry-custom-loader.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +11 -5
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +8 -0
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +93 -8
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +24 -12
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +7 -6
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +23 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +33 -5
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-initial.d.ts +6 -1
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +12 -7
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts +1 -0
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +24 -9
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts +1 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -10
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-entry-normalization.d.ts +7 -0
- package/dist/core/session-entry-normalization.d.ts.map +1 -0
- package/dist/core/session-entry-normalization.js +14 -0
- package/dist/core/session-entry-normalization.js.map +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +127 -108
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +2 -2
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +1 -1
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts +2 -0
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +141 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +11 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +2 -2
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main-early-input.d.ts.map +1 -1
- package/dist/main-early-input.js +7 -0
- package/dist/main-early-input.js.map +1 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +0 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-options.js +3 -1
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -1
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +21 -9
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-child-ordering.d.ts +7 -0
- package/dist/modes/interactive/interactive-child-ordering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-child-ordering.js +26 -0
- package/dist/modes/interactive/interactive-child-ordering.js.map +1 -0
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +43 -30
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +41 -6
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +3 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +11 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +0 -3
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +15 -1
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +5 -1
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +20 -21
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +26 -2
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +3 -0
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +24 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js +60 -5
- package/dist/utils/fs-watch.js.map +1 -1
- package/docs/changelog.mdx +19 -0
- package/docs/compaction.md +60 -49
- package/docs/custom-provider.md +18 -5
- package/docs/development.md +4 -0
- package/docs/extensions.md +11 -2
- package/docs/json.md +1 -1
- package/docs/models.md +69 -10
- package/docs/providers.md +1 -1
- package/docs/quickstart.md +12 -8
- package/docs/rpc.md +2 -2
- package/docs/sdk.md +1 -1
- package/docs/settings.md +4 -4
- package/docs/subagents.md +40 -5
- package/docs/tools.md +1 -1
- package/docs/usage.md +4 -2
- package/docs/windows.md +4 -0
- package/docs/workflows.md +33 -48
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/subagent/README.md +2 -2
- package/examples/extensions/subagent/index.ts +1 -2
- package/examples/extensions/subagent/schemas.ts +4 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/npm-shrinkwrap.json +48 -51
- package/package.json +7 -7
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +0 -75
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +0 -202
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +0 -97
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +0 -160
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +0 -72
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +0 -161
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +0 -203
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +0 -234
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +0 -103
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +0 -29
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +0 -9
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +0 -117
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `/impeccable hooks <on|off|status|reset>` — manage the design hook runtime
|
|
4
|
+
* via the `hook` key and shared detector ignores via the `detector` key in
|
|
5
|
+
* .impeccable/config.json / .impeccable/config.local.json.
|
|
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
|
+
hooks: {
|
|
79
|
+
PostToolUse: [
|
|
80
|
+
{
|
|
81
|
+
matcher: 'Edit|Write|apply_patch',
|
|
82
|
+
hooks: [
|
|
83
|
+
{
|
|
84
|
+
type: 'command',
|
|
85
|
+
command: 'node ".agents/skills/impeccable/scripts/hook.mjs"',
|
|
86
|
+
timeout: TIMEOUT_SECONDS,
|
|
87
|
+
statusMessage: STATUS_MESSAGE,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
provider: '.cursor',
|
|
97
|
+
skillRel: '.cursor/skills/impeccable',
|
|
98
|
+
destRel: '.cursor/hooks.json',
|
|
99
|
+
manifest: () => ({
|
|
100
|
+
version: 1,
|
|
101
|
+
hooks: {
|
|
102
|
+
preToolUse: [
|
|
103
|
+
{
|
|
104
|
+
command: 'node ".cursor/skills/impeccable/scripts/hook-before-edit.mjs"',
|
|
105
|
+
timeout: TIMEOUT_SECONDS,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
// GitHub Copilot reads repo-level hooks from `.github/hooks/*.json`. The same
|
|
113
|
+
// manifest is honored by the CLI (once committed to the default branch) and
|
|
114
|
+
// the cloud/app agent. Schema differs: lowercase `postToolUse`, flat entries,
|
|
115
|
+
// `bash`/`timeoutSec`, and a `matcher` regex against the `edit`/`create` tools.
|
|
116
|
+
provider: '.github',
|
|
117
|
+
skillRel: '.github/skills/impeccable',
|
|
118
|
+
destRel: '.github/hooks/impeccable.json',
|
|
119
|
+
manifest: () => ({
|
|
120
|
+
version: 1,
|
|
121
|
+
hooks: {
|
|
122
|
+
postToolUse: [
|
|
123
|
+
{
|
|
124
|
+
type: 'command',
|
|
125
|
+
matcher: 'edit|create|apply_patch',
|
|
126
|
+
bash: 'node "$(git rev-parse --show-toplevel)/.github/skills/impeccable/scripts/hook.mjs"',
|
|
127
|
+
timeoutSec: TIMEOUT_SECONDS,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
function readRawConfigFile(filePath) {
|
|
136
|
+
if (!fs.existsSync(filePath)) return { exists: false, malformed: false, raw: null };
|
|
137
|
+
try {
|
|
138
|
+
return { exists: true, malformed: false, raw: JSON.parse(fs.readFileSync(filePath, 'utf-8')) };
|
|
139
|
+
} catch {
|
|
140
|
+
return { exists: true, malformed: true, raw: null };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const DETECTOR_CONFIG_KEYS = new Set(['ignoreRules', 'ignoreFiles', 'ignoreValues', 'designSystem']);
|
|
145
|
+
|
|
146
|
+
function hookSection(unified) {
|
|
147
|
+
return unified && typeof unified === 'object' && !Array.isArray(unified) && unified.hook && typeof unified.hook === 'object' && !Array.isArray(unified.hook)
|
|
148
|
+
? unified.hook
|
|
149
|
+
: null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function detectorSection(unified) {
|
|
153
|
+
return unified && typeof unified === 'object' && !Array.isArray(unified) && unified.detector && typeof unified.detector === 'object' && !Array.isArray(unified.detector)
|
|
154
|
+
? unified.detector
|
|
155
|
+
: null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function readRawHookConfig(cwd, opts = {}) {
|
|
159
|
+
const unified = readRawConfigFile(opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd)).raw;
|
|
160
|
+
return hookSection(unified);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function readRawDetectorConfig(cwd, opts = {}) {
|
|
164
|
+
const unified = readRawConfigFile(opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd)).raw;
|
|
165
|
+
const merged = mergeDetectorConfig(hookSection(unified));
|
|
166
|
+
return mergeDetectorConfig(detectorSection(unified), merged);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function stripDetectorKeys(raw) {
|
|
170
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};
|
|
171
|
+
const out = {};
|
|
172
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
173
|
+
if (!DETECTOR_CONFIG_KEYS.has(key)) out[key] = value;
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Write hook runtime config under `hook`, leaving detector filters in
|
|
179
|
+
// `detector` and preserving sibling keys such as updateCheck.
|
|
180
|
+
function writeHookConfig(cwd, hookConfig, opts = {}) {
|
|
181
|
+
const filePath = opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd);
|
|
182
|
+
if (opts.local) ensureHookGitExcludes(cwd);
|
|
183
|
+
const existingRaw = readRawConfigFile(filePath).raw;
|
|
184
|
+
const existing = existingRaw && typeof existingRaw === 'object' && !Array.isArray(existingRaw) ? existingRaw : {};
|
|
185
|
+
const existingHook = stripDetectorKeys(hookSection(existing));
|
|
186
|
+
// Merge over the existing hook object so fields the merge helpers don't manage
|
|
187
|
+
// (consent, quiet, auditLog) survive a `/impeccable hooks` edit.
|
|
188
|
+
const next = { ...existing, hook: { ...existingHook, ...hookConfig } };
|
|
189
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
190
|
+
fs.writeFileSync(filePath, JSON.stringify(next, null, 2) + '\n');
|
|
191
|
+
return filePath;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function writeDetectorConfig(cwd, detectorConfig, opts = {}) {
|
|
195
|
+
const filePath = opts.local ? getLocalConfigPath(cwd) : getConfigPath(cwd);
|
|
196
|
+
if (opts.local) ensureHookGitExcludes(cwd);
|
|
197
|
+
const existingRaw = readRawConfigFile(filePath).raw;
|
|
198
|
+
const existing = existingRaw && typeof existingRaw === 'object' && !Array.isArray(existingRaw) ? existingRaw : {};
|
|
199
|
+
const nextHook = stripDetectorKeys(hookSection(existing));
|
|
200
|
+
const existingDetector = mergeDetectorConfig(detectorSection(existing));
|
|
201
|
+
const next = {
|
|
202
|
+
...existing,
|
|
203
|
+
detector: mergeDetectorConfig(detectorConfig, existingDetector),
|
|
204
|
+
};
|
|
205
|
+
if (Object.keys(nextHook).length > 0) next.hook = nextHook;
|
|
206
|
+
else delete next.hook;
|
|
207
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
208
|
+
fs.writeFileSync(filePath, JSON.stringify(next, null, 2) + '\n');
|
|
209
|
+
return filePath;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function mergeHookConfig(existing) {
|
|
213
|
+
const base = existing && typeof existing === 'object' ? existing : {};
|
|
214
|
+
return {
|
|
215
|
+
enabled: base.enabled === false ? false : true,
|
|
216
|
+
limits: {
|
|
217
|
+
maxFindings: Number.isFinite(base?.limits?.maxFindings) ? base.limits.maxFindings : DEFAULT_CONFIG.limits.maxFindings,
|
|
218
|
+
maxChars: Number.isFinite(base?.limits?.maxChars) ? base.limits.maxChars : DEFAULT_CONFIG.limits.maxChars,
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function mergeDetectorConfig(existing, seed = null) {
|
|
224
|
+
const base = existing && typeof existing === 'object' ? existing : {};
|
|
225
|
+
const out = seed ? {
|
|
226
|
+
ignoreRules: [...seed.ignoreRules],
|
|
227
|
+
ignoreFiles: [...seed.ignoreFiles],
|
|
228
|
+
ignoreValues: normalizeIgnoreValueEntries(seed.ignoreValues),
|
|
229
|
+
} : {
|
|
230
|
+
ignoreRules: [],
|
|
231
|
+
ignoreFiles: [],
|
|
232
|
+
ignoreValues: [],
|
|
233
|
+
};
|
|
234
|
+
if (seed?.designSystem && typeof seed.designSystem === 'object' && !Array.isArray(seed.designSystem)) {
|
|
235
|
+
out.designSystem = { ...seed.designSystem };
|
|
236
|
+
}
|
|
237
|
+
if (base.designSystem && typeof base.designSystem === 'object' && !Array.isArray(base.designSystem)) {
|
|
238
|
+
out.designSystem = {
|
|
239
|
+
...(out.designSystem || {}),
|
|
240
|
+
enabled: base.designSystem.enabled === false ? false : true,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (Array.isArray(base.ignoreRules)) {
|
|
244
|
+
out.ignoreRules = Array.from(new Set([...out.ignoreRules, ...base.ignoreRules.map(String)]));
|
|
245
|
+
}
|
|
246
|
+
if (Array.isArray(base.ignoreFiles)) {
|
|
247
|
+
out.ignoreFiles = Array.from(new Set([...out.ignoreFiles, ...base.ignoreFiles.map(String)]));
|
|
248
|
+
}
|
|
249
|
+
if (Array.isArray(base.ignoreValues)) {
|
|
250
|
+
out.ignoreValues = mergeIgnoreValueEntries(out.ignoreValues, base.ignoreValues);
|
|
251
|
+
}
|
|
252
|
+
return out;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function mergeIgnoreValueEntries(existing, incoming) {
|
|
256
|
+
const map = new Map();
|
|
257
|
+
for (const entry of normalizeIgnoreValueEntries(existing)) {
|
|
258
|
+
map.set(ignoreValueEntryKey(entry), entry);
|
|
259
|
+
}
|
|
260
|
+
for (const entry of normalizeIgnoreValueEntries(incoming)) {
|
|
261
|
+
map.set(ignoreValueEntryKey(entry), entry);
|
|
262
|
+
}
|
|
263
|
+
return Array.from(map.values());
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function ignoreValueEntryKey(entry) {
|
|
267
|
+
const files = Array.isArray(entry.files) && entry.files.length > 0 ? entry.files.join('\x1f') : '';
|
|
268
|
+
return `${entry.rule}\0${entry.value}\0${files}`;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function statusReport(cwd) {
|
|
272
|
+
const shared = readRawConfigFile(getConfigPath(cwd));
|
|
273
|
+
const local = readRawConfigFile(getLocalConfigPath(cwd));
|
|
274
|
+
const cfg = readConfig(cwd);
|
|
275
|
+
const envKill = process.env.IMPECCABLE_HOOK_DISABLED;
|
|
276
|
+
const envState = envKill ? `IMPECCABLE_HOOK_DISABLED=${envKill}` : 'unset';
|
|
277
|
+
const cfgPath = path.relative(cwd, getConfigPath(cwd)) || '.impeccable/config.json';
|
|
278
|
+
const localPath = path.relative(cwd, getLocalConfigPath(cwd)) || '.impeccable/config.local.json';
|
|
279
|
+
const cachePath = path.relative(cwd, getCachePath(cwd)) || '.impeccable/hook.cache.json';
|
|
280
|
+
const fileState = (info, relPath, absent) => {
|
|
281
|
+
if (info.malformed) return `${relPath} (malformed; ignored)`;
|
|
282
|
+
if (info.exists) return relPath;
|
|
283
|
+
return `${relPath} (${absent})`;
|
|
284
|
+
};
|
|
285
|
+
const ignoreValues = cfg.ignoreValues.map((entry) => `${entry.rule}=${entry.value}`);
|
|
286
|
+
|
|
287
|
+
const lines = [
|
|
288
|
+
`Impeccable design hook`,
|
|
289
|
+
` state: ${cfg.enabled ? 'enabled' : 'disabled'}`,
|
|
290
|
+
` shared file: ${fileState(shared, cfgPath, 'using defaults; file not present')}`,
|
|
291
|
+
` local file: ${fileState(local, localPath, 'not present')}`,
|
|
292
|
+
` ignoreRules: ${cfg.ignoreRules.length ? cfg.ignoreRules.join(', ') : '(none)'}`,
|
|
293
|
+
` ignoreFiles: ${cfg.ignoreFiles.length ? cfg.ignoreFiles.join(', ') : '(none)'}`,
|
|
294
|
+
` ignoreValues: ${ignoreValues.length ? ignoreValues.join(', ') : '(none)'}`,
|
|
295
|
+
` maxFindings: ${cfg.limits.maxFindings}`,
|
|
296
|
+
` maxChars: ${cfg.limits.maxChars}`,
|
|
297
|
+
` env override: ${envState}`,
|
|
298
|
+
` cache file: ${fs.existsSync(getCachePath(cwd)) ? cachePath : `${cachePath} (not present)`}`,
|
|
299
|
+
];
|
|
300
|
+
return lines.join('\n');
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function setEnabled(cwd, value) {
|
|
304
|
+
const config = mergeHookConfig(readRawHookConfig(cwd));
|
|
305
|
+
config.enabled = value;
|
|
306
|
+
const target = writeHookConfig(cwd, config);
|
|
307
|
+
if (!value) {
|
|
308
|
+
return `Design hook disabled for this project (wrote ${path.relative(cwd, target) || target}).`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const localTarget = writeHookConfig(cwd, { consent: 'accepted' }, { local: true });
|
|
312
|
+
const repaired = repairHookManifests(cwd);
|
|
313
|
+
const parts = [
|
|
314
|
+
`Design hook enabled for this project (wrote ${path.relative(cwd, target) || target}).`,
|
|
315
|
+
`Recorded local hook consent in ${path.relative(cwd, localTarget) || localTarget}.`,
|
|
316
|
+
];
|
|
317
|
+
if (repaired.written.length > 0) {
|
|
318
|
+
parts.push(`Installed or repaired hook manifests for: ${repaired.written.join(', ')}.`);
|
|
319
|
+
} else if (repaired.already.length > 0) {
|
|
320
|
+
parts.push(`Hook manifests already installed for: ${repaired.already.join(', ')}.`);
|
|
321
|
+
} else {
|
|
322
|
+
parts.push('No installed provider skill folders found to repair.');
|
|
323
|
+
}
|
|
324
|
+
if (repaired.backups.length > 0) {
|
|
325
|
+
parts.push(`Backed up malformed manifest(s): ${repaired.backups.map((filePath) => path.relative(cwd, filePath) || filePath).join(', ')}.`);
|
|
326
|
+
}
|
|
327
|
+
return parts.join(' ');
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function repairHookManifests(cwd) {
|
|
331
|
+
const result = { written: [], already: [], backups: [] };
|
|
332
|
+
for (const target of HOOK_MANIFEST_TARGETS) {
|
|
333
|
+
if (!fs.existsSync(path.join(cwd, target.skillRel))) continue;
|
|
334
|
+
const dest = path.join(cwd, target.destRel);
|
|
335
|
+
const sharedDest = target.sharedDestRel ? path.join(cwd, target.sharedDestRel) : null;
|
|
336
|
+
|
|
337
|
+
if (sharedDest && fileHasImpeccableHookMarker(sharedDest)) {
|
|
338
|
+
pruneImpeccableHookFromManifest(dest);
|
|
339
|
+
result.already.push(target.provider);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const fresh = target.manifest();
|
|
344
|
+
let next = fresh;
|
|
345
|
+
if (fs.existsSync(dest)) {
|
|
346
|
+
try {
|
|
347
|
+
next = mergeHookManifests(JSON.parse(fs.readFileSync(dest, 'utf-8')), fresh);
|
|
348
|
+
} catch {
|
|
349
|
+
const backup = `${dest}.bak`;
|
|
350
|
+
fs.copyFileSync(dest, backup);
|
|
351
|
+
result.backups.push(backup);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const serialized = `${JSON.stringify(next, null, 2)}\n`;
|
|
356
|
+
const current = fs.existsSync(dest) ? safeReadText(dest) : null;
|
|
357
|
+
if (current === serialized) {
|
|
358
|
+
result.already.push(target.provider);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
362
|
+
fs.writeFileSync(dest, serialized);
|
|
363
|
+
result.written.push(target.provider);
|
|
364
|
+
}
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function safeReadText(filePath) {
|
|
369
|
+
try {
|
|
370
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
371
|
+
} catch {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function mergeHookManifests(existing, fresh) {
|
|
377
|
+
const existingObject = existing && typeof existing === 'object' && !Array.isArray(existing) ? existing : {};
|
|
378
|
+
const freshObject = fresh && typeof fresh === 'object' && !Array.isArray(fresh) ? fresh : {};
|
|
379
|
+
const existingHooks = existingObject.hooks && typeof existingObject.hooks === 'object' && !Array.isArray(existingObject.hooks)
|
|
380
|
+
? existingObject.hooks
|
|
381
|
+
: {};
|
|
382
|
+
const freshHooks = freshObject.hooks && typeof freshObject.hooks === 'object' && !Array.isArray(freshObject.hooks)
|
|
383
|
+
? freshObject.hooks
|
|
384
|
+
: {};
|
|
385
|
+
|
|
386
|
+
const merged = { ...existingObject, hooks: {} };
|
|
387
|
+
if (freshObject.version !== undefined) merged.version = freshObject.version;
|
|
388
|
+
if (freshObject.description !== undefined) merged.description = freshObject.description;
|
|
389
|
+
|
|
390
|
+
const hookEvents = new Set([...Object.keys(existingHooks), ...Object.keys(freshHooks)]);
|
|
391
|
+
for (const event of hookEvents) {
|
|
392
|
+
const preserved = stripImpeccableHookEntries(existingHooks[event]);
|
|
393
|
+
const added = Array.isArray(freshHooks[event]) ? freshHooks[event] : [];
|
|
394
|
+
const mergedEntries = [...preserved, ...added];
|
|
395
|
+
if (mergedEntries.length > 0) merged.hooks[event] = mergedEntries;
|
|
396
|
+
}
|
|
397
|
+
return merged;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function fileHasImpeccableHookMarker(filePath) {
|
|
401
|
+
if (!fs.existsSync(filePath)) return false;
|
|
402
|
+
let parsed;
|
|
403
|
+
try {
|
|
404
|
+
parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
405
|
+
} catch {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return false;
|
|
409
|
+
if (!parsed.hooks || typeof parsed.hooks !== 'object') return false;
|
|
410
|
+
return valueHasImpeccableHookMarker(parsed.hooks);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function valueHasImpeccableHookMarker(value) {
|
|
414
|
+
if (typeof value === 'string') {
|
|
415
|
+
return IMPECCABLE_HOOK_COMMAND_MARKERS.some((marker) => value.includes(marker));
|
|
416
|
+
}
|
|
417
|
+
if (Array.isArray(value)) return value.some(valueHasImpeccableHookMarker);
|
|
418
|
+
if (value && typeof value === 'object') return Object.values(value).some(valueHasImpeccableHookMarker);
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function stripImpeccableHookEntry(entry) {
|
|
423
|
+
if (!entry || typeof entry !== 'object') return entry;
|
|
424
|
+
// `command`/`args`: Claude/Codex/Cursor. `bash`/`powershell`: GitHub Copilot's
|
|
425
|
+
// flat entry shape, where the marker lives under the shell-command keys.
|
|
426
|
+
if (valueHasImpeccableHookMarker(entry.command) || valueHasImpeccableHookMarker(entry.args)
|
|
427
|
+
|| valueHasImpeccableHookMarker(entry.bash) || valueHasImpeccableHookMarker(entry.powershell)) {
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
if (!Array.isArray(entry.hooks)) return entry;
|
|
431
|
+
|
|
432
|
+
const strippedHooks = entry.hooks
|
|
433
|
+
.map(stripImpeccableHookEntry)
|
|
434
|
+
.filter(Boolean);
|
|
435
|
+
|
|
436
|
+
if (strippedHooks.length === 0 && entry.hooks.some(valueHasImpeccableHookMarker)) {
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
return { ...entry, hooks: strippedHooks };
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function stripImpeccableHookEntries(entries) {
|
|
443
|
+
if (!Array.isArray(entries)) return [];
|
|
444
|
+
return entries
|
|
445
|
+
.map(stripImpeccableHookEntry)
|
|
446
|
+
.filter(Boolean);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function pruneImpeccableHookFromManifest(manifestPath) {
|
|
450
|
+
if (!fileHasImpeccableHookMarker(manifestPath)) return false;
|
|
451
|
+
let parsed;
|
|
452
|
+
try {
|
|
453
|
+
parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf-8'));
|
|
454
|
+
} catch {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const existingHooks = parsed.hooks && typeof parsed.hooks === 'object' && !Array.isArray(parsed.hooks)
|
|
459
|
+
? parsed.hooks
|
|
460
|
+
: {};
|
|
461
|
+
const cleanedHooks = {};
|
|
462
|
+
for (const [event, entries] of Object.entries(existingHooks)) {
|
|
463
|
+
const kept = stripImpeccableHookEntries(entries);
|
|
464
|
+
if (kept.length > 0) cleanedHooks[event] = kept;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const next = { ...parsed };
|
|
468
|
+
if (Object.keys(cleanedHooks).length > 0) {
|
|
469
|
+
next.hooks = cleanedHooks;
|
|
470
|
+
} else {
|
|
471
|
+
delete next.hooks;
|
|
472
|
+
delete next.description;
|
|
473
|
+
delete next.version;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (Object.keys(next).length === 0) {
|
|
477
|
+
fs.rmSync(manifestPath, { force: true });
|
|
478
|
+
} else {
|
|
479
|
+
fs.writeFileSync(manifestPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
480
|
+
}
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function normalizeRuleId(rule) {
|
|
485
|
+
return String(rule || '').trim().toLowerCase();
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function parseIgnoreRuleArgs(args) {
|
|
489
|
+
const positionals = [];
|
|
490
|
+
let allValues = false;
|
|
491
|
+
|
|
492
|
+
for (let i = 0; i < args.length; i++) {
|
|
493
|
+
const arg = String(args[i] || '');
|
|
494
|
+
if (arg === '--all-values') {
|
|
495
|
+
allValues = true;
|
|
496
|
+
} else if (arg === '--reason') {
|
|
497
|
+
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) i++;
|
|
498
|
+
} else if (arg.startsWith('--reason=')) {
|
|
499
|
+
// Accepted for command symmetry; ignoreRules stores rule ids only.
|
|
500
|
+
} else if (arg.startsWith('--')) {
|
|
501
|
+
throw new Error(`Unknown ignore-rule flag: ${arg}`);
|
|
502
|
+
} else {
|
|
503
|
+
positionals.push(arg);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
return {
|
|
508
|
+
rule: normalizeRuleId(positionals[0]),
|
|
509
|
+
allValues,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function addIgnoreRule(cwd, args) {
|
|
514
|
+
const parsed = parseIgnoreRuleArgs(args);
|
|
515
|
+
const rule = parsed.rule;
|
|
516
|
+
if (!rule) throw new Error('Pass a rule id, e.g. /impeccable hooks ignore-rule side-tab');
|
|
517
|
+
if (rule === 'overused-font' && !parsed.allValues) {
|
|
518
|
+
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.');
|
|
519
|
+
}
|
|
520
|
+
const config = mergeDetectorConfig(readRawDetectorConfig(cwd));
|
|
521
|
+
if (!config.ignoreRules.includes(rule)) config.ignoreRules.push(rule);
|
|
522
|
+
writeDetectorConfig(cwd, config);
|
|
523
|
+
return `Added "${rule}" to detector.ignoreRules. Current: ${config.ignoreRules.join(', ')}`;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function addIgnoreFile(cwd, glob) {
|
|
527
|
+
if (!glob) throw new Error('Pass a glob, e.g. /impeccable hooks ignore-file "src/legacy/**"');
|
|
528
|
+
const config = mergeDetectorConfig(readRawDetectorConfig(cwd));
|
|
529
|
+
if (!config.ignoreFiles.includes(glob)) config.ignoreFiles.push(glob);
|
|
530
|
+
writeDetectorConfig(cwd, config);
|
|
531
|
+
return `Added "${glob}" to detector.ignoreFiles. Current: ${config.ignoreFiles.join(', ')}`;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function parseIgnoreValueArgs(args) {
|
|
535
|
+
const positionals = [];
|
|
536
|
+
let shared = false;
|
|
537
|
+
let local = false;
|
|
538
|
+
let reason = '';
|
|
539
|
+
|
|
540
|
+
for (let i = 0; i < args.length; i++) {
|
|
541
|
+
const arg = args[i];
|
|
542
|
+
if (arg === '--shared') {
|
|
543
|
+
shared = true;
|
|
544
|
+
} else if (arg === '--local') {
|
|
545
|
+
local = true;
|
|
546
|
+
} else if (arg === '--reason') {
|
|
547
|
+
const chunks = [];
|
|
548
|
+
while (i + 1 < args.length && !String(args[i + 1]).startsWith('--')) {
|
|
549
|
+
chunks.push(args[++i]);
|
|
550
|
+
}
|
|
551
|
+
reason = chunks.join(' ').trim();
|
|
552
|
+
} else if (String(arg).startsWith('--reason=')) {
|
|
553
|
+
reason = String(arg).slice('--reason='.length).trim();
|
|
554
|
+
} else {
|
|
555
|
+
positionals.push(arg);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const [rule, ...valueParts] = positionals;
|
|
560
|
+
return {
|
|
561
|
+
rule: String(rule || '').trim().toLowerCase(),
|
|
562
|
+
value: normalizeIgnoreValue(valueParts.join(' ')),
|
|
563
|
+
shared,
|
|
564
|
+
local,
|
|
565
|
+
reason,
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function addIgnoreValue(cwd, args) {
|
|
570
|
+
const parsed = parseIgnoreValueArgs(args);
|
|
571
|
+
if (!parsed.rule || !parsed.value) {
|
|
572
|
+
throw new Error('Pass a rule id and value, e.g. /impeccable hooks ignore-value overused-font Inter');
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
if (parsed.shared && parsed.local) {
|
|
576
|
+
throw new Error('Pass only one scope flag: --shared or --local');
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const local = parsed.local;
|
|
580
|
+
const config = mergeDetectorConfig(readRawDetectorConfig(cwd, { local }));
|
|
581
|
+
const key = `${parsed.rule}\0${parsed.value}`;
|
|
582
|
+
const existing = config.ignoreValues.find((entry) => `${entry.rule}\0${entry.value}` === key);
|
|
583
|
+
|
|
584
|
+
if (existing) {
|
|
585
|
+
if (parsed.reason) existing.reason = parsed.reason;
|
|
586
|
+
} else {
|
|
587
|
+
const entry = {
|
|
588
|
+
rule: parsed.rule,
|
|
589
|
+
value: parsed.value,
|
|
590
|
+
createdAt: new Date().toISOString(),
|
|
591
|
+
};
|
|
592
|
+
if (parsed.reason) entry.reason = parsed.reason;
|
|
593
|
+
config.ignoreValues.push(entry);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const target = writeDetectorConfig(cwd, config, { local });
|
|
597
|
+
const scope = local ? 'local detector.ignoreValues' : 'shared detector.ignoreValues';
|
|
598
|
+
return `Added ${parsed.rule}=${parsed.value} to ${scope} (${path.relative(cwd, target) || target}).`;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function reset(cwd) {
|
|
602
|
+
const removed = [];
|
|
603
|
+
// Unified files may hold non-hook keys (e.g. updateCheck); strip only the
|
|
604
|
+
// hook/detector subtrees and keep the rest, deleting the file only if nothing remains.
|
|
605
|
+
for (const filePath of [getConfigPath(cwd), getLocalConfigPath(cwd)]) {
|
|
606
|
+
try {
|
|
607
|
+
const raw = readRawConfigFile(filePath).raw;
|
|
608
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw) || (!('hook' in raw) && !('detector' in raw))) continue;
|
|
609
|
+
const { hook, detector, ...rest } = raw;
|
|
610
|
+
if (Object.keys(rest).length === 0) {
|
|
611
|
+
fs.unlinkSync(filePath);
|
|
612
|
+
} else {
|
|
613
|
+
fs.writeFileSync(filePath, JSON.stringify(rest, null, 2) + '\n');
|
|
614
|
+
}
|
|
615
|
+
removed.push(path.relative(cwd, filePath) || filePath);
|
|
616
|
+
} catch { /* ignore */ }
|
|
617
|
+
}
|
|
618
|
+
// State files are wholly ours; delete outright.
|
|
619
|
+
for (const filePath of [getCachePath(cwd), getPendingPath(cwd)]) {
|
|
620
|
+
try {
|
|
621
|
+
if (fs.existsSync(filePath)) {
|
|
622
|
+
fs.unlinkSync(filePath);
|
|
623
|
+
removed.push(path.relative(cwd, filePath) || filePath);
|
|
624
|
+
}
|
|
625
|
+
} catch { /* ignore */ }
|
|
626
|
+
}
|
|
627
|
+
return removed.length
|
|
628
|
+
? `Reset design hook config and cache (removed: ${removed.join(', ')}).`
|
|
629
|
+
: 'No hook config or cache to remove. Already at defaults.';
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function main() {
|
|
633
|
+
const [, , actionArg, ...rest] = process.argv;
|
|
634
|
+
const action = (actionArg || 'status').toLowerCase();
|
|
635
|
+
const cwd = process.cwd();
|
|
636
|
+
|
|
637
|
+
if (!ACTIONS.has(action)) {
|
|
638
|
+
process.stderr.write(`Unknown action: ${action}\nValid: ${Array.from(ACTIONS).join(', ')}\n`);
|
|
639
|
+
process.exit(1);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
try {
|
|
643
|
+
let out = '';
|
|
644
|
+
switch (action) {
|
|
645
|
+
case 'status': out = statusReport(cwd); break;
|
|
646
|
+
case 'on': out = setEnabled(cwd, true); break;
|
|
647
|
+
case 'off': out = setEnabled(cwd, false); break;
|
|
648
|
+
case 'ignore-rule': out = addIgnoreRule(cwd, rest); break;
|
|
649
|
+
case 'ignore-file': out = addIgnoreFile(cwd, rest[0]); break;
|
|
650
|
+
case 'ignore-value': out = addIgnoreValue(cwd, rest); break;
|
|
651
|
+
case 'reset': out = reset(cwd); break;
|
|
652
|
+
}
|
|
653
|
+
process.stdout.write(out + '\n');
|
|
654
|
+
} catch (err) {
|
|
655
|
+
process.stderr.write(`Error: ${err.message || err}\n`);
|
|
656
|
+
process.exit(1);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
main();
|