Fix CodeFactor duplication in CLI and SDK primitives

Merged
UN
4mo ago
+267-313

Summary

  • Single-source create/update --unset field metadata in shared-unset-fields.ts and reuse it from both command handlers.
  • Share create/update mutation option keys and SDK bulk mutation filter contracts to remove duplicated shipped tables.
  • Keep CodeFactor focused on actionable source by excluding generated package runtime loaders, generated plugin MCP launchers, and tests enforced by repo gates; update the CodeFactor docs pointer.
  • Record PM evidence under pm-92if, pm-fmjy, and pm-arzz, including GitHub/dependency/security/changelog/Sentry/telemetry findings.

Verification

  • pnpm build
  • node scripts/run-tests.mjs test -- tests/unit/commands/create-command.spec.ts tests/unit/commands/update-command.spec.ts tests/unit/packages/runtime-loaders.spec.ts tests/unit/scripts/gen-package-runtime-loaders.spec.ts tests/unit/scripts/gen-plugin-mcp-wrappers.spec.ts tests/unit/plugins/pm-mcp-server.spec.ts tests/unit/packages/package-manifest.spec.ts (7 files, 254 tests)
  • pnpm contracts:check
  • pnpm quality:static
  • pnpm typecheck
  • pnpm security:scan
  • node scripts/run-tests.mjs coverage (256 files, 5133 tests, 100% statements/branches/functions/lines)
  • pnpm changelog:pm:check (pm-changelog 2026.6.20, CHANGELOG.md unchanged)
  • manual temp-dir smoke with isolated PM_PATH/PM_GLOBAL_PATH: init, create, update --unset, package install todos, package doctor deep, contracts, health
  • node scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effort
  • pm telemetry stats --json

GitHub / release notes

  • No open Dependabot alerts and no open code scanning alerts at branch creation time.
  • Existing issue #374 remains externally blocked on missing RELEASE_PAT in the release environment; this branch does not require code changes for that failure.

Summary by Sourcery

Deduplicate shared CLI unset-field metadata and bulk mutation option/filter contracts while tightening CodeFactor analysis scope and recording associated PM evidence.

Enhancements:

  • Single-source unset-field definitions for create and update CLI commands via shared metadata.
  • Share common mutation command option key lists between create and update item type registry entries.
  • Reuse a unified bulk-mutation filter option contract across SDK update-many and close-many tool contracts.

Build:

  • Refine CodeFactor configuration to exclude generated loaders, generated plugin launchers, and tests from analysis.

Chores:

  • Add and update PM agent evidence files for the referenced product-management tasks and epics.

Summary by cubic

Dedupes CLI and SDK primitives flagged by CodeFactor by single-sourcing unset field metadata, shared mutation option keys, and bulk filter contracts. Updates .codefactor.yml to ignore generated loaders/launchers and tests so reports focus on shipped code; no behavior changes.

  • Refactors
    • Added src/cli/commands/shared-unset-fields.ts and reused in create.ts/update.ts; replaced slice-based update ordering with named groups around close-reason; kept author placement for create.
    • Extracted COMMON_MUTATION_COMMAND_OPTION_KEYS in src/core/item/type-registry.ts and reused across create/update; documented core↔CLI alignment boundary.
    • Unified SDK bulk mutation filter contracts via TOOL_BULK_MUTATION_FILTER_OPTION_CONTRACTS, reused by update-many and close-many.
    • Updated .codefactor.yml docs link and excluded packages/**/runtime-loader.ts, plugins/**/scripts/pm-mcp-server.mjs, and tests/** from analysis.