@selesai/code 0.12.0 → 0.13.1
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 +17 -0
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.js +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/usage-totals.d.ts +2 -0
- package/dist/core/usage-totals.js +10 -0
- package/dist/extensions/ascii.txt +9 -0
- package/dist/extensions/package.json +1 -2
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +371 -0
- package/dist/extensions/pi-hermes-memory/LICENSE +21 -0
- package/dist/extensions/pi-hermes-memory/README.md +643 -0
- package/dist/extensions/pi-hermes-memory/docs/0.1/TASKS.md +197 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/PLAN.md +290 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TASKS.md +134 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TEST-PLAN.md +216 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/PLAN.md +330 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/TASKS.md +125 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/PLAN.md +160 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/TASKS.md +113 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/CHANGELOG.md +57 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/PLAN.md +202 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/TASKS.md +144 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/PLAN.md +349 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/TASKS.md +110 -0
- package/dist/extensions/pi-hermes-memory/docs/PUBLISHING.md +149 -0
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +468 -0
- package/dist/extensions/pi-hermes-memory/docs/images/memory-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi-logo.svg +22 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.png +0 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.svg +19 -0
- package/dist/extensions/pi-hermes-memory/docs/images/security-flow.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/session-lifecycle.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/source-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/memory-architecture.mmd +49 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/security-flow.mmd +40 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/session-lifecycle.mmd +56 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/source-architecture.mmd +54 -0
- package/dist/extensions/pi-hermes-memory/package-lock.json +3799 -0
- package/dist/extensions/pi-hermes-memory/package.json +66 -0
- package/dist/extensions/pi-hermes-memory/scripts/check-min-sdk.mjs +99 -0
- package/dist/extensions/pi-hermes-memory/scripts/ensure-dev.mjs +57 -0
- package/dist/extensions/pi-hermes-memory/src/auto-consolidation-warning.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/config.ts +178 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +424 -0
- package/dist/extensions/pi-hermes-memory/src/extension-root-migration.ts +639 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/auto-consolidate.ts +401 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +297 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/child-process-watchdog.mjs +90 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/correction-detector.ts +300 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +86 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/insights.ts +78 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/interview.ts +37 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/learn-memory.ts +186 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/message-parts.ts +27 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/pi-child-process.ts +485 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/preview-context.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +506 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +145 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-flush.ts +151 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-live-index.ts +94 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/skills-command.ts +1334 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/standing-pin.ts +111 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/switch-project.ts +75 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +266 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +378 -0
- package/dist/extensions/pi-hermes-memory/src/lifecycle-timing.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/paths.ts +61 -0
- package/dist/extensions/pi-hermes-memory/src/project-context.ts +13 -0
- package/dist/extensions/pi-hermes-memory/src/project-memory-migration.ts +93 -0
- package/dist/extensions/pi-hermes-memory/src/project.ts +157 -0
- package/dist/extensions/pi-hermes-memory/src/prompt-context.ts +55 -0
- package/dist/extensions/pi-hermes-memory/src/store/atomic-lock-coordinator.ts +375 -0
- package/dist/extensions/pi-hermes-memory/src/store/canonical-storage-path.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/store/content-scanner.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +1180 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/markdown-mutation-lock.ts +38 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-lookup.ts +24 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +1191 -0
- package/dist/extensions/pi-hermes-memory/src/store/recovery-maintenance.ts +66 -0
- package/dist/extensions/pi-hermes-memory/src/store/schema.ts +118 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-anchor-search.ts +472 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +511 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-parser.ts +213 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +234 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-store.ts +950 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-utils.ts +133 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +1002 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-native.ts +241 -0
- package/dist/extensions/pi-hermes-memory/src/store/standing-instructions.ts +247 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +95 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +469 -0
- package/dist/extensions/pi-hermes-memory/src/tools/session-search-tool.ts +246 -0
- package/dist/extensions/pi-hermes-memory/src/tools/shared-output-view.ts +170 -0
- package/dist/extensions/pi-hermes-memory/src/tools/skill-tool.ts +333 -0
- package/dist/extensions/pi-hermes-memory/src/tools/tool-result-views.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/types.ts +214 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +434 -0
- package/dist/extensions/pi-hermes-memory/tests/extension-root-migration.test.ts +368 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/auto-consolidate.test.ts +984 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +950 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/correction-detector.test.ts +671 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/insights.test.ts +157 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/interview.test.ts +127 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/pi-child-process.test.ts +905 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/preview-context.test.ts +152 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/prompt-context.test.ts +166 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/resources-discover.test.ts +71 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +614 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +192 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-flush.test.ts +677 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-live-index.test.ts +225 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/skills-command.test.ts +827 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/standing-pin.test.ts +134 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/sync-markdown-memories.test.ts +491 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/system-prompt.test.ts +199 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/thinking-max.test.ts +64 -0
- package/dist/extensions/pi-hermes-memory/tests/index.test.ts +30 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/flow.test.ts +126 -0
- package/dist/extensions/pi-hermes-memory/tests/lifecycle-timing.test.ts +76 -0
- package/dist/extensions/pi-hermes-memory/tests/paths.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/tests/project-memory-migration.test.ts +80 -0
- package/dist/extensions/pi-hermes-memory/tests/project-rebinding.test.ts +115 -0
- package/dist/extensions/pi-hermes-memory/tests/project.test.ts +120 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all-timeout.test.ts +107 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all.sh +45 -0
- package/dist/extensions/pi-hermes-memory/tests/store/atomic-lock-coordinator.test.ts +381 -0
- package/dist/extensions/pi-hermes-memory/tests/store/content-scanner.test.ts +388 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +1046 -0
- package/dist/extensions/pi-hermes-memory/tests/store/markdown-mutation-lock.test.ts +34 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +2150 -0
- package/dist/extensions/pi-hermes-memory/tests/store/recovery-maintenance.test.ts +170 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-anchor-search.test.ts +210 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +643 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-parser.test.ts +282 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +287 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-store.test.ts +678 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-utils.test.ts +21 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-lazy-load.test.ts +78 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +543 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +164 -0
- package/dist/extensions/pi-hermes-memory/tests/store/standing-instructions.test.ts +171 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +84 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +709 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/session-search-tool.test.ts +345 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/shared-output-view.test.ts +362 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/skill-tool.test.ts +478 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/tool-result-renderer-wiring.test.ts +40 -0
- package/dist/extensions/pi-hermes-memory/tsconfig.json +19 -0
- package/dist/extensions/pi-subagents/.oxlintrc.json +43 -0
- package/dist/extensions/pi-subagents/AGENTS.md +5 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +157 -0
- package/dist/extensions/pi-subagents/README.md +12 -6
- package/dist/extensions/pi-subagents/VISION.md +81 -0
- package/dist/extensions/pi-subagents/agents/claude-code-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/claude-code.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec-writer.md +15 -0
- package/dist/extensions/pi-subagents/agents/codex-exec.md +15 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent-writer.md +14 -0
- package/dist/extensions/pi-subagents/agents/cursor-agent.md +14 -0
- package/dist/extensions/pi-subagents/agents/reviewer.md +1 -3
- package/dist/extensions/pi-subagents/docs/agents.md +488 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +46 -9
- package/dist/extensions/pi-subagents/docs/extension-api.md +42 -3
- package/dist/extensions/pi-subagents/docs/models.md +27 -4
- package/dist/extensions/pi-subagents/docs/observability.md +10 -9
- package/dist/extensions/pi-subagents/docs/tool-reference.md +102 -6
- package/dist/extensions/pi-subagents/docs/workflows.md +135 -0
- package/dist/extensions/pi-subagents/package-lock.json +389 -2
- package/dist/extensions/pi-subagents/package.json +3 -1
- package/dist/extensions/pi-subagents/prompts/review-loop.md +2 -2
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +3 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +7 -3
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +26 -5
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +41 -22
- package/dist/extensions/pi-subagents/src/agents/agent-refinements.ts +4 -4
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +9 -2
- package/dist/extensions/pi-subagents/src/agents/agents.ts +322 -75
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +6 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +27 -20
- package/dist/extensions/pi-subagents/src/api/agents.ts +10 -5
- package/dist/extensions/pi-subagents/src/api/background-work.ts +5 -1
- package/dist/extensions/pi-subagents/src/api/delegation.ts +0 -7
- package/dist/extensions/pi-subagents/src/api/preflight.ts +34 -12
- package/dist/extensions/pi-subagents/src/extension/config.ts +70 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +3 -3
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +5 -3
- package/dist/extensions/pi-subagents/src/extension/index.ts +83 -30
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +44 -15
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +55 -19
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +41 -15
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +28 -31
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +2 -1
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +2 -10
- package/dist/extensions/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +51 -3
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +2 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +5 -6
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +77 -10
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +176 -53
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +19 -12
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +29 -27
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +20 -3
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +23 -261
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +73 -7
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +8 -3
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +74 -8
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +37 -21
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +8 -8
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +184 -9
- package/dist/extensions/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +28 -14
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +38 -15
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +50 -13
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +93 -8
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +10 -4
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +4 -14
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +549 -377
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +58 -10
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +26 -1
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +23 -9
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +9 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +204 -129
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +23 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +773 -311
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +140 -115
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +463 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +19 -4
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +21 -7
- package/dist/extensions/pi-subagents/src/runs/shared/claude-code-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/codex-exec-adapter.ts +129 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +5 -4
- package/dist/extensions/pi-subagents/src/runs/shared/cursor-agent-adapter.ts +114 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +167 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +348 -55
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +5 -5
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +230 -0
- package/dist/extensions/pi-subagents/src/runs/shared/lane-metadata.ts +105 -0
- package/dist/extensions/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +221 -158
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +197 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +69 -7
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +47 -6
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +7 -2
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +9 -3
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +419 -7
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +15 -1
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +81 -8
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +13 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +21 -1
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +44 -4
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +98 -13
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +1 -1
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +18 -0
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/dist/extensions/pi-subagents/src/shared/extension-context.ts +24 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/formatters.ts +18 -3
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +5 -1
- package/dist/extensions/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/dist/extensions/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/dist/extensions/pi-subagents/src/shared/session-tokens.ts +14 -3
- package/dist/extensions/pi-subagents/src/shared/settings.ts +19 -105
- package/dist/extensions/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +359 -40
- package/dist/extensions/pi-subagents/src/shared/utils.ts +41 -84
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +116 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +1 -9
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +0 -4
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +1 -2
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +378 -88
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +22 -11
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +3 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +147 -79
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +11 -5
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +39 -18
- package/dist/extensions/pi-subagents/src/tui/render.ts +369 -46
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +1 -1
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +6 -3
- package/dist/extensions/pi-subagents/src/workflows/host-command.ts +230 -0
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +740 -58
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +270 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +195 -6
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +1114 -260
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +150 -3
- package/dist/extensions/pi-subagents/test/integration/claude-code-smoke.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/integration/claude-code-writer-smoke.test.ts +55 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-smoke.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/integration/codex-exec-writer-smoke.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-smoke.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/integration/cursor-agent-writer-smoke.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +57 -1
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +4 -3
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +54 -4
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +482 -4
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +157 -9
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +5 -5
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +1508 -291
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +423 -1
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/support/cursor-smoke-inputs.ts +51 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +2 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +5 -5
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +6 -6
- package/dist/extensions/pi-subagents/test/unit/abort-recovery.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +48 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +184 -6
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +66 -6
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/agent-refinements.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/anti-slop-oxlint.test.ts +86 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +101 -1
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +14 -7
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +190 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +42 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +8 -4
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +78 -1
- package/dist/extensions/pi-subagents/test/unit/child-launch-plan.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/child-session-name.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/claude-code-adapter.test.ts +245 -0
- package/dist/extensions/pi-subagents/test/unit/codex-exec-adapter.test.ts +192 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +150 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-agent-adapter.test.ts +259 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-smoke-inputs.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +1 -4
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/extension-context.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +223 -0
- package/dist/extensions/pi-subagents/test/unit/fast-mode-extension.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +208 -2
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +29 -1
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +110 -1
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +10 -0
- package/dist/extensions/pi-subagents/test/unit/formatters.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +18 -9
- package/dist/extensions/pi-subagents/test/unit/herdr-session-roots-codec.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +132 -0
- package/dist/extensions/pi-subagents/test/unit/host-command.test.ts +156 -0
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +178 -26
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +2 -1
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/mcp-direct-tool-grant.test.ts +138 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +72 -7
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +20 -2
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +129 -1
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +4 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +358 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +574 -21
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +109 -1
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +7 -7
- package/dist/extensions/pi-subagents/test/unit/pruned-fork.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +29 -8
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +53 -0
- package/dist/extensions/pi-subagents/test/unit/result-delivery-ownership.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +101 -3
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +10 -8
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +71 -1
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +41 -7
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +136 -2
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +137 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +33 -12
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +504 -1
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +8 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +12 -1
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +3 -5
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +5 -6
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +0 -8
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +5 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +157 -2
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +1 -1
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +63 -4
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +27 -23
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +44 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +1 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +7 -5
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +106 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +484 -9
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +38 -4
- package/dist/extensions/pi-subagents/test/unit/workflow-preflight.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +318 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +21 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +2 -7
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/index.ts +13 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/index.ts +41 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +247 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-module-mocking.ts +91 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-object-parameters.ts +126 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +67 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +39 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +83 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +115 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +72 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +134 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +62 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/dictionary-types.ts +502 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +60 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/reflect-method.ts +35 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +1 -1
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +2 -2
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +1 -1
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +2 -1
- package/dist/extensions/pi-zentui/test/format.test.ts +15 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/interactive-mode.js +11 -11
- package/dist/skills/workflow/SKILL.md +65 -50
- package/package.json +112 -110
- package/dist/extensions/enable-readonly-tools.test.ts +0 -63
- package/dist/extensions/enable-readonly-tools.ts +0 -24
- package/dist/extensions/model-prompt-injector/config.json +0 -16
- package/dist/extensions/model-prompt-injector/index.test.ts +0 -102
- package/dist/extensions/model-prompt-injector/index.ts +0 -148
- package/dist/extensions/pi-subagents/src/runs/shared/turn-budget.ts +0 -98
- package/dist/extensions/pi-subagents/test/unit/turn-budget.test.ts +0 -250
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
classifyWideningTarget,
|
|
5
|
+
createTypeEnvironment,
|
|
6
|
+
isKnownEvidenceExpression,
|
|
7
|
+
type TypeEnvironment,
|
|
8
|
+
type WideningTarget,
|
|
9
|
+
} from "../shared/dictionary-types.ts";
|
|
10
|
+
|
|
11
|
+
import type { ESTree, Scope, SourceCode, Variable } from "@oxlint/plugins";
|
|
12
|
+
|
|
13
|
+
type FunctionExpression = ESTree.ArrowFunctionExpression | ESTree.Function;
|
|
14
|
+
|
|
15
|
+
function unwrapExpression(expression: ESTree.Expression): ESTree.Expression {
|
|
16
|
+
let current = expression;
|
|
17
|
+
while (
|
|
18
|
+
current.type === "ParenthesizedExpression" ||
|
|
19
|
+
current.type === "TSAsExpression" ||
|
|
20
|
+
current.type === "TSSatisfiesExpression" ||
|
|
21
|
+
current.type === "TSTypeAssertion" ||
|
|
22
|
+
current.type === "TSNonNullExpression"
|
|
23
|
+
) {
|
|
24
|
+
current = current.expression;
|
|
25
|
+
}
|
|
26
|
+
return current;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function resolveVariable(
|
|
30
|
+
sourceCode: SourceCode,
|
|
31
|
+
identifier: ESTree.IdentifierReference,
|
|
32
|
+
): Variable | null {
|
|
33
|
+
let scope: Scope | null = sourceCode.getScope(identifier);
|
|
34
|
+
while (scope !== null) {
|
|
35
|
+
const variable = scope.set.get(identifier.name);
|
|
36
|
+
if (variable !== undefined) return variable;
|
|
37
|
+
scope = scope.upper;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function variableDeclarator(variable: Variable): ESTree.VariableDeclarator | null {
|
|
43
|
+
if (variable.defs.length !== 1) return null;
|
|
44
|
+
const [definition] = variable.defs;
|
|
45
|
+
return definition?.type === "Variable" && definition.node.type === "VariableDeclarator"
|
|
46
|
+
? definition.node
|
|
47
|
+
: null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isStableConstVariable(variable: Variable, declarator: ESTree.VariableDeclarator): boolean {
|
|
51
|
+
return (
|
|
52
|
+
declarator.parent.type === "VariableDeclaration" &&
|
|
53
|
+
declarator.parent.kind === "const" &&
|
|
54
|
+
variable.references.every((reference) => reference.init || !reference.isWrite())
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function hasKnownEvidence(
|
|
59
|
+
sourceCode: SourceCode,
|
|
60
|
+
expression: ESTree.Expression,
|
|
61
|
+
visitedVariables = new Set<Variable>(),
|
|
62
|
+
): boolean {
|
|
63
|
+
if (isKnownEvidenceExpression(expression)) return true;
|
|
64
|
+
const unwrapped = unwrapExpression(expression);
|
|
65
|
+
if (unwrapped.type !== "Identifier") return false;
|
|
66
|
+
const variable = resolveVariable(sourceCode, unwrapped);
|
|
67
|
+
if (variable === null || visitedVariables.has(variable)) return false;
|
|
68
|
+
const declarator = variableDeclarator(variable);
|
|
69
|
+
if (
|
|
70
|
+
declarator === null ||
|
|
71
|
+
declarator.init === null ||
|
|
72
|
+
!isStableConstVariable(variable, declarator)
|
|
73
|
+
) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
visitedVariables.add(variable);
|
|
77
|
+
return hasKnownEvidence(sourceCode, declarator.init, visitedVariables);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function annotationTarget(
|
|
81
|
+
annotation: ESTree.TSTypeAnnotation | null | undefined,
|
|
82
|
+
environment: TypeEnvironment,
|
|
83
|
+
): WideningTarget | null {
|
|
84
|
+
return annotation === null || annotation === undefined
|
|
85
|
+
? null
|
|
86
|
+
: classifyWideningTarget(annotation.typeAnnotation, environment);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function enclosingFunction(node: ESTree.Node): FunctionExpression | null {
|
|
90
|
+
let current: ESTree.Node | null = node.parent;
|
|
91
|
+
while (current !== null && current.type !== "Program") {
|
|
92
|
+
if (
|
|
93
|
+
current.type === "ArrowFunctionExpression" ||
|
|
94
|
+
current.type === "FunctionDeclaration" ||
|
|
95
|
+
current.type === "FunctionExpression"
|
|
96
|
+
) {
|
|
97
|
+
return current;
|
|
98
|
+
}
|
|
99
|
+
current = current.parent;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function sourceKeyName(sourceCode: SourceCode, key: ESTree.PropertyKey): string {
|
|
105
|
+
if (key.type === "Identifier" || key.type === "PrivateIdentifier") return key.name;
|
|
106
|
+
if (key.type === "Literal") return String(key.value);
|
|
107
|
+
return sourceCode.getText(key);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function functionName(sourceCode: SourceCode, owner: FunctionExpression | null): string {
|
|
111
|
+
if (owner === null) return "anonymous function";
|
|
112
|
+
if (owner.id !== null) return owner.id.name;
|
|
113
|
+
const parent = owner.parent;
|
|
114
|
+
if (parent.type === "VariableDeclarator" && parent.id.type === "Identifier")
|
|
115
|
+
return parent.id.name;
|
|
116
|
+
if (parent.type === "MethodDefinition") return sourceKeyName(sourceCode, parent.key);
|
|
117
|
+
return "anonymous function";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isEmptyObjectExpression(expression: ESTree.Expression): boolean {
|
|
121
|
+
const unwrapped = unwrapExpression(expression);
|
|
122
|
+
return unwrapped.type === "ObjectExpression" && unwrapped.properties.length === 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isDictionaryAccumulatorTarget(destination: WideningTarget): boolean {
|
|
126
|
+
return destination.kind === "open dictionary" || destination.kind === "generic container";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function hasParentAssertion(node: ESTree.Node): boolean {
|
|
130
|
+
return node.parent?.type === "TSAsExpression" || node.parent?.type === "TSTypeAssertion";
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Detect sound syntactic cases where a known value is explicitly widened and loses evidence. */
|
|
134
|
+
export const noKnownValueWideningRule = defineRule({
|
|
135
|
+
meta: {
|
|
136
|
+
type: "problem",
|
|
137
|
+
docs: {
|
|
138
|
+
description:
|
|
139
|
+
"Disallow syntactically established values from flowing into explicitly broad or anonymous target types that discard useful evidence.",
|
|
140
|
+
},
|
|
141
|
+
messages: {
|
|
142
|
+
widening:
|
|
143
|
+
"The explicit {{target}} type on {{subject}} discards known type evidence. Keep inference, validate with `satisfies`, or use a named owner contract.",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
createOnce(context) {
|
|
147
|
+
let environment: TypeEnvironment | null = null;
|
|
148
|
+
|
|
149
|
+
const reportFlow = (
|
|
150
|
+
expression: ESTree.Expression,
|
|
151
|
+
destination: WideningTarget | null,
|
|
152
|
+
subject: string,
|
|
153
|
+
) => {
|
|
154
|
+
if (destination === null) return;
|
|
155
|
+
if (
|
|
156
|
+
isDictionaryAccumulatorTarget(destination) &&
|
|
157
|
+
isEmptyObjectExpression(expression)
|
|
158
|
+
) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!hasKnownEvidence(context.sourceCode, expression)) return;
|
|
162
|
+
context.report({
|
|
163
|
+
node: expression,
|
|
164
|
+
messageId: "widening",
|
|
165
|
+
data: { subject, target: destination.kind },
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const targetFromAnnotation = (annotation: ESTree.TSTypeAnnotation | null | undefined) =>
|
|
170
|
+
environment === null ? null : annotationTarget(annotation, environment);
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
Program(node) {
|
|
174
|
+
environment = createTypeEnvironment(node);
|
|
175
|
+
},
|
|
176
|
+
VariableDeclarator(node) {
|
|
177
|
+
if (node.init === null || node.id.type !== "Identifier") return;
|
|
178
|
+
reportFlow(
|
|
179
|
+
node.init,
|
|
180
|
+
targetFromAnnotation(node.id.typeAnnotation),
|
|
181
|
+
`binding \`${node.id.name}\``,
|
|
182
|
+
);
|
|
183
|
+
},
|
|
184
|
+
PropertyDefinition(node) {
|
|
185
|
+
if (node.value === null) return;
|
|
186
|
+
reportFlow(
|
|
187
|
+
node.value,
|
|
188
|
+
targetFromAnnotation(node.typeAnnotation),
|
|
189
|
+
`property \`${sourceKeyName(context.sourceCode, node.key)}\``,
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
AccessorProperty(node) {
|
|
193
|
+
if (node.value === null) return;
|
|
194
|
+
reportFlow(
|
|
195
|
+
node.value,
|
|
196
|
+
targetFromAnnotation(node.typeAnnotation),
|
|
197
|
+
`property \`${sourceKeyName(context.sourceCode, node.key)}\``,
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
AssignmentExpression(node) {
|
|
201
|
+
if (node.operator !== "=" || node.left.type !== "Identifier") return;
|
|
202
|
+
const variable = resolveVariable(context.sourceCode, node.left);
|
|
203
|
+
if (variable === null) return;
|
|
204
|
+
const declarator = variableDeclarator(variable);
|
|
205
|
+
if (declarator === null || declarator.id.type !== "Identifier") return;
|
|
206
|
+
reportFlow(
|
|
207
|
+
node.right,
|
|
208
|
+
targetFromAnnotation(declarator.id.typeAnnotation),
|
|
209
|
+
`binding \`${declarator.id.name}\``,
|
|
210
|
+
);
|
|
211
|
+
},
|
|
212
|
+
ReturnStatement(node) {
|
|
213
|
+
if (node.argument === null) return;
|
|
214
|
+
const owner = enclosingFunction(node);
|
|
215
|
+
reportFlow(
|
|
216
|
+
node.argument,
|
|
217
|
+
targetFromAnnotation(owner?.returnType),
|
|
218
|
+
`return value of \`${functionName(context.sourceCode, owner)}\``,
|
|
219
|
+
);
|
|
220
|
+
},
|
|
221
|
+
ArrowFunctionExpression(node) {
|
|
222
|
+
if (node.body.type === "BlockStatement") return;
|
|
223
|
+
reportFlow(
|
|
224
|
+
node.body,
|
|
225
|
+
targetFromAnnotation(node.returnType),
|
|
226
|
+
`return value of \`${functionName(context.sourceCode, node)}\``,
|
|
227
|
+
);
|
|
228
|
+
},
|
|
229
|
+
TSAsExpression(node) {
|
|
230
|
+
if (environment === null || hasParentAssertion(node)) return;
|
|
231
|
+
reportFlow(
|
|
232
|
+
node.expression,
|
|
233
|
+
classifyWideningTarget(node.typeAnnotation, environment),
|
|
234
|
+
"assertion",
|
|
235
|
+
);
|
|
236
|
+
},
|
|
237
|
+
TSTypeAssertion(node) {
|
|
238
|
+
if (environment === null || hasParentAssertion(node)) return;
|
|
239
|
+
reportFlow(
|
|
240
|
+
node.expression,
|
|
241
|
+
classifyWideningTarget(node.typeAnnotation, environment),
|
|
242
|
+
"assertion",
|
|
243
|
+
);
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import type { ESTree, Scope, SourceCode, Variable } from "@oxlint/plugins";
|
|
4
|
+
|
|
5
|
+
const moduleMockMethods = new Set(["doMock", "mock", "unstable_mockModule"]);
|
|
6
|
+
|
|
7
|
+
function resolveVariable(
|
|
8
|
+
sourceCode: SourceCode,
|
|
9
|
+
identifier: ESTree.IdentifierReference,
|
|
10
|
+
): Variable | null {
|
|
11
|
+
let scope: Scope | null = sourceCode.getScope(identifier);
|
|
12
|
+
while (scope !== null) {
|
|
13
|
+
const variable = scope.set.get(identifier.name);
|
|
14
|
+
if (variable !== undefined) return variable;
|
|
15
|
+
scope = scope.upper;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function importedName(node: ESTree.Node): string | null {
|
|
21
|
+
if (node.type !== "ImportSpecifier") return null;
|
|
22
|
+
return node.imported.type === "Identifier" ? node.imported.name : node.imported.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isTestFrameworkObject(
|
|
26
|
+
sourceCode: SourceCode,
|
|
27
|
+
expression: ESTree.Expression,
|
|
28
|
+
): expression is ESTree.IdentifierReference {
|
|
29
|
+
if (expression.type !== "Identifier") return false;
|
|
30
|
+
if (
|
|
31
|
+
(expression.name === "vi" || expression.name === "jest") &&
|
|
32
|
+
sourceCode.isGlobalReference(expression)
|
|
33
|
+
) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const variable = resolveVariable(sourceCode, expression);
|
|
38
|
+
if (variable === null || variable.defs.length === 0) {
|
|
39
|
+
return expression.name === "vi" || expression.name === "jest";
|
|
40
|
+
}
|
|
41
|
+
return variable.defs.some((definition) => {
|
|
42
|
+
if (definition.type !== "ImportBinding" || definition.parent?.type !== "ImportDeclaration") {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const source = definition.parent.source.value;
|
|
46
|
+
const name = importedName(definition.node);
|
|
47
|
+
return (source === "vitest" && name === "vi") || (source === "@jest/globals" && name === "jest");
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function moduleMockCall(sourceCode: SourceCode, callee: ESTree.Expression): boolean {
|
|
52
|
+
if (!("property" in callee) || !("object" in callee) || !("computed" in callee)) return false;
|
|
53
|
+
if (!isTestFrameworkObject(sourceCode, callee.object)) return false;
|
|
54
|
+
const property = callee.property;
|
|
55
|
+
const method = callee.computed
|
|
56
|
+
? property.type === "Literal" &&
|
|
57
|
+
(property.value === "doMock" ||
|
|
58
|
+
property.value === "mock" ||
|
|
59
|
+
property.value === "unstable_mockModule")
|
|
60
|
+
? property.value
|
|
61
|
+
: null
|
|
62
|
+
: property.type === "Identifier"
|
|
63
|
+
? property.name
|
|
64
|
+
: null;
|
|
65
|
+
return method !== null && moduleMockMethods.has(method);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Ban test framework module mocking in favor of real dependency seams. */
|
|
69
|
+
export const noModuleMockingRule = defineRule({
|
|
70
|
+
meta: {
|
|
71
|
+
type: "problem",
|
|
72
|
+
docs: {
|
|
73
|
+
description:
|
|
74
|
+
"Disallow Vitest and Jest module mocking; tests must replace dependencies through real interfaces.",
|
|
75
|
+
},
|
|
76
|
+
messages: {
|
|
77
|
+
moduleMock:
|
|
78
|
+
"Replace module mocking with dependency injection through a real interface, service layer, or faithful test implementation.",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
createOnce(context) {
|
|
82
|
+
return {
|
|
83
|
+
CallExpression(node) {
|
|
84
|
+
if (node.callee.type === "Super" || node.callee.type === "V8IntrinsicExpression") return;
|
|
85
|
+
if (moduleMockCall(context.sourceCode, node.callee)) {
|
|
86
|
+
context.report({ node, messageId: "moduleMock" });
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import type { ESTree, SourceCode } from "@oxlint/plugins";
|
|
4
|
+
|
|
5
|
+
import { lexicalTypeParameterNames } from "../shared/lexical-type-parameters.ts";
|
|
6
|
+
|
|
7
|
+
type Parameter = ESTree.ParamPattern;
|
|
8
|
+
type ParameterOwner =
|
|
9
|
+
| ESTree.ArrowFunctionExpression
|
|
10
|
+
| ESTree.Function
|
|
11
|
+
| ESTree.TSCallSignatureDeclaration
|
|
12
|
+
| ESTree.TSConstructSignatureDeclaration
|
|
13
|
+
| ESTree.TSConstructorType
|
|
14
|
+
| ESTree.TSFunctionType
|
|
15
|
+
| ESTree.TSMethodSignature;
|
|
16
|
+
|
|
17
|
+
function parameterAnnotation(parameter: Parameter): ESTree.TSTypeAnnotation | null | undefined {
|
|
18
|
+
if (parameter.type === "TSParameterProperty") {
|
|
19
|
+
return parameterAnnotation(parameter.parameter);
|
|
20
|
+
}
|
|
21
|
+
if (parameter.type === "RestElement") {
|
|
22
|
+
return parameter.typeAnnotation ?? parameterAnnotation(parameter.argument);
|
|
23
|
+
}
|
|
24
|
+
if (parameter.type === "AssignmentPattern") {
|
|
25
|
+
return parameter.typeAnnotation ?? parameter.left.typeAnnotation;
|
|
26
|
+
}
|
|
27
|
+
return parameter.typeAnnotation;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parameterName(parameter: Parameter, sourceCode: SourceCode): string {
|
|
31
|
+
return parameter.type === "Identifier"
|
|
32
|
+
? parameter.name
|
|
33
|
+
: sourceCode.getText(parameter).replace(/\s*:\s*object\s*$/u, "");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Ban the broad object type on function inputs, including local aliases to object. */
|
|
37
|
+
export const noObjectParametersRule = defineRule({
|
|
38
|
+
meta: {
|
|
39
|
+
type: "problem",
|
|
40
|
+
docs: {
|
|
41
|
+
description:
|
|
42
|
+
"Disallow object function parameters; inputs must use an owner-provided type and be parsed at their boundary.",
|
|
43
|
+
},
|
|
44
|
+
messages: {
|
|
45
|
+
objectParameter:
|
|
46
|
+
"Parameter `{{parameter}}` uses the broad `object` type. Accept a named owner type; parse external input at its boundary before calling this function.",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
createOnce(context) {
|
|
50
|
+
const aliases = new Map<string, ESTree.TSType>();
|
|
51
|
+
|
|
52
|
+
const resolvesToObject = (
|
|
53
|
+
type: ESTree.TSType,
|
|
54
|
+
shadowedAliases: ReadonlySet<string>,
|
|
55
|
+
visited = new Set<string>(),
|
|
56
|
+
): boolean => {
|
|
57
|
+
if (type.type === "TSObjectKeyword") return true;
|
|
58
|
+
if (type.type === "TSParenthesizedType")
|
|
59
|
+
return resolvesToObject(type.typeAnnotation, shadowedAliases, visited);
|
|
60
|
+
if (type.type === "TSUnionType") {
|
|
61
|
+
return type.types.some((member) =>
|
|
62
|
+
resolvesToObject(member, shadowedAliases, visited),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (
|
|
66
|
+
type.type !== "TSTypeReference" ||
|
|
67
|
+
type.typeName.type !== "Identifier" ||
|
|
68
|
+
(type.typeArguments !== null &&
|
|
69
|
+
type.typeArguments !== undefined &&
|
|
70
|
+
type.typeArguments.params.length > 0) ||
|
|
71
|
+
visited.has(type.typeName.name) ||
|
|
72
|
+
shadowedAliases.has(type.typeName.name)
|
|
73
|
+
) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const alias = aliases.get(type.typeName.name);
|
|
77
|
+
if (alias === undefined) return false;
|
|
78
|
+
const nextVisited = new Set(visited);
|
|
79
|
+
nextVisited.add(type.typeName.name);
|
|
80
|
+
return resolvesToObject(alias, shadowedAliases, nextVisited);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const checkParameters = (node: ParameterOwner) => {
|
|
84
|
+
const shadowedAliases = lexicalTypeParameterNames(
|
|
85
|
+
node,
|
|
86
|
+
context.sourceCode.visitorKeys,
|
|
87
|
+
);
|
|
88
|
+
for (const parameter of node.params) {
|
|
89
|
+
const annotation = parameterAnnotation(parameter);
|
|
90
|
+
if (annotation === null || annotation === undefined) continue;
|
|
91
|
+
if (!resolvesToObject(annotation.typeAnnotation, shadowedAliases)) continue;
|
|
92
|
+
context.report({
|
|
93
|
+
node: annotation.typeAnnotation,
|
|
94
|
+
messageId: "objectParameter",
|
|
95
|
+
data: { parameter: parameterName(parameter, context.sourceCode) },
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
Program(node) {
|
|
102
|
+
aliases.clear();
|
|
103
|
+
for (const statement of node.body) {
|
|
104
|
+
const declaration =
|
|
105
|
+
statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
106
|
+
if (
|
|
107
|
+
declaration?.type === "TSTypeAliasDeclaration" &&
|
|
108
|
+
(declaration.typeParameters === null || declaration.typeParameters === undefined)
|
|
109
|
+
) {
|
|
110
|
+
aliases.set(declaration.id.name, declaration.typeAnnotation);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
ArrowFunctionExpression: checkParameters,
|
|
115
|
+
FunctionDeclaration: checkParameters,
|
|
116
|
+
FunctionExpression: checkParameters,
|
|
117
|
+
TSCallSignatureDeclaration: checkParameters,
|
|
118
|
+
TSConstructSignatureDeclaration: checkParameters,
|
|
119
|
+
TSConstructorType: checkParameters,
|
|
120
|
+
TSDeclareFunction: checkParameters,
|
|
121
|
+
TSEmptyBodyFunctionExpression: checkParameters,
|
|
122
|
+
TSFunctionType: checkParameters,
|
|
123
|
+
TSMethodSignature: checkParameters,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import { isGlobalReflectMethodCall } from "../shared/reflect-method.ts";
|
|
4
|
+
|
|
5
|
+
/** Ban Reflect.apply, which bypasses ordinary typed function calls. */
|
|
6
|
+
export const noReflectApplyRule = defineRule({
|
|
7
|
+
meta: {
|
|
8
|
+
type: "problem",
|
|
9
|
+
docs: {
|
|
10
|
+
description:
|
|
11
|
+
"Disallow Reflect.apply; call typed functions directly or model dynamic dispatch behind an interface.",
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
reflectApply:
|
|
15
|
+
"Replace `Reflect.apply` with a typed function call. Model dynamic dispatch behind a named interface.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
createOnce(context) {
|
|
19
|
+
return {
|
|
20
|
+
CallExpression(node) {
|
|
21
|
+
if (node.callee.type === "Super" || node.callee.type === "V8IntrinsicExpression") return;
|
|
22
|
+
if (isGlobalReflectMethodCall(context.sourceCode, node.callee, "apply")) {
|
|
23
|
+
context.report({ node, messageId: "reflectApply" });
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import { isGlobalReflectMethodCall } from "../shared/reflect-method.ts";
|
|
4
|
+
|
|
5
|
+
/** Ban Reflect.get, which bypasses ordinary property access and useful type evidence. */
|
|
6
|
+
export const noReflectGetRule = defineRule({
|
|
7
|
+
meta: {
|
|
8
|
+
type: "problem",
|
|
9
|
+
docs: {
|
|
10
|
+
description:
|
|
11
|
+
"Disallow Reflect.get; use typed property access or parse dynamic input into a domain type.",
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
reflectGet:
|
|
15
|
+
"Replace `Reflect.get` with typed property access. Parse dynamic input into a named domain type before reading it.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
createOnce(context) {
|
|
19
|
+
return {
|
|
20
|
+
CallExpression(node) {
|
|
21
|
+
if (node.callee.type === "Super" || node.callee.type === "V8IntrinsicExpression") return;
|
|
22
|
+
if (isGlobalReflectMethodCall(context.sourceCode, node.callee, "get")) {
|
|
23
|
+
context.report({ node, messageId: "reflectGet" });
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
|
|
3
|
+
import type { ESTree } from "@oxlint/plugins";
|
|
4
|
+
|
|
5
|
+
type RuntimeFunction = ESTree.ArrowFunctionExpression | ESTree.Function;
|
|
6
|
+
|
|
7
|
+
function isRuntimeFunction(node: ESTree.Node): node is RuntimeFunction {
|
|
8
|
+
return (
|
|
9
|
+
node.type === "ArrowFunctionExpression" ||
|
|
10
|
+
node.type === "FunctionDeclaration" ||
|
|
11
|
+
node.type === "FunctionExpression"
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isInsideTypeGuard(node: ESTree.Node): boolean {
|
|
16
|
+
let current: ESTree.Node | null = node.parent;
|
|
17
|
+
while (current !== null && current.type !== "Program") {
|
|
18
|
+
if (isRuntimeFunction(current)) {
|
|
19
|
+
return current.returnType?.typeAnnotation.type === "TSTypePredicate";
|
|
20
|
+
}
|
|
21
|
+
current = current.parent;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Disallow runtime typeof checks that narrow unparsed values instead of decoding them. */
|
|
27
|
+
export const noRuntimeTypeofRule = defineRule({
|
|
28
|
+
meta: {
|
|
29
|
+
type: "problem",
|
|
30
|
+
docs: {
|
|
31
|
+
description:
|
|
32
|
+
"Disallow runtime typeof checks; external values must be decoded into meaningful types at their I/O boundary.",
|
|
33
|
+
},
|
|
34
|
+
messages: {
|
|
35
|
+
runtimeTypeof:
|
|
36
|
+
"A `typeof` check narrows a representation without establishing its contract. Parse input at its I/O boundary, then branch on the domain value.",
|
|
37
|
+
},
|
|
38
|
+
schema: [
|
|
39
|
+
{
|
|
40
|
+
type: "object",
|
|
41
|
+
properties: {
|
|
42
|
+
allowInTypeGuards: { type: "boolean" },
|
|
43
|
+
},
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
defaultOptions: [{ allowInTypeGuards: false }],
|
|
48
|
+
},
|
|
49
|
+
createOnce(context) {
|
|
50
|
+
return {
|
|
51
|
+
UnaryExpression(node) {
|
|
52
|
+
const option = context.options?.[0];
|
|
53
|
+
const allowInTypeGuards =
|
|
54
|
+
typeof option === "object" &&
|
|
55
|
+
option !== null &&
|
|
56
|
+
!Array.isArray(option) &&
|
|
57
|
+
option.allowInTypeGuards === true;
|
|
58
|
+
if (
|
|
59
|
+
node.operator === "typeof" &&
|
|
60
|
+
(!allowInTypeGuards || !isInsideTypeGuard(node))
|
|
61
|
+
) {
|
|
62
|
+
context.report({ node, messageId: "runtimeTypeof" });
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
import type { ESTree } from "@oxlint/plugins";
|
|
3
|
+
|
|
4
|
+
const FORBIDDEN_SYMBOL_NAME = "shape";
|
|
5
|
+
|
|
6
|
+
function containsForbiddenSymbolName(name: string): boolean {
|
|
7
|
+
return name.toLowerCase().includes(FORBIDDEN_SYMBOL_NAME);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Ban the case-insensitive substring "shape" in every JavaScript and TypeScript symbol name. */
|
|
11
|
+
export const noForbiddenTermInSymbolNamesRule = defineRule({
|
|
12
|
+
meta: {
|
|
13
|
+
type: "problem",
|
|
14
|
+
docs: {
|
|
15
|
+
description:
|
|
16
|
+
'Disallow the case-insensitive substring "shape" in JavaScript, TypeScript, private, and JSX symbol names.',
|
|
17
|
+
},
|
|
18
|
+
messages: {
|
|
19
|
+
forbiddenSymbolName:
|
|
20
|
+
'Rename symbol "{{name}}" for its domain role; "shape" describes structure rather than ownership.',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
createOnce(context) {
|
|
24
|
+
const reportForbiddenSymbolName = (node: ESTree.Node & { name: string }) => {
|
|
25
|
+
if (!containsForbiddenSymbolName(node.name)) return;
|
|
26
|
+
context.report({
|
|
27
|
+
node,
|
|
28
|
+
messageId: "forbiddenSymbolName",
|
|
29
|
+
data: { name: node.name },
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
Identifier: reportForbiddenSymbolName,
|
|
35
|
+
PrivateIdentifier: reportForbiddenSymbolName,
|
|
36
|
+
JSXIdentifier: reportForbiddenSymbolName,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|